to access the old non-gdbm data store.
* housekeeping.c: rewrote check_ref_counts() to do a ForEachRoom()
traversal instead of a MAXROOMS loop.
* sysdep.c: set up a dummy CitContext record to be used during server
startup, during which time there is no real context.
+Tue Sep 29 13:20:14 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+ * Removed code from some of the utilities which was still attempting
+ to access the old non-gdbm data store.
+ * housekeeping.c: rewrote check_ref_counts() to do a ForEachRoom()
+ traversal instead of a MAXROOMS loop.
+ * sysdep.c: set up a dummy CitContext record to be used during server
+ startup, during which time there is no real context.
+
Mon Sep 28 23:51:51 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Implemented the function ForEachRoom() to handle all-rooms traversal
(this will work with both the old and new paradigms, because both
lprintf(7, "Checking floor reference counts\n");
check_ref_counts();
-
}
/*
/*
* Check (and fix) floor reference counts. This doesn't need to be done
* very often, since the counts should remain correct during normal operation.
+ * NOTE: this function pair should ONLY be called during startup. It is NOT
+ * thread safe.
*/
+void check_ref_counts_backend(struct quickroom *qrbuf) {
+ struct floor flbuf;
+
+ lgetfloor(&flbuf, qrbuf->QRfloor);
+ ++flbuf.f_ref_count;
+ flbuf.f_flags = flbuf.f_flags | QR_INUSE;
+ lputfloor(&flbuf, qrbuf->QRfloor);
+ }
+
void check_ref_counts(void) {
- int ref[MAXFLOORS];
- struct quickroom qrbuf;
struct floor flbuf;
int a;
- for (a=0; a<MAXFLOORS; ++a) ref[a] = 0;
-
- for (a=0; a<MAXROOMS; ++a) {
- getroom(&qrbuf, a);
- if (qrbuf.QRflags & QR_INUSE) {
- ++ref[(int)qrbuf.QRfloor];
- }
- }
-
for (a=0; a<MAXFLOORS; ++a) {
lgetfloor(&flbuf, a);
- flbuf.f_ref_count = ref[a];
- if (ref[a] > 0) flbuf.f_flags = flbuf.f_flags | QR_INUSE ;
+ flbuf.f_ref_count = 0;
+ flbuf.f_flags = flbuf.f_flags & ~QR_INUSE;
lputfloor(&flbuf, a);
}
+
+ ForEachRoom(check_ref_counts_backend);
}
*/
void cmd_msgs(char *cmdbuf)
{
- int a;
- int mode;
+ int a = 0;
+ int mode = 0;
char which[256];
- int cm_howmany;
- long cm_gt;
+ int cm_howmany = 0;
+ long cm_gt = 0L;
extract(which,cmdbuf,0);
/* FIX ... rewrite this to simply check for the existence of the twitroom,
* and create it if necessary. No slot-numbers will need to be loaded.
+ * (Actually, twitroom should be created during the same portion of startup
+ * that creates Lobby/Mail/Aide.)
*/
void loadtroom(void) {
struct quickroom qrbuf;
void get_config(void);
struct filterlist *filter = NULL;
-char roomnames[MAXROOMS][20];
-char roomdirs[MAXROOMS][15];
struct syslist *slist = NULL;
struct config config;
}
-/*
- * 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
/*
* 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);
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));
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");
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();
#define UNCOMPRESS "/usr/bin/gunzip"
-/* Citadel/UX rnews
- * version 2.8
+/* Citadel/UX rcit
+ * version 2.9
*
* This program functions the same as the standard rnews program for
* UseNet. It accepts standard input, and looks for rooms to post messages
void get_config(void);
struct config config;
-char roomlist[MAXROOMS][20];
-
-void load_roomlist(void) {
- FILE *fp;
- struct quickroom QRtemp;
- int a;
-
- for (a=0; a<MAXROOMS; ++a) strcpy(roomlist[a],TWITROOM);
- fp=fopen("quickroom","r");
- if (fp==NULL) return;
- for (a=0; a<MAXROOMS; ++a) {
- fread((char *)&QRtemp,sizeof(struct quickroom),1,fp);
- if (QRtemp.QRflags & QR_INUSE)
- strcpy(roomlist[a],QRtemp.QRname);
- }
- fclose(fp);
- }
-
-
-
-int rnewsxref(char *room, char *ngroup) /* xref table */
-
- {
+/*
+ * Cross-reference newsgroup names to Citadel room names
+ */
+int rnewsxref(char *room, char *ngroup) {
FILE *fp;
int a,b;
char aaa[50],bbb[50];
}
-void getroom(char *room, char *ngroup)
-{
- char ngbuf[256];
- char tryme[256];
- int a,b;
- struct quickroom qbuf;
-
- strcpy(ngbuf,ngroup);
- strcat(ngbuf,",");
- for (a=0; a<strlen(ngbuf); ++a) {
- if ((ngbuf[a]==',')||(ngbuf[a]==0)) {
- strcpy(tryme,ngbuf);
- tryme[a]=0;
- if (!rnewsxref(room,tryme)) return;
- room[sizeof(qbuf.QRname)-1]=0;
- for (b=0; b<MAXROOMS; ++b) {
- if (!strcasecmp(roomlist[b],room)) return;
- }
- strcpy(ngbuf,&ngbuf[a+1]);
- a=(-1);
- }
- }
- }
-
void main(int argc, char **argv)
{
char aaa[128],bbb[128],ccc[128];
}
/* process UseNet news input */
- load_roomlist();
A: if (fgets(aaa,128,minput)==NULL) goto END;
aaa[strlen(aaa)-1]=0;
if (strncmp(aaa,"#! rnews ",9)) goto A;
fprintf(mout,"T%ld",now); putc(0,mout);
fprintf(mout,"A%s",author); putc(0,mout);
strcpy(ccc,room);
- getroom(room,ccc);
+ rnewsxref(room,ccc);
fprintf(mout,"O%s",room); putc(0,mout);
fprintf(mout,"N%s",node); putc(0,mout);
if (orgname[0]!=0) {
int msock; /* master listening socket */
int verbosity = 3; /* Logging level */
+struct CitContext masterCC;
+
/*
* lprintf() ... Write logging information
* Return a pointer to a thread's own CitContext structure (new)
*/
struct CitContext *MyContext(void) {
- return (struct CitContext *) pthread_getspecific(MyConKey);
+ struct CitContext *retCC;
+ retCC = (struct CitContext *) pthread_getspecific(MyConKey);
+ if (retCC == NULL) retCC = &masterCC;
+ return(retCC);
}
lprintf(7, "Loading citadel.config\n");
get_config();
- /* Databases must be opened *after* config is loaded, otherwise we might
- * end up working in the wrong directory.
- */
- lprintf(7, "Opening databases\n");
- open_databases();
-
- lprintf(7, "Checking floor reference counts\n");
- check_ref_counts();
+ /* Do non system dependent startup functions */
+ master_startup();
/*
* Bind the server to our favourite port.