Fixed small bbs problem, started chat protocol

This commit is contained in:
Michiel Broek 2003-03-19 22:45:46 +00:00
parent f5a9861ead
commit 0fc8c478f4
12 changed files with 791 additions and 680 deletions

View File

@ -43,8 +43,24 @@ v0.37.2 23-Feb-2003.
Added menu 320, toggle Offline Reader Extended Info. Added menu 320, toggle Offline Reader Extended Info.
Added new control code: control-U + 8, this displays YES or NO Added new control code: control-U + 8, this displays YES or NO
for the new Extended Info setting. for the new Extended Info setting.
The display file functio now displays the ^U8 code. The display file function now displays the ^U8 code.
Added support for door32.sys dropfile. Added support for door32.sys dropfile.
Fixed user idle logoff when new mailcheck took too long.
Added email reply when reading new (e)mail.
With the CIPM and CSPM mbtask commands added the parameter for
the chat channel.
mbmon:
Reports sysop available or left the system when mbmon starts
or stops.
mbtask:
Safer logging of user log messages.
The CSPM command has an extra channel parameter.
The CIPM reply has an extra channel parameter.
In personal message text the text after a ; character is not
ignored anymore.
Added CSYS command to report if sysop is available.
lang: lang:
Changed language prompts 15 and 16. Changed language prompts 15 and 16.

5
TODO
View File

@ -22,7 +22,7 @@ mbsebbs:
N: Implement session and time/day limits. N: Implement session and time/day limits.
N: Display textfiles and archives. N: Display archives.
L: Better word wrapping or paragraph justification in editor. L: Better word wrapping or paragraph justification in editor.
@ -30,9 +30,6 @@ mbsebbs:
N: OLR, implement file requests. N: OLR, implement file requests.
N: If a new mailcheck takes longer then the idle timeout, the user is
disconnected as soon as the mailcheck is ready.
N: Only count posted messages in local mail areas. N: Only count posted messages in local mail areas.
L: ChangeHandle, allow own unix name as handle. L: ChangeHandle, allow own unix name as handle.

View File

@ -41,13 +41,19 @@ extern int bbs_free;
static void die(int onsig) static void die(int onsig)
{ {
signal(onsig, SIG_IGN); char buf[128];
screen_stop();
if (onsig && (onsig <= NSIG)) signal(onsig, SIG_IGN);
Syslog('?', "Finished on signal %s", SigName[onsig]); screen_stop();
else if (onsig && (onsig <= NSIG))
Syslog(' ', "Normally finished"); Syslog('?', "Finished on signal %s", SigName[onsig]);
ExitClient(0); else
Syslog(' ', "Normally finished");
sprintf(buf, "CSYS:1,0;");
if (socket_send(buf) == 0)
sprintf(buf, "%s", socket_receive());
ExitClient(0);
} }
@ -413,70 +419,78 @@ void soft_info(void)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct passwd *pw; struct passwd *pw;
char buf[128];
#ifdef MEMWATCH #ifdef MEMWATCH
mwInit(); mwInit();
#endif #endif
/* /*
* Find out who is on the keyboard or automated the keyboard. * Find out who is on the keyboard or automated the keyboard.
*/ */
pw = getpwuid(getuid()); pw = getpwuid(getuid());
InitClient(pw->pw_name); InitClient(pw->pw_name);
Syslog(' ', "Started by %s", pw->pw_name); Syslog(' ', "Started by %s", pw->pw_name);
bbs_free = FALSE; bbs_free = FALSE;
/*
* Report sysop available for chat
*/
sprintf(buf, "CSYS:1,1;");
if (socket_send(buf) == 0)
sprintf(buf, "%s", socket_receive());
/* /*
* Setup several signals so when the program terminate's it * Setup several signals so when the program terminate's it
* will properly close. * will properly close.
*/ */
signal(SIGINT, (void (*))die); signal(SIGINT, (void (*))die);
signal(SIGBUS, (void (*))die); signal(SIGBUS, (void (*))die);
signal(SIGSEGV,(void (*))die); signal(SIGSEGV,(void (*))die);
signal(SIGTERM,(void (*))die); signal(SIGTERM,(void (*))die);
signal(SIGKILL,(void (*))die); signal(SIGKILL,(void (*))die);
screen_start((char *)"MBmon"); screen_start((char *)"MBmon");
for (;;) { for (;;) {
IsDoing("Browsing Menu"); IsDoing("Browsing Menu");
clr_index(); clr_index();
set_color(WHITE, BLACK); set_color(WHITE, BLACK);
mvprintw( 5, 6, "0. MBSE BBS MONITOR"); mvprintw( 5, 6, "0. MBSE BBS MONITOR");
set_color(CYAN, BLACK); set_color(CYAN, BLACK);
mvprintw( 7, 6, "1. View Server Clients"); mvprintw( 7, 6, "1. View Server Clients");
mvprintw( 8, 6, "2. View Server Statistics"); mvprintw( 8, 6, "2. View Server Statistics");
mvprintw( 9, 6, "3. View Filesystem Usage"); mvprintw( 9, 6, "3. View Filesystem Usage");
mvprintw(10, 6, "4. View BBS System Information"); mvprintw(10, 6, "4. View BBS System Information");
mvprintw(11, 6, "5. View BBS Lastcallers List"); mvprintw(11, 6, "5. View BBS Lastcallers List");
mvprintw(12, 6, "6. View Software Information"); mvprintw(12, 6, "6. View Software Information");
switch(select_menu(6)) { switch(select_menu(6)) {
case 0: case 0:
die(0); die(0);
break; break;
case 1: case 1:
system_moni(); system_moni();
break; break;
case 2: case 2:
system_stat(); system_stat();
break; break;
case 3: case 3:
disk_stat(); disk_stat();
break; break;
case 4: case 4:
ShowSysinfo(); ShowSysinfo();
break; break;
case 5: case 5:
ShowLastcaller(); ShowLastcaller();
break; break;
case 6: case 6:
soft_info(); soft_info();
break; break;
}
} }
}
} }

View File

@ -4,7 +4,7 @@
* Purpose ...............: Internet email * Purpose ...............: Internet email
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -65,7 +65,6 @@ extern int LC_Wrote;
int HasNoEmail(void); int HasNoEmail(void);
int Export_a_Email(unsigned long); int Export_a_Email(unsigned long);
int EmailPanel(void); int EmailPanel(void);
void Reply_Email(int);
int Save_Email(int); int Save_Email(int);

View File

