$Log$
+ Revision 629.8 2005/01/19 20:49:46 ajc
+ * Minor fixenbugs after running with Valgrind
+
Revision 629.7 2005/01/19 03:03:36 ajc
* Minor and/or cosmetic changes made during x64 troubleshooting
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
dbfilename,
NULL,
DB_BTREE,
- DB_CREATE|DB_THREAD
- |DB_AUTO_COMMIT
+ DB_CREATE|DB_AUTO_COMMIT|DB_THREAD
,
0600);
if (ret) {
* 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;
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);
}
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 = (long)sizeof(buf);
-TRACE;
while (bytes_remaining > 0L) {
-TRACE;
if (blocksize > bytes_remaining) blocksize = bytes_remaining;
-TRACE;
fread(buf, blocksize, 1, tmp);
-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;
}
/*
return(om_no_such_msg);
}
- TRACE;
retcode = CtdlOutputPreLoadedMsg(
TheMessage, msg_num, mode,
headers_only, do_proto, crlf);
- TRACE;
CtdlFreeMessage(TheMessage);
return(retcode);
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) {
for (i = 0; i < 256; ++i) {
- TRACE;
if (TheMessage->cm_fields[i]) {
mptr = TheMessage->cm_fields[i];
- TRACE;
if (i == 'A') {
safestrncpy(luser, mptr, sizeof luser);
}
}
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)) {
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);
}
* reply's copy will have the same address, but an updated
* status.)
*/
- TRACE;
icalcomponent_remove_property(event, e_attendee);
- TRACE;
icalproperty_free(e_attendee);
- TRACE;
icalcomponent_remove_property(reply, r_attendee);
- TRACE;
icalcomponent_add_property(event, r_attendee);
- TRACE;
/* Since we diddled both sets of attendees, we have to start
* the iteration over again. This will not create an infinite
*/
void load_working_ignetcfg(void) {
char *cfg;
+ char *oldcfg;
cfg = CtdlGetSysConfig(IGNETCFG);
if (cfg == NULL) {
cfg = strdup("");
}
- working_ignetcfg = realloc(working_ignetcfg, strlen(cfg) + 1 );
- strcpy(working_ignetcfg, cfg);
+ oldcfg = working_ignetcfg;
+ working_ignetcfg = cfg;
+ if (oldcfg != NULL) {
+ free(oldcfg);
+ }
}
"attempted|%ld\n"
"retry|%ld\n",
SPOOLMIME, instr, (long)time(NULL), (long)retry );
- free(instr);
CtdlSubmitMsg(msg, NULL, SMTP_SPOOLOUT_ROOM);
CtdlFreeMessage(msg);
}
+ free(instr);
}
if (syslog_facility >= 0) {
if (loglevel <= verbosity) {
/* Hackery -IO */
- if (CC && CC->cs_pid) {
+ if (CC->cs_pid != 0) {
memmove(&buf[6], buf, sizeof(buf) - 6);
snprintf(buf, 6, "[%3d]", CC->cs_pid);
buf[5] = ' ';
/* Promote to time_t; types differ on some OSes (like darwin) */
unixtime = tv.tv_sec;
localtime_r(&unixtime, &tim);
- /*
- * Log provides millisecond accuracy. If you need
- * microsecond accuracy and your OS supports it, change
- * %03ld to %06ld and remove " / 1000" after tv.tv_usec.
- */
- if (CC && CC->cs_pid) {
-#if 0
- /* Millisecond display */
- fprintf(stderr,
- "%04d/%02d/%02d %2d:%02d:%02d.%03ld [%3d] %s",
- tim.tm_year + 1900, tim.tm_mon + 1,
- tim.tm_mday, tim.tm_hour, tim.tm_min,
- tim.tm_sec, (long)tv.tv_usec / 1000,
- CC->cs_pid, buf);
-#endif
- /* Microsecond display */
+ if (CC->cs_pid != 0) {
fprintf(stderr,
"%04d/%02d/%02d %2d:%02d:%02d.%06ld [%3d] %s",
tim.tm_year + 1900, tim.tm_mon + 1,
tim.tm_sec, (long)tv.tv_usec,
CC->cs_pid, buf);
} else {
-#if 0
- /* Millisecond display */
- fprintf(stderr,
- "%04d/%02d/%02d %2d:%02d:%02d.%03ld %s",
- tim.tm_year + 1900, tim.tm_mon + 1,
- tim.tm_mday, tim.tm_hour, tim.tm_min,
- tim.tm_sec, (long)tv.tv_usec / 1000, buf);
-#endif
- /* Microsecond display */
fprintf(stderr,
"%04d/%02d/%02d %2d:%02d:%02d.%06ld %s",
tim.tm_year + 1900, tim.tm_mon + 1,
}
return (NULL);
}
+
+
+/*
+ * In our world, we want strcpy() to be able to work with overlapping strings.
+ */
+char *strcpy(char *dest, const char *src) {
+ memmove(dest, src, (strlen(src) + 1) );
+ return(dest);
+}