]> code.citadel.org Git - citadel.git/commitdiff
* Worked a little more on the in-server replacement for netproc
authorArt Cancro <ajc@citadel.org>
Sat, 25 Aug 2001 05:04:57 +0000 (05:04 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 25 Aug 2001 05:04:57 +0000 (05:04 +0000)
citadel/ChangeLog
citadel/serv_network.c

index 3501b4d57b40dcb15d863147f953fe9b6447cd57..d65ee071bc89b3db6a2f66d677681e64d9739434 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 580.28  2001/08/25 05:04:57  ajc
+ * Worked a little more on the in-server replacement for netproc
+
  Revision 580.27  2001/08/22 04:18:17  ajc
  * Realized that there was lots of similarly broken code in
    process_rfc822_addr().  Wrote two new utility functions in tools.c
@@ -2695,4 +2698,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index 77326bd231ae2cacf931036e587e9f205da3622d..4900ee8c997b7aa650a485d0b3cbc040778b82a8 100644 (file)
@@ -18,7 +18,7 @@
 #include <pwd.h>
 #include <errno.h>
 #include <sys/types.h>
-
+#include <dirent.h>
 #if TIME_WITH_SYS_TIME
 # include <sys/time.h>
 # include <time.h>
@@ -405,7 +405,105 @@ void network_queue_room(struct quickroom *qrbuf, void *data) {
        ptr->next = rplist;
        rplist = ptr;
 }
+
+
+
+/*
+ * Process a buffer containing a single message from a single file
+ * from the inbound queue 
+ */
+void network_process_buffer(char *buffer, long size) {
+
+       /* FIXME ... do something with it! */
+
+}
+
+
+/*
+ * Process a single message from a single file from the inbound queue 
+ */
+void network_process_message(FILE *fp, long msgstart, long msgend) {
+       long hold_pos;
+       long size;
+       char *buffer;
+
+       hold_pos = ftell(fp);
+       size = msgend - msgstart + 1;
+       buffer = mallok(size);
+       if (buffer != NULL) {
+               fseek(fp, msgstart, SEEK_SET);
+               fread(buffer, size, 1, fp);
+               network_process_buffer(buffer, size);
+               phree(buffer);
+       }
+
+       fseek(fp, hold_pos, SEEK_SET);
+}
+
+
+/*
+ * Process a single file from the inbound queue 
+ */
+void network_process_file(char *filename) {
+       FILE *fp;
+       long msgstart = (-1L);
+       long msgend = (-1L);
+       long msgcur = 0L;
+       int ch;
+
+       lprintf(7, "network: processing <%s>\n", filename);
+
+       fp = fopen(filename, "rb");
+       if (fp == NULL) {
+               lprintf(5, "Error opening %s: %s\n",
+                       filename, strerror(errno));
+               return;
+       }
+
+       /* Look for messages in the data stream and break them out */
+       while (ch = getc(fp), ch >= 0) {
        
+               if (ch == 255) {
+                       if (msgstart >= 0L) {
+                               msgend = msgcur - 1;
+                               network_process_message(fp, msgstart, msgend);
+                       }
+                       msgstart = msgcur;
+               }
+
+               ++msgcur;
+       }
+
+       msgend = msgcur - 1;
+       if (msgstart >= 0L) {
+               network_process_message(fp, msgstart, msgend);
+       }
+
+       fclose(fp);
+       /* unlink(filename); FIXME put back in */
+}
+
+
+/*
+ * Process anything in the inbound queue
+ */
+void network_do_spoolin(void) {
+       DIR *dp;
+       struct dirent *d;
+       char filename[SIZ];
+
+       dp = opendir("./network/spoolin");
+       if (dp == NULL) return;
+
+       while (d = readdir(dp), d != NULL) {
+               sprintf(filename, "./network/spoolin/%s", d->d_name);
+               network_process_file(filename);
+       }
+
+
+       closedir(dp);
+}
+
 
 /*
  * network_do_queue()
@@ -447,6 +545,9 @@ void network_do_queue(void) {
                phree(ptr);
        }
 
+       lprintf(7, "network: processing inbound queue\n");
+       network_do_spoolin();
+
        lprintf(7, "network: queue run completed\n");
        doing_queue = 0;
 }