#include "tools.h"
#include "citserver.h"
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
+
+/*
+ * network_talking_to() -- concurrency checker
+ */
+int network_talking_to(char *nodename, int operation) {
+
+ static char *nttlist = NULL;
+ char *ptr = NULL;
+ int i;
+ char buf[SIZ];
+ int retval = 0;
+
+ begin_critical_section(S_NTTLIST);
+
+ switch(operation) {
+
+ case NTT_ADD:
+ if (nttlist == NULL) nttlist = strdoop("");
+ if (nttlist == NULL) break;
+ nttlist = (char *)reallok(nttlist,
+ (strlen(nttlist) + strlen(nodename) + 3) );
+ strcat(nttlist, "|");
+ strcat(nttlist, nodename);
+ break;
+
+ case NTT_REMOVE:
+ if (nttlist == NULL) break;
+ if (strlen(nttlist) == 0) break;
+ ptr = mallok(strlen(nttlist));
+ if (ptr == NULL) break;
+ strcpy(ptr, "");
+ for (i = 0; i < num_tokens(nttlist, '|'); ++i) {
+ extract(buf, nttlist, i);
+ if ( (strlen(buf) > 0)
+ && (strcasecmp(buf, nodename)) ) {
+ strcat(ptr, buf);
+ strcat(ptr, "|");
+ }
+ }
+ phree(nttlist);
+ nttlist = ptr;
+ break;
+
+ case NTT_CHECK:
+ if (nttlist == NULL) break;
+ if (strlen(nttlist) == 0) break;
+ for (i = 0; i < num_tokens(nttlist, '|'); ++i) {
+ extract(buf, nttlist, i);
+ if (!strcasecmp(buf, nodename)) ++retval;
+ }
+ break;
+ }
+
+ if (nttlist != NULL) lprintf(9, "nttlist=<%s>\n", nttlist);
+ end_critical_section(S_NTTLIST);
+ return(retval);
+}
+
+
+
/*
* Server command to delete a file from a room's directory
CC->quickroom.QRdirname, filename);
a = unlink(pathname);
if (a == 0) {
- cprintf("%d File '%s' deleted.\n", OK, pathname);
+ cprintf("%d File '%s' deleted.\n", CIT_OK, pathname);
}
else {
cprintf("%d File '%s' not found.\n",
"cat ./files/%s/filedir |grep %s >>./files/%s/filedir",
CC->quickroom.QRdirname, filename, qrbuf.QRdirname);
system(buf);
- cprintf("%d File '%s' has been moved.\n", OK, filename);
+ cprintf("%d File '%s' has been moved.\n", CIT_OK, filename);
}
}
snprintf(buf, sizeof buf, "sysop@%s", destsys);
e = alias(buf);
- if (e != MES_BINARY) {
+ if (e != MES_IGNET) {
cprintf("%d No such system: '%s'\n",
ERROR + NO_SUCH_SYSTEM, destsys);
return;
putc(0, ofp);
fclose(ofp);
- cprintf("%d File '%s' has been sent to %s.\n", OK, filename,
+ cprintf("%d File '%s' has been sent to %s.\n", CIT_OK, filename,
destsys);
- system("nohup ./netproc -i >/dev/null 2>&1 &");
+ /* FIXME start a network run here. */
return;
}
modtime = (time_t) statbuf.st_mtime;
cprintf("%d %ld|%ld|%s|%s\n",
- OK, filesize, modtime, filename, mime_type);
+ CIT_OK, filesize, (long)modtime, filename, mime_type);
}
snprintf(pathname, sizeof pathname,
"./images/floor.%d.gif", which_floor);
} else if (!strcasecmp(filename, "_roompic_")) {
- assoc_file_name(pathname, &CC->quickroom, "images");
+ assoc_file_name(pathname, sizeof pathname, &CC->quickroom, "images");
} else {
for (a = 0; a < strlen(filename); ++a) {
filename[a] = tolower(filename[a]);
ERROR, CC->upl_path, strerror(errno));
return;
}
- cprintf("%d Ok\n", OK);
+ cprintf("%d Ok\n", CIT_OK);
}
}
if ((!strcasecmp(basenm, "_roompic_")) && (is_room_aide())) {
- assoc_file_name(CC->upl_path, &CC->quickroom, "images");
+ assoc_file_name(CC->upl_path, sizeof CC->upl_path, &CC->quickroom, "images");
}
if (strlen(CC->upl_path) == 0) {
}
if (is_this_for_real == 0) {
- cprintf("%d Ok to send image\n", OK);
+ cprintf("%d Ok to send image\n", CIT_OK);
return;
}
ERROR, CC->upl_path, strerror(errno));
return;
}
- cprintf("%d Ok\n", OK);
+ cprintf("%d Ok\n", CIT_OK);
CC->upload_type = UPL_IMAGE;
}
unlink(buf);
}
- cprintf("%d Ok\n", OK);
+ cprintf("%d Ok\n", CIT_OK);
}
if ((!strcasecmp(cmd, "1")) && (CC->upload_type != UPL_FILE)) {
CC->upload_type = UPL_FILE;
- cprintf("%d Upload completed.\n", OK);
+ cprintf("%d Upload completed.\n", CIT_OK);
/* FIXME ... here we need to trigger a network run */
}
if (!strcasecmp(cmd, "1")) {
- cprintf("%d File '%s' saved.\n", OK, CC->upl_path);
+ cprintf("%d File '%s' saved.\n", CIT_OK, CC->upl_path);
fp = fopen(CC->upl_filedir, "a");
if (fp == NULL) {
fp = fopen(CC->upl_filedir, "w");
}
/* put together an upload notice */
- sprintf(upload_notice,
+ snprintf(upload_notice, sizeof upload_notice,
"NEW UPLOAD: '%s'\n %s\n",
CC->upl_file, CC->upl_comment);
quickie_message(CC->curr_user, NULL, CC->quickroom.QRname,
upload_notice);
} else {
abort_upl(CC);
- cprintf("%d File '%s' aborted.\n", OK, CC->upl_path);
+ cprintf("%d File '%s' aborted.\n", CIT_OK, CC->upl_path);
}
}
CC->dl_is_net = 1;
stat(pathname, &statbuf);
- cprintf("%d %ld\n", OK, statbuf.st_size);
+ cprintf("%d %ld\n", CIT_OK, (long)statbuf.st_size);
}
/*
}
CC->upload_type = UPL_NET;
- cprintf("%d Ok\n", OK);
+ cprintf("%d Ok\n", CIT_OK);
}