Sticking with local convention, as Ken requested.
/* A convenience for the common case of dst being an array. */
#define TRUNCCPY(dst, src) trunccpy(dst, src, sizeof (dst))
-bool HasPrefix(const char *s, const char *prefix);
+bool has_prefix(const char *s, const char *prefix);
bool HasSuffix(const char *s, const char *suffix);
bool HasSuffixC(const char *s, int c);
void TrimSuffixC(char *s, int c);
&errstr)) != NULL ; ) {
if (doingEHLO
- && HasPrefix(buffer, "250")
+ && has_prefix(buffer, "250")
&& (buffer[3] == '-' || doingEHLO == 2)
&& buffer[4]) {
if (doingEHLO == 2) {
for (ehlo = EHLOkeys; *ehlo; ehlo++) {
ep = *ehlo;
- if (HasPrefix(ep, s)) {
+ if (has_prefix(ep, s)) {
for (ep += len; *ep == ' '; ep++)
continue;
return ep;
return NOTOK;
}
- if (!HasPrefix(line, "334 ")) {
+ if (!has_prefix(line, "334 ")) {
netsec_err(errstr, "Improper SASL protocol response: %s", line);
return NOTOK;
}
if (line == NULL)
return NOTOK;
- if (!HasPrefix(line, "235 ")) {
+ if (!has_prefix(line, "235 ")) {
if (len > 4)
netsec_err(errstr, "Authentication failed: %s", line + 4);
else
default:
/* skip any files beginning with backup prefix */
- if (HasPrefix(dp->d_name, BACKUP_PREFIX))
+ if (has_prefix(dp->d_name, BACKUP_PREFIX))
continue;
/* skip the LINK file */
/* hack for "cur-name", "cur-n", etc. */
if (!strcmp (cp, "cur"))
return 0;
- if (HasPrefix(cp, "cur")) {
+ if (has_prefix(cp, "cur")) {
if (cp[3] == ':' || cp[3] == '=')
return 0;
}
char maildir[BUFSIZ];
if (*folder != '/'
- && !HasPrefix(folder, CWD)
+ && !has_prefix(folder, CWD)
&& strcmp (folder, DOT)
&& strcmp (folder, DOTDOT)
- && !HasPrefix(folder, PWD)) {
+ && !has_prefix(folder, PWD)) {
strncpy (maildir, mailfold, sizeof(maildir)); /* preserve... */
cp = getcpy (m_maildir (folder));
strncpy (mailfold, maildir, sizeof(mailfold));
folder = getfolder(1);
if (!(*folder != '/'
- && !HasPrefix(folder, CWD)
+ && !has_prefix(folder, CWD)
&& strcmp (folder, DOT)
&& strcmp (folder, DOTDOT)
- && !HasPrefix(folder, PWD))) {
+ && !has_prefix(folder, PWD))) {
strncpy (mailfold, folder, sizeof(mailfold));
return mailfold;
}
int
isfrom(const char *string)
{
- return (HasPrefix(string, "From ")
- || HasPrefix(string, ">From "));
+ return (has_prefix(string, "From ")
+ || has_prefix(string, ">From "));
}
static int
isat (const char *p)
{
- return HasPrefix(p, " AT ") || HasPrefix(p, " At ") ||
- HasPrefix(p, " aT ") || HasPrefix(p, " at ");
+ return has_prefix(p, " AT ") || has_prefix(p, " At ") ||
+ has_prefix(p, " aT ") || has_prefix(p, " at ");
}
case FLDPLUS: {
char **save, *expire;
time_t *expires_at = NULL;
- if (HasPrefix(name, "access-")) {
+ if (has_prefix(name, "access-")) {
const char *user = name + 7;
mh_oauth_cred *creds = find_or_alloc_user_creds(user_creds,
user);
save = &creds->access_token;
- } else if (HasPrefix(name, "refresh-")) {
+ } else if (has_prefix(name, "refresh-")) {
const char *user = name + 8;
mh_oauth_cred *creds = find_or_alloc_user_creds(user_creds,
user);
save = &creds->refresh_token;
- } else if (HasPrefix(name, "expire-")) {
+ } else if (has_prefix(name, "expire-")) {
const char *user = name + 7;
mh_oauth_cred *creds = find_or_alloc_user_creds(user_creds,
user);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, ctx);
- if (HasPrefix(url, "http://127.0.0.1:")) {
+ if (has_prefix(url, "http://127.0.0.1:")) {
/* Hack: on Cygwin, curl doesn't fail to connect with ECONNREFUSED.
Instead, it waits to timeout. So set a really short timeout, but
just on localhost (for convenience of the user, and the test
if (*name == '/'
|| (flag == TFOLDER
- && (!HasPrefix(name, CWD)
+ && (!has_prefix(name, CWD)
&& strcmp (name, DOT)
&& strcmp (name, DOTDOT)
- && !HasPrefix(name, PWD))))
+ && !has_prefix(name, PWD))))
return mh_xstrdup(name);
if (pwds == NULL)
if (cp == pwds)
cp++;
- if (HasPrefix(name, CWD))
+ if (has_prefix(name, CWD))
name += LEN(CWD);
if (strcmp (name, DOTDOT) == 0 || strcmp (name, PWD) == 0) {
return mh_xstrdup(buffer);
}
- if (HasPrefix(name, PWD))
+ if (has_prefix(name, PWD))
name += LEN(PWD);
else
cp = ep;
*cp = '\0';
break;
}
- if (HasPrefix(cp, PWD)) {
+ if (has_prefix(cp, PWD)) {
for (dp = cp - 2; dp > f; dp--)
if (*dp == '/')
break;
cp = dp;
continue;
}
- if (HasPrefix(cp, CWD)) {
+ if (has_prefix(cp, CWD)) {
strcpy (cp - 1, cp + LEN(CWD) - 1);
cp--;
continue;
}
-/* HasPrefix returns true if non-NULL s starts with non-NULL prefix. */
-bool HasPrefix(const char *s, const char *prefix)
+/* has_prefix returns true if non-NULL s starts with non-NULL prefix. */
+bool has_prefix(const char *s, const char *prefix)
{
while (*s && *s == *prefix) {
s++;
break for versions with multiple decimal points, etc. */
const float current_version = strtof (VERSION, NULL);
const float old_version =
- context_version && HasPrefix(context_version, "nmh-")
+ context_version && has_prefix(context_version, "nmh-")
? strtof (context_version + 4, NULL)
: 99999999;
FILE *fp;
if (*file != '/'
- && !HasPrefix(file, "./") && !HasPrefix(file, "../"))
+ && !has_prefix(file, "./") && !has_prefix(file, "../"))
file = etcpath (file);
if ((fp = fopen (file, "r")) == NULL) {
akerrst = file;
* Change the "Return-Path:" field (if in first line)
* back to "From ".
*/
- if (HasPrefix(buffer, "Return-Path:")) {
+ if (has_prefix(buffer, "Return-Path:")) {
char tmpbuffer[BUFSIZ];
char *tp, *ep, *fp;
tp = dctime(dlocaltimenow());
snprintf (buffer, sizeof(buffer), "From %.*s %s",
(int)(fp - ep), ep, tp);
- } else if (HasPrefix(buffer, "X-Envelope-From:")) {
+ } else if (has_prefix(buffer, "X-Envelope-From:")) {
/*
* Change the "X-Envelope-From:" field
* (if first line) back to "From ".
strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
ep = tmpbuffer + 17;
snprintf (buffer, sizeof(buffer), "From %s", ep);
- } else if (!HasPrefix(buffer, "From ")) {
+ } else if (!has_prefix(buffer, "From ")) {
/*
* If there is already a "From " line,
* then leave it alone. Else we add one.
* If this is not first line, and begins with
* "From ", then prepend line with ">".
*/
- if (j != 0 && HasPrefix(buffer, "From ")) {
+ if (j != 0 && has_prefix(buffer, "From ")) {
if (write (md, ">", 1) < 0) {
advise (mailbox, "write");
}
fix_filename_param (char *name, char *value, PM *first_pm, PM *last_pm) {
int fixed = 0;
- if (HasPrefix(value, "=?") && HasSuffix(value, "?=")) {
+ if (has_prefix(value, "=?") && HasSuffix(value, "?=")) {
/* Looks like an RFC 2047 encoded parameter. */
char decoded[PATH_MAX + 1];
* doesn't falsely match an mbox delimiter.
*/
cp = bufp;
- if (gotlen >= 5 && HasPrefix(cp, "From ")) {
+ if (gotlen >= 5 && has_prefix(cp, "From ")) {
fprintf (out, "=%02X", 'F');
cp++;
n += 3;
int cwdlen = strlen (info->cwd);
fprintf (stderr, " as file %s\n",
- !HasPrefix(ct->c_storage, info->cwd)
+ !has_prefix(ct->c_storage, info->cwd)
|| ct->c_storage[cwdlen] != '/'
? ct->c_storage : ct->c_storage + cwdlen + 1);
}
if (line == NULL)
return NOTOK;
- if (!HasPrefix(line, "+OK")) {
+ if (!has_prefix(line, "+OK")) {
netsec_err(errstr, "Authentication failed: %s", line);
return NOTOK;
}
if (pop_getline (buffer, sizeof buffer, nsc) != OK)
return NOTOK;
- if (HasPrefix(buffer, TRM)) {
+ if (has_prefix(buffer, TRM)) {
if (buffer[LEN(TRM)] == 0)
return DONE;
strncpy (response, buffer + LEN(TRM), sizeof(response));
const char *no_at_sign = "no at-sign after local-part";
adr_nodep->escape_local_part =
- HasPrefix(error, no_at_sign);
+ has_prefix(error, no_at_sign);
} else {
mnfree (mp);
}
if (m_atoi (dp->d_name))
break;
if (strcmp (dp->d_name, LINK) == 0
- || HasPrefix(dp->d_name, BACKUP_PREFIX))
+ || has_prefix(dp->d_name, BACKUP_PREFIX))
break;
admonish (NULL, "file \"%s/%s\" not deleted",
while (fgets (buffer, sizeof(buffer), qfp)) {
if (first) {
first = 0;
- if (HasPrefix(buffer, "From ")) {
+ if (has_prefix(buffer, "From ")) {
/* get copy of envelope information ("From " line) */
envelope = mh_xstrdup(buffer);