void GetstrLC(char *sStr, int iMaxlen) { unsigned char ch = 0; int iPos = 0; strcpy(sStr, ""); alarm_on(); while (ch != 13) { ch = Readkey(); if ((ch == 8) || (ch == KEY_DEL) || (ch == 127)) { if (iPos > 0) { BackErase(); sStr[--iPos] = '\0'; } else { Beep(); } } if ((ch > 31 && ch < 127) || traduce((char *)&ch)) { if (iPos <= iMaxlen) { iPos++; snprintf(sStr + strlen(sStr), 5, "%c", ch); PUTCHAR(ch); } else { Beep(); } } } Enter(1); }
/* * Choose Message Editor */ void Chg_FsMsged() { int z; char temp[81]; ReadExitinfo(); Enter(2); /* Now using the */ pout(LIGHTMAGENTA, BLACK, (char *)Language(372)); /* Line/Fullscreen/External */ colour(LIGHTCYAN, BLACK); snprintf(temp, 81, " %s ", Language(387 + (exitinfo.MsgEditor & 3))); PUTSTR(temp); /* Editor */ pout(LIGHTMAGENTA, BLACK, (char *)Language(390)); Enter(1); if (strlen(CFG.externaleditor)) /* Select: 1) Fullscreen editor, 2) External editor */ pout(WHITE, BLACK, (char *)Language(373)); else /* Select: 1) Fullscreen editor */ pout(WHITE, BLACK, (char *)Language(438)); alarm_on(); z = toupper(Readkey()); if (z == Keystroke(373, 0)) { exitinfo.MsgEditor = FSEDIT; Syslog('+', "User selected fullscreen editor"); } else if ((z == Keystroke(373, 1) && strlen(CFG.externaleditor))) { exitinfo.MsgEditor = EXTEDIT; Syslog('+', "User selected external editor"); } Enter(2); /* Now using the */ pout(LIGHTMAGENTA, BLACK, (char *)Language(372)); /* Line/Fullscreen/External */ colour(LIGHTCYAN, BLACK); snprintf(temp, 81, " %s ", Language(387 + (exitinfo.MsgEditor & 3))); PUTSTR(temp); /* Editor */ pout(LIGHTMAGENTA, BLACK, (char *)Language(390)); Enter(2); sleep(2); WriteExitinfo(); }
int Fs_Edit() { unsigned char ch; int i, Changed = FALSE; char *filname, *tmpname; FILE *fd; Syslog('b', "FSEDIT: Entering FullScreen editor"); if (utf8) chartran_init((char *)"CP437", (char *)"UTF-8", 'B'); clear(); InsMode = TRUE; TopVisible = 1; Col = 1; Row = 1; Refresh(); while (TRUE) { Nopper(); alarm_on(); ch = Readkey(); CurRow = Row + TopVisible - 1; switch (ch) { case KEY_ENTER: if (Col == 1) { /* Enter at beginning of line */ for (i = Line; i >= CurRow; i--) { snprintf(Message[i+1], TEXTBUFSIZE +1, "%s", Message[i]); } Message[i+1][0] = '\0'; } else { for (i = Line; i > CurRow; i--) { snprintf(Message[i+1], TEXTBUFSIZE +1, "%s", Message[i]); } Message[CurRow+1][0] = '\0'; if (Col <= strlen(Message[CurRow])) { /* Enter in middle of line */ for (i = Col-1; i <= strlen(Message[CurRow]); i++) { snprintf(Message[CurRow+1] + strlen(Message[CurRow+1]), 5, "%c", Message[CurRow][i]); } Message[CurRow][Col-1] = '\0'; } /* else Enter at end of line */ } Line++; Row++; Col = 1; if (Row >= (rows -1)) ScrollDown(); Refresh(); Changed = TRUE; break; case ('N' - 64): /* Insert line, scroll down */ for (i = Line; i >= CurRow; i--) snprintf(Message[i+1], TEXTBUFSIZE +1, "%s", Message[i]); Message[CurRow][0] = '\0'; Line++; Col = 1; Refresh(); Changed = TRUE; break; case ('Y' - 64): /* Erase line, scroll up */ if (Line == CurRow) { /* Erasing last line */ if ((Line > 1) || (strlen(Message[CurRow]) > 0)) { Message[CurRow][0] = '\0'; if (Line > 1) { Line--; if (Row == 1) ScrollUp(); Row--; } if (Col > strlen(Message[CurRow])) Col = strlen(Message[CurRow]); Refresh(); Changed = TRUE; } else Beep(); } else { /* Erasing line in the middle */ for (i = CurRow; i < Line; i++) { snprintf(Message[i], TEXTBUFSIZE +1, "%s", Message[i+1]); } Message[i+1][0] = '\0'; Line--; if (Col > strlen(Message[CurRow]) + 1) Col = strlen(Message[CurRow]) + 1; Refresh(); Changed = TRUE; } break; case KEY_UP: case ('E' - 64): FsMove(KEY_UP); break; case KEY_DOWN: case ('X' - 64): FsMove(KEY_DOWN); break; case KEY_LEFT: case ('S' - 64): FsMove(KEY_LEFT); break; case KEY_RIGHT: case ('D' - 64): FsMove(KEY_RIGHT); break; case KEY_DEL: if (Col <= strlen(Message[CurRow])) { /* * If before the end of the line... */ Setcursor(); for (i = Col; i <= strlen(Message[CurRow]); i++) { Message[CurRow][i-1] = Message[CurRow][i]; PUTCHAR(Message[CurRow][i]); } PUTCHAR(' '); PUTCHAR('\b'); Message[CurRow][i-1] = '\0'; Setcursor(); } else if (((strlen(Message[CurRow]) + strlen(Message[CurRow+1]) < 75) || (strlen(Message[CurRow]) == 0)) && (CurRow < Line)) { for (i = 0; i < strlen(Message[CurRow+1]); i++) snprintf(Message[CurRow] + strlen(Message[CurRow]), 5, "%c", Message[CurRow+1][i]); for (i = CurRow+1; i < Line; i++) snprintf(Message[i], TEXTBUFSIZE +1, "%s", Message[i+1]); Message[Line][0] = '\0'; Line--; Refresh(); } else Beep(); /* * Trap the extra code so it isn't * inserted in the text */ if (ch == KEY_DEL) Readkey(); break; case KEY_BACKSPACE: case KEY_RUBOUT: if (Col == 1 && CurRow == 1) { /* BS on first character in message */ Beep(); } else if (Col == 1) { /* BS at beginning of line */ if ((strlen(Message[CurRow-1]) + strlen(Message[CurRow]) < 75) || strlen(Message[CurRow]) == 0) { Col = strlen(Message[CurRow-1]) + 1; strcat(Message[CurRow-1], Message[CurRow]); for ( i = CurRow; i < Line; i++) snprintf(Message[i], TEXTBUFSIZE +1, "%s", Message[i+1]); Message[i+1][0] = '\0'; Line--; if (Row == 1) ScrollUp(); Row--; Refresh(); Changed = TRUE; } else { i = strlen(Message[CurRow-1]) + strlen(Message[CurRow]); Beep(); } } else { if (Col == strlen(Message[CurRow]) + 1) { /* BS at end of line */ BackErase(); Col--; Message[CurRow][Col-1] = '\0'; Changed = TRUE; } else { /* BS in middle of line */ Col--; Setcursor(); for (i = Col; i <= strlen(Message[CurRow]); i++) { Message[CurRow][i-1] = Message[CurRow][i]; PUTCHAR(Message[CurRow][i]); } PUTCHAR(' '); PUTCHAR('\b'); Message[CurRow][strlen(Message[CurRow])] = '\0'; Setcursor(); Changed = TRUE; } } break; case KEY_INS: /* Toggle Insert Mode */ case ('V' - 64): InsMode = !InsMode; Show_Ins(); colour(CFG.TextColourF, CFG.TextColourB); Setcursor(); /* * Trap the extra code so it isn't * inserted in the text */ if (ch == KEY_INS) Readkey(); break; case ('L' - 64): /* Refresh screen */ Refresh(); break; case ('R' - 64): /* Read from file */ Syslog('b', "FSEDIT: Read from file"); tmpname = calloc(PATH_MAX, sizeof(char)); filname = calloc(PATH_MAX, sizeof(char)); Enter(1); /* Please enter filename: */ pout(YELLOW, BLACK, (char *) Language(245)); colour(CFG.InputColourF, CFG.InputColourB); GetstrLC(filname, 80); if ((strcmp(filname, "") == 0)) { Enter(2); /* No filename entered, aborting */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(246)); Enter(1); Pause(); free(filname); free(tmpname); Refresh(); break; } if (*(filname) == '/' || *(filname) == ' ') { Enter(2); /* Illegal filename */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247)); Enter(1); Pause(); free(tmpname); free(filname); Refresh(); break; } snprintf(tmpname, PATH_MAX, "%s/%s/wrk/%s", CFG.bbs_usersdir, exitinfo.Name, filname); if ((fd = fopen(tmpname, "r")) == NULL) { WriteError("$Can't open %s", tmpname); Enter(2); /* File does not exist, please try again */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(296)); Enter(1); Pause(); } else { while ((fgets(filname, 80, fd)) != NULL) { for (i = 0; i < strlen(filname); i++) { if (*(filname + i) == '\0') break; if (*(filname + i) == '\n') *(filname + i) = '\0'; if (*(filname + i) == '\r') *(filname + i) = '\0'; } /* * Make sure that any tear or origin lines are * made invalid. */ if (strncmp(filname, (char *)"--- ", 4) == 0) filname[1] = 'v'; if (strncmp(filname, (char *)" * Origin:", 10) == 0) filname[1] = '+'; snprintf(Message[Line], TEXTBUFSIZE +1, "%s", filname); Line++; if ((Line - 1) == TEXTBUFSIZE) break; } fclose(fd); Changed = TRUE; Syslog('+', "FSEDIT: Inserted file %s", tmpname); } free(tmpname); free(filname); Col = 1; Refresh(); break; case KEY_ESCAPE: /* Editor menu */ Top_Menu(); ch = toupper(Readkey()); if (ch == 'A' || ch == 'S') { Syslog('b', "FSEDIT: %s message (%c)", (ch == 'S' && Changed) ? "Saving" : "Aborting", ch); clear(); chartran_close(); if (ch == 'S' && Changed) { Syslog('+', "FSEDIT: Message will be saved"); return TRUE; } else { Syslog('+', "FSEDIT: Message aborted"); return FALSE; } } if (ch == 'H') { Full_Help(); ch = Readkey(); Refresh(); } else Top_Help(); colour(CFG.TextColourF, CFG.TextColourB); Setcursor(); break; default: if ((ch > 31) || traduce((char *)&ch) ) { /* * Normal printable characters or hi-ascii */ if (Col == strlen(Message[CurRow]) + 1) { /* * Append to line */ snprintf(Message[CurRow] + strlen(Message[CurRow]), 5, "%c", ch); if (strlen(Message[CurRow]) > 79){ Col = FsWordWrap(); Row++; Refresh(); } else { Col++; PUTCHAR(ch); } Changed = TRUE; } else { /* * Insert or overwrite */ if (InsMode) { for (i = strlen(Message[CurRow]); i >= (Col-1); i--) { /* * Shift characters right */ Message[CurRow][i+1] = Message[CurRow][i]; } Message[CurRow][Col-1] = ch; Col++; if (strlen(Message[CurRow]) > 80) { i = FsWordWrap(); if (Col > strlen(Message[CurRow])+1) { Col = Col - strlen(Message[CurRow]); if (Col > 1) Col--; Row++; } if (Row > (rows -1)) ScrollDown(); else Refresh(); } else { locate(Row + 1, 1); PUTSTR(Message[CurRow]); Setcursor(); } Changed = TRUE; } else { Message[CurRow][Col-1] = ch; PUTCHAR(ch); Col++; Changed = TRUE; } } } } } chartran_close(); WriteError("FsEdit(): Impossible to be here"); return FALSE; }
void menu() { FILE *pMenuFile; int Key, IsANSI; char temp[81], *Input, *sMenuPathFileName, buf[81]; Input = calloc(PATH_MAX, sizeof(char)); sMenuPathFileName = calloc(PATH_MAX, sizeof(char)); Syslog('+', "Starting menu loop"); /* * Loop forever, this is what a BBS should do until a user logs out. */ while (TRUE) { WhosDoingWhat(BROWSING, NULL); /* * Open menufile, first users language menu, if it fails * try to open the default menu. */ snprintf(sMenuPathFileName, PATH_MAX, "%s/share/int/menus/%s/%s", getenv("FTND_ROOT"), lang.lc, Menus[MenuLevel]); if ((pMenuFile = fopen(sMenuPathFileName, "r")) == NULL) { snprintf(sMenuPathFileName, PATH_MAX, "%s/share/int/menus/%s/%s", getenv("FTND_ROOT"), CFG.deflang, Menus[MenuLevel]); pMenuFile = fopen(sMenuPathFileName,"r"); if (pMenuFile != NULL) Syslog('b', "Menu %s (Default)", Menus[MenuLevel]); } else { Syslog('b', "Menu %s (%s)", Menus[MenuLevel], lang.Name); } if (pMenuFile == NULL) { clear(); WriteError("Can't open menu file: %s", sMenuPathFileName); MenuError++; /* * Is this the last attempt to open the default menu? */ if (MenuError == 10) { WriteError("FATAL ERROR: Too many menu errors"); snprintf(temp, 81, "Too many menu errors, notifying Sysop\r\n\r\n"); PUTSTR(temp); sleep(3); die(FTNERR_CONFIG_ERROR); } /* * Switch back to the default menu */ MenuLevel = 0; strcpy(Menus[0], CFG.default_menu); } else { /* * Display Menu Text Fields and Perform all autoexec menus in order of menu file. * First check if there are any ANSI menus, if not, send a clearscreen first. */ IsANSI = FALSE; while (fread(&menus, sizeof(menus), 1, pMenuFile) == 1) { if ( Le_Access(exitinfo.Security, menus.MenuSecurity) && (UserAge >= le_int(menus.Age))){ if ((le_int(menus.MenuType) == 5) || (le_int(menus.MenuType) == 19) || (le_int(menus.MenuType) == 20)) IsANSI = TRUE; } } fseek(pMenuFile, 0, SEEK_SET); if (! IsANSI) clear(); while (fread(&menus, sizeof(menus), 1, pMenuFile) == 1) { if ( Le_Access(exitinfo.Security, menus.MenuSecurity) && (UserAge >= le_int(menus.Age))){ if (menus.AutoExec) { DoMenu( le_int(menus.MenuType) ); } DisplayMenu( ); } } /* * Check if the BBS closed down for Zone Mail Hour or * system shutdown. If so, we run the Goodbye show. */ if (CheckStatus() == FALSE) { fclose(pMenuFile); Syslog('+', "Kicking user out, the BBS is closed."); sleep(3); Good_Bye(FTNERR_OK); } /* * Check the upsdown semafore */ if (IsSema((char *)"upsdown")) { fclose(pMenuFile); Syslog('+', "Kicking user out, upsdown semafore detected"); snprintf(temp, 81, "System power failure, closing the bbs"); PUTSTR(temp); Enter(2); sleep(3); Good_Bye(FTNERR_OK); } /* * Check if SysOp wants to chat to user everytime user gets prompt. */ if (CFG.iChatPromptChk) { snprintf(buf, 81, "CISC:1,%d", mypid); if (socket_send(buf) == 0) { strcpy(buf, socket_receive()); if (strcmp(buf, "100:1,1;") == 0) { Syslog('+', "Forced sysop/user chat"); Chat(exitinfo.Name, (char *)"#sysop"); continue; } } } /* * Check users timeleft */ TimeCheck(); alarm_on(); if (exitinfo.HotKeys) { Key = Readkey(); snprintf(Input, 81, "%c", Key); Enter(1); } else { colour(CFG.InputColourF, CFG.InputColourB); GetstrC(Input, 80); } if ((strcmp(Input, "")) != 0) { fseek(pMenuFile, 0, SEEK_SET); while (fread(&menus, sizeof(menus), 1, pMenuFile) == 1) { if ((strcmp(tu(Input), menus.MenuKey)) == 0) { if ((Le_Access(exitinfo.Security, menus.MenuSecurity)) && (UserAge >= le_int(menus.Age))) { Syslog('+', "Menu[%d] %d=(%s), Opt: '%s'", MenuLevel, le_int(menus.MenuType), menus.TypeDesc, menus.OptionalData); if (le_int(menus.MenuType) == 13) { /* * Terminate call, cleanup here */ free(Input); free(sMenuPathFileName); fclose(pMenuFile); } DoMenu(le_int(menus.MenuType)); break; } } } } fclose(pMenuFile); } /* If menu open */ } /* while true */ }
void Write_Email(void) { faddr *Dest = NULL; int i; char *orgbox; if (HasNoEmail()) return; orgbox = xstrcpy(sMailbox); SetEmailArea((char *)"mailbox"); WhosDoingWhat(READ_POST, NULL); clear(); for (i = 0; i < (TEXTBUFSIZE + 1); i++) Message[i] = (char *) calloc(MAX_LINE_LENGTH +1, sizeof(char)); Line = 1; Msg_New(); Enter(1); colour(LIGHTBLUE, BLACK); /* Posting message in area: */ pout(LIGHTBLUE, BLACK, (char *) Language(156)); PUTSTR((char *)"\"mailbox\""); Enter(2); /* From : */ pout(YELLOW, BLACK, (char *) Language(157)); if (CFG.EmailMode != E_PRMISP) { /* * If not permanent connected to the internet, use fidonet.org style addressing. */ Dest = fido2faddr(CFG.EmailFidoAka); snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.sUserName, ascinode(Dest, 0x2f), exitinfo.sUserName); } else snprintf(Msg.From, 101, "%s@%s (%s)", exitinfo.Name, CFG.sysdomain, exitinfo.sUserName); for (i = 0; i < strlen(Msg.From); i++) { if (Msg.From[i] == ' ') Msg.From[i] = '_'; if (Msg.From[i] == '@') break; } pout(CFG.MsgInputColourF, CFG.MsgInputColourB, Msg.From); Syslog('b', "Setting From: %s", Msg.From); Enter(1); /* To : */ pout(YELLOW, BLACK, (char *) Language(158)); colour(CFG.MsgInputColourF, CFG.MsgInputColourB); alarm_on(); GetstrU(Msg.To, 63); if ((strcmp(Msg.To, "")) == 0) { for (i = 0; i < (TEXTBUFSIZE + 1); i++) free(Message[i]); SetEmailArea(orgbox); free(orgbox); return; } /* Subject : */ pout(YELLOW, BLACK, (char *) Language(161)); colour(CFG.MsgInputColourF, CFG.MsgInputColourB); alarm_on(); GetstrP(Msg.Subject, 65, 0); mbse_CleanSubject(Msg.Subject); if ((strcmp(Msg.Subject, "")) == 0) { Enter(1); /* Abort Message [y/N] ?: */ pout(CYAN, BLACK, (char *) Language(162)); alarm_on(); if (toupper(Readkey()) == Keystroke(162, 0)) { for (i = 0; i < (TEXTBUFSIZE + 1); i++) free(Message[i]); SetEmailArea(orgbox); free(orgbox); return; } } Msg.Private = TRUE; if (Edit_Msg()) { Save_Email(FALSE); } for (i = 0; i < (TEXTBUFSIZE + 1); i++) free(Message[i]); SetEmailArea(orgbox); free(orgbox); }
/* * The panel bar under the message while email reading */ int EmailPanel(void) { int input; WhosDoingWhat(READ_POST, NULL); /* (A)gain, (N)ext, (L)ast, (R)eply, (E)nter, (D)elete, (Q)uit, e(X)port */ pout(WHITE, RED, (char *) Language(214)); if (exitinfo.Security.level >= CFG.sysop_access) PUTSTR((char *)", (!)"); PUTSTR((char *)": "); alarm_on(); input = toupper(Readkey()); if (input == '!') { if (exitinfo.Security.level >= CFG.sysop_access) { if (Kludges) Kludges = FALSE; else Kludges = TRUE; Read_a_Email(LastNum); } } else if (input == Keystroke(214, 0)) { /* (A)gain */ Read_a_Email(LastNum); } else if (input == Keystroke(214, 4)) { /* (P)ost */ Write_Email(); Read_a_Email(LastNum); } else if (input == Keystroke(214, 2)) { /* (L)ast */ if (LastNum > EmailBase.Lowest) LastNum--; Read_a_Email(LastNum); } else if (input == Keystroke(214, 3)) { /* (R)eply */ Reply_Email(TRUE); Read_a_Email(LastNum); } else if (input == Keystroke(214, 5)) { /* (Q)uit */ /* Quit */ pout(WHITE, BLACK, (char *) Language(189)); Enter(1); return FALSE; } else if (input == Keystroke(214, 7)) { /* e(X)port */ Export_a_Email(LastNum); Read_a_Email(LastNum); } else if (input == '+') { if (Msg.Reply) LastNum = Msg.Reply; Read_a_Email(LastNum); } else if (input == '-') { if (Msg.Original) LastNum = Msg.Original; Read_a_Email(LastNum); } else if (input == Keystroke(214, 6)) { /* (D)elete */ // Delete_EmailNum(LastNum); if (LastNum < EmailBase.Highest) { LastNum++; Read_a_Email(LastNum); } else { return FALSE; } } else { /* Next */ pout(WHITE, BLACK, (char *) Language(216)); if (LastNum < EmailBase.Highest) LastNum++; else return FALSE; Read_a_Email(LastNum); } return TRUE; }
/* * Change default protocol. */ void Chg_Protocol() { FILE *pProtConfig; int iProt, iFoundProt = FALSE, precno = 0; char *temp, Prot[2]; temp = calloc(PATH_MAX, sizeof(char)); ReadExitinfo(); Set_Protocol(exitinfo.sProtocol); Syslog('+', "Old protocol %s", sProtName); while(TRUE) { snprintf(temp, PATH_MAX, "%s/etc/protocol.data", getenv("FTND_ROOT")); if ((pProtConfig = fopen(temp, "r")) == NULL) { WriteError("$Can't open %s", temp); /* Protocol: Can't open protocol file. */ Enter(1); PUTSTR((char *) Language(262)); Enter(2); Pause(); free(temp); fclose(pProtConfig); return; } fread(&PROThdr, sizeof(PROThdr), 1, pProtConfig); Enter(1); /* Select your preferred protocol */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(263)); Enter(2); while (fread(&PROT, PROThdr.recsize, 1, pProtConfig) == 1) { if (PROT.Available && Access(exitinfo.Security, PROT.Level)) { colour(LIGHTBLUE, BLACK); PUTCHAR('('); colour(WHITE, BLACK); PUTSTR(PROT.ProtKey); colour(LIGHTBLUE, BLACK); snprintf(temp, 81, ") %-20s Efficiency %3d %%\r\n", PROT.ProtName, PROT.Efficiency); PUTSTR(temp); } } Enter(1); pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(264)); alarm_on(); iProt = toupper(Readkey()); PUTCHAR(iProt); snprintf(Prot, 2, "%c", iProt); fseek(pProtConfig, PROThdr.hdrsize, 0); while (fread(&PROT, PROThdr.recsize, 1, pProtConfig) == 1) { if ((strncmp(PROT.ProtKey, Prot, 1) == 0) && PROT.Available && Access(exitinfo.Security, PROT.Level)) { strcpy(sProtName, PROT.ProtName); strcpy(sProtUp, PROT.ProtUp); strcpy(sProtDn, PROT.ProtDn); strcpy(sProtAdvice, PROT.Advice); uProtInternal = PROT.Internal; iProtEfficiency = PROT.Efficiency; iFoundProt = TRUE; } else precno++; } fclose(pProtConfig); if (iProt == 13) { free(temp); return; } else { if (!iFoundProt) { Enter(2); pout(LIGHTGREEN, BLACK, (char *) Language(265)); Enter(2); /* Loop for new attempt */ } else { Setup(exitinfo.sProtocol, sProtName); Enter(1); /* Protocol now set to: */ pout(LIGHTGREEN, BLACK, (char *) Language(266)); PUTSTR(sProtName); Enter(2); Pause(); break; } } } Syslog('+', "New protocol %s", sProtName); WriteExitinfo(); free(temp); }
int Chg_Language(int NewMode) { FILE *pLang; int iLang, iFoundLang = FALSE; char *temp; temp = calloc(PATH_MAX, sizeof(char)); if (!NewMode) ReadExitinfo(); while(TRUE) { snprintf(temp, PATH_MAX, "%s/etc/language.data", getenv("FTND_ROOT")); if(( pLang = fopen(temp, "r")) == NULL) { WriteError("$Can't open %s", temp); snprintf(temp, 81, "\nFATAL: Can't open language file\n\n"); PUTSTR(temp); Pause(); free(temp); return 0; } fread(&langhdr, sizeof(langhdr), 1, pLang); colour(CFG.HiliteF, CFG.HiliteB); /* Select your preferred language */ snprintf(temp, 81, "\r\n%s\r\n\r\n", (char *) Language(378)); PUTSTR(temp); iLang = 6; colour(LIGHTBLUE, BLACK); while (fread(&lang, langhdr.recsize, 1, pLang) == 1) if (lang.Available) { colour(LIGHTMAGENTA, BLACK); snprintf(temp, 81, "(%s)", lang.LangKey); PUTSTR(temp); colour(DARKGRAY, BLACK); snprintf(temp, 81, " %c ", 46); PUTSTR(temp); colour(CYAN, BLACK); snprintf(temp, 81, "%-29s ", lang.Name); PUTSTR(temp); iLang++; if ((iLang % 2) == 0) { PUTCHAR('\r'); PUTCHAR('\n'); } } Enter(1); colour(CFG.HiliteF, CFG.HiliteB); /* Select language: */ snprintf(temp, 81, "\n%s", (char *) Language(379)); PUTSTR(temp); alarm_on(); iLang = toupper(Readkey()); PUTCHAR(iLang); fseek(pLang, langhdr.hdrsize, 0); while (fread(&lang, langhdr.recsize, 1, pLang) == 1) { strcpy(lang.LangKey,tu(lang.LangKey)); if ((lang.LangKey[0] == iLang) && (lang.Available)) { strcpy(current_language, lang.lc); iFoundLang = TRUE; break; } } fclose(pLang); if(!iFoundLang) { Enter(2); /* Invalid selection, please try again! */ pout(LIGHTGREEN, BLACK, (char *) Language(265)); Enter(2); } else { exitinfo.iLanguage = iLang; strcpy(current_language, lang.lc); Free_Language(); InitLanguage(); colour(LIGHTGREEN, BLACK); /* Language now set to" */ snprintf(temp, 81, "\r\n\r\n%s%s\r\n\r\n", (char *) Language(380), lang.Name); PUTSTR(temp); if (!NewMode) { Syslog('+', "Changed language to %s", lang.Name); WriteExitinfo(); Pause(); } break; } } free(temp); Enter(1); return iLang; }
/* * Scan for new files, called from menu. */ int NewfileScan(int AskStart) { FILE *pAreas; int ifDate, itDate; char *temp, *Date; int Found, Count = 0; _Tag T; struct _fdbarea *fdb_area = NULL; Date = calloc(81, sizeof(char)); temp = calloc(81, sizeof(char)); iLineCount = 2; arecno = 1; /* Reset Area Number to One */ if (AskStart) { Enter(2); /* Search for new since your last call [Y/n]: */ pout(LIGHTCYAN, BLACK, (char *) Language(273)); colour(CFG.InputColourF, CFG.InputColourB); if (toupper(Readkey()) == Keystroke(273, 1)) { Enter(1); /* Enter new date to search for [DD-MM-YYYY]: */ pout(GREEN, BLACK, (char *) Language(274)); colour(CFG.InputColourF, CFG.InputColourB); GetDate(temp, 10); } else { strcpy(temp, LastLoginDate); } } else { strcpy(temp, LastLoginDate); } Syslog('+', "NewfileScan() since %s", temp); clear(); /* File Search by Date */ pout(WHITE, BLACK, (char *) Language(275)); Enter(2); Date[0] = temp[6]; /* Swap the date around */ Date[1] = temp[7]; /* Instead of DD-MM-YYYY */ Date[2] = temp[8]; /* Let it equal YYYYMMDD */ Date[3] = temp[9]; /* Swap the date around */ Date[4] = temp[3]; /* Swap the date around */ Date[5] = temp[4]; /* because when you convert */ Date[6] = temp[0]; /* a string to an int you */ Date[7] = temp[1]; /* loose the front Zero */ Date[8] = '\0'; /* making the number smaller */ itDate = atol(Date); InitTag(); if ((pAreas = OpenFareas(FALSE)) == NULL) return 0; while (fread(&area, areahdr.recsize, 1, pAreas) == 1) { if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0) && (area.New)) { if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) { Sheader(); Found = FALSE; Nopper(); while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) { strcpy(temp, StrDateDMY(fdb.UploadDate)); /* Realloc Space for Date */ Date[0] = temp[6]; /* Swap the date around */ Date[1] = temp[7]; /* Instead of DD-MM-YYYY */ Date[2] = temp[8]; /* Let it equal YYYYMMDD */ Date[3] = temp[9]; /* Swap the date around */ Date[4] = temp[3]; /* Swap the date around */ Date[5] = temp[4]; /* because when you convert */ Date[6] = temp[0]; /* a string to an int you */ Date[7] = temp[1]; /* loose the front Zero */ Date[8] = '\0'; /* making the number smaller */ /* and invalid to this cause */ ifDate = atol(Date); if (ifDate >= itDate) { if (!Found) { Enter(2); if (iLC(2) == 1) { free(Date); free(temp); mbsedb_CloseFDB(fdb_area); fclose(pAreas); return 1; } Found = TRUE; } memset(&T, 0, sizeof(T)); T.Area = arecno; T.Active = FALSE; T.Size = fdb.Size; strncpy(T.SFile, fdb.Name, 12); strncpy(T.LFile, fdb.LName, 80); SetTag(T); Count++; if (ShowOneFile() == 1) { free(Date); free(temp); mbsedb_CloseFDB(fdb_area); fclose(pAreas); return 1; } } /* End of if */ } /* End of while */ mbsedb_CloseFDB(fdb_area); /* * Add 2 blank lines after found files. */ if (Found) { Enter(2); if (iLC(2) == 1) { free(Date); free(temp); fclose(pAreas); return 1; } } } /* End of open filebase */ } /* End of check new files scan */ arecno++; /* Go to next file area */ } /* End of Main */ if (Count) Syslog('+', "Found %d new files", Count); fclose(pAreas); Enter(1); if (Count) Mark(); else Pause(); free(temp); free(Date); return 1; }
/* * Edit the list of tagged files. */ void EditTaglist() { FILE *tf; int i, x, Fg, Count; char *temp; if ((tf = fopen("taglist", "r+")) == NULL) { Enter(1); /* No files tagged. */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(361)); Enter(2); Pause(); return; } temp = calloc(81, sizeof(char)); if (utf8) chartran_init((char *)"CP437", (char *)"UTF-8", 'B'); while (TRUE) { clear(); fseek(tf, 0, SEEK_SET); Count = 0; /* # Area Active Size Cost File */ /* 123 12345 123456 12345678 12345 */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(355)); Enter(1); colour(LIGHTGREEN, BLACK); PUTSTR(chartran(fLine_str(79))); while ((fread(&Tag, sizeof(Tag), 1, tf) == 1)) { Count++; if (Tag.Active) Fg = WHITE; else Fg = LIGHTGRAY; snprintf(temp, 81, "%3d ", Count); pout(Fg, BLACK, temp); Fg--; snprintf(temp, 81, "%5d ", Tag.Area); pout(Fg, BLACK, temp); Fg--; if (Tag.Active) /* Yes */ snprintf(temp, 81, "%-6s ", (char *) Language(356)); else /* No */ snprintf(temp, 81, "%-6s ", (char *) Language(357)); pout(Fg, BLACK, temp); Fg--; snprintf(temp, 81, "%8d ", (int)(Tag.Size)); pout(Fg, BLACK, temp); Fg--; snprintf(temp, 81, "%5d ", Tag.Cost); pout(Fg, BLACK, temp); Fg--; snprintf(temp, 81, "%s", Tag.LFile); pout(Fg, BLACK, temp); Enter(1); } colour(LIGHTGREEN, BLACK); PUTSTR(chartran(fLine_str(79))); /* (T)oggle active, (E)rase all, (ENTER) to continue: */ pout(WHITE, RED, (char *) Language(358)); i = toupper(Readkey()); colour(CFG.CRColourF, CFG.CRColourB); if (i == Keystroke(358, 0)) { Enter(2); /* Enter file number, 1.. */ snprintf(temp, 81, "%s%d ", (char *) Language(359), Count); PUTSTR(temp); GetstrC(temp, 5); x = atoi(temp); if ((x > 0) && (x <= Count)) { if (fseek(tf, (x - 1) * sizeof(Tag), SEEK_SET) == 0) { if (fread(&Tag, sizeof(Tag), 1, tf) == 1) { if (Tag.Active) Tag.Active = FALSE; else Tag.Active = TRUE; fseek(tf,(x - 1) * sizeof(Tag), SEEK_SET); fwrite(&Tag, sizeof(Tag), 1, tf); } } } } chartran_close(); if (i == Keystroke(358, 1)) { fclose(tf); unlink("taglist"); free(temp); return; } if ((i == '\r') || (i == '\n')) { fclose(tf); free(temp); return; } } }
/* * Delete files from home directory */ void Delete_Home() { char *temp, *temp1, msg[81]; int i; temp = calloc(PATH_MAX, sizeof(char)); temp1 = calloc(PATH_MAX, sizeof(char)); snprintf(temp, PATH_MAX, "%s/%s/wrk/", CFG.bbs_usersdir, exitinfo.Name); Enter(1); /* Please enter filename to delete: */ pout(LIGHTBLUE, BLACK, (char *) Language(292)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(temp1, 80); if (strcmp(temp1, "") == 0) { free(temp); free(temp1); return; } if (temp1[0] == '.') { Enter(1); /* Sorry you may not delete hidden files ...*/ pout(LIGHTRED, BLACK, (char *) Language(293)); } else { strcat(temp, temp1); if ((access(temp, R_OK)) == 0) { Enter(1); /* Delete file: */ /* Are you Sure? [Y/n]: */ snprintf(msg, 81, "%s %s, %s", (char *) Language(368), temp1, (char *) Language(369)); pout(LIGHTGREEN, BLACK, msg); i = toupper(Readkey()); if (i == Keystroke(369, 0) || i == 13) { i = unlink(temp); if (i == -1) { Enter(1); /* Unable to delete file ... */ pout(LIGHTRED, BLACK, (char *) Language(294)); } else { Syslog('+', "Delete %s from homedir", temp1); } } else { Enter(2); /* Aborting ... */ pout(DARKGRAY, BLACK, (char *) Language(116)); } } else { Enter(1); /* Invalid filename, please try again ... */ pout(LIGHTRED, BLACK, (char *) Language(295)); } } Enter(2); free(temp); free(temp1); Pause(); }
/* * Edit signature file with a simple line editor. */ int editsignature(void) { FILE *fp; int i, x; char *temp, *temp1; temp = calloc(PATH_MAX, sizeof(char)); temp1 = calloc(PATH_MAX, sizeof(char)); snprintf(temp, PATH_MAX, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name); while (TRUE) { Enter(1); /* Functions available: */ poutCR(CFG.HiliteF, CFG.HiliteB, (char *) Language(113)); Enter(1); /* (L)ist, (R)eplace text, (E)dit line, (A)bort, (S)ave */ pout(YELLOW, RED, (char *) Language(114)); Enter(2); /* Select: */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(115)); alarm_on(); i = toupper(Readkey()); Enter(1); if (i == Keystroke(114, 3)) { /* Aborting... */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(116)); Syslog('+', "User aborted .signature editor"); free(temp); free(temp1); return TRUE; } else if (i == Keystroke(114, 2)) { Enter(1); /* Edit which line: */ snprintf(temp, 80, " %s", (char *) Language(118)); pout(CFG.HiliteF, CFG.HiliteB, temp); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(temp, 3); if ((strcmp(temp, "")) == 0) break; i = atoi(temp); if ((i < 1) || (i > MAXSIGLINES)) { Enter(1); /* Line does not exist. */ poutCR(LIGHTRED, BLACK, (char *) Language(119)); break; } x = strlen(sLiNE[i-1]); snprintf(temp, 80, "%d:", i); pout(LIGHTRED, BLACK, temp); pout(CFG.InputColourF, CFG.InputColourB, sLiNE[i-1]); GetstrP(sLiNE[i-1], LENSIGLINES-1, x); } else if (i == Keystroke(114, 0)) { /* List lines */ toprow(); for (i = 0; i < MAXSIGLINES; i++) { snprintf(temp, 80, "%d:", i+1); pout(LIGHTRED, BLACK, temp); poutCR(CFG.MoreF, CFG.MoreB, sLiNE[i]); } botrow(); } else if (i == Keystroke(114, 4)) { Enter(1); /* Saving... */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(340)); /* Open TextFile for Writing NextUser Info */ snprintf(temp, PATH_MAX, "%s/%s/.signature", CFG.bbs_usersdir, exitinfo.Name); if ((fp = fopen(temp, "w")) == NULL) { WriteError("$Can't open %s", temp); free(temp); free(temp1); return TRUE; } for (i = 0; i < MAXSIGLINES; i++) { if (strlen(sLiNE[i])) fprintf(fp, "%s\n", sLiNE[i]); } fclose(fp); Syslog('+', "User Saved .signature"); free(temp); free(temp1); return TRUE; } else if (i == Keystroke(114, 1)) { Enter(1); /* Edit which line: */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(118)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(temp, 3); if ((strcmp(temp, "")) == 0) break; i = atoi(temp); if ((i < 1) || (i > MAXSIGLINES)) { Enter(1); /* Line does not exist. */ poutCR(LIGHTRED, BLACK, (char *) Language(119)); break; } Enter(1); /* Line reads: */ poutCR(CFG.MoreF, CFG.MoreB, (char *) Language(186)); snprintf(temp, 81, "%d:%s", i, sLiNE[i-1]); poutCR(CFG.MoreF, CFG.MoreB, temp); Enter(1); /* Text to replace: */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(195)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(temp, LENSIGLINES-1); if ((strcmp(temp, "")) == 0) break; /* Replacement text: */ pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(196)); colour(CFG.InputColourF, CFG.InputColourB); GetstrC(temp1, LENSIGLINES-1); if ((strcmp(temp1, "")) == 0) break; strreplace(sLiNE[i-1], temp, temp1); } else Enter(1); } free(temp); free(temp1); return FALSE; }