Left: | ||
Right: |
OLD | NEW |
---|---|
1 // Copyright (c) 2006, Google Inc. | 1 // Copyright (c) 2006, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 23 matching lines...) Expand all Loading... | |
34 // ver: the product version | 34 // ver: the product version |
35 // symbol_file: the breakpad format symbol file | 35 // symbol_file: the breakpad format symbol file |
36 | 36 |
37 #include <stdio.h> | 37 #include <stdio.h> |
38 #include <stdlib.h> | 38 #include <stdlib.h> |
39 #include <unistd.h> | 39 #include <unistd.h> |
40 | 40 |
41 #include <string> | 41 #include <string> |
42 | 42 |
43 #include "common/linux/http_upload.h" | 43 #include "common/linux/http_upload.h" |
44 #include "common/using_std_string.h" | |
44 | 45 |
45 using google_breakpad::HTTPUpload; | 46 using google_breakpad::HTTPUpload; |
46 | 47 |
47 struct Options { | 48 struct Options { |
48 std::string minidumpPath; | 49 string minidumpPath; |
49 std::string uploadURLStr; | 50 string uploadURLStr; |
50 std::string product; | 51 string product; |
51 std::string version; | 52 string version; |
52 std::string proxy; | 53 string proxy; |
53 std::string proxy_user_pwd; | 54 string proxy_user_pwd; |
54 bool success; | 55 bool success; |
55 }; | 56 }; |
56 | 57 |
57 //============================================================================= | 58 //============================================================================= |
58 static void Start(Options *options) { | 59 static void Start(Options *options) { |
59 std::map<std::string, std::string> parameters; | 60 std::map<string, string> parameters; |
60 // Add parameters | 61 // Add parameters |
61 parameters["prod"] = options->product; | 62 parameters["prod"] = options->product; |
62 parameters["ver"] = options->version; | 63 parameters["ver"] = options->version; |
63 | 64 |
64 // Send it | 65 // Send it |
65 std::string response, error; | 66 string response, error; |
66 bool success = HTTPUpload::SendRequest(options->uploadURLStr, | 67 bool success = HTTPUpload::SendRequest(options->uploadURLStr, |
67 parameters, | 68 parameters, |
68 options->minidumpPath, | 69 options->minidumpPath, |
69 "upload_file_minidump", | 70 "upload_file_minidump", |
70 options->proxy, | 71 options->proxy, |
71 options->proxy_user_pwd, | 72 options->proxy_user_pwd, |
72 "", | 73 "", |
73 &response, | 74 &response, |
74 NULL, | 75 NULL, |
75 &error); | 76 &error); |
76 | 77 |
77 if (success) { | 78 if (success) { |
78 printf("Successfully sent the minidump file.\n"); | 79 printf("Successfully sent the minidump file.\n"); |
79 } else { | 80 } else { |
80 printf("Failed to send minidump: %s\n", error.c_str()); | 81 printf("Failed to send minidump: %s\n", error.c_str()); |
81 printf("Response:\n"); | |
82 printf("%s\n", response.c_str()); | |
83 } | 82 } |
83 printf("Response:\n"); | |
84 printf("%s\n", response.c_str()); | |
84 options->success = success; | 85 options->success = success; |
85 } | 86 } |
86 | 87 |
87 //============================================================================= | 88 //============================================================================= |
88 static void | 89 static void |
89 Usage(int argc, const char *argv[]) { | 90 Usage(int argc, const char *argv[]) { |
90 fprintf(stderr, "Submit minidump information.\n"); | 91 fprintf(stderr, "Submit minidump information.\n"); |
91 fprintf(stderr, "Usage: %s [options...] -p <product> -v <version> <minidump> " | 92 fprintf(stderr, "Usage: %s [options...] -p <product> -v <version> <minidump> " |
92 "<upload-URL>\n", argv[0]); | 93 "<upload-URL>\n", argv[0]); |
93 fprintf(stderr, "Options:\n"); | 94 fprintf(stderr, "Options:\n"); |
94 fprintf(stderr, "<minidump> should be a minidump.\n"); | 95 fprintf(stderr, "<minidump> should be a minidump.\n"); |
95 fprintf(stderr, "<upload-URL> is the destination for the upload\n"); | 96 fprintf(stderr, "<upload-URL> is the destination for the upload\n"); |
96 | 97 |
97 fprintf(stderr, "-p:\t <product> Product name\n"); | 98 fprintf(stderr, "-p:\t <product> Product name\n"); |
98 fprintf(stderr, "-v:\t <version> Product version\n"); | 99 fprintf(stderr, "-v:\t <version> Product version\n"); |
99 fprintf(stderr, "-x:\t <host[:port]> Use HTTP proxy on given port\n"); | 100 fprintf(stderr, "-x:\t <host[:port]> Use HTTP proxy on given port\n"); |
100 fprintf(stderr, "-u:\t <user[:password]> Set proxy user and password\n"); | 101 fprintf(stderr, "-u:\t <user[:password]> Set proxy user and password\n"); |
101 fprintf(stderr, "-h:\t Usage\n"); | 102 fprintf(stderr, "-h:\t Usage\n"); |
102 fprintf(stderr, "-?:\t Usage\n"); | 103 fprintf(stderr, "-?:\t Usage\n"); |
103 } | 104 } |
104 | 105 |
105 //============================================================================= | 106 //============================================================================= |
106 static void | 107 static void |
107 SetupOptions(int argc, const char *argv[], Options *options) { | 108 SetupOptions(int argc, const char *argv[], Options *options) { |
108 extern int optind; | 109 extern int optind; |
109 char ch; | 110 int ch; |
110 | 111 |
111 while ((ch = getopt(argc, (char * const *)argv, "p:u:v:x:h?")) != -1) { | 112 while ((ch = getopt(argc, (char * const *)argv, "p:u:v:x:h?")) != -1) { |
112 switch (ch) { | 113 switch (ch) { |
113 case 'p': | 114 case 'p': |
114 options->product = optarg; | 115 options->product = optarg; |
115 break; | 116 break; |
116 case 'u': | 117 case 'u': |
117 options->proxy_user_pwd = optarg; | 118 options->proxy_user_pwd = optarg; |
118 break; | 119 break; |
119 case 'v': | 120 case 'v': |
120 options->version = optarg; | 121 options->version = optarg; |
121 break; | 122 break; |
122 case 'x': | 123 case 'x': |
123 options->proxy = optarg; | 124 options->proxy = optarg; |
124 break; | 125 break; |
125 | 126 |
126 default: | 127 default: |
128 fprintf(stderr, "Invalid option '%c'\n", ch); | |
127 Usage(argc, argv); | 129 Usage(argc, argv); |
128 exit(0); | 130 exit(1); |
129 break; | 131 break; |
130 } | 132 } |
131 } | 133 } |
132 | 134 |
133 if ((argc - optind) != 2) { | 135 if ((argc - optind) != 2) { |
134 fprintf(stderr, "%s: Missing symbols file and/or upload-URL\n", argv[0]); | 136 fprintf(stderr, "%s: Missing symbols file and/or upload-URL\n", argv[0]); |
135 Usage(argc, argv); | 137 Usage(argc, argv); |
136 exit(1); | 138 exit(1); |
137 } | 139 } |
138 | 140 |
139 options->minidumpPath = argv[optind]; | 141 options->minidumpPath = argv[optind]; |
140 options->uploadURLStr = argv[optind + 1]; | 142 options->uploadURLStr = argv[optind + 1]; |
141 } | 143 } |
142 | 144 |
143 //============================================================================= | 145 //============================================================================= |
144 int main (int argc, const char * argv[]) { | 146 int main(int argc, const char * argv[]) { |
Mark Mentovai
2013/04/23 19:56:16
Since you’re fixing this line, fix the * too. It s
Ivan Penkov
2013/04/23 20:29:43
Done.
| |
145 Options options; | 147 Options options; |
146 SetupOptions(argc, argv, &options); | 148 SetupOptions(argc, argv, &options); |
147 Start(&options); | 149 Start(&options); |
148 return options.success ? 0 : 1; | 150 return options.success ? 0 : 1; |
149 } | 151 } |
OLD | NEW |