From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id DAA0D431FAF for ; Sun, 3 Jun 2012 09:58:15 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v8UKkbHzkHPu for ; Sun, 3 Jun 2012 09:58:15 -0700 (PDT) Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU [18.9.25.13]) by olra.theworths.org (Postfix) with ESMTP id 0CE0E431FC4 for ; Sun, 3 Jun 2012 09:58:14 -0700 (PDT) X-AuditID: 1209190d-b7fd56d000000933-f1-4fcb97a631eb Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP id 92.98.02355.6A79BCF4; Sun, 3 Jun 2012 12:58:14 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q53GwDSG012636; Sun, 3 Jun 2012 12:58:13 -0400 Received: from drake.dyndns.org (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q53GwC1m004204 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sun, 3 Jun 2012 12:58:13 -0400 (EDT) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1SbE7j-00037u-Oa; Sun, 03 Jun 2012 12:57:51 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 2/4] lib: Move _filename_is_in_maildir Date: Sun, 3 Jun 2012 12:57:34 -0400 Message-Id: <1338742656-11640-3-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1338742656-11640-1-git-send-email-amdragon@mit.edu> References: <1338742656-11640-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixCmqrLts+ml/g4+3lS2u35zJ7MDo8WzV LeYAxigum5TUnMyy1CJ9uwSujCWPl7AWPJao2Ph+OlsD40+hLkZODgkBE4nZ89oZIWwxiQv3 1rN1MXJxCAnsY5SY2vyPFcJZzyixu/kWlPOQSWJH8wooZy6jRPOJY6wg/WwCGhLb9i8HmyUi IC2x8+5soDgHB7OAmsSfLhWQsLCAmcT1OxPBylkEVCXufD7EAlLCK+AgcfGRBMQV8hJP7/ex gYQ5BRwleg+YgISFgCo+NFxhn8DIv4CRYRWjbEpulW5uYmZOcWqybnFyYl5eapGukV5uZole akrpJkZwyEjy7mB8d1DpEKMAB6MSD+/nWaf8hVgTy4orcw8xSnIwKYnyTpt62l+ILyk/pTIj sTgjvqg0J7X4EKMEB7OSCG+nHVCONyWxsiq1KB8mJc3BoiTOu0pzt7+QQHpiSWp2ampBahFM VoaDQ0mClxUYG0KCRanpqRVpmTklCGkmDk6Q4TxAw7lAaniLCxJzizPTIfKnGHU55h06d51R iCUvPy9VSpxXBKRIAKQoozQPbg4s1l8xigO9Jcz7chpQFQ8wTcBNegW0hAloicHhkyBLShIR UlINjAb+t9S/Hl9beqc8eH//XCG9vxPmcD+akJDySWZflF76EalX6112GiUZeulsCwuO8Ta3 CZ9zvfDSziKFzQl5JirVjxks7Wzj9l6/t9j1xfbjrf7PpdTnVL2f4GK8/fUTw2/nZn58Xf1m c/CH+k8iD4J1TT8f7glS6NVYcuJ5WcDnzOa7x9nvzVFiKc5INNRiLipOBABRtbX50AIAAA== X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jun 2012 16:58:16 -0000 This way notmuch_message_maildir_flags_to_tags can call it. It makes more sense for this to be just above all of the maildir synchronization code rather than mixed in the middle. --- lib/message.cc | 82 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 6787506..ed96477 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -1027,6 +1027,47 @@ notmuch_message_remove_tag (notmuch_message_t *message, const char *tag) return NOTMUCH_STATUS_SUCCESS; } +/* Is the given filename within a maildir directory? + * + * Specifically, is the final directory component of 'filename' either + * "cur" or "new". If so, return a pointer to that final directory + * component within 'filename'. If not, return NULL. + * + * A non-NULL return value is guaranteed to be a valid string pointer + * pointing to the characters "new/" or "cur/", (but not + * NUL-terminated). + */ +static const char * +_filename_is_in_maildir (const char *filename) +{ + const char *slash, *dir = NULL; + + /* Find the last '/' separating directory from filename. */ + slash = strrchr (filename, '/'); + if (slash == NULL) + return NULL; + + /* Jump back 4 characters to where the previous '/' will be if the + * directory is named "cur" or "new". */ + if (slash - filename < 4) + return NULL; + + slash -= 4; + + if (*slash != '/') + return NULL; + + dir = slash + 1; + + if (STRNCMP_LITERAL (dir, "cur/") == 0 || + STRNCMP_LITERAL (dir, "new/") == 0) + { + return dir; + } + + return NULL; +} + notmuch_status_t notmuch_message_maildir_flags_to_tags (notmuch_message_t *message) { @@ -1083,47 +1124,6 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message) return status; } -/* Is the given filename within a maildir directory? - * - * Specifically, is the final directory component of 'filename' either - * "cur" or "new". If so, return a pointer to that final directory - * component within 'filename'. If not, return NULL. - * - * A non-NULL return value is guaranteed to be a valid string pointer - * pointing to the characters "new/" or "cur/", (but not - * NUL-terminated). - */ -static const char * -_filename_is_in_maildir (const char *filename) -{ - const char *slash, *dir = NULL; - - /* Find the last '/' separating directory from filename. */ - slash = strrchr (filename, '/'); - if (slash == NULL) - return NULL; - - /* Jump back 4 characters to where the previous '/' will be if the - * directory is named "cur" or "new". */ - if (slash - filename < 4) - return NULL; - - slash -= 4; - - if (*slash != '/') - return NULL; - - dir = slash + 1; - - if (STRNCMP_LITERAL (dir, "cur/") == 0 || - STRNCMP_LITERAL (dir, "new/") == 0) - { - return dir; - } - - return NULL; -} - /* From the set of tags on 'message' and the flag2tag table, compute a * set of maildir-flag actions to be taken, (flags that should be * either set or cleared). -- 1.7.10