@ -1,10 +1,13 @@
#ifndef _EMAIL_H #ifndef _EMAIL_H
#define _EMAIL_H #define _EMAIL_H
/* $Id$ */
void ShowEmailHdr(void); void ShowEmailHdr(void);
int Read_a_Email(unsigned long); int Read_a_Email(unsigned long);
void Read_Email(void); void Read_Email(void);
void Write_Email(void); void Write_Email(void);
void Reply_Email(int);
void QuickScan_Email(void); void QuickScan_Email(void);
void Trash_Email(void); void Trash_Email(void);
void Choose_Mailbox(char *); void Choose_Mailbox(char *);

View File

@ -2083,227 +2083,229 @@ int CheckUser(char *To)
*/ */
void CheckMail() void CheckMail()
{ {
FILE *pMsgArea, *Tmp; FILE *pMsgArea, *Tmp;
int x, Found = 0; int x, Found = 0, Color, Count = 0, Reading, OldMsgArea;
int Color, Count = 0, Reading; char *temp, *sFileName;
int OldMsgArea; unsigned long i, Start;
char *temp; typedef struct _Mailrec {
char *sFileName; long Area;
unsigned long i, Start; unsigned long Msg;
typedef struct _Mailrec { } _Mail;
long Area; _Mail Mail;
unsigned long Msg; lastread LR;
} _Mail;
_Mail Mail;
lastread LR;
OldMsgArea = iMsgAreaNumber; OldMsgArea = iMsgAreaNumber;
iMsgAreaNumber = 0; iMsgAreaNumber = 0;
Syslog('+', "Start checking for new mail"); Syslog('+', "Start checking for new mail");
clear(); clear();
/* Checking your mail box ... */ /* Checking your mail box ... */
language(LIGHTGREEN, BLACK, 150); language(LIGHTGREEN, BLACK, 150);
Enter(2); Enter(2);
Color = LIGHTBLUE; Color = LIGHTBLUE;
fflush(stdout);
/*
* Open temporary file
*/
if ((Tmp = tmpfile()) == NULL) {
WriteError("$unable to open temporary file");
return;
}
/*
* First check the e-mail mailbox
*/
temp = calloc(PATH_MAX, sizeof(char));
if (exitinfo.Email && strlen(exitinfo.Password)) {
check_popmail(exitinfo.Name, exitinfo.Password);
colour(Color++, BLACK);
printf("\re-mail Private e-mail mailbox");
fflush(stdout); fflush(stdout);
Count = 0;
sprintf(temp, "%s/%s/mailbox", CFG.bbs_usersdir, exitinfo.Name);
SetEmailArea((char *)"mailbox");
if (Msg_Open(temp)) {
/*
* Check lastread pointer, if none found start
* at the begin of the messagebase.
*/
LR.UserID = grecno;
if (Msg_GetLastRead(&LR))
Start = LR.HighReadMsg + 1;
else
Start = EmailBase.Lowest;
/* for (i = Start; i <= EmailBase.Highest; i++) {
* Open temporary file if (Msg_ReadHeader(i)) {
*/ /*
if ((Tmp = tmpfile()) == NULL) { * Only check the received status of the email. The mail
WriteError("$unable to open temporary file"); * may not be direct addressed to this user (aliases database)
return; * but if it is in his mailbox it is always for the user.
} */
if (!Msg.Received) {
/*
* First check the e-mail mailbox
*/
temp = calloc(PATH_MAX, sizeof(char));
if (exitinfo.Email && strlen(exitinfo.Password)) {
check_popmail(exitinfo.Name, exitinfo.Password);
colour(Color++, BLACK);
printf("\re-mail Private e-mail mailbox");
fflush(stdout);
Count = 0;
sprintf(temp, "%s/%s/mailbox", CFG.bbs_usersdir, exitinfo.Name);
SetEmailArea((char *)"mailbox");
if (Msg_Open(temp)) {
/* /*
* Check lastread pointer, if none found start * Store area and message number in temporary file.
* at the begin of the messagebase.
*/ */
LR.UserID = grecno; Mail.Area = -1; /* Means e-mail mailbox */
if (Msg_GetLastRead(&LR)) Mail.Msg = Msg.Id + EmailBase.Lowest -1;
Start = LR.HighReadMsg + 1; fwrite(&Mail, sizeof(Mail), 1, Tmp);
else Count++;
Start = EmailBase.Lowest; Found++;
}
for (i = Start; i <= EmailBase.Highest; i++) {
if (Msg_ReadHeader(i)) {
/*
* Only check the received status of the email. The mail
* may not be direct addressed to this user (aliases database)
* but if it is in his mailbox it is always for the user.
*/
if (!Msg.Received) {
/*
* Store area and message number in temporary file.
*/
Mail.Area = -1; /* Means e-mail mailbox */
Mail.Msg = Msg.Id + EmailBase.Lowest -1;
fwrite(&Mail, sizeof(Mail), 1, Tmp);
Count++;
Found++;
}
}
}
Msg_Close();
}
if (Count) {
colour(CFG.TextColourF, CFG.TextColourB);
/* messages in */
printf("\n\n%d %s private e-mail mailbox\n\n", Count, (char *)Language(213));
Syslog('m', " %d messages in private e-mail mailbox", Count);
} }
}
Msg_Close();
} }
if (Count) {
/* colour(CFG.TextColourF, CFG.TextColourB);
* Open the message base configuration /* messages in */
*/ printf("\n\n%d %s private e-mail mailbox\n\n", Count, (char *)Language(213));
sFileName = calloc(PATH_MAX, sizeof(char)); Syslog('m', " %d messages in private e-mail mailbox", Count);
sprintf(sFileName,"%s/etc/mareas.data", getenv("MBSE_ROOT"));
if((pMsgArea = fopen(sFileName, "r+")) == NULL) {
WriteError("$Can't open: %s", sFileName);
free(temp);
free(sFileName);
return;
} }
fread(&msgshdr, sizeof(msgshdr), 1, pMsgArea); }
/* /*
* Check all normal areas one by one * Open the message base configuration
*/ */
while (fread(&msgs, msgshdr.recsize, 1, pMsgArea) == 1) { sFileName = calloc(PATH_MAX, sizeof(char));
fseek(pMsgArea, msgshdr.syssize, SEEK_CUR); sprintf(sFileName,"%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((msgs.Active) && (exitinfo.Security.level >= msgs.RDSec.level)) { if((pMsgArea = fopen(sFileName, "r+")) == NULL) {
SetMsgArea(iMsgAreaNumber); WriteError("$Can't open: %s", sFileName);
sprintf(temp, "%d", iMsgAreaNumber + 1); free(temp);
colour(Color, 0); free(sFileName);
if (Color < WHITE) return;
Color++; }
else fread(&msgshdr, sizeof(msgshdr), 1, pMsgArea);
Color = LIGHTBLUE;
printf("\r%6s %-40s", temp, sMsgAreaDesc);
fflush(stdout);
Count = 0;
Nopper();
if (Msg_Open(sMsgAreaBase)) { /*
/* * Check all normal areas one by one
* Check lastread pointer, if none found start */
* at the begin of the messagebase. while (fread(&msgs, msgshdr.recsize, 1, pMsgArea) == 1) {
*/ fseek(pMsgArea, msgshdr.syssize, SEEK_CUR);
LR.UserID = grecno; if ((msgs.Active) && (exitinfo.Security.level >= msgs.RDSec.level)) {
if (Msg_GetLastRead(&LR)) SetMsgArea(iMsgAreaNumber);
Start = LR.HighReadMsg + 1; sprintf(temp, "%d", iMsgAreaNumber + 1);
else colour(Color, 0);
Start = MsgBase.Lowest; if (Color < WHITE)
Color++;
else
Color = LIGHTBLUE;
printf("\r%6s %-40s", temp, sMsgAreaDesc);
fflush(stdout);
Count = 0;
/*
* Refresh timers
*/
Nopper();
alarm_on();
for (i = Start; i <= MsgBase.Highest; i++) { if (Msg_Open(sMsgAreaBase)) {
if (Msg_ReadHeader(i)) { /*
if ((!Msg.Received) && (IsMe(Msg.To))) { * Check lastread pointer, if none found start
/* * at the begin of the messagebase.
* Store area and message number */
* in temporary file. LR.UserID = grecno;
*/ if (Msg_GetLastRead(&LR))
Mail.Area = iMsgAreaNumber; Start = LR.HighReadMsg + 1;
Mail.Msg = Msg.Id + MsgBase.Lowest -1; else
fwrite(&Mail, sizeof(Mail), 1, Tmp); Start = MsgBase.Lowest;
Count++;
Found++; for (i = Start; i <= MsgBase.Highest; i++) {
} if (Msg_ReadHeader(i)) {
} if ((!Msg.Received) && (IsMe(Msg.To))) {
} /*
Msg_Close(); * Store area and message number
} * in temporary file.
if (Count) { */
colour(CFG.TextColourF, CFG.TextColourB); Mail.Area = iMsgAreaNumber;
/* messages in */ Mail.Msg = Msg.Id + MsgBase.Lowest -1;
printf("\n\n%d %s %s\n\n", Count, (char *)Language(213), sMsgAreaDesc); fwrite(&Mail, sizeof(Mail), 1, Tmp);
Syslog('m', " %d messages in %s", Count, sMsgAreaDesc); Count++;
Found++;
} }
}
} }
iMsgAreaNumber++; Msg_Close();
}
if (Count) {
colour(CFG.TextColourF, CFG.TextColourB);
/* messages in */
printf("\n\n%d %s %s\n\n", Count, (char *)Language(213), sMsgAreaDesc);
Syslog('m', " %d messages in %s", Count, sMsgAreaDesc);
}
} }
iMsgAreaNumber++;
}
fclose(pMsgArea); fclose(pMsgArea);
putchar('\r'); putchar('\r');
for (i = 0; i < 48; i++) for (i = 0; i < 48; i++)
putchar(' '); putchar(' ');
putchar('\r'); putchar('\r');
if (Found) { if (Found) {
colour(YELLOW, BLACK); colour(YELLOW, BLACK);
/* You have messages, read your mail now? [Y/n]: */ /* You have messages, read your mail now? [Y/n]: */
printf("\n%s%d %s", (char *) Language(142), Found, (char *) Language(143)); printf("\n%s%d %s", (char *) Language(142), Found, (char *) Language(143));
colour(CFG.InputColourF, CFG.InputColourB); colour(CFG.InputColourF, CFG.InputColourB);
fflush(stdout);
fflush(stdin);
alarm_on();
if (toupper(Getone()) != Keystroke(143,1)) {
rewind(Tmp);
Reading = TRUE;
while ((Reading) && (fread(&Mail, sizeof(Mail), 1, Tmp) == 1)) {
if (Mail.Area == -1) {
/*
* Private e-mail
*/
Read_a_Email(Mail.Msg);
} else {
SetMsgArea(Mail.Area);
Read_a_Msg(Mail.Msg, FALSE);
}
/* (R)eply, (N)ext, (Q)uit */
pout(CFG.CRColourF, CFG.CRColourB, (char *)Language(218));
fflush(stdout); fflush(stdout);
fflush(stdin); fflush(stdin);
alarm_on(); alarm_on();
x = toupper(Getone());
if (toupper(Getone()) != Keystroke(143,1)) { if (x == Keystroke(218, 0)) {
rewind(Tmp); Syslog('m', " Reply!");
Reading = TRUE; if (Mail.Area == -1) {
Reply_Email(TRUE);
while ((Reading) && (fread(&Mail, sizeof(Mail), 1, Tmp) == 1)) { } else {
if (Mail.Area == -1) { Reply_Msg(TRUE);
/* }
* Private e-mail
*/
Read_a_Email(Mail.Msg);
} else {
SetMsgArea(Mail.Area);
Read_a_Msg(Mail.Msg, FALSE);
}
/* (R)eply, (N)ext, (Q)uit */
pout(CFG.CRColourF, CFG.CRColourB, (char *)Language(218));
fflush(stdout);
fflush(stdin);
alarm_on();
x = toupper(Getone());
if (x == Keystroke(218, 0)) {
Syslog('m', " Reply!");
if (Mail.Area == -1) {
} else {
Reply_Msg(TRUE);
}
}
if (x == Keystroke(218, 2)) {
Syslog('m', " Quit check for new mail");
iMsgAreaNumber = OldMsgArea;
fclose(Tmp);
SetMsgArea(OldMsgArea);
printf("\n\n");
free(temp);
free(sFileName);
return;
}
}
} }
} else { if (x == Keystroke(218, 2)) {
language(LIGHTRED, BLACK, 144); Syslog('m', " Quit check for new mail");
Enter(1); iMsgAreaNumber = OldMsgArea;
sleep(3); fclose(Tmp);
} /* if (Found) */ SetMsgArea(OldMsgArea);
printf("\n\n");
free(temp);
free(sFileName);
return;
}
}
}
} else {
language(LIGHTRED, BLACK, 144);
Enter(1);
sleep(3);
} /* if (Found) */
iMsgAreaNumber = OldMsgArea; iMsgAreaNumber = OldMsgArea;
fclose(Tmp); fclose(Tmp);
SetMsgArea(OldMsgArea); SetMsgArea(OldMsgArea);
printf("\n\n"); printf("\n\n");
free(temp); free(temp);
free(sFileName); free(sFileName);
} }

