static int delete_lines(int nrows, char *rows) { char input[4]; int first, last; DDPut(sd[ledelstr]); input[0] = 0; if (!(Prompt(input, 3, PROMPT_NOCRLF))) return -1; if ((first = str2uint(input, 1, nrows)) == -1) return nrows; DDPut(sd[ledeltostr]); input[0] = 0; if (!(Prompt(input, 3, 0))) return -1; if ((last = str2uint(input, 1, nrows)) == -1) return nrows; if (last < first) { int tmp; tmp = last; last = first; first = tmp; } memmove(rows + (first - 1) * 80, rows + last * 80, (nrows - last) * 80); return nrows - (last - first + 1); }
int autodisconnect(void) { int count; char autodb[80]; int i; DDPut(sd[dlautodcstr]); for (count = 9; count; count--) { sleep(1); i = HotKey(HOT_QUICK); if (i == 3) { DDPut("\n\n"); return 0; } if (!checkcarrier()) return 0; ddprintf("%2.2d", count); } DDPut("\n\n"); snprintf(autodb, sizeof autodb, "Connection closed by automatic disconnection at %s\n", currt()); writelog(autodb); dropcarrier(); return 1; }
static int visit_bbs(int m) { time_t aika; char *aikas; char puskur[300]; lrp = lsp = oldlrp = oldlsp = 0; lrpdatname[0] = 0; ffilestagged = filestagged = bytestagged = fbytestagged = 0; *reason = 0; memset(&clog, 0, sizeof(struct callerslog)); memset(&user, 0, sizeof(struct userbase)); onlinestat = 0; display = 0; clearlist(olms); clearlist(flaggedfiles); carrier = 1; aika = time(0); aikas = ctime(&aika); aikas[24] = 0; snprintf(puskur, sizeof puskur, "===============================================[ %s ]===\n%d BPS connection on line #%d\n\n", aikas, bpsrate, node); writelog(puskur); changenodestatus("Logging in..."); ddprintf("[0m[2J[HDayDream BBS/UNiX %s\nProgramming by Antti Häyrynen 1996, 1997,\n DayDream Development Team 1998, 1999, 2000, 2001, 2002, 2003, 2004,\n Bo Simonsen 2008, 2009, 2010\nCurrently maintained by Ryan Fantus\nYou are connected to node #%d at %d BPS.\n\n", versionstring, node, bpsrate); rundoorbatch("data/frontends.dat", NULL); if (!display) if (getdisplaymode(0, 0) < 1) { DDPut("Failed to load displaymode... disconnecting!\n\n"); return 0; } if (!syspw()) { DDPut(sd[disconnectingstr]); return 0; } TypeFile("banner", TYPE_MAKE | TYPE_WARN); if (m) { switch (checklogon("sysop")) { case 1: sleep(2); getin(); break; } return 1; } login_loop(); DDPut(sd[disconnectingstr]); dropcarrier(); return 1; }
void killflood(void) { DDPut(sd[dlkillfloodstr]); delayt = 3; for (;;) { int i; if (!checkcarrier()) break; i = HotKey(HOT_DELAY); if (!checkcarrier()) break; if (i == 0 || i == 255 || i == 'y' || i == 'Y') break; } DDPut("\n"); }
void saveuserbase(const struct userbase *usr) { /* maybe this is the wisest thing to do */ if (writeubent(usr)) { syslog(LOG_ALERT, "cannot save userbase: %m"); DDPut("Cannot save userbase.\n"); exit(1); } }
static void login_loop(void) { int attempts; for (attempts = 0; attempts < 10; attempts++) { if (!try_login()) return; if (!checkcarrier()) return; } DDPut(sd[maxattemptsstr]); }
void who(void) { struct DayDream_Multinode *cn; cn = nodes; changenodestatus("Viewing who's online"); TypeFile("who", TYPE_MAKE | TYPE_WARN); DDPut(sd[whheadstr]); while (cn->MULTI_NODE) { if (cn->MULTI_NODE == 253) { int j; int i = maincfg.CFG_TELNET1ST; j = maincfg.CFG_TELNETMAX; while (j) { j--; who_show(cn, i); i++; } } else if (cn->MULTI_NODE == 254) { int j; int i = maincfg.CFG_LOCAL1ST; j = maincfg.CFG_LOCALMAX; while (j) { j--; who_show(cn, i); i++; } } else if (cn->MULTI_NODE != 252) { who_show(cn, cn->MULTI_NODE); } cn++; } DDPut(sd[whtailstr]); }
int fileattach(void) { char olddir[1024]; char fabuf[1024]; FILE *falist; int cnt = 0; struct dirent *dent; DIR *dh; if (cleantemp() == -1) { DDPut(sd[tempcleanerrstr]); return 0; } recfiles(currnode->MULTI_TEMPORARY, 0); snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); /* FIXME: check falist == NULL */ falist = fopen(fabuf, "w"); if ((dh = opendir(currnode->MULTI_TEMPORARY))) { getcwd(olddir, 1024); chdir(currnode->MULTI_TEMPORARY); while ((dent = readdir(dh))) { if (dent->d_name[0] == '.' && (dent->d_name[1] == '\0' || (dent->d_name[1] == '.' && dent->d_name[2] == '\0'))) continue; if (!strcmp(".packtmp", dent->d_name)) continue; deldir(".packtmp"); ddprintf(sd[afqstr], dent->d_name); if (HotKey(HOT_YESNO) == 1) { fprintf(falist, "%s\n", dent->d_name); cnt++; } else { unlink(dent->d_name); } if (!checkcarrier()) break; } chdir(olddir); closedir(dh); } fclose(falist); if (!cnt) { snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); unlink(fabuf); } return 1; }
static int create_new_account(void) { DDPut(sd[newucstr]); switch (HotKey(HOT_NOYES)) { case 1: if (CreateNewAccount()) { clog.cl_userid = user.user_account_id; clog.cl_firstcall = user.user_firstcall; clog.cl_logon = time(0); if (user.user_connections == 0) clog.cl_flags |= CL_NEWUSER; clog.cl_bpsrate = bpsrate; getin(); return 1; } return 0; case 2: DDPut("\n"); return 0; default: return 1; } }
int setmsgptrs(void) { int msgfd; struct DayDream_MsgPointers ptrs; ptrs.msp_high = highest; ptrs.msp_low = lowest; if(ddmsg_setptrs(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, &ptrs) < 0) { DDPut(sd[setptrserrstr]); return 0; } return 1; }
void edituser(void) { char askbuf[20]; changenodestatus("Editing personal data"); TypeFile("edituser", TYPE_MAKE | TYPE_WARN); for (;;) { DDPut(sd[eupromptstr]); askbuf[0] = 0; if (!(Prompt(askbuf, 3, 0))) return; if (handle_choice(askbuf)) return; } }
static int syspw(void) { char b[80]; int i; if (*maincfg.CFG_SYSTEMPW) { TypeFile("systempassword", TYPE_MAKE); for (i = 2; i; i--) { *b = 0; DDPut(sd[syspwstr]); if (!(Prompt(b, 16, PROMPT_SECRET))) return 0; if (!strcasecmp(b, maincfg.CFG_SYSTEMPW)) return 1; } return 0; } return 1; }
int edfile(char *lineedmem, size_t memsize, int reply, struct DayDream_Message *header) { int edtype = 0; int hola; edtype = 0; if (user.user_toggles & (1L << 11)) { DDPut(sd[emfsedstr]); hola = HotKey(HOT_YESNO); if (hola == 0) return 0; if (hola == 1) edtype = 1; } else if (user.user_toggles & (1L << 0)) { edtype = 1; } memset(lineedmem, 0, memsize); if (edtype) return fsed(lineedmem, memsize, reply, header); else return lineed(lineedmem, memsize, reply, header); }
/* FIXME: rethink */ int lineed(char *buffer, size_t bufsize, int mode, struct DayDream_Message *msg) { int i, j; char lbuf[300]; char *s; int row; *wrapbuf = 0; row = 1; DDPut(sd[leheadstr]); if (mode) row = quote(buffer, bufsize); for (;;) { snprintf(lbuf, sizeof lbuf, "%c", maincfg.CFG_LINEEDCHAR); while (row != 495) { ddprintf(sd[lelinestr], row); s = buffer + (row - 1) * 80; *s = 0; if (!(Prompt(s, 75, PROMPT_WRAP))) return 0; if (!*s || !strcasecmp(lbuf, s)) break; row++; } for (;;) { DDPut(sd[lepromptstr]); lbuf[0] = 0; if (!(Prompt(lbuf, 3, 0))) return 0; if (!strcasecmp(lbuf, "a")) { DDPut(sd[lesureabortstr]); i = HotKey(HOT_NOYES); if (!i || i == 1) return 0; } else if (!strcasecmp(lbuf, "c")) { TypeFile("lineedcommands", TYPE_WARN | TYPE_MAKE); } else if (!strcasecmp(lbuf, "d")) { if ((row = delete_lines(row, buffer)) == -1) return 0; } else if (!strcasecmp(lbuf, "e")) { DDPut(sd[leedlinstr]); lbuf[0] = 0; if (!(Prompt(lbuf, 3, 0))) return 0; i = atoi(lbuf); if (!(i < 1 || i > (row - 1))) { ddprintf(sd[leedpstr], i); s = buffer + (i - 1) * 80; if (!(Prompt(s, 75, 0))) return 0; } } else if (!strcasecmp(lbuf, "r")) { break; } else if (!strcasecmp(lbuf, "f")) { if (msg && *msg->MSG_ATTACH) { fileattach(); } else { DDPut(sd[noattachstr]); } } else if ((!strcasecmp(lbuf, "i")) && row < 495) { DDPut(sd[insertstr]); lbuf[0] = 0; if (!(Prompt(lbuf, 3, 0))) return 0; DDPut("\nInsert does not work yet, sorry...\n\n"); } else if (!strcasecmp(lbuf, "l")) { int lcount = user.user_screenlength; i = row - 1; j = 1; while (i) { s = buffer + (j - 1) * 80; ddprintf(sd[lellinestr], j, s); lcount--; if (lcount == 0) { int hot; DDPut(sd[morepromptstr]); hot = HotKey(0); DDPut("\r \r"); if (hot == 'N' || hot == 'n') break; if (hot == 'C' || hot == 'c') { lcount = -1; } else { lcount = user.user_screenlength; } } j++; i--; } } else if (!strcasecmp(lbuf, "s")) { return row - 1; } else if (!strcasecmp(lbuf, "q")) { if (!mode) { DDPut(sd[lereperrorstr]); } row = quote(s, strlen(s)); } } } }
int changemsgbase(int newb, int flags) { char cbuffer[500]; int basen; int i; struct DayDream_LRP lrpd; int lrpfd; struct stat st; msgbase_t *cb; if (!conference()->conf.CONF_MSGBASES) { current_msgbase = NULL; return 0; } basen = newb; if (basen > conference()->conf.CONF_MSGBASES) basen = 0; /* The MC_QUICK flag is used on non-interactive occasions. */ if (!basen && (flags & MC_QUICK)) return 0; if (!basen) { if (conference()->conf.CONF_MSGBASES == 1) { DDPut(sd[cmbonlymsgsstr]); return 0; } TypeFile("messagebases", TYPE_WARN | TYPE_CONF | TYPE_MAKE); } while (!basen) { DDPut(sd[cmbselectstr]); cbuffer[0] = 0; if (!(Prompt(cbuffer, 3, 0))) return 0; if (!strcasecmp(cbuffer, "?") || (!strcasecmp(cbuffer, "l"))) { TypeFile("messagebases", TYPE_WARN | TYPE_CONF | TYPE_MAKE); } else if (cbuffer[0] == 0) { return 0; } else basen = atoi(cbuffer); } for (i = 0; i < conference()->conf.CONF_MSGBASES; i++) { cb = conference()->msgbases[i]; if (cb->MSGBASE_NUMBER != basen) continue; current_msgbase = cb; getmsgptrs(); if (lrpdatname[0] && (oldlrp != lrp || oldlsp != lsp)) { lrpfd = open(lrpdatname, O_WRONLY | O_CREAT, 0666); if (lrpfd == -1) { DDPut(sd[cmberrlrpstr]); return 0; } fsetperm(lrpfd, 0666); fstat(lrpfd, &st); lrpd.lrp_read = lrp; lrpd.lrp_scan = lsp; lseek(lrpfd, sizeof(struct DayDream_LRP) * user.user_account_id, SEEK_SET); safe_write(lrpfd, &lrpd, sizeof(struct DayDream_LRP)); close(lrpfd); } snprintf(lrpdatname, sizeof lrpdatname, "%s/messages/base%3.3d/msgbase.lrp", conference()->conf.CONF_PATH, cb->MSGBASE_NUMBER); lrpfd = open(lrpdatname, O_RDONLY); lrp = 0; lsp = 0; oldlrp = 0; oldlsp = 0; if (lrpfd != -1) { if ((lseek(lrpfd, sizeof(struct DayDream_LRP) * user.user_account_id, SEEK_SET)) != -1) { if (read(lrpfd, &lrpd, sizeof(struct DayDream_LRP))) { oldlrp = lrp = lrpd.lrp_read; oldlsp = lsp = lrpd.lrp_scan; } } close(lrpfd); } current_msgbase = cb; getmsgptrs(); if ((flags & MC_NOSTAT) == 0) { ddprintf(sd[cmbstat1str], current_msgbase->MSGBASE_NAME, highest - lowest); ddprintf(sd[cmbstat2str], lrp, lsp); ddprintf(sd[cmbstat3str], lowest, highest); } return 1; } DDPut(sd[cmbunkbasestr]); return 0; }
int joinconf(int confn, int flags) { int newconfnum; conference_t *mc; struct iterator *iterator; char jbuffer[100]; newconfnum = confn; changenodestatus("Changing conference"); if ((flags & JC_LIST) && newconfnum == -1) TypeFile("joinconference", TYPE_WARN | TYPE_MAKE); while (newconfnum == -1) { jbuffer[0] = 0; DDPut(sd[jcpromptstr]); if (!(Prompt(jbuffer, 3, 0))) return 0; if ((!strcasecmp(jbuffer, "l")) || jbuffer[0] == '?') TypeFile("joinconference", TYPE_WARN | TYPE_MAKE); else if (jbuffer[0] == 0) return 0; else { char *endptr; newconfnum = strtol(jbuffer, &endptr, 10); if (*jbuffer && !*endptr) break; } newconfnum = -1; } iterator = conference_iterator(); while ((mc = (conference_t *) iterator_next(iterator))) { if (mc->conf.CONF_NUMBER != newconfnum) continue; if (!checkconfaccess(newconfnum, &user)) { if (!(flags & JC_SHUTUP)) { DDPut(sd[jcnoaccessstr]); } iterator_discard(iterator); return 0; } if (*mc->conf.CONF_PASSWD && !(flags & JC_SHUTUP) && !(flags & JC_QUICK)) { conference_t *oldconf = conference(); set_conference(mc); TypeFile("conferencepw", TYPE_CONF | TYPE_MAKE); set_conference(oldconf); DDPut("[36mConference password: [0m"); *jbuffer = 0; if (!(Prompt(jbuffer, 16, PROMPT_SECRET))) { iterator_discard(iterator); return 0; } if (strcasecmp(jbuffer, mc->conf.CONF_PASSWD)) { iterator_discard(iterator); return 0; } } if (!(flags & JC_NOUPDATE)) user.user_joinconference = newconfnum; set_conference(mc); if (conference()->conf.CONF_MSGBASES) current_msgbase = conference()->msgbases[0]; else current_msgbase = NULL; if (!(flags & JC_QUICK)) { TypeFile("conferencejoined", TYPE_MAKE | TYPE_CONF); } if (current_msgbase) { if (flags & JC_QUICK) { changemsgbase(current_msgbase->MSGBASE_NUMBER, MC_QUICK | MC_NOSTAT); } else { changemsgbase(current_msgbase->MSGBASE_NUMBER, MC_QUICK); } } iterator_discard(iterator); return 1; } iterator_discard(iterator); if (!(flags & JC_SHUTUP)) { DDPut(sd[jcnoconfstr]); } return 0; }
int entermsg(struct DayDream_Message *msg, int reply, char *params) { char ebuf[1024]; int hola; int msgfd; char *s; struct DayDream_Message header; char *lineedmem; int recoff; if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E' && ((access1 & (1L << SECB_FIDOMESSAGE)) == 0)) { DDPut(sd[emnofidomsgstr]); return 0; } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N' && ((access2 & (1L << SECB_SENDNETMAIL)) == 0)) { DDPut(sd[emnonetmsgstr]); return 0; } changenodestatus("Entering a message"); if (msg) { memcpy(&header, msg, sizeof(struct DayDream_Message)); } else { s = (char *) &header; memset(&header, 0, sizeof(struct DayDream_Message)); if (params) strncpy(header.MSG_RECEIVER, params, 25); } if (current_msgbase->MSGBASE_FLAGS & (1L << 0) && current_msgbase->MSGBASE_FLAGS & (1L << 1)) { DDPut(sd[emnomsgsstr]); return 0; } DDPut(sd[emhead1str]); DDPut(current_msgbase->MSGBASE_NAME); ebuf[0] = 0; strlcat(ebuf, sd[emhead2str], sizeof ebuf); hola = 61 - strlen(current_msgbase->MSGBASE_NAME); while (hola) { strlcat(ebuf, "-", sizeof ebuf); hola--; } DDPut(ebuf); ddprintf(sd[emhead3str], highest); DDPut(sd[emhead4str]); if ((current_msgbase->MSGBASE_FLAGS & (1L << 0)) || (header.MSG_FLAGS & (1L << 0))) { DDPut(sd[emprvstr]); header.MSG_FLAGS |= (1L << 0); } else { DDPut(sd[empubstr]); } header.MSG_CREATION = time(0); DDPut(sd[emhead5str]); DDPut(ctime(&header.MSG_CREATION)); DDPut(sd[emhead6str]); if (current_msgbase->MSGBASE_FLAGS & (1L << 2)) { strlcpy(header.MSG_AUTHOR, user.user_handle, sizeof header.MSG_AUTHOR); } else { strlcpy(header.MSG_AUTHOR, user.user_realname, sizeof header.MSG_AUTHOR); } DDPut(header.MSG_AUTHOR); for (;;) { askrec: DDPut(sd[emhead7str]); if (!(Prompt(header.MSG_RECEIVER, 25, 0))) return 0; if (header.MSG_RECEIVER[0] == 0 || (!strcasecmp(header.MSG_RECEIVER, "all")) || (!strcasecmp(header.MSG_RECEIVER, "all users"))) { if (current_msgbase->MSGBASE_FLAGS & (1L << 0)) { DDPut(sd[emhead8str]); HotKey(0); header.MSG_RECEIVER[0] = 0; } else { DDPut(sd[emhead9str]); header.MSG_RECEIVER[0] = 0; break; } } else if (!strcasecmp(header.MSG_RECEIVER, "eall")) { if (current_msgbase->MSGBASE_FLAGS & (1L << 0)) { DDPut(sd[emhead8str]); HotKey(0); header.MSG_RECEIVER[0] = 0; } else if (access1 & (1L << SECB_EALLMESSAGE)) { header.MSG_RECEIVER[0] = -1; DDPut(sd[emhead10str]); break; } else { DDPut(sd[emnopoststr]); HotKey(0); header.MSG_RECEIVER[0] = 0; } } else { if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'L') { struct userbase user; if (!strcasecmp(header.MSG_RECEIVER, "sysop")) { recoff = 0; } else { recoff = findusername(header.MSG_RECEIVER); } if (recoff == -1 || getubentbyid(recoff, &user) == -1) { DDPut(sd[emnouserstr]); HotKey(0); goto askrec; } if (!checkconfaccess(conference()->conf.CONF_NUMBER, &user)) { DDPut(sd[emnoaccessstr]); HotKey(0); } DDPut("[5;12H [5;12H"); if (current_msgbase->MSGBASE_FLAGS & (1L << 2)) { strlcpy(header.MSG_RECEIVER, user.user_handle, sizeof header.MSG_RECEIVER); } else { strlcpy(header.MSG_RECEIVER, user.user_realname, sizeof header.MSG_RECEIVER); } DDPut(header.MSG_RECEIVER); break; } else break; } } DDPut(sd[emsubjectstr]); if (!(Prompt(header.MSG_SUBJECT, 67, 0))) return 0; if (header.MSG_SUBJECT[0] == 0) { DDPut(sd[emabortedstr]); return 0; } DDPut("[11;1H [11;1H"); if (header.MSG_RECEIVER[0] == 0 || header.MSG_RECEIVER[0] == -1 || header.MSG_FLAGS & (1L << 0) || current_msgbase->MSGBASE_FLAGS & (1L << 1)) { } else { DDPut(sd[emisprivatestr]); hola = HotKey(HOT_NOYES); if (hola == 0) return 0; if (hola == 1) header.MSG_FLAGS |= MSG_FLAGS_PRIVATE; } if ((header.MSG_FLAGS & (1L << 0)) == 0 && (access1 & (1L << SECB_PUBLICMESSAGE)) == 0) { DDPut(sd[emnopubstr]); return 0; } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') { if (header.MSG_FN_DEST_NET) { snprintf(ebuf, sizeof ebuf, "%d:%d/%d.%d", header.MSG_FN_DEST_ZONE, header.MSG_FN_DEST_NET, header.MSG_FN_DEST_NODE, header.MSG_FN_DEST_POINT); } else { *ebuf = 0; } DDPut(sd[emnetaddstr]); if (!(Prompt(ebuf, 30, 0))) return 0; if (!str2addr(ebuf, &header.MSG_FN_DEST_ZONE, &header.MSG_FN_DEST_NET, &header.MSG_FN_DEST_NODE, &header.MSG_FN_DEST_POINT)) return 0; if(access2 & (1L << SECB_CRASH)) { DDPut(sd[emnetcrashstr]); if(HotKey(HOT_NOYES) == 1) { header.MSG_FLAGS |= MSG_FLAGS_CRASH; } } DDPut(sd[emnetkillstr]); if(HotKey(HOT_YESNO) == 1) { header.MSG_FLAGS |= MSG_FLAGS_KILL_SENT; } } *header.MSG_ATTACH = 0; if (current_msgbase->MSGBASE_FLAGS & (1L << 5)) { if ((header.MSG_FLAGS & (1L << 0)) && (access2 & (1L << SECB_PVTATTACH))) { *header.MSG_ATTACH = 1; } else if (((header.MSG_FLAGS & (1L << 0)) == 0) && (access2 & (1L << SECB_PUBATTACH))) { *header.MSG_ATTACH = 1; } } if (reply) { if (!askqlines()) { snprintf(ebuf, sizeof ebuf, "%s/daydream%d.msg", DDTMP, node); unlink(ebuf); } DDPut("\n\n"); } /* XXX: size should be replaced by a constant! */ lineedmem = (char *) xmalloc(80 * 500); hola = edfile(lineedmem, 80 * 500, reply, &header); if (hola == 0) { char fabuf[1024]; DDPut(sd[emaborted2str]); free(lineedmem); if (cleantemp() == -1) { DDPut(sd[tempcleanerrstr]); return 0; } snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); unlink(fabuf); return 0; } DDPut(sd[emsavingstr]); getmsgptrs(); highest++; header.MSG_NUMBER = highest; if (setmsgptrs() == 0) { free(lineedmem); return 0; } if (*header.MSG_ATTACH) { char fabuf[1024]; FILE *fd; snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); if ((fd = fopen(fabuf, "r"))) { char hoobab[1024]; snprintf(hoobab, sizeof hoobab, "%s/messages/base%3.3d/fa%5.5d", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER); mkdir(hoobab, 0777); setperm(hoobab, 0777); while (fgetsnolf(hoobab, 1024, fd)) { char sr[1024]; char de[1024]; snprintf(sr, sizeof sr, "%s/%s", currnode->MULTI_TEMPORARY, hoobab); snprintf(de, sizeof de, "%s/messages/base%3.3d/fa%5.5d/%s", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER, hoobab); newrename(sr, de); } fclose(fd); snprintf(hoobab, sizeof hoobab, "%s/messages/base%3.3d/msf%5.5d", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER); newrename(fabuf, hoobab); } else { *header.MSG_ATTACH = 0; } } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) != 'L') { header.MSG_FN_ORIG_ZONE = current_msgbase->MSGBASE_FN_ZONE; header.MSG_FN_ORIG_NET = current_msgbase->MSGBASE_FN_NET; header.MSG_FN_ORIG_NODE = current_msgbase->MSGBASE_FN_NODE; header.MSG_FN_ORIG_POINT = current_msgbase->MSGBASE_FN_POINT; header.MSG_FLAGS |= (1L << 2); } if ((msgfd = ddmsg_open_base(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, O_RDWR | O_CREAT, 0666)) == -1) { DDPut(sd[emwriteerrstr]); free(lineedmem); return 0; } fsetperm(msgfd, 0666); lseek(msgfd, 0, SEEK_END); safe_write(msgfd, &header, sizeof(struct DayDream_Message)); ddmsg_close_base(msgfd); if ((msgfd = ddmsg_open_msg(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER, O_RDWR | O_CREAT | O_TRUNC, 0666)) == -1) { DDPut(sd[emwriteerrstr]); free(lineedmem); return 0; } fsetperm(msgfd, 0666); if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E') { char ub[128]; int uq; strlcpy(ub, current_msgbase->MSGBASE_FN_TAG, sizeof ub); strupr(ub); snprintf(ebuf, sizeof ebuf, "AREA:%s\n", ub); safe_write(msgfd, ebuf, strlen(ebuf)); if ((uq = getfidounique())) { snprintf(ebuf, sizeof ebuf, "\001MSGID: %d:%d/%d.%d %8.8x\n", current_msgbase->MSGBASE_FN_ZONE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE, current_msgbase->MSGBASE_FN_POINT, uq); safe_write(msgfd, ebuf, strlen(ebuf)); if (header.MSG_ORIGINAL) { if (getreplyid(header.MSG_ORIGINAL, ebuf, sizeof ebuf)) safe_write(msgfd, ebuf, strlen(ebuf)); } } } else if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') { snprintf(ebuf, sizeof ebuf, "\001INTL %d:%d/%d %d:%d/%d\n", header.MSG_FN_DEST_ZONE, header.MSG_FN_DEST_NET, header.MSG_FN_DEST_NODE, header.MSG_FN_ORIG_ZONE, header.MSG_FN_ORIG_NET, header.MSG_FN_ORIG_NODE); safe_write(msgfd, ebuf, strlen(ebuf)); if (header.MSG_FN_DEST_POINT) { snprintf(ebuf, sizeof ebuf, "\001TOPT %d\n", header.MSG_FN_DEST_POINT); safe_write(msgfd, ebuf, strlen(ebuf)); } if (header.MSG_FN_ORIG_POINT) { snprintf(ebuf, sizeof ebuf, "\001FMPT %d\n", header.MSG_FN_ORIG_POINT); safe_write(msgfd, ebuf, strlen(ebuf)); } } s = lineedmem; while (hola) { snprintf(ebuf, sizeof ebuf, "%s\n", s); safe_write(msgfd, ebuf, strlen(ebuf)); hola--; s = &s[80]; } // place holder, user auto-sig goes here // snprintf(ebuf, sizeof ebuf, "signature here"); // safe_write(msgfd, ebuf, strlen(ebuf)); if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E') { snprintf(ebuf, sizeof ebuf, "\n--- DayDream BBS/UNIX (" UNAME ") %s\n * Origin: %s (%d:%d/%d)\nSEEN-BY: %d/%d\n", versionstring, current_msgbase->MSGBASE_FN_ORIGIN, current_msgbase->MSGBASE_FN_ZONE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE); safe_write(msgfd, ebuf, strlen(ebuf)); } else if (toupper(current_msgbase->MSGBASE_FN_FLAGS) != 'L') { snprintf(ebuf, sizeof ebuf, "\n--- DayDream BBS/UNIX (" UNAME ") %s\n", versionstring); safe_write(msgfd, ebuf, strlen(ebuf)); } ddmsg_close_msg(msgfd); DDPut(sd[emdonestr]); free(lineedmem); if (header.MSG_FLAGS & (1L << 0)) { user.user_pvtmessages++; clog.cl_pvtmessages++; } else { user.user_pubmessages++; clog.cl_pubmessages++; } return 1; }
int sysopdownload(const char *params) { const char *srcstrh; char parbuf[1024]; char bigbuf[4096]; int discon = 0; struct FFlag *myf; FILE *listh; char lastfile[100]; int keepc = 1; changenodestatus("SysOp download"); TypeFile("sysopdownload", TYPE_MAKE); srcstrh = params; for (;;) { if (strtoken(parbuf, &srcstrh, sizeof parbuf) > sizeof parbuf) continue; if (!*parbuf) break; sflagfile(parbuf); } for (;;) { typedlprompt(); bigbuf[0] = 0; if (!(Prompt(bigbuf, 200, 0))) return 0; if (!bigbuf[0]) { break; } else if (!strcasecmp(bigbuf, "a")) { return 0; } else { srcstrh = bigbuf; for (;;) { if (strtoken(parbuf, &srcstrh, sizeof parbuf) > sizeof parbuf) continue; if (!*parbuf) break; sflagfile(parbuf); } } } if (!filestagged) return 0; listtags(); if (estimsecs(bytestagged) > timeleft) { DDPut(sd[dlnotimestr]); return 0; } for (;;) { DDPut(sd[dlproceedstr]); bigbuf[0] = 0; if (!(Prompt(bigbuf, 3, 0))) return 0; if (!bigbuf[0] || bigbuf[0] == 'p' || bigbuf[0] == 'P') break; else if (bigbuf[0] == 'e' || bigbuf[0] == 'E') { taged(0); } else if (bigbuf[0] == 'd' || bigbuf[0] == 'D') { discon = 1; break; } else if (bigbuf[0] == 'a' || bigbuf[0] == 'A') { return 0; } } if (estimsecs(bytestagged) > timeleft) { DDPut(sd[dlnotimestr]); return 0; } snprintf(parbuf, sizeof parbuf - 250, "%s/dszlog.%d", DDTMP, node); snprintf(&parbuf[250], sizeof parbuf - 250, "%s/ddfilelist.%d", DDTMP, node); unlink(&parbuf[250]); if (!(listh = fopen(&parbuf[250], "w"))) return 0; myf = (struct FFlag *) flaggedfiles->lh_Head; while (myf->fhead.ln_Succ) { char tbu[256]; snprintf(tbu, sizeof tbu, "%s%s\n", myf->f_path, myf->f_filename); fputs(tbu, listh); myf = (struct FFlag *) myf->fhead.ln_Succ; } fclose(listh); *lastfile = 0; sendfiles(&parbuf[250], lastfile, sizeof lastfile); if (*lastfile) { myf = (struct FFlag *) flaggedfiles->lh_Head; while (myf->fhead.ln_Succ && keepc) { struct FFlag *oldf; if (!strcasecmp(lastfile, myf->f_filename)) keepc = 0; Remove((struct Node *) myf); oldf = myf; myf = (struct FFlag *) myf->fhead.ln_Succ; free(oldf); } } recountfiles(); unlink(&parbuf[250]); if (protocol->PROTOCOL_TYPE == 2 || protocol->PROTOCOL_TYPE == 3) { upload(2); } if (discon) { if (autodisconnect()) return 2; } return 1; }
/* FIXME! buffer overflows? */ static int handle_choice(const char *askbuf) { char lesbabuf[30]; struct userbase muser = user; int leps; if (!(strcasecmp(askbuf, "1"))) { for (;;) { if (!isaccess(SECB_REALNAME, access2)) break; DDPut(sd[eu1str]); strlcpy(lesbabuf, user.user_realname, sizeof lesbabuf); if (!(Prompt(lesbabuf, 25, 0))) return 1; removespaces(lesbabuf); if (strcasecmp(lesbabuf, user.user_realname)) { leps = findusername(lesbabuf); if (leps == user.user_account_id || leps == -1) { if (lesbabuf[0]) strlcpy(user.user_realname, lesbabuf, sizeof user.user_realname); } else { DDPut(sd[newalreadystr]); continue; } } break; } } else if (!(strcasecmp(askbuf, "2"))) { for (;;) { if (!isaccess(SECB_HANDLE, access2)) break; DDPut(sd[eu2str]); strlcpy(lesbabuf, user.user_handle, sizeof lesbabuf); if (!(Prompt(lesbabuf, 25, 0))) return 1; removespaces(lesbabuf); if (strcasecmp(lesbabuf, user.user_handle)) { leps = findusername(lesbabuf); if (leps == user.user_account_id || leps == -1) { if (lesbabuf[0]) strlcpy(user.user_handle, lesbabuf, sizeof user.user_handle); } else { DDPut(sd[newalreadystr]); continue; } } break; } } else if (!(strcasecmp(askbuf, "3"))) { DDPut(sd[eu3str]); if (!(Prompt(user.user_organization, 25, 0))) return 1; } else if (!(strcasecmp(askbuf, "4"))) { DDPut(sd[eu4str]); if (!(Prompt(user.user_zipcity, 20, 0))) return 1; } else if (!(strcasecmp(askbuf, "5"))) { DDPut(sd[eu5str]); if (!(Prompt(user.user_voicephone, 20, 0))) return 1; } else if (!(strcasecmp(askbuf, "6"))) { MD_CTX context; char verifypw[32]; DDPut(sd[eu6str]); lesbabuf[0] = 0; if (!(Prompt(lesbabuf, 15, PROMPT_SECRET))) return 1; if (lesbabuf[0] == 0) return 0; *verifypw = 0; DDPut(sd[euverifypwstr]); if (!(Prompt(verifypw, 15, PROMPT_SECRET))) return 1; if (strcasecmp(lesbabuf, verifypw)) { DDPut(sd[eunomatchstr]); return 0; } strupr(lesbabuf); MDInit(&context); MDUpdate(&context, (unsigned char *) lesbabuf, strlen(lesbabuf)); MDFinal(user.user_password, &context); } else if (!strcasecmp(askbuf, "7")) { for (;;) { int fallos; DDPut(sd[eu7str]); lesbabuf[0] = 0; if (!(Prompt(lesbabuf, 3, 0))) return 1; if (lesbabuf[0] == 't' || lesbabuf[0] == 'T') { testscreenl(); continue; } fallos = atoi(lesbabuf); if (fallos < 10) { DDPut(sd[newminslstr]); continue; } user.user_screenlength = fallos; break; } } else if (!(strcasecmp(askbuf, "8"))) { struct DayDream_Protocol *tp; TypeFile("protocols", TYPE_MAKE | TYPE_WARN); DDPut(sd[eu8str]); *lesbabuf = 0; if (user.user_protocol) { *lesbabuf = user.user_protocol; lesbabuf[1] = 0; } if (!(Prompt(lesbabuf, 3, 0))) return 1; *lesbabuf = toupper(*lesbabuf); if (!*lesbabuf) return 0; tp = protocols; for (;;) { if (tp->PROTOCOL_ID == 0) return 0; if (tp->PROTOCOL_ID == *lesbabuf) { protocol = tp; user.user_protocol = *lesbabuf; return 0; } tp++; } } else if (!(strcasecmp(askbuf, "9"))) { DDPut(sd[eu9str]); if (!(Prompt(user.user_signature, 44, 0))) return 1; } else if (!(strcasecmp(askbuf, "10"))) { DDPut(sd[eu10str]); if (!(Prompt(user.user_computermodel, 20, 0))) return 1; } else if (!(strcasecmp(askbuf, "11"))) { DDPut(sd[eu11str]); snprintf(lesbabuf, sizeof lesbabuf, "%d", user.user_flines); if (!(Prompt(lesbabuf, 3, 0))) return 1; user.user_flines = atoi(lesbabuf); } else if (!(strcasecmp(askbuf, "12"))) { rundoor("doors/autosig %N", 0); return 1; } else if (!(strcasecmp(askbuf, "a"))) { DDPut(sd[euabortedstr]); user = muser; return 1; } else if (!(strcasecmp(askbuf, "v"))) { TypeFile("edituser", TYPE_MAKE | TYPE_WARN); } else if (!(strcasecmp(askbuf, "s"))) { switches(); } else if ((!(strcasecmp(askbuf, "c")) || (askbuf[0] == 0))) { DDPut(sd[eusavedstr]); saveuserbase(&user); return 1; } return 0; }
int tagmessageareas(void) { uint8_t backup[32]; char tbuf[500]; const char *sta; msgbase_t *mb; int bcnt; char inp[90]; const char *s; char tok[90]; int screenl; int i, j; memcpy(backup, &selcfg[(conference()->conf.CONF_NUMBER - 1) * 32], sizeof backup); vagain: DDPut("[2J[H"); screenl = user.user_screenlength; bcnt = conference()->conf.CONF_MSGBASES; for (i = j = 0; j < bcnt; j++) { mb = conference()->msgbases[j]; i++; if (i == 3) { DDPut("\n"); i = 1; screenl--; if (screenl == 1) { int hot; DDPut(sd[morepromptstr]); hot = HotKey(0); DDPut("\r \r"); if (hot == 'N' || hot == 'n' || !checkcarrier()) break; if (hot == 'C' || hot == 'c') { screenl = 20000000; } else { screenl = user.user_screenlength; } } } if (isbasetagged(conference()->conf.CONF_NUMBER, mb->MSGBASE_NUMBER)) { sta = "ON"; } else sta = "OFF"; ddprintf(sd[tbclinestr], mb->MSGBASE_NUMBER, mb->MSGBASE_NAME, sta); } DDPut("\n"); for (;;) { DDPut(sd[tbpromptstr]); inp[0] = 0; if (!(Prompt(inp, 80, 0))) return 0; s = inp; if (!*inp) { strlcpy(inp, "s", sizeof inp); } for (;;) { if (strtoken(tok, &s, sizeof tok) > sizeof tok) continue; if (!*tok) break; if (!strcasecmp(tok, "c")) { memcpy(&selcfg[(conference()->conf.CONF_NUMBER - 1) * 32], backup, sizeof backup); return 0; } else if (!strcasecmp(tok, "v")) { goto vagain; } else if (!strcasecmp(tok, "s")) { int selfd; snprintf(tbuf, sizeof tbuf, "users/%d/selected.dat", user.user_account_id); selfd = open(tbuf, O_WRONLY | O_CREAT, 0666); if (selfd != -1) { fsetperm(selfd, 0666); safe_write(selfd, &selcfg, 2056); close(selfd); } return 0; } else if (!strcasecmp(tok, "-")) { for (i = 0; i < 32; i++) { selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + i] = 0; } DDPut(sd[tballoffstr]); } else if (!strcasecmp(tok, "+")) { bcnt = conference()->conf.CONF_MSGBASES; for (i = 0; i < bcnt; i++) { mb = conference()->msgbases[i]; selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] |= (1L << (mb->MSGBASE_NUMBER - 1) % 8); } DDPut(sd[tballonstr]); } else { i = atoi(tok); if (i) { for (j = 0; j < conference()->conf.CONF_MSGBASES; j++) { mb = conference()->msgbases[j]; if (i == mb->MSGBASE_NUMBER) { if (selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] & (1L << (mb->MSGBASE_NUMBER - 1) % 8)) { selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] &= ~(1L << (mb->MSGBASE_NUMBER - 1) % 8); } else { selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] |= (1L << (mb->MSGBASE_NUMBER - 1) % 8); } break; } } } } } } }
int pagesysop(const char *reas) { struct DayDream_PageMsg pm; struct sockaddr_un name; int sock; time_t ctim; int i; changenodestatus("Paging SysOp"); reason[0] = 0; if (reas) strlcpy(reason, reas, sizeof reason); TypeFile("pagesysop", TYPE_MAKE | TYPE_WARN); if (maincfg.CFG_FLAGS & (1L << 0)) { if (reason[0] == 0) { DDPut(sd[psreasonstr]); if (!(Prompt(reason, 75, 0))) return 0; if (reason[0] == 0) { DDPut("\n"); return 0; } } } clog.cl_flags |= CL_PAGEDSYSOP; sock = socket(AF_UNIX, SOCK_DGRAM, 0); if (sock < 0) return 0; pm.pm_cmd = 2; ctim = time(0); *pm.pm_string = 0; if (onlinestat) snprintf(pm.pm_string, sizeof pm.pm_string, "\n\n%s / %s (node %d) paged you on %s\n", user.user_realname, user.user_handle, node, ctime(&ctim)); if (reason[0]) { strlcat(pm.pm_string, "Reason: ", sizeof pm.pm_string); strlcat(pm.pm_string, reason, sizeof pm.pm_string); strlcat(pm.pm_string, "\n\n", sizeof pm.pm_string); } name.sun_family = AF_UNIX; strlcpy(name.sun_path, YELLDSOCK, sizeof name.sun_path); if (sendto(sock, &pm, sizeof(struct DayDream_PageMsg), 0, (struct sockaddr *) &name, sizeof(struct sockaddr_un)) < 0) { DDPut(sd[pspageoffstr]); close(sock); return 0; } pages--; ddprintf(sd[pspagingstr], maincfg.CFG_SYSOPNAME); pageflag = 0; for (i = 0; i < 20; i++) { unsigned char c; DDPut("."); delayt = 1; while ((c = HotKey(HOT_QUICK))) { if (c == 255) break; if (c == 3) { DDPut(sd[psabortstr]); i = 21; break; } } if (pageflag) break; pm.pm_cmd = 1; name.sun_family = AF_UNIX; strlcpy(name.sun_path, YELLDSOCK, sizeof name.sun_path); sendto(sock, &pm, sizeof(struct DayDream_PageMsg), 0, (struct sockaddr *) &name, sizeof(struct sockaddr_un)); sleep(1); } if (i == 20) DDPut(sd[psnosysopstr]); close(sock); return 0; }
int download(const char *params) { char parbuf[512]; char bigbuf[10000]; const char *srcstrh; int discon = 0; struct FFlag *myf; FILE *listh; char lastfile[100]; int keepc = 1; bgrun = 0; wasbg = 0; setprotocol(); changenodestatus("Downloading"); TypeFile("download", TYPE_MAKE | TYPE_CONF | TYPE_WARN); if (!conference()->conf.CONF_FILEAREAS) { DDPut(sd[dlnoareasstr]); return 0; } if ((protocol->PROTOCOL_TYPE == 3 || protocol->PROTOCOL_TYPE == 2) && !conference()->conf.CONF_UPLOADAREA) { DDPut(sd[dlnouploadsstr]); return 0; } if (protocol->PROTOCOL_TYPE == 2 || protocol->PROTOCOL_TYPE == 3) { if (cleantemp() == -1) { DDPut(sd[tempcleanerrstr]); return 0; } if (!freespace()) return 0; maketmplist(); } srcstrh = params; for (;;) { if (strtoken(parbuf, &srcstrh, sizeof parbuf) > sizeof parbuf) continue; if (!*parbuf) break; flagfile(parbuf, 1); } for (;;) { typedlprompt(); bigbuf[0] = 0; if (!(Prompt(bigbuf, 200, 0))) return 0; if (!bigbuf[0]) { break; } else if (!strcasecmp(bigbuf, "a")) { return 0; } else { srcstrh = bigbuf; for (;;) { if (strtoken(parbuf, &srcstrh, sizeof parbuf) > sizeof parbuf) continue; if (!*parbuf) break; flagfile(parbuf, 1); } } } if (!filestagged) return 0; listtags(); if (estimsecs(bytestagged) > timeleft) { DDPut(sd[dlnotimestr]); return 0; } for (;;) { DDPut(sd[dlproceedstr]); bigbuf[0] = 0; if (!(Prompt(bigbuf, 3, 0))) return 0; if (!bigbuf[0] || bigbuf[0] == 'p' || bigbuf[0] == 'P') break; else if (bigbuf[0] == 'e' || bigbuf[0] == 'E') { taged(0); } else if (bigbuf[0] == 'd' || bigbuf[0] == 'D') { discon = 1; break; } else if (bigbuf[0] == 'a' || bigbuf[0] == 'A') { return 0; } } snprintf(parbuf, sizeof parbuf, "%s/dszlog.%d", DDTMP, node); sprintf(&parbuf[250], "%s/ddfilelist.%d", DDTMP, node); unlink(&parbuf[250]); if (!(listh = fopen(&parbuf[250], "w"))) return 0; myf = (struct FFlag *) flaggedfiles->lh_Head; while (myf->fhead.ln_Succ) { char tbu[256]; snprintf(tbu, sizeof tbu, "%s%s\n", myf->f_path, myf->f_filename); fputs(tbu, listh); myf = (struct FFlag *) myf->fhead.ln_Succ; } fclose(listh); *lastfile = 0; if (protocol->PROTOCOL_TYPE == 2 || protocol->PROTOCOL_TYPE == 3) { if ((!(user.user_toggles & (1L << 15))) && (maincfg.CFG_FLAGS & (1L << 11))) { initbgchecker(); } } sendfiles(&parbuf[250], lastfile, sizeof lastfile); if (protocol->PROTOCOL_TYPE == 2 || protocol->PROTOCOL_TYPE == 3) { upload(2); } if (*lastfile) { myf = (struct FFlag *) flaggedfiles->lh_Head; while (myf->fhead.ln_Succ && keepc) { struct FFlag *oldf; struct DD_DownloadLog ddl; char lbuf[100]; int logfd; snprintf(lbuf, sizeof lbuf, "%s/logfiles/downloadlog.dat", origdir); logfd = open(lbuf, O_WRONLY | O_CREAT, 0666); if (logfd != -1) { fsetperm(logfd, 0666); memset((char *) &ddl, 0, sizeof(struct DD_DownloadLog)); ddl.DL_SLOT = user.user_account_id; strlcpy(ddl.DL_FILENAME, myf->f_filename, sizeof ddl.DL_FILENAME); ddl.DL_FILESIZE = myf->f_size; ddl.DL_TIME = time(0); ddl.DL_BPSRATE = bpsrate; ddl.DL_NODE = node; ddl.DL_CONF = (unsigned char) myf->f_conf; lseek(logfd, 0, SEEK_END); safe_write(logfd, &ddl, sizeof(struct DD_DownloadLog)); close(logfd); } if (!(myf->f_flags & FLAG_FREE)) { user.user_dlbytes += myf->f_size; user.user_dlfiles++; } if (!strcasecmp(lastfile, myf->f_filename)) keepc = 0; Remove((struct Node *) myf); oldf = myf; myf = (struct FFlag *) myf->fhead.ln_Succ; free(oldf); } } recountfiles(); unlink(&parbuf[250]); if (discon) { if (autodisconnect()) return 2; } return 1; }
static void switches(void) { char inp[82]; const char *s; char tok[82]; uint32_t togbak; int poro; togbak = user.user_toggles; for (;;) { char buffa[200]; char *togf; DDPut("\n"); if (user.user_toggles & (1L << 12)) togf = sd[tsaskstr]; else if (user.user_toggles & (1L << 5)) togf = sd[tsnostr]; else togf = sd[tsyesstr]; ddprintf(sd[togglinestr], 1, sd[ts1str], togf); if (user.user_toggles & (1L << 13)) togf = sd[tsaskstr]; else if (user.user_toggles & (1L << 6)) togf = sd[tsyesstr]; else togf = sd[tsnostr]; ddprintf(sd[togglinestr], 2, sd[ts2str], togf); DDPut("\n"); if (user.user_toggles & (1L << 11)) togf = sd[tsaskstr]; else if (user.user_toggles & (1L << 0)) togf = sd[tsyesstr]; else togf = sd[tsnostr]; ddprintf(sd[togglinestr], 3, sd[ts3str], togf); if (user.user_toggles & (1L << 9)) togf = sd[tsnostr]; else togf = sd[tsyesstr]; ddprintf(sd[togglinestr], 4, sd[ts4str], togf); DDPut("\n"); if (user.user_toggles & (1L << 14)) togf = sd[tsyesstr]; else togf = sd[tsnostr]; ddprintf(sd[togglinestr], 5, sd[ts5str], togf); if (user.user_toggles & (1L << 15)) togf = sd[tsnostr]; else togf = sd[tsyesstr]; ddprintf(sd[togglinestr], 6, sd[ts6str], togf); DDPut("\n"); poro = 1; while (poro) { DDPut(sd[tspromptstr]); inp[0] = 0; if (!(Prompt(inp, 80, 0))) return; s = inp; if (!*inp) { strlcpy(inp, "s", sizeof inp); } for (;;) { int numb; if (strtoken(tok, &s, sizeof tok) > sizeof tok) continue; if (!*tok) break; if (!strcasecmp("s", tok)) { return; } else if (!strcasecmp("a", tok)) { user.user_toggles = togbak; return; } else if (!strcasecmp("v", tok)) { poro = 0; break; } else { numb = atoi(tok); switch (numb) { case 1: if (user.user_toggles & (1L << 5)) { user.user_toggles |= (1L << 12); user.user_toggles &= ~(1L << 5); snprintf(buffa, sizeof buffa, sd[asktlinestr], sd[ts1str]); } else if (user.user_toggles & (1L << 12)) { user.user_toggles &= ~(1L << 12); user.user_toggles &= ~(1L << 5); snprintf(buffa, sizeof buffa, sd[ontlinestr], sd[ts1str]); } else { user.user_toggles &= ~(1L << 12); user.user_toggles |= (1L << 5); snprintf(buffa, sizeof buffa, sd[offtlinestr], sd[ts1str]); } DDPut(buffa); break; case 2: if (user.user_toggles & (1L << 6)) { user.user_toggles |= (1L << 13); user.user_toggles &= ~(1L << 6); snprintf(buffa, sizeof buffa, sd[asktlinestr], sd[ts2str]); } else if (user.user_toggles & (1L << 13)) { user.user_toggles &= ~(1L << 13); user.user_toggles &= ~(1L << 6); snprintf(buffa, sizeof buffa, sd[offtlinestr], sd[ts2str]); } else { user.user_toggles &= ~(1L << 13); user.user_toggles |= (1L << 6); snprintf(buffa, sizeof buffa, sd[ontlinestr], sd[ts2str]); } DDPut(buffa); break; case 3: if (user.user_toggles & (1L << 0)) { user.user_toggles |= (1L << 11); user.user_toggles &= ~(1L << 0); snprintf(buffa, sizeof buffa, sd[asktlinestr], sd[ts3str]); } else if (user.user_toggles & (1L << 11)) { user.user_toggles &= ~(1L << 11); user.user_toggles &= ~(1L << 0); snprintf(buffa, sizeof buffa, sd[offtlinestr], sd[ts3str]); } else { user.user_toggles &= ~(1L << 11); user.user_toggles |= (1L << 0); snprintf(buffa, sizeof buffa, sd[ontlinestr], sd[ts3str]); } DDPut(buffa); break; case 4: if (user.user_toggles & (1L << 9)) { user.user_toggles &= ~(1L << 9); snprintf(buffa, sizeof buffa, sd[ontlinestr], sd[ts4str]); } else { user.user_toggles |= (1L << 9); snprintf(buffa, sizeof buffa, sd[offtlinestr], sd[ts4str]); } DDPut(buffa); break; case 5: if (user.user_toggles & (1L << 14)) { user.user_toggles &= ~(1L << 14); snprintf(buffa, sizeof buffa, sd[offtlinestr], sd[ts5str]); } else { user.user_toggles |= (1L << 14); snprintf(buffa, sizeof buffa, sd[ontlinestr], sd[ts5str]); } DDPut(buffa); break; case 6: if (user.user_toggles & (1L << 15)) { user.user_toggles &= ~(1L << 15); snprintf(buffa, sizeof buffa, sd[ontlinestr], sd[ts6str]); } else { user.user_toggles |= (1L << 15); snprintf(buffa, sizeof buffa, sd[offtlinestr], sd[ts6str]); } DDPut(buffa); break; } } } } } }
static int try_login(void) { char username[300]; int retvalue, passwdcnt; DDPut(sd[usernamestr]); username[0] = 0; Prompt(username, 25, 0); removespaces(username); if (!checkcarrier()) return -1; if (!username[0]) { DDPut(""); return -1; } if (!strcasecmp("new", username) && !(maincfg.CFG_FLAGS & (1L << 17))) { CreateNewAccount(); return -1; } if (!strcasecmp("logoff", username)) return 0; if (!strcasecmp("chat", username)) { pagesysop(0); return -1; } retvalue = checklogon(username); if (!retvalue && !(maincfg.CFG_FLAGS & (1L << 17))) { if (maincfg.CFG_FLAGS & (1L << 9)) return create_new_account() ? 0 : -1; else { DDPut(sd[unknownuserstr]); return -1; } } else { if (retvalue != 1 && !(maincfg.CFG_FLAGS & (1L << 18))) return -1; for (passwdcnt = 0; passwdcnt < 3; passwdcnt++) { username[0] = 0; if (ispw() || retvalue != 1) { DDPut(sd[passwordstr]); Prompt(username, 25, PROMPT_SECRET); } if (!checkcarrier()) return -1; if (retvalue > 0 && (!ispw() || cmppasswds(username, user.user_password))) { if (retvalue == 2) DDPut(sd[alreadyonlinestr]); else getin(); return 0; } else { if (passwdcnt != 2) DDPut(sd[tryagainstr]); clog.cl_flags |= CL_PASSWDFAIL; } } if (retvalue != 2) { TypeFile("passwordfailure", TYPE_MAKE); DDPut(sd[excessivepwfailstr]); return 0; } } return -1; }
int tagconfs(void) { uint8_t backup[8]; char tbuf[500]; const char *sta; char inp[90]; const char *s; char tok[90]; conference_t *mc; struct iterator *iterator; int i; int screenl; for (i = 0; i < 8; i++) { backup[i] = selcfg[2048 + i]; } vagain: DDPut("[2J[H"); i = 0; screenl = user.user_screenlength; iterator = conference_iterator(); while ((mc = (conference_t *) iterator_next(iterator))) { if (checkconfaccess(mc->conf.CONF_NUMBER, &user)) { i++; if (i == 3) { DDPut("\n"); i = 1; screenl--; if (screenl == 1) { int hot; DDPut(sd[morepromptstr]); hot = HotKey(0); DDPut("\r \r"); if (hot == 'N' || hot == 'n' || !checkcarrier()) break; if (hot == 'C' || hot == 'c') { screenl = 20000000; } else { screenl = user.user_screenlength; } } } if (isconftagged(mc->conf.CONF_NUMBER)) { sta = "ON"; } else sta = "OFF"; ddprintf(sd[togglinestr], mc->conf.CONF_NUMBER, mc->conf.CONF_NAME, sta); } } iterator_discard(iterator); DDPut("\n"); for (;;) { DDPut(sd[tcpromptstr]); inp[0] = 0; if (!(Prompt(inp, 80, 0))) return 0; s = inp; if (!*inp) { strlcpy(inp, "s", sizeof inp); } for (;;) { if (strtoken(tok, &s, sizeof tok) > sizeof tok) continue; if (!*tok) break; if (!strcasecmp(tok, "c")) { for (i = 0; i < 8; i++) { selcfg[2048 + i] = backup[i]; } return 0; } else if (!strcasecmp(tok, "v")) { goto vagain; } else if (!strcasecmp(tok, "s")) { int selfd; snprintf(tbuf, sizeof tbuf, "users/%d/selected.dat", user.user_account_id); selfd = open(tbuf, O_WRONLY | O_CREAT, 0666); if (selfd != -1) { fsetperm(selfd, 0666); safe_write(selfd, &selcfg, 2056); close(selfd); } return 0; } else if (!strcasecmp(tok, "-")) { for (i = 0; i < 8; i++) { selcfg[2048 + i] = 0; } DDPut(sd[tcalloffstr]); } else if (!strcasecmp(tok, "+")) { for (i = 0; i < 8; i++) { selcfg[2048 + i] = 255; } DDPut(sd[tcallonstr]); } else { i = atoi(tok); if (i > 0 && i < 65 && checkconfaccess(i, &user)) { iterator = conference_iterator(); while ((mc = (conference_t *) iterator_next(iterator))) { if (mc->conf.CONF_NUMBER == i) { if (selcfg[2048 + (mc->conf.CONF_NUMBER - 1) / 8] & (1L << (mc->conf.CONF_NUMBER - 1) % 8)) { selcfg[2048 + (mc->conf.CONF_NUMBER - 1) / 8] &= ~(1L << (mc->conf.CONF_NUMBER - 1) % 8); } else { selcfg[2048 + (mc->conf.CONF_NUMBER - 1) / 8] |= (1L << (mc->conf.CONF_NUMBER - 1) % 8); } break; } } iterator_discard(iterator); } } } } }
int bulletins(char *params) { char bdir[200]; char menunam[240]; char bullb[500]; char tbuf[400]; char nbu[240]; int first = 0; int menfd; const char *srcstrh; changenodestatus("Viewing bulletins"); snprintf(bdir, sizeof bdir, "%s/bulletins/", conference()->conf.CONF_PATH); snprintf(menunam, sizeof menunam, "%sbulletinmenu.%s", bdir, ansi ? "gfx" : "txt"); menfd = open(menunam, O_RDONLY); if (menfd == -1) { snprintf(bdir, sizeof bdir, "bulletins/"); snprintf(menunam, sizeof menunam, "bulletins/bulletinmenu.%s", ansi ? "gfx" : "txt"); menfd = open(menunam, O_RDONLY); if (menfd == -1) { DDPut(sd[bunobullsstr]); return 0; } } close(menfd); srcstrh = params; for (;;) { int bulnum; if (strtoken(bullb, &srcstrh, sizeof bullb) > sizeof bullb) continue; if (!*bullb) { if (!first) TypeFile(menunam, TYPE_WARN); DDPut(sd[bumenustr]); *tbuf = 0; if (!(Prompt(tbuf, 60, 0))) return 0; srcstrh = tbuf; if (strtoken(bullb, &srcstrh, sizeof bullb) > sizeof bullb) return 0; if (!*bullb) return 0; } first = 1; if (*bullb == 'q' || *bullb == 'Q') return 0; if (*bullb == 'l' || *bullb == 'L' || *bullb == '?') { TypeFile(menunam, TYPE_WARN); } else if ((bulnum = atoi(bullb))) { snprintf(nbu, sizeof nbu, "%sbulletin.%d.%s", bdir, bulnum, ansi ? "gfx" : "txt"); if (TypeFile(nbu, TYPE_WARN)) { if (!(user.user_toggles & (1L << 4))) { DDPut(sd[pause2str]); HotKey(0); } } } } }
/* FIXME! better to move this to entermsg.c */ int askqlines(void) { char qbuffer[200]; char input[100]; int ql; int lcount; int outp; int startn; int endn; int line; FILE *qfd, *msgfd; snprintf(qbuffer, sizeof qbuffer, "%s/daydream%d.mtm", DDTMP, node); if (!(qfd = fopen(qbuffer, "r"))) return 0; DDPut("\n"); for (;;) { ql = 0; lcount = user.user_screenlength; outp = 1; while (fgets(input, 77, qfd)) { ql++; if (outp) { ddprintf(sd[lel2str], ql, input); lcount--; } if (lcount == 0) { int hot; DDPut(sd[morepromptstr]); hot = HotKey(0); DDPut("\r \r"); if (hot == 'N' || hot == 'n') { outp = 0; lcount = -1; } else if (hot == 'C' || hot == 'c') { lcount = -1; } else { lcount = user.user_screenlength; } } } ddprintf(sd[lequotestr], ql); qbuffer[0] = 0; if (!(Prompt(qbuffer, 3, PROMPT_NOCRLF))) { fclose(qfd); return 0; } if (!strcasecmp(qbuffer, "l")) { DDPut("\n\n"); fseek(qfd, 0, SEEK_SET); } else if ((!strcasecmp(qbuffer, "*")) || *qbuffer == 0) { startn = 1; endn = ql; break; } else if ((startn = atoi(qbuffer))) { DDPut(sd[ledeltostr]); qbuffer[0] = 0; if (!(Prompt(qbuffer, 3, PROMPT_NOCRLF))) { fclose(qfd); return 0; } if ((endn = atoi(qbuffer))) { break; } else { fclose(qfd); return 0; } } else { fclose(qfd); return 0; } } fseek(qfd, 0, SEEK_SET); if (startn < 1 || endn > ql) { fclose(qfd); return 0; } line = 1; snprintf(qbuffer, sizeof qbuffer, "%s/daydream%d.msg", DDTMP, node); if (!(msgfd = fopen(qbuffer, "w"))) { fclose(qfd); return 0; } while (fgets(input, 77, qfd)) { if (startn <= line && endn >= line) { fputs(input, msgfd); } line++; } fclose(qfd); fclose(msgfd); return 1; }