From: Thomas Roessler Date: Sun, 13 Jan 2002 21:16:34 +0000 (+0000) Subject: Parse IMAP responses locale- and case- insensitive. From Brendan X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=29f0965b8b6d963b7f32cf783584638b307cc60c;p=neomutt Parse IMAP responses locale- and case- insensitive. From Brendan Cully. --- diff --git a/imap/auth_sasl.c b/imap/auth_sasl.c index 5c54f5dc7..c8e656edf 100644 --- a/imap/auth_sasl.c +++ b/imap/auth_sasl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-1 Brendan Cully + * Copyright (C) 2000-2 Brendan Cully * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -62,7 +62,7 @@ imap_auth_res_t imap_auth_sasl (IMAP_DATA* idata, const char* method) if (mutt_bit_isset (idata->capabilities, AUTH_ANON) && (!idata->conn->account.user[0] || - !mutt_strncmp (idata->conn->account.user, "anonymous", 9))) + !ascii_strncmp (idata->conn->account.user, "anonymous", 9))) rc = sasl_client_start (saslconn, "AUTH=ANONYMOUS", NULL, NULL, &pc, &olen, &mech); } diff --git a/imap/browse.c b/imap/browse.c index 846fc4bc1..f5af8922a 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -1,6 +1,6 @@ /* * Copyright (C) 1996-9 Brandon Long - * Copyright (C) 1999-2001 Brendan Cully + * Copyright (C) 1999-2002 Brendan Cully * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -125,7 +125,7 @@ int imap_browse (char* path, struct browser_state* state) } } } - while (mutt_strncmp (idata->cmd.buf, idata->cmd.seq, SEQLEN)); + while (ascii_strncmp (idata->cmd.buf, idata->cmd.seq, SEQLEN)); } /* if we're descending a folder, mark it as current in browser_state */ @@ -335,7 +335,7 @@ static int browse_add_list_result (IMAP_DATA* idata, const char* cmd, isparent); } } - while ((mutt_strncmp (idata->cmd.buf, idata->cmd.seq, SEQLEN) != 0)); + while ((ascii_strncmp (idata->cmd.buf, idata->cmd.seq, SEQLEN) != 0)); FREE (&mx.mbox); return 0; @@ -439,7 +439,7 @@ static int browse_get_namespace (IMAP_DATA* idata, char* nsbuf, int nsblen, for (type = IMAP_NS_PERSONAL; *s; type++) { s = imap_next_word (s); - if (*s && strncmp (s, "NIL", 3)) + if (ascii_strncasecmp (s, "NIL", 3)) { s++; while (*s && *s != ')') @@ -545,7 +545,7 @@ static int browse_verify_namespace (IMAP_DATA* idata, return -1; nsi->listable |= (name != NULL); } - while ((mutt_strncmp (idata->cmd.buf, idata->cmd.seq, SEQLEN) != 0)); + while ((ascii_strncmp (idata->cmd.buf, idata->cmd.seq, SEQLEN) != 0)); } return 0; diff --git a/imap/command.c b/imap/command.c index ed01d432d..2d475bf6f 100644 --- a/imap/command.c +++ b/imap/command.c @@ -1,7 +1,7 @@ /* * Copyright (C) 1996-8 Michael R. Elkins * Copyright (C) 1996-9 Brandon Long - * Copyright (C) 1999-2001 Brendan Cully + * Copyright (C) 1999-2002 Brendan Cully * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -135,18 +135,18 @@ int imap_cmd_step (IMAP_DATA* idata) } /* handle untagged messages. The caller still gets its shot afterwards. */ - if (!strncmp (cmd->buf, "* ", 2) && + if (!ascii_strncmp (cmd->buf, "* ", 2) && cmd_handle_untagged (idata)) return IMAP_CMD_BAD; /* server demands a continuation response from us */ - if (!strncmp (cmd->buf, "+ ", 2)) + if (!ascii_strncmp (cmd->buf, "+ ", 2)) { return IMAP_CMD_RESPOND; } /* tagged completion code */ - if (!mutt_strncmp (cmd->buf, cmd->seq, SEQLEN)) + if (!ascii_strncmp (cmd->buf, cmd->seq, SEQLEN)) { imap_cmd_finish (idata); return imap_code (cmd->buf) ? IMAP_CMD_OK : IMAP_CMD_NO; diff --git a/imap/imap.c b/imap/imap.c index 1998e2bfc..3059d7ac7 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1,7 +1,7 @@ /* * Copyright (C) 1996-8 Michael R. Elkins * Copyright (C) 1996-9 Brandon Long - * Copyright (C) 1999-2001 Brendan Cully + * Copyright (C) 1999-2002 Brendan Cully * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -378,7 +378,7 @@ int imap_open_connection (IMAP_DATA* idata) if (imap_cmd_step (idata) != IMAP_CMD_CONTINUE) goto bail; - if (mutt_strncmp ("* OK", idata->cmd.buf, 4) == 0) + if (ascii_strncasecmp ("* OK", idata->cmd.buf, 4) == 0) { /* TODO: Parse new tagged CAPABILITY data (* OK [CAPABILITY...]) */ if (imap_check_capabilities (idata)) @@ -419,7 +419,7 @@ int imap_open_connection (IMAP_DATA* idata) dprint (2, (debugfile, "Communication encrypted at %d bits\n", idata->conn->ssf)); } - else if (mutt_strncmp ("* PREAUTH", idata->cmd.buf, 9) == 0) + else if (ascii_strncasecmp ("* PREAUTH", idata->cmd.buf, 9) == 0) { if (imap_check_capabilities (idata) != 0) goto bail; @@ -613,7 +613,7 @@ int imap_open_mailbox (CONTEXT* ctx) goto fail; /* check for READ-ONLY notification */ - if (!strncmp (imap_get_qualifier (idata->cmd.buf), "[READ-ONLY]", 11)) + if (!ascii_strncasecmp (imap_get_qualifier (idata->cmd.buf), "[READ-ONLY]", 11)) { dprint (2, (debugfile, "Mailbox is read-only.\n")); ctx->readonly = 1; @@ -1183,7 +1183,7 @@ int imap_mailbox_check (char* path, int new) */ if (mutt_strcmp (mbox_unquoted, idata->mailbox) == 0 - || (mutt_strcasecmp (mbox_unquoted, "INBOX") == 0 + || (ascii_strcasecmp (mbox_unquoted, "INBOX") == 0 && mutt_strcasecmp (mbox_unquoted, idata->mailbox) == 0)) { strfcpy (buf, "NOOP", sizeof (buf)); @@ -1289,7 +1289,7 @@ int imap_parse_list_response(IMAP_DATA* idata, char **name, int *noselect, return 0; s = imap_next_word (s); /* delim */ /* Reset the delimiter, this can change */ - if (strncmp (s, "NIL", 3)) + if (ascii_strncmp (s, "NIL", 3)) { if (s && s[0] == '\"' && s[1] && s[2] == '\"') *delim = s[1]; @@ -1434,7 +1434,7 @@ int imap_complete(char* dest, size_t dlen, char* path) { completions++; } } - while (mutt_strncmp(idata->cmd.seq, idata->cmd.buf, SEQLEN)); + while (ascii_strncmp(idata->cmd.seq, idata->cmd.buf, SEQLEN)); if (completions) { diff --git a/imap/message.c b/imap/message.c index 62510b0c1..65b74bd8c 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1,6 +1,6 @@ /* * Copyright (C) 1996-9 Brandon Long - * Copyright (C) 1999-2001 Brendan Cully + * Copyright (C) 1999-2002 Brendan Cully * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -591,7 +591,7 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete) if (rc == -2) { /* bail out if command failed for reasons other than nonexistent target */ - if (strncmp (imap_get_qualifier (idata->cmd.buf), "[TRYCREATE]", 11)) + if (ascii_strncasecmp (imap_get_qualifier (idata->cmd.buf), "[TRYCREATE]", 11)) { imap_error ("imap_copy_messages", idata->cmd.buf); goto fail; diff --git a/imap/util.c b/imap/util.c index bb7ff16f9..d5002a7bd 100644 --- a/imap/util.c +++ b/imap/util.c @@ -1,7 +1,7 @@ /* * Copyright (C) 1996-8 Michael R. Elkins * Copyright (C) 1996-9 Brandon Long - * Copyright (C) 1999-2001 Brendan Cully + * Copyright (C) 1999-2002 Brendan Cully * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -152,7 +152,7 @@ int imap_parse_path (const char* path, IMAP_MBOX* mx) mx->account.flags |= M_ACCT_PORT; if (sscanf (tmp, "/%s", tmp) == 1) { - if (!strncmp (tmp, "ssl", 3)) + if (!ascii_strncmp (tmp, "ssl", 3)) mx->account.flags |= M_ACCT_SSL; else {