if (bar) {
bar[0] = 0;
++bar;
- striplt(aaa);
- striplt(bar);
+ string_trim(aaa);
+ string_trim(bar);
if ( (!IsEmptyStr(aaa)) && (!strcasecmp(name, aaa)) ) {
syslog(LOG_DEBUG, "internet_addressing: global alias <%s> to <%s>", name, bar);
strcpy(name, bar);
safestrncpy(original_name, name, sizeof original_name);
// should these checks still be here, or maybe move them to split_recps() ?
- striplt(name);
+ string_trim(name);
remove_any_whitespace_to_the_left_or_right_of_at_symbol(name);
stripallbut(name, '<', '>');
for (i=0; i<num_addresses; ++i) {
char this_address[256];
extract_token(this_address, a, i, ',', sizeof this_address);
- striplt(this_address); // strip leading and trailing whitespace
+ string_trim(this_address); // strip leading and trailing whitespace
stripout(this_address, '(', ')'); // remove any portion in parentheses
stripallbut(this_address, '<', '>'); // if angle brackets are present, keep only what is inside them
if (!IsEmptyStr(this_address)) {
}
// strip leading and trailing spaces in all strings
- striplt(user);
- striplt(node);
- striplt(name);
+ string_trim(user);
+ string_trim(node);
+ string_trim(name);
// If we processed a string that had the address in angle brackets
// but no name outside the brackets, we now have an empty name. In
strcat(fieldbuf, " ");
cont = &fieldbuf[strlen(fieldbuf)];
ptr = cmemreadline(ptr, cont, SIZ-strlen(fieldbuf) );
- striplt(cont);
+ string_trim(cont);
}
strcpy(fieldbuf, &fieldbuf[strlen(fieldhdr)]);
- striplt(fieldbuf);
+ string_trim(fieldbuf);
return(fieldbuf);
}
int h;
extract_token(domain, addr, 1, '@', sizeof domain);
- striplt(domain);
+ string_trim(domain);
h = CtdlHostAlias(domain);
if (!IsEmptyStr(coll)) {
strcat(coll, ",");
}
- striplt(addr);
+ string_trim(addr);
strcat(coll, addr);
}
}
ldap_set_option(ldserver, LDAP_OPT_PROTOCOL_VERSION, &ctdl_require_ldap_version);
ldap_set_option(ldserver, LDAP_OPT_REFERRALS, (void *)LDAP_OPT_OFF);
- striplt(CtdlGetConfigStr("c_ldap_bind_dn"));
- striplt(CtdlGetConfigStr("c_ldap_bind_pw"));
+ string_trim(CtdlGetConfigStr("c_ldap_bind_dn"));
+ string_trim(CtdlGetConfigStr("c_ldap_bind_pw"));
i = ldap_simple_bind_s(ldserver,
(!IsEmptyStr(CtdlGetConfigStr("c_ldap_bind_dn")) ? CtdlGetConfigStr("c_ldap_bind_dn") : NULL),
(!IsEmptyStr(CtdlGetConfigStr("c_ldap_bind_pw")) ? CtdlGetConfigStr("c_ldap_bind_pw") : NULL)
for (i=0; i<strlen(nnn); ++i) {
if (!strncmp(&nnn[i], " ", 2)) strcpy(&nnn[i], &nnn[i+1]);
}
- striplt(nnn);
+ string_trim(nnn);
return(nnn);
}
ch = icalproperty_get_attendee(attendee);
if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
safestrncpy(attendee_string, ch + 7, sizeof (attendee_string));
- striplt(attendee_string);
+ string_trim(attendee_string);
recp = validate_recipients(attendee_string, NULL, 0);
if (recp != NULL) {
if (!strcasecmp(recp->recp_local, CC->user.fullname)) {
}
if (!strncasecmp(organizer_string, "MAILTO:", 7)) {
strcpy(organizer_string, &organizer_string[7]);
- striplt(organizer_string);
+ string_trim(organizer_string);
} else {
strcpy(organizer_string, "");
}
}
if (!strncasecmp(organizer_string, "MAILTO:", 7)) {
strcpy(organizer_string, &organizer_string[7]);
- striplt(organizer_string);
+ string_trim(organizer_string);
/*
* If the user saving the event is listed as the
* organizer, then send out invitations.
/* screen name or email address */
safestrncpy(buf, ch + 7, sizeof(buf));
- striplt(buf);
+ string_trim(buf);
cprintf("%s ", buf);
}
cprintf("\n");
int a;
extract_token(username, cmdbuf, 0, '|', sizeof username);
- striplt(username);
+ string_trim(username);
syslog(LOG_DEBUG, "user_ops: cmd_user(%s)", username);
a = CtdlLoginExistingUser(username);
void cmd_list(char *cmdbuf) {
char searchstring[256];
extract_token(searchstring, cmdbuf, 0, '|', sizeof searchstring);
- striplt(searchstring);
+ string_trim(searchstring);
cprintf("%d \n", LISTING_FOLLOWS);
ForEachUser(ListThisUser, (void *)searchstring );
cprintf("000\n");
/* Output them one by one. */
for (i=0; i<num_addrs; ++i) {
extract_token(individual_addr, addr, i, ',', sizeof individual_addr);
- striplt(individual_addr);
+ string_trim(individual_addr);
process_rfc822_addr(individual_addr, user, node, name);
IAPuts("(");
IPutStr(name, strlen(name));
if (whichflags[strlen(whichflags)-1]==')') {
whichflags[strlen(whichflags)-1]=0;
}
- striplt(whichflags);
+ string_trim(whichflags);
/* A client might twiddle more than one bit at a time.
* Note that we check for the flag names without the leading
int t = 0;
for (t=0; t<nt; ++t) {
extract_token(rtoken, decoded_rule, t, '|', sizeof(rtoken));
- striplt(rtoken);
+ string_trim(rtoken);
switch(t) {
case 1: // field to compare
for (i=0; i<=field_all; ++i) {
if (mptr != NULL) {
char *aptr;
safestrncpy(smi.meta_content_type, &mptr[13], sizeof smi.meta_content_type);
- striplt(smi.meta_content_type);
+ string_trim(smi.meta_content_type);
aptr = smi.meta_content_type;
while (!IsEmptyStr(aptr)) {
if ((*aptr == ';')
}
strcpy(username, argbuf);
- striplt(username);
+ string_trim(username);
if (CtdlLoginExistingUser(username) == login_ok) {
cprintf("+OK Password required for %s\r\n", username);
char password[SIZ];
safestrncpy(password, argbuf, sizeof password);
- striplt(password);
+ string_trim(password);
if (CtdlTryPassword(password, strlen(password)) == pass_ok) {
pop3_login();
r->link = NULL;
}
r->link = strdup(attribute[i+1]);
- striplt(r->link);
+ string_trim(r->link);
}
}
}
k = vcard_get_prop(v, "email", 1, instance, 1);
if ( (s != NULL) && (k != NULL) && (bmstrcasestr(k, "internet")) ) {
addr = strdup(s);
- striplt(addr);
+ string_trim(addr);
if (!IsEmptyStr(addr)) {
IsDirectoryAddress = IsDirectory(addr, 1);
if (displayname[i] == ';') displayname[i] = ',';
if (displayname[i] == ',') has_commas = 1;
}
- striplt(displayname);
+ string_trim(displayname);
cprintf("%s%s%s <%s>\n",
(has_commas ? "\"" : ""),
/* Make a vCard out of each address */
extract_token(recipient, aptr->collected_addresses, i, ',', sizeof recipient);
- striplt(recipient);
+ string_trim(recipient);
v = vcard_new_from_rfc822_addr(recipient);
if (v != NULL) {
const char *s;
do {
ptr = memreadline(ptr, buf, sizeof buf);
if (*ptr != 0) {
- striplt(buf);
+ string_trim(buf);
if (!IsEmptyStr(buf) && (!strncasecmp(buf, "Content-type:", 13))) {
if (
(bmstrcasestr(buf, "multipart") != NULL)
CtdlDecodeBase64(memo, filename, strlen(filename));
extract_token(this_rev, memo, 0, '|', sizeof this_rev);
- striplt(this_rev);
+ string_trim(this_rev);
/* Perform the patch */
fp = popen("patch -f -s -p0 -r /dev/null >/dev/null 2>/dev/null", "w");
memset(&hecbd, 0, sizeof(struct HistoryEraserCallBackData));
hecbd.tempfilename = temp;
hecbd.stop_when = rev;
- striplt(hecbd.stop_when);
+ string_trim(hecbd.stop_when);
mime_parser(CM_RANGE(msg, eMesageText), *wiki_rev_callback, NULL, NULL, (void *)&hecbd, 0);
CM_Free(msg);
if (!strcasecmp(el, "resource")) {
if (XMPP->chardata_len > 0) {
safestrncpy(XMPP->iq_client_resource, XMPP->chardata, sizeof XMPP->iq_client_resource);
- striplt(XMPP->iq_client_resource);
+ string_trim(XMPP->iq_client_resource);
}
}
else if (!strcasecmp(el, "username")) { /* NON SASL ONLY */
if (XMPP->chardata_len > 0) {
safestrncpy(XMPP->iq_client_username, XMPP->chardata, sizeof XMPP->iq_client_username);
- striplt(XMPP->iq_client_username);
+ string_trim(XMPP->iq_client_username);
}
}
else if (!strcasecmp(el, "password")) { /* NON SASL ONLY */
if (XMPP->chardata_len > 0) {
safestrncpy(XMPP->iq_client_password, XMPP->chardata, sizeof XMPP->iq_client_password);
- striplt(XMPP->iq_client_password);
+ string_trim(XMPP->iq_client_password);
}
}
xmlesc(xmlbuf2, ptr->sender_email, sizeof xmlbuf2)
);
if (ptr->text != NULL) {
- striplt(ptr->text);
+ string_trim(ptr->text);
cprintf("<body>%s</body>", xmlesc(xmlbuf1, ptr->text, sizeof xmlbuf1));
free(ptr->text);
}
if (mptr != NULL) {
char *aptr;
safestrncpy(content_type, &mptr[13], sizeof content_type);
- striplt(content_type);
+ string_trim(content_type);
aptr = content_type;
while (!IsEmptyStr(aptr)) {
if ((*aptr == ';')
msg->cm_anon_type = type;
msg->cm_format_type = format_type;
- if (recipient != NULL) rcplen = striplt(recipient);
- if (recp_cc != NULL) cclen = striplt(recp_cc);
+ if (recipient != NULL) rcplen = string_trim(recipient);
+ if (recp_cc != NULL) cclen = string_trim(recp_cc);
/* Path or Return-Path */
if (myelen > 0) {
if (subject != NULL) {
long length;
- length = striplt(subject);
+ length = string_trim(subject);
if (length > 0) {
long i;
long IsAscii;
// Continue attempting user validation...
safestrncpy(username, trythisname, sizeof (username));
- striplt(username);
+ string_trim(username);
if (IsEmptyStr(username)) {
return login_not_found;
for (i=0; i<num_recp_on_this_line; ++i) {
extract_token(this_recp, add_these_recipients,
i, ',', sizeof this_recp);
- striplt(this_recp);
+ string_trim(this_recp);
if (!IsEmptyStr(this_recp)) {
++num_recipients;
recipients = realloc(recipients,
output_len += strlen(outbuf);
/* Strip leading/trailing whitespace. We can't do this with
- * striplt() because it uses too many strlen()'s
+ * string_trim() because it uses too many strlen()'s
*/
while ((output_len > 0) && (isspace(outptr[0]))) {
strcpy(outptr, &outptr[1]);
unsigned int decode_hex(char *Source);
int CtdlDecodeQuotedPrintable(char *decoded, char *encoded, int sourcelen);
void StripSlashes(char *Dir, int TrailingSlash);
-size_t striplt(char *);
+size_t string_trim(char *);
int haschar(const char *st, int ch);
void remove_token(char *source, int parmnum, char separator);
int is_msg_in_sequence_set(const char *mset, long msgnum);
char *rfc2047encode(const char *line, long length);
int is_msg_in_mset(const char *mset, long msgnum);
int pattern2(char *search, char *patn);
-void stripltlen(char *, int *);
+void string_trimlen(char *, int *);
char *html_to_ascii(const char *inputmsg, int msglen, int screenwidth, int ansi);
void LoadEntityList(char *FileName);
void utf8ify_rfc822_string(char *buf);
if (!strncasecmp(header, "Content-type:", 13)) {
memcpy (m->b[content_type].Key, &header[13], headerlen - 12);
m->b[content_type].Key[headerlen - 12] = '\0';
- m->b[content_type].len = striplt (m->b[content_type].Key);
+ m->b[content_type].len = string_trim (m->b[content_type].Key);
m->b[content_type_name].len = extract_key(m->b[content_type_name].Key, CKEY(m->b[content_type]), HKEY("name"), '=');
m->b[charset].len = extract_key(m->b[charset].Key, CKEY(m->b[content_type]), HKEY("charset"), '=');
else if (!strncasecmp(header, "Content-Disposition:", 20)) {
memcpy (m->b[disposition].Key, &header[20], headerlen - 19);
m->b[disposition].Key[headerlen - 19] = '\0';
- m->b[disposition].len = striplt(m->b[disposition].Key);
+ m->b[disposition].len = string_trim(m->b[disposition].Key);
m->b[content_disposition_name].len = extract_key(m->b[content_disposition_name].Key, CKEY(m->b[disposition]), HKEY("name"), '=');
m->b[filename].len = extract_key(m->b[filename].Key, CKEY(m->b[disposition]), HKEY("filename"), '=');
pch = strchr(m->b[disposition].Key, ';');
if (pch != NULL) *pch = '\0';
- m->b[disposition].len = striplt(m->b[disposition].Key);
+ m->b[disposition].len = string_trim(m->b[disposition].Key);
}
else if (!strncasecmp(header, "Content-ID:", 11)) {
memcpy(m->b[id].Key, &header[11], headerlen - 11);
m->b[id].Key[headerlen - 11] = '\0';
- striplt(m->b[id].Key);
+ string_trim(m->b[id].Key);
m->b[id].len = stripallbut(m->b[id].Key, '<', '>');
}
else if (!strncasecmp(header, "Content-length: ", 15)) {
else if (!strncasecmp(header, "Content-transfer-encoding: ", 26)) {
memcpy(m->b[encoding].Key, &header[26], headerlen - 26);
m->b[encoding].Key[headerlen - 26] = '\0';
- m->b[encoding].len = striplt(m->b[encoding].Key);
+ m->b[encoding].len = string_trim(m->b[encoding].Key);
}
*header = '\0';
headerlen = 0;
// Strip leading and trailing spaces from a string
-size_t striplt(char *buf) {
+size_t string_trim(char *buf) {
char *first_nonspace = NULL;
char *last_nonspace = NULL;
char *ptr;
* buf - the string to modify
* len - length of the string.
*/
-void stripltlen(char *buf, int *len) {
+void string_trimlen(char *buf, int *len) {
int delta = 0;
if (*len == 0) return;
while ((*len > delta) && (isspace(buf[delta]))){
t = num_tokens(strbuf, ';');
for (i=0; i<t; ++i) {
extract_token(compare, strbuf, i, ';', sizeof compare);
- striplt(compare);
+ string_trim(compare);
if (!strncasecmp(compare, "charset=", 8)) {
remove_token(strbuf, i, ';');
}
/* Anything left is probably the first name */
safestrncpy(firstname, buf, sizeof firstname);
- striplt(firstname);
+ string_trim(firstname);
/* Compose the structured name */
snprintf(vname, vname_size, "%s;%s;%s;%s;%s", lastname, firstname, middlename,
switch (ch) {
case 'a':
newprompt("Enter new email address: ", buf, 50);
- striplt(buf);
+ string_trim(buf);
if (!IsEmptyStr(buf)) {
// FIXME validate the email address (format, our own domain, addr does not belong to another user)
++num_recs;
if (r / 100 == 2) {
extract_token(diruser, buf, 0, '@', sizeof diruser);
extract_token(dirnode, buf, 1, '@', sizeof dirnode);
- striplt(diruser);
- striplt(dirnode);
+ string_trim(diruser);
+ string_trim(dirnode);
if ((strcasecmp(diruser, fullname))
|| (strcasecmp(dirnode, ipc->ServInfo.nodename))) {
scr_printf("\nYou can't use %s as your address.\n", tmpemail);
switch (ch) {
case 'a':
newprompt("Enter host name: ", buf, 50);
- striplt(buf);
+ string_trim(buf);
if (!IsEmptyStr(buf)) {
++num_recs;
if (num_recs == 1) {
if (buf[i] == '#')
buf[i] = 0;
}
- striplt(buf);
+ string_trim(buf);
if (!IsEmptyStr(buf)) {
fprintf(changefp, "%s|%s\n", entrytype, buf);
}
int num_recp = num_tokens(recp, ',');
for (int i=0; i<num_recp; ++i) {
extract_token(tokbuf, recp, i, ',', sizeof(tokbuf));
- striplt(tokbuf);
+ string_trim(tokbuf);
JsonArrayAppend(j, NewJsonPlainString(HKEY("r"), tokbuf, strlen(tokbuf)));
}
return(j);
// rfc822 header parsing here
if (!strncasecmp(buf, "Content-transfer-encoding:", 26)) {
strcpy(content_transfer_encoding, &buf[26]);
- striplt(content_transfer_encoding);
+ string_trim(content_transfer_encoding);
}
if (!strncasecmp(buf, "Content-type:", 13)) {
strcpy(content_type, &buf[13]);
- striplt(content_type);
+ string_trim(content_type);
}
}
if (!strcmp(buf, "000")) { // if we have an empty message, don't try to read further
return;
safestrncpy(buf, ++ptr, sizeof buf);
- striplt(buf);
+ string_trim(buf);
if (!strncasecmp(buf, "charset=", 8)) {
strcpy(charset, &buf[8]);
// Remove wandering punctuation
if ((ptr = strchr(charset, '\"')))
*ptr = 0;
- striplt(charset);
+ string_trim(charset);
}
}
meta = malloc(meta_length + 1);
safestrncpy(meta, meta_start, meta_length);
meta[meta_length] = 0;
- striplt(meta);
+ string_trim(meta);
if (!strncasecmp(meta, "HTTP-EQUIV=", 11)) {
meta_http_equiv = strdup(&meta[11]);
spaceptr = strchr(meta_http_equiv, ' ');
new_request_header.key = strdup(buf);
++c;
new_request_header.val = strdup(c);
- striplt(new_request_header.key);
- striplt(new_request_header.val);
+ string_trim(new_request_header.key);
+ string_trim(new_request_header.val);
array_append(h.request_headers, &new_request_header);
#ifdef DEBUG_HTTP
syslog(LOG_DEBUG, "\033[1m\033[35m{ %s: %s\033[0m", new_request_header.key, new_request_header.val);
if (v) {
*v = 0;
++v;
- striplt(v); // we now have a key (k) and a value (v)
+ string_trim(v); // we now have a key (k) and a value (v)
if ((!strcasecmp(k, "content-type")) // fields which can be passed from RFC822 to HTTP as-is
|| (!strcasecmp(k, "date"))
) {
for (i = 0; i < num_tags; ++i) {
extract_token(tag, taglist, i, ',', sizeof tag);
- striplt(tag);
+ string_trim(tag);
char *lq = (strchr(tag, '"'));
char *rq = (strrchr(tag, '"'));
if (lq < rq) { // has two double quotes
strcpy(rq, "");
strcpy(tag, ++lq);
}
- striplt(tag);
+ string_trim(tag);
if (!strcmp(tag, "*")) { // wildcard match
return (1);
}