]> code.citadel.org Git - citadel.git/blobdiff - citadel/netproc.c
Changeover to new room structure. See ChangeLog for details.
[citadel.git] / citadel / netproc.c
index f999e1c958f63320ee0727ab9ad066e48444b3de..a665961e5ab32818758b3e2ea4fbd0bd49961e5b 100644 (file)
 struct msglist {
        struct msglist *next;
        long m_num;
-       char m_rmname[20];
+       char m_rmname[ROOMNAMELEN];
        };
 
 struct rmlist {
        struct rmlist *next;
-       char rm_name[20];
+       char rm_name[ROOMNAMELEN];
        long rm_lastsent;
        };
 
@@ -103,8 +103,6 @@ void serv_write(char *buf, int nbytes);
 void get_config(void);
 
 struct filterlist *filter = NULL;
-char roomnames[MAXROOMS][20];
-char roomdirs[MAXROOMS][15];
 struct syslist *slist = NULL;
 
 struct config config;
@@ -112,7 +110,7 @@ extern char bbs_home_directory[];
 extern int home_specified;
 
 
-#ifdef NO_STRERROR
+#ifndef HAVE_STRERROR
 /*
  * replacement strerror() for systems that don't have it
  */
@@ -133,30 +131,6 @@ void strip_trailing_whitespace(char *buf)
        }
 
 
-/*
- * for performance optimization, netproc loads the list of room names (and
- * their corresponding directory names, if applicable) into a table in memory.
- */
-int load_roomnames(void) {
-       FILE *fp;
-       struct quickroom qbuf;
-       int i;
-
-       fp=fopen("./quickroom","rb");
-       if (fp==NULL) return(1);
-       for (i=0; i<MAXROOMS; ++i) {
-               if (fread((char *)&qbuf,sizeof(struct quickroom),1,fp)!=1)
-                       return(1);
-               strcpy(roomnames[i],qbuf.QRname);
-               if (qbuf.QRflags & QR_DIRECTORY)
-                       strcpy(roomdirs[i],qbuf.QRdirname);
-               else
-                       strcpy(roomdirs[i],config.c_bucket_dir);
-               }
-       fclose(fp);
-       return(0);
-       }
-
 /*
  * we also load the network/mail.sysinfo table into memory, make changes
  * as we learn more about the network from incoming messages, and write
@@ -337,29 +311,14 @@ struct syslist *get_sys_ptr(char *sysname)
  */
 int set_lockfile(void) {
        FILE *lfp;
-       int ok = 1;
        int onppid;
-       char buf[64];
 
-       if (access(LOCKFILE,0)==0) {
-
-       /* 
-        * if the /proc filesystem is available, we can further check to
-        * make sure that the process that wrote the lock file is actually
-        * running, and didn't simply terminate and not clean up after itself
-        */
-#ifdef HAVE_PROC_FS
-               lfp = fopen(LOCKFILE,"r");
-               fscanf(lfp,"%d",&onppid);
-               fclose(lfp);
-               sprintf(buf,"/proc/%d/cmdline",onppid);
-               if (access(buf,0)==0) ok = 0;
-#else
-               ok = 0;
-#endif
+       if ((lfp = fopen(LOCKFILE,"r")) != NULL) {
+                fscanf(lfp,"%d",&onppid);
+                fclose(lfp);
+               if (!kill(onppid, 0) || errno == EPERM) return 1;
                }
 
-       if (ok == 0) return(1);
        lfp=fopen(LOCKFILE,"w");
        fprintf(lfp,"%d\n",getpid());
        fclose(lfp);
@@ -595,16 +554,18 @@ void ship_to(char *filenm, char *sysnm)   /* send spool file filenm to system sysn
 
 /*
  * proc_file_transfer()  -  handle a simple file transfer packet
+ *
+ * FIX  This shouldn't be like this.  What it needs to do is begin an upload
+ * and transmit the file to the server.
  */
 void proc_file_transfer(char *tname)
 {      /* name of temp file containing the whole message */
        char buf[128];
-       char dest_dir[32];
+       char dest_room[32];
        FILE *tfp,*uud;
-       int a,b;
+       int a;
 
        printf("netproc: processing network file transfer...\n");
-       strcpy(dest_dir,config.c_bucket_dir);
 
        tfp=fopen(tname,"rb");
        if (tfp==NULL) printf("netproc: cannot open %s\n",tname);
@@ -613,9 +574,8 @@ void proc_file_transfer(char *tname)
                a=getc(tfp);
                if (a!='M') {
                        fpgetfield(tfp,buf);
-                       if (a=='O') for (b=0; b<MAXROOMS; ++b) {
-                               if (!strcasecmp(buf,roomnames[b]))
-                                       strcpy(dest_dir,roomdirs[b]);
+                       if (a=='O') {
+                               strcpy(dest_room, buf);
                                }
                        }
                } while ((a!='M')&&(a>=0));
@@ -625,7 +585,7 @@ void proc_file_transfer(char *tname)
                return;
                }
 
-       sprintf(buf,"cd %s/files/%s; exec %s",bbs_home_directory,dest_dir,UUDECODE);
+       sprintf(buf,"cd %s/files/%s; exec %s",bbs_home_directory,config.c_bucket_dir,UUDECODE);
        uud=(FILE *)popen(buf,"w");
        if (uud==NULL) {
                printf("netproc: cannot open uudecode pipe\n");
@@ -1245,7 +1205,7 @@ void np_attach_to_server(void) {
 /*
  * main
  */
-void main(int argc, char **argv)
+int main(int argc, char **argv)
 {
        char allst[32];
        FILE *allfp;
@@ -1290,7 +1250,6 @@ void main(int argc, char **argv)
        np_attach_to_server();
        fflush(stdout);
 
-       if (load_roomnames()!=0) fprintf(stdout,"netproc: cannot load rooms\n");
        if (load_syslist()!=0) fprintf(stdout,"netproc: cannot load sysinfo\n");
        setup_special_nodes();
 
@@ -1309,5 +1268,6 @@ void main(int argc, char **argv)
        rewrite_syslist();
        printf("netproc: processing ended.\n");
        cleanup(0);
+       return 0;
        }