$Log$
+ Revision 629.6 2005/01/18 17:58:38 ajc
+ * Trying to fix IMAP brokenness on Linux-x64. Committing changes even
+ though there are a lot of annoying trace messages in this tree, because
+ I did clean up a bunch of stuff here and there.
+
Revision 629.5 2005/01/14 17:08:30 ajc
* Applied a configure script fix sent in by David Given for more reliable
detection of the installed libical version.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
for (i=0; i<rows; ++i) {
memset(buf, 0, SIZ);
extract_token(buf, listing, i, '\n');
- memcpy(&sortbuf[i*SIZ], buf, SIZ);
+ memcpy(&sortbuf[i*SIZ], buf, (size_t)SIZ);
}
/* Do the sort */
{
sptr2++;
*sptr2 = '\0';
- strncpy(nonce, sptr, NONCE_SIZE);
+ strncpy(nonce, sptr, (size_t)NONCE_SIZE);
}
}
* "RFC822.TEXT" body only (without leading blank line)
*/
void imap_fetch_rfc822(long msgnum, char *whichfmt) {
- char buf[1024];
+ char buf[SIZ];
char *ptr;
long headers_size, text_size, total_size;
long bytes_remaining = 0;
/* Good to go! */
tmp = IMAP->cached_fetch;
}
- else if ((IMAP->cached_fetch != NULL) && (IMAP->cached_msgnum != msgnum)) {
+ else if (IMAP->cached_fetch != NULL) {
/* Some other message is cached -- free it */
fclose(IMAP->cached_fetch);
IMAP->cached_fetch == NULL;
IMAP->cached_msgnum = (-1);
- tmp = NULL;
}
/* At this point, we now can fetch and convert the message iff it's not
}
/*
- * Load the message into a temp file for translation
- * and measurement
- */
+ * Load the message into a temp file for translation
+ * and measurement
+ */
+ TRACE;
CtdlRedirectOutput(tmp, -1);
+ TRACE;
CtdlOutputMsg(msgnum, MT_RFC822, HEADERS_ALL, 0, 1);
+ TRACE;
CtdlRedirectOutput(NULL, -1);
+ TRACE;
IMAP->cached_fetch = tmp;
IMAP->cached_msgnum = msgnum;
fseek(tmp, 0L, SEEK_END);
total_size = ftell(tmp);
text_size = total_size - headers_size;
+ lprintf(CTDL_DEBUG, "RFC822: headers=%ld, text=%ld, total=%ld\n",
+ headers_size, text_size, total_size);
if (!strcasecmp(whichfmt, "RFC822.SIZE")) {
cprintf("RFC822.SIZE %ld", total_size);
}
cprintf("%s {%ld}\r\n", whichfmt, bytes_remaining);
- blocksize = sizeof(buf);
+ blocksize = (long)sizeof(buf);
while (bytes_remaining > 0L) {
if (blocksize > bytes_remaining) blocksize = bytes_remaining;
- fread(buf, blocksize, 1, tmp);
- client_write(buf, blocksize);
+ fread(buf, (size_t)blocksize, 1, tmp);
+ client_write(buf, (int)blocksize);
bytes_remaining = bytes_remaining - blocksize;
}
void *cbuserdata)
{
struct imap_fetch_part *imfp;
- char mbuf2[1024];
+ char mbuf2[SIZ];
imfp = (struct imap_fetch_part *)cbuserdata;
* really need to make this suck less.
*/
void imap_output_envelope_from(struct CtdlMessage *msg) {
- char user[1024], node[1024], name[1024];
+ char user[SIZ], node[SIZ], name[SIZ];
/* For anonymous messages, it's so easy! */
if (!is_room_aide() && (msg->cm_anon_type == MES_ANONONLY)) {
* then boil it down to just the fields we want.
*/
void imap_strip_headers(FILE *fp, char *section) {
- char buf[1024];
+ char buf[SIZ];
char *which_fields = NULL;
int doing_headers = 0;
int headers_not = 0;
*/
void imap_fetch_body(long msgnum, char *item, int is_peek) {
struct CtdlMessage *msg = NULL;
- char section[1024];
- char partial[1024];
+ char section[SIZ];
+ char partial[SIZ];
int is_partial = 0;
- char buf[1024];
- int i;
+ char buf[SIZ];
FILE *tmp = NULL;
long bytes_remaining = 0;
long blocksize;
struct imap_fetch_part imfp;
/* extract section */
- strcpy(section, item);
- for (i=0; i<strlen(section); ++i) {
- if (section[i]=='[') strcpy(section, §ion[i+1]);
- }
- for (i=0; i<strlen(section); ++i) {
- if (section[i]==']') section[i] = 0;
+ safestrncpy(section, item, sizeof section);
+ if (strchr(section, '[') != NULL) {
+ stripallbut(section, '[', ']');
}
- lprintf(CTDL_DEBUG, "Section is %s\n", section);
+ lprintf(CTDL_DEBUG, "Section is: %s%s\n", section, ((strlen(section)==0) ? "(empty)" : "") );
/* Burn the cache if we don't have the same section of the
* same message again.
}
/* extract partial */
- strcpy(partial, item);
- for (i=0; i<strlen(partial); ++i) {
- if (partial[i]=='<') {
- strcpy(partial, &partial[i+1]);
- is_partial = 1;
- }
- }
- for (i=0; i<strlen(partial); ++i) {
- if (partial[i]=='>') partial[i] = 0;
+ safestrncpy(partial, item, sizeof partial);
+ if (strchr(partial, '<') != NULL) {
+ stripallbut(partial, '<', '>');
+ is_partial = 1;
}
if (is_partial == 0) strcpy(partial, "");
if (strlen(partial) > 0) lprintf(CTDL_DEBUG, "Partial is %s\n", partial);
return;
}
msg = CtdlFetchMessage(msgnum, 1);
+TRACE;
}
/* Now figure out what the client wants, and get it */
+TRACE;
if (IMAP->cached_body != NULL) {
tmp = IMAP->cached_body;
+TRACE;
}
else if ( (!strcmp(section, "1")) && (msg->cm_format_type != 4) ) {
+TRACE;
CtdlRedirectOutput(tmp, -1);
CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822,
HEADERS_NONE, 0, 1);
CtdlRedirectOutput(NULL, -1);
+TRACE;
}
else if (!strcmp(section, "")) {
+TRACE;
CtdlRedirectOutput(tmp, -1);
+TRACE;
+ lprintf(CTDL_DEBUG, "calling CtdlOutputPreLoadedMsg()\n");
+ lprintf(CTDL_DEBUG, "msg %s null\n", ((msg == NULL) ? "is" : "is not") );
+ lprintf(CTDL_DEBUG, "msgnum is %ld\n", msgnum);
CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822,
HEADERS_ALL, 0, 1);
+TRACE;
CtdlRedirectOutput(NULL, -1);
+TRACE;
}
/*
* fields, strip it down.
*/
else if (!strncasecmp(section, "HEADER", 6)) {
+TRACE;
CtdlRedirectOutput(tmp, -1);
+TRACE;
+ lprintf(CTDL_DEBUG, "calling CtdlOutputPreLoadedMsg()\n");
+ lprintf(CTDL_DEBUG, "msg %s null\n", ((msg == NULL) ? "is" : "is not") );
+ lprintf(CTDL_DEBUG, "msgnum is %ld\n", msgnum);
CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822,
HEADERS_ONLY, 0, 1);
+TRACE;
CtdlRedirectOutput(NULL, -1);
imap_strip_headers(tmp, section);
}
*/
else if (!strncasecmp(section, "TEXT", 4)) {
CtdlRedirectOutput(tmp, -1);
+ lprintf(CTDL_DEBUG, "calling CtdlOutputPreLoadedMsg()\n");
+ lprintf(CTDL_DEBUG, "msg %s null\n", ((msg == NULL) ? "is" : "is not") );
+ lprintf(CTDL_DEBUG, "msgnum is %ld\n", msgnum);
CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822,
HEADERS_NONE, 0, 1);
+TRACE;
CtdlRedirectOutput(NULL, -1);
+TRACE;
}
/*
* (Note value of 1 passed as 'dont_decode' so client gets it encoded)
*/
else {
+TRACE;
safestrncpy(imfp.desired_section, section,
sizeof(imfp.desired_section));
+TRACE;
imfp.output_fp = tmp;
+TRACE;
mime_parser(msg->cm_fields['M'], NULL,
*imap_load_part, NULL, NULL,
(void *)&imfp,
1);
+TRACE;
}
+TRACE;
fseek(tmp, 0L, SEEK_END);
+TRACE;
bytes_remaining = ftell(tmp);
+TRACE;
if (is_partial == 0) {
+TRACE;
rewind(tmp);
cprintf("BODY[%s] {%ld}\r\n", section, bytes_remaining);
+TRACE;
}
else {
+TRACE;
sscanf(partial, "%ld.%ld", &pstart, &pbytes);
if ((bytes_remaining - pstart) < pbytes) {
pbytes = bytes_remaining - pstart;
}
+TRACE;
fseek(tmp, pstart, SEEK_SET);
+TRACE;
bytes_remaining = pbytes;
+TRACE;
cprintf("BODY[%s]<%ld> {%ld}\r\n",
section, pstart, bytes_remaining);
}
+TRACE;
- blocksize = sizeof(buf);
+ blocksize = (long)sizeof(buf);
+TRACE;
while (bytes_remaining > 0L) {
+TRACE;
if (blocksize > bytes_remaining) blocksize = bytes_remaining;
+TRACE;
fread(buf, blocksize, 1, tmp);
- client_write(buf, blocksize);
+TRACE;
+ client_write(buf, (int)blocksize);
+TRACE;
bytes_remaining = bytes_remaining - blocksize;
+TRACE;
}
+TRACE;
/* Don't close it ... cache it! */
/* fclose(tmp); */
+TRACE;
IMAP->cached_body = tmp;
IMAP->cached_bodymsgnum = msgnum;
strcpy(IMAP->cached_bodypart, section);
+TRACE;
if (msg != NULL) {
+TRACE;
CtdlFreeMessage(msg);
}
/* Mark this message as "seen" *unless* this is a "peek" operation */
+TRACE;
if (is_peek == 0) {
CtdlSetSeen(msgnum, 1, ctdlsetseen_seen);
}
+TRACE;
}
/*
void imap_fetch_bodystructure (long msgnum, char *item,
struct CtdlMessage *msg) {
FILE *tmp;
- char buf[1024];
+ char buf[SIZ];
long lines = 0L;
long start_of_body = 0L;
long body_bytes = 0L;
int i;
struct CtdlMessage *msg = NULL;
+ lprintf(CTDL_DEBUG, "imap_do_fetch_msg(%d, %d)\n", seq, num_items);
+ for (i=0; i<num_items; ++i) {
+ lprintf(CTDL_DEBUG, " %s\n", itemlist[i]);
+ }
+
cprintf("* %d FETCH (", seq);
for (i=0; i<num_items; ++i) {
* is not a generic search-and-replace function.
*/
void imap_macro_replace(char *str, char *find, char *replace) {
- char holdbuf[1024];
+ char holdbuf[SIZ];
if (!strncasecmp(str, find, strlen(find))) {
if (str[strlen(find)]==' ') {
int i;
int num_sets;
int s;
- char setstr[SIZ], lostr[SIZ], histr[SIZ]; /* was 1024 */
- int lo, hi;
+ char setstr[SIZ], lostr[SIZ], histr[SIZ];
+ long lo, hi;
char actual_range[SIZ];
/*
extract_token(lostr, setstr, 0, ':');
if (num_tokens(setstr, ':') >= 2) {
extract_token(histr, setstr, 1, ':');
- if (!strcmp(histr, "*")) snprintf(histr, sizeof histr, "%d", INT_MAX);
+ if (!strcmp(histr, "*")) snprintf(histr, sizeof histr, "%ld", LONG_MAX);
}
else {
strcpy(histr, lostr);
}
- lo = atoi(lostr);
- hi = atoi(histr);
+ lo = atol(lostr);
+ hi = atol(histr);
/* Loop through the array, flipping bits where appropriate */
for (i = 1; i <= IMAP->num_msgs; ++i) {
* This function is called by the main command loop.
*/
void imap_fetch(int num_parms, char *parms[]) {
- char items[SIZ]; /* was 1024 */
+ char items[SIZ];
char *itemlist[SIZ];
int num_items;
int i;
* This function is called by the main command loop.
*/
void imap_uidfetch(int num_parms, char *parms[]) {
- char items[SIZ]; /* was 1024 */
+ char items[SIZ];
char *itemlist[SIZ];
int num_items;
int i;
* This function is called by the main command loop.
*/
void imap_append(int num_parms, char *parms[]) {
- size_t literal_length;
- size_t bytes_transferred;
- size_t stripped_length = 0;
+ long literal_length;
+ long bytes_transferred;
+ long stripped_length = 0;
struct CtdlMessage *msg;
int ret = 0;
size_t blksize;
return;
}
- literal_length = (size_t) atol(&parms[num_parms-1][1]);
+ literal_length = atol(&parms[num_parms-1][1]);
if (literal_length < 1) {
cprintf("%s BAD Message length must be at least 1.\r\n",
parms[0]);
IMAP->transmitted_length = literal_length;
cprintf("+ Transmit message now.\r\n");
- lprintf(CTDL_DEBUG, "imap_append() expecting %d bytes\n",
+ lprintf(CTDL_DEBUG, "imap_append() expecting %ld bytes\n",
literal_length);
bytes_transferred = 0;
else {
bytes_transferred += blksize; /* keep going */
}
- lprintf(CTDL_DEBUG, "Received %d of %d bytes (%d%%)\n",
+ lprintf(CTDL_DEBUG, "Received %ld of %ld bytes (%ld%%)\n",
bytes_transferred,
literal_length,
((bytes_transferred * 100) / literal_length)
s->size = strlen(buf);
}
-static int string_overflow(struct string* s)
-{
- return (s->size == s->maxsize);
-}
-
-static int string_length(struct string* s)
-{
- return s->size;
-}
-
-static char* string_ptr(struct string* s)
-{
- return s->buffer;
-}
-
static char* string_end(struct string* s)
{
return s->buffer + s->size;
string_append_sn(s, buf, len);
}
-/* Append another string structure. */
-
-static void string_append(struct string* dest, struct string* src)
-{
- string_append_sn(dest, src->buffer, src->size);
-}
-
/* Reads a UTF8 character from a char*, advancing the pointer. */
int utf8_getc(char** ptr)
if (field_length == 0)
break;
field_header = *mptr++;
- ret->cm_fields[field_header] = malloc(field_length);
+ ret->cm_fields[field_header] = malloc(field_length + 1);
strcpy(ret->cm_fields[field_header], mptr);
while (*mptr++ != 0); /* advance to next field */
int do_proto, /* do Citadel protocol responses? */
int crlf /* Use CRLF newlines instead of LF? */
) {
- struct CtdlMessage *TheMessage;
- int retcode;
+ struct CtdlMessage *TheMessage = NULL;
+ int retcode = om_no_such_msg;
lprintf(CTDL_DEBUG, "CtdlOutputMsg() msgnum=%ld, mode=%d\n",
msg_num, mode);
- TheMessage = NULL;
-
if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {
if (do_proto) cprintf("%d Not logged in.\n",
ERROR + NOT_LOGGED_IN);
return(om_no_such_msg);
}
+ TRACE;
retcode = CtdlOutputPreLoadedMsg(
TheMessage, msg_num, mode,
headers_only, do_proto, crlf);
+ TRACE;
CtdlFreeMessage(TheMessage);
return(retcode);
* Get a message off disk. (returns om_* values found in msgbase.h)
*
*/
-int CtdlOutputPreLoadedMsg(struct CtdlMessage *TheMessage,
+int CtdlOutputPreLoadedMsg(
+ struct CtdlMessage *TheMessage,
long msg_num,
int mode, /* how would you like that message? */
int headers_only, /* eschew the message body? */
int crlf /* Use CRLF newlines instead of LF? */
) {
int i, k;
- char buf[1024];
+ char buf[SIZ];
cit_uint8_t ch;
char allkeys[SIZ];
char display_name[SIZ];
char datestamp[SIZ];
/* */
+ lprintf(CTDL_DEBUG, "CtdlOutputPreLoadedMsg(TheMessage=%s, %ld, %d, %d, %d, %d\n",
+ ((TheMessage == NULL) ? "NULL" : "not null"),
+ msg_num,
+ mode, headers_only, do_proto, crlf);
+
+ TRACE;
snprintf(mid, sizeof mid, "%ld", msg_num);
nl = (crlf ? "\r\n" : "\n");
+ TRACE;
if (!is_valid_message(TheMessage)) {
lprintf(CTDL_ERR,
"ERROR: invalid preloaded message for output\n");
}
/* Are we downloading a MIME component? */
+ TRACE;
if (mode == MT_DOWNLOAD) {
if (TheMessage->cm_format_type != FMT_RFC822) {
if (do_proto)
desired_section);
}
}
+ TRACE;
return((CC->download_fp != NULL) ? om_ok : om_mime_error);
}
+ TRACE;
/* now for the user-mode message reading loops */
if (do_proto) cprintf("%d Message %ld:\n", LISTING_FOLLOWS, msg_num);
/* begin header processing loop for Citadel message format */
+ TRACE;
if ((mode == MT_CITADEL) || (mode == MT_MIME)) {
strcpy(display_name, "<unknown>");
}
/* begin header processing loop for RFC822 transfer format */
+ TRACE;
strcpy(suser, "");
strcpy(luser, "");
strcpy(fuser, "");
strcpy(snode, NODENAME);
strcpy(lnode, HUMANNODE);
+ TRACE;
if (mode == MT_RFC822) {
- cprintf("X-UIDL: %ld%s", msg_num, nl);
for (i = 0; i < 256; ++i) {
+ TRACE;
if (TheMessage->cm_fields[i]) {
mptr = TheMessage->cm_fields[i];
+ TRACE;
if (i == 'A') {
- strcpy(luser, mptr);
- strcpy(suser, mptr);
- }
-/****
- "Path:" removed for now because it confuses brain-dead Microsoft shitware
- into thinking that mail messages are newsgroup messages instead. When we
- add NNTP support back into Citadel we'll have to add code to only output
- this field when appropriate.
- else if (i == 'P') {
- cprintf("Path: %s%s", mptr, nl);
+ safestrncpy(luser, mptr, sizeof luser);
+ safestrncpy(suser, mptr, sizeof suser);
}
- ****/
else if (i == 'U') {
cprintf("Subject: %s%s", mptr, nl);
subject_found = 1;
}
}
if (subject_found == 0) {
+ TRACE;
cprintf("Subject: (no subject)%s", nl);
}
}
+ TRACE;
for (i=0; i<strlen(suser); ++i) {
suser[i] = tolower(suser[i]);
if (!isalnum(suser[i])) suser[i]='_';
}
+ TRACE;
if (mode == MT_RFC822) {
if (!strcasecmp(snode, NODENAME)) {
- strcpy(snode, FQDN);
+ safestrncpy(snode, FQDN, sizeof snode);
}
+ TRACE;
/* Construct a fun message id */
cprintf("Message-ID: <%s", mid);
cprintf("@%s", snode);
}
cprintf(">%s", nl);
+ TRACE;
if (!is_room_aide() && (TheMessage->cm_anon_type == MES_ANONONLY)) {
cprintf("From: x@x.org (----)%s", nl);
}
cprintf("Organization: %s%s", lnode, nl);
+ TRACE;
/* Blank line signifying RFC822 end-of-headers */
if (TheMessage->cm_format_type != FMT_RFC822) {
/* end header processing loop ... at this point, we're in the text */
START_TEXT:
+ TRACE;
if (headers_only == HEADERS_FAST) goto DONE;
mptr = TheMessage->cm_fields['M'];
if ( (mode == MT_CITADEL) || (mode == MT_MIME) ) {
if (do_proto) cprintf("text\n");
}
+ TRACE;
/* If the format type on disk is 1 (fixed-format), then we want
* everything to be output completely literally ... regardless of
* what message transfer format is in use.
*/
+ TRACE;
if (TheMessage->cm_format_type == FMT_FIXED) {
if (mode == MT_MIME) {
cprintf("Content-type: text/plain\n\n");
* for new paragraphs is correct and the client will reformat the
* message to the reader's screen width.
*/
+ TRACE;
if (TheMessage->cm_format_type == FMT_CITADEL) {
if (mode == MT_MIME) {
cprintf("Content-type: text/x-citadel-variformat\n\n");
* this message is format 1 (fixed format), so the callback function
* we use will display those parts as-is.
*/
+ TRACE;
if (TheMessage->cm_format_type == FMT_RFC822) {
CtdlAllocUserData(SYM_MA_INFO, sizeof(struct ma_info));
memset(ma, 0, sizeof(struct ma_info));
DONE: /* now we're done */
if (do_proto) cprintf("000\n");
+ TRACE;
return(om_ok);
}
highest_msg = msglist[num_msgs - 1];
/* Write it back to disk. */
- cdb_store(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long),
- msglist, num_msgs * sizeof(long));
+ cdb_store(CDB_MSGLISTS, &CC->room.QRnumber, (int)sizeof(long),
+ msglist, (int)(num_msgs * sizeof(long)));
/* Free up the memory we used. */
free(msglist);
}
/* Write our little bundle of joy into the message base */
- if (cdb_store(CDB_MSGMAIN, &newmsgid, sizeof(long),
+ if (cdb_store(CDB_MSGMAIN, &newmsgid, (int)sizeof(long),
smr.ser, smr.len) < 0) {
lprintf(CTDL_ERR, "Can't store message\n");
retval = 0L;
if (is_bigmsg) {
cdb_store(CDB_BIGMSGS,
&newmsgid,
- sizeof(long),
+ (int)sizeof(long),
holdM,
(strlen(holdM) + 1)
);
}
num_msgs = sort_msglist(msglist, num_msgs);
- cdb_store(CDB_MSGLISTS, &qrbuf.QRnumber, sizeof(long),
- msglist, (num_msgs * sizeof(long)));
+ cdb_store(CDB_MSGLISTS, &qrbuf.QRnumber, (int)sizeof(long),
+ msglist, (int)(num_msgs * sizeof(long)));
qrbuf.QRhighest = msglist[num_msgs - 1];
}
smibuf->meta_msgnum, smibuf->meta_refcount);
cdb_store(CDB_MSGMAIN,
- &TheIndex, sizeof(long),
- smibuf, sizeof(struct MetaData));
+ &TheIndex, (int)sizeof(long),
+ smibuf, (int)sizeof(struct MetaData));
}
if (smi.meta_refcount == 0) {
lprintf(CTDL_DEBUG, "Deleting message <%ld>\n", msgnum);
delnum = msgnum;
- cdb_delete(CDB_MSGMAIN, &delnum, sizeof(long));
- cdb_delete(CDB_BIGMSGS, &delnum, sizeof(long));
+ cdb_delete(CDB_MSGMAIN, &delnum, (int)sizeof(long));
+ cdb_delete(CDB_BIGMSGS, &delnum, (int)sizeof(long));
/* We have to delete the metadata record too! */
delnum = (0L - msgnum);
- cdb_delete(CDB_MSGMAIN, &delnum, sizeof(long));
+ cdb_delete(CDB_MSGMAIN, &delnum, (int)sizeof(long));
}
}
cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
if (cdbfr != NULL) {
msglist = malloc(cdbfr->len);
- memcpy(msglist, cdbfr->ptr, cdbfr->len);
+ if (msglist == NULL) {
+ lprintf(CTDL_CRIT, "malloc() failed\n");
+ abort();
+ }
+ memcpy(msglist, cdbfr->ptr, (size_t)cdbfr->len);
num_msgs = cdbfr->len / sizeof(long);
cdb_free(cdbfr);
} else {
imap_rescan_msgids();
}
- lprintf(9, "Expunged %d messages.\n", num_expunged);
+ lprintf(CTDL_DEBUG, "Expunged %d messages.\n", num_expunged);
return (num_expunged);
}
char *parms[SIZ];
int num_parms;
- time(&CC->lastcmd);
+ CC->lastcmd = time(NULL);
memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
flush_output();
if (client_gets(cmdbuf) < 1) {
while (strlen(cmdbuf) < 5)
strcat(cmdbuf, " ");
-
/* strip off l/t whitespace and CRLF */
if (cmdbuf[strlen(cmdbuf) - 1] == '\n')
cmdbuf[strlen(cmdbuf) - 1] = 0;
return;
}
-
/* Ok, at this point we're in normal command mode. The first thing
* we do is print any incoming pages (yeah! we really do!)
*/
struct citimap {
int authstate;
char authseq[SIZ];
- int selected; /* set to 1 if in the SELECTED state */
- int readonly; /* mailbox is open read only */
- int num_msgs; /* Number of messages being mapped */
+ int selected; /* set to 1 if in the SELECTED state */
+ int readonly; /* mailbox is open read only */
+ int num_msgs; /* Number of messages being mapped */
long *msgids;
unsigned int *flags;
char *transmitted_message; /* for APPEND command... */
void lprintf(enum LogLevel loglevel, const char *format, ...) {
va_list arg_ptr;
char buf[SIZ];
-
+
va_start(arg_ptr, format);
vsnprintf(buf, sizeof(buf), format, arg_ptr);
va_end(arg_ptr);
}
-/* extract_token() - a smarter string tokenizer */
-void extract_token(char *dest, const char *source, unsigned long parmnum, char separator)
+/*
+ * extract_token() - a string tokenizer
+ */
+void extract_token(char *dest, const char *source, int parmnum, char separator)
{
char *d; /* dest */
const char *s; /* source */
}
-/* remove_token() - a tokenizer that kills, maims, and destroys fast */
-void remove_token(char *source, unsigned long parmnum, char separator)
+/*
+ * remove_token() - a tokenizer that kills, maims, and destroys
+ */
+void remove_token(char *source, int parmnum, char separator)
{
char *d, *s; /* dest, source */
int count = 0;
/*
* extract_int() - extract an int parm w/o supplying a buffer
*/
-int extract_int(const char *source, unsigned long parmnum)
+int extract_int(const char *source, int parmnum)
{
char buf[SIZ];
/*
* extract_long() - extract an long parm w/o supplying a buffer
*/
-long extract_long(const char *source, unsigned long parmnum)
+long extract_long(const char *source, int parmnum)
{
char buf[SIZ];
/*
* extract_unsigned_long() - extract an unsigned long parm
*/
-unsigned long extract_unsigned_long(const char *source, unsigned long parmnum)
+unsigned long extract_unsigned_long(const char *source, int parmnum)
{
char buf[SIZ];
strcpy(outbuf, "");
- for (a = 0; a < strlen(strbuf); ++a) {
+ for (a = 0; a < (int)strlen(strbuf); ++a) {
c = 0;
for (b = 0; b < strlen(ec); ++b) {
if (strbuf[a] == ec[b])
/* $Id$ */
char *safestrncpy(char *dest, const char *src, size_t n);
int num_tokens (const char *source, char tok);
-void extract_token(char *dest, const char *source, unsigned long parmnum, char separator);
-int extract_int (const char *source, unsigned long parmnum);
-long extract_long (const char *source, unsigned long parmnum);
-unsigned long extract_unsigned_long(const char *source, unsigned long parmnum);
+void extract_token(char *dest, const char *source, int parmnum, char separator);
+int extract_int (const char *source, int parmnum);
+long extract_long (const char *source, int parmnum);
+unsigned long extract_unsigned_long(const char *source, int parmnum);
void CtdlEncodeBase64(char *dest, const char *source, size_t sourcelen);
int CtdlDecodeBase64(char *dest, const char *source, size_t length);
void striplt(char *);
int haschar(const char *st, int ch);
-void remove_token(char *source, unsigned long parmnum, char separator);
+void remove_token(char *source, int parmnum, char separator);
void fmt_date(char *buf, size_t n, time_t thetime, int seconds);
int is_msg_in_mset(char *mset, long msgnum);
char *memreadline(char *start, char *buf, int maxlen);
#define strcasecmp(x,y) strncasecmp(x,y,INT_MAX);
#endif
-#define extract(dest,source,parmnum) extract_token(dest,source,parmnum,'|')
-#define num_parms(source) num_tokens(source, '|')
+#define extract(dest,source,parmnum) extract_token(dest,source,parmnum,(char)'|')
+#define num_parms(source) num_tokens(source,(char)'|')
void stripout(char *str, char leftboundary, char rightboundary);
void stripallbut(char *str, char leftboundary, char rightboundary);