Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: third_party/protobuf/src/google/protobuf/testing/zcgunzip.cc

Issue 1842653006: Update //third_party/protobuf to version 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update README.chromium Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2009 Google Inc. All rights reserved. 2 // Copyright 2009 Google Inc. All rights reserved.
3 // http://code.google.com/p/protobuf/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above 11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer 12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the 13 // in the documentation and/or other materials provided with the
(...skipping 17 matching lines...) Expand all
31 // Author: brianolson@google.com (Brian Olson) 31 // Author: brianolson@google.com (Brian Olson)
32 // Based on original Protocol Buffers design by 32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others. 33 // Sanjay Ghemawat, Jeff Dean, and others.
34 // 34 //
35 // Test program to verify that GzipInputStream is compatible with command line 35 // Test program to verify that GzipInputStream is compatible with command line
36 // gunzip or java.util.zip.GzipInputStream 36 // gunzip or java.util.zip.GzipInputStream
37 // 37 //
38 // Reads gzip stream on standard input and writes decompressed data to standard 38 // Reads gzip stream on standard input and writes decompressed data to standard
39 // output. 39 // output.
40 40
41 #include "config.h"
42
43 #include <assert.h> 41 #include <assert.h>
44 #include <stdio.h> 42 #include <stdio.h>
45 #include <stdlib.h> 43 #include <stdlib.h>
46 #include <fcntl.h> 44 #include <fcntl.h>
47 45
46 #ifdef _WIN32
47 #ifndef STDIN_FILENO
48 #define STDIN_FILENO 0
49 #endif
50 #ifndef STDOUT_FILENO
51 #define STDOUT_FILENO 1
52 #endif
53 #endif
54
48 #include <google/protobuf/io/gzip_stream.h> 55 #include <google/protobuf/io/gzip_stream.h>
49 #include <google/protobuf/io/zero_copy_stream_impl.h> 56 #include <google/protobuf/io/zero_copy_stream_impl.h>
50 57
51 using google::protobuf::io::FileInputStream; 58 using google::protobuf::io::FileInputStream;
52 using google::protobuf::io::GzipInputStream; 59 using google::protobuf::io::GzipInputStream;
53 60
54 int main(int argc, const char** argv) { 61 int main(int argc, const char** argv) {
55 FileInputStream fin(STDIN_FILENO); 62 FileInputStream fin(STDIN_FILENO);
56 GzipInputStream in(&fin); 63 GzipInputStream in(&fin);
57 64
58 while (true) { 65 while (true) {
59 const void* inptr; 66 const void* inptr;
60 int inlen; 67 int inlen;
61 bool ok; 68 bool ok;
62 ok = in.Next(&inptr, &inlen); 69 ok = in.Next(&inptr, &inlen);
63 if (!ok) { 70 if (!ok) {
64 break; 71 break;
65 } 72 }
66 if (inlen > 0) { 73 if (inlen > 0) {
67 int err = write(STDOUT_FILENO, inptr, inlen); 74 int err = write(STDOUT_FILENO, inptr, inlen);
68 assert(err == inlen); 75 assert(err == inlen);
69 } 76 }
70 } 77 }
71 78
72 return 0; 79 return 0;
73 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698