Switched to detected screensize

This commit is contained in:
Michiel Broek 2005-10-07 20:42:35 +00:00
parent 4122c4f309
commit 0f69e97f44
20 changed files with 253 additions and 242 deletions

View File

@ -1027,7 +1027,7 @@ struct sysconfig {
unsigned GiveEmail : 1; /* Give user email */
unsigned AskAddress : 1; /* Ask Home Address */
unsigned iOneName : 1; /* Allow one user name */
unsigned AskScreenlen : 1; /* Ask screenlength */
unsigned xAskScreenlen : 1;
unsigned iCrashLevel; /* User level for crash mail*/
unsigned iAttachLevel; /* User level for fileattach*/

View File

@ -4,7 +4,7 @@
* Purpose ...............: MBSE BBS Users Database structure
*
*****************************************************************************
* Copyright (C) 1997-2004
* Copyright (C) 1997-2005
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -112,7 +112,7 @@ struct userrec {
int iTimeLeft; /* Time left today */
int iConnectTime; /* Connect time this call */
int iTimeUsed; /* Time used today */
int iScreenLen; /* User Screen Length */
int xScreenLen;
time_t tLastPwdChange; /* Date last password chg */
unsigned xHangUps;
long Credit; /* Users credit */

View File

@ -203,7 +203,10 @@ void Help()
void die(int onsig)
{
if (onsig && (onsig <= NSIG)) {
signal(onsig, SIG_IGN);
}
if (!do_quiet) {
printf("\r");
mbse_colour(CYAN, BLACK);
@ -221,9 +224,6 @@ void die(int onsig)
WriteError("Terminated with error %d", onsig);
}
if (onsig == SIGSEGV)
Syslog('+', "Last msg area %s", msgs.Name);
if (are_tot || are_proc || msg_link)
Syslog('+', "Areas [%6d] Processed [%6d] Linked [%6d]", are_tot, are_proc, msg_link);
if (msg_tot || msg_del)

View File

@ -49,6 +49,9 @@ char rbuf[50][81]; /* Chat receive buffer */ /* FIXME: must be a dynamic b
int rpointer = 0; /* Chat receive pointer */
int rsize = 5; /* Chat receive size */
extern pid_t mypid;
extern int cols;
extern int rows;
void Showline(int, int, char *);
@ -168,7 +171,7 @@ void Chat(char *username, char *channel)
WhosDoingWhat(SYSOPCHAT, NULL);
clear();
rsize = exitinfo.iScreenLen - 5;
rsize = rows - 5;
rpointer = 0;
if (SYSOP == TRUE) {
@ -205,7 +208,7 @@ void Chat(char *username, char *channel)
locate(1, 1);
colour(WHITE, BLUE);
clrtoeol();
snprintf(buf, 200, "%-*s", 79, " MBSE BBS Chat Server");
snprintf(buf, 200, "%-*s", cols -1, " MBSE BBS Chat Server");
mvprintw(1, 1, buf);
snprintf(buf, 200, "CCON,4,%d,%s,%s,0;", mypid, exitinfo.sUserName, exitinfo.Name);
@ -224,14 +227,14 @@ void Chat(char *username, char *channel)
}
}
locate(exitinfo.iScreenLen - 2, 1);
locate(rows - 2, 1);
colour(WHITE, BLUE);
clrtoeol();
snprintf(buf, 200, "%-*s", 79, " Chat, type \"/EXIT\" to exit or \"/HELP\" for help");
mvprintw(exitinfo.iScreenLen - 2, 1, buf);
snprintf(buf, 200, "%-*s", cols -1, " Chat, type \"/EXIT\" to exit or \"/HELP\" for help");
mvprintw(rows - 2, 1, buf);
colour(LIGHTGRAY, BLACK);
mvprintw(exitinfo.iScreenLen - 1, 1, ">");
mvprintw(rows - 1, 1, ">");
memset(&sbuf, 0, sizeof(sbuf));
memset(&rbuf, 0, sizeof(rbuf));
@ -290,7 +293,7 @@ void Chat(char *username, char *channel)
* Check for a pressed key, if so then process it.
* Allow hi-ascii for multi-language.
*/
ch = testkey(exitinfo.iScreenLen -1, curpos + 2);
ch = testkey(rows -1, curpos + 2);
if ((ch == KEY_BACKSPACE) || (ch == KEY_RUBOUT) || (ch == KEY_DEL)) {
alarm_on();
if (curpos) {
@ -333,9 +336,9 @@ void Chat(char *username, char *channel)
}
curpos = 0;
memset(&sbuf, 0, sizeof(sbuf));
locate(exitinfo.iScreenLen - 1, 2);
locate(rows - 1, 2);
clrtoeol();
mvprintw(exitinfo.iScreenLen - 1, 1, ">");
mvprintw(rows - 1, 1, ">");
}
}
chatting = FALSE;

View File

@ -50,6 +50,10 @@
#include "ttyio.h"
extern int rows;
/*
* Function returns total number of bbs users
*/
@ -184,7 +188,7 @@ int DisplayTextFile(char *filename)
Enter(1);
lc++;
if ((lc >= exitinfo.iScreenLen) && (lc < 1000)) {
if ((lc >= rows) && (lc < 1000)) {
lc = 0;
/* More (Y/n/=) */
pout(CFG.MoreF, CFG.MoreB, (char *) Language(61));
@ -467,7 +471,7 @@ void ControlCodeU(int ch)
break;
case 'M':
snprintf(temp, 81, "%d", exitinfo.iScreenLen);
snprintf(temp, 81, "%d", rows);
break;
case 'N':

View File

@ -46,7 +46,8 @@
extern time_t t_start;
extern int e_pid;
extern char **environ;
extern int cols;
extern int rows;
char *Gdate(time_t, int);
@ -220,7 +221,7 @@ void ExtDoor(char *Program, int NoDoorsys, int Y2Kdoorsys, int Comport, int NoSu
fprintf(fp, "%d\r\n", exitinfo.iTimeLeft * 60); /* Seconds */
fprintf(fp, "%d\r\n", exitinfo.iTimeLeft); /* Minutes */
fprintf(fp, "%s\r\n", exitinfo.GraphMode?"GR":"NG"); /* Graphics GR,RIP,NG */
fprintf(fp, "%d\r\n", exitinfo.iScreenLen);
fprintf(fp, "%d\r\n", rows);
fprintf(fp, "N\r\n"); /* User mode, always N */
fprintf(fp, "\r\n"); /* Always blank */
fprintf(fp, "\r\n"); /* Always blank */

View File

@ -54,7 +54,7 @@
extern long arecno; /* File area number in xxxScan() functions */
int Strlen = 0;
int FileRecno = 0;
extern int rows;
int CheckFile(char *, int);
@ -461,7 +461,7 @@ void File_RawDir(char *OpData)
Enter(1);
LineCount++;
if (LineCount == exitinfo.iScreenLen) {
if (LineCount == rows) {
Pause();
LineCount = 0;
}
@ -1430,7 +1430,7 @@ void FileArea_List(char *Option)
Recno++;
if ((iAreaCount / 2) == exitinfo.iScreenLen) {
if ((iAreaCount / 2) == rows) {
/* More (Y/n/=/Area #): */
pout(CFG.MoreF, CFG.MoreB, (char *) Language(207));
/*

View File

@ -48,6 +48,7 @@
extern pid_t mypid;
long arecno = 1; /* Area record number */
int Hcolor = 9; /* Color of area line in xxxScan() functions */
extern int rows;
/*
@ -309,7 +310,7 @@ int iLC(int Lines)
x = strlen(Language(131));
iLineCount += Lines;
if ((iLineCount >= exitinfo.iScreenLen) && (iLineCount < 1000)) {
if ((iLineCount >= rows) && (iLineCount < 1000)) {
iLineCount = 0;
while (TRUE) {

View File

@ -42,6 +42,10 @@
#include "ttyio.h"
extern int cols;
extern int rows;
void Show_Ins(void)
{
locate(1, 70);
@ -180,7 +184,7 @@ void Refresh(void)
colour(CFG.TextColourF, CFG.TextColourB);
for (i = 1; i <= Line; i++) {
if ((i >= TopVisible) && (i < (TopVisible + exitinfo.iScreenLen -1))) {
if ((i >= TopVisible) && (i < (TopVisible + rows -1))) {
locate(j, 1);
j++;
PUTSTR(Message[i]);
@ -259,13 +263,13 @@ void FsMove(unsigned char Direction)
* Handle long lines better.
* For now, we will just refuse to go past col 80
*/
if ((Col <= strlen(Message[CurRow])) && (Col < 80)){
if ((Col <= strlen(Message[CurRow])) && (Col < cols)){
Col++;
Setcursor();
} else if (Row < (Line - TopVisible +1)) {
Row++;
Col = 1;
if (Row > (exitinfo.iScreenLen -1)) ScrollDown();
if (Row > (rows -1)) ScrollDown();
Refresh();
} else
Beep();
@ -282,8 +286,8 @@ void FsMove(unsigned char Direction)
* Handle long lines better.
* For now, we will just refuse to go past col 80
*/
if (Col > 80)
Col = 80;
if (Col > cols)
Col = cols;
if (Row == 1)
ScrollUp();
Row--;
@ -310,7 +314,7 @@ void FsMove(unsigned char Direction)
Row++;
if (Col > strlen(Message[CurRow+1]) + 1)
Col = strlen(Message[CurRow+1]) + 1;
if (Row <= (exitinfo.iScreenLen -1))
if (Row <= (rows -1))
Setcursor();
else
ScrollDown();
@ -339,10 +343,10 @@ int FsWordWrap()
WCol = 79;
while (Message[CurRow][WCol] != ' ' && WCol > 0)
WCol--;
if ((WCol > 0) && (WCol < 80))
if ((WCol > 0) && (WCol < cols))
WCol++;
else
WCol=80;
WCol=cols;
if (WCol <= strlen(Message[CurRow])) {
/*
* If WCol = 80 (no spaces in line) be sure to grab
@ -445,7 +449,7 @@ int Fs_Edit()
Line++;
Row++;
Col = 1;
if (Row >= (exitinfo.iScreenLen -1))
if (Row >= (rows -1))
ScrollDown();
Refresh();
Changed = TRUE;
@ -756,7 +760,7 @@ int Fs_Edit()
Col--;
Row++;
}
if (Row > (exitinfo.iScreenLen -1))
if (Row > (rows -1))
ScrollDown();
else
Refresh();

View File

@ -60,7 +60,7 @@ int CheckStatus()
snprintf(buf, 81, "SBBS:0;");
if (socket_send(buf) == 0) {
strcpy(buf, socket_receive());
strncpy(buf, socket_receive(), 80);
if (strncmp(buf, "100:2,0", 7) == 0)
return TRUE;
if ((strncmp(buf, "100:2,2", 7) == 0) && (!ttyinfo.honor_zmh))
@ -320,7 +320,7 @@ void FindMBSE()
}
snprintf(FileName, PATH_MAX, "%s/etc/config.data", getenv("MBSE_ROOT"));
if(( pDataFile = fopen(FileName, "rb")) == NULL) {
if (( pDataFile = fopen(FileName, "rb")) == NULL) {
printf("FATAL ERROR: Can't open %s for reading!\n", FileName);
printf("Please run mbsetup to create configuration file.\n");
printf("Or check that your environment variable MBSE_ROOT is set to the BBS Path!\n");
@ -343,44 +343,19 @@ char *GetMonth(int Month)
static char month[10];
switch (Month) {
case 1:
strcpy(month, *(mLanguage + 398));
break;
case 2:
strcpy(month, *(mLanguage + 399));
break;
case 3:
strcpy(month, *(mLanguage + 400));
break;
case 4:
strcpy(month, *(mLanguage + 401));
break;
case 5:
strcpy(month, *(mLanguage + 402));
break;
case 6:
strcpy(month, *(mLanguage + 403));
break;
case 7:
strcpy(month, *(mLanguage + 404));
break;
case 8:
strcpy(month, *(mLanguage + 405));
break;
case 9:
strcpy(month, *(mLanguage + 406));
break;
case 10:
strcpy(month, *(mLanguage + 407));
break;
case 11:
strcpy(month, *(mLanguage + 408));
break;
case 12:
strcpy(month, *(mLanguage + 409));
break;
default:
strcpy(month, "Unknown");
case 1: strcpy(month, *(mLanguage + 398)); break;
case 2: strcpy(month, *(mLanguage + 399)); break;
case 3: strcpy(month, *(mLanguage + 400)); break;
case 4: strcpy(month, *(mLanguage + 401)); break;
case 5: strcpy(month, *(mLanguage + 402)); break;
case 6: strcpy(month, *(mLanguage + 403)); break;
case 7: strcpy(month, *(mLanguage + 404)); break;
case 8: strcpy(month, *(mLanguage + 405)); break;
case 9: strcpy(month, *(mLanguage + 406)); break;
case 10: strcpy(month, *(mLanguage + 407)); break;
case 11: strcpy(month, *(mLanguage + 408)); break;
case 12: strcpy(month, *(mLanguage + 409)); break;
default: strcpy(month, "Unknown");
}
return(month);
@ -403,7 +378,7 @@ char *GLCdateyy()
strcat(GLcdateyy, GetMonth(l_date->tm_mon+1));
strcat(GLcdateyy,ntime);
return(GLcdateyy);
return (GLcdateyy);
}

View File

@ -49,6 +49,8 @@ extern int LC_Wrote;
extern int LC_Chat;
extern int LC_Olr;
extern int LC_Door;
extern int rows;
extern int cols;
@ -81,7 +83,7 @@ void LastCallers(char *OpData)
x = strlen(Heading);
for(i = 0; i < x; i++)
for (i = 0; i < x; i++)
snprintf(Underline, 81, "%s%c", Underline, exitinfo.GraphMode ? 196 : 45);
colour(LIGHTRED, BLACK);
@ -94,7 +96,7 @@ void LastCallers(char *OpData)
Enter(1);
colour(GREEN, BLACK);
fLine(79);
fLine(cols -1);
while (fread(&lcall, lcallhdr.recsize, 1, pLC) == 1) {
if (!lcall.Hidden) {
@ -131,7 +133,7 @@ void LastCallers(char *OpData)
Enter(1);
LineCount++;
if (LineCount == exitinfo.iScreenLen) {
if (LineCount == rows) {
Pause();
LineCount = 0;
}
@ -139,7 +141,7 @@ void LastCallers(char *OpData)
}
colour(GREEN, BLACK);
fLine(79);
fLine(cols -1);
fclose(pLC);
Enter(1);

View File

@ -74,6 +74,7 @@ char *Message[TEXTBUFSIZE +1];/* Message compose text buffer */
FILE *qf; /* Quote file */
extern int do_mailout;
extern int LC_Wrote; /* Lastcaller info write message */
extern int rows;
/*
@ -103,7 +104,7 @@ int LC(int Lines)
iLineCount += Lines;
if (iLineCount >= exitinfo.iScreenLen && iLineCount < 1000) {
if (iLineCount >= rows && iLineCount < 1000) {
iLineCount = 1;
pout(CFG.MoreF, CFG.MoreB, (char *) Language(61));
@ -1955,7 +1956,7 @@ int CheckLine(int FG, int BG, int Email, int Conv)
x = strlen(Language(61));
iLineCount++;
if ((iLineCount >= (exitinfo.iScreenLen -1)) && (iLineCount < 1000)) {
if ((iLineCount >= (rows -1)) && (iLineCount < 1000)) {
iLineCount = 7;
DoNop();
@ -2208,7 +2209,7 @@ void MsgArea_List(char *Option)
Recno++;
if ((iAreaCount / 2) == exitinfo.iScreenLen) {
if ((iAreaCount / 2) == rows) {
/* More (Y/n/=/Area #): */
pout(CFG.MoreF, CFG.MoreB, (char *) Language(207));
/*

View File

@ -47,6 +47,8 @@
extern int do_quiet; /* Logging quiet flag */
time_t t_start;
char *StartTime;
int cols = 80; /* Screen columns */
int rows = 80; /* Screen rows */
int main(int argc, char **argv)
@ -108,6 +110,8 @@ int main(int argc, char **argv)
if (ioctl(1, TIOCGWINSZ, &ws) != -1 && (ws.ws_col > 0) && (ws.ws_row > 0)) {
Syslog('b', "columns=%d lines=%d", ws.ws_col, ws.ws_row);
cols = ws.ws_col;
rows = ws.ws_row;
}
if ((rc = rawport()) != 0) {
@ -167,7 +171,7 @@ int main(int argc, char **argv)
* Default set the terminal to ANSI mode. If your logo
* is in color, the user will see color no mather what.
*/
TermInit(1, 80, 24);
TermInit(1, cols, rows);
/*
* Now it's time to check if the bbs is open. If not, we
@ -223,7 +227,7 @@ int main(int argc, char **argv)
alarm_on();
Pause();
newuser(ws.ws_row);
newuser();
Fast_Bye(MBERR_OK);
return 0;
}

View File

@ -50,7 +50,8 @@
extern int do_quiet; /* Logging quiet flag */
time_t t_start;
int cols = 80; /* Screen columns */
int rows = 24; /* Screen rows */
int main(int argc, char **argv)
@ -101,8 +102,10 @@ int main(int argc, char **argv)
Syslog(' ', " ");
Syslog(' ', "MBSEBBS v%s", VERSION);
if(ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col>0 && ws.ws_row>0){
if (ioctl(1, TIOCGWINSZ, &ws) != -1 && (ws.ws_col > 0) && (ws.ws_row > 0)) {
Syslog('b', "columns=%d lines=%d", ws.ws_col, ws.ws_row);
cols = ws.ws_col;
rows = ws.ws_row;
}
if ((rc = rawport()) != 0) {
@ -166,7 +169,7 @@ int main(int argc, char **argv)
* Default set the terminal to ANSI mode. If your logo
* is in color, the user will see color no mather what.
*/
TermInit(1, 80, 24);
TermInit(1, ws.ws_col, ws.ws_row);
/*
* Now it's time to check if the bbs is open. If not, we

View File

@ -40,13 +40,16 @@
#include "ttyio.h"
extern int rows;
int MoreFile(char *filename)
{
char Buf[81];
static FILE *fptr;
int lines, input, ignore = FALSE, maxlines;
maxlines = lines = exitinfo.iScreenLen - 2;
maxlines = lines = rows - 2;
if ((fptr = fopen(filename,"r")) == NULL) {
snprintf(Buf, 81, "%s%s", (char *) Language(72), filename);

View File

@ -65,13 +65,15 @@ extern char *ieHandle; /* Users Handle */
extern time_t t_start; /* Program starttime */
int do_mailout = FALSE; /* Just for linking */
int chat_with_sysop = FALSE; /* Just for linking */
extern int rows;
extern int cols;
/*
* The main newuser registration function
*/
int newuser(int rows)
int newuser(void)
{
FILE *pUsrConfig;
int i, x, Found, iLang, recno = 0, Count = 0, badname;
@ -464,7 +466,8 @@ int newuser(int rows)
} else {
usrconfig.iScreenLen = 24;
}
TermInit(usrconfig.GraphMode, 80, usrconfig.iScreenLen);
rows = usrconfig.iScreenLen;
TermInit(usrconfig.GraphMode, cols, rows);
alarm_on();
usrconfig.tLastPwdChange = ltime; /* Days Since Last Password Change */

View File

@ -4,7 +4,7 @@
#define _NEWUSER_H
int newuser(int);
int newuser(void);
void Fast_Bye(int);
#endif

View File

@ -60,6 +60,8 @@ unsigned short BarWidth;
lastread LR;
static char TempStr[128];
extern int do_mailout;
extern int cols;
extern int rows;
char *newtear = NULL;
@ -250,7 +252,7 @@ void OLR_TagArea()
GetstrC(buf, 20);
if (buf[0] == '?') {
maxlines = lines = exitinfo.iScreenLen - 1;
maxlines = lines = rows - 1;
/* Conference Area Msgs Description */
poutCR(LIGHTCYAN, BLACK, (char *)Language(229));
if ((ma = fopen(Msgname, "r")) != NULL) {
@ -390,7 +392,7 @@ void OLR_UntagArea()
GetstrC(buf, 20);
if (buf[0] == '?') {
maxlines = lines = exitinfo.iScreenLen - 1;
maxlines = lines = rows - 1;
/* Conference Area Msgs Description */
poutCR(LIGHTCYAN, BLACK, (char *)Language(229));
if ((ma = fopen(Msgname, "r")) != NULL) {
@ -747,7 +749,7 @@ void OLR_ViewTags()
/* Conference Area Msgs Description */
poutCR(LIGHTCYAN, BLACK, (char *)Language(229));
colour(CYAN, BLACK);
maxlines = lines = exitinfo.iScreenLen - 1;
maxlines = lines = rows - 1;
while (fread(&msgs, msgshdr.recsize, 1, ma) == 1) {
fseek(ma, msgshdr.syssize, SEEK_CUR);

View File

@ -55,6 +55,8 @@
extern int sock;
extern int cols;
extern int rows;
extern pid_t mypid;
char *StartTime = NULL;
@ -168,7 +170,7 @@ void SwapDate(char *Date3, char *Date4)
void user()
void user(void)
{
FILE *pUsrConfig, *pLimits;
int i, x, FoundName = FALSE, iFoundLimit = FALSE, IsNew = FALSE, logins = 0, Start;
@ -257,7 +259,7 @@ void user()
UserCity(mypid, usrconfig.Name, usrconfig.sLocation);
else
UserCity(mypid, usrconfig.Name, (char *)"N/A");
TermInit(usrconfig.GraphMode, 80, usrconfig.iScreenLen);
TermInit(usrconfig.GraphMode, cols, rows);
/*
* Count simultaneous logins

View File

@ -40,6 +40,9 @@
#include "ttyio.h"
extern int rows;
void UserList(char *OpData)
{
FILE *pUsrConfig;
@ -133,7 +136,7 @@ void UserList(char *OpData)
Enter(1);
}
if (LineCount >= exitinfo.iScreenLen - 2) {
if (LineCount >= rows - 2) {
LineCount = 0;
Pause();
colour(CYAN, BLACK);