[PATCH] Omit User-Agent: header by default
[notmuch-archives.git] / 0b / f0926dbd14f7b469f5ea3fadca21e84973e3db
1 Return-Path: <jani@nikula.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id E85CA431FC0\r
6         for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:46:51 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id 4MM6nB70lV-X for <notmuch@notmuchmail.org>;\r
17         Tue, 29 Jan 2013 13:46:51 -0800 (PST)\r
18 Received: from mail-la0-f45.google.com (mail-la0-f45.google.com\r
19         [209.85.215.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 43325431FC7\r
22         for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:46:50 -0800 (PST)\r
23 Received: by mail-la0-f45.google.com with SMTP id er20so647502lab.18\r
24         for <notmuch@notmuchmail.org>; Tue, 29 Jan 2013 13:46:48 -0800 (PST)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=google.com; s=20120113;\r
27         h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to\r
28         :references:in-reply-to:references:x-gm-message-state;\r
29         bh=4qDQAjZfBxw+vY+TowfikkHP/5T9Zn3JBgUl8IWByd0=;\r
30         b=LxS8Q186Dv8+exSpgYvTTIxH9pHaTGgrhm3X6ltjeOlbcc2KKkcynb4f4suhIaLnNm\r
31         CZvf1twbcaXWQjN4tYe84xdwN7GrfraJWEvLnyZ9FFBS0ek7P0gGChbCl1Ajqh1EPNac\r
32         GuPoUSLJeCnaQhfCvifYVj6HSd/ghQ194qZzKJ9Uqix5azNf1dWCw2xRo9hraiSkDK9z\r
33         o3p0imkotHoNmEMjQ/fMDeIVsSbkThlXmwCLQqx5AEfnBvwVp52fRqKOhNnA0NQx7i2Z\r
34         +0gNjHKQRiMB4QPfO4zoq5R6YMUfMQq3FYJKr5OiW7NR2uRLJHqZgWMuFqUBEtCaHRm6\r
35         kjiw==\r
36 X-Received: by 10.112.38.164 with SMTP id h4mr1031947lbk.123.1359496008558;\r
37         Tue, 29 Jan 2013 13:46:48 -0800 (PST)\r
38 Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.\r
39         [80.223.81.27])\r
40         by mx.google.com with ESMTPS id q4sm5590461lbj.15.2013.01.29.13.46.46\r
41         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
42         Tue, 29 Jan 2013 13:46:47 -0800 (PST)\r
43 From: Jani Nikula <jani@nikula.org>\r
44 To: notmuch@notmuchmail.org\r
45 Subject: [PATCH 3/6] cli: abstract subcommand finding into a new function\r
46 Date: Tue, 29 Jan 2013 23:46:21 +0200\r
47 Message-Id:\r
48  <4fa07d936647d316f642c8f30b763d316604ea5f.1359495450.git.jani@nikula.org>\r
49 X-Mailer: git-send-email 1.7.10.4\r
50 In-Reply-To: <cover.1359495450.git.jani@nikula.org>\r
51 References: <cover.1359495450.git.jani@nikula.org>\r
52 In-Reply-To: <cover.1359495450.git.jani@nikula.org>\r
53 References: <cover.1359495450.git.jani@nikula.org>\r
54 X-Gm-Message-State:\r
55  ALoCoQkR3nDUsllGMSZG26Z6cqxy+Q2aboFlmB/+qbEGMNWhm6WpjHM3+3qDTMGsni0AeoOoK5c0\r
56 X-BeenThere: notmuch@notmuchmail.org\r
57 X-Mailman-Version: 2.1.13\r
58 Precedence: list\r
59 List-Id: "Use and development of the notmuch mail system."\r
60         <notmuch.notmuchmail.org>\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
64 List-Post: <mailto:notmuch@notmuchmail.org>\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
68 X-List-Received-Date: Tue, 29 Jan 2013 21:46:52 -0000\r
69 \r
70 Clean up code.\r
71 ---\r
72  notmuch.c |   68 +++++++++++++++++++++++++++++++------------------------------\r
73  1 file changed, 35 insertions(+), 33 deletions(-)\r
74 \r
75 diff --git a/notmuch.c b/notmuch.c\r
76 index b413b53..c47b998 100644\r
77 --- a/notmuch.c\r
78 +++ b/notmuch.c\r
79 @@ -70,6 +70,18 @@ static command_t commands[] = {\r
80        "This message, or more detailed help for the named command." }\r
81  };\r
82  \r
83 +static command_t *\r
84 +find_command (const char *name)\r
85 +{\r
86 +    size_t i;\r
87 +\r
88 +    for (i = 0; i < ARRAY_SIZE (commands); i++)\r
89 +       if (strcmp (name, commands[i].name) == 0)\r
90 +           return &commands[i];\r
91 +\r
92 +    return NULL;\r
93 +}\r
94 +\r
95  int notmuch_format_version;\r
96  \r
97  static void\r
98 @@ -139,7 +151,6 @@ static int\r
99  notmuch_help_command (void *ctx, int argc, char *argv[])\r
100  {\r
101      command_t *command;\r
102 -    unsigned int i;\r
103  \r
104      argc--; argv++; /* Ignore "help" */\r
105  \r
106 @@ -158,13 +169,10 @@ notmuch_help_command (void *ctx, int argc, char *argv[])\r
107         return 0;\r
108      }\r
109  \r
110 -    for (i = 0; i < ARRAY_SIZE (commands); i++) {\r
111 -       command = &commands[i];\r
112 -\r
113 -       if (strcmp (argv[0], command->name) == 0) {\r
114 -           char *page = talloc_asprintf (ctx, "notmuch-%s", command->name);\r
115 -           exec_man (page);\r
116 -       }\r
117 +    command = find_command (argv[0]);\r
118 +    if (command) {\r
119 +       char *page = talloc_asprintf (ctx, "notmuch-%s", command->name);\r
120 +       exec_man (page);\r
121      }\r
122  \r
123      if (strcmp (argv[0], "search-terms") == 0) {\r
124 @@ -246,10 +254,11 @@ int\r
125  main (int argc, char *argv[])\r
126  {\r
127      void *local;\r
128 +    char *talloc_report;\r
129      command_t *command;\r
130 -    unsigned int i;\r
131      notmuch_bool_t print_help=FALSE, print_version=FALSE;\r
132      int opt_index;\r
133 +    int ret = 0;\r
134  \r
135      notmuch_opt_desc_t options[] = {\r
136         { NOTMUCH_OPT_BOOLEAN, &print_help, "help", 'h', 0 },\r
137 @@ -284,37 +293,30 @@ main (int argc, char *argv[])\r
138         return 0;\r
139      }\r
140  \r
141 -    for (i = 0; i < ARRAY_SIZE (commands); i++) {\r
142 -       command = &commands[i];\r
143 -\r
144 -       if (strcmp (argv[opt_index], command->name) == 0) {\r
145 -           int ret;\r
146 -           char *talloc_report;\r
147 -\r
148 -           ret = (command->function)(local, argc - opt_index, argv + opt_index);\r
149 +    command = find_command (argv[opt_index]);\r
150 +    if (!command) {\r
151 +       fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",\r
152 +                argv[opt_index]);\r
153 +       return 1;\r
154 +    }\r
155  \r
156 -           /* in the future support for this environment variable may\r
157 -            * be supplemented or replaced by command line arguments\r
158 -            * --leak-report and/or --leak-report-full */\r
159 +    ret = (command->function)(local, argc - opt_index, argv + opt_index);\r
160  \r
161 -           talloc_report = getenv ("NOTMUCH_TALLOC_REPORT");\r
162 +    /* in the future support for this environment variable may\r
163 +     * be supplemented or replaced by command line arguments\r
164 +     * --leak-report and/or --leak-report-full */\r
165  \r
166 -           /* this relies on the previous call to\r
167 -            * talloc_enable_null_tracking */\r
168 +    talloc_report = getenv ("NOTMUCH_TALLOC_REPORT");\r
169  \r
170 -           if (talloc_report && strcmp (talloc_report, "") != 0) {\r
171 -               FILE *report = fopen (talloc_report, "w");\r
172 -               talloc_report_full (NULL, report);\r
173 -           }\r
174 +    /* this relies on the previous call to\r
175 +     * talloc_enable_null_tracking */\r
176  \r
177 -           return ret;\r
178 -       }\r
179 +    if (talloc_report && strcmp (talloc_report, "") != 0) {\r
180 +       FILE *report = fopen (talloc_report, "w");\r
181 +       talloc_report_full (NULL, report);\r
182      }\r
183  \r
184 -    fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",\r
185 -            argv[1]);\r
186 -\r
187      talloc_free (local);\r
188  \r
189 -    return 1;\r
190 +    return ret;\r
191  }\r
192 -- \r
193 1.7.10.4\r
194 \r