$Log$
+ Revision 601.28 2002/10/15 17:41:20 ajc
+ * Numerous warning fixes and cleanups for compile on Linux for IBM S/390
+ * Name temp files with source code location of who created them
+
Revision 601.27 2002/10/15 06:47:11 error
* IPC support for resumable downloads
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
"./network/spoolin/ap.%04x",
getpid());
- tempfp = tmpfile();
+ unlink(tempspool);
+
+ tempfp = fopen(tempspool, "w+b");
+ unlink(tempspool);
if (tempfp == NULL) {
perror("cannot open temp file");
exit(errno);
}
#endif
+#ifdef tmpnam
+#undef tmpnam
+#endif
+#define tmpnam(x) CtdlTempFileName(__FILE__, __LINE__)
+
+#ifdef tmpfile
+#undef tmpfile
+#endif
+#define tmpfile() CtdlTempFile()
+
#endif /* CITADEL_H */
/* ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, resume, progress_gauge_callback, cret); */
ret = CtdlIPCEndDownload(ipc, cret);
if (ret / 100 == 2)
- sprintf(cret, "%d|%ld|%s|%s", bytes, last_mod,
+ sprintf(cret, "%d|%ld|%s|%s", (int)bytes, last_mod,
filename, mimetype);
}
return ret;
ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret);
ret = CtdlIPCEndDownload(ipc, cret);
if (ret / 100 == 2)
- sprintf(cret, "%d|%ld|%s|%s", bytes, last_mod,
+ sprintf(cret, "%d|%ld|%s|%s", (int)bytes, last_mod,
filename, mimetype);
}
return ret;
ret = CtdlIPCReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret);
ret = CtdlIPCEndDownload(ipc, cret);
if (ret / 100 == 2)
- sprintf(cret, "%d|%ld|%s|%s", bytes, last_mod,
+ sprintf(cret, "%d|%ld|%s|%s", (int)bytes, last_mod,
filename, mimetype);
}
return ret;
if (offset < 0) return -1;
CtdlIPC_lock(ipc);
- sprintf(aaa, "READ %d|%d", offset, bytes);
+ sprintf(aaa, "READ %d|%d", (int)offset, (int)bytes);
CtdlIPC_putline(ipc, aaa);
CtdlIPC_getline(ipc, aaa);
if (aaa[0] != '6')
/* Send all requests at once */
for (i = 0; i < calls; i++) {
- sprintf(aaa, "READ %d|4096", i * 4096 + resume);
+ sprintf(aaa, "READ %d|4096", (int)(i * 4096 + resume) );
CtdlIPC_putline(ipc, aaa);
}
if (!to_write) {
if (feof(fd) || ferror(fd)) break;
}
- sprintf(aaa, "WRIT %d", to_write);
+ sprintf(aaa, "WRIT %d", (int)to_write);
CtdlIPC_putline(ipc, aaa);
CtdlIPC_getline(ipc, aaa);
strcpy(cret, &aaa[4]);
}
error_printf("SSL_read in serv_read:\n");
ERR_print_errors_fp(stderr);
- connection_died();
+ connection_died(NULL);
return;
}
len += rlen;
}
error_printf("SSL_write in serv_write:\n");
ERR_print_errors_fp(stderr);
- connection_died();
+ connection_died(NULL);
return;
}
bytes_written += retval;
extern int (*error_printf)(char *s, ...);
void setIPCDeathHook(void (*hook)(void));
void setIPCErrorPrintf(int (*func)(char *s, ...));
+void connection_died(CtdlIPC *ipc);
+int CtdlIPC_getsockfd(CtdlIPC* ipc);
+char CtdlIPC_get(CtdlIPC* ipc);
#ifdef __cplusplus
}
int main(int argc, char **argv) {
char buf[1024];
char fromline[1024];
+ char tempfilename[SIZ];
FILE *fp;
get_config();
- fp = tmpfile();
+ sprintf(tempfilename, "/tmp/citmail.%04x.%04x",
+ (int)time(NULL),
+ (int)getpid()
+ );
+ fp = fopen(tempfilename, "w+b");
+ unlink(tempfilename);
if (fp == NULL) return(errno);
snprintf(fromline, sizeof fromline, "From: someone@somewhere.org");
while (fgets(buf, 1024, stdin) != NULL) {
{
struct SessionFunctionHook *fcn;
+ TRACE;
for (fcn = SessionHookTable; fcn != NULL; fcn = fcn->next) {
+ TRACE;
if (fcn->eventtype == EventType) {
+ TRACE;
(*fcn->h_function_pointer) ();
}
+ TRACE;
}
+ TRACE;
}
void PerformLogHooks(int loglevel, char *logmsg)
fseek(CC->download_fp, start_pos, 0);
actual_bytes = fread(buf, 1, bytes, CC->download_fp);
- cprintf("%d %d\n", BINARY_FOLLOWS, actual_bytes);
+ cprintf("%d %d\n", BINARY_FOLLOWS, (int)actual_bytes);
client_write(buf, actual_bytes);
}
static int housekeeping_in_progress = 0;
static time_t last_timer = 0L;
int do_housekeeping_now = 0;
+ time_t now;
/*
* We do it this way instead of wrapping the whole loop in an
* potentially have multiple concurrent mutexes in progress.
*/
begin_critical_section(S_HOUSEKEEPING);
- if ( ((time(NULL) - last_timer) > 60L)
- && (housekeeping_in_progress == 0) ) {
- do_housekeeping_now = 1;
- housekeeping_in_progress = 1;
- last_timer = time(NULL);
+ now = time(NULL);
+ if ( (now - last_timer) > (time_t)60 ) {
+ if (housekeeping_in_progress == 0) {
+ do_housekeeping_now = 1;
+ housekeeping_in_progress = 1;
+ last_timer = time(NULL);
+ }
}
end_critical_section(S_HOUSEKEEPING);
- if (do_housekeeping_now == 0) return;
+
+ if (do_housekeeping_now == 0) {
+ return;
+ }
/*
* Ok, at this point we've made the decision to run the housekeeping
cprintf("Content-type: %s\n", cbtype);
cprintf("Content-length: %d\n",
- length + add_newline);
+ (int)(length + add_newline) );
cprintf("Content-transfer-encoding: %s\n", encoding);
cprintf("\n");
client_write(content, length);
#endif
#include "sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
}
+/*
+ * Citadelian replacement for tmpnam()
+ */
+char *CtdlTempFileName(char *prefix1, int prefix2) {
+ static int seq = 0;
+ static char buf[SIZ];
+
+ sprintf(buf, "/tmp/Citadel-%s-%d-%04x-%04x",
+ prefix1,
+ prefix2,
+ (int)getpid(),
+ ++seq
+ );
+
+ return(buf);
+}
+
+
+/*
+ * Citadelian replacement for tmpfile()
+ */
+FILE *CtdlTempFile(void) {
+ char filename[SIZ];
+ FILE *fp;
+
+ strcpy(filename, tmpnam(NULL));
+ fp = fopen(filename, "w+b");
+ unlink(filename);
+ return(fp);
+}
char *myfgets(char *s, int size, FILE *stream);
void urlesc(char *outbuf, char *strbuf);
+char *CtdlTempFileName(char *prefix1, int prefix2);
+FILE *CtdlTempFile(void);