From e04792e4cb5ab92c46fa8ea0439ffb8c757cd208 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Mon, 8 Jul 2002 19:40:22 +0000 Subject: [PATCH] Several bugfixes --- ChangeLog | 16 + lang/dutch.txt | 2 +- mbfido/makestat.c | 8 +- mbsebbs/funcs.c | 46 +- mbsebbs/newuser.c | 1113 +++++++++++++++++++++++---------------------- mbsebbs/page.c | 377 +++++++-------- mbtask/calllist.c | 5 +- mbtask/outstat.c | 10 +- 8 files changed, 801 insertions(+), 776 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7ad5e1a..6a67476d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,12 +4,28 @@ $Id$ v0.35.03 06-Jul-2002 + lang: + Corrected a spelling error in the Dutch language file. + mbcico: Changed IsDoing information. + newuser: + Check for Unix accounts is now case sensitive. + Check existing usernames now also checks handles. + + mbsebbs: + Check existing usernames now also checks handles. + When a user paged the sysop for a chat, after the timer was + expired, the bbs crashed. + mbtask: Changed logging of multiple logmessages that are equal. Changed semafore debug logmessages. + Fixed log problem not always showing the Call flag. + Now forces callmode to None if the callflag was cleared. + The test to add a node to the calllist now also checks the + internal call flag. v0.35.02 22-Jun-2002 - 06-Jul-2002 diff --git a/lang/dutch.txt b/lang/dutch.txt index d0478b74..7bc8c120 100644 --- a/lang/dutch.txt +++ b/lang/dutch.txt @@ -380,7 +380,7 @@ JN|Zeker weten? [J/n]: |Kies taal: |De taal is nu: |Het systeem zal nu een "Unix gebruikersnaam" vragen -|Uw "Unix gerbuikersnaam" is gemaakt, U kunt dit de volgende keer gebruiken. +|Uw "Unix gebruikersnaam" is gemaakt, U kunt dit de volgende keer gebruiken. |Geef een inlog naam (Maximaal 8 karakters, kleine letters) |bv. Piet Snot, login = psnot |login > diff --git a/mbfido/makestat.c b/mbfido/makestat.c index 7a81ae3a..874d64ed 100644 --- a/mbfido/makestat.c +++ b/mbfido/makestat.c @@ -101,7 +101,7 @@ char *adate(time_t now) struct tm ptm; if (now == 0L) { - sprintf(buf, "N/A"); + sprintf(buf, " "); } else { ptm = *localtime(&now); sprintf(buf, "%02d-%02d-%04d %02d:%02d", ptm.tm_mday, ptm.tm_mon +1, ptm.tm_year + 1900, @@ -148,7 +148,7 @@ void MakeStat(void) fseek(fi, fileptr, SEEK_SET); MacroVars("b", "s", mgroup.Name); MacroVars("c", "s", mgroup.Comment); - MacroVars("d", "s", aka2str(mgroup.UseAka)); + MacroVars("d", "s", mgroup.UseAka.zone ? aka2str(mgroup.UseAka):" "); MacroVars("e", "s", adate(mgroup.LastDate)); MacroVars("f", "d", mgroup.MsgsRcvd.lweek); MacroVars("g", "d", mgroup.MsgsRcvd.month[Lm]); @@ -227,7 +227,7 @@ void MakeStat(void) fseek(fi, fileptr, SEEK_SET); MacroVars("b", "s", fgroup.Name); MacroVars("c", "s", fgroup.Comment); - MacroVars("d", "s", aka2str(fgroup.UseAka)); + MacroVars("d", "s", fgroup.UseAka.zone ? aka2str(fgroup.UseAka):" "); MacroVars("e", "s", adate(fgroup.LastDate)); MacroVars("f", "d", fgroup.Files.lweek); MacroVars("g", "d", fgroup.KBytes.lweek); @@ -343,7 +343,7 @@ void MakeStat(void) fseek(fi, fileptr, SEEK_SET); if (!strcmp(hist.aka.domain, "(null)")) hist.aka.domain[0] = '\0'; - MacroVars("c", "s", hist.aka.zone ? aka2str(hist.aka):"N/A"); + MacroVars("c", "s", hist.aka.zone ? aka2str(hist.aka):" "); MacroVars("d", "s", hist.system_name); MacroVars("e", "s", hist.sysop); MacroVars("f", "s", hist.location); diff --git a/mbsebbs/funcs.c b/mbsebbs/funcs.c index bebff062..7c8c11b8 100644 --- a/mbsebbs/funcs.c +++ b/mbsebbs/funcs.c @@ -78,39 +78,33 @@ int CheckStatus() /* - * Function to check if UserName exists and returns a 0 or 1 + * Function to check if UserName/Handle exists and returns a 0 or 1 */ int CheckName(char *Name) { - FILE *fp; - int Status = FALSE; - char *temp, *temp1; - struct userhdr ushdr; - struct userrec us; + FILE *fp; + int Status = FALSE; + char *temp; + struct userhdr ushdr; + struct userrec us; - temp = calloc(PATH_MAX, sizeof(char)); - temp1 = calloc(81, sizeof(char)); + temp = calloc(PATH_MAX, sizeof(char)); - strcpy(temp1, tl(Name)); + sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT")); + if ((fp = fopen(temp,"rb")) != NULL) { + fread(&ushdr, sizeof(ushdr), 1, fp); - sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT")); - if ((fp = fopen(temp,"rb")) != NULL) { - fread(&ushdr, sizeof(ushdr), 1, fp); + while (fread(&us, ushdr.recsize, 1, fp) == 1) { + if ((strcasecmp(Name, us.sUserName) == 0) || (strcasecmp(Name, us.sHandle) == 0)) { + Status = TRUE; + break; + } + } + fclose(fp); + } - while (fread(&us, ushdr.recsize, 1, fp) == 1) { - strcpy(temp, tl(us.sUserName)); - - if((strcmp(temp, temp1)) == 0) { - Status = TRUE; - break; - } - } - fclose(fp); - } - - free(temp); - free(temp1); - return Status; + free(temp); + return Status; } diff --git a/mbsebbs/newuser.c b/mbsebbs/newuser.c index 561a552b..f0418f5b 100644 --- a/mbsebbs/newuser.c +++ b/mbsebbs/newuser.c @@ -73,513 +73,515 @@ int do_mailout = FALSE; /* Just for linking */ */ int newuser() { - FILE *pUsrConfig; - int i, x, Found, iLang, recno = 0, Count = 0; - unsigned long crc; - char temp[PATH_MAX], *FullName; - char *temp1, *temp2; - char *Phone1, *Phone2; - long offset; - struct userrec us; - int badname; + FILE *pUsrConfig; + int i, x, Found, iLang, recno = 0, Count = 0, badname; + unsigned long crc; + char temp[PATH_MAX], *FullName, *temp1, *temp2, *Phone1, *Phone2; + long offset; + struct userrec us; - IsDoing("New user login"); - Syslog('+', "Newuser registration"); - clear(); - DisplayFile((char *)"newuser"); - if ((iLang = Chg_Language(TRUE)) == 0) - Fast_Bye(1); + IsDoing("New user login"); + Syslog('+', "Newuser registration"); + clear(); + DisplayFile((char *)"newuser"); + if ((iLang = Chg_Language(TRUE)) == 0) + Fast_Bye(1); + Enter(1); + /* MBSE BBS - NEW USER REGISTRATION */ + language(CYAN, BLACK, 37); + Enter(2); + + memset(&usrconfig, 0, sizeof(usrconfig)); + memset(&exitinfo, 0, sizeof(exitinfo)); + + temp1 = calloc(81, sizeof(char)); + temp2 = calloc(81, sizeof(char)); + Phone1 = calloc(81, sizeof(char)); + Phone2 = calloc(81, sizeof(char)); + FullName = calloc(81, sizeof(char)); + + usrconfig.iLanguage = iLang; + usrconfig.MsgEditor = FSEDIT; + + do { + + /* Please enter your First and Last name: */ + language(CYAN, BLACK, 0); + fflush(stdout); + alarm_on(); + Getname(temp, 35); + strcpy(FullName, tlcap(temp)); + Syslog('+', "Name entered: %s", FullName); + + /* + * Secret escape name + */ + if ((strcasecmp(temp, "off")) == 0) { + Syslog('+', "Quick \"off\" logout"); + Fast_Bye(0); + } + + Count++; + if (Count >= CFG.iCRLoginCount) { + Enter(1); + /* Disconnecting user ... */ + language(CFG.HiliteF, CFG.HiliteB, 2); + Enter(2); + Syslog('!', "Exceeded maximum login attempts"); + Fast_Bye(0); + } + + /* + * Check name, duplicate names, unwanted names, single names, they all get + * the same errormessage. + */ + badname = (BadNames(temp) || (CheckName(temp) || (strchr(temp, ' ') == NULL))); + if (badname) { + /* That login name already exists, please choose another one. */ + language(LIGHTRED, BLACK, 386); + Enter(1); + } + + } while (badname); + + strcpy(FullName, tlcap(temp)); + UserCity(mypid, FullName, (char *)"Unknown"); + + while (TRUE) { Enter(1); - /* MBSE BBS - NEW USER REGISTRATION */ - language(CYAN, BLACK, 37); - Enter(2); - - memset(&usrconfig, 0, sizeof(usrconfig)); - memset(&exitinfo, 0, sizeof(exitinfo)); - - temp1 = calloc(81, sizeof(char)); - temp2 = calloc(81, sizeof(char)); - Phone1 = calloc(81, sizeof(char)); - Phone2 = calloc(81, sizeof(char)); - FullName = calloc(81, sizeof(char)); - - usrconfig.iLanguage = iLang; - usrconfig.MsgEditor = FSEDIT; - - do { - - /* Please enter your First and Last name: */ - language(CYAN, BLACK, 0); + /* Please enter new password : */ + language(LIGHTCYAN, BLACK, 39); + fflush(stdout); + alarm_on(); + Getpass(temp1); + if ((x = strlen(temp1)) >= CFG.password_length) { + Enter(1); + /* Please enter password again : */ + language(LIGHTCYAN, BLACK, 40); fflush(stdout); alarm_on(); - Getname(temp, 35); - strcpy(FullName, tlcap(temp)); - Syslog('+', "Name entered: %s", FullName); - - /* - * Secret escape name - */ - if ((strcasecmp(temp, "off")) == 0) { - Syslog('+', "Quick \"off\" logout"); - Fast_Bye(0); - } - - Count++; - if (Count >= CFG.iCRLoginCount) { - Enter(1); - /* Disconnecting user ... */ - language(CFG.HiliteF, CFG.HiliteB, 2); + Getpass(temp2); + if ((i = strcmp(temp1,temp2)) != 0) { Enter(2); - Syslog('!', "Exceeded maximum login attempts"); - Fast_Bye(0); + /* Your passwords do not match! Try again. */ + language(LIGHTRED, BLACK, 41); + Enter(1); + } else { + crc = StringCRC32(tu(temp1)); + break; } + } else { + Enter(2); + /* Your password must contain at least */ + language(LIGHTRED, BLACK, 42); + printf("%d ", CFG.password_length); + /* characters! Try again. */ + language(WHITE, BLACK, 43); + Enter(1); + } + } + + memset(&usrconfig.Password, 0, sizeof(usrconfig.Password)); + sprintf(usrconfig.Password, "%s", temp2); + alarm_on(); + sprintf(UnixName, "%s", (char *) NameCreate(NameGen(FullName), FullName, temp2)); + + strcpy(usrconfig.sUserName, FullName); + strcpy(usrconfig.Name, UnixName); + Time_Now = time(NULL); + l_date = localtime(&Time_Now); + ltime = time(NULL); + + if (CFG.iAnsi) { + Enter(2); + /* Do you want ANSI and graphics mode [Y/n]: */ + language(LIGHTGRAY, BLACK, 44); + + alarm_on(); + i = toupper(getchar()); + + if (i == Keystroke(44, 0) || i == '\n') + usrconfig.GraphMode = TRUE; + else + usrconfig.GraphMode = FALSE; + } else { + usrconfig.GraphMode = TRUE; /* Default set it to ANSI */ + Enter(1); + } + exitinfo.GraphMode = usrconfig.GraphMode; + TermInit(exitinfo.GraphMode); + + if (CFG.iVoicePhone) { + while (1) { + Enter(1); + /* Please enter you Voice Number */ + language(LIGHTGREEN, BLACK, 45); + Enter(1); + + pout(LIGHTGREEN, BLACK, (char *)": "); + colour(CFG.InputColourF, CFG.InputColourB); + fflush(stdout); + alarm_on(); + GetPhone(temp, 16); + + if (strlen(temp) < 6) { + Enter(1); + /* Please enter a proper phone number */ + language(LIGHTRED, BLACK, 47); + Enter(1); + } else { + strcpy(usrconfig.sVoicePhone, temp); + strcpy(Phone1, temp); + break; + } + } + } /* End of first if statement */ + + if (CFG.iDataPhone) { + while (TRUE) { + Enter(1); + /* Please enter you Data Number */ + language(LIGHTGREEN, BLACK, 48); + Enter(1); + + pout(LIGHTGREEN, BLACK, (char *)": "); + colour(CFG.InputColourF, CFG.InputColourB); + alarm_on(); + GetPhone(temp, 16); /* - * Check name, duplicate names, unwanted names, single names, they all get - * the same errormessage. + * If no dataphone, copy voicephone. */ - badname = (BadNames(temp) || (CheckName(temp) || (strchr(temp, ' ') == NULL))); + if (strcmp(temp, "") == 0) { + strcpy(usrconfig.sDataPhone, usrconfig.sVoicePhone); + break; + } + + if (strlen(temp) < 6) { + Enter(1); + /* Please enter a proper phone number */ + language(LIGHTRED, BLACK, 47); + Enter(1); + } else { + strcpy(usrconfig.sDataPhone, temp); + strcpy(Phone2, temp); + break; + } + } + } /* End of if Statement */ + + if (!CFG.iDataPhone) + printf("\n"); + + if (CFG.iLocation) { + while (TRUE) { + Enter(1); + /* Enter your location */ + language(YELLOW, BLACK, 49); + colour(CFG.InputColourF, CFG.InputColourB); + alarm_on(); + if (CFG.iCapLocation) { /* Cap Location is turned on, Capitalise first letter */ + fflush(stdout); + GetnameNE(temp, 24); + } else + GetstrC(temp, 80); + + if (strlen(temp) < CFG.CityLen) { + Enter(1); + /* Please enter a longer location */ + language(LIGHTRED, BLACK, 50); + Enter(1); + printf("%s%d)", (char *) Language(74), CFG.CityLen); + Enter(1); + } else { + strcpy(usrconfig.sLocation, temp); + UserCity(mypid, FullName, temp); + break; + } + } + } + + if (CFG.AskAddress) { + while (TRUE) { + Enter(1); + /* Your address, maximum 3 lines (only visible for the sysop): */ + language(LIGHTMAGENTA, BLACK, 474); + Enter(1); + for (i = 0; i < 3; i++) { + colour(YELLOW, BLACK); + printf("%d: ", i+1); + colour(CFG.InputColourF, CFG.InputColourB); + fflush(stdout); + alarm_on(); + GetstrC(usrconfig.address[i], 40); + } + if (strlen(usrconfig.address[0]) || strlen(usrconfig.address[1]) || strlen(usrconfig.address[2])) + break; + Enter(1); + /* You need to enter your address here */ + language(LIGHTRED, BLACK, 475); + Enter(1); + } + } + + if (CFG.iHandle) { + do { + Enter(1); + /* Enter a handle (Enter to Quit): */ + language(LIGHTRED, BLACK, 412); + colour(CFG.InputColourF, CFG.InputColourB); + fflush(stdout); + alarm_on(); + Getname(temp, 34); + + badname = (BadNames(temp) || CheckName(temp)); if (badname) { + /* That login name already exists, please choose another one. */ language(LIGHTRED, BLACK, 386); Enter(1); - } - - } while (badname); - - strcpy(FullName, tlcap(temp)); - UserCity(mypid, FullName, (char *)"Unknown"); - - while (TRUE) { - Enter(1); - /* Please enter new password : */ - language(LIGHTCYAN, BLACK, 39); - fflush(stdout); - alarm_on(); - Getpass(temp1); - if((x = strlen(temp1)) >= CFG.password_length) { - Enter(1); - /* Please enter password again : */ - language(LIGHTCYAN, BLACK, 40); - fflush(stdout); - alarm_on(); - Getpass(temp2); - if((i = strcmp(temp1,temp2)) != 0) { - Enter(2); - /* Your passwords do not match! Try again. */ - language(LIGHTRED, BLACK, 41); - Enter(1); - } else { - crc = StringCRC32(tu(temp1)); - break; - } - } else { - Enter(2); - /* Your password must contain at least */ - language(LIGHTRED, BLACK, 42); - printf("%d ", CFG.password_length); - /* characters! Try again. */ - language(WHITE, BLACK, 43); - Enter(1); - } - } - - memset(&usrconfig.Password, 0, sizeof(usrconfig.Password)); - sprintf(usrconfig.Password, "%s", temp2); - alarm_on(); - sprintf(UnixName, "%s", (char *) NameCreate(NameGen(FullName), FullName, temp2)); - - strcpy(usrconfig.sUserName, FullName); - strcpy(usrconfig.Name, UnixName); - Time_Now = time(NULL); - l_date = localtime(&Time_Now); - ltime = time(NULL); - - if(CFG.iAnsi) { - Enter(2); - /* Do you want ANSI and graphics mode [Y/n]: */ - language(LIGHTGRAY, BLACK, 44); - - alarm_on(); - i = toupper(getchar()); - - if (i == Keystroke(44, 0) || i == '\n') - usrconfig.GraphMode = TRUE; - else - usrconfig.GraphMode = FALSE; - } else { - usrconfig.GraphMode = TRUE; /* Default set it to ANSI */ - Enter(1); - } - exitinfo.GraphMode = usrconfig.GraphMode; - TermInit(exitinfo.GraphMode); - - if (CFG.iVoicePhone) { - while (1) { - Enter(1); - /* Please enter you Voice Number */ - language(LIGHTGREEN, BLACK, 45); - Enter(1); - - pout(LIGHTGREEN, BLACK, (char *)": "); - colour(CFG.InputColourF, CFG.InputColourB); - fflush(stdout); - alarm_on(); - GetPhone(temp, 16); - - if (strlen(temp) < 6) { - Enter(1); - /* Please enter a proper phone number */ - language(LIGHTRED, BLACK, 47); - Enter(1); - } else { - strcpy(usrconfig.sVoicePhone, temp); - strcpy(Phone1, temp); - break; - } - } - } /* End of first if statement */ - - if (CFG.iDataPhone) { - while (TRUE) { - Enter(1); - /* Please enter you Data Number */ - language(LIGHTGREEN, BLACK, 48); - Enter(1); - - pout(LIGHTGREEN, BLACK, (char *)": "); - colour(CFG.InputColourF, CFG.InputColourB); - alarm_on(); - GetPhone(temp, 16); - - /* - * If no dataphone, copy voicephone. - */ - if (strcmp(temp, "") == 0) { - strcpy(usrconfig.sDataPhone, usrconfig.sVoicePhone); - break; - } - - if( strlen(temp) < 6) { - Enter(1); - /* Please enter a proper phone number */ - language(LIGHTRED, BLACK, 47); - Enter(1); - } else { - strcpy(usrconfig.sDataPhone, temp); - strcpy(Phone2, temp); - break; - } - } - } /* End of if Statement */ - - if(!CFG.iDataPhone) - printf("\n"); - - if (CFG.iLocation) { - while (TRUE) { - Enter(1); - /* Enter your location */ - language(YELLOW, BLACK, 49); - colour(CFG.InputColourF, CFG.InputColourB); - alarm_on(); - if (CFG.iCapLocation) { /* Cap Location is turn on, Capitalise first letter */ - fflush(stdout); - GetnameNE(temp, 24); - } else - GetstrC(temp, 80); - - if( strlen(temp) < CFG.CityLen) { - Enter(1); - /* Please enter a longer location */ - language(LIGHTRED, BLACK, 50); - Enter(1); - printf("%s%d)", (char *) Language(74), CFG.CityLen); - Enter(1); - } else { - strcpy(usrconfig.sLocation, temp); - UserCity(mypid, FullName, temp); - break; - } - } - } - - if (CFG.AskAddress) { - while (TRUE) { - Enter(1); - /* Your address, maximum 3 lines (only visible for the sysop): */ - language(LIGHTMAGENTA, BLACK, 474); - Enter(1); - for (i = 0; i < 3; i++) { - colour(YELLOW, BLACK); - printf("%d: ", i+1); - colour(CFG.InputColourF, CFG.InputColourB); - fflush(stdout); - alarm_on(); - GetstrC(usrconfig.address[i], 40); - } - if (strlen(usrconfig.address[0]) || strlen(usrconfig.address[1]) || strlen(usrconfig.address[2])) - break; - Enter(1); - /* You need to enter your address here */ - language(LIGHTRED, BLACK, 475); - Enter(1); - } - } - - if (CFG.iHandle) { - Enter(1); - /* Enter a handle (Enter to Quit): */ - language(LIGHTRED, BLACK, 412); - colour(CFG.InputColourF, CFG.InputColourB); - fflush(stdout); - alarm_on(); - Getname(temp, 34); - + } else { if(strcmp(temp, "") == 0) - strcpy(usrconfig.sHandle, ""); + strcpy(usrconfig.sHandle, ""); else - strcpy(usrconfig.sHandle, temp); - } + strcpy(usrconfig.sHandle, temp); + } + } while (badname); + } - /* - * Note, the users database always contains the english sex - */ - if(CFG.iSex) { - while (TRUE) { - Enter(1); - /* What is your sex? (M)ale or (F)emale: */ - language(LIGHTBLUE, BLACK, 51); - colour(CFG.InputColourF, CFG.InputColourB); - fflush(stdout); - alarm_on(); - i = toupper(Getone()); + /* + * Note, the users database always contains the english sex + */ + if (CFG.iSex) { + while (TRUE) { + Enter(1); + /* What is your sex? (M)ale or (F)emale: */ + language(LIGHTBLUE, BLACK, 51); + colour(CFG.InputColourF, CFG.InputColourB); + fflush(stdout); + alarm_on(); + i = toupper(Getone()); - if (i == Keystroke(51, 0)) { - /* Male */ - sprintf(usrconfig.sSex, "Male"); - pout(CFG.InputColourF, CFG.InputColourB, (char *) Language(52)); - Enter(1); - break; - } else - if (i == Keystroke(51, 1)) { - /* Female */ - sprintf(usrconfig.sSex, "Female"); - pout(CFG.InputColourF, CFG.InputColourB, (char *) Language(53)); - Enter(1); - break; - } else { - Enter(2); - /* Please answer M or F */ - language(LIGHTRED, BLACK, 54); - Enter(1); - } - } - } else /* End of if Statement */ - sprintf(usrconfig.sSex, "Unknown"); /* If set off, set to Unknown */ - - if (CFG.iDOB) { - while (TRUE) { + if (i == Keystroke(51, 0)) { + /* Male */ + sprintf(usrconfig.sSex, "Male"); + pout(CFG.InputColourF, CFG.InputColourB, (char *) Language(52)); Enter(1); - /* Please enter your Date of Birth DD-MM-YYYY: */ - pout(CYAN, BLACK, (char *) Language(56)); - colour(CFG.InputColourF, CFG.InputColourB); - fflush(stdout); - alarm_on(); - GetDate(temp, 10); + break; + } else if (i == Keystroke(51, 1)) { + /* Female */ + sprintf(usrconfig.sSex, "Female"); + pout(CFG.InputColourF, CFG.InputColourB, (char *) Language(53)); + Enter(1); + break; + } else { + Enter(2); + /* Please answer M or F */ + language(LIGHTRED, BLACK, 54); + Enter(1); + } + } + } else /* End of if Statement */ + sprintf(usrconfig.sSex, "Unknown"); /* If set off, set to Unknown */ - sprintf(temp1, "%c%c%c%c", temp[6], temp[7], temp[8], temp[9]); - sprintf(temp2, "%02d", l_date->tm_year); - iLang = atoi(temp2) + 1900; - sprintf(temp2, "%04d", iLang); + if (CFG.iDOB) { + while (TRUE) { + Enter(1); + /* Please enter your Date of Birth DD-MM-YYYY: */ + pout(CYAN, BLACK, (char *) Language(56)); + colour(CFG.InputColourF, CFG.InputColourB); + fflush(stdout); + alarm_on(); + GetDate(temp, 10); - if ((strcmp(temp1,temp2)) == 0) { + sprintf(temp1, "%c%c%c%c", temp[6], temp[7], temp[8], temp[9]); + sprintf(temp2, "%02d", l_date->tm_year); + iLang = atoi(temp2) + 1900; + sprintf(temp2, "%04d", iLang); + + if ((strcmp(temp1,temp2)) == 0) { + Enter(1); + /* Sorry you entered this year by mistake. */ + pout(LIGHTRED, BLACK, (char *) Language(57)); + Enter(1); + } else { + if((strlen(temp)) != 10) { Enter(1); - /* Sorry you entered this year by mistake. */ - pout(LIGHTRED, BLACK, (char *) Language(57)); + /* Please enter the correct date format */ + pout(LIGHTRED, BLACK, (char *) Language(58)); Enter(1); } else { - if((strlen(temp)) != 10) { - Enter(1); - /* Please enter the correct date format */ - pout(LIGHTRED, BLACK, (char *) Language(58)); - Enter(1); - } else { - strcpy(usrconfig.sDateOfBirth,temp); - break; - } + strcpy(usrconfig.sDateOfBirth,temp); + break; } } } + } - usrconfig.tFirstLoginDate = ltime; /* Set first login date to current date */ - usrconfig.tLastLoginDate = (time_t)0; /* To force setting new limits */ - strcpy(usrconfig.sExpiryDate,"00-00-0000"); - usrconfig.ExpirySec = CFG.newuser_access; - usrconfig.Security = CFG.newuser_access; - usrconfig.Email = CFG.GiveEmail; + usrconfig.tFirstLoginDate = ltime; /* Set first login date to current date */ + usrconfig.tLastLoginDate = (time_t)0; /* To force setting new limits */ + strcpy(usrconfig.sExpiryDate,"00-00-0000"); + usrconfig.ExpirySec = CFG.newuser_access; + usrconfig.Security = CFG.newuser_access; + usrconfig.Email = CFG.GiveEmail; - if (CFG.iHotkeys) { - while (TRUE) { - Enter(1); - /* Would you like hot-keyed menus [Y/n]: */ - pout(LIGHTRED, BLACK, (char *) Language(62)); - colour(CFG.InputColourF, CFG.InputColourB); - alarm_on(); - GetstrC(temp, 8); + if (CFG.iHotkeys) { + while (TRUE) { + Enter(1); + /* Would you like hot-keyed menus [Y/n]: */ + pout(LIGHTRED, BLACK, (char *) Language(62)); + colour(CFG.InputColourF, CFG.InputColourB); + alarm_on(); + GetstrC(temp, 8); - if ((toupper(temp[0]) == Keystroke(62, 0)) || (strcmp(temp,"") == 0)) { - usrconfig.HotKeys = TRUE; - break; - } - if (toupper(temp[0]) == Keystroke(62, 1)) { - usrconfig.HotKeys = FALSE; - break; - } else { - /* Please answer Y or N */ - pout(WHITE, BLACK, (char *) Language(63)); - } - } - } else - usrconfig.HotKeys = TRUE; /* Default set it to Hotkeys */ - - usrconfig.iTimeLeft = 20; /* Set Timeleft in users file to 20 */ - - Enter(1); - /* Please enter your Screen Length [24]: */ - pout(LIGHTMAGENTA, BLACK, (char *) Language(64)); - colour(CFG.InputColourF, CFG.InputColourB); - fflush(stdout); - alarm_on(); - Getnum(temp, 3); - - if(strlen(temp) == 0) - usrconfig.iScreenLen = 24; - else - usrconfig.iScreenLen = atoi(temp); - - alarm_on(); - - usrconfig.tLastPwdChange = ltime; /* Days Since Last Password Change */ - usrconfig.iLastFileArea = 1; - usrconfig.iLastMsgArea = 1; - - sprintf(usrconfig.sProtocol, "%s", (char *) Language(65)); - usrconfig.DoNotDisturb = FALSE; - usrconfig.MailScan = TRUE; - usrconfig.ieFILE = TRUE; - usrconfig.ieNEWS = TRUE; - usrconfig.Cls = TRUE; - usrconfig.More = TRUE; - usrconfig.ieASCII8 = TRUE; - - /* - * Search a free slot in the users datafile - */ - sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT")); - if ((pUsrConfig = fopen(temp, "r+")) == NULL) { - WriteError("Can't open file: %s", temp); - ExitClient(1); + if ((toupper(temp[0]) == Keystroke(62, 0)) || (strcmp(temp,"") == 0)) { + usrconfig.HotKeys = TRUE; + break; + } + if (toupper(temp[0]) == Keystroke(62, 1)) { + usrconfig.HotKeys = FALSE; + break; + } else { + /* Please answer Y or N */ + pout(WHITE, BLACK, (char *) Language(63)); + } } + } else + usrconfig.HotKeys = TRUE; /* Default set it to Hotkeys */ - fread(&usrconfighdr, sizeof(usrconfighdr), 1, pUsrConfig); - offset = ftell(pUsrConfig); - Found = FALSE; + usrconfig.iTimeLeft = 20; /* Set Timeleft in users file to 20 */ - while ((fread(&us, usrconfighdr.recsize, 1, pUsrConfig) == 1) && (!Found)) { - if (us.sUserName[0] == '\0') { - Found = TRUE; - } else { - offset = ftell(pUsrConfig); - recno++; - } + Enter(1); + /* Please enter your Screen Length [24]: */ + pout(LIGHTMAGENTA, BLACK, (char *) Language(64)); + colour(CFG.InputColourF, CFG.InputColourB); + fflush(stdout); + alarm_on(); + Getnum(temp, 3); + + if(strlen(temp) == 0) + usrconfig.iScreenLen = 24; + else + usrconfig.iScreenLen = atoi(temp); + + alarm_on(); + + usrconfig.tLastPwdChange = ltime; /* Days Since Last Password Change */ + usrconfig.iLastFileArea = 1; + usrconfig.iLastMsgArea = 1; + + sprintf(usrconfig.sProtocol, "%s", (char *) Language(65)); + usrconfig.DoNotDisturb = FALSE; + usrconfig.MailScan = TRUE; + usrconfig.ieFILE = TRUE; + usrconfig.ieNEWS = TRUE; + usrconfig.Cls = TRUE; + usrconfig.More = TRUE; + usrconfig.ieASCII8 = TRUE; + + /* + * Search a free slot in the users datafile + */ + sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT")); + if ((pUsrConfig = fopen(temp, "r+")) == NULL) { + WriteError("Can't open file: %s", temp); + ExitClient(1); + } + + fread(&usrconfighdr, sizeof(usrconfighdr), 1, pUsrConfig); + offset = ftell(pUsrConfig); + Found = FALSE; + + while ((fread(&us, usrconfighdr.recsize, 1, pUsrConfig) == 1) && (!Found)) { + if (us.sUserName[0] == '\0') { + Found = TRUE; + } else { + offset = ftell(pUsrConfig); + recno++; } + } - if (Found) - fseek(pUsrConfig, offset, SEEK_SET); - else - fseek(pUsrConfig, 0, SEEK_END); + if (Found) + fseek(pUsrConfig, offset, SEEK_SET); + else + fseek(pUsrConfig, 0, SEEK_END); - fwrite(&usrconfig, sizeof(usrconfig), 1, pUsrConfig); - fclose(pUsrConfig); + fwrite(&usrconfig, sizeof(usrconfig), 1, pUsrConfig); + fclose(pUsrConfig); - Enter(2); - /* Your user account has been created: */ - pout(YELLOW, BLACK, (char *) Language(67)); - Enter(2); + Enter(2); + /* Your user account has been created: */ + pout(YELLOW, BLACK, (char *) Language(67)); + Enter(2); - /* Login Name : */ - pout(LIGHTBLUE, BLACK, (char *) Language(68)); - colour(CYAN, BLACK); - printf("%s (%s)\n", UnixName, FullName); - /* Password : */ - pout(LIGHTBLUE, BLACK, (char *) Language(69)); - pout(CYAN, BLACK, (char *)"<"); - /* not displayed */ - pout(WHITE, BLACK, (char *) Language(70)); - pout(CYAN, BLACK, (char *)">\n\n"); - fflush(stdout); - fflush(stdin); + /* Login Name : */ + pout(LIGHTBLUE, BLACK, (char *) Language(68)); + colour(CYAN, BLACK); + printf("%s (%s)\n", UnixName, FullName); + /* Password : */ + pout(LIGHTBLUE, BLACK, (char *) Language(69)); + pout(CYAN, BLACK, (char *)"<"); + /* not displayed */ + pout(WHITE, BLACK, (char *) Language(70)); + pout(CYAN, BLACK, (char *)">\n\n"); + fflush(stdout); + fflush(stdin); - if(CFG.iVoicePhone) { - if(TelephoneScan(Phone1, FullName)) - Syslog('!', "Duplicate phone numbers found"); - } + if (CFG.iVoicePhone && TelephoneScan(Phone1, FullName)) + Syslog('!', "Duplicate phone numbers found"); - if(CFG.iDataPhone) { - if(TelephoneScan(Phone2, FullName)) - Syslog('!', "Duplicate phone numbers found"); - } + if (CFG.iDataPhone && TelephoneScan(Phone2, FullName)) + Syslog('!', "Duplicate phone numbers found"); - free(temp1); - free(temp2); - free(Phone1); - free(Phone2); + free(temp1); + free(temp2); + free(Phone1); + free(Phone2); - DisplayFile((char *)"registered"); + DisplayFile((char *)"registered"); - Syslog('+', "Completed new-user procedure"); - /* New user registration completed. */ - pout(LIGHTGREEN, BLACK, (char *) Language(71)); - Enter(1); - /* You need to login again with the name: */ - pout(LIGHTRED, BLACK, (char *) Language(5)); - pout(YELLOW, BLACK, UnixName); - Enter(2); - alarm_on(); - Pause(); - alarm_off(); - printf("\n"); - return 0; + Syslog('+', "Completed new-user procedure"); + /* New user registration completed. */ + pout(LIGHTGREEN, BLACK, (char *) Language(71)); + Enter(1); + /* You need to login again with the name: */ + pout(LIGHTRED, BLACK, (char *) Language(5)); + pout(YELLOW, BLACK, UnixName); + Enter(2); + alarm_on(); + Pause(); + alarm_off(); + printf("\n"); + return 0; } void Fast_Bye(int onsig) { - char *temp; - time_t t_end; + char *temp; + time_t t_end; - t_end = time(NULL); - Syslog(' ', "MBNEWUSR finished in %s", t_elapsed(t_start, t_end)); - socket_shutdown(mypid); + t_end = time(NULL); + Syslog(' ', "MBNEWUSR finished in %s", t_elapsed(t_start, t_end)); + socket_shutdown(mypid); - temp = calloc(PATH_MAX, sizeof(char)); - sprintf(temp, "%s/tmp/mbsebbs%d", getenv("MBSE_ROOT"), getpid()); - unlink(temp); - free(temp); + temp = calloc(PATH_MAX, sizeof(char)); + sprintf(temp, "%s/tmp/mbsebbs%d", getenv("MBSE_ROOT"), getpid()); + unlink(temp); + free(temp); - colour(7, 0); - fflush(stdout); - fflush(stdin); - sleep(3); + colour(LIGHTGRAY, BLACK); + fflush(stdout); + fflush(stdin); + sleep(3); - Free_Language(); - free(pTTY); + Free_Language(); + free(pTTY); #ifdef MEMWATCH - mwTerm(); + mwTerm(); #endif - exit(0); + exit(0); } @@ -601,79 +603,83 @@ void Good_Bye(int onsig) */ char *NameGen(char *FidoName) { - char *sUserName; - struct passwd *pw; + char *sUserName; + struct passwd *pw; - sUserName = calloc(10, sizeof(char)); + sUserName = calloc(10, sizeof(char)); + Syslog('+', "NameGen(%s)", FidoName); - Syslog('+', "NameGen(%s)", FidoName); - setpwent(); - while ((strcmp(sUserName, "") == 0 || (pw = getpwnam(sUserName)) != NULL) || (strlen(sUserName) < 3)) { - colour(12, 0); - printf("\n%s\n\n", (char *) Language(381)); - colour(15, 0); - /* Please enter a login name (Maximum 8 characters) */ - printf("\n%s\n", (char *) Language(383)); - /* ie. John Doe, login = jdoe */ - printf("%s\n", (char *) Language(384)); - colour(10, 0); - /* login > */ - printf("%s", (char *) Language(385)); - fflush(stdout); - fflush(stdin); - GetstrU(sUserName, 7); + while ((strcmp(sUserName, "") == 0) || ((pw = getpwnam(sUserName)) != NULL) || (strlen(sUserName) < 3)) { + colour(LIGHTRED, BLACK); + printf("\n%s\n\n", (char *) Language(381)); + colour(WHITE, BLACK); + /* Please enter a login name (Maximum 8 characters) */ + printf("\n%s\n", (char *) Language(383)); + /* ie. John Doe, login = jdoe */ + printf("%s\n", (char *) Language(384)); + colour(LIGHTGREEN, BLACK); + /* login > */ + printf("%s", (char *) Language(385)); + fflush(stdout); + fflush(stdin); + GetstrU(sUserName, 7); - setpwent(); - if (pw = getpwnam(tl(sUserName)), pw != NULL) { - /* That login name already exists, please choose another one. */ - colour(12, 0); - printf("\n%s\n", (char *) Language(386)); - setpwent(); - } - } - return tl(sUserName); + if ((pw = getpwnam(sUserName)) != NULL) { + /* That login name already exists, please choose another one. */ + colour(LIGHTRED, BLACK); + printf("\n%s\n", (char *) Language(386)); + } + } + return sUserName; } + /* * Function will create the users name in the passwd file */ char *NameCreate(char *Name, char *Comment, char *Password) { - char *PassEnt; + char *progname; + int err; - PassEnt = calloc(256, sizeof(char)); + progname = calloc(PATH_MAX, sizeof(char)); - /* - * Call mbuseradd, this is a special setuid root program to create - * unix acounts and home directories. - */ - sprintf(PassEnt, "%s/bin/mbuseradd %d %s \"%s\" %s", - getenv("MBSE_ROOT"), getgid(), Name, Comment, CFG.bbs_usersdir); - Syslog('+', "%s", PassEnt); - fflush(stdout); - fflush(stdin); + /* + * Call mbuseradd, this is a special setuid root program to create + * unix acounts and home directories. + */ + sprintf(progname, "%s/bin/mbuseradd %d %s \"%s\" %s", getenv("MBSE_ROOT"), getgid(), Name, Comment, CFG.bbs_usersdir); + Syslog('+', "%s", progname); + fflush(stdout); + fflush(stdin); - if (system(PassEnt) != 0) { - WriteError("Failed to create unix account"); - free(PassEnt); - ExitClient(1); - } - sprintf(PassEnt, "%s/bin/mbpasswd -f %s %s", getenv("MBSE_ROOT"), Name, Password); - Syslog('+', "%s/bin/mbpasswd -f %s ******", getenv("MBSE_ROOT"), Name); - if (system(PassEnt) != 0) { - WriteError("Failed to set unix password"); - free(PassEnt); - ExitClient(1); - } + if ((err = system(progname))) { + perror(""); + WriteError("Failed to create unix account"); + free(progname); + ExitClient(1); + } - colour(14, 0); - /* Your "Unix Account" is created, you may use it the next time you call */ - printf("\n%s\n", (char *) Language(382)); - Syslog('+', "Created Unix account %s for %s", Name, Comment); + sprintf(progname, "%s/bin/mbpasswd -f %s %s", getenv("MBSE_ROOT"), Name, Password); + Syslog('+', "%s/bin/mbpasswd -f %s ******", getenv("MBSE_ROOT"), Name); + fflush(stdout); + fflush(stdin); - free(PassEnt); - return Name; + if ((err = system(progname))) { + perror(""); + WriteError("Failed to set unix password"); + free(progname); + ExitClient(1); + } + + colour(YELLOW, BLACK); + /* Your "Unix Account" is created, you may use it the next time you call */ + printf("\n%s\n", (char *) Language(382)); + Syslog('+', "Created Unix account %s for %s", Name, Comment); + + free(progname); + return Name; } @@ -683,34 +689,34 @@ char *NameCreate(char *Name, char *Comment, char *Password) */ int BadNames(char *Username) { - FILE *fp; - short iFoundName = FALSE; - char *temp, *String, *User; + FILE *fp; + int iFoundName = FALSE; + char *temp, *String, *User; - temp = calloc(PATH_MAX, sizeof(char)); - String = calloc(81, sizeof(char)); - User = calloc(81, sizeof(char)); + temp = calloc(PATH_MAX, sizeof(char)); + String = calloc(81, sizeof(char)); + User = calloc(81, sizeof(char)); - strcpy(User, tl(Username)); + strcpy(User, tl(Username)); - sprintf(temp, "%s/etc/badnames.ctl", getenv("MBSE_ROOT")); - if(( fp = fopen(temp, "r")) != NULL) { - while((fgets(String, 80, fp)) != NULL) { - strcpy(String, tl(String)); - Striplf(String); - if((strstr(User, String)) != NULL) { - printf("\nSorry that name is not acceptable on this system\n"); - iFoundName = TRUE; - break; - } - } - fclose(fp); + sprintf(temp, "%s/etc/badnames.ctl", getenv("MBSE_ROOT")); + if ((fp = fopen(temp, "r")) != NULL) { + while ((fgets(String, 80, fp)) != NULL) { + strcpy(String, tl(String)); + Striplf(String); + if ((strstr(User, String)) != NULL) { + printf("\nSorry that name is not acceptable on this system\n"); + iFoundName = TRUE; + break; + } } + fclose(fp); + } - free(temp); - free(String); - free(User); - return iFoundName; + free(temp); + free(String); + free(User); + return iFoundName; } @@ -722,33 +728,32 @@ int BadNames(char *Username) */ int TelephoneScan(char *Number, char *Name) { - FILE *fp; - int Status = FALSE; - char *temp; - struct userhdr uhdr; - struct userrec u; + FILE *fp; + int Status = FALSE; + char *temp; + struct userhdr uhdr; + struct userrec u; - temp = calloc(81, sizeof(char)); + temp = calloc(PATH_MAX, sizeof(char)); - sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT")); - if(( fp = fopen(temp,"rb")) != NULL) { - fread(&uhdr, sizeof(uhdr), 1, fp); + sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT")); + if ((fp = fopen(temp,"rb")) != NULL) { + fread(&uhdr, sizeof(uhdr), 1, fp); - while (fread(&u, uhdr.recsize, 1, fp) == 1) { - if (strcasecmp(u.sUserName, Name) != 0) - if ((strlen(u.sVoicePhone) && (strcmp(u.sVoicePhone, Number) == 0)) || - (strlen(u.sDataPhone) && (strcmp(u.sDataPhone, Number) == 0))) { - Status = TRUE; - Syslog('b', "Dupe phones ref: \"%s\" voice: \"%s\" data: \"%s\"", - Number, u.sVoicePhone, u.sDataPhone); - Syslog('+', "Uses the same telephone number as %s", u.sUserName); - } + while (fread(&u, uhdr.recsize, 1, fp) == 1) { + if (strcasecmp(u.sUserName, Name) != 0) + if ((strlen(u.sVoicePhone) && (strcmp(u.sVoicePhone, Number) == 0)) || + (strlen(u.sDataPhone) && (strcmp(u.sDataPhone, Number) == 0))) { + Status = TRUE; + Syslog('b', "Dupe phones ref: \"%s\" voice: \"%s\" data: \"%s\"", Number, u.sVoicePhone, u.sDataPhone); + Syslog('+', "Uses the same telephone number as %s", u.sUserName); } - fclose(fp); } + fclose(fp); + } - free(temp); - return Status; + free(temp); + return Status; } diff --git a/mbsebbs/page.c b/mbsebbs/page.c index 85ddf750..bd15904f 100644 --- a/mbsebbs/page.c +++ b/mbsebbs/page.c @@ -52,141 +52,144 @@ */ void Page_Sysop(char *String) { - int i; - FILE *pWritingDevice, *pBusy; - int iOpenDevice = FALSE; /* Flag to check if you can write to CFG.sChatDevice */ - char *Reason; - char temp[81]; + FILE *pWritingDevice; + int i, iOpenDevice = FALSE; /* Flag to check if you can write to CFG.sChatDevice */ + char *Reason, temp[81]; - Reason = calloc(81, sizeof(char)); + Reason = calloc(81, sizeof(char)); - clear(); - colour(12, 0); - /* MBSE BBS Chat */ - Center((char *) Language(151)); + clear(); + colour(12, 0); + /* MBSE BBS Chat */ + Center((char *) Language(151)); - if (CFG.iAskReason) { - locate(6, 0); - colour(1, 0); - printf("%c", 213); - for(i = 0; i < 78; i++) - printf("%c", 205); - printf("%c ", 184); + if (CFG.iAskReason) { + locate(6, 0); + colour(BLUE, BLACK); + printf("%c", 213); + for (i = 0; i < 78; i++) + printf("%c", 205); + printf("%c\n", 184); - colour(7, 0); - for(i = 0; i < 78; i++) - printf("%c", 250); - printf("\n"); + colour(LIGHTGRAY, BLACK); + for (i = 0; i < 78; i++) + printf("%c", 250); + printf("\n"); - colour(1, 0); - printf("%c", 212); - for(i = 0; i < 78; i++) - printf("%c", 205); - printf("%c\n", 190); + colour(BLUE, BLACK); + printf("%c", 212); + for (i = 0; i < 78; i++) + printf("%c", 205); + printf("%c\n", 190); - locate(7, 2); + locate(7, 2); - colour(7, 0); - fflush(stdout); - GetPageStr(temp, 76); + colour(LIGHTGRAY, BLACK); + fflush(stdout); + GetPageStr(temp, 76); - colour(1, 0); - printf("%c", 212); - for(i = 0; i < 78; i++) - printf("%c", 205); - printf("%c\n", 190); + colour(BLUE, BLACK); + printf("%c", 212); + for (i = 0; i < 78; i++) + printf("%c", 205); + printf("%c\n", 190); - if((strcmp(temp, "")) == 0) - return; + if ((strcmp(temp, "")) == 0) + return; - Syslog('+', "Chat Reason: %s", temp); - strcpy(Reason, temp); + Syslog('+', "Chat Reason: %s", temp); + strcpy(Reason, temp); + } + +// if (access("/tmp/.BusyChatting", F_OK) == 0) { +// if((pBusy = fopen("/tmp/.BusyChatting", "r")) == NULL) +// WriteError("Unable to open BusyChatting file", pTTY); +// else { +// fscanf(pBusy, "%10s", temp); +// fclose(pBusy); +// } +// colour(13, 0); +// printf("%s%s\n", (char *) Language(152), temp); +// pout(10, 0, (char *) Language(153)); +// Enter(2); +// Syslog('+', "SysOp was busy chatting to user on %s", temp); +// Pause(); +// free(Reason); +// return; +// } + + CFG.iMaxPageTimes--; + + if (CFG.iMaxPageTimes <= 0) { + if (!DisplayFile((char *)"maxpage")) { + /* If i is FALSE display hard coded message */ + Enter(1); + pout(WHITE, BLACK, (char *) Language(154)); + Enter(2); } - if (access("/tmp/.BusyChatting", F_OK) == 0) { - if((pBusy = fopen("/tmp/.BusyChatting", "r")) == NULL) - WriteError("Unable to open BusyChatting file", pTTY); - else { - fscanf(pBusy, "%10s", temp); - fclose(pBusy); - } - colour(13, 0); - printf("%s%s\n", (char *) Language(152), temp); - pout(10, 0, (char *) Language(153)); - Enter(2); - Syslog('+', "SysOp was busy chatting to user on %s", temp); - Pause(); + Syslog('!', "Attempted to page Sysop, above maximum page limit."); + Pause(); + } else { + locate(14, ((80 - strlen(String) ) / 2 - 2)); + pout(WHITE, BLACK, (char *)"["); + pout(LIGHTGRAY, BLACK, String); + pout(WHITE, BLACK, (char *)"]"); + + locate(16, ((80 - CFG.iPageLength) / 2 - 2)); + pout(WHITE, BLACK, (char *)"["); + colour(BLUE, BLACK); + for (i = 0; i < CFG.iPageLength; i++) + printf("%c", 176); + pout(WHITE, BLACK, (char *)"]"); + + locate(16, ((80 - CFG.iPageLength) / 2 - 2) + 1); + + if ((pWritingDevice = fopen(CFG.sChatDevice, "w")) != NULL) { + fprintf(pWritingDevice, "\n\n\n%s is trying to page you on %s.\n", \ + usrconfig.sUserName, pTTY); + + fprintf(pWritingDevice, "Type: '%s/bin/schat %s' to talk to him, you have", \ + getenv("MBSE_ROOT"), pTTY); + fprintf(pWritingDevice, "\n%d seconds to respond!\n\n", CFG.iPageLength); + fprintf(pWritingDevice, "%s\n", temp); + iOpenDevice = TRUE; + } + + colour(LIGHTBLUE, BLACK); + for (i = 0; i < CFG.iPageLength; i++) { + printf("\x07"); + /* If there weren't any problems opening the writing device */ + if (iOpenDevice) { + fprintf(pWritingDevice, "\x07"); + fflush(pWritingDevice); + } + printf("%c", 219); + fflush(stdout); + sleep(1); + if (access("/tmp/chatdev", R_OK) == 0) { + fclose(pWritingDevice); + Chat(); free(Reason); return; + } } - CFG.iMaxPageTimes--; - - if(CFG.iMaxPageTimes <= 0) { - if (!DisplayFile((char *)"maxpage")) { - /* If i is FALSE display hard coded message */ - Enter(1); - pout(15, 0, (char *) Language(154)); - Enter(2); - } - - Syslog('!', "Attempted to page Sysop, above maximum page limit."); - Pause(); - } else { - locate(14, ((80 - strlen(String) ) / 2 - 2)); - pout(15, 0, (char *)"["); - pout(7, 0, String); - pout(15, 0, (char *)"]"); - - locate(16, ((80 - CFG.iPageLength) / 2 - 2)); - pout(15, 0, (char *)"["); - colour(1, 0); - for(i = 0; i < CFG.iPageLength; i++) - printf("%c", 176); - pout(15, 0, (char *)"]"); - - locate(16, ((80 - CFG.iPageLength) / 2 - 2) + 1); - - if((pWritingDevice = fopen(CFG.sChatDevice, "w")) != NULL) { - fprintf(pWritingDevice, "\n\n\n%s is trying to page you on %s.\n", \ - usrconfig.sUserName, pTTY); - - fprintf(pWritingDevice, "Type: '%s/bin/schat %s' to talk to him, you have", \ - getenv("MBSE_ROOT"), pTTY); - fprintf(pWritingDevice, "\n%d seconds to respond!\n\n", CFG.iPageLength); - fprintf(pWritingDevice, "%s\n", temp); - iOpenDevice = TRUE; - } - - colour(9, 0); - for(i = 0; i < CFG.iPageLength; i++) { - printf("\x07"); - /* If there weren't any problems opening the writing device */ - if(iOpenDevice) - fprintf(pWritingDevice, "\x07"); - printf("%c", 219); - fflush(pWritingDevice); - fflush(stdout); - sleep(1); - if(access("/tmp/chatdev", R_OK) == 0) { - fclose(pWritingDevice); - Chat(); - free(Reason); - return; - } - } - - fclose(pWritingDevice); - PageReason(); - printf("\n\n\n"); - if (strlen(Reason)) - SysopComment(Reason); - else - SysopComment((char *)"Failed chat"); + if (iOpenDevice) { + fclose(pWritingDevice); + iOpenDevice = 0; } + PageReason(); + printf("\n\n\n"); + Pause(); + if (strlen(Reason)) + SysopComment(Reason); + else + SysopComment((char *)"Failed chat"); + } - free(Reason); - Pause(); + free(Reason); + Pause(); } @@ -196,41 +199,41 @@ void Page_Sysop(char *String) */ void GetPageStr(char *sStr, int iMaxlen) { - unsigned char ch = 0; - int iPos = 0; + unsigned char ch = 0; + int iPos = 0; - if ((ttyfd = open ("/dev/tty", O_RDWR)) < 0) { - perror("open 6"); - return; - } - Setraw(); + if ((ttyfd = open ("/dev/tty", O_RDWR)) < 0) { + perror("open 6"); + return; + } + Setraw(); - strcpy(sStr, ""); + strcpy(sStr, ""); - alarm_on(); - while (ch != 13) { - ch = Readkey(); + alarm_on(); + while (ch != 13) { + ch = Readkey(); - if (((ch == 8) || (ch == KEY_DEL) || (ch == 127)) && (iPos > 0)) { - printf("\b%c\b", 250); - fflush(stdout); - sStr[--iPos]='\0'; - } - - if (ch > 31 && ch < 127) { - if (iPos <= iMaxlen) { - iPos++; - sprintf(sStr, "%s%c", sStr, ch); - printf("%c", ch); - fflush(stdout); - } else - ch=13; - } + if (((ch == 8) || (ch == KEY_DEL) || (ch == 127)) && (iPos > 0)) { + printf("\b%c\b", 250); + fflush(stdout); + sStr[--iPos]='\0'; } - Unsetraw(); - close(ttyfd); - printf("\n"); + if (ch > 31 && ch < 127) { + if (iPos <= iMaxlen) { + iPos++; + sprintf(sStr, "%s%c", sStr, ch); + printf("%c", ch); + fflush(stdout); + } else + ch=13; + } + } + + Unsetraw(); + close(ttyfd); + printf("\n"); } @@ -241,58 +244,58 @@ void GetPageStr(char *sStr, int iMaxlen) */ void PageReason() { - FILE *Page; - int iLoop = FALSE, id, i, j = 0; - int Lines = 0, Count = 0, iFoundString = FALSE; - char *String; - char *temp; + FILE *Page; + int iLoop = FALSE, id, i, j = 0; + int Lines = 0, Count = 0, iFoundString = FALSE; + char *String; + char *temp; - temp = calloc(128, sizeof(char)); - String = calloc(81, sizeof(char)); + temp = calloc(PATH_MAX, sizeof(char)); + String = calloc(81, sizeof(char)); - sprintf(temp, "%s/page.asc", CFG.bbs_txtfiles); - if(( Page = fopen(temp, "r")) != NULL) { + sprintf(temp, "%s/page.asc", CFG.bbs_txtfiles); + if ((Page = fopen(temp, "r")) != NULL) { - while (( fgets(String, 80 ,Page)) != NULL) - Lines++; + while (( fgets(String, 80 ,Page)) != NULL) + Lines++; - rewind(Page); + rewind(Page); - Count = Lines; - id = getpid(); - do { - i = rand(); - j = i % id; - if ((j <= Count) && (j != 0)) - iLoop = 1; - } while (!iLoop); + Count = Lines; + id = getpid(); + do { + i = rand(); + j = i % id; + if ((j <= Count) && (j != 0)) + iLoop = 1; + } while (!iLoop); - Lines = 0; + Lines = 0; - while (( fgets(String,80,Page)) != NULL) { - if(Lines == j) { - Striplf(String); - locate(18, ((78 - strlen(String) ) / 2)); - pout(15, 0, (char *)"["); - pout(9, 0, String); - pout(15, 0, (char *)"]"); - iFoundString = TRUE; - } - - Lines++; /* Increment Lines until correct line is found */ - } - } /* End of Else */ - - if(!iFoundString) { - /* Sysop currently is not available ... please leave a comment */ - sprintf(String, "%s", (char *) Language(155)); + while (( fgets(String,80,Page)) != NULL) { + if (Lines == j) { + Striplf(String); locate(18, ((78 - strlen(String) ) / 2)); pout(15, 0, (char *)"["); pout(9, 0, String); pout(15, 0, (char *)"]"); - } + iFoundString = TRUE; + } - free(temp); - free(String); + Lines++; /* Increment Lines until correct line is found */ + } + } /* End of Else */ + + if (!iFoundString) { + /* Sysop currently is not available ... please leave a comment */ + sprintf(String, "%s", (char *) Language(155)); + locate(18, ((78 - strlen(String) ) / 2)); + pout(15, 0, (char *)"["); + pout(9, 0, String); + pout(15, 0, (char *)"]"); + } + + free(temp); + free(String); } diff --git a/mbtask/calllist.c b/mbtask/calllist.c index 385d0569..eda39edf 100644 --- a/mbtask/calllist.c +++ b/mbtask/calllist.c @@ -87,8 +87,9 @@ int check_calllist(void) if (pots_calls || isdn_calls || inet_calls) { call_work = 0; for (tmp = alist; tmp; tmp = tmp->next) { - if (((tmp->callmode == CM_INET) && TCFG.max_tcp && internet) || - ((tmp->callmode == CM_ISDN) && isdn_lines) || ((tmp->callmode == CM_POTS) && pots_lines)) { + if ((((tmp->callmode == CM_INET) && TCFG.max_tcp && internet) || + ((tmp->callmode == CM_ISDN) && isdn_lines) || ((tmp->callmode == CM_POTS) && pots_lines)) && + ((tmp->flavors) & F_CALL)) { call_work++; /* diff --git a/mbtask/outstat.c b/mbtask/outstat.c index 7c63f958..47eb07fe 100644 --- a/mbtask/outstat.c +++ b/mbtask/outstat.c @@ -460,8 +460,6 @@ int outstat() */ tmp->flavors &= ~F_CALL; } - if ((tmp->flavors) & F_CALL) - flstr[10]='C'; if (tmp->t1) flstr[12] = tmp->t1; if (tmp->t2) @@ -519,6 +517,14 @@ int outstat() tmp->flavors &= ~F_CALL; } } + + if ((tmp->flavors) & F_CALL) + flstr[10]='C'; + else + /* + * Safety, clear callmode. + */ + tmp->callmode = CM_NONE; /* * Show callresult for this node.