[Patch v7 4/6] restore: transparently support gzipped input
[notmuch-archives.git] / 90 / 9acc7ef901578fb9bc4fd82aeebce15c54b50d
1 Return-Path: <novalazy@gmail.com>\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 0152E431FDC\r
6         for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:44:10 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, 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 KwdukMViGVzD for <notmuch@notmuchmail.org>;\r
17         Wed, 25 Jul 2012 06:44:09 -0700 (PDT)\r
18 Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com\r
19         [209.85.160.53]) (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 8D937431FAE\r
22         for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:44:09 -0700 (PDT)\r
23 Received: by mail-pb0-f53.google.com with SMTP id rr13so1767731pbb.26\r
24         for <notmuch@notmuchmail.org>; Wed, 25 Jul 2012 06:44:09 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
27         bh=znSJ6OY/HEngoNx3sDcCsFahxHQeS923hhE/P7Llewk=;\r
28         b=XrHMAxzY6Z8ezbaBCaWCJGg0/5MaYWkZ/ztJxQ0iDdpIQPY4l/DP+voBeA0bBLWN4p\r
29         QW9JXTI4t7PcB0xImio0GDqYtkxSNbiZnRreACp+YDCsc9lIMUPPs66FEnYNwvE03RYi\r
30         la1XDnFbR1uk8MZhERd1n2Uu+yCruw1z6Rwnu08kYU8PXtsHKjH/7uah58e2SKsz8MJA\r
31         FIAzjquErcufYkomhLHJj5ZwlfEd85OS4dpHkLSQ5op4zJgvER96zx8xPxYhLbF1S2wH\r
32         iomXCzh2dK/PBGByWBkZwgzsMEvvXw5cDVZ6Dg8TTp6eMPsnalmPjiiMGa5HlLPew/50\r
33         Xv9w==\r
34 Received: by 10.68.231.10 with SMTP id tc10mr53678564pbc.107.1343223849378;\r
35         Wed, 25 Jul 2012 06:44:09 -0700 (PDT)\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.\r
37         [220.233.42.215])\r
38         by mx.google.com with ESMTPS id ny4sm14408899pbb.57.2012.07.25.06.44.06\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Wed, 25 Jul 2012 06:44:08 -0700 (PDT)\r
41 From: Peter Wang <novalazy@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH 10/18] insert: parse command-line tag operations\r
44 Date: Wed, 25 Jul 2012 23:42:39 +1000\r
45 Message-Id: <1343223767-9812-10-git-send-email-novalazy@gmail.com>\r
46 X-Mailer: git-send-email 1.7.4.4\r
47 In-Reply-To: <1343223767-9812-1-git-send-email-novalazy@gmail.com>\r
48 References: <1343223767-9812-1-git-send-email-novalazy@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Wed, 25 Jul 2012 13:44:11 -0000\r
62 \r
63 Parse +tag and -tag on the 'insert' command-line.\r
64 Issue a warning about ambiguous -tag arguments which don't follow\r
65 +tag nor an explicit option list terminator.\r
66 ---\r
67  notmuch-insert.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
68  1 files changed, 50 insertions(+), 0 deletions(-)\r
69 \r
70 diff --git a/notmuch-insert.c b/notmuch-insert.c\r
71 index 4fb3ea3..6db03e3 100644\r
72 --- a/notmuch-insert.c\r
73 +++ b/notmuch-insert.c\r
74 @@ -24,6 +24,11 @@\r
75  #include <sys/stat.h>\r
76  #include <fcntl.h>\r
77  \r
78 +typedef struct {\r
79 +    const char *tag;\r
80 +    notmuch_bool_t remove;\r
81 +} tag_operation_t;\r
82 +\r
83  static notmuch_bool_t\r
84  check_folder_name (const char *folder)\r
85  {\r
86 @@ -236,8 +241,11 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])\r
87      const char **new_tags;\r
88      size_t new_tags_length;\r
89      const char *folder = NULL;\r
90 +    tag_operation_t *tag_ops;\r
91 +    int tag_ops_count = 0;\r
92      char *maildir;\r
93      int opt_index;\r
94 +    notmuch_bool_t warn_tag_rem;\r
95      notmuch_bool_t ret;\r
96  \r
97      notmuch_opt_desc_t options[] = {\r
98 @@ -253,6 +261,48 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])\r
99         return 1;\r
100      }\r
101  \r
102 +    if (opt_index > 0 && strcmp (argv[opt_index - 1], "--") == 0) {\r
103 +       warn_tag_rem = FALSE;\r
104 +    } else {\r
105 +       warn_tag_rem = TRUE;\r
106 +    }\r
107 +\r
108 +    /* Array of tagging operations (add or remove), terminated with an\r
109 +     * empty element. */\r
110 +    tag_ops = talloc_array (ctx, tag_operation_t, argc - opt_index + 1);\r
111 +    if (tag_ops == NULL) {\r
112 +       fprintf (stderr, "Out of memory.\n");\r
113 +       return 1;\r
114 +    }\r
115 +\r
116 +    for (; opt_index < argc; opt_index++) {\r
117 +       if (argv[opt_index][0] == '+') {\r
118 +           tag_ops[tag_ops_count].tag = argv[opt_index] + 1;\r
119 +           tag_ops[tag_ops_count].remove = FALSE;\r
120 +           tag_ops_count++;\r
121 +           warn_tag_rem = FALSE;\r
122 +       } else if (argv[opt_index][0] == '-') {\r
123 +           if (warn_tag_rem) {\r
124 +               fprintf (stderr,\r
125 +                        "Warning: ambiguous argument treated as tag removal: %s\n",\r
126 +                        argv[opt_index]);\r
127 +           }\r
128 +           tag_ops[tag_ops_count].tag = argv[opt_index] + 1;\r
129 +           tag_ops[tag_ops_count].remove = TRUE;\r
130 +           tag_ops_count++;\r
131 +       } else {\r
132 +           break;\r
133 +       }\r
134 +    }\r
135 +\r
136 +    tag_ops[tag_ops_count].tag = NULL;\r
137 +\r
138 +    if (opt_index != argc) {\r
139 +       fprintf (stderr, "Error: bad argument to notmuch insert: %s\n",\r
140 +                argv[opt_index]);\r
141 +       return 1;\r
142 +    }\r
143 +\r
144      config = notmuch_config_open (ctx, NULL, NULL);\r
145      if (config == NULL)\r
146         return 1;\r
147 -- \r
148 1.7.4.4\r
149 \r