View File

@ -56,23 +56,27 @@ extern pid_t mypid; /* Pid of this program */
void Check_PM(void); void Check_PM(void);
void Check_PM(void) void Check_PM(void)
{ {
static char buf[128]; static char buf[128];
char resp[128]; char resp[128];
sprintf(buf, "CIPM:1,%d;", mypid); sprintf(buf, "CIPM:1,%d;", mypid);
if (socket_send(buf) == 0) { if (socket_send(buf) == 0) {
strcpy(buf, socket_receive()); strcpy(buf, socket_receive());
if (strncmp(buf, "100:0;", 6) == 0) if (strncmp(buf, "100:0;", 6) == 0)
return; return;
strcpy(resp, strtok(buf, ":")); strcpy(resp, strtok(buf, ":")); /* Should be 100 */
strcpy(resp, strtok(NULL, ",")); strcpy(resp, strtok(NULL, ",")); /* Should be 3 */
colour(CYAN, BLACK); strcpy(resp, strtok(NULL, ",")); /* Should be channel -1 */
/* ** Message ** from */ strncpy(resp, strtok(NULL, ","), 36); /* From Name */
printf("\n\n\007%s %s:\n", (char *)Language(434), strtok(NULL, ",")); colour(CYAN, BLACK);
printf("%s\n", strtok(NULL, ";")); /* ** Message ** from */
Pause(); printf("\n\n\007%s %s:\n", (char *)Language(434), resp);
} strncpy(resp, strtok(NULL, "\0"), 80); /* The real message */
resp[strlen(resp)-1] = '\0';
printf("%s\n", resp);
Pause();
}
} }

