ptr = memreadline(ptr, buf, sizeof buf);
if (*ptr != 0) {
striplt(buf);
- if (strlen(buf) == 0) {
+ if (IsEmptyStr(buf)) {
headers_size = ptr - IMAP->cached_rfc822_data;
}
}
if (!strcasecmp(desired_section, mbuf2)) {
cprintf("Content-type: %s", cbtype);
- if (strlen(cbcharset) > 0)
+ if (!IsEmptyStr(cbcharset))
cprintf("; charset=\"%s\"", cbcharset);
- if (strlen(name) > 0)
+ if (!IsEmptyStr(name))
cprintf("; name=\"%s\"", name);
cprintf("\r\n");
- if (strlen(encoding) > 0)
+ if (!IsEmptyStr(encoding))
cprintf("Content-Transfer-Encoding: %s\r\n", encoding);
- if (strlen(encoding) > 0) {
+ if (!IsEmptyStr(encoding)) {
cprintf("Content-Disposition: %s", disp);
- if (strlen(filename) > 0) {
+ if (!IsEmptyStr(filename)) {
cprintf("; filename=\"%s\"", filename);
}
cprintf("\r\n");
return;
}
- if (strlen(addr) == 0) {
+ if (IsEmptyStr(addr)) {
cprintf("NIL ");
return;
}
if (!strncasecmp(which_fields, "HEADER.FIELDS.NOT", 17))
headers_not = 1;
- for (i=0; i<strlen(which_fields); ++i) {
+ for (i=0; !IsEmptyStr(&which_fields[i]); ++i) {
if (which_fields[i]=='(')
strcpy(which_fields, &which_fields[i+1]);
}
- for (i=0; i<strlen(which_fields); ++i) {
- if (which_fields[i]==')')
+ for (i=0; !IsEmptyStr(&which_fields[i]); ++i) {
+ if (which_fields[i]==')') {
which_fields[i] = 0;
+ break;
+ }
}
num_parms = imap_parameterize(parms, which_fields);
strcat(boiled_headers, "\r\n");
}
- if (strlen(buf) == 0) done_headers = 1;
+ if (IsEmptyStr(buf)) done_headers = 1;
if (buf[0]=='\r') done_headers = 1;
if (buf[0]=='\n') done_headers = 1;
}
if (strchr(section, '[') != NULL) {
stripallbut(section, '[', ']');
}
- lprintf(CTDL_DEBUG, "Section is: %s%s\n", section, ((strlen(section)==0) ? "(empty)" : "") );
+ lprintf(CTDL_DEBUG, "Section is: %s%s\n",
+ section,
+ IsEmptyStr(section) ? "(empty)" : "");
if (!strncasecmp(section, "HEADER", 6)) {
need_body = 0;
}
is_partial = 1;
}
if (is_partial == 0) strcpy(partial, "");
- /* if (strlen(partial) > 0) lprintf(CTDL_DEBUG, "Partial is %s\n", partial); */
+ /* if (!IsEmptyStr(partial)) lprintf(CTDL_DEBUG, "Partial is %s\n", partial); */
if (IMAP->cached_body == NULL) {
CC->redirect_buffer = malloc(SIZ);
char cbmaintype[128];
char cbsubtype[128];
- if (cbtype != NULL) if (strlen(cbtype)>0) have_cbtype = 1;
+ if (cbtype != NULL) if (!IsEmptyStr(cbtype)) have_cbtype = 1;
if (have_cbtype) {
extract_token(cbmaintype, cbtype, 0, '/', sizeof cbmaintype);
extract_token(cbsubtype, cbtype, 1, '/', sizeof cbsubtype);
if (cbcharset == NULL) {
cprintf("(\"CHARSET\" \"US-ASCII\"");
}
- else if (strlen(cbcharset) == 0) {
+ else if (IsEmptyStr(cbcharset)) {
cprintf("(\"CHARSET\" \"US-ASCII\"");
}
else {
imap_strout(cbcharset);
}
- if (name != NULL) if (strlen(name)>0) {
+ if (name != NULL) if (!IsEmptyStr(name)) {
cprintf(" \"NAME\" ");
imap_strout(name);
}
cprintf("NIL "); /* Body ID */
cprintf("NIL "); /* Body description */
- if (encoding != NULL) if (strlen(encoding) > 0) have_encoding = 1;
+ if (encoding != NULL) if (!IsEmptyStr(encoding)) have_encoding = 1;
if (have_encoding) {
imap_strout(encoding);
}
if (disp == NULL) {
cprintf("NIL");
}
- else if (strlen(disp) == 0) {
+ else if (IsEmptyStr(disp)) {
cprintf("NIL");
}
else {
cprintf("(");
imap_strout(disp);
- if (filename != NULL) if (strlen(filename)>0) {
+ if (filename != NULL) if (!IsEmptyStr(filename)) {
cprintf(" (\"FILENAME\" ");
imap_strout(filename);
cprintf(")");
ptr = rfc822;
while (ptr = memreadline(ptr, buf, sizeof buf), *ptr != 0) {
++lines;
- if ((strlen(buf) == 0) && (rfc822_body == NULL)) {
+ if ((IsEmptyStr(buf)) && (rfc822_body == NULL)) {
rfc822_body = ptr;
}
}
int i;
int nest = 0;
- for (i=0; i<strlen(str); ++i) {
+ for (i=0; !IsEmptyStr(&str[i]); ++i) {
if (str[i]=='(') ++nest;
if (str[i]=='[') ++nest;
if (str[i]=='<') ++nest;
int imap_extract_data_items(char **argv, char *items) {
int num_items = 0;
int nest = 0;
- int i, initial_len;
+ int i;
char *start;
/* Convert all whitespace to ordinary space characters. */
- for (i=0; i<strlen(items); ++i) {
+ for (i=0; !IsEmptyStr(&items[i]); ++i) {
if (isspace(items[i])) items[i]=' ';
}