#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
+#include <ctype.h>
#include <string.h>
#include <sys/stat.h>
#include <limits.h>
#include "citadel.h"
#include "server.h"
-#include "dynloader.h"
+#include "serv_extensions.h"
#include "config.h"
#include "file_ops.h"
#include "sysdep_decls.h"
if (CtdlAccessCheck(ac_room_aide))
return;
- if ((CC->quickroom.QRflags & QR_DIRECTORY) == 0) {
+ if ((CC->room.QRflags & QR_DIRECTORY) == 0) {
cprintf("%d No directory in this room.\n",
ERROR + NOT_HERE);
return;
}
}
snprintf(pathname, sizeof pathname, "./files/%s/%s",
- CC->quickroom.QRdirname, filename);
+ CC->room.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",
char newroom[SIZ];
char buf[SIZ];
int a;
- struct quickroom qrbuf;
+ struct ctdlroom qrbuf;
extract(filename, cmdbuf, 0);
extract(newroom, cmdbuf, 1);
if (CtdlAccessCheck(ac_room_aide)) return;
- if ((CC->quickroom.QRflags & QR_DIRECTORY) == 0) {
+ if ((CC->room.QRflags & QR_DIRECTORY) == 0) {
cprintf("%d No directory in this room.\n",
ERROR + NOT_HERE);
return;
}
}
snprintf(pathname, sizeof pathname, "./files/%s/%s",
- CC->quickroom.QRdirname, filename);
+ CC->room.QRdirname, filename);
if (access(pathname, 0) != 0) {
cprintf("%d File '%s' not found.\n",
ERROR + FILE_NOT_FOUND, pathname);
/* this is a crude method of copying the file description */
snprintf(buf, sizeof buf,
"cat ./files/%s/filedir |grep %s >>./files/%s/filedir",
- CC->quickroom.QRdirname, filename, qrbuf.QRdirname);
+ CC->room.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);
}
if (CtdlAccessCheck(ac_room_aide)) return;
- if ((CC->quickroom.QRflags & QR_DIRECTORY) == 0) {
+ if ((CC->room.QRflags & QR_DIRECTORY) == 0) {
cprintf("%d No directory in this room.\n",
ERROR + NOT_HERE);
return;
}
}
snprintf(pathname, sizeof pathname, "./files/%s/%s",
- CC->quickroom.QRdirname, filename);
+ CC->room.QRdirname, filename);
if (access(pathname, 0) != 0) {
cprintf("%d File '%s' not found.\n",
ERROR + FILE_NOT_FOUND, pathname);
putc(255, ofp);
putc(MES_NORMAL, ofp);
putc(0, ofp);
- fprintf(ofp, "Pcit%ld", CC->usersupp.usernum);
+ fprintf(ofp, "Pcit%ld", CC->user.usernum);
putc(0, ofp);
time(&now);
fprintf(ofp, "T%ld", (long) now);
putc(0, ofp);
- fprintf(ofp, "A%s", CC->usersupp.fullname);
+ fprintf(ofp, "A%s", CC->user.fullname);
putc(0, ofp);
- fprintf(ofp, "O%s", CC->quickroom.QRname);
+ fprintf(ofp, "O%s", CC->room.QRname);
putc(0, ofp);
fprintf(ofp, "N%s", NODENAME);
putc(0, ofp);
snprintf(buf, sizeof buf,
"cd ./files/%s; uuencode %s <%s 2>/dev/null >>%s",
- CC->quickroom.QRdirname, filename, filename, outfile);
+ CC->room.QRdirname, filename, filename, outfile);
system(buf);
ofp = fopen(outfile, "a");
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);
/* FIXME start a network run here. */
return;
modtime = (time_t) statbuf.st_mtime;
cprintf("%d %ld|%ld|%s|%s\n",
- OK, filesize, (long)modtime, filename, mime_type);
+ CIT_OK, filesize, (long)modtime, filename, mime_type);
}
if (CtdlAccessCheck(ac_logged_in)) return;
- if ((CC->quickroom.QRflags & QR_DIRECTORY) == 0) {
+ if ((CC->room.QRflags & QR_DIRECTORY) == 0) {
cprintf("%d No directory in this room.\n",
ERROR + NOT_HERE);
return;
}
snprintf(pathname, sizeof pathname,
- "./files/%s/%s", CC->quickroom.QRdirname, filename);
+ "./files/%s/%s", CC->room.QRdirname, filename);
CC->download_fp = fopen(pathname, "r");
if (CC->download_fp == NULL) {
{
char filename[SIZ];
char pathname[SIZ];
- struct usersupp usbuf;
- char which_user[32];
+ struct ctdluser usbuf;
+ char which_user[USERNAME_SIZE];
int which_floor;
int a;
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->room, "images");
} else {
for (a = 0; a < strlen(filename); ++a) {
filename[a] = tolower(filename[a]);
if (CtdlAccessCheck(ac_logged_in)) return;
- if ((CC->quickroom.QRflags & QR_DIRECTORY) == 0) {
+ if ((CC->room.QRflags & QR_DIRECTORY) == 0) {
cprintf("%d No directory in this room.\n",
ERROR + NOT_HERE);
return;
}
}
snprintf(CC->upl_path, sizeof CC->upl_path, "./files/%s/%s",
- CC->quickroom.QRdirname, CC->upl_file);
+ CC->room.QRdirname, CC->upl_file);
snprintf(CC->upl_filedir, sizeof CC->upl_filedir,
- "./files/%s/filedir", CC->quickroom.QRdirname);
+ "./files/%s/filedir", CC->room.QRdirname);
CC->upload_fp = fopen(CC->upl_path, "r");
if (CC->upload_fp != NULL) {
ERROR, CC->upl_path, strerror(errno));
return;
}
- cprintf("%d Ok\n", OK);
+ cprintf("%d Ok\n", CIT_OK);
}
}
}
- if (CC->usersupp.axlevel >= 6) {
+ if (CC->user.axlevel >= 6) {
snprintf(CC->upl_path, sizeof CC->upl_path, "./images/%s",
basenm);
}
if (!strcasecmp(basenm, "_userpic_")) {
snprintf(CC->upl_path, sizeof CC->upl_path,
- "./userpics/%ld.gif", CC->usersupp.usernum);
+ "./userpics/%ld.gif", CC->user.usernum);
}
if ((!strcasecmp(basenm, "_floorpic_"))
- && (CC->usersupp.axlevel >= 6)) {
+ && (CC->user.axlevel >= 6)) {
which_floor = extract_int(cmdbuf, 2);
snprintf(CC->upl_path, sizeof CC->upl_path,
"./images/floor.%d.gif", which_floor);
}
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->room, "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);
+ quickie_message(CC->curr_user, NULL, CC->room.QRname,
+ upload_notice, 0, NULL);
} 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);
}
}
void cmd_read(char *cmdbuf)
{
long start_pos;
- int bytes;
+ size_t bytes;
+ size_t actual_bytes;
char buf[4096];
start_pos = extract_long(cmdbuf, 0);
return;
}
- if (bytes > 4096) {
- cprintf("%d You may not read more than 4096 bytes.\n",
- ERROR);
- return;
- }
+ if (bytes > 4096) bytes = 4096;
fseek(CC->download_fp, start_pos, 0);
- fread(buf, bytes, 1, CC->download_fp);
- cprintf("%d %d\n", BINARY_FOLLOWS, bytes);
- client_write(buf, bytes);
+ actual_bytes = fread(buf, 1, bytes, CC->download_fp);
+ cprintf("%d %d\n", BINARY_FOLLOWS, (int)actual_bytes);
+ client_write(buf, actual_bytes);
}
CC->dl_is_net = 1;
stat(pathname, &statbuf);
- cprintf("%d %ld\n", OK, (long)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);
}