while ((line = mutt_file_read_line(line, &linelen, fpin, &lineno, 0)))
{
- if (mutt_str_strncmp(line, "[GNUPG:] ", 9) != 0)
+ size_t plen = mutt_str_startswith(line, "[GNUPG:]", CASE_MATCH);
+ if (plen == 0)
continue;
- s = line + 9;
+ s = line + plen;
mutt_debug(2, "checking \"%s\".\n", line);
- if (mutt_str_strncmp(s, "BEGIN_DECRYPTION", 16) == 0)
+ if (mutt_str_startswith(s, "BEGIN_DECRYPTION", CASE_MATCH))
inside_decrypt = 1;
- else if (mutt_str_strncmp(s, "END_DECRYPTION", 14) == 0)
+ else if (mutt_str_startswith(s, "END_DECRYPTION", CASE_MATCH))
inside_decrypt = 0;
- else if (mutt_str_strncmp(s, "PLAINTEXT", 9) == 0)
+ else if (mutt_str_startswith(s, "PLAINTEXT", CASE_MATCH))
{
if (!inside_decrypt)
{
break;
}
}
- else if (mutt_str_strncmp(s, "DECRYPTION_FAILED", 17) == 0)
+ else if (mutt_str_startswith(s, "DECRYPTION_FAILED", CASE_MATCH))
{
mutt_debug(2, "\tDECRYPTION_FAILED encountered. Failure.\n");
rv = -3;
break;
}
- else if (mutt_str_strncmp(s, "DECRYPTION_OKAY", 15) == 0)
+ else if (mutt_str_startswith(s, "DECRYPTION_OKAY", CASE_MATCH))
{
/* Don't break out because we still have to check for
* PLAINTEXT outside of the decryption boundaries. */
bytes -= (offset - last_pos); /* don't rely on mutt_str_strlen(buf) */
last_pos = offset;
- if (mutt_str_strncmp("-----BEGIN PGP ", buf, 15) == 0)
+ size_t plen = mutt_str_startswith(buf, "-----BEGIN PGP ", CASE_MATCH);
+ if (plen != 0)
{
clearsign = false;
could_not_decrypt = false;
decrypt_okay_rc = 0;
- if (mutt_str_strcmp("MESSAGE-----\n", buf + 15) == 0)
+ if (mutt_str_startswith(buf + plen, "MESSAGE-----\n", CASE_MATCH))
needpass = 1;
- else if (mutt_str_strcmp("SIGNED MESSAGE-----\n", buf + 15) == 0)
+ else if (mutt_str_startswith(buf + plen, "SIGNED MESSAGE-----\n", CASE_MATCH))
{
clearsign = true;
needpass = 0;
}
- else if (mutt_str_strcmp("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
+ else if (mutt_str_startswith(buf + plen, "PUBLIC KEY BLOCK-----\n", CASE_MATCH))
{
needpass = 0;
pgp_keyblock = true;
break;
}
/* remember optional Charset: armor header as defined by RFC4880 */
- if (mutt_str_strncmp("Charset: ", buf, 9) == 0)
+ if (mutt_str_startswith(buf, "Charset: ", CASE_MATCH))
{
size_t l = 0;
FREE(&gpgcharset);
while (fgets(buf, sizeof(buf), tfp))
{
- if (mutt_str_strncmp("-----BEGIN PGP ", buf, 15) == 0)
+ size_t plen = mutt_str_startswith(buf, "-----BEGIN PGP ", CASE_MATCH);
+ if (plen != 0)
{
- if (mutt_str_strcmp("MESSAGE-----\n", buf + 15) == 0)
+ if (mutt_str_startswith(buf + plen, "MESSAGE-----\n", CASE_MATCH))
enc = true;
- else if (mutt_str_strcmp("SIGNED MESSAGE-----\n", buf + 15) == 0)
+ else if (mutt_str_startswith(buf + plen, "SIGNED MESSAGE-----\n", CASE_MATCH))
sgn = true;
- else if (mutt_str_strcmp("PUBLIC KEY BLOCK-----\n", buf + 15) == 0)
+ else if (mutt_str_startswith(buf + plen, "PUBLIC KEY BLOCK-----\n", CASE_MATCH))
key = true;
}
}