1
// Copyright (c) 2006, Google Inc.
2
// All rights reserved.
4
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions are
8
// * Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above
11
// copyright notice, this list of conditions and the following disclaimer
12
// in the documentation and/or other materials provided with the
14
// * Neither the name of Google Inc. nor the names of its
15
// contributors may be used to endorse or promote products derived from
16
// this software without specific prior written permission.
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
// minidump_upload.m: Upload a minidump to a HTTP server. The upload is sent as
31
// a multipart/form-data POST request with the following parameters:
32
// prod: the product name
33
// ver: the product version
34
// symbol_file: the breakpad format symbol file
40
#include "common/linux/http_upload.h"
42
using google_breakpad::HTTPUpload;
45
std::string minidumpPath;
46
std::string uploadURLStr;
50
std::string proxy_user_pwd;
54
//=============================================================================
55
static void Start(Options *options) {
56
std::map<std::string, std::string> parameters;
58
parameters["prod"] = options->product;
59
parameters["ver"] = options->version;
63
bool success = HTTPUpload::SendRequest(options->uploadURLStr,
65
options->minidumpPath,
66
"upload_file_minidump",
68
options->proxy_user_pwd,
72
printf("Successfully sent the minidump file.\n");
74
printf("Failed to send minidump\n");
75
printf("Response:\n");
76
printf("%s\n", response.c_str());
78
options->success = success;
81
//=============================================================================
83
Usage(int argc, const char *argv[]) {
84
fprintf(stderr, "Submit minidump information.\n");
85
fprintf(stderr, "Usage: %s [options...] -p <product> -v <version> <minidump> "
86
"<upload-URL>\n", argv[0]);
87
fprintf(stderr, "Options:\n");
88
fprintf(stderr, "<minidump> should be a minidump.\n");
89
fprintf(stderr, "<upload-URL> is the destination for the upload\n");
91
fprintf(stderr, "-p:\t <product> Product name\n");
92
fprintf(stderr, "-v:\t <version> Product version\n");
93
fprintf(stderr, "-x:\t <host[:port]> Use HTTP proxy on given port\n");
94
fprintf(stderr, "-u:\t <user[:password]> Set proxy user and password\n");
95
fprintf(stderr, "-h:\t Usage\n");
96
fprintf(stderr, "-?:\t Usage\n");
99
//=============================================================================
101
SetupOptions(int argc, const char *argv[], Options *options) {
105
while ((ch = getopt(argc, (char * const *)argv, "p:u:v:x:h?")) != -1) {
108
options->product = optarg;
111
options->proxy_user_pwd = optarg;
114
options->version = optarg;
117
options->proxy = optarg;
127
if ((argc - optind) != 2) {
128
fprintf(stderr, "%s: Missing symbols file and/or upload-URL\n", argv[0]);
133
options->minidumpPath = argv[optind];
134
options->uploadURLStr = argv[optind + 1];
137
//=============================================================================
138
int main (int argc, const char * argv[]) {
140
SetupOptions(argc, argv, &options);
142
return options.success ? 0 : 1;