return;
}
while (*listing && strlen(listing)) {
- extract_token(buf, listing, 0, '\n');
+ extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
- extract(floorlist[extract_int(buf, 0)], buf, 1);
+ extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', SIZ);
}
free(listing);
}
return 0;
}
do {
- block = fwrite(file + bytes_written, 1,
+ block = fwrite((char *)file + bytes_written, 1,
filelen - bytes_written, fp);
bytes_written += block;
} while (errno == EINTR && bytes_written < filelen);
*/
void roomdir(CtdlIPC *ipc)
{
- char flnm[SIZ];
+ char flnm[256];
char flsz[32];
- char comment[SIZ];
- char buf[SIZ];
+ char comment[256];
+ char buf[256];
+ char *listing = NULL; /* Returned directory listing */
+ int r;
- CtdlIPC_putline(ipc, "RDIR");
- CtdlIPC_getline(ipc, buf);
- if (buf[0] != '1') {
- pprintf("%s\n", &buf[4]);
+ r = CtdlIPCReadDirectory(ipc, &listing, buf);
+ if (r / 100 != 1) {
+ pprintf("%s\n", buf);
return;
}
- extract(comment, &buf[4], 0);
- extract(flnm, &buf[4], 1);
+ extract_token(comment, buf, 0, '|', sizeof comment);
+ extract_token(flnm, buf, 1, '|', sizeof flnm);
pprintf("\nDirectory of %s on %s\n", flnm, comment);
pprintf("-----------------------\n");
- while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
- extract(flnm, buf, 0);
- extract(flsz, buf, 1);
- extract(comment, buf, 2);
+ while (*listing && strlen(listing)) {
+ extract_token(buf, listing, 0, '\n', sizeof buf);
+ remove_token(listing, 0, '\n');
+
+ extract_token(flnm, buf, 0, '|', sizeof flnm);
+ extract_token(flsz, buf, 1, '|', sizeof flsz);
+ extract_token(comment, buf, 2, '|', sizeof comment);
if (strlen(flnm) <= 14)
pprintf("%-14s %8s %s\n", flnm, flsz, comment);
else
*/
void whoknows(CtdlIPC *ipc)
{
- char buf[SIZ];
+ char buf[256];
char *listing = NULL;
int r;
return;
}
while (strlen(listing) > 0) {
- extract_token(buf, listing, 0, '\n');
+ extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');
if (sigcaught == 0)
pprintf("%s\n", buf);
fp = fopen(temp, "w");
fclose(fp);
- CtdlIPC_putline(ipc, check_cmd);
- CtdlIPC_getline(ipc, cmd);
+ CtdlIPC_chat_send(ipc, check_cmd);
+ CtdlIPC_chat_recv(ipc, cmd);
if (cmd[0] != '2') {
scr_printf("%s\n", &cmd[4]);
return;
}
if (strlen(editor_paths[0]) > 0) {
- CtdlIPC_putline(ipc, read_cmd);
- CtdlIPC_getline(ipc, cmd);
+ CtdlIPC_chat_send(ipc, read_cmd);
+ CtdlIPC_chat_recv(ipc, cmd);
if (cmd[0] == '1') {
fp = fopen(temp, "w");
- while (CtdlIPC_getline(ipc, cmd), strcmp(cmd, "000")) {
+ while (CtdlIPC_chat_recv(ipc, cmd), strcmp(cmd, "000")) {
fprintf(fp, "%s\n", cmd);
}
fclose(fp);
}
else {
- CtdlIPC_putline(ipc, write_cmd);
- CtdlIPC_getline(ipc, cmd);
+ CtdlIPC_chat_send(ipc, write_cmd);
+ CtdlIPC_chat_recv(ipc, cmd);
if (cmd[0] != '4') {
scr_printf("%s\n", &cmd[4]);
return;
fp = fopen(temp, "r");
while (fgets(cmd, SIZ - 1, fp) != NULL) {
cmd[strlen(cmd) - 1] = 0;
- CtdlIPC_putline(ipc, cmd);
+ CtdlIPC_chat_send(ipc, cmd);
}
fclose(fp);
- CtdlIPC_putline(ipc, "000");
+ CtdlIPC_chat_send(ipc, "000");
}
unlink(temp);
}
newprompt("Name for new floor: ", newfloorname, 255);
- if (!*newprompt) return;
+ if (!*newfloorname) return;
r = CtdlIPCCreateFloor(ipc, 1, newfloorname, buf);
if (r / 100 == 2) {
scr_printf("Floor has been created.\n");