├── .gitignore ├── helper-scripts ├── readme ├── uridecode.pl ├── get_all_parameters.pl ├── IEF_Google_Searches_TSV_to_list.pl ├── convertTime.pl ├── testGSERPent.pl └── parameter_values.pl ├── ved-decoder-master ├── lib │ └── google │ │ ├── __init__.py │ │ ├── __init__.pyc │ │ └── protobuf │ │ ├── __init__.pyc │ │ ├── message.pyc │ │ ├── descriptor.pyc │ │ ├── reflection.pyc │ │ ├── text_format.pyc │ │ ├── text_encoding.pyc │ │ ├── descriptor_pb2.pyc │ │ ├── descriptor_pool.pyc │ │ ├── internal │ │ ├── decoder.pyc │ │ ├── encoder.pyc │ │ ├── __init__.pyc │ │ ├── containers.pyc │ │ ├── wire_format.pyc │ │ ├── python_message.pyc │ │ ├── type_checkers.pyc │ │ ├── enum_type_wrapper.pyc │ │ ├── message_listener.pyc │ │ ├── api_implementation.pyc │ │ ├── import_test_package │ │ │ ├── __init__.py │ │ │ ├── inner.proto │ │ │ └── outer.proto │ │ ├── more_extensions_dynamic.proto │ │ ├── more_extensions.proto │ │ ├── test_bad_identifiers.proto │ │ ├── missing_enum_values.proto │ │ ├── more_messages.proto │ │ ├── factory_test1.proto │ │ ├── descriptor_pool_test2.proto │ │ ├── message_set_extensions.proto │ │ ├── text_encoding_test.py │ │ ├── descriptor_database_test.py │ │ ├── descriptor_pool_test1.proto │ │ ├── packed_field_test.proto │ │ ├── message_listener.py │ │ ├── enum_type_wrapper.py │ │ ├── factory_test2.proto │ │ ├── proto_builder_test.py │ │ ├── api_implementation.cc │ │ ├── api_implementation.py │ │ ├── service_reflection_test.py │ │ ├── symbol_database_test.py │ │ └── message_factory_test.py │ │ ├── symbol_database.pyc │ │ ├── descriptor_database.pyc │ │ ├── pyext │ │ ├── README │ │ ├── proto2_api_test.proto │ │ ├── python_protobuf.h │ │ ├── python.proto │ │ ├── cpp_message.py │ │ ├── scoped_pyobject_ptr.h │ │ ├── descriptor.h │ │ ├── descriptor_containers.h │ │ ├── scalar_map_container.h │ │ ├── repeated_scalar_container.h │ │ ├── message_map_container.h │ │ ├── extension_dict.h │ │ └── descriptor_pool.h │ │ ├── __init__.py │ │ ├── text_encoding.py │ │ ├── reflection.py │ │ ├── descriptor_database.py │ │ ├── proto_builder.py │ │ └── message_factory.py ├── proto │ ├── ved_pb2.pyc │ ├── __init__.pyc │ ├── ved.ta.attempt.proto │ └── ved.proto ├── veds-old-format.txt ├── Makefile ├── bindump.py ├── README.md ├── LICENSE ├── veds-new-format.txt └── ved.py ├── history.txt ├── tests ├── image search.txt ├── firefox.txt ├── gmail_youtube_referral.txt ├── test2.txt ├── test1.txt └── urls.txt ├── README.md └── google-ei-time.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /helper-scripts/readme: -------------------------------------------------------------------------------- 1 | helper-scripts directory 2 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/__init__.py: -------------------------------------------------------------------------------- 1 | __import__('pkg_resources').declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /ved-decoder-master/proto/ved_pb2.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/proto/ved_pb2.pyc -------------------------------------------------------------------------------- /ved-decoder-master/proto/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/proto/__init__.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/__init__.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/__init__.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/message.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/message.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/descriptor.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/descriptor.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/reflection.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/reflection.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/text_format.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/text_format.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/text_encoding.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/text_encoding.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/descriptor_pb2.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/descriptor_pb2.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/descriptor_pool.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/descriptor_pool.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/decoder.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/internal/decoder.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/encoder.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/internal/encoder.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/symbol_database.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/symbol_database.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/internal/__init__.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/descriptor_database.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/descriptor_database.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/containers.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/internal/containers.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/wire_format.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/internal/wire_format.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/python_message.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/internal/python_message.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/type_checkers.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/internal/type_checkers.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/enum_type_wrapper.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/internal/enum_type_wrapper.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/message_listener.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/internal/message_listener.pyc -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/api_implementation.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/randomaccess3/googleURLParser/HEAD/ved-decoder-master/lib/google/protobuf/internal/api_implementation.pyc -------------------------------------------------------------------------------- /ved-decoder-master/veds-old-format.txt: -------------------------------------------------------------------------------- 1 | 0CC8QFjAA 2 | 0CCoQFjAA 3 | 0CCwQFjAA 4 | 0CC0QFjAA 5 | 0CCkQFjAA 6 | 0CAUQ_AUoAA 7 | 0CAoQvwU 8 | 1t:429,r:65,s:500,i:199 9 | 0CPwCEBYwPw 10 | 0CPwBENUCKAU 11 | 0CPoBEBYwFQ 12 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/README: -------------------------------------------------------------------------------- 1 | This is the 'v2' C++ implementation for python proto2. 2 | 3 | It is active when: 4 | 5 | PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp 6 | PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2 7 | -------------------------------------------------------------------------------- /ved-decoder-master/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: proto/ved_pb2.py 3 | 4 | proto/ved_pb2.py:proto/ved.proto 5 | protoc -I. --python_out=. proto/ved.proto 6 | 7 | #patch the generated code (I hate this part!) 8 | # cat proto/ved_pb2.py|sed 's/google./googlepb./' > proto/ved_pb2.py.txt 9 | # mv proto/ved_pb2.py.txt proto/ved_pb2.py 10 | -------------------------------------------------------------------------------- /helper-scripts/uridecode.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | #usage uridecode "url" 4 | 5 | use strict; 6 | use URI::Escape; 7 | 8 | my $url = shift; 9 | 10 | printEqDivider(); 11 | print $url."\n"; 12 | printEqDivider(); 13 | $url = uri_unescape($url); 14 | print $url."\n"; 15 | print "\n"; 16 | 17 | sub printEqDivider{ 18 | my $n = 150; 19 | my $character = '='; 20 | my $text =~ s/^(.*)/$character x $n . $1/mge; 21 | print $text."\n"; 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /history.txt: -------------------------------------------------------------------------------- 1 | https://www.google.com.au/webhp?hl=en&ictx=2&sa=X&ved=0ahUKEwipjtPT-LHSAhXkzVQKHSQKDZgQPQgD#hl=en&q=hello+world&*|Tue Feb 28 15:21:23 2017 2 | https://www.google.com/search?biw=1366&bih=694&tbm=isch&q=superman&chips=q:superman,g_1:supergirl&sa=X&ved=0ahUKEwihv-Hy4MHSAhUqrFQKHdtMD4IQ3VYIHSgA&dpr=1|Mon Mar 6 22:32:47 2017 3 | https://www.google.com.au/search?q=supermn&nfpr=1&sa=X&ved=0ahUKEwi31PPG5MHSAhUHkZQKHXapDLoQvgUIGSgB&biw=1366&bih=694|Mon Mar 6 22:42:49 2017 4 | -------------------------------------------------------------------------------- /ved-decoder-master/bindump.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from struct import unpack 3 | import base64 4 | import sys 5 | 6 | def try_decode(s): 7 | try: 8 | return base64.b64decode(s+'=====', '_-') 9 | except TypeError: 10 | return None 11 | 12 | if __name__ == '__main__': 13 | for line in sys.stdin: 14 | line = line.strip() 15 | if not line: 16 | continue 17 | packed = try_decode(line[1:]) 18 | if not packed: 19 | print line 20 | continue 21 | unpacked = unpack('B'*len(packed), packed) 22 | 23 | print '|'.join(map(lambda x: '{0:08b}'.format(x), unpacked)) 24 | -------------------------------------------------------------------------------- /tests/image search.txt: -------------------------------------------------------------------------------- 1 | # Image search 2 | # It's the same picture but different options selected 3 | # The VED is the only thing that's different (outside of the link) 4 | https://www.google.com.au/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&ved=0ahUKEwi_p5LyyrPRAhUHlpQKHVrFBAAQjxwIAw&url=https%3A%2F%2Fenterprise.google.com%2Fsearch%2Fproducts%2Fgss.html&psig=AFQjCNFGIpYEFIr9QvFaLjSahpT75yLBQg&ust=1484000519706050 | click on an image and view image 5 | https://www.google.com.au/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&ved=0ahUKEwimwobwzLPRAhVGNJQKHUvMCIgQjBwIBA&url=https%3A%2F%2Flh4.googleusercontent.com%2FenVZiSNpLcn_qa1u8iLJHT8NcxqE4TGuShfiKvgXuR6EmK_2bB3f5W4ptSI2HctW8byaK6WcZQ%3Ds640-h400-e365&psig=AFQjCNFGIpYEFIr9QvFaLjSahpT75yLBQg&ust=1484000519706050 | click on an image and visit page -------------------------------------------------------------------------------- /tests/firefox.txt: -------------------------------------------------------------------------------- 1 | https://www.google.com.au/search?q=source%3Dlmns&ie=utf-8&oe=utf-8&client=firefox-b&gfe_rd=cr&ei=gV1tWN29F7PM8gep85CoDg | search from the firefox new tab 2 | https://www.google.com.au/search?q=source%3Dlmns&ie=utf-8&oe=utf-8&client=firefox-b&gfe_rd=cr&ei=aF5tWNqsJKzM8gf_-YBw | search from search box after initial search 3 | https://www.google.com.au/search?q=source%3Dlmns&ie=utf-8&oe=utf-8&client=firefox-b&gfe_rd=cr&ei=jF5tWPCsGazM8gf_-YBw | search from search box new window 4 | https://www.google.com.au/search?q=new+search&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&ei=sF5tWP3vD6zM8gf_-YBw | new search (after initial search) in address bar 5 | 6 | 7 | #Additional testing on firefox - should provide different results but doesnt 8 | https://www.google.com.au/search?q=can+you+run+strings+from+encase+console&ie=utf-8&oe=utf-8&client=firefox-b&gfe_rd=cr&ei=0IVtWPK7EKjM8gfk8raoAg | Search with no +'s between words 9 | https://www.google.com.au/search?q=can%2Byou%2Brun%2Bstrings%2Bfrom%2Bencase%2Bconsole&ie=utf-8&oe=utf-8&client=firefox-b&gfe_rd=cr&ei=HYZtWOu4AajM8gfk8raoAg | search with +'s between words -------------------------------------------------------------------------------- /ved-decoder-master/README.md: -------------------------------------------------------------------------------- 1 | ved-decoder 2 | =========== 3 | 4 | A decoder for the ved parameter of referrer URIs from google written in python 5 | 6 | To find out, what the purpose of this repository is, please read [Google Referrer Query Strings Debunked](http://gqs-decoder.blogspot.com/2013/08/google-referrer-query-strings-debunked-part-1.html). 7 | 8 | You can also try out a [web version](//gqs-decoder.appspot.com) of this decoder. 9 | 10 | Pull requests welcome! 11 | 12 | running 13 | ======= 14 | 15 | ``cat veds.txt|./ved.py`` 16 | 17 | hacking 18 | ======= 19 | 20 | install google protobuf compiler: 21 | 22 | ``apt-get install protobuf-compiler`` or 23 | ``brew install protobuf`` or 24 | [install protobuf from source](https://code.google.com/p/protobuf/) 25 | 26 | modify ved.proto or ved.py and recompile the .proto-file via 27 | ``make all`` 28 | 29 | notes 30 | ===== 31 | 32 | a modified copy of python-protobuf 2.5.0 is included in this repository. it is licensed via [New BSD License](http://opensource.org/licenses/BSD-3-Clause). The reason for that is, that in Google App Engine (GAE), you cannot use packages from the google namespace. 33 | -------------------------------------------------------------------------------- /ved-decoder-master/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Benjamin Schulz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /tests/gmail_youtube_referral.txt: -------------------------------------------------------------------------------- 1 | # Referral link for a youtube video out of an email 2 | # May only apply to google properties 3 | # has a timestamp in it relating to when the user clicked on the link, run both queries and you can see the ust time is different 4 | # To test: is this timestamp a network time (most probably) 5 | 6 | # Additional testing suggests that this time may not always be accurate as to when the user clicked the link. 7 | # Also only works from the Youtube subscription links, not just sending a link to youtube to someone by pasting the URL 8 | 9 | https://www.google.com/url?hl=en&q=https://www.youtube.com/attribution_link?a%3Dxqp9jjcoVUI%26u%3D/watch?v%253DPfNgeZyALEo%2526feature%253Dem-subs_digest%26g%3D8VfO5Yf4rrki5n9NcmHK7WrVj6JqSxdMuN3pQWu-TnDQhuyUz18qfK6d8FeGe_sjkCUuryqdAnmLVG8RNx5a7cPPPZd4tm7WChdRhoJzoe9XNjKYAvxA3H1Th2OHY4eSAczHQsJvmbD2rBE79v9GsJuNppaACByR-xwx41YTPhYL6_2N6Szb&source=gmail&ust=1483051552954000&usg=AFQjCNGuKYYp2jwhDkADVQ8_T0hO-0Scrw 10 | https://www.google.com/url?hl=en&q=https://www.youtube.com/attribution_link?a%3Dxqp9jjcoVUI%26u%3D/watch?v%253DPfNgeZyALEo%2526feature%253Dem-subs_digest%26g%3D8VfO5Yf4rrki5n9NcmHK7WrVj6JqSxdMuN3pQWu-TnDQhuyUz18qfK6d8FeGe_sjkCUuryqdAnmLVG8RNx5a7cPPPZd4tm7WChdRhoJzoe9XNjKYAvxA3H1Th2OHY4eSAczHQsJvmbD2rBE79v9GsJuNppaACByR-xwx41YTPhYL6_2N6Szb&source=gmail&ust=1483063992207000&usg=AFQjCNGGetShTcCuVE80aStSkPoIK-_3Uw 11 | -------------------------------------------------------------------------------- /helper-scripts/get_all_parameters.pl: -------------------------------------------------------------------------------- 1 | # build a list of unique parameters 2 | 3 | use strict; 4 | use Getopt::Long; 5 | use URI; 6 | use URI::Escape; 7 | use URI::Split qw(uri_split uri_join); 8 | use List::MoreUtils qw(uniq); 9 | 10 | my @parameters; 11 | my %config; 12 | Getopt::Long::Configure("prefix_pattern=(-|\/)"); 13 | GetOptions(\%config, qw(file|f=s help|?|h)); 14 | 15 | if ($config{help} || !%config) { 16 | _help(); 17 | exit; 18 | } 19 | 20 | my $file = $config{file}; 21 | open (FH, "<", $file); 22 | 23 | foreach my $line (){ 24 | chomp $line; 25 | next if (!defined($line)); 26 | #skip blank or commented out lines 27 | 28 | next if $line =~ m/^\#/; 29 | next if $line =~ m/^$/; 30 | 31 | my ($url, $comment) = split /\|/, $line; 32 | 33 | #change # to & to remove "fragment" 34 | $url =~ s/\#/\&/g; 35 | 36 | my $u = URI->new($url); 37 | my ($scheme, $domain, $path, $query, $frag) = uri_split($u); 38 | 39 | my %query_parameters = $u->query_form($u); 40 | 41 | push @parameters, keys %query_parameters; 42 | } 43 | 44 | 45 | my @uniq = uniq @parameters; 46 | 47 | print join("\n", @uniq), "\n"; 48 | 49 | sub _help { 50 | print<< "EOT"; 51 | ----------------------------------------------------------- 52 | Print out list of unique parameters from a list of urls in GSERPant.pl input format 53 | 54 | -f|file ....... input file 55 | -h|help ....... prints this help screen 56 | 57 | No validation on the input 58 | ----------------------------------------------------------- 59 | EOT 60 | } -------------------------------------------------------------------------------- /tests/test2.txt: -------------------------------------------------------------------------------- 1 | # test to compare parameters 2 | # I opened google chrome (signed in). Did a search straight from the address bar for superman 3 | # I change the tab to images and saved the url 4 | # I then added a 2 to the end of superman and performed the search 5 | # I then opened a new tab, searched for superman 2 and saved the url 6 | # I changed the tab to image search and saved the url 7 | # I then searched again for superman in a new tab and change the page to image search and saved the URL 8 | # Clicked on fourth image and saved the link from visit page 9 | 10 | https://www.google.com.au/search?q=superman&safe=off&espv=2&source=lnms&tbm=isch&sa=X&ved=0ahUKEwj6iJaD467RAhVStJQKHbGDA1kQ_AUICCgB&biw=1366&bih=671 | search from google chrome url bar (signed in) for superman 11 | https://www.google.com.au/search?safe=off&espv=2&biw=1366&bih=671&tbm=isch&sa=1&q=superman+2&oq=superman+2&gs_l=img.3..0l10.18312.18779.0.18990.2.2.0.0.0.0.201.399.0j1j1.2.0....0...1c.1.64.img..0.2.398...0i67k1.6N5zxlqhJ5A | search in search box from previous search for superman 2 (added 2) 12 | https://www.google.com.au/search?q=superman+2&oq=superman+2&aqs=chrome.0.69i59j69i60l2j69i61.999j0j4&sourceid=chrome&ie=UTF-8 | new tab search for superman 2 13 | https://www.google.com.au/search?q=superman+2&safe=off&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjiraKZ467RAhUEI5QKHfsaATMQ_AUICCgB&biw=1366&bih=671 | change to image search 14 | https://www.google.com.au/search?q=superman&safe=off&source=lnms&tbm=isch&sa=X&ved=0ahUKEwie2ri6467RAhWBxZQKHUehAogQ_AUICCgB&biw=1366&bih=671 | new tab search for superman, change to image search 15 | https://www.google.com.au/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwjpkPW55K7RAhWEupQKHXPBCkkQjxwIAw&url=http%3A%2F%2Fwww.dccomics.com%2Fcharacters%2Fsuperman&psig=AFQjCNHamGIxXv_b0mZsUABU1kGBF-IBKw&ust=1483835322693616 16 | -------------------------------------------------------------------------------- /helper-scripts/IEF_Google_Searches_TSV_to_list.pl: -------------------------------------------------------------------------------- 1 | 2 | # Convert TSV to list format 3 | # input file is first argument 4 | 5 | use strict; 6 | use Getopt::Long; 7 | 8 | 9 | my %config; 10 | Getopt::Long::Configure("prefix_pattern=(-|\/)"); 11 | GetOptions(\%config, qw(file|f=s help|?|h)); 12 | 13 | if ($config{help} || !%config) { 14 | _help(); 15 | exit; 16 | } 17 | my $file = $config{file}; 18 | open (FH, "<", $file); 19 | 20 | my $i=0; 21 | 22 | #first line is the header 23 | my $line = ; 24 | print "# Parsed TSV file: $file\n"; 25 | 26 | 27 | foreach $line (){ 28 | chomp $line; 29 | my @args = split /\t/, $line; 30 | 31 | 32 | my $search_term = $args[1]; 33 | my $url = $args[2]; 34 | my $date = $args[3]; 35 | 36 | #skip non searches 37 | next if $url =~ m/http[s]:\/\/support\.google/; 38 | 39 | if ($date ne ""){ 40 | print "$url| Search for $search_term at $date UTC\n"; 41 | } 42 | else{ 43 | print "$url| Search for $search_term\n"; 44 | } 45 | 46 | } 47 | close(FH); 48 | 49 | #TSV output fields 50 | # Record 51 | # Search Term 52 | # URL 53 | # Date/Time - (UTC) (dd/MM/yyyy) 54 | # Date/Time - Local Time (yyyy-mm-dd) 55 | # Original Search Query 56 | # Search Session Start Date/Time - (UTC) (dd/MM/yyyy) 57 | # Web Page Title 58 | # Previous Queries 59 | # Artifact 60 | # Artifact 61 | # ID 62 | # Source 63 | # Located At 64 | # Evidence Number 65 | 66 | 67 | 68 | 69 | sub _help { 70 | print<< "EOT"; 71 | ----------------------------------------------------------- 72 | Converts IEF TSV format into list format for GSERPant 73 | 74 | -f|file ....... input file 75 | -h|help ....... prints this help screen 76 | 77 | No validation on the input 78 | ----------------------------------------------------------- 79 | EOT 80 | } -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/__init__.py: -------------------------------------------------------------------------------- 1 | # Protocol Buffers - Google's data interchange format 2 | # Copyright 2008 Google Inc. All rights reserved. 3 | # https://developers.google.com/protocol-buffers/ 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | # Copyright 2007 Google Inc. All Rights Reserved. 32 | 33 | __version__ = '3.0.0a4' 34 | -------------------------------------------------------------------------------- /helper-scripts/convertTime.pl: -------------------------------------------------------------------------------- 1 | # convert time 2 | 3 | # adding loop for continuous input 4 | 5 | 6 | use Getopt::Long; 7 | 8 | my %config; 9 | Getopt::Long::Configure("prefix_pattern=(-|\/)"); 10 | GetOptions(\%config,qw(unix|u=s timezone|tz=s loop|l help|?|h)); 11 | 12 | 13 | 14 | 15 | #my $name = ; 16 | my $unix = $config{unix} if ($config{unix}); 17 | 18 | while (1){ 19 | printUnix($unix) if ($unix); 20 | 21 | if ($config{loop}){ 22 | print "\n"; 23 | $unix = <>; 24 | chomp $unix; 25 | last if ($unix eq "q"); # quit if the user types q 26 | } 27 | else{ 28 | last; 29 | } 30 | } 31 | 32 | 33 | 34 | if ($config{help} || !%config) { 35 | _help(); 36 | exit; 37 | } 38 | 39 | sub printUnix($){ 40 | my $unix = shift; 41 | 42 | if ($config{timezone}){ 43 | print modify_unix_timezone($unix); 44 | } 45 | else{ 46 | print "$unix = ".gmtime($unix); 47 | } 48 | } 49 | 50 | 51 | sub _help { 52 | print<< "EOT"; 53 | convertTime v.$VERSION 54 | convertTime [-u time] [-h] 55 | Convert timestamps 56 | -u|unix ...........Unix timestamp 57 | -tz|timezone ......Timezone modifier (ie +5, -5) 58 | -l|loop ...........Loop infinitely 59 | -h.................Help 60 | EOT 61 | } 62 | 63 | 64 | 65 | #returns a modified unix timestamp 66 | sub modify_unix_timezone($){ 67 | my $unix = shift; 68 | my $timezone_modifier = $config{timezone}; 69 | my $timezone = $timezone_modifier * (60 * 60); 70 | my $comment = ""; 71 | my $gm_unix = gmtime($unix+$timezone); 72 | 73 | # check to see if its either +12,12,0, -12, throw error if not 74 | 75 | if ($timezone_modifier =~ /-/){ 76 | $comment = "$unix UTC = $gm_unix UTC$timezone_modifier" ; 77 | } 78 | else { 79 | $comment = "$unix UTC = $gm_unix UTC+$timezone_modifier"; 80 | } 81 | return $comment; 82 | } -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/import_test_package/__init__.py: -------------------------------------------------------------------------------- 1 | # Protocol Buffers - Google's data interchange format 2 | # Copyright 2008 Google Inc. All rights reserved. 3 | # https://developers.google.com/protocol-buffers/ 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Sample module importing a nested proto from itself.""" 32 | 33 | from google.protobuf.internal.import_test_package import outer_pb2 as myproto 34 | -------------------------------------------------------------------------------- /ved-decoder-master/veds-new-format.txt: -------------------------------------------------------------------------------- 1 | 0CBMQvSc 2 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ2x8ICygF 3 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ2h8IDCgA 4 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ3B8IEQ 5 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ-CcIGQ 6 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ-icIGw 7 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQGggd 8 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ7B0IITAA 9 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQqR8IIjAA 10 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9AEILCgAMAE 11 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9QEILTAB 12 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9AEILigBMAI 13 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9QEILzAC 14 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9AEIMCgCMAM 15 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9QEIMTAD 16 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9AEIMigDMAQ 17 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9QEIMzAE 18 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9AEINCgEMAU 19 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9QEINTAF 20 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9AEINigFMAY 21 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ9QEINzAG 22 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQyjcIOA 23 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ7B0IPTAH 24 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQqR8IPjAH 25 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ7B0IQzAI 26 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQqR8IRDAI 27 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ7B0ISTAJ 28 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQqR8ISjAJ 29 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ7B0ITzAK 30 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQqR8IUDAK 31 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ7B0IVTAL 32 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQqR8IVjAL 33 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQ7B0IXDAM 34 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQqR8IXTAM 35 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQuAIIYjAN 36 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQCAhq 37 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQpyoIdg 38 | 0ahUKEwi8s4uK1qHJAhVGzxQKHXMFC_IQLgh4 39 | 0CAAQwS4oAA 40 | 0CAIQwS4oAg 41 | 0CAMQwS4oAw 42 | 0CAQQwS4oBA 43 | 0CAUQwS4oBQ 44 | 0CAYQwS4oBg 45 | 0CAcQwS4oBw 46 | 0CAgQwS4oCA 47 | 0CAkQwS4oCQ 48 | 0CAoQwS4oCg 49 | 0CAsQwS4oCw 50 | 0CAwQwS4oDA 51 | 0CA0QwS4oDQ 52 | 0CA8QwS4oDw 53 | 0CBAQwS4oEA 54 | 0CBEQwS4oEQ -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/import_test_package/inner.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto2"; 32 | 33 | package google.protobuf.python.internal.import_test_package; 34 | 35 | message Inner { 36 | optional int32 value = 1 [default = 57]; 37 | } 38 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/import_test_package/outer.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto2"; 32 | 33 | package google.protobuf.python.internal.import_test_package; 34 | 35 | import "google/protobuf/internal/import_test_package/inner.proto"; 36 | 37 | message Outer { 38 | optional Inner inner = 1; 39 | } 40 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/proto2_api_test.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto2"; 32 | 33 | import "google/protobuf/internal/cpp/proto1_api_test.proto"; 34 | 35 | package google.protobuf.python.internal; 36 | 37 | message TestNestedProto1APIMessage { 38 | optional int32 a = 1; 39 | optional TestMessage.NestedMessage b = 2; 40 | } 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # googleURLParser - GSERPent 2 | 3 | ### Parser for Google search strings 4 | 5 | This tool came about to try and identify the data located within a Google URL. 6 | Using this script examiners may be able to understand a little bit more about how the user came to a certain page, or what their actions were. 7 | You can view the webcast (and download the slides) for the presentation I did on 11th May 2017 here: https://www.sans.org/webcasts/wwwgooglecom-searchqwhat-plus-does-plus-this-plus-all-plus-mean-104857 8 | Requires - Perl, and Python 9 | 10 | ## Usage Example: 11 | 12 | * perl GSERPent.pl -u "http://www.google.com" 13 | * perl GSERPent.pl -f input.txt 14 | 15 | List input formatting expects [link] | [comment] and ignores lines starting with # 16 | 17 | ## Perl Libraries Required 18 | Windows 19 | - ppm install URI 20 | - ppm install Text-ASCIITable 21 | 22 | Mac 23 | - cpan Text::ASCIITable 24 | 25 | Linux (debian) 26 | - sudo apt install build-essentials 27 | - sudo cpan Text::ASCIITable 28 | 29 | ### Helper Scripts: 30 | * IEF_Google_Searches_TSV_to_list.pl - converts IEF's TSV output from the Google Searches section into a list that can be injested with the -f option in GSERPent. 31 | 32 | * get_all_parameters.pl - given a list of Google URLs, provide a list of all of the parameters 33 | 34 | * parameter_values.pl - given a list of Google URLs, provide a list of all of the parameters, and the grouped values 35 | 36 | * testGSERPent.pl - run test cases, not really populated 37 | 38 | * uridecode.pl - split URLs by & and # value 39 | 40 | * convertTime.pl - command line unix timestamp converter 41 | 42 | 43 | ### Known Issues: 44 | * Doesn't parse the data in the fragment (after the #) 45 | 46 | ### Credits 47 | It's in the code but I realised I didn't link to the original modules that I've included in this repo for ease of use 48 | 1. Cheeky4n6Monkey for Google-Ei-time - https://raw.githubusercontent.com/cheeky4n6monkey/4n6-scripts/master/google-ei-time.py 49 | 2. Tom Anthony and Benjamin Schulz (https://github.com/TomAnthony/ved-decoder/ which is an updated fork of the code by https://github.com/beschulz) 50 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/more_extensions_dynamic.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: jasonh@google.com (Jason Hsueh) 32 | // 33 | // This file is used to test a corner case in the CPP implementation where the 34 | // generated C++ type is available for the extendee, but the extension is 35 | // defined in a file whose C++ type is not in the binary. 36 | 37 | syntax = "proto2"; 38 | 39 | import "google/protobuf/internal/more_extensions.proto"; 40 | 41 | package google.protobuf.internal; 42 | 43 | message DynamicMessageType { 44 | optional int32 a = 1; 45 | } 46 | 47 | extend ExtendedMessage { 48 | optional int32 dynamic_int32_extension = 100; 49 | optional DynamicMessageType dynamic_message_extension = 101; 50 | } 51 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/more_extensions.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: robinson@google.com (Will Robinson) 32 | 33 | syntax = "proto2"; 34 | 35 | package google.protobuf.internal; 36 | 37 | 38 | message TopLevelMessage { 39 | optional ExtendedMessage submessage = 1; 40 | } 41 | 42 | 43 | message ExtendedMessage { 44 | extensions 1 to max; 45 | } 46 | 47 | 48 | message ForeignMessage { 49 | optional int32 foreign_message_int = 1; 50 | } 51 | 52 | 53 | extend ExtendedMessage { 54 | optional int32 optional_int_extension = 1; 55 | optional ForeignMessage optional_message_extension = 2; 56 | 57 | repeated int32 repeated_int_extension = 3; 58 | repeated ForeignMessage repeated_message_extension = 4; 59 | } 60 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/test_bad_identifiers.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: kenton@google.com (Kenton Varda) 32 | 33 | syntax = "proto2"; 34 | 35 | package protobuf_unittest; 36 | 37 | option py_generic_services = true; 38 | 39 | message TestBadIdentifiers { 40 | extensions 100 to max; 41 | } 42 | 43 | // Make sure these reasonable extension names don't conflict with internal 44 | // variables. 45 | extend TestBadIdentifiers { 46 | optional string message = 100 [default="foo"]; 47 | optional string descriptor = 101 [default="bar"]; 48 | optional string reflection = 102 [default="baz"]; 49 | optional string service = 103 [default="qux"]; 50 | } 51 | 52 | message AnotherMessage {} 53 | service AnotherService {} 54 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/missing_enum_values.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto2"; 32 | 33 | package google.protobuf.python.internal; 34 | 35 | message TestEnumValues { 36 | enum NestedEnum { 37 | ZERO = 0; 38 | ONE = 1; 39 | } 40 | optional NestedEnum optional_nested_enum = 1; 41 | repeated NestedEnum repeated_nested_enum = 2; 42 | repeated NestedEnum packed_nested_enum = 3 [packed = true]; 43 | } 44 | 45 | message TestMissingEnumValues { 46 | enum NestedEnum { 47 | TWO = 2; 48 | } 49 | optional NestedEnum optional_nested_enum = 1; 50 | repeated NestedEnum repeated_nested_enum = 2; 51 | repeated NestedEnum packed_nested_enum = 3 [packed = true]; 52 | } 53 | 54 | message JustString { 55 | required string dummy = 1; 56 | } 57 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/more_messages.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: robinson@google.com (Will Robinson) 32 | 33 | syntax = "proto2"; 34 | 35 | package google.protobuf.internal; 36 | 37 | // A message where tag numbers are listed out of order, to allow us to test our 38 | // canonicalization of serialized output, which should always be in tag order. 39 | // We also mix in some extensions for extra fun. 40 | message OutOfOrderFields { 41 | optional sint32 optional_sint32 = 5; 42 | extensions 4 to 4; 43 | optional uint32 optional_uint32 = 3; 44 | extensions 2 to 2; 45 | optional int32 optional_int32 = 1; 46 | }; 47 | 48 | 49 | extend OutOfOrderFields { 50 | optional uint64 optional_uint64 = 4; 51 | optional int64 optional_int64 = 2; 52 | } 53 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/factory_test1.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: matthewtoia@google.com (Matt Toia) 32 | 33 | syntax = "proto2"; 34 | 35 | package google.protobuf.python.internal; 36 | 37 | 38 | enum Factory1Enum { 39 | FACTORY_1_VALUE_0 = 0; 40 | FACTORY_1_VALUE_1 = 1; 41 | } 42 | 43 | message Factory1Message { 44 | optional Factory1Enum factory_1_enum = 1; 45 | enum NestedFactory1Enum { 46 | NESTED_FACTORY_1_VALUE_0 = 0; 47 | NESTED_FACTORY_1_VALUE_1 = 1; 48 | } 49 | optional NestedFactory1Enum nested_factory_1_enum = 2; 50 | message NestedFactory1Message { 51 | optional string value = 1; 52 | } 53 | optional NestedFactory1Message nested_factory_1_message = 3; 54 | optional int32 scalar_value = 4; 55 | repeated string list_value = 5; 56 | 57 | extensions 1000 to max; 58 | } 59 | -------------------------------------------------------------------------------- /tests/test1.txt: -------------------------------------------------------------------------------- 1 | #tests run on my mac (10.10) running latest available versions of safari, chrome and firefox 2 | #EI reliablely created by going to google homepage first 3 | https://www.google.com.au/?gfe_rd=cr&ei=RwxhWPvFLMnr8Aeih74g#q=incognito | go to google homepage in chrome incognito, search for incognito 4 | https://www.google.com.au/?gfe_rd=cr&ei=HAxhWKf2D8nr8Aeih74g&gws_rd=ssl#q=safari | go to google homepage in safari private, search for safari 5 | https://www.google.com.au/?gfe_rd=cr&ei=bAxhWLiOEqzu8wfg-bjAAQ#safe=off&q=google | go to google homepage in chrome (logged in), search for google 6 | https://www.google.com.au/search?client=safari&rls=en&q=safari+search+2&ie=UTF-8&oe=UTF-8&gfe_rd=cr&ei=fg1hWPjDAsTr8AeosajwCg | search from safari search bar for "Safari Search 2" 7 | https://www.google.com.au/?gfe_rd=cr&ei=0Q1hWJSiL8rr8AeX1axA&gws_rd=ssl#q=safari+search+3 | go to google homepage in safari (not logged in), search for "safari search 3" 8 | https://www.google.com.au/?gfe_rd=cr&ei=xQ5hWJLlGMfN8geVuJDIDA&gws_rd=ssl#q=firefox | go to google homepage in firefox (not logged in), search for firefox 9 | https://www.google.com.au/search?q=right+hand+search+box&ie=utf-8&oe=utf-8&gws_rd=cr&ei=AQ9hWPquN4er0QT6n4ugDw | open new window in firefox (not logged in), search in right hand search box 10 | https://www.google.com.au/search?q=suggested+meaning&ie=utf-8&oe=utf-8&gws_rd=cr&ei=KA9hWOjFLcXL0AT4_zw | open new window in firefox (not logged in), start typing in right hand search box and click on one of the suggested links 11 | https://www.google.com.au/search?q=search+bar&oq=search+bar&aqs=chrome..69i57j69i60l3j69i65j69i60.1350j0j1&sourceid=chrome&ie=UTF-8 | search straight from chrome (logged in) 12 | https://www.google.com.au/search?q=search+bar&oq=search+bar&aqs=chrome..69i57j69i60l3j69i65j69i60.1350j0j1&sourceid=chrome&ie=UTF-8#q=search+bar&safe=off&start=10 | as above, but select second page 13 | https://www.google.com.au/url?sa=t&rct=j&q=&esrc=s&source=web&cd=11&cad=rja&uact=8&ved=0ahUKEwiSutT085HRAhUKi5QKHWtdDFo4ChAWCBgwAA&url=https%3A%2F%2Fcolorlib.com%2Fwp%2Ffree-css3-html5-search-form-examples%2F&usg=AFQjCNFNXqCOX9ebV4MQl86DLM0fGch5iw&sig2=NCcJlVx5-h76LRIM3qQJZQ&bvm=bv.142059868,d.dGo | right click on first link from above search and copy referred link 14 | https://www.google.com.au/url?sa=t&rct=j&q=&esrc=s&source=web&cd=12&cad=rja&uact=8&ved=0ahUKEwiSutT085HRAhUKi5QKHWtdDFo4ChAWCB8wAQ&url=http%3A%2F%2Fsevenspark.com%2Fdocs%2Fubermenu-3%2Fcontent%2Fshortcodes%2Fsearch&usg=AFQjCNEm_iqaW4lcVdC-Bg3KxqTb2ntvHA&sig2=KC_8oUeAsH5oi6qvtUIUVQ&bvm=bv.142059868,d.dGo | right click on first link from above search and copy referred link -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/python_protobuf.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: qrczak@google.com (Marcin Kowalczyk) 32 | // 33 | // This module exposes the C proto inside the given Python proto, in 34 | // case the Python proto is implemented with a C proto. 35 | 36 | #ifndef GOOGLE_PROTOBUF_PYTHON_PYTHON_PROTOBUF_H__ 37 | #define GOOGLE_PROTOBUF_PYTHON_PYTHON_PROTOBUF_H__ 38 | 39 | #include 40 | 41 | namespace google { 42 | namespace protobuf { 43 | 44 | class Message; 45 | 46 | namespace python { 47 | 48 | // Return the pointer to the C proto inside the given Python proto, 49 | // or NULL when this is not a Python proto implemented with a C proto. 50 | const Message* GetCProtoInsidePyProto(PyObject* msg); 51 | Message* MutableCProtoInsidePyProto(PyObject* msg); 52 | 53 | } // namespace python 54 | } // namespace protobuf 55 | 56 | } // namespace google 57 | #endif // GOOGLE_PROTOBUF_PYTHON_PYTHON_PROTOBUF_H__ 58 | -------------------------------------------------------------------------------- /helper-scripts/testGSERPent.pl: -------------------------------------------------------------------------------- 1 | #Program to store tests 2 | 3 | use strict; 4 | 5 | my %tests = ( 6 | "https://www.google.com.au/?gfe_rd=cr&ei=-5Z-WN-lF6Tr8Af4lYnYDA" => "====================================================================================================\nhttps://www.google.com.au/?gfe_rd=cr&ei=-5Z-WN-lF6Tr8Af4lYnYDA\n====================================================================================================\nei=-5Z-WN-lF6Tr8Af4lYnYDA\t\t(2017-01-17T22:13:15 UTC) - Session Start Time\ngfe_rd=cr\t\t(Country Redirect - Direct to your countries Google homepage)\n----------------------------------------------------------------------------------------------------\nAlerts:\nEI: Set by Google's Time Servers to indicate the start of a session. If found in cache this isn't always reliable\n\n", 7 | "https://www.google.com.au/search?site=&source=hp&q=hello+world&oq=hello+world&gs_l=hp.3..35i39k1l2j0i67k1l3j0l5.1166.2397.0.2524.12.9.0.0.0.0.264.914.0j1j3.4.0....0...1c.1.64.hp..8.3.732.0..0i131k1.Iq3pvlQg1nI" => "====================================================================================================\nhttps://www.google.com.au/search?site=&source=hp&q=hello+world&oq=hello+world&gs_l=hp.3..35i39k1l2j0i67k1l3j0l5.1166.2397.0.2524.12.9.0.0.0.0.264.914.0j1j3.4.0....0...1c.1.64.hp..8.3.732.0..0i131k1.Iq3pvlQg1nI\n====================================================================================================\ngs_l=hp.3..35i39k1l2j0i67k1l3j0l5.1166.2397.0.2524.12.9.0.0.0.0.264.914.0j1j3.4.0....0...1c.1.64.hp..8.3.732.0..0i131k1.Iq3pvlQg1nI\t\t(keyboard [enter] key, Characters changed, more testing required-- IN PROGRESS\noq=hello world\t\t(Query entered)\nq=hello world\t\t(Query that Search results are returned for)\nsite=\t\tseen --NOT IMPLEMENTED\nsource=hp\t\t(Home Page - needs confirmation)\n\n" 8 | ); 9 | 10 | 11 | 12 | my $gserpent = "gserpent.pl"; 13 | 14 | #system (qq{$command}); 15 | 16 | # 17 | # 18 | 19 | #print $expected; 20 | 21 | my $count = 0; 22 | 23 | foreach my $url (keys %tests){ 24 | $count++; 25 | my $command = "perl $gserpent -u \"$url\""; 26 | my $output = qx($command); 27 | my $expected = $tests{$url}; 28 | 29 | if ($output eq $expected){ 30 | print "$count. PASS\n"; 31 | } 32 | else{ 33 | print "$count. FAIL\n"; 34 | print "Output:\n$output"; 35 | print "Expected:\n$expected\n"; 36 | 37 | #print_each_character($output); 38 | #print_each_character($expected); 39 | } 40 | 41 | } 42 | 43 | 44 | 45 | 46 | sub print_each_character($){ 47 | my $c; 48 | my @chars = split //, shift; 49 | foreach $c (@chars){ 50 | print "'$c'\n"; 51 | } 52 | print "------------------\n"; 53 | } -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/descriptor_pool_test2.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto2"; 32 | 33 | package google.protobuf.python.internal; 34 | 35 | import "google/protobuf/internal/descriptor_pool_test1.proto"; 36 | 37 | 38 | message DescriptorPoolTest3 { 39 | 40 | extend DescriptorPoolTest1 { 41 | optional DescriptorPoolTest3 descriptor_pool_test = 1001; 42 | } 43 | 44 | enum NestedEnum { 45 | NU = 13; 46 | XI = 14; 47 | } 48 | 49 | optional NestedEnum nested_enum = 1 [default = XI]; 50 | 51 | message NestedMessage { 52 | enum NestedEnum { 53 | OMICRON = 15; 54 | PI = 16; 55 | } 56 | optional NestedEnum nested_enum = 1 [default = PI]; 57 | optional string nested_field = 2 [default = "nu"]; 58 | optional DeepNestedMessage deep_nested_message = 3; 59 | 60 | message DeepNestedMessage { 61 | enum NestedEnum { 62 | RHO = 17; 63 | SIGMA = 18; 64 | } 65 | optional NestedEnum nested_enum = 1 [default = RHO]; 66 | optional string nested_field = 2 [default = "sigma"]; 67 | } 68 | } 69 | 70 | optional NestedMessage nested_message = 2; 71 | } 72 | 73 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/message_set_extensions.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // This file contains messages that extend MessageSet. 32 | 33 | syntax = "proto2"; 34 | package google.protobuf.internal; 35 | 36 | 37 | // A message with message_set_wire_format. 38 | message TestMessageSet { 39 | option message_set_wire_format = true; 40 | extensions 4 to max; 41 | } 42 | 43 | message TestMessageSetExtension1 { 44 | extend TestMessageSet { 45 | optional TestMessageSetExtension1 message_set_extension = 98418603; 46 | } 47 | optional int32 i = 15; 48 | } 49 | 50 | message TestMessageSetExtension2 { 51 | extend TestMessageSet { 52 | optional TestMessageSetExtension2 message_set_extension = 98418634; 53 | } 54 | optional string str = 25; 55 | } 56 | 57 | // This message was used to generate 58 | // //net/proto2/python/internal/testdata/message_set_message, but is commented 59 | // out since it must not actually exist in code, to simulate an "unknown" 60 | // extension. 61 | // message TestMessageSetUnknownExtension { 62 | // extend TestMessageSet { 63 | // optional TestMessageSetUnknownExtension message_set_extension = 56141421; 64 | // } 65 | // optional int64 a = 1; 66 | // } 67 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/python.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: tibell@google.com (Johan Tibell) 32 | // 33 | // These message definitions are used to exercises known corner cases 34 | // in the C++ implementation of the Python API. 35 | 36 | syntax = "proto2"; 37 | 38 | package google.protobuf.python.internal; 39 | 40 | // Protos optimized for SPEED use a strict superset of the generated code 41 | // of equivalent ones optimized for CODE_SIZE, so we should optimize all our 42 | // tests for speed unless explicitly testing code size optimization. 43 | option optimize_for = SPEED; 44 | 45 | message TestAllTypes { 46 | message NestedMessage { 47 | optional int32 bb = 1; 48 | optional ForeignMessage cc = 2; 49 | } 50 | 51 | repeated NestedMessage repeated_nested_message = 1; 52 | optional NestedMessage optional_nested_message = 2; 53 | optional int32 optional_int32 = 3; 54 | } 55 | 56 | message ForeignMessage { 57 | optional int32 c = 1; 58 | repeated int32 d = 2; 59 | } 60 | 61 | message TestAllExtensions { 62 | extensions 1 to max; 63 | } 64 | 65 | extend TestAllExtensions { 66 | optional TestAllTypes.NestedMessage optional_nested_message_extension = 1; 67 | repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 2; 68 | } 69 | -------------------------------------------------------------------------------- /helper-scripts/parameter_values.pl: -------------------------------------------------------------------------------- 1 | #print all the parameters and their available values from a list 2 | 3 | 4 | use strict; 5 | use Getopt::Long; 6 | use URI; 7 | 8 | use URI::URL; 9 | use URI::Escape; 10 | use URI::Split qw(uri_split uri_join); 11 | use List::MoreUtils qw(uniq); 12 | 13 | my %parameters; 14 | my %config; 15 | Getopt::Long::Configure("prefix_pattern=(-|\/)"); 16 | GetOptions(\%config, qw(file|f=s param|p=s help|?|h)); 17 | 18 | if ($config{help} || !%config) { 19 | _help(); 20 | exit; 21 | } 22 | 23 | my $file = $config{file}; 24 | open (FH, "<", $file); 25 | 26 | foreach my $line (){ 27 | chomp $line; 28 | next if (!defined($line)); 29 | #skip blank or commented out lines 30 | 31 | next if $line =~ m/^\#/; 32 | next if $line =~ m/^$/; 33 | 34 | my ($url, $comment) = split /\|/, $line; 35 | 36 | #change # to & to remove "fragment" 37 | #$url =~ s/\#/\&/g; 38 | 39 | my $u = URI->new($url); 40 | my ($scheme, $domain, $path, $query, $frag) = uri_split($u); 41 | 42 | #my %query_parameters = $u->query_form($u); 43 | #print $query."\n"; 44 | #my $v = keys %query_parameters; 45 | #print $v. "\n"; 46 | 47 | #foreach my $k (keys %query_parameters){ 48 | # print $query_parameters{$k}."\n"; 49 | # push( @{ $parameters { $k } }, $query_parameters{$k}); 50 | #} 51 | my $f; 52 | my @q = split /&/, $query; 53 | foreach my $f (@q){ 54 | $f =~ m/(.*)=(.*)/; 55 | my $key = $1; 56 | my $value = $2; 57 | push( @{ $parameters { $key } }, $value); 58 | } 59 | 60 | 61 | 62 | 63 | #split frag parameters 64 | my @fragments = split /&/, $frag; 65 | foreach my $f (@fragments){ 66 | $f =~ m/(.*)=(.*)/; 67 | my $key = $1; 68 | my $value = $2; 69 | push( @{ $parameters { $key } }, $value); 70 | } 71 | #print "\n"; 72 | 73 | 74 | } 75 | 76 | 77 | #use Data::Dumper; 78 | #print Dumper \%parameters; 79 | my @uniq; 80 | print "-------------------\n"; 81 | if ($config{param}){ 82 | my $k = $config{param}; 83 | print "$k=\n"; 84 | my @vals = @{$parameters{$k}}; 85 | @uniq = uniq @vals; 86 | print join("\n", @uniq), "\n"; 87 | print "-------------------\n"; 88 | } 89 | else{ 90 | 91 | foreach my $k (keys %parameters) { 92 | print "$k=\n"; 93 | my @vals = @{$parameters{$k}}; 94 | @uniq = uniq @vals; 95 | print join("\n", @uniq), "\n"; 96 | print "-------------------\n"; 97 | } 98 | } 99 | 100 | 101 | 102 | 103 | 104 | 105 | sub _help { 106 | print<< "EOT"; 107 | ----------------------------------------------------------- 108 | Print out list of unique parameters from a list of urls in GSERPant.pl input format 109 | 110 | -f|file ....... input file 111 | -p|param ...... specify parameter 112 | -h|help ....... prints this help screen 113 | 114 | No validation on the input 115 | ----------------------------------------------------------- 116 | EOT 117 | } -------------------------------------------------------------------------------- /tests/urls.txt: -------------------------------------------------------------------------------- 1 | #Test URLS 2 | https://www.google.com.au/?gfe_rd=cr&ei=u_paWP7NHKbr8Af0vYcI| go to Google homepage, in chrome, safe search on, not logged in 3 | https://www.google.com.au/search?q=perl+scalars&oq=perl+scalars&aqs=chrome.0.0l6.4792j1j7&sourceid=chrome&ie=UTF-8| search in Google Chrome search bar for perl scalars, safe search on, not logged in 4 | https://www.google.com.au/search?q=push+array+perl&oq=push+&aqs=chrome.2.69i57j0l5.5225j1j7&sourceid=chrome&ie=UTF-8| search in Google Chrome search bar for push array perl, safe search on, typed partial then selected from suggested, , not logged in 5 | http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=target| taken from https://moz.com/blog/the-ultimate-guide-to-the-google-search-parameters, "gfns=1the link will take you to the first (organic) result for that term" 6 | https://www.google.com/search?q=vonnegut&hl=en&biw=1440&bih=728&site=webhp&ei=lTHWVqawIJikjwPj1J7ADA&start=140&sa=N&bav=on.2,or.&bvm=bv.115946447,d.cGc&fp=1a23df61796ce349&tch=1&ech=1&psi=ajHWVq-dGcP8jwP6w4G4Aw.1456877930638.29| provided in email on iacis listserv 7 | https://www.google.com.au/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwinjbDJ0InRAhXEvLwKHXDBDdoQFggaMAA&url=https%3A%2F%2Fwww.unsw.edu.au%2F&usg=AFQjCNEtSJzSKZNVWJBJhOHpSV7gGhO5rw&sig2=n8AKr_63jcO2c1ZEVGuwxA&bvm=bv.142059868,d.dGc| logged in user, chrome, safe off, search for new south wales (initial search, then changed spelling and clicked on "did you mean" which reperformed the correct search. then opened first link in new window, took Google Redirect link) 8 | https://www.google.com.au/?gfe_rd=cr&ei=4HZfWN22EtTr8AegzrSgBQ#q=j&safe=off&tbas=0&pws=1| Show all results 9 | https://www.google.com.au/?gfe_rd=cr&ei=4HZfWN22EtTr8AegzrSgBQ#q=j&safe=off&tbas=0&pws=0| Hide private results 10 | https://www.google.com.au/search?safe=off&site=&source=hp&q=hello+world&oq=hello+world&gs_l=hp.3..35i39k1l2j0l8.1675.2983.0.3103.12.10.0.0.0.0.501.1338.0j1j3j5-1.5.0....0...1c.1.64.hp..7.4.836.0..0i67k1.XLdcoWz4hV8| turn off Google Instant 11 | https://www.google.com.au/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwientLR8I7RAhXGKJQKHfnmCZ4QFggbMAA&url=http%3A%2F%2Fcheeky4n6monkey.blogspot.com%2F2014%2F10%2Fgoogle-eid.html&usg=AFQjCNFjONFBJV19pRVHTowjvGdFNC2AFA&sig2=Z-UBPuidUQ51ZgB8DHgUbA| redirect link 12 | https://www.google.com.au/imgres?imgurl=http%3A%2F%2Fmedia.dcentertainment.com%2Fsites%2Fdefault%2Ffiles%2FGalleryChar_1900x900_MOS_52e05e3fe24a61.04593858.jpg&imgrefurl=http%3A%2F%2Fwww.dccomics.com%2Fcharacters%2Fsuperman&docid=9hNu2pmaGjcaZM&tbnid=XtZSalLpNwpoXM%3A&vet=1&w=1900&h=900&safe=off&bih=694&biw=1366&q=superman&ved=0ahUKEwiY3uPOkpHRAhWFjpQKHYVwDVoQMwgzKAMwAw&iact=mrc&uact=8| search for superman through google taskbar, then change to images, right click on the fourth picture 13 | https://www.google.com.au/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwjk1MX7kpHRAhWDlZQKHdyKBfYQjxwIAw&url=http%3A%2F%2Fwww.dccomics.com%2Fcharacters%2Fsuperman&psig=AFQjCNFQbLRxR8NQ6gheWTrd8EVaziSYCA&ust=1482817187182632| same as above, just select the "visit page" on the fourth picture 14 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/cpp_message.py: -------------------------------------------------------------------------------- 1 | # Protocol Buffers - Google's data interchange format 2 | # Copyright 2008 Google Inc. All rights reserved. 3 | # https://developers.google.com/protocol-buffers/ 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Protocol message implementation hooks for C++ implementation. 32 | 33 | Contains helper functions used to create protocol message classes from 34 | Descriptor objects at runtime backed by the protocol buffer C++ API. 35 | """ 36 | 37 | __author__ = 'tibell@google.com (Johan Tibell)' 38 | 39 | from google.protobuf.pyext import _message 40 | 41 | 42 | class GeneratedProtocolMessageType(_message.MessageMeta): 43 | 44 | """Metaclass for protocol message classes created at runtime from Descriptors. 45 | 46 | The protocol compiler currently uses this metaclass to create protocol 47 | message classes at runtime. Clients can also manually create their own 48 | classes at runtime, as in this example: 49 | 50 | mydescriptor = Descriptor(.....) 51 | class MyProtoClass(Message): 52 | __metaclass__ = GeneratedProtocolMessageType 53 | DESCRIPTOR = mydescriptor 54 | myproto_instance = MyProtoClass() 55 | myproto.foo_field = 23 56 | ... 57 | 58 | The above example will not work for nested types. If you wish to include them, 59 | use reflection.MakeClass() instead of manually instantiating the class in 60 | order to create the appropriate class structure. 61 | """ 62 | 63 | # Must be consistent with the protocol-compiler code in 64 | # proto2/compiler/internal/generator.*. 65 | _DESCRIPTOR_KEY = 'DESCRIPTOR' 66 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/text_encoding_test.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # Protocol Buffers - Google's data interchange format 4 | # Copyright 2008 Google Inc. All rights reserved. 5 | # https://developers.google.com/protocol-buffers/ 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are 9 | # met: 10 | # 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above 14 | # copyright notice, this list of conditions and the following disclaimer 15 | # in the documentation and/or other materials provided with the 16 | # distribution. 17 | # * Neither the name of Google Inc. nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | """Tests for google.protobuf.text_encoding.""" 34 | 35 | try: 36 | import unittest2 as unittest 37 | except ImportError: 38 | import unittest 39 | from google.protobuf import text_encoding 40 | 41 | TEST_VALUES = [ 42 | ("foo\\rbar\\nbaz\\t", 43 | "foo\\rbar\\nbaz\\t", 44 | b"foo\rbar\nbaz\t"), 45 | ("\\'full of \\\"sound\\\" and \\\"fury\\\"\\'", 46 | "\\'full of \\\"sound\\\" and \\\"fury\\\"\\'", 47 | b"'full of \"sound\" and \"fury\"'"), 48 | ("signi\\\\fying\\\\ nothing\\\\", 49 | "signi\\\\fying\\\\ nothing\\\\", 50 | b"signi\\fying\\ nothing\\"), 51 | ("\\010\\t\\n\\013\\014\\r", 52 | "\x08\\t\\n\x0b\x0c\\r", 53 | b"\010\011\012\013\014\015")] 54 | 55 | 56 | class TextEncodingTestCase(unittest.TestCase): 57 | def testCEscape(self): 58 | for escaped, escaped_utf8, unescaped in TEST_VALUES: 59 | self.assertEqual(escaped, 60 | text_encoding.CEscape(unescaped, as_utf8=False)) 61 | self.assertEqual(escaped_utf8, 62 | text_encoding.CEscape(unescaped, as_utf8=True)) 63 | 64 | def testCUnescape(self): 65 | for escaped, escaped_utf8, unescaped in TEST_VALUES: 66 | self.assertEqual(unescaped, text_encoding.CUnescape(escaped)) 67 | self.assertEqual(unescaped, text_encoding.CUnescape(escaped_utf8)) 68 | 69 | 70 | if __name__ == "__main__": 71 | unittest.main() 72 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/descriptor_database_test.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # Protocol Buffers - Google's data interchange format 4 | # Copyright 2008 Google Inc. All rights reserved. 5 | # https://developers.google.com/protocol-buffers/ 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are 9 | # met: 10 | # 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above 14 | # copyright notice, this list of conditions and the following disclaimer 15 | # in the documentation and/or other materials provided with the 16 | # distribution. 17 | # * Neither the name of Google Inc. nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | """Tests for google.protobuf.descriptor_database.""" 34 | 35 | __author__ = 'matthewtoia@google.com (Matt Toia)' 36 | 37 | try: 38 | import unittest2 as unittest 39 | except ImportError: 40 | import unittest 41 | from google.protobuf import descriptor_pb2 42 | from google.protobuf.internal import factory_test2_pb2 43 | from google.protobuf import descriptor_database 44 | 45 | 46 | class DescriptorDatabaseTest(unittest.TestCase): 47 | 48 | def testAdd(self): 49 | db = descriptor_database.DescriptorDatabase() 50 | file_desc_proto = descriptor_pb2.FileDescriptorProto.FromString( 51 | factory_test2_pb2.DESCRIPTOR.serialized_pb) 52 | db.Add(file_desc_proto) 53 | 54 | self.assertEqual(file_desc_proto, db.FindFileByName( 55 | 'google/protobuf/internal/factory_test2.proto')) 56 | self.assertEqual(file_desc_proto, db.FindFileContainingSymbol( 57 | 'google.protobuf.python.internal.Factory2Message')) 58 | self.assertEqual(file_desc_proto, db.FindFileContainingSymbol( 59 | 'google.protobuf.python.internal.Factory2Message.NestedFactory2Message')) 60 | self.assertEqual(file_desc_proto, db.FindFileContainingSymbol( 61 | 'google.protobuf.python.internal.Factory2Enum')) 62 | self.assertEqual(file_desc_proto, db.FindFileContainingSymbol( 63 | 'google.protobuf.python.internal.Factory2Message.NestedFactory2Enum')) 64 | self.assertEqual(file_desc_proto, db.FindFileContainingSymbol( 65 | 'google.protobuf.python.internal.MessageWithNestedEnumOnly.NestedEnum')) 66 | 67 | if __name__ == '__main__': 68 | unittest.main() 69 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/descriptor_pool_test1.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto2"; 32 | 33 | package google.protobuf.python.internal; 34 | 35 | 36 | message DescriptorPoolTest1 { 37 | extensions 1000 to max; 38 | 39 | enum NestedEnum { 40 | ALPHA = 1; 41 | BETA = 2; 42 | } 43 | 44 | optional NestedEnum nested_enum = 1 [default = BETA]; 45 | 46 | message NestedMessage { 47 | enum NestedEnum { 48 | EPSILON = 5; 49 | ZETA = 6; 50 | } 51 | optional NestedEnum nested_enum = 1 [default = ZETA]; 52 | optional string nested_field = 2 [default = "beta"]; 53 | optional DeepNestedMessage deep_nested_message = 3; 54 | 55 | message DeepNestedMessage { 56 | enum NestedEnum { 57 | ETA = 7; 58 | THETA = 8; 59 | } 60 | optional NestedEnum nested_enum = 1 [default = ETA]; 61 | optional string nested_field = 2 [default = "theta"]; 62 | } 63 | } 64 | 65 | optional NestedMessage nested_message = 2; 66 | } 67 | 68 | message DescriptorPoolTest2 { 69 | enum NestedEnum { 70 | GAMMA = 3; 71 | DELTA = 4; 72 | } 73 | 74 | optional NestedEnum nested_enum = 1 [default = GAMMA]; 75 | 76 | message NestedMessage { 77 | enum NestedEnum { 78 | IOTA = 9; 79 | KAPPA = 10; 80 | } 81 | optional NestedEnum nested_enum = 1 [default = IOTA]; 82 | optional string nested_field = 2 [default = "delta"]; 83 | optional DeepNestedMessage deep_nested_message = 3; 84 | 85 | message DeepNestedMessage { 86 | enum NestedEnum { 87 | LAMBDA = 11; 88 | MU = 12; 89 | } 90 | optional NestedEnum nested_enum = 1 [default = MU]; 91 | optional string nested_field = 2 [default = "lambda"]; 92 | } 93 | } 94 | 95 | optional NestedMessage nested_message = 2; 96 | } 97 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/packed_field_test.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf.python.internal; 34 | 35 | message TestPackedTypes { 36 | enum NestedEnum { 37 | FOO = 0; 38 | BAR = 1; 39 | BAZ = 2; 40 | } 41 | 42 | repeated int32 repeated_int32 = 1; 43 | repeated int64 repeated_int64 = 2; 44 | repeated uint32 repeated_uint32 = 3; 45 | repeated uint64 repeated_uint64 = 4; 46 | repeated sint32 repeated_sint32 = 5; 47 | repeated sint64 repeated_sint64 = 6; 48 | repeated fixed32 repeated_fixed32 = 7; 49 | repeated fixed64 repeated_fixed64 = 8; 50 | repeated sfixed32 repeated_sfixed32 = 9; 51 | repeated sfixed64 repeated_sfixed64 = 10; 52 | repeated float repeated_float = 11; 53 | repeated double repeated_double = 12; 54 | repeated bool repeated_bool = 13; 55 | repeated NestedEnum repeated_nested_enum = 14; 56 | } 57 | 58 | message TestUnpackedTypes { 59 | repeated int32 repeated_int32 = 1 [packed = false]; 60 | repeated int64 repeated_int64 = 2 [packed = false]; 61 | repeated uint32 repeated_uint32 = 3 [packed = false]; 62 | repeated uint64 repeated_uint64 = 4 [packed = false]; 63 | repeated sint32 repeated_sint32 = 5 [packed = false]; 64 | repeated sint64 repeated_sint64 = 6 [packed = false]; 65 | repeated fixed32 repeated_fixed32 = 7 [packed = false]; 66 | repeated fixed64 repeated_fixed64 = 8 [packed = false]; 67 | repeated sfixed32 repeated_sfixed32 = 9 [packed = false]; 68 | repeated sfixed64 repeated_sfixed64 = 10 [packed = false]; 69 | repeated float repeated_float = 11 [packed = false]; 70 | repeated double repeated_double = 12 [packed = false]; 71 | repeated bool repeated_bool = 13 [packed = false]; 72 | repeated TestPackedTypes.NestedEnum repeated_nested_enum = 14 [packed = false]; 73 | } 74 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/message_listener.py: -------------------------------------------------------------------------------- 1 | # Protocol Buffers - Google's data interchange format 2 | # Copyright 2008 Google Inc. All rights reserved. 3 | # https://developers.google.com/protocol-buffers/ 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Defines a listener interface for observing certain 32 | state transitions on Message objects. 33 | 34 | Also defines a null implementation of this interface. 35 | """ 36 | 37 | __author__ = 'robinson@google.com (Will Robinson)' 38 | 39 | 40 | class MessageListener(object): 41 | 42 | """Listens for modifications made to a message. Meant to be registered via 43 | Message._SetListener(). 44 | 45 | Attributes: 46 | dirty: If True, then calling Modified() would be a no-op. This can be 47 | used to avoid these calls entirely in the common case. 48 | """ 49 | 50 | def Modified(self): 51 | """Called every time the message is modified in such a way that the parent 52 | message may need to be updated. This currently means either: 53 | (a) The message was modified for the first time, so the parent message 54 | should henceforth mark the message as present. 55 | (b) The message's cached byte size became dirty -- i.e. the message was 56 | modified for the first time after a previous call to ByteSize(). 57 | Therefore the parent should also mark its byte size as dirty. 58 | Note that (a) implies (b), since new objects start out with a client cached 59 | size (zero). However, we document (a) explicitly because it is important. 60 | 61 | Modified() will *only* be called in response to one of these two events -- 62 | not every time the sub-message is modified. 63 | 64 | Note that if the listener's |dirty| attribute is true, then calling 65 | Modified at the moment would be a no-op, so it can be skipped. Performance- 66 | sensitive callers should check this attribute directly before calling since 67 | it will be true most of the time. 68 | """ 69 | 70 | raise NotImplementedError 71 | 72 | 73 | class NullMessageListener(object): 74 | 75 | """No-op MessageListener implementation.""" 76 | 77 | def Modified(self): 78 | pass 79 | -------------------------------------------------------------------------------- /ved-decoder-master/proto/ved.ta.attempt.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package ved; 4 | 5 | message Ved 6 | { 7 | enum Type 8 | { 9 | WEB = 22; 10 | BLOG_SEARCH_RESULT = 152; 11 | BOOK_SEARCH_RESULT = 232; 12 | BOOK_SEARCH_RESULT_THUMBNAIL = 235; 13 | IMAGE_SEARCH_RESULT_IN_BASIC_NON_JAVASCRIPT_IMAGE_SEARCH_OR_IMAGE_RESULT_IN_UNIVERSAL_SEARCH = 245; 14 | LOCAL_SEARCH_RESULT = 288; 15 | NEWS_RESULT_THUMBNAIL = 295; 16 | NEWS_RESULT = 297; 17 | MORE_RESULTS_LINK_LISTED_MAINLY_FOR_QA_WEBSITES = 300; 18 | VIDEO_RESULT = 311; 19 | VIDEO_RESULT_THUMBNAIL = 312; 20 | ONE_LINE_SITELINK = 338; 21 | SHOPPING_SEARCH_RESULT = 371; 22 | IMAGE_SEARCH_RESULT_PROBABLY_NOT_IN_USE_ANY_MORE = 429; 23 | JUMP_TO_LINK = 586; 24 | MAP_SEARCH_RESULT_WEBSITE_LINK = 612; 25 | MAP_SEARCH_RESULT_THUMBNAIL = 646; 26 | ADWORD_SITELINK = 706; 27 | BREADCRUMB = 745; 28 | PATENT_RESULT_OVERVIEW_RELATED_DISCUSS_LINK = 1107; 29 | BOOK_SEARCH_RESULT_AUTHOR_LINK = 1140; 30 | NORMAL_RESULT_THUMBNAIL_EG_FOR_AN_APPLICATION_RECIPE_ETC = 1146; 31 | NORMAL_RESULT_THUMBNAIL_EG_FOR_AN_APPLICATION_RECIPE_ETC_ALT = 1150; 32 | LOCAL_SEARCH_RESULT_MARKER_PIN_ICON = 1455; 33 | NEWS_SUB_RESULT_IE_THE_SAME_STORY_FROM_A_DIFFERENT_SITE = 1532; 34 | ADWORD_IE_SPONSORED_SEARCH_RESULT = 1617; 35 | MAP_SEARCH_RESULT = 1701; 36 | KNOWLEDGE_GRAPH_REPEATED_SUB_LINK_EG_FOOTBALL_TEAM_SQUAD_PLAYERS_ALBUM_TRACK_LISTINGS = 1732; 37 | SPONSORED_SHOPPING_RESULT_THUMBNAIL_IN_RIGHT_HAND_COLUMN_OF_UNIVERSAL_SEARCH_RESULTS = 1907; 38 | SPONSORED_SHOPPING_RESULT_IN_RIGHT_HAND_COLUMN_OF_UNIVERSAL_SEARCH_RESULTS = 1908; 39 | SPONSORED_SHOPPING_RESULT_THUMBNAIL_IN_MAIN_COLUMN_OF_UNIVERSAL_SEARCH_RESULTS = 1986; 40 | SPONSORED_SHOPPING_RESULT_IN_MAIN_COLUMN_OF_UNIVERSAL_SEARCH_RESULTS = 1987; 41 | SITELINK = 2060; 42 | NEWS_RESULT_VIDEO_THUMBNAIL = 2237; 43 | KNOWLEDGE_GRAPH_LINK = 2459; 44 | AUTHORSHIP_BY_AUTHOR_LINK = 2847; 45 | AUTHORSHIP_THUMBNAIL_LINK = 2937; 46 | IMAGE_SEARCH_RESULT_THUMBNAIL = 3588; 47 | IMAGE_SEARCH_RESULT_PREVIEW_VIEW_IMAGE_LINK = 3596; 48 | IMAGE_SEARCH_RESULT_PREVIEW_THUMBNAIL = 3597; 49 | IMAGE_SEARCH_RESULT_PREVIEW_TITLE_LINK = 3598; 50 | IMAGE_SEARCH_RESULT_PREVIEW_VISIT_PAGE_LINK = 3599; 51 | IMAGE_SEARCH_RESULT_PREVIEW_GREY_WEBSITE_LINK_UNDERNEATH_TITLE = 3724; 52 | KNOWLEDGE_GRAPH_MAIN_IMAGE = 3836; 53 | IN_DEPTH_ARTICLE_RESULT = 5077; 54 | IN_DEPTH_ARTICLE_RESULT_THUMBNAIL = 5078; 55 | ADWORD_ONE_LINE_SITELINK = 5158; 56 | DICTIONARY_DEFINITION_LINK = 5497; 57 | }; 58 | 59 | optional int32 index_boost = 1; // i 60 | optional Type type = 2; // t 61 | optional int32 sub_link_position = 5; // (zero based) 62 | optional int32 result_position = 6; // r (zero based) 63 | optional int32 start = 7; // s (zero based) 64 | 65 | optional int32 unknown_3 = 3; // unknown 66 | optional int32 unknown_4 = 4; // unknown 67 | optional int32 unknown_8 = 8; // unknown 68 | optional int32 unknown_9 = 9; // unknown 69 | optional int32 unknown_10 = 10; // unknown 70 | optional int32 unknown_11 = 11; // unknown 71 | optional int32 unknown_12 = 12; // unknown 72 | optional int32 unknown_13 = 13; // unknown 73 | optional int32 unknown_14 = 14; // unknown 74 | optional int32 unknown_15 = 15; // unknown 75 | optional int32 unknown_16 = 16; // unknown 76 | optional int32 unknown_17 = 17; // unknown 77 | optional int32 unknown_18 = 18; // unknown 78 | optional int32 unknown_19 = 19; // unknown 79 | optional int32 unknown_20 = 20; // unknown 80 | optional int32 unknown_21 = 21; // unknown 81 | optional int32 unknown_22 = 22; // unknown 82 | optional int32 unknown_23 = 23; // unknown 83 | } -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/scoped_pyobject_ptr.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: tibell@google.com (Johan Tibell) 32 | 33 | #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_SCOPED_PYOBJECT_PTR_H__ 34 | #define GOOGLE_PROTOBUF_PYTHON_CPP_SCOPED_PYOBJECT_PTR_H__ 35 | 36 | #include 37 | 38 | #include 39 | 40 | namespace google { 41 | class ScopedPyObjectPtr { 42 | public: 43 | // Constructor. Defaults to initializing with NULL. 44 | // There is no way to create an uninitialized ScopedPyObjectPtr. 45 | explicit ScopedPyObjectPtr(PyObject* p = NULL) : ptr_(p) { } 46 | 47 | // Destructor. If there is a PyObject object, delete it. 48 | ~ScopedPyObjectPtr() { 49 | Py_XDECREF(ptr_); 50 | } 51 | 52 | // Reset. Deletes the current owned object, if any. 53 | // Then takes ownership of a new object, if given. 54 | // This function must be called with a reference that you own. 55 | // this->reset(this->get()) is wrong! 56 | // this->reset(this->release()) is OK. 57 | PyObject* reset(PyObject* p = NULL) { 58 | Py_XDECREF(ptr_); 59 | ptr_ = p; 60 | return ptr_; 61 | } 62 | 63 | // Releases ownership of the object. 64 | // The caller now owns the returned reference. 65 | PyObject* release() { 66 | PyObject* p = ptr_; 67 | ptr_ = NULL; 68 | return p; 69 | } 70 | 71 | PyObject* operator->() const { 72 | assert(ptr_ != NULL); 73 | return ptr_; 74 | } 75 | 76 | PyObject* get() const { return ptr_; } 77 | 78 | Py_ssize_t refcnt() const { return Py_REFCNT(ptr_); } 79 | 80 | void inc() const { Py_INCREF(ptr_); } 81 | 82 | // Comparison operators. 83 | // These return whether a ScopedPyObjectPtr and a raw pointer 84 | // refer to the same object, not just to two different but equal 85 | // objects. 86 | bool operator==(const PyObject* p) const { return ptr_ == p; } 87 | bool operator!=(const PyObject* p) const { return ptr_ != p; } 88 | 89 | private: 90 | PyObject* ptr_; 91 | 92 | GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ScopedPyObjectPtr); 93 | }; 94 | 95 | } // namespace google 96 | #endif // GOOGLE_PROTOBUF_PYTHON_CPP_SCOPED_PYOBJECT_PTR_H__ 97 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/enum_type_wrapper.py: -------------------------------------------------------------------------------- 1 | # Protocol Buffers - Google's data interchange format 2 | # Copyright 2008 Google Inc. All rights reserved. 3 | # https://developers.google.com/protocol-buffers/ 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """A simple wrapper around enum types to expose utility functions. 32 | 33 | Instances are created as properties with the same name as the enum they wrap 34 | on proto classes. For usage, see: 35 | reflection_test.py 36 | """ 37 | 38 | __author__ = 'rabsatt@google.com (Kevin Rabsatt)' 39 | 40 | 41 | class EnumTypeWrapper(object): 42 | """A utility for finding the names of enum values.""" 43 | 44 | DESCRIPTOR = None 45 | 46 | def __init__(self, enum_type): 47 | """Inits EnumTypeWrapper with an EnumDescriptor.""" 48 | self._enum_type = enum_type 49 | self.DESCRIPTOR = enum_type; 50 | 51 | def Name(self, number): 52 | """Returns a string containing the name of an enum value.""" 53 | if number in self._enum_type.values_by_number: 54 | return self._enum_type.values_by_number[number].name 55 | raise ValueError('Enum %s has no name defined for value %d' % ( 56 | self._enum_type.name, number)) 57 | 58 | def Value(self, name): 59 | """Returns the value coresponding to the given enum name.""" 60 | if name in self._enum_type.values_by_name: 61 | return self._enum_type.values_by_name[name].number 62 | raise ValueError('Enum %s has no value defined for name %s' % ( 63 | self._enum_type.name, name)) 64 | 65 | def keys(self): 66 | """Return a list of the string names in the enum. 67 | 68 | These are returned in the order they were defined in the .proto file. 69 | """ 70 | 71 | return [value_descriptor.name 72 | for value_descriptor in self._enum_type.values] 73 | 74 | def values(self): 75 | """Return a list of the integer values in the enum. 76 | 77 | These are returned in the order they were defined in the .proto file. 78 | """ 79 | 80 | return [value_descriptor.number 81 | for value_descriptor in self._enum_type.values] 82 | 83 | def items(self): 84 | """Return a list of the (name, value) pairs of the enum. 85 | 86 | These are returned in the order they were defined in the .proto file. 87 | """ 88 | return [(value_descriptor.name, value_descriptor.number) 89 | for value_descriptor in self._enum_type.values] 90 | -------------------------------------------------------------------------------- /ved-decoder-master/proto/ved.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package ved; 4 | 5 | message Ved { 6 | 7 | enum Type { 8 | normal_universal_search_result = 22; 9 | blog_search_result = 152; 10 | patent_result = 232; 11 | patent_result_thumbnail = 235; 12 | image_search_result_in_basic_image_search_universal_search = 245; 13 | local_search_result = 288; 14 | news_result_thumbnail = 295; 15 | news_result = 297; 16 | more_results_link_listed_mainly_for_QA_websites = 300; 17 | video_result = 311; 18 | video_result_thumbnail = 312; 19 | oneline_sitelink = 338; 20 | shopping_search_result = 371; 21 | image_search_result = 429; 22 | new_image_search_result = 51; 23 | Jump_to_link = 586; 24 | map_search_result_website_link = 612; 25 | map_search_result_thumbnail = 646; 26 | adword_sitelink = 706; 27 | breadcrumb = 745; 28 | patent_result_Overview_Related_Discuss_link = 1107; 29 | book_search_result_author_link = 1140; 30 | normal_result_thumbnail_1 = 1146; 31 | normal_result_thumbnail_2 = 1150; 32 | local_search_result_marker_pin_icon = 1455; 33 | news_sub_result = 1532; 34 | sponsored_search_result = 1617; 35 | map_search_result = 1701; 36 | knowledge_graph_repeated_sub_link = 1732; 37 | sponsored_shopping_result_thumbnail = 1907; 38 | sponsored_shopping_result = 1908; 39 | sponsored_shopping_result_thumbnail_ = 1986; 40 | sponsored_shopping_result_main_column_of_universal_search = 1987; 41 | sitelink = 2060; 42 | news_result_video_thumbnail = 2237; 43 | knowledge_graph_link = 2459; 44 | authorship_by_author_link = 2847; 45 | authorship_thumbnail_link = 2937; 46 | image_search_result_thumbnail = 3588; 47 | image_search_result_preview_View_image_link = 3596; 48 | image_search_result_preview_thumbnail = 3597; 49 | image_search_result_preview_title_link = 3598; 50 | image_search_result_preview_Visit_page_link = 3599; 51 | image_search_result_preview_grey_website_link_underneath_title = 3724; 52 | knowledge_graph_main_image = 3836; 53 | indepth_article_result = 5077; 54 | indepth_article_result_thumbnail = 5078; 55 | adword_oneline_sitelink = 5158; 56 | dictionary_definition_link = 5497; 57 | } 58 | ; 59 | 60 | message Mysterious { 61 | message NestedMysterious { 62 | optional int64 ts = 1; 63 | optional sfixed32 mysterious1 = 2; 64 | optional sfixed32 mysterious2 = 3; 65 | } 66 | optional NestedMysterious nested_mysterious_msg = 1; 67 | } 68 | 69 | optional uint64 link_index = 1; 70 | optional Type link_type = 2; 71 | optional uint64 sub_result_position = 5; 72 | optional uint64 result_position = 6; 73 | optional uint64 start_result_position = 7; 74 | optional uint64 v3 = 3; 75 | optional uint64 v4 = 4; 76 | optional uint64 v8 = 8; 77 | optional uint64 v9 = 9; 78 | optional uint64 v10 = 10; 79 | optional uint64 v11 = 11; 80 | optional uint64 v12 = 12; 81 | 82 | /** 83 | It seems that the ved structure has changed. 84 | pos 13 now has nested types 85 | 1: 51 86 | 2: 51 87 | 5: 1 88 | 6: 1 89 | 13 { 90 | 1 { 91 | 1: 1437758367149743 //this seems to be microseconds since epoch 92 | 2: 0x0a883787 //hex to num: 176699271 / 176723780 / 176725331 ... seems that it could be the number of clicks/views/?? on the ad/campaign? 93 | //the closer you click again the closer the number is 94 | 3: 0x9504a24e //2500108878 95 | } 96 | } 97 | */ 98 | 99 | optional Mysterious mysterious_msg = 13; 100 | } -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/factory_test2.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: matthewtoia@google.com (Matt Toia) 32 | 33 | syntax = "proto2"; 34 | 35 | package google.protobuf.python.internal; 36 | 37 | import "google/protobuf/internal/factory_test1.proto"; 38 | 39 | 40 | enum Factory2Enum { 41 | FACTORY_2_VALUE_0 = 0; 42 | FACTORY_2_VALUE_1 = 1; 43 | } 44 | 45 | message Factory2Message { 46 | required int32 mandatory = 1; 47 | optional Factory2Enum factory_2_enum = 2; 48 | enum NestedFactory2Enum { 49 | NESTED_FACTORY_2_VALUE_0 = 0; 50 | NESTED_FACTORY_2_VALUE_1 = 1; 51 | } 52 | optional NestedFactory2Enum nested_factory_2_enum = 3; 53 | message NestedFactory2Message { 54 | optional string value = 1; 55 | } 56 | optional NestedFactory2Message nested_factory_2_message = 4; 57 | optional Factory1Message factory_1_message = 5; 58 | optional Factory1Enum factory_1_enum = 6; 59 | optional Factory1Message.NestedFactory1Enum nested_factory_1_enum = 7; 60 | optional Factory1Message.NestedFactory1Message nested_factory_1_message = 8; 61 | optional Factory2Message circular_message = 9; 62 | optional string scalar_value = 10; 63 | repeated string list_value = 11; 64 | repeated group Grouped = 12 { 65 | optional string part_1 = 13; 66 | optional string part_2 = 14; 67 | } 68 | optional LoopMessage loop = 15; 69 | optional int32 int_with_default = 16 [default = 1776]; 70 | optional double double_with_default = 17 [default = 9.99]; 71 | optional string string_with_default = 18 [default = "hello world"]; 72 | optional bool bool_with_default = 19 [default = false]; 73 | optional Factory2Enum enum_with_default = 20 [default = FACTORY_2_VALUE_1]; 74 | optional bytes bytes_with_default = 21 [default = "a\373\000c"]; 75 | 76 | 77 | extend Factory1Message { 78 | optional string one_more_field = 1001; 79 | } 80 | 81 | oneof oneof_field { 82 | int32 oneof_int = 22; 83 | string oneof_string = 23; 84 | } 85 | } 86 | 87 | message LoopMessage { 88 | optional Factory2Message loop = 1; 89 | } 90 | 91 | message MessageWithNestedEnumOnly { 92 | enum NestedEnum { 93 | NESTED_MESSAGE_ENUM_0 = 0; 94 | } 95 | } 96 | 97 | extend Factory1Message { 98 | optional string another_field = 1002; 99 | } 100 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/proto_builder_test.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # Protocol Buffers - Google's data interchange format 4 | # Copyright 2008 Google Inc. All rights reserved. 5 | # https://developers.google.com/protocol-buffers/ 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are 9 | # met: 10 | # 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above 14 | # copyright notice, this list of conditions and the following disclaimer 15 | # in the documentation and/or other materials provided with the 16 | # distribution. 17 | # * Neither the name of Google Inc. nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | """Tests for google.protobuf.proto_builder.""" 34 | 35 | try: 36 | from collections import OrderedDict 37 | except ImportError: 38 | from ordereddict import OrderedDict #PY26 39 | try: 40 | import unittest2 as unittest 41 | except ImportError: 42 | import unittest 43 | from google.protobuf import descriptor_pb2 44 | from google.protobuf import descriptor_pool 45 | from google.protobuf import proto_builder 46 | from google.protobuf import text_format 47 | 48 | 49 | class ProtoBuilderTest(unittest.TestCase): 50 | 51 | def setUp(self): 52 | self.ordered_fields = OrderedDict([ 53 | ('foo', descriptor_pb2.FieldDescriptorProto.TYPE_INT64), 54 | ('bar', descriptor_pb2.FieldDescriptorProto.TYPE_STRING), 55 | ]) 56 | self._fields = dict(self.ordered_fields) 57 | 58 | def testMakeSimpleProtoClass(self): 59 | """Test that we can create a proto class.""" 60 | proto_cls = proto_builder.MakeSimpleProtoClass( 61 | self._fields, 62 | full_name='net.proto2.python.public.proto_builder_test.Test') 63 | proto = proto_cls() 64 | proto.foo = 12345 65 | proto.bar = 'asdf' 66 | self.assertMultiLineEqual( 67 | 'bar: "asdf"\nfoo: 12345\n', text_format.MessageToString(proto)) 68 | 69 | def testOrderedFields(self): 70 | """Test that the field order is maintained when given an OrderedDict.""" 71 | proto_cls = proto_builder.MakeSimpleProtoClass( 72 | self.ordered_fields, 73 | full_name='net.proto2.python.public.proto_builder_test.OrderedTest') 74 | proto = proto_cls() 75 | proto.foo = 12345 76 | proto.bar = 'asdf' 77 | self.assertMultiLineEqual( 78 | 'foo: 12345\nbar: "asdf"\n', text_format.MessageToString(proto)) 79 | 80 | def testMakeSameProtoClassTwice(self): 81 | """Test that the DescriptorPool is used.""" 82 | pool = descriptor_pool.DescriptorPool() 83 | proto_cls1 = proto_builder.MakeSimpleProtoClass( 84 | self._fields, 85 | full_name='net.proto2.python.public.proto_builder_test.Test', 86 | pool=pool) 87 | proto_cls2 = proto_builder.MakeSimpleProtoClass( 88 | self._fields, 89 | full_name='net.proto2.python.public.proto_builder_test.Test', 90 | pool=pool) 91 | self.assertIs(proto_cls1.DESCRIPTOR, proto_cls2.DESCRIPTOR) 92 | 93 | 94 | if __name__ == '__main__': 95 | unittest.main() 96 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/descriptor.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: petar@google.com (Petar Petrov) 32 | 33 | #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__ 34 | #define GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__ 35 | 36 | #include 37 | 38 | #include 39 | 40 | namespace google { 41 | namespace protobuf { 42 | namespace python { 43 | 44 | extern PyTypeObject PyMessageDescriptor_Type; 45 | extern PyTypeObject PyFieldDescriptor_Type; 46 | extern PyTypeObject PyEnumDescriptor_Type; 47 | extern PyTypeObject PyEnumValueDescriptor_Type; 48 | extern PyTypeObject PyFileDescriptor_Type; 49 | extern PyTypeObject PyOneofDescriptor_Type; 50 | 51 | // Wraps a Descriptor in a Python object. 52 | // The C++ pointer is usually borrowed from the global DescriptorPool. 53 | // In any case, it must stay alive as long as the Python object. 54 | // Returns a new reference. 55 | PyObject* PyMessageDescriptor_FromDescriptor(const Descriptor* descriptor); 56 | PyObject* PyFieldDescriptor_FromDescriptor(const FieldDescriptor* descriptor); 57 | PyObject* PyEnumDescriptor_FromDescriptor(const EnumDescriptor* descriptor); 58 | PyObject* PyEnumValueDescriptor_FromDescriptor( 59 | const EnumValueDescriptor* descriptor); 60 | PyObject* PyOneofDescriptor_FromDescriptor(const OneofDescriptor* descriptor); 61 | PyObject* PyFileDescriptor_FromDescriptor( 62 | const FileDescriptor* file_descriptor); 63 | 64 | // Alternate constructor of PyFileDescriptor, used when we already have a 65 | // serialized FileDescriptorProto that can be cached. 66 | // Returns a new reference. 67 | PyObject* PyFileDescriptor_FromDescriptorWithSerializedPb( 68 | const FileDescriptor* file_descriptor, PyObject* serialized_pb); 69 | 70 | // Return the C++ descriptor pointer. 71 | // This function checks the parameter type; on error, return NULL with a Python 72 | // exception set. 73 | const Descriptor* PyMessageDescriptor_AsDescriptor(PyObject* obj); 74 | const FieldDescriptor* PyFieldDescriptor_AsDescriptor(PyObject* obj); 75 | const EnumDescriptor* PyEnumDescriptor_AsDescriptor(PyObject* obj); 76 | const FileDescriptor* PyFileDescriptor_AsDescriptor(PyObject* obj); 77 | 78 | // Returns the raw C++ pointer. 79 | const void* PyDescriptor_AsVoidPtr(PyObject* obj); 80 | 81 | // Check that the calling Python code is the global scope of a _pb2.py module. 82 | // This function is used to support the current code generated by the proto 83 | // compiler, which insists on modifying descriptors after they have been 84 | // created. 85 | // 86 | // stacklevel indicates which Python frame should be the _pb2.py module. 87 | // 88 | // Don't use this function outside descriptor classes. 89 | bool _CalledFromGeneratedFile(int stacklevel); 90 | 91 | bool InitDescriptor(); 92 | 93 | } // namespace python 94 | } // namespace protobuf 95 | 96 | } // namespace google 97 | #endif // GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_H__ 98 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/descriptor_containers.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_CONTAINERS_H__ 32 | #define GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_CONTAINERS_H__ 33 | 34 | // Mappings and Sequences of descriptors. 35 | // They implement containers like fields_by_name, EnumDescriptor.values... 36 | // See descriptor_containers.cc for more description. 37 | #include 38 | 39 | namespace google { 40 | namespace protobuf { 41 | 42 | class Descriptor; 43 | class FileDescriptor; 44 | class EnumDescriptor; 45 | class OneofDescriptor; 46 | 47 | namespace python { 48 | 49 | // Initialize the various types and objects. 50 | bool InitDescriptorMappingTypes(); 51 | 52 | // Each function below returns a Mapping, or a Sequence of descriptors. 53 | // They all return a new reference. 54 | 55 | namespace message_descriptor { 56 | PyObject* NewMessageFieldsByName(const Descriptor* descriptor); 57 | PyObject* NewMessageFieldsByCamelcaseName(const Descriptor* descriptor); 58 | PyObject* NewMessageFieldsByNumber(const Descriptor* descriptor); 59 | PyObject* NewMessageFieldsSeq(const Descriptor* descriptor); 60 | 61 | PyObject* NewMessageNestedTypesSeq(const Descriptor* descriptor); 62 | PyObject* NewMessageNestedTypesByName(const Descriptor* descriptor); 63 | 64 | PyObject* NewMessageEnumsByName(const Descriptor* descriptor); 65 | PyObject* NewMessageEnumsSeq(const Descriptor* descriptor); 66 | PyObject* NewMessageEnumValuesByName(const Descriptor* descriptor); 67 | 68 | PyObject* NewMessageExtensionsByName(const Descriptor* descriptor); 69 | PyObject* NewMessageExtensionsSeq(const Descriptor* descriptor); 70 | 71 | PyObject* NewMessageOneofsByName(const Descriptor* descriptor); 72 | PyObject* NewMessageOneofsSeq(const Descriptor* descriptor); 73 | } // namespace message_descriptor 74 | 75 | namespace enum_descriptor { 76 | PyObject* NewEnumValuesByName(const EnumDescriptor* descriptor); 77 | PyObject* NewEnumValuesByNumber(const EnumDescriptor* descriptor); 78 | PyObject* NewEnumValuesSeq(const EnumDescriptor* descriptor); 79 | } // namespace enum_descriptor 80 | 81 | namespace oneof_descriptor { 82 | PyObject* NewOneofFieldsSeq(const OneofDescriptor* descriptor); 83 | } // namespace oneof_descriptor 84 | 85 | namespace file_descriptor { 86 | PyObject* NewFileMessageTypesByName(const FileDescriptor* descriptor); 87 | 88 | PyObject* NewFileEnumTypesByName(const FileDescriptor* descriptor); 89 | 90 | PyObject* NewFileExtensionsByName(const FileDescriptor* descriptor); 91 | 92 | PyObject* NewFileDependencies(const FileDescriptor* descriptor); 93 | PyObject* NewFilePublicDependencies(const FileDescriptor* descriptor); 94 | } // namespace file_descriptor 95 | 96 | 97 | } // namespace python 98 | } // namespace protobuf 99 | 100 | } // namespace google 101 | #endif // GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_CONTAINERS_H__ 102 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/scalar_map_container.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_SCALAR_MAP_CONTAINER_H__ 32 | #define GOOGLE_PROTOBUF_PYTHON_CPP_SCALAR_MAP_CONTAINER_H__ 33 | 34 | #include 35 | 36 | #include 37 | #ifndef _SHARED_PTR_H 38 | #include 39 | #endif 40 | 41 | #include 42 | 43 | namespace google { 44 | namespace protobuf { 45 | 46 | class Message; 47 | 48 | using internal::shared_ptr; 49 | 50 | namespace python { 51 | 52 | struct CMessage; 53 | 54 | struct ScalarMapContainer { 55 | PyObject_HEAD; 56 | 57 | // This is the top-level C++ Message object that owns the whole 58 | // proto tree. Every Python ScalarMapContainer holds a 59 | // reference to it in order to keep it alive as long as there's a 60 | // Python object that references any part of the tree. 61 | shared_ptr owner; 62 | 63 | // Pointer to the C++ Message that contains this container. The 64 | // ScalarMapContainer does not own this pointer. 65 | Message* message; 66 | 67 | // Weak reference to a parent CMessage object (i.e. may be NULL.) 68 | // 69 | // Used to make sure all ancestors are also mutable when first 70 | // modifying the container. 71 | CMessage* parent; 72 | 73 | // Pointer to the parent's descriptor that describes this 74 | // field. Used together with the parent's message when making a 75 | // default message instance mutable. 76 | // The pointer is owned by the global DescriptorPool. 77 | const FieldDescriptor* parent_field_descriptor; 78 | const FieldDescriptor* key_field_descriptor; 79 | const FieldDescriptor* value_field_descriptor; 80 | 81 | // We bump this whenever we perform a mutation, to invalidate existing 82 | // iterators. 83 | uint64 version; 84 | }; 85 | 86 | #if PY_MAJOR_VERSION >= 3 87 | extern PyObject *ScalarMapContainer_Type; 88 | extern PyType_Spec ScalarMapContainer_Type_spec; 89 | #else 90 | extern PyTypeObject ScalarMapContainer_Type; 91 | #endif 92 | extern PyTypeObject ScalarMapIterator_Type; 93 | 94 | namespace scalar_map_container { 95 | 96 | // Builds a ScalarMapContainer object, from a parent message and a 97 | // field descriptor. 98 | extern PyObject *NewContainer( 99 | CMessage* parent, const FieldDescriptor* parent_field_descriptor); 100 | 101 | // Releases the messages in the container to a new message. 102 | // 103 | // Returns 0 on success, -1 on failure. 104 | int Release(ScalarMapContainer* self); 105 | 106 | // Set the owner field of self and any children of self. 107 | void SetOwner(ScalarMapContainer* self, 108 | const shared_ptr& new_owner); 109 | 110 | } // namespace scalar_map_container 111 | } // namespace python 112 | } // namespace protobuf 113 | 114 | } // namespace google 115 | #endif // GOOGLE_PROTOBUF_PYTHON_CPP_SCALAR_MAP_CONTAINER_H__ 116 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/api_implementation.cc: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #include 32 | 33 | namespace google { 34 | namespace protobuf { 35 | namespace python { 36 | 37 | // Version constant. 38 | // This is either 0 for python, 1 for CPP V1, 2 for CPP V2. 39 | // 40 | // 0 is default and is equivalent to 41 | // PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python 42 | // 43 | // 1 is set with -DPYTHON_PROTO2_CPP_IMPL_V1 and is equivalent to 44 | // PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp 45 | // and 46 | // PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=1 47 | // 48 | // 2 is set with -DPYTHON_PROTO2_CPP_IMPL_V2 and is equivalent to 49 | // PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp 50 | // and 51 | // PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION=2 52 | #ifdef PYTHON_PROTO2_CPP_IMPL_V1 53 | #error "PYTHON_PROTO2_CPP_IMPL_V1 is no longer supported." 54 | #else 55 | #ifdef PYTHON_PROTO2_CPP_IMPL_V2 56 | static int kImplVersion = 2; 57 | #else 58 | #ifdef PYTHON_PROTO2_PYTHON_IMPL 59 | static int kImplVersion = 0; 60 | #else 61 | 62 | static int kImplVersion = -1; // -1 means "Unspecified by compiler flags". 63 | 64 | #endif // PYTHON_PROTO2_PYTHON_IMPL 65 | #endif // PYTHON_PROTO2_CPP_IMPL_V2 66 | #endif // PYTHON_PROTO2_CPP_IMPL_V1 67 | 68 | static const char* kImplVersionName = "api_version"; 69 | 70 | static const char* kModuleName = "_api_implementation"; 71 | static const char kModuleDocstring[] = 72 | "_api_implementation is a module that exposes compile-time constants that\n" 73 | "determine the default API implementation to use for Python proto2.\n" 74 | "\n" 75 | "It complements api_implementation.py by setting defaults using compile-time\n" 76 | "constants defined in C, such that one can set defaults at compilation\n" 77 | "(e.g. with blaze flag --copt=-DPYTHON_PROTO2_CPP_IMPL_V2)."; 78 | 79 | #if PY_MAJOR_VERSION >= 3 80 | static struct PyModuleDef _module = { 81 | PyModuleDef_HEAD_INIT, 82 | kModuleName, 83 | kModuleDocstring, 84 | -1, 85 | NULL, 86 | NULL, 87 | NULL, 88 | NULL, 89 | NULL 90 | }; 91 | #define INITFUNC PyInit__api_implementation 92 | #define INITFUNC_ERRORVAL NULL 93 | #else 94 | #define INITFUNC init_api_implementation 95 | #define INITFUNC_ERRORVAL 96 | #endif 97 | 98 | extern "C" { 99 | PyMODINIT_FUNC INITFUNC() { 100 | #if PY_MAJOR_VERSION >= 3 101 | PyObject *module = PyModule_Create(&_module); 102 | #else 103 | PyObject *module = Py_InitModule3( 104 | const_cast(kModuleName), 105 | NULL, 106 | const_cast(kModuleDocstring)); 107 | #endif 108 | if (module == NULL) { 109 | return INITFUNC_ERRORVAL; 110 | } 111 | 112 | // Adds the module variable "api_version". 113 | if (PyModule_AddIntConstant( 114 | module, 115 | const_cast(kImplVersionName), 116 | kImplVersion)) 117 | #if PY_MAJOR_VERSION < 3 118 | return; 119 | #else 120 | { Py_DECREF(module); return NULL; } 121 | 122 | return module; 123 | #endif 124 | } 125 | } 126 | 127 | } // namespace python 128 | } // namespace protobuf 129 | } // namespace google 130 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/repeated_scalar_container.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: anuraag@google.com (Anuraag Agrawal) 32 | // Author: tibell@google.com (Johan Tibell) 33 | 34 | #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_SCALAR_CONTAINER_H__ 35 | #define GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_SCALAR_CONTAINER_H__ 36 | 37 | #include 38 | 39 | #include 40 | #ifndef _SHARED_PTR_H 41 | #include 42 | #endif 43 | 44 | #include 45 | 46 | namespace google { 47 | namespace protobuf { 48 | 49 | class Message; 50 | 51 | using internal::shared_ptr; 52 | 53 | namespace python { 54 | 55 | struct CMessage; 56 | 57 | typedef struct RepeatedScalarContainer { 58 | PyObject_HEAD; 59 | 60 | // This is the top-level C++ Message object that owns the whole 61 | // proto tree. Every Python RepeatedScalarContainer holds a 62 | // reference to it in order to keep it alive as long as there's a 63 | // Python object that references any part of the tree. 64 | shared_ptr owner; 65 | 66 | // Pointer to the C++ Message that contains this container. The 67 | // RepeatedScalarContainer does not own this pointer. 68 | Message* message; 69 | 70 | // Weak reference to a parent CMessage object (i.e. may be NULL.) 71 | // 72 | // Used to make sure all ancestors are also mutable when first 73 | // modifying the container. 74 | CMessage* parent; 75 | 76 | // Pointer to the parent's descriptor that describes this 77 | // field. Used together with the parent's message when making a 78 | // default message instance mutable. 79 | // The pointer is owned by the global DescriptorPool. 80 | const FieldDescriptor* parent_field_descriptor; 81 | } RepeatedScalarContainer; 82 | 83 | extern PyTypeObject RepeatedScalarContainer_Type; 84 | 85 | namespace repeated_scalar_container { 86 | 87 | // Builds a RepeatedScalarContainer object, from a parent message and a 88 | // field descriptor. 89 | extern PyObject *NewContainer( 90 | CMessage* parent, const FieldDescriptor* parent_field_descriptor); 91 | 92 | // Appends the scalar 'item' to the end of the container 'self'. 93 | // 94 | // Returns None if successful; returns NULL and sets an exception if 95 | // unsuccessful. 96 | PyObject* Append(RepeatedScalarContainer* self, PyObject* item); 97 | 98 | // Releases the messages in the container to a new message. 99 | // 100 | // Returns 0 on success, -1 on failure. 101 | int Release(RepeatedScalarContainer* self); 102 | 103 | // Appends all the elements in the input iterator to the container. 104 | // 105 | // Returns None if successful; returns NULL and sets an exception if 106 | // unsuccessful. 107 | PyObject* Extend(RepeatedScalarContainer* self, PyObject* value); 108 | 109 | // Set the owner field of self and any children of self. 110 | void SetOwner(RepeatedScalarContainer* self, 111 | const shared_ptr& new_owner); 112 | 113 | } // namespace repeated_scalar_container 114 | } // namespace python 115 | } // namespace protobuf 116 | 117 | } // namespace google 118 | #endif // GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_SCALAR_CONTAINER_H__ 119 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/message_map_container.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_MESSAGE_MAP_CONTAINER_H__ 32 | #define GOOGLE_PROTOBUF_PYTHON_CPP_MESSAGE_MAP_CONTAINER_H__ 33 | 34 | #include 35 | 36 | #include 37 | #ifndef _SHARED_PTR_H 38 | #include 39 | #endif 40 | 41 | #include 42 | 43 | namespace google { 44 | namespace protobuf { 45 | 46 | class Message; 47 | 48 | using internal::shared_ptr; 49 | 50 | namespace python { 51 | 52 | struct CMessage; 53 | 54 | struct MessageMapContainer { 55 | PyObject_HEAD; 56 | 57 | // This is the top-level C++ Message object that owns the whole 58 | // proto tree. Every Python MessageMapContainer holds a 59 | // reference to it in order to keep it alive as long as there's a 60 | // Python object that references any part of the tree. 61 | shared_ptr owner; 62 | 63 | // Pointer to the C++ Message that contains this container. The 64 | // MessageMapContainer does not own this pointer. 65 | Message* message; 66 | 67 | // Weak reference to a parent CMessage object (i.e. may be NULL.) 68 | // 69 | // Used to make sure all ancestors are also mutable when first 70 | // modifying the container. 71 | CMessage* parent; 72 | 73 | // Pointer to the parent's descriptor that describes this 74 | // field. Used together with the parent's message when making a 75 | // default message instance mutable. 76 | // The pointer is owned by the global DescriptorPool. 77 | const FieldDescriptor* parent_field_descriptor; 78 | const FieldDescriptor* key_field_descriptor; 79 | const FieldDescriptor* value_field_descriptor; 80 | 81 | // A callable that is used to create new child messages. 82 | PyObject* subclass_init; 83 | 84 | // A dict mapping Message* -> CMessage. 85 | PyObject* message_dict; 86 | 87 | // We bump this whenever we perform a mutation, to invalidate existing 88 | // iterators. 89 | uint64 version; 90 | }; 91 | 92 | #if PY_MAJOR_VERSION >= 3 93 | extern PyObject *MessageMapContainer_Type; 94 | extern PyType_Spec MessageMapContainer_Type_spec; 95 | #else 96 | extern PyTypeObject MessageMapContainer_Type; 97 | #endif 98 | extern PyTypeObject MessageMapIterator_Type; 99 | 100 | namespace message_map_container { 101 | 102 | // Builds a MessageMapContainer object, from a parent message and a 103 | // field descriptor. 104 | extern PyObject* NewContainer(CMessage* parent, 105 | const FieldDescriptor* parent_field_descriptor, 106 | PyObject* concrete_class); 107 | 108 | // Releases the messages in the container to a new message. 109 | // 110 | // Returns 0 on success, -1 on failure. 111 | int Release(MessageMapContainer* self); 112 | 113 | // Set the owner field of self and any children of self. 114 | void SetOwner(MessageMapContainer* self, 115 | const shared_ptr& new_owner); 116 | 117 | } // namespace message_map_container 118 | } // namespace python 119 | } // namespace protobuf 120 | 121 | } // namespace google 122 | #endif // GOOGLE_PROTOBUF_PYTHON_CPP_MESSAGE_MAP_CONTAINER_H__ 123 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/text_encoding.py: -------------------------------------------------------------------------------- 1 | # Protocol Buffers - Google's data interchange format 2 | # Copyright 2008 Google Inc. All rights reserved. 3 | # https://developers.google.com/protocol-buffers/ 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Encoding related utilities.""" 32 | import re 33 | 34 | import six 35 | 36 | # Lookup table for utf8 37 | _cescape_utf8_to_str = [chr(i) for i in range(0, 256)] 38 | _cescape_utf8_to_str[9] = r'\t' # optional escape 39 | _cescape_utf8_to_str[10] = r'\n' # optional escape 40 | _cescape_utf8_to_str[13] = r'\r' # optional escape 41 | _cescape_utf8_to_str[39] = r"\'" # optional escape 42 | 43 | _cescape_utf8_to_str[34] = r'\"' # necessary escape 44 | _cescape_utf8_to_str[92] = r'\\' # necessary escape 45 | 46 | # Lookup table for non-utf8, with necessary escapes at (o >= 127 or o < 32) 47 | _cescape_byte_to_str = ([r'\%03o' % i for i in range(0, 32)] + 48 | [chr(i) for i in range(32, 127)] + 49 | [r'\%03o' % i for i in range(127, 256)]) 50 | _cescape_byte_to_str[9] = r'\t' # optional escape 51 | _cescape_byte_to_str[10] = r'\n' # optional escape 52 | _cescape_byte_to_str[13] = r'\r' # optional escape 53 | _cescape_byte_to_str[39] = r"\'" # optional escape 54 | 55 | _cescape_byte_to_str[34] = r'\"' # necessary escape 56 | _cescape_byte_to_str[92] = r'\\' # necessary escape 57 | 58 | 59 | def CEscape(text, as_utf8): 60 | """Escape a bytes string for use in an ascii protocol buffer. 61 | 62 | text.encode('string_escape') does not seem to satisfy our needs as it 63 | encodes unprintable characters using two-digit hex escapes whereas our 64 | C++ unescaping function allows hex escapes to be any length. So, 65 | "\0011".encode('string_escape') ends up being "\\x011", which will be 66 | decoded in C++ as a single-character string with char code 0x11. 67 | 68 | Args: 69 | text: A byte string to be escaped 70 | as_utf8: Specifies if result should be returned in UTF-8 encoding 71 | Returns: 72 | Escaped string 73 | """ 74 | # PY3 hack: make Ord work for str and bytes: 75 | # //platforms/networking/data uses unicode here, hence basestring. 76 | Ord = ord if isinstance(text, six.string_types) else lambda x: x 77 | if as_utf8: 78 | return ''.join(_cescape_utf8_to_str[Ord(c)] for c in text) 79 | return ''.join(_cescape_byte_to_str[Ord(c)] for c in text) 80 | 81 | 82 | _CUNESCAPE_HEX = re.compile(r'(\\+)x([0-9a-fA-F])(?![0-9a-fA-F])') 83 | _cescape_highbit_to_str = ([chr(i) for i in range(0, 127)] + 84 | [r'\%03o' % i for i in range(127, 256)]) 85 | 86 | 87 | def CUnescape(text): 88 | """Unescape a text string with C-style escape sequences to UTF-8 bytes.""" 89 | 90 | def ReplaceHex(m): 91 | # Only replace the match if the number of leading back slashes is odd. i.e. 92 | # the slash itself is not escaped. 93 | if len(m.group(1)) & 1: 94 | return m.group(1) + 'x0' + m.group(2) 95 | return m.group(0) 96 | 97 | # This is required because the 'string_escape' encoding doesn't 98 | # allow single-digit hex escapes (like '\xf'). 99 | result = _CUNESCAPE_HEX.sub(ReplaceHex, text) 100 | 101 | if str is bytes: # PY2 102 | return result.decode('string_escape') 103 | result = ''.join(_cescape_highbit_to_str[ord(c)] for c in result) 104 | return (result.encode('ascii') # Make it bytes to allow decode. 105 | .decode('unicode_escape') 106 | # Make it bytes again to return the proper type. 107 | .encode('raw_unicode_escape')) 108 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/api_implementation.py: -------------------------------------------------------------------------------- 1 | # Protocol Buffers - Google's data interchange format 2 | # Copyright 2008 Google Inc. All rights reserved. 3 | # https://developers.google.com/protocol-buffers/ 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Determine which implementation of the protobuf API is used in this process. 32 | """ 33 | 34 | import os 35 | import sys 36 | 37 | try: 38 | # pylint: disable=g-import-not-at-top 39 | from google.protobuf.internal import _api_implementation 40 | # The compile-time constants in the _api_implementation module can be used to 41 | # switch to a certain implementation of the Python API at build time. 42 | _api_version = _api_implementation.api_version 43 | _proto_extension_modules_exist_in_build = True 44 | except ImportError: 45 | _api_version = -1 # Unspecified by compiler flags. 46 | _proto_extension_modules_exist_in_build = False 47 | 48 | if _api_version == 1: 49 | raise ValueError('api_version=1 is no longer supported.') 50 | if _api_version < 0: # Still unspecified? 51 | try: 52 | # The presence of this module in a build allows the proto implementation to 53 | # be upgraded merely via build deps rather than a compiler flag or the 54 | # runtime environment variable. 55 | # pylint: disable=g-import-not-at-top 56 | from google.protobuf import _use_fast_cpp_protos 57 | # Work around a known issue in the classic bootstrap .par import hook. 58 | if not _use_fast_cpp_protos: 59 | raise ImportError('_use_fast_cpp_protos import succeeded but was None') 60 | del _use_fast_cpp_protos 61 | _api_version = 2 62 | except ImportError: 63 | if _proto_extension_modules_exist_in_build: 64 | if sys.version_info[0] >= 3: # Python 3 defaults to C++ impl v2. 65 | _api_version = 2 66 | # TODO(b/17427486): Make Python 2 default to C++ impl v2. 67 | 68 | _default_implementation_type = ( 69 | 'python' if _api_version <= 0 else 'cpp') 70 | 71 | # This environment variable can be used to switch to a certain implementation 72 | # of the Python API, overriding the compile-time constants in the 73 | # _api_implementation module. Right now only 'python' and 'cpp' are valid 74 | # values. Any other value will be ignored. 75 | _implementation_type = os.getenv('PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION', 76 | _default_implementation_type) 77 | 78 | if _implementation_type != 'python': 79 | _implementation_type = 'cpp' 80 | 81 | # This environment variable can be used to switch between the two 82 | # 'cpp' implementations, overriding the compile-time constants in the 83 | # _api_implementation module. Right now only '2' is supported. Any other 84 | # value will cause an error to be raised. 85 | _implementation_version_str = os.getenv( 86 | 'PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION', '2') 87 | 88 | if _implementation_version_str != '2': 89 | raise ValueError( 90 | 'unsupported PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION: "' + 91 | _implementation_version_str + '" (supported versions: 2)' 92 | ) 93 | 94 | _implementation_version = int(_implementation_version_str) 95 | 96 | 97 | # Usage of this function is discouraged. Clients shouldn't care which 98 | # implementation of the API is in use. Note that there is no guarantee 99 | # that differences between APIs will be maintained. 100 | # Please don't use this function if possible. 101 | def Type(): 102 | return _implementation_type 103 | 104 | 105 | # See comment on 'Type' above. 106 | def Version(): 107 | return _implementation_version 108 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/reflection.py: -------------------------------------------------------------------------------- 1 | # Protocol Buffers - Google's data interchange format 2 | # Copyright 2008 Google Inc. All rights reserved. 3 | # https://developers.google.com/protocol-buffers/ 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | # This code is meant to work on Python 2.4 and above only. 32 | 33 | """Contains a metaclass and helper functions used to create 34 | protocol message classes from Descriptor objects at runtime. 35 | 36 | Recall that a metaclass is the "type" of a class. 37 | (A class is to a metaclass what an instance is to a class.) 38 | 39 | In this case, we use the GeneratedProtocolMessageType metaclass 40 | to inject all the useful functionality into the classes 41 | output by the protocol compiler at compile-time. 42 | 43 | The upshot of all this is that the real implementation 44 | details for ALL pure-Python protocol buffers are *here in 45 | this file*. 46 | """ 47 | 48 | __author__ = 'robinson@google.com (Will Robinson)' 49 | 50 | 51 | from google.protobuf.internal import api_implementation 52 | from google.protobuf import message 53 | 54 | 55 | if api_implementation.Type() == 'cpp': 56 | from google.protobuf.pyext import cpp_message as message_impl 57 | else: 58 | from google.protobuf.internal import python_message as message_impl 59 | 60 | # The type of all Message classes. 61 | # Part of the public interface. 62 | # 63 | # Used by generated files, but clients can also use it at runtime: 64 | # mydescriptor = pool.FindDescriptor(.....) 65 | # class MyProtoClass(Message): 66 | # __metaclass__ = GeneratedProtocolMessageType 67 | # DESCRIPTOR = mydescriptor 68 | GeneratedProtocolMessageType = message_impl.GeneratedProtocolMessageType 69 | 70 | 71 | def ParseMessage(descriptor, byte_str): 72 | """Generate a new Message instance from this Descriptor and a byte string. 73 | 74 | Args: 75 | descriptor: Protobuf Descriptor object 76 | byte_str: Serialized protocol buffer byte string 77 | 78 | Returns: 79 | Newly created protobuf Message object. 80 | """ 81 | result_class = MakeClass(descriptor) 82 | new_msg = result_class() 83 | new_msg.ParseFromString(byte_str) 84 | return new_msg 85 | 86 | 87 | def MakeClass(descriptor): 88 | """Construct a class object for a protobuf described by descriptor. 89 | 90 | Composite descriptors are handled by defining the new class as a member of the 91 | parent class, recursing as deep as necessary. 92 | This is the dynamic equivalent to: 93 | 94 | class Parent(message.Message): 95 | __metaclass__ = GeneratedProtocolMessageType 96 | DESCRIPTOR = descriptor 97 | class Child(message.Message): 98 | __metaclass__ = GeneratedProtocolMessageType 99 | DESCRIPTOR = descriptor.nested_types[0] 100 | 101 | Sample usage: 102 | file_descriptor = descriptor_pb2.FileDescriptorProto() 103 | file_descriptor.ParseFromString(proto2_string) 104 | msg_descriptor = descriptor.MakeDescriptor(file_descriptor.message_type[0]) 105 | msg_class = reflection.MakeClass(msg_descriptor) 106 | msg = msg_class() 107 | 108 | Args: 109 | descriptor: A descriptor.Descriptor object describing the protobuf. 110 | Returns: 111 | The Message class object described by the descriptor. 112 | """ 113 | attributes = {} 114 | for name, nested_type in descriptor.nested_types_by_name.items(): 115 | attributes[name] = MakeClass(nested_type) 116 | 117 | attributes[GeneratedProtocolMessageType._DESCRIPTOR_KEY] = descriptor 118 | 119 | return GeneratedProtocolMessageType(str(descriptor.name), (message.Message,), 120 | attributes) 121 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/extension_dict.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Author: anuraag@google.com (Anuraag Agrawal) 32 | // Author: tibell@google.com (Johan Tibell) 33 | 34 | #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__ 35 | #define GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__ 36 | 37 | #include 38 | 39 | #include 40 | #ifndef _SHARED_PTR_H 41 | #include 42 | #endif 43 | 44 | namespace google { 45 | namespace protobuf { 46 | 47 | class Message; 48 | class FieldDescriptor; 49 | 50 | using internal::shared_ptr; 51 | 52 | namespace python { 53 | 54 | struct CMessage; 55 | 56 | typedef struct ExtensionDict { 57 | PyObject_HEAD; 58 | 59 | // This is the top-level C++ Message object that owns the whole 60 | // proto tree. Every Python container class holds a 61 | // reference to it in order to keep it alive as long as there's a 62 | // Python object that references any part of the tree. 63 | shared_ptr owner; 64 | 65 | // Weak reference to parent message. Used to make sure 66 | // the parent is writable when an extension field is modified. 67 | CMessage* parent; 68 | 69 | // Pointer to the C++ Message that this ExtensionDict extends. 70 | // Not owned by us. 71 | Message* message; 72 | 73 | // A dict of child messages, indexed by Extension descriptors. 74 | // Similar to CMessage::composite_fields. 75 | PyObject* values; 76 | } ExtensionDict; 77 | 78 | extern PyTypeObject ExtensionDict_Type; 79 | 80 | namespace extension_dict { 81 | 82 | // Builds an Extensions dict for a specific message. 83 | ExtensionDict* NewExtensionDict(CMessage *parent); 84 | 85 | // Gets the number of extension values in this ExtensionDict as a python object. 86 | // 87 | // Returns a new reference. 88 | PyObject* len(ExtensionDict* self); 89 | 90 | // Releases extensions referenced outside this dictionary to keep outside 91 | // references alive. 92 | // 93 | // Returns 0 on success, -1 on failure. 94 | int ReleaseExtension(ExtensionDict* self, 95 | PyObject* extension, 96 | const FieldDescriptor* descriptor); 97 | 98 | // Gets an extension from the dict for the given extension descriptor. 99 | // 100 | // Returns a new reference. 101 | PyObject* subscript(ExtensionDict* self, PyObject* key); 102 | 103 | // Assigns a value to an extension in the dict. Can only be used for singular 104 | // simple types. 105 | // 106 | // Returns 0 on success, -1 on failure. 107 | int ass_subscript(ExtensionDict* self, PyObject* key, PyObject* value); 108 | 109 | // Clears an extension from the dict. Will release the extension if there 110 | // is still an external reference left to it. 111 | // 112 | // Returns None on success. 113 | PyObject* ClearExtension(ExtensionDict* self, 114 | PyObject* extension); 115 | 116 | // Checks if the dict has an extension. 117 | // 118 | // Returns a new python boolean reference. 119 | PyObject* HasExtension(ExtensionDict* self, PyObject* extension); 120 | 121 | // Gets an extension from the dict given the extension name as opposed to 122 | // descriptor. 123 | // 124 | // Returns a new reference. 125 | PyObject* _FindExtensionByName(ExtensionDict* self, PyObject* name); 126 | 127 | } // namespace extension_dict 128 | } // namespace python 129 | } // namespace protobuf 130 | 131 | } // namespace google 132 | #endif // GOOGLE_PROTOBUF_PYTHON_CPP_EXTENSION_DICT_H__ 133 | -------------------------------------------------------------------------------- /ved-decoder-master/ved.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # ugly path patching 4 | import sys 5 | import os 6 | sys.path.append(os.path.abspath(os.path.join(__file__, '..', 'lib'))) 7 | 8 | import base64 9 | from proto.ved_pb2 import Ved 10 | 11 | ''' 12 | The type of link encoded in the ved message. If you find out, what other values mean, 13 | please either send me a pull request or comment in the article 14 | (http://gqs-decoder.blogspot.com/2013/08/google-referrer-query-strings-debunked-part-1.html) 15 | ''' 16 | LINK_TYPES = { 17 | 22 : 'web', 18 | 152 : 'blog search result', 19 | 232 : 'book search result', 20 | 232 : 'patent result', 21 | 235 : 'book search result thumbnail', 22 | 235 : 'patent result thumbnail', 23 | 244 : 'image result in standard SERPs', 24 | 245 : 'image search result in basic (non-javascript) image search, or image result in universal search', 25 | 288 : 'local search result', 26 | 295 : 'news result thumbnail', 27 | 297 : 'news result', 28 | 300 : 'more results link (listed mainly for Q&A websites)', 29 | 311 : 'video result', 30 | 312 : 'video result thumbnail', 31 | 338 : 'one-line sitelink', 32 | 371 : 'shopping search result', 33 | 429 : 'image search result [probably not in use any more]', 34 | 586 : '"Jump to" link', 35 | 612 : 'map search result website link', 36 | 646 : 'map search result thumbnail', 37 | 706 : 'adword sitelink', 38 | 745 : 'breadcrumb', 39 | 1107 : 'patent result "Overview" / "Related" / "Discuss" link', 40 | 1140 : 'book search result author link', 41 | 1146 : 'normal result thumbnail (e.g. for an application, recipe, etc.)', 42 | 1150 : 'normal result thumbnail (e.g. for an application, recipe, etc.)', 43 | 1455 : 'local search result marker pin icon', 44 | 1532 : 'news sub-result (i.e. the same story from a different site)', 45 | 1617 : 'adword (i.e. sponsored search result)', 46 | 1701 : 'map search result', 47 | 1732 : 'knowledge graph repeated sub-link (e.g. football team squad players, album track listings)', 48 | 1907 : 'sponsored shopping result thumbnail (in right-hand column of universal search results)', 49 | 1908 : 'sponsored shopping result (in right-hand column of universal search results)', 50 | 1986 : 'sponsored shopping result thumbnail (in main column of universal search results)', 51 | 1987 : 'sponsored shopping result (in main column of universal search results)', 52 | 2060 : 'sitelink', 53 | 2237 : 'news result video thumbnail', 54 | 2459 : 'knowledge graph link', 55 | 2847 : 'authorship "by [author]" link', 56 | 2937 : 'authorship thumbnail link', 57 | 3588 : 'image search result (thumbnail)', 58 | 3596 : 'image search result preview "View image" link', 59 | 3597 : 'image search result preview thumbnail', 60 | 3598 : 'image search result preview title link', 61 | 3599 : 'image search result preview "Visit page" link', 62 | 3724 : 'image search result preview grey website link underneath title', 63 | 3836 : 'knowledge graph main image', 64 | 5077 : 'in-depth article result', 65 | 5078 : 'in-depth article result thumbnail', 66 | 5158 : 'adword one-line sitelink', 67 | 5497 : 'dictionary definition link' 68 | } 69 | 70 | 71 | def try_decode(s): 72 | ''' try to base64 decode s. return None, if decoding fails ''' 73 | try: 74 | return base64.b64decode(str(s)+'=====', '_-') 75 | except TypeError: 76 | return None 77 | 78 | 79 | def decode_ved_plain(s): 80 | ''' decode the plain text varian of the ved parameter. no error checking. ''' 81 | 82 | key_mapping = {'i':'index_boost', 't':'type', 'r':'result_position', 's':'start'} 83 | 84 | kv_pairs = s.split(',') 85 | kv_pairs = map(lambda x: x.split(':'), kv_pairs) 86 | kv_pairs = map(lambda (k,v): (key_mapping[k], int(v)), kv_pairs) 87 | return dict(kv_pairs) 88 | 89 | 90 | def decode_ved_protobuf(s): 91 | ''' decode the protobuf variant of the ved parameter. ''' 92 | 93 | decoded = try_decode(s) 94 | if not decoded: 95 | return None 96 | ved = Ved() 97 | try: 98 | ved.ParseFromString(decoded) 99 | 100 | ret = {} 101 | for k, v in ved.ListFields(): 102 | ret[k.name] = v 103 | return ret 104 | except DecodeError: 105 | return None 106 | 107 | 108 | def decode_ved(s): 109 | ''' decode a ved ''' 110 | if not s: 111 | return None 112 | if s[0] == '1': 113 | return decode_ved_plain(s[1:]) 114 | elif s[0] == '0': 115 | return decode_ved_protobuf(s[1:]) 116 | 117 | 118 | def format_type(type): 119 | type_name = LINK_TYPES.get(type, 'unknown') 120 | return '%s (%s)' % (type_name, type) 121 | 122 | 123 | def format_ved(ved): 124 | if ved: 125 | if 'type' in ved: 126 | ved['type'] = format_type(ved['type']) 127 | if 'link_type' in ved: 128 | ved['link_type'] = format_type(ved['link_type']) 129 | if 'mysterious_msg' in ved: 130 | filth = "" 131 | for k, v in ved['mysterious_msg'].ListFields(): 132 | # ved['mysterious_msg'][k.name] = v 133 | filth += str(v).replace("\n", ", ") 134 | ved['mysterious_msg'] = filth 135 | 136 | return ved 137 | 138 | 139 | def main(): 140 | import sys 141 | for line in sys.stdin: 142 | line = line.strip() 143 | if not line: 144 | continue 145 | print line 146 | print format_ved(decode_ved(line)) 147 | print "---" 148 | 149 | if __name__ == '__main__': 150 | main() 151 | -------------------------------------------------------------------------------- /google-ei-time.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # google-ei-time.py = Python script takes a Google Search URL or ei parameter and returns a human readable timestamp 4 | # 5 | # Copyright (C) 2014 Adrian Leong (cheeky4n6monkey@gmail.com) 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You can view the GNU General Public License at 18 | # 19 | # Special Thanks to Phillip Moore for suggesting the idea and for helping to test it. 20 | # 21 | # Reference: 22 | # https://deedpolloffice.com/blog/articles/decoding-ei-parameter 23 | # Example: 24 | # http://www.google.com.au/?gfe_rd=cr&ei=tci4UszSJeLN7Ab9xYD4CQ 25 | # ei=tci4UszSJeLN7Ab9xYD4CQ => 1387841717 => 23rd December 2013 at 23.35.17 26 | # 27 | # Version History: 28 | # v2014-10-10 Initial Version 29 | # v2019-09-09 Update to python3 by PM 30 | 31 | import sys 32 | from optparse import OptionParser 33 | import datetime 34 | import base64 35 | 36 | try: 37 | from urllib.parse import urlparse 38 | except ImportError: 39 | from urlparse import urlparse 40 | 41 | version_string = "google-ei-time.py v2019-09-09" 42 | usage = "%prog -e EITERM -q OR %prog -u URL -q" 43 | 44 | parser = OptionParser(usage=usage) 45 | parser.add_option("-e", dest="eiterm", 46 | action="store", type="string", 47 | help="Google search URLs EI parameter value") 48 | parser.add_option("-u", dest="url", 49 | action="store", type="string", 50 | help="Complete Google search URL") 51 | parser.add_option("-q", dest="quiet", 52 | action="store_true", 53 | help="(Optional) Quiet output (only outputs timestamp string)") 54 | (options, args) = parser.parse_args() 55 | 56 | if not (options.quiet): 57 | print ("Running " + version_string + "\n") 58 | 59 | # No arguments given by user, print help and exit 60 | if len(sys.argv) == 1: 61 | parser.print_help() 62 | exit(-1) 63 | 64 | if ((options.eiterm == None) and (options.url == None)): 65 | print ("Error! Neither ei or URL terms were specified. Choose one!\n") 66 | parser.print_help() 67 | exit(-1) 68 | 69 | if ((options.eiterm != None) and (options.url != None)): 70 | print ("Error! BOTH ei and URL terms were specified. Choose one!\n") 71 | parser.print_help() 72 | exit(-1) 73 | 74 | ei = "" 75 | if (options.url != None): 76 | parsed = urlparse(options.url) 77 | #parsed = urlparse.urlparse(options.url) 78 | #print parsed 79 | # returns a 6 tuple list. The element we're interested in is "parsed.query" 80 | if ("ei" not in parsed.query): 81 | if not (options.quiet): 82 | print ("No ei parameter found in URL!") 83 | exit(-1) 84 | 85 | # search parsed query for "ei" parameter and extract the returned list item 86 | # parse_qs returns a dictionary item, hence the following ["ei"]. 87 | # The dictionary value is a list, hence the following [0] 88 | ei = urlparse.parse_qs(parsed.query)["ei"][0] 89 | #ei = urlparse.parse_qs(parsed.query)["ei"][0] 90 | if not (options.quiet): 91 | print ("URL's ei term = " + ei) 92 | else: 93 | ei = options.eiterm 94 | if not (options.quiet): 95 | print ("Input ei term = " + ei) 96 | 97 | # ei parameter may require padding (length must be a multiple of 4 for Python's base64 decode) 98 | num_extra_bytes = (len(ei) % 4) # equals number of extra bytes past last multiple of 4 eg equals 1 for ei length of 21 99 | if (num_extra_bytes != 0): 100 | padlength = 4 - num_extra_bytes # eg 4 - 1 results in 3 extra "=" pad bytes being added 101 | padstring = ei + padlength*'=' 102 | else: 103 | padstring = ei 104 | 105 | if not (options.quiet): 106 | print ("Padded base64 string = " + padstring) 107 | 108 | # Apparently the base64 string are made URL safe by substituting - instead of + and _ instead of / 109 | # Python base64 conveniently has a "urlsafe_b64decode" function to handle the reverse of the above substitution 110 | # Will the wonders never cease? 111 | decoded = base64.urlsafe_b64decode(padstring) 112 | 113 | #print decoded 114 | #print "decoded length = " + str(len(decoded)) 115 | # decoded should be 16 bytes ... 116 | 117 | # grab 1st 4 bytes and treat as LE unsigned int 118 | # byte 0 is least significant ... byte 3 is most significant 119 | # a byte is 8 bits and ranges from 00000000 to 11111111 (dec. 255) 120 | # Each byte range is 256 times the previous bytes range 121 | # ie xFF = 255, xFF00 = 255 * 256 = 65280 dec, xFF0000 = 255 * 256 *256 = 16711680 dec 122 | # Calling "ord" converts the given byte string into a number 123 | timestamp = (decoded[0]) + (decoded[1])*256 + (decoded[2])*(256**2) + (decoded[3])*(256**3) 124 | #timestamp = ord(decoded[0]) + ord(decoded[1])*256 + ord(decoded[2])*(256**2) + ord(decoded[3])*(256**3) 125 | 126 | if not (options.quiet): 127 | print ("Extracted timestamp = " + str(timestamp)) 128 | 129 | try: 130 | datetimestr = datetime.datetime.utcfromtimestamp(timestamp).strftime('%Y-%m-%dT%H:%M:%S') 131 | except: 132 | datetimestr = "Unknown" 133 | 134 | if not (options.quiet): 135 | print ("Human readable timestamp (UTC) = " + datetimestr) 136 | else: 137 | print (datetimestr) 138 | 139 | exit(0) 140 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/descriptor_database.py: -------------------------------------------------------------------------------- 1 | # Protocol Buffers - Google's data interchange format 2 | # Copyright 2008 Google Inc. All rights reserved. 3 | # https://developers.google.com/protocol-buffers/ 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Provides a container for DescriptorProtos.""" 32 | 33 | __author__ = 'matthewtoia@google.com (Matt Toia)' 34 | 35 | 36 | class Error(Exception): 37 | pass 38 | 39 | 40 | class DescriptorDatabaseConflictingDefinitionError(Error): 41 | """Raised when a proto is added with the same name & different descriptor.""" 42 | 43 | 44 | class DescriptorDatabase(object): 45 | """A container accepting FileDescriptorProtos and maps DescriptorProtos.""" 46 | 47 | def __init__(self): 48 | self._file_desc_protos_by_file = {} 49 | self._file_desc_protos_by_symbol = {} 50 | 51 | def Add(self, file_desc_proto): 52 | """Adds the FileDescriptorProto and its types to this database. 53 | 54 | Args: 55 | file_desc_proto: The FileDescriptorProto to add. 56 | Raises: 57 | DescriptorDatabaseException: if an attempt is made to add a proto 58 | with the same name but different definition than an exisiting 59 | proto in the database. 60 | """ 61 | proto_name = file_desc_proto.name 62 | if proto_name not in self._file_desc_protos_by_file: 63 | self._file_desc_protos_by_file[proto_name] = file_desc_proto 64 | elif self._file_desc_protos_by_file[proto_name] != file_desc_proto: 65 | raise DescriptorDatabaseConflictingDefinitionError( 66 | '%s already added, but with different descriptor.' % proto_name) 67 | 68 | package = file_desc_proto.package 69 | for message in file_desc_proto.message_type: 70 | self._file_desc_protos_by_symbol.update( 71 | (name, file_desc_proto) for name in _ExtractSymbols(message, package)) 72 | for enum in file_desc_proto.enum_type: 73 | self._file_desc_protos_by_symbol[ 74 | '.'.join((package, enum.name))] = file_desc_proto 75 | 76 | def FindFileByName(self, name): 77 | """Finds the file descriptor proto by file name. 78 | 79 | Typically the file name is a relative path ending to a .proto file. The 80 | proto with the given name will have to have been added to this database 81 | using the Add method or else an error will be raised. 82 | 83 | Args: 84 | name: The file name to find. 85 | 86 | Returns: 87 | The file descriptor proto matching the name. 88 | 89 | Raises: 90 | KeyError if no file by the given name was added. 91 | """ 92 | 93 | return self._file_desc_protos_by_file[name] 94 | 95 | def FindFileContainingSymbol(self, symbol): 96 | """Finds the file descriptor proto containing the specified symbol. 97 | 98 | The symbol should be a fully qualified name including the file descriptor's 99 | package and any containing messages. Some examples: 100 | 101 | 'some.package.name.Message' 102 | 'some.package.name.Message.NestedEnum' 103 | 104 | The file descriptor proto containing the specified symbol must be added to 105 | this database using the Add method or else an error will be raised. 106 | 107 | Args: 108 | symbol: The fully qualified symbol name. 109 | 110 | Returns: 111 | The file descriptor proto containing the symbol. 112 | 113 | Raises: 114 | KeyError if no file contains the specified symbol. 115 | """ 116 | 117 | return self._file_desc_protos_by_symbol[symbol] 118 | 119 | 120 | def _ExtractSymbols(desc_proto, package): 121 | """Pulls out all the symbols from a descriptor proto. 122 | 123 | Args: 124 | desc_proto: The proto to extract symbols from. 125 | package: The package containing the descriptor type. 126 | 127 | Yields: 128 | The fully qualified name found in the descriptor. 129 | """ 130 | 131 | message_name = '.'.join((package, desc_proto.name)) 132 | yield message_name 133 | for nested_type in desc_proto.nested_type: 134 | for symbol in _ExtractSymbols(nested_type, message_name): 135 | yield symbol 136 | for enum_type in desc_proto.enum_type: 137 | yield '.'.join((message_name, enum_type.name)) 138 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/proto_builder.py: -------------------------------------------------------------------------------- 1 | # Protocol Buffers - Google's data interchange format 2 | # Copyright 2008 Google Inc. All rights reserved. 3 | # https://developers.google.com/protocol-buffers/ 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Dynamic Protobuf class creator.""" 32 | 33 | try: 34 | from collections import OrderedDict 35 | except ImportError: 36 | from ordereddict import OrderedDict #PY26 37 | import hashlib 38 | import os 39 | 40 | from google.protobuf import descriptor_pb2 41 | from google.protobuf import message_factory 42 | 43 | 44 | def _GetMessageFromFactory(factory, full_name): 45 | """Get a proto class from the MessageFactory by name. 46 | 47 | Args: 48 | factory: a MessageFactory instance. 49 | full_name: str, the fully qualified name of the proto type. 50 | Returns: 51 | A class, for the type identified by full_name. 52 | Raises: 53 | KeyError, if the proto is not found in the factory's descriptor pool. 54 | """ 55 | proto_descriptor = factory.pool.FindMessageTypeByName(full_name) 56 | proto_cls = factory.GetPrototype(proto_descriptor) 57 | return proto_cls 58 | 59 | 60 | def MakeSimpleProtoClass(fields, full_name=None, pool=None): 61 | """Create a Protobuf class whose fields are basic types. 62 | 63 | Note: this doesn't validate field names! 64 | 65 | Args: 66 | fields: dict of {name: field_type} mappings for each field in the proto. If 67 | this is an OrderedDict the order will be maintained, otherwise the 68 | fields will be sorted by name. 69 | full_name: optional str, the fully-qualified name of the proto type. 70 | pool: optional DescriptorPool instance. 71 | Returns: 72 | a class, the new protobuf class with a FileDescriptor. 73 | """ 74 | factory = message_factory.MessageFactory(pool=pool) 75 | 76 | if full_name is not None: 77 | try: 78 | proto_cls = _GetMessageFromFactory(factory, full_name) 79 | return proto_cls 80 | except KeyError: 81 | # The factory's DescriptorPool doesn't know about this class yet. 82 | pass 83 | 84 | # Get a list of (name, field_type) tuples from the fields dict. If fields was 85 | # an OrderedDict we keep the order, but otherwise we sort the field to ensure 86 | # consistent ordering. 87 | field_items = fields.items() 88 | if not isinstance(fields, OrderedDict): 89 | field_items = sorted(field_items) 90 | 91 | # Use a consistent file name that is unlikely to conflict with any imported 92 | # proto files. 93 | fields_hash = hashlib.sha1() 94 | for f_name, f_type in field_items: 95 | fields_hash.update(f_name.encode('utf-8')) 96 | fields_hash.update(str(f_type).encode('utf-8')) 97 | proto_file_name = fields_hash.hexdigest() + '.proto' 98 | 99 | # If the proto is anonymous, use the same hash to name it. 100 | if full_name is None: 101 | full_name = ('net.proto2.python.public.proto_builder.AnonymousProto_' + 102 | fields_hash.hexdigest()) 103 | try: 104 | proto_cls = _GetMessageFromFactory(factory, full_name) 105 | return proto_cls 106 | except KeyError: 107 | # The factory's DescriptorPool doesn't know about this class yet. 108 | pass 109 | 110 | # This is the first time we see this proto: add a new descriptor to the pool. 111 | factory.pool.Add( 112 | _MakeFileDescriptorProto(proto_file_name, full_name, field_items)) 113 | return _GetMessageFromFactory(factory, full_name) 114 | 115 | 116 | def _MakeFileDescriptorProto(proto_file_name, full_name, field_items): 117 | """Populate FileDescriptorProto for MessageFactory's DescriptorPool.""" 118 | package, name = full_name.rsplit('.', 1) 119 | file_proto = descriptor_pb2.FileDescriptorProto() 120 | file_proto.name = os.path.join(package.replace('.', '/'), proto_file_name) 121 | file_proto.package = package 122 | desc_proto = file_proto.message_type.add() 123 | desc_proto.name = name 124 | for f_number, (f_name, f_type) in enumerate(field_items, 1): 125 | field_proto = desc_proto.field.add() 126 | field_proto.name = f_name 127 | field_proto.number = f_number 128 | field_proto.label = descriptor_pb2.FieldDescriptorProto.LABEL_OPTIONAL 129 | field_proto.type = f_type 130 | return file_proto 131 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/service_reflection_test.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # Protocol Buffers - Google's data interchange format 4 | # Copyright 2008 Google Inc. All rights reserved. 5 | # https://developers.google.com/protocol-buffers/ 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are 9 | # met: 10 | # 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above 14 | # copyright notice, this list of conditions and the following disclaimer 15 | # in the documentation and/or other materials provided with the 16 | # distribution. 17 | # * Neither the name of Google Inc. nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | """Tests for google.protobuf.internal.service_reflection.""" 34 | 35 | __author__ = 'petar@google.com (Petar Petrov)' 36 | 37 | try: 38 | import unittest2 as unittest 39 | except ImportError: 40 | import unittest 41 | from google.protobuf import unittest_pb2 42 | from google.protobuf import service_reflection 43 | from google.protobuf import service 44 | 45 | 46 | class FooUnitTest(unittest.TestCase): 47 | 48 | def testService(self): 49 | class MockRpcChannel(service.RpcChannel): 50 | def CallMethod(self, method, controller, request, response, callback): 51 | self.method = method 52 | self.controller = controller 53 | self.request = request 54 | callback(response) 55 | 56 | class MockRpcController(service.RpcController): 57 | def SetFailed(self, msg): 58 | self.failure_message = msg 59 | 60 | self.callback_response = None 61 | 62 | class MyService(unittest_pb2.TestService): 63 | pass 64 | 65 | self.callback_response = None 66 | 67 | def MyCallback(response): 68 | self.callback_response = response 69 | 70 | rpc_controller = MockRpcController() 71 | channel = MockRpcChannel() 72 | srvc = MyService() 73 | srvc.Foo(rpc_controller, unittest_pb2.FooRequest(), MyCallback) 74 | self.assertEqual('Method Foo not implemented.', 75 | rpc_controller.failure_message) 76 | self.assertEqual(None, self.callback_response) 77 | 78 | rpc_controller.failure_message = None 79 | 80 | service_descriptor = unittest_pb2.TestService.GetDescriptor() 81 | srvc.CallMethod(service_descriptor.methods[1], rpc_controller, 82 | unittest_pb2.BarRequest(), MyCallback) 83 | self.assertEqual('Method Bar not implemented.', 84 | rpc_controller.failure_message) 85 | self.assertEqual(None, self.callback_response) 86 | 87 | class MyServiceImpl(unittest_pb2.TestService): 88 | def Foo(self, rpc_controller, request, done): 89 | self.foo_called = True 90 | def Bar(self, rpc_controller, request, done): 91 | self.bar_called = True 92 | 93 | srvc = MyServiceImpl() 94 | rpc_controller.failure_message = None 95 | srvc.Foo(rpc_controller, unittest_pb2.FooRequest(), MyCallback) 96 | self.assertEqual(None, rpc_controller.failure_message) 97 | self.assertEqual(True, srvc.foo_called) 98 | 99 | rpc_controller.failure_message = None 100 | srvc.CallMethod(service_descriptor.methods[1], rpc_controller, 101 | unittest_pb2.BarRequest(), MyCallback) 102 | self.assertEqual(None, rpc_controller.failure_message) 103 | self.assertEqual(True, srvc.bar_called) 104 | 105 | def testServiceStub(self): 106 | class MockRpcChannel(service.RpcChannel): 107 | def CallMethod(self, method, controller, request, 108 | response_class, callback): 109 | self.method = method 110 | self.controller = controller 111 | self.request = request 112 | callback(response_class()) 113 | 114 | self.callback_response = None 115 | 116 | def MyCallback(response): 117 | self.callback_response = response 118 | 119 | channel = MockRpcChannel() 120 | stub = unittest_pb2.TestService_Stub(channel) 121 | rpc_controller = 'controller' 122 | request = 'request' 123 | 124 | # GetDescriptor now static, still works as instance method for compatibility 125 | self.assertEqual(unittest_pb2.TestService_Stub.GetDescriptor(), 126 | stub.GetDescriptor()) 127 | 128 | # Invoke method. 129 | stub.Foo(rpc_controller, request, MyCallback) 130 | 131 | self.assertIsInstance(self.callback_response, unittest_pb2.FooResponse) 132 | self.assertEqual(request, channel.request) 133 | self.assertEqual(rpc_controller, channel.controller) 134 | self.assertEqual(stub.GetDescriptor().methods[0], channel.method) 135 | 136 | 137 | if __name__ == '__main__': 138 | unittest.main() 139 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/symbol_database_test.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # Protocol Buffers - Google's data interchange format 4 | # Copyright 2008 Google Inc. All rights reserved. 5 | # https://developers.google.com/protocol-buffers/ 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are 9 | # met: 10 | # 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above 14 | # copyright notice, this list of conditions and the following disclaimer 15 | # in the documentation and/or other materials provided with the 16 | # distribution. 17 | # * Neither the name of Google Inc. nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | """Tests for google.protobuf.symbol_database.""" 34 | 35 | try: 36 | import unittest2 as unittest 37 | except ImportError: 38 | import unittest 39 | from google.protobuf import unittest_pb2 40 | from google.protobuf import descriptor 41 | from google.protobuf import symbol_database 42 | 43 | class SymbolDatabaseTest(unittest.TestCase): 44 | 45 | def _Database(self): 46 | # TODO(b/17734095): Remove this difference when the C++ implementation 47 | # supports multiple databases. 48 | if descriptor._USE_C_DESCRIPTORS: 49 | return symbol_database.Default() 50 | else: 51 | db = symbol_database.SymbolDatabase() 52 | # Register representative types from unittest_pb2. 53 | db.RegisterFileDescriptor(unittest_pb2.DESCRIPTOR) 54 | db.RegisterMessage(unittest_pb2.TestAllTypes) 55 | db.RegisterMessage(unittest_pb2.TestAllTypes.NestedMessage) 56 | db.RegisterMessage(unittest_pb2.TestAllTypes.OptionalGroup) 57 | db.RegisterMessage(unittest_pb2.TestAllTypes.RepeatedGroup) 58 | db.RegisterEnumDescriptor(unittest_pb2.ForeignEnum.DESCRIPTOR) 59 | db.RegisterEnumDescriptor(unittest_pb2.TestAllTypes.NestedEnum.DESCRIPTOR) 60 | return db 61 | 62 | def testGetPrototype(self): 63 | instance = self._Database().GetPrototype( 64 | unittest_pb2.TestAllTypes.DESCRIPTOR) 65 | self.assertTrue(instance is unittest_pb2.TestAllTypes) 66 | 67 | def testGetMessages(self): 68 | messages = self._Database().GetMessages( 69 | ['google/protobuf/unittest.proto']) 70 | self.assertTrue( 71 | unittest_pb2.TestAllTypes is 72 | messages['protobuf_unittest.TestAllTypes']) 73 | 74 | def testGetSymbol(self): 75 | self.assertEqual( 76 | unittest_pb2.TestAllTypes, self._Database().GetSymbol( 77 | 'protobuf_unittest.TestAllTypes')) 78 | self.assertEqual( 79 | unittest_pb2.TestAllTypes.NestedMessage, self._Database().GetSymbol( 80 | 'protobuf_unittest.TestAllTypes.NestedMessage')) 81 | self.assertEqual( 82 | unittest_pb2.TestAllTypes.OptionalGroup, self._Database().GetSymbol( 83 | 'protobuf_unittest.TestAllTypes.OptionalGroup')) 84 | self.assertEqual( 85 | unittest_pb2.TestAllTypes.RepeatedGroup, self._Database().GetSymbol( 86 | 'protobuf_unittest.TestAllTypes.RepeatedGroup')) 87 | 88 | def testEnums(self): 89 | # Check registration of types in the pool. 90 | self.assertEqual( 91 | 'protobuf_unittest.ForeignEnum', 92 | self._Database().pool.FindEnumTypeByName( 93 | 'protobuf_unittest.ForeignEnum').full_name) 94 | self.assertEqual( 95 | 'protobuf_unittest.TestAllTypes.NestedEnum', 96 | self._Database().pool.FindEnumTypeByName( 97 | 'protobuf_unittest.TestAllTypes.NestedEnum').full_name) 98 | 99 | def testFindMessageTypeByName(self): 100 | self.assertEqual( 101 | 'protobuf_unittest.TestAllTypes', 102 | self._Database().pool.FindMessageTypeByName( 103 | 'protobuf_unittest.TestAllTypes').full_name) 104 | self.assertEqual( 105 | 'protobuf_unittest.TestAllTypes.NestedMessage', 106 | self._Database().pool.FindMessageTypeByName( 107 | 'protobuf_unittest.TestAllTypes.NestedMessage').full_name) 108 | 109 | def testFindFindContainingSymbol(self): 110 | # Lookup based on either enum or message. 111 | self.assertEqual( 112 | 'google/protobuf/unittest.proto', 113 | self._Database().pool.FindFileContainingSymbol( 114 | 'protobuf_unittest.TestAllTypes.NestedEnum').name) 115 | self.assertEqual( 116 | 'google/protobuf/unittest.proto', 117 | self._Database().pool.FindFileContainingSymbol( 118 | 'protobuf_unittest.TestAllTypes').name) 119 | 120 | def testFindFileByName(self): 121 | self.assertEqual( 122 | 'google/protobuf/unittest.proto', 123 | self._Database().pool.FindFileByName( 124 | 'google/protobuf/unittest.proto').name) 125 | 126 | 127 | if __name__ == '__main__': 128 | unittest.main() 129 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/internal/message_factory_test.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # 3 | # Protocol Buffers - Google's data interchange format 4 | # Copyright 2008 Google Inc. All rights reserved. 5 | # https://developers.google.com/protocol-buffers/ 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions are 9 | # met: 10 | # 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above 14 | # copyright notice, this list of conditions and the following disclaimer 15 | # in the documentation and/or other materials provided with the 16 | # distribution. 17 | # * Neither the name of Google Inc. nor the names of its 18 | # contributors may be used to endorse or promote products derived from 19 | # this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | """Tests for google.protobuf.message_factory.""" 34 | 35 | __author__ = 'matthewtoia@google.com (Matt Toia)' 36 | 37 | try: 38 | import unittest2 as unittest 39 | except ImportError: 40 | import unittest 41 | from google.protobuf import descriptor_pb2 42 | from google.protobuf.internal import factory_test1_pb2 43 | from google.protobuf.internal import factory_test2_pb2 44 | from google.protobuf import descriptor_database 45 | from google.protobuf import descriptor_pool 46 | from google.protobuf import message_factory 47 | 48 | class MessageFactoryTest(unittest.TestCase): 49 | 50 | def setUp(self): 51 | self.factory_test1_fd = descriptor_pb2.FileDescriptorProto.FromString( 52 | factory_test1_pb2.DESCRIPTOR.serialized_pb) 53 | self.factory_test2_fd = descriptor_pb2.FileDescriptorProto.FromString( 54 | factory_test2_pb2.DESCRIPTOR.serialized_pb) 55 | 56 | def _ExerciseDynamicClass(self, cls): 57 | msg = cls() 58 | msg.mandatory = 42 59 | msg.nested_factory_2_enum = 0 60 | msg.nested_factory_2_message.value = 'nested message value' 61 | msg.factory_1_message.factory_1_enum = 1 62 | msg.factory_1_message.nested_factory_1_enum = 0 63 | msg.factory_1_message.nested_factory_1_message.value = ( 64 | 'nested message value') 65 | msg.factory_1_message.scalar_value = 22 66 | msg.factory_1_message.list_value.extend([u'one', u'two', u'three']) 67 | msg.factory_1_message.list_value.append(u'four') 68 | msg.factory_1_enum = 1 69 | msg.nested_factory_1_enum = 0 70 | msg.nested_factory_1_message.value = 'nested message value' 71 | msg.circular_message.mandatory = 1 72 | msg.circular_message.circular_message.mandatory = 2 73 | msg.circular_message.scalar_value = 'one deep' 74 | msg.scalar_value = 'zero deep' 75 | msg.list_value.extend([u'four', u'three', u'two']) 76 | msg.list_value.append(u'one') 77 | msg.grouped.add() 78 | msg.grouped[0].part_1 = 'hello' 79 | msg.grouped[0].part_2 = 'world' 80 | msg.grouped.add(part_1='testing', part_2='123') 81 | msg.loop.loop.mandatory = 2 82 | msg.loop.loop.loop.loop.mandatory = 4 83 | serialized = msg.SerializeToString() 84 | converted = factory_test2_pb2.Factory2Message.FromString(serialized) 85 | reserialized = converted.SerializeToString() 86 | self.assertEqual(serialized, reserialized) 87 | result = cls.FromString(reserialized) 88 | self.assertEqual(msg, result) 89 | 90 | def testGetPrototype(self): 91 | db = descriptor_database.DescriptorDatabase() 92 | pool = descriptor_pool.DescriptorPool(db) 93 | db.Add(self.factory_test1_fd) 94 | db.Add(self.factory_test2_fd) 95 | factory = message_factory.MessageFactory() 96 | cls = factory.GetPrototype(pool.FindMessageTypeByName( 97 | 'google.protobuf.python.internal.Factory2Message')) 98 | self.assertFalse(cls is factory_test2_pb2.Factory2Message) 99 | self._ExerciseDynamicClass(cls) 100 | cls2 = factory.GetPrototype(pool.FindMessageTypeByName( 101 | 'google.protobuf.python.internal.Factory2Message')) 102 | self.assertTrue(cls is cls2) 103 | 104 | def testGetMessages(self): 105 | # performed twice because multiple calls with the same input must be allowed 106 | for _ in range(2): 107 | messages = message_factory.GetMessages([self.factory_test2_fd, 108 | self.factory_test1_fd]) 109 | self.assertTrue( 110 | set(['google.protobuf.python.internal.Factory2Message', 111 | 'google.protobuf.python.internal.Factory1Message'], 112 | ).issubset(set(messages.keys()))) 113 | self._ExerciseDynamicClass( 114 | messages['google.protobuf.python.internal.Factory2Message']) 115 | self.assertTrue( 116 | set(['google.protobuf.python.internal.Factory2Message.one_more_field', 117 | 'google.protobuf.python.internal.another_field'], 118 | ).issubset( 119 | set(messages['google.protobuf.python.internal.Factory1Message'] 120 | ._extensions_by_name.keys()))) 121 | factory_msg1 = messages['google.protobuf.python.internal.Factory1Message'] 122 | msg1 = messages['google.protobuf.python.internal.Factory1Message']() 123 | ext1 = factory_msg1._extensions_by_name[ 124 | 'google.protobuf.python.internal.Factory2Message.one_more_field'] 125 | ext2 = factory_msg1._extensions_by_name[ 126 | 'google.protobuf.python.internal.another_field'] 127 | msg1.Extensions[ext1] = 'test1' 128 | msg1.Extensions[ext2] = 'test2' 129 | self.assertEqual('test1', msg1.Extensions[ext1]) 130 | self.assertEqual('test2', msg1.Extensions[ext2]) 131 | 132 | 133 | if __name__ == '__main__': 134 | unittest.main() 135 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/pyext/descriptor_pool.h: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_POOL_H__ 32 | #define GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_POOL_H__ 33 | 34 | #include 35 | 36 | #include 37 | #include 38 | 39 | namespace google { 40 | namespace protobuf { 41 | class MessageFactory; 42 | 43 | namespace python { 44 | 45 | // Wraps operations to the global DescriptorPool which contains information 46 | // about all messages and fields. 47 | // 48 | // There is normally one pool per process. We make it a Python object only 49 | // because it contains many Python references. 50 | // TODO(amauryfa): See whether such objects can appear in reference cycles, and 51 | // consider adding support for the cyclic GC. 52 | // 53 | // "Methods" that interacts with this DescriptorPool are in the cdescriptor_pool 54 | // namespace. 55 | typedef struct PyDescriptorPool { 56 | PyObject_HEAD 57 | 58 | DescriptorPool* pool; 59 | 60 | // DynamicMessageFactory used to create C++ instances of messages. 61 | // This object cache the descriptors that were used, so the DescriptorPool 62 | // needs to get rid of it before it can delete itself. 63 | // 64 | // Note: A C++ MessageFactory is different from the Python MessageFactory. 65 | // The C++ one creates messages, when the Python one creates classes. 66 | MessageFactory* message_factory; 67 | 68 | // Make our own mapping to retrieve Python classes from C++ descriptors. 69 | // 70 | // Descriptor pointers stored here are owned by the DescriptorPool above. 71 | // Python references to classes are owned by this PyDescriptorPool. 72 | typedef hash_map ClassesByMessageMap; 73 | ClassesByMessageMap* classes_by_descriptor; 74 | 75 | // Cache the options for any kind of descriptor. 76 | // Descriptor pointers are owned by the DescriptorPool above. 77 | // Python objects are owned by the map. 78 | hash_map* descriptor_options; 79 | } PyDescriptorPool; 80 | 81 | 82 | extern PyTypeObject PyDescriptorPool_Type; 83 | 84 | namespace cdescriptor_pool { 85 | 86 | // Looks up a message by name. 87 | // Returns a message Descriptor, or NULL if not found. 88 | const Descriptor* FindMessageTypeByName(PyDescriptorPool* self, 89 | const string& name); 90 | 91 | // Registers a new Python class for the given message descriptor. 92 | // On error, returns -1 with a Python exception set. 93 | int RegisterMessageClass(PyDescriptorPool* self, 94 | const Descriptor* message_descriptor, 95 | PyObject* message_class); 96 | 97 | // Retrieves the Python class registered with the given message descriptor. 98 | // 99 | // Returns a *borrowed* reference if found, otherwise returns NULL with an 100 | // exception set. 101 | PyObject* GetMessageClass(PyDescriptorPool* self, 102 | const Descriptor* message_descriptor); 103 | 104 | // The functions below are also exposed as methods of the DescriptorPool type. 105 | 106 | // Looks up a message by name. Returns a PyMessageDescriptor corresponding to 107 | // the field on success, or NULL on failure. 108 | // 109 | // Returns a new reference. 110 | PyObject* FindMessageByName(PyDescriptorPool* self, PyObject* name); 111 | 112 | // Looks up a field by name. Returns a PyFieldDescriptor corresponding to 113 | // the field on success, or NULL on failure. 114 | // 115 | // Returns a new reference. 116 | PyObject* FindFieldByName(PyDescriptorPool* self, PyObject* name); 117 | 118 | // Looks up an extension by name. Returns a PyFieldDescriptor corresponding 119 | // to the field on success, or NULL on failure. 120 | // 121 | // Returns a new reference. 122 | PyObject* FindExtensionByName(PyDescriptorPool* self, PyObject* arg); 123 | 124 | // Looks up an enum type by name. Returns a PyEnumDescriptor corresponding 125 | // to the field on success, or NULL on failure. 126 | // 127 | // Returns a new reference. 128 | PyObject* FindEnumTypeByName(PyDescriptorPool* self, PyObject* arg); 129 | 130 | // Looks up a oneof by name. Returns a COneofDescriptor corresponding 131 | // to the oneof on success, or NULL on failure. 132 | // 133 | // Returns a new reference. 134 | PyObject* FindOneofByName(PyDescriptorPool* self, PyObject* arg); 135 | 136 | } // namespace cdescriptor_pool 137 | 138 | // Retrieve the global descriptor pool owned by the _message module. 139 | // This is the one used by pb2.py generated modules. 140 | // Returns a *borrowed* reference. 141 | PyDescriptorPool* GetDefaultDescriptorPool(); 142 | 143 | // Retrieve the python descriptor pool owning a C++ descriptor pool. 144 | // Returns a *borrowed* reference. 145 | PyDescriptorPool* GetDescriptorPool_FromPool(const DescriptorPool* pool); 146 | 147 | // Initialize objects used by this module. 148 | bool InitDescriptorPool(); 149 | 150 | } // namespace python 151 | } // namespace protobuf 152 | 153 | } // namespace google 154 | #endif // GOOGLE_PROTOBUF_PYTHON_CPP_DESCRIPTOR_POOL_H__ 155 | -------------------------------------------------------------------------------- /ved-decoder-master/lib/google/protobuf/message_factory.py: -------------------------------------------------------------------------------- 1 | # Protocol Buffers - Google's data interchange format 2 | # Copyright 2008 Google Inc. All rights reserved. 3 | # https://developers.google.com/protocol-buffers/ 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Provides a factory class for generating dynamic messages. 32 | 33 | The easiest way to use this class is if you have access to the FileDescriptor 34 | protos containing the messages you want to create you can just do the following: 35 | 36 | message_classes = message_factory.GetMessages(iterable_of_file_descriptors) 37 | my_proto_instance = message_classes['some.proto.package.MessageName']() 38 | """ 39 | 40 | __author__ = 'matthewtoia@google.com (Matt Toia)' 41 | 42 | from google.protobuf import descriptor_database 43 | from google.protobuf import descriptor_pool 44 | from google.protobuf import message 45 | from google.protobuf import reflection 46 | 47 | 48 | class MessageFactory(object): 49 | """Factory for creating Proto2 messages from descriptors in a pool.""" 50 | 51 | def __init__(self, pool=None): 52 | """Initializes a new factory.""" 53 | self.pool = (pool or descriptor_pool.DescriptorPool( 54 | descriptor_database.DescriptorDatabase())) 55 | 56 | # local cache of all classes built from protobuf descriptors 57 | self._classes = {} 58 | 59 | def GetPrototype(self, descriptor): 60 | """Builds a proto2 message class based on the passed in descriptor. 61 | 62 | Passing a descriptor with a fully qualified name matching a previous 63 | invocation will cause the same class to be returned. 64 | 65 | Args: 66 | descriptor: The descriptor to build from. 67 | 68 | Returns: 69 | A class describing the passed in descriptor. 70 | """ 71 | if descriptor.full_name not in self._classes: 72 | descriptor_name = descriptor.name 73 | if str is bytes: # PY2 74 | descriptor_name = descriptor.name.encode('ascii', 'ignore') 75 | result_class = reflection.GeneratedProtocolMessageType( 76 | descriptor_name, 77 | (message.Message,), 78 | {'DESCRIPTOR': descriptor, '__module__': None}) 79 | # If module not set, it wrongly points to the reflection.py module. 80 | self._classes[descriptor.full_name] = result_class 81 | for field in descriptor.fields: 82 | if field.message_type: 83 | self.GetPrototype(field.message_type) 84 | for extension in result_class.DESCRIPTOR.extensions: 85 | if extension.containing_type.full_name not in self._classes: 86 | self.GetPrototype(extension.containing_type) 87 | extended_class = self._classes[extension.containing_type.full_name] 88 | extended_class.RegisterExtension(extension) 89 | return self._classes[descriptor.full_name] 90 | 91 | def GetMessages(self, files): 92 | """Gets all the messages from a specified file. 93 | 94 | This will find and resolve dependencies, failing if the descriptor 95 | pool cannot satisfy them. 96 | 97 | Args: 98 | files: The file names to extract messages from. 99 | 100 | Returns: 101 | A dictionary mapping proto names to the message classes. This will include 102 | any dependent messages as well as any messages defined in the same file as 103 | a specified message. 104 | """ 105 | result = {} 106 | for file_name in files: 107 | file_desc = self.pool.FindFileByName(file_name) 108 | for name, msg in file_desc.message_types_by_name.items(): 109 | if file_desc.package: 110 | full_name = '.'.join([file_desc.package, name]) 111 | else: 112 | full_name = msg.name 113 | result[full_name] = self.GetPrototype( 114 | self.pool.FindMessageTypeByName(full_name)) 115 | 116 | # While the extension FieldDescriptors are created by the descriptor pool, 117 | # the python classes created in the factory need them to be registered 118 | # explicitly, which is done below. 119 | # 120 | # The call to RegisterExtension will specifically check if the 121 | # extension was already registered on the object and either 122 | # ignore the registration if the original was the same, or raise 123 | # an error if they were different. 124 | 125 | for name, extension in file_desc.extensions_by_name.items(): 126 | if extension.containing_type.full_name not in self._classes: 127 | self.GetPrototype(extension.containing_type) 128 | extended_class = self._classes[extension.containing_type.full_name] 129 | extended_class.RegisterExtension(extension) 130 | return result 131 | 132 | 133 | _FACTORY = MessageFactory() 134 | 135 | 136 | def GetMessages(file_protos): 137 | """Builds a dictionary of all the messages available in a set of files. 138 | 139 | Args: 140 | file_protos: A sequence of file protos to build messages out of. 141 | 142 | Returns: 143 | A dictionary mapping proto names to the message classes. This will include 144 | any dependent messages as well as any messages defined in the same file as 145 | a specified message. 146 | """ 147 | for file_proto in file_protos: 148 | _FACTORY.pool.Add(file_proto) 149 | return _FACTORY.GetMessages([file_proto.name for file_proto in file_protos]) 150 | --------------------------------------------------------------------------------