View File

@ -315,11 +315,11 @@ void SendOnlineMsg(char *OpData)
if ((strcmp(String, "")) != 0) { if ((strcmp(String, "")) != 0) {
buf[0] = '\0'; buf[0] = '\0';
if ((strcasecmp(OpData, "/H") == 0) && strlen(exitinfo.sHandle)) if ((strcasecmp(OpData, "/H") == 0) && strlen(exitinfo.sHandle))
sprintf(buf, "CSPM:3,%s,%s,%s;", exitinfo.sHandle, User, String); sprintf(buf, "CSPM:4,-1,%s,%s,%s;", exitinfo.sHandle, User, String);
else if (strcasecmp(OpData, "/U") == 0) else if (strcasecmp(OpData, "/U") == 0)
sprintf(buf, "CSPM:3,%s,%s,%s;", exitinfo.Name, User, String); sprintf(buf, "CSPM:4,-1,%s,%s,%s;", exitinfo.Name, User, String);
else else
sprintf(buf, "CSPM:3,%s,%s,%s;", exitinfo.sUserName, User, String); sprintf(buf, "CSPM:4,-1,%s,%s,%s;", exitinfo.sUserName, User, String);
if (socket_send(buf) == 0) { if (socket_send(buf) == 0) {
strcpy(buf, socket_receive()); strcpy(buf, socket_receive());

View File

@ -77,276 +77,291 @@ int userlog(char *param)
char *exe_cmd(char *); char *exe_cmd(char *);
char *exe_cmd(char *in) char *exe_cmd(char *in)
{ {
static char obuf[SS_BUFSIZE]; static char obuf[SS_BUFSIZE];
static char ibuf[SS_BUFSIZE]; static char ibuf[SS_BUFSIZE];
static char cmd[4]; static char cmd[4];
static char token[SS_BUFSIZE]; static char token[SS_BUFSIZE];
static char ebuf[19]; static char ebuf[19];
static char *cnt, var1[16]; static char *cnt, var1[16];
int result; int result;
strcpy(ibuf, in); strcpy(ibuf, in);
strncpy(cmd, ibuf, 4); strncpy(cmd, ibuf, 4);
token[0] = '\0'; token[0] = '\0';
strcpy(ebuf, "200:1,Syntax error;"); strcpy(ebuf, "200:1,Syntax error;");
/* /*
* Split the commandline after the colon so we can give the * Split the commandline after the colon so we can give the
* options directly to the actual functions. Also set a default * options directly to the actual functions. Also set a default
* and most used answer. * and most used answer.
*/ */
strcpy(token, &ibuf[5]); strcpy(token, &ibuf[5]);
strcpy(obuf, "100:0;"); strcpy(obuf, "100:0;");
/* /*
* The A(counting) commands. * The A(counting) commands.
* *
* AINI:5,pid,tty,user,program,city; * AINI:5,pid,tty,user,program,city;
* 100:0; * 100:0;
* 200:1,Syntax Error; * 200:1,Syntax Error;
*/ */
if (strncmp(cmd, "AINI", 4) == 0) { if (strncmp(cmd, "AINI", 4) == 0) {
if (reg_newcon(token) != -1) if (reg_newcon(token) != -1)
return obuf; return obuf;
else { else {
stat_inc_serr(); stat_inc_serr();
return ebuf; return ebuf;
}
} }
}
/* /*
* ACLO:1,pid; * ACLO:1,pid;
* 107:0; * 107:0;
* 200:1,Syntax Error; * 200:1,Syntax Error;
*/ */
if (strncmp(cmd ,"ACLO", 4) == 0) { if (strncmp(cmd ,"ACLO", 4) == 0) {
if (reg_closecon(token) == 0) { if (reg_closecon(token) == 0) {
strcpy(obuf, "107:0;"); strcpy(obuf, "107:0;");
return obuf; return obuf;
} else { } else {
stat_inc_serr(); stat_inc_serr();
return ebuf; return ebuf;
}
} }
}
/* /*
* ADOI:2,pid,doing; * ADOI:2,pid,doing;
* 100:0; * 100:0;
* 200:1,Syntax Error; * 200:1,Syntax Error;
*/ */
if (strncmp(cmd, "ADOI", 4) == 0) { if (strncmp(cmd, "ADOI", 4) == 0) {
if (reg_doing(token) == 0) if (reg_doing(token) == 0)
return obuf; return obuf;
else { else {
stat_inc_serr(); stat_inc_serr();
return ebuf; return ebuf;
}
} }
}
/* /*
* ATCP:1,pid; * ATCP:1,pid;
* 100:0; * 100:0;
* 200:1,Syntax Error; * 200:1,Syntax Error;
*/ */
if (strncmp(cmd, "ATCP", 4) == 0) { if (strncmp(cmd, "ATCP", 4) == 0) {
if (reg_ip(token) == 0) if (reg_ip(token) == 0)
return obuf; return obuf;
else { else {
stat_inc_serr(); stat_inc_serr();
return ebuf; return ebuf;
}
} }
}
/* /*
* ATTY:2,pid,tty; * ATTY:2,pid,tty;
* 100:0; * 100:0;
* 200:1,Syntax Error; * 200:1,Syntax Error;
*/ */
if (strncmp(cmd, "ATTY", 4) == 0) { if (strncmp(cmd, "ATTY", 4) == 0) {
if (reg_tty(token) == 0) if (reg_tty(token) == 0)
return obuf; return obuf;
else { else {
stat_inc_serr(); stat_inc_serr();
return ebuf; return ebuf;
}
} }
}
/* /*
* ALOG:5,file,program,pid,grade,text; * ALOG:5,file,program,pid,grade,text;
* 100:0; * 100:0;
* 201:1,errno; * 201:1,errno;
*/ */
if (strncmp(cmd, "ALOG", 4) == 0) { if (strncmp(cmd, "ALOG", 4) == 0) {
if (userlog(token) != 0) if (userlog(token) != 0)
sprintf(obuf, "201:1,%d;", oserr); sprintf(obuf, "201:1,%d;", oserr);
return obuf; return obuf;
} }
/* /*
* AUSR:3,pid,user,city; * AUSR:3,pid,user,city;
* 100:0; * 100:0;
* 200:1,Syntax Error; * 200:1,Syntax Error;
*/ */
if (strncmp(cmd, "AUSR", 4) == 0) { if (strncmp(cmd, "AUSR", 4) == 0) {
if (reg_user(token) == 0) if (reg_user(token) == 0)
return obuf; return obuf;
else { else {
stat_inc_serr(); stat_inc_serr();
return ebuf; return ebuf;
}
} }
}
/* /*
* ADIS:2,pid,flag; (set Do Not Disturb). * ADIS:2,pid,flag; (set Do Not Disturb).
* 100:0; * 100:0;
* 200:1,Syntax Error; * 200:1,Syntax Error;
*/ */
if (strncmp(cmd, "ADIS", 4) == 0) { if (strncmp(cmd, "ADIS", 4) == 0) {
if (reg_silent(token) == 0) if (reg_silent(token) == 0)
return obuf; return obuf;
else { else {
stat_inc_serr(); stat_inc_serr();
return ebuf; return ebuf;
}
} }
}
/* /*
* ATIM:2,pid,seconds; * ATIM:2,pid,seconds;
* 100:0; * 100:0;
* 200:1,Syntax Error; * 200:1,Syntax Error;
*/ */
if (strncmp(cmd, "ATIM", 4) == 0) { if (strncmp(cmd, "ATIM", 4) == 0) {
if (reg_timer(TRUE, token) == 0) if (reg_timer(TRUE, token) == 0)
return obuf; return obuf;
else { else {
stat_inc_serr(); stat_inc_serr();
return ebuf; return ebuf;
}
} }
}
/* /*
* ADEF:1,pid; * ADEF:1,pid;
* 100:0; * 100:0;
*/ */
if (strncmp(cmd, "ADEF", 4) == 0) { if (strncmp(cmd, "ADEF", 4) == 0) {
if (reg_timer(FALSE, token) == 0) if (reg_timer(FALSE, token) == 0)
return obuf; return obuf;
else { else {
stat_inc_serr(); stat_inc_serr();
return ebuf; return ebuf;
}
} }
}
/* /*
* The chat commands * The chat commands
* *
* CIPM:1,pid; (Is personal message present) * Used channels: -1 Personal messages between ordinary users.
* 100:2,fromname,message; * 0 Sysop/user chat
* 100:0; * 1..99 Chatting channels
*/ *
if (strncmp(cmd, "CIPM", 4) == 0) { * CIPM:1,pid; (Is personal/chat message present)
return reg_ipm(token); * 100:3,channel,fromname,message;
} * 100:0;
*/
if (strncmp(cmd, "CIPM", 4) == 0) {
return reg_ipm(token);
}
/* /*
* CSPM:3,fromuser,touser,text; (Send personal message). * CSPM:3,channel,fromuser,touser,text; (Send personal/chat message).
* 100:1,n; n: 0=oke, 1=donotdisturb 2=buffer full 3=error * 100:1,n; n: 1=donotdisturb 2=buffer full 3=error
* 100:0; * 100:0;
*/ */
if (strncmp(cmd, "CSPM", 4) == 0) { if (strncmp(cmd, "CSPM", 4) == 0) {
if ((result = reg_spm(token))) { if ((result = reg_spm(token))) {
sprintf(obuf, "100:1,%d;", result); sprintf(obuf, "100:1,%d;", result);
return obuf; return obuf;
} else } else
return obuf; return obuf;
} }
/* /*
* The G(lobal) commands. * CSYS:1,1; Sysop available for chat (from mbmon)
* * CSYS:1,0; Sysop goes away (from mbmon)
* GNOP:1,pid; * 100:0; Allways Ok.
* 100:0; */
*/ if (strncmp(cmd, "CSYS", 4) == 0) {
if (strncmp(cmd ,"GNOP", 4) == 0) { reg_sysop(token);
reg_nop(token); return obuf;
return obuf; }
}
/*
* GPNG:n,data;
* 100:n,data;
*/
if (strncmp(cmd, "GPNG", 4) == 0) {
sprintf(obuf, "100:%s", token);
return obuf;
}
/* /*
* GVER:0; * The G(lobal) commands.
* 100:1,Version ...; *
*/ * GNOP:1,pid;
if (strncmp(cmd, "GVER", 4) == 0) { * 100:0;
sprintf(obuf, "100:1,Version %s;", VERSION); */
return obuf; if (strncmp(cmd ,"GNOP", 4) == 0) {
} reg_nop(token);
return obuf;
}
/* /*
* GSTA:0; * GPNG:n,data;
* 100:19,start,laststart,daily,startups,clients,tot_clients,tot_peak,tot_syntax,tot_comerr, * 100:n,data;
* today_clients,today_peak,today_syntax,today_comerr,!BBSopen,ZMH,internet,Processing,Load,sequence; */
* 201:1,16; if (strncmp(cmd, "GPNG", 4) == 0) {
*/ sprintf(obuf, "100:%s", token);
if (strncmp(cmd, "GSTA", 4) == 0) { return obuf;
return stat_status(); }
}
/* /*
* GMON:1,n; n=1 First time * GVER:0;
* 100:7,pid,tty,user,program,city,isdoing,starttime; * 100:1,Version ...;
* 100:0; */
*/ if (strncmp(cmd, "GVER", 4) == 0) {
if (strncmp(cmd, "GMON", 4) == 0) { sprintf(obuf, "100:1,Version %s;", VERSION);
cnt = strtok(token, ","); return obuf;
strcpy(var1, strtok(NULL, ";")); }
return get_reginfo(atoi(var1));
}
/* /*
* GDST:0; * GSTA:0;
* 100:n,data1,..,data10; * 100:19,start,laststart,daily,startups,clients,tot_clients,tot_peak,tot_syntax,tot_comerr,
*/ * today_clients,today_peak,today_syntax,today_comerr,!BBSopen,ZMH,internet,Processing,Load,sequence;
if (strncmp(cmd, "GDST", 4) == 0) { * 201:1,16;
return get_diskstat(); */
} if (strncmp(cmd, "GSTA", 4) == 0) {
return stat_status();
}
/* /*
* GSYS:0; * GMON:1,n; n=1 First time
* 100:7,calls,pots_calls,isdn_calls,network_calls,local_calls,startdate,last_caller; * 100:7,pid,tty,user,program,city,isdoing,starttime;
* 201:1,16; * 100:0;
*/ */
if (strncmp(cmd, "GSYS", 4) == 0) { if (strncmp(cmd, "GMON", 4) == 0) {
return get_sysinfo(); cnt = strtok(token, ",");
} strcpy(var1, strtok(NULL, ";"));
return get_reginfo(atoi(var1));
}
/* /*
* GLCC:0; * GDST:0;
* 100:1,n; * 100:n,data1,..,data10;
*/ */
if (strncmp(cmd, "GLCC", 4) == 0) { if (strncmp(cmd, "GDST", 4) == 0) {
return get_lastcallercount(); return get_diskstat();
} }
/* /*
* GLCR:1,recno; * GSYS:0;
* 100:9,user,location,level,device,time,mins,calls,speed,actions; * 100:7,calls,pots_calls,isdn_calls,network_calls,local_calls,startdate,last_caller;
* 201:1,16; * 201:1,16;
*/ */
if (strncmp(cmd, "GLCR", 4) == 0) { if (strncmp(cmd, "GSYS", 4) == 0) {
cnt = strtok(token, ","); return get_sysinfo();
strcpy(var1, strtok(NULL, ";")); }
return get_lastcallerrec(atoi(var1));
} /*
* GLCC:0;
* 100:1,n;
*/
if (strncmp(cmd, "GLCC", 4) == 0) {
return get_lastcallercount();
}
/*
* GLCR:1,recno;
* 100:9,user,location,level,device,time,mins,calls,speed,actions;
* 201:1,16;
*/
if (strncmp(cmd, "GLCR", 4) == 0) {
cnt = strtok(token, ",");
strcpy(var1, strtok(NULL, ";"));
return get_lastcallerrec(atoi(var1));
}
/* /*

View File

@ -4,7 +4,7 @@
* Purpose ...............: Buffers for registration information. * Purpose ...............: Buffers for registration information.
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -38,6 +38,7 @@
extern reg_info reginfo[MAXCLIENT]; /* Array with clients */ extern reg_info reginfo[MAXCLIENT]; /* Array with clients */
static int entrypos = 0; /* Status pointer */ static int entrypos = 0; /* Status pointer */
static int mailers = 0; /* Registered mailers */ static int mailers = 0; /* Registered mailers */
static int sysop_present = 0; /* Sysop present */
int ipmailers = 0; /* TCP/IP mail sessions */ int ipmailers = 0; /* TCP/IP mail sessions */
@ -48,15 +49,15 @@ int ipmailers = 0; /* TCP/IP mail sessions */
int reg_find(char *); int reg_find(char *);
int reg_find(char *pids) int reg_find(char *pids)
{ {
int i; int i;
for (i = 0; i < MAXCLIENT; i++) { for (i = 0; i < MAXCLIENT; i++) {
if ((int)reginfo[i].pid == atoi(pids)) if ((int)reginfo[i].pid == atoi(pids))
return i; return i;
} }
Syslog('?', "Panic, pid %s not found", pids); Syslog('?', "Panic, pid %s not found", pids);
return -1; return -1;
} }
@ -68,70 +69,71 @@ int reg_find(char *pids)
int reg_newcon(char *data) int reg_newcon(char *data)
{ {
char *cnt, *pid, *tty, *uid, *prg, *city; char *cnt, *pid, *tty, *uid, *prg, *city;
int retval; int retval;
cnt = strtok(data, ","); cnt = strtok(data, ",");
pid = strtok(NULL, ","); pid = strtok(NULL, ",");
tty = strtok(NULL, ","); tty = strtok(NULL, ",");
uid = strtok(NULL, ","); uid = strtok(NULL, ",");
prg = strtok(NULL, ","); prg = strtok(NULL, ",");
city = strtok(NULL, ";"); city = strtok(NULL, ";");
/* /*
* Abort if no empty record is found * Abort if no empty record is found
*/ */
if ((retval = reg_find((char *)"0")) == -1) { if ((retval = reg_find((char *)"0")) == -1) {
Syslog('?', "Maximum clients (%d) reached", MAXCLIENT); Syslog('?', "Maximum clients (%d) reached", MAXCLIENT);
return -1; return -1;
} }
memset((char *)&reginfo[retval], 0, sizeof(reg_info)); memset((char *)&reginfo[retval], 0, sizeof(reg_info));
reginfo[retval].pid = atoi(pid); reginfo[retval].pid = atoi(pid);
strncpy((char *)&reginfo[retval].tty, tty, 6); strncpy((char *)&reginfo[retval].tty, tty, 6);
strncpy((char *)&reginfo[retval].uname, uid, 35); strncpy((char *)&reginfo[retval].uname, uid, 35);
strncpy((char *)&reginfo[retval].prg, prg, 14); strncpy((char *)&reginfo[retval].prg, prg, 14);
strncpy((char *)&reginfo[retval].city, city, 35); strncpy((char *)&reginfo[retval].city, city, 35);
strcpy((char *)&reginfo[retval].doing, "-"); strcpy((char *)&reginfo[retval].doing, "-");
reginfo[retval].started = time(NULL); reginfo[retval].started = time(NULL);
reginfo[retval].lastcon = time(NULL); reginfo[retval].lastcon = time(NULL);
reginfo[retval].altime = 600; reginfo[retval].altime = 600;
reginfo[retval].channel = -1; /* Default chat channel */
/* /*
* Everyone says do not disturb, unless the flag * Everyone says do not disturb, unless the flag
* is cleared by the owner of this process. * is cleared by the owner of this process.
*/ */
reginfo[retval].silent = 1; reginfo[retval].silent = 1;
stat_inc_clients(); stat_inc_clients();
if (strcmp(prg, (char *)"mbcico") == 0) if (strcmp(prg, (char *)"mbcico") == 0)
mailers++; mailers++;
Syslog('-', "Registered client pgm \"%s\", pid %s, slot %d, mailers %d, TCP/IP %d", Syslog('-', "Registered client pgm \"%s\", pid %s, slot %d, mailers %d, TCP/IP %d",
prg, pid, retval, mailers, ipmailers); prg, pid, retval, mailers, ipmailers);
return retval; return retval;
} }
int reg_closecon(char *data) int reg_closecon(char *data)
{ {
char *cnt, *pid; char *cnt, *pid;
int rec; int rec;
cnt = strtok(data, ","); cnt = strtok(data, ",");
pid = strtok(NULL, ";"); pid = strtok(NULL, ";");
if ((rec = reg_find(pid)) == -1) if ((rec = reg_find(pid)) == -1)
return -1; return -1;
if (strcmp(reginfo[rec].prg, (char *)"mbcico") == 0) if (strcmp(reginfo[rec].prg, (char *)"mbcico") == 0)
mailers--; mailers--;
if (reginfo[rec].istcp) if (reginfo[rec].istcp)
ipmailers--; ipmailers--;
Syslog('-', "Unregistered client pgm \"%s\", pid %s, slot %d, mailers %d, TCP/IP %d", Syslog('-', "Unregistered client pgm \"%s\", pid %s, slot %d, mailers %d, TCP/IP %d",
reginfo[rec].prg, pid, rec, mailers, ipmailers); reginfo[rec].prg, pid, rec, mailers, ipmailers);
memset(&reginfo[rec], 0, sizeof(reg_info)); memset(&reginfo[rec], 0, sizeof(reg_info));
stat_dec_clients(); stat_dec_clients();
return 0; return 0;
} }
@ -141,44 +143,47 @@ int reg_closecon(char *data)
*/ */
void reg_check(void) void reg_check(void)
{ {
int i; int i;
time_t Now; time_t Now;
Now = time(NULL); Now = time(NULL);
for (i = 1; i < MAXCLIENT; i++) { for (i = 1; i < MAXCLIENT; i++) {
if (reginfo[i].pid) { if (reginfo[i].pid) {
if (kill(reginfo[i].pid, 0) == -1) { if (kill(reginfo[i].pid, 0) == -1) {
if (errno == ESRCH) { if (errno == ESRCH) {
if (strcmp(reginfo[i].prg, (char *)"mbcico") == 0) if (strcmp(reginfo[i].prg, (char *)"mbcico") == 0)
mailers--; mailers--;
if (reginfo[i].istcp) if (reginfo[i].istcp)
ipmailers--; ipmailers--;
Syslog('?', "Stale registration found for pid %d (%s), mailers now %d, TCP/IP now %d", Syslog('?', "Stale registration found for pid %d (%s), mailers now %d, TCP/IP now %d",
reginfo[i].pid, reginfo[i].prg, mailers, ipmailers); reginfo[i].pid, reginfo[i].prg, mailers, ipmailers);
memset(&reginfo[i], 0, sizeof(reg_info));
stat_dec_clients(); // FIXME: If this was a moderators chat channel, kill the whole channel
}
} else { memset(&reginfo[i], 0, sizeof(reg_info));
/* stat_dec_clients();
* Check timeout
*/
if ((Now - reginfo[i].lastcon) >= reginfo[i].altime) {
if (reginfo[i].altime < 600) {
kill(reginfo[i].pid, SIGKILL);
Syslog('+', "Send SIGKILL to pid %d", reginfo[i].pid);
} else {
kill(reginfo[i].pid, SIGTERM);
Syslog('+', "Send SIGTERM to pid %d", reginfo[i].pid);
}
/*
* 10 seconds to the next kill
*/
reginfo[i].altime = 10;
reginfo[i].lastcon = time(NULL);
}
}
} }
} else {
/*
* Check timeout
*/
if ((Now - reginfo[i].lastcon) >= reginfo[i].altime) {
if (reginfo[i].altime < 600) {
kill(reginfo[i].pid, SIGKILL);
Syslog('+', "Send SIGKILL to pid %d", reginfo[i].pid);
} else {
kill(reginfo[i].pid, SIGTERM);
Syslog('+', "Send SIGTERM to pid %d", reginfo[i].pid);
}
/*
* 10 seconds to the next kill
*/
reginfo[i].altime = 10;
reginfo[i].lastcon = time(NULL);
}
}
} }
}
} }
@ -349,39 +354,56 @@ int reg_user(char *data)
/*
* Register sysop available for chat
*/
int reg_sysop(char *data)
{
char *cnt;
cnt = strtok(data, ",");
sysop_present = atoi(strtok(NULL, ";"));
Syslog('+', "Sysop present for chat: %s", sysop_present ? "True":"False");
return 0;
}
/* /*
* Check for personal message * Check for personal message
*/ */
char *reg_ipm(char *data) char *reg_ipm(char *data)
{ {
char *cnt, *pid; char *cnt, *pid;
static char buf[128]; static char buf[128];
int rec; int rec;
buf[0] = '\0'; buf[0] = '\0';
sprintf(buf, "100:0;");
sprintf(buf, "100:0;"); cnt = strtok(data, ",");
cnt = strtok(data, ","); pid = strtok(NULL, ";");
pid = strtok(NULL, ";");
if ((rec = reg_find(pid)) == -1)
return buf;
reginfo[rec].lastcon = time(NULL);
if (!reginfo[rec].ismsg)
return buf;
buf[0] = '\0';
sprintf(buf, "100:2,%s,%s;", reginfo[rec].fname[reginfo[rec].ptr_out], reginfo[rec].msg[reginfo[rec].ptr_out]);
if (reginfo[rec].ptr_out < RB)
reginfo[rec].ptr_out++;
else
reginfo[rec].ptr_out = 0;
if (reginfo[rec].ptr_out == reginfo[rec].ptr_in)
reginfo[rec].ismsg = FALSE;
Syslog('+', "reg_ipm: in=%d out=%d ismsg=%d", reginfo[rec].ptr_in, reginfo[rec].ptr_out, reginfo[rec].ismsg);
if ((rec = reg_find(pid)) == -1)
return buf; return buf;
reginfo[rec].lastcon = time(NULL);
if (!reginfo[rec].ismsg || (reginfo[rec].channel != -1))
return buf;
buf[0] = '\0';
sprintf(buf, "100:3,%d,%s,%s;", reginfo[rec].channel,
reginfo[rec].fname[reginfo[rec].ptr_out], reginfo[rec].msg[reginfo[rec].ptr_out]);
if (reginfo[rec].ptr_out < RB)
reginfo[rec].ptr_out++;
else
reginfo[rec].ptr_out = 0;
if (reginfo[rec].ptr_out == reginfo[rec].ptr_in)
reginfo[rec].ismsg = FALSE;
Syslog('+', "reg_ipm: ch=%d in=%d out=%d ismsg=%d", reginfo[rec].channel,
reginfo[rec].ptr_in, reginfo[rec].ptr_out, reginfo[rec].ismsg);
return buf;
} }
@ -391,51 +413,77 @@ char *reg_ipm(char *data)
*/ */
int reg_spm(char *data) int reg_spm(char *data)
{ {
char *cnt, *from, *too, *txt; char *cnt, *from, *too, *txt;
int i; int ch, i;
cnt = strtok(data, ","); cnt = strtok(data, ",");
from = strtok(NULL, ","); ch = atoi(strtok(NULL, ","));
too = strtok(NULL, ","); from = strtok(NULL, ",");
txt = strtok(NULL, ";"); too = strtok(NULL, ",");
txt = strtok(NULL, "\0");
txt[strlen(txt)-1] = '\0';
for (i = 1; i < MAXCLIENT; i++) { Syslog('-', "SIPM:%s,%d,%s,%s,%s;", cnt, ch, from, too, txt);
if (reginfo[i].pid && (strcasecmp(reginfo[i].uname, too) == 0)) {
/*
* If the in and out pointers are the same and the
* message present flag is still set, then this user
* can't get anymore new messages.
*/
if (reginfo[i].ismsg && (reginfo[i].ptr_in == reginfo[i].ptr_out)) {
return 2;
}
/* for (i = 0; i < MAXCLIENT; i++) {
* If user has the "do not distrurb" flag set. /*
*/ * Personal messages and sysop/user chat messages.
if (reginfo[i].silent) { */
return 1; if (reginfo[i].pid && (strcasecmp(reginfo[i].uname, too) == 0) && ((ch == -1) || (ch == 0)) && (ch == reginfo[i].channel)) {
} /*
* If the in and out pointers are the same and the
* message present flag is still set, then this user
* can't get anymore new messages.
*/
if (reginfo[i].ismsg && (reginfo[i].ptr_in == reginfo[i].ptr_out)) {
return 2;
}
/* /*
* If all is well, insert the new message. * If user has the "do not distrurb" flag set, but the sysop ignore's this.
*/ */
strncpy((char *)&reginfo[i].fname[reginfo[i].ptr_in], from, 35); if (reginfo[i].silent && (ch == -1)) {
strncpy((char *)&reginfo[i].msg[reginfo[i].ptr_in], txt, 80); return 1;
if (reginfo[i].ptr_in < RB) }
reginfo[i].ptr_in++;
else /*
reginfo[i].ptr_in = 0; * If all is well, insert the new message.
reginfo[i].ismsg = TRUE; */
Syslog('+', "reg_spm: in=%d out=%d ismsg=%d", reginfo[i].ptr_in, reginfo[i].ptr_out, reginfo[i].ismsg); strncpy((char *)&reginfo[i].fname[reginfo[i].ptr_in], from, 35);
return 0; strncpy((char *)&reginfo[i].msg[reginfo[i].ptr_in], txt, 80);
} if (reginfo[i].ptr_in < RB)
reginfo[i].ptr_in++;
else
reginfo[i].ptr_in = 0;
reginfo[i].ismsg = TRUE;
Syslog('+', "reg_spm: in=%d out=%d ismsg=%d", reginfo[i].ptr_in, reginfo[i].ptr_out, reginfo[i].ismsg);
return 0;
} }
/* /*
* User not found * Chat messages, they are send to each user that is chatting in the right channel.
*/ */
return 3; if (reginfo[i].pid && reginfo[i].chatting && reginfo[i].channel == ch) {
if (reginfo[i].ismsg && (reginfo[i].ptr_in == reginfo[i].ptr_out)) {
Syslog('!', "reg_spm: buffer full for %s", reginfo[i].uname);
} else {
strncpy((char *)&reginfo[i].fname[reginfo[i].ptr_in], from, 35);
strncpy((char *)&reginfo[i].msg[reginfo[i].ptr_in], txt, 80);
if (reginfo[i].ptr_in < RB)
reginfo[i].ptr_in++;
else
reginfo[i].ptr_in = 0;
reginfo[i].ismsg = TRUE;
Syslog('+', "reg_spm: user=%s in=%d out=%d ismsg=%d", reginfo[i].uname, reginfo[i].ptr_in,
reginfo[i].ptr_out, reginfo[i].ismsg);
}
}
}
if ((ch == -1) || (ch == 0))
return 3; // Error
return 0; // Ok
} }

View File

@ -26,16 +26,21 @@ typedef struct _reg_info {
unsigned chatting : 1; /* User is chatting */ unsigned chatting : 1; /* User is chatting */
unsigned ismsg : 1; /* Message waiting */ unsigned ismsg : 1; /* Message waiting */
unsigned istcp : 1; /* Is a TCP/IP session */ unsigned istcp : 1; /* Is a TCP/IP session */
unsigned paging : 1; /* Is paging sysop */
unsigned haspaged : 1; /* Has paged sysop */
unsigned moderator : 1; /* Is channel moderator */
int channel; /* Chat channel */ int channel; /* Chat channel */
int ptr_in; /* Input buffer pointer */ int ptr_in; /* Input buffer pointer */
int ptr_out; /* Output buffer ptr */ int ptr_out; /* Output buffer ptr */
char fname[RB][36]; /* Message from user */ char fname[RB][36]; /* Message from user */
char msg[RB][81]; /* The message itself */ char msg[RB][81]; /* The message itself */
char reason[81]; /* Chat reason */
char chname[21]; /* Short channel name */
char chsubj[61]; /* Channel subject */
} reg_info; } reg_info;
void reg_init(void);
int reg_newcon(char *); int reg_newcon(char *);
int reg_closecon(char *); int reg_closecon(char *);
void reg_check(void); void reg_check(void);
@ -50,6 +55,7 @@ char *reg_ipm(char *);
int reg_spm(char *); int reg_spm(char *);
char *reg_fre(void); char *reg_fre(void);
char *get_reginfo(int); char *get_reginfo(int);
int reg_sysop(char *);
#endif #endif

View File

@ -159,7 +159,7 @@ void Syslog(int grade, const char *format, ...)
*/ */
int ulog(char *fn, char *grade, char *prname, char *prpid, char *format) int ulog(char *fn, char *grade, char *prname, char *prpid, char *format)
{ {
int oldmask; int i, oldmask;
FILE *log; FILE *log;
oldmask = umask(066); oldmask = umask(066);
@ -172,10 +172,17 @@ int ulog(char *fn, char *grade, char *prname, char *prpid, char *format)
} }
fprintf(log, "%s %s %s[%s] ", grade, date(), prname, prpid); fprintf(log, "%s %s %s[%s] ", grade, date(), prname, prpid);
fwrite(format, strlen(format), 1, log); for (i = 0; i < strlen(format); i++) {
fprintf(log, "\n"); if (iscntrl(format[i])) {
fputc('^', log);
fputc(format[i] + 64, log);
} else {
fputc(format[i], log);
}
}
fputc('\n', log);
fflush(log); fflush(log);
if (fclose(log) != 0) { if (fclose(log) != 0) {
oserr = errno; oserr = errno;
Syslog('!', "$Cannot close user logfile %s", fn); Syslog('!', "$Cannot close user logfile %s", fn);