Finished tasks now report using a signal call
This commit is contained in:
parent
e0079fb364
commit
a41d4dab47
@ -6,10 +6,14 @@ v0.83.11 28-Jan-2006
|
|||||||
When the IBC server detects a IP change of a remote server it
|
When the IBC server detects a IP change of a remote server it
|
||||||
will completly restart the connection with that remote.
|
will completly restart the connection with that remote.
|
||||||
Made several functions multithread aware (still not Ok).
|
Made several functions multithread aware (still not Ok).
|
||||||
|
Finished tasks now report using a signal call.
|
||||||
|
|
||||||
mbcico:
|
mbcico:
|
||||||
Assume EXTCMD is set when GZ or BZ2 is active.
|
Assume EXTCMD is set when GZ or BZ2 is active.
|
||||||
|
|
||||||
|
mbstat:
|
||||||
|
Added semafore names to help.
|
||||||
|
|
||||||
|
|
||||||
v0.83.10 25-Jan-2006 - 28-Jan-2006
|
v0.83.10 25-Jan-2006 - 28-Jan-2006
|
||||||
|
|
||||||
|
@ -555,6 +555,30 @@ int runtasktype(int tasktype)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Signal handler for finished tasks
|
||||||
|
*/
|
||||||
|
void taskdie(int);
|
||||||
|
void taskdie(int onsig)
|
||||||
|
{
|
||||||
|
int i, status;
|
||||||
|
|
||||||
|
Syslog('t', "taskdie(%s)", SigName[onsig]);
|
||||||
|
|
||||||
|
for (i = 0; i < MAXTASKS; i++) {
|
||||||
|
if (strlen(task[i].name)) {
|
||||||
|
task[i].rc = wait4(task[i].pid, &status, WNOHANG | WUNTRACED, NULL);
|
||||||
|
if (task[i].rc) {
|
||||||
|
task[i].running = FALSE;
|
||||||
|
task[i].status = status;
|
||||||
|
Syslog('t', "taskdie() set task %d not running, rc=%d, status=%d", i, task[i].rc, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check all running tasks registered in the tasklist.
|
* Check all running tasks registered in the tasklist.
|
||||||
* Report programs that are stopped. If signal is set
|
* Report programs that are stopped. If signal is set
|
||||||
@ -562,7 +586,7 @@ int runtasktype(int tasktype)
|
|||||||
*/
|
*/
|
||||||
int checktasks(int onsig)
|
int checktasks(int onsig)
|
||||||
{
|
{
|
||||||
int i, j, rc, count = 0, first = TRUE, status;
|
int i, j, rc, count = 0, first = TRUE;
|
||||||
|
|
||||||
for (i = 0; i < MAXTASKS; i++) {
|
for (i = 0; i < MAXTASKS; i++) {
|
||||||
if (strlen(task[i].name)) {
|
if (strlen(task[i].name)) {
|
||||||
@ -574,9 +598,11 @@ int checktasks(int onsig)
|
|||||||
Syslog('+', "%s to %s (pid %d) failed", SigName[onsig], task[i].name, task[i].pid);
|
Syslog('+', "%s to %s (pid %d) failed", SigName[onsig], task[i].name, task[i].pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
task[i].rc = wait4(task[i].pid, &status, WNOHANG | WUNTRACED, NULL);
|
// task[i].rc = wait4(task[i].pid, &status, WNOHANG | WUNTRACED, NULL);
|
||||||
if (task[i].rc) {
|
// if (task[i].rc) {
|
||||||
task[i].running = FALSE;
|
// task[i].running = FALSE;
|
||||||
|
|
||||||
|
if (task[i].running == FALSE) {
|
||||||
/*
|
/*
|
||||||
* If a mailer call is finished, set the global rescan flag.
|
* If a mailer call is finished, set the global rescan flag.
|
||||||
*/
|
*/
|
||||||
@ -613,7 +639,7 @@ int checktasks(int onsig)
|
|||||||
/*
|
/*
|
||||||
* Update last known status when running.
|
* Update last known status when running.
|
||||||
*/
|
*/
|
||||||
task[i].status = status;
|
// task[i].status = status;
|
||||||
count++;
|
count++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -777,6 +803,7 @@ void die(int onsig)
|
|||||||
* Free memory
|
* Free memory
|
||||||
*/
|
*/
|
||||||
deinitnl();
|
deinitnl();
|
||||||
|
unload_ports();
|
||||||
ulocktask();
|
ulocktask();
|
||||||
printable(NULL, 0);
|
printable(NULL, 0);
|
||||||
|
|
||||||
@ -1499,7 +1526,8 @@ int main(int argc, char **argv)
|
|||||||
else if ((i == SIGINT) || (i == SIGTERM))
|
else if ((i == SIGINT) || (i == SIGTERM))
|
||||||
signal(i, (void (*))start_shutdown);
|
signal(i, (void (*))start_shutdown);
|
||||||
else if (i == SIGCHLD)
|
else if (i == SIGCHLD)
|
||||||
signal(i, SIG_DFL);
|
// signal(i, SIG_DFL);
|
||||||
|
signal(i, (void (*))taskdie);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Purpose ...............: mbtask - mode portlists
|
* Purpose ...............: mbtask - mode portlists
|
||||||
*
|
*
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
* Copyright (C) 1997-2005
|
* Copyright (C) 1997-2006
|
||||||
*
|
*
|
||||||
* Michiel Broek FIDO: 2:280/2802
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
* Beekmansbos 10
|
* Beekmansbos 10
|
||||||
@ -176,6 +176,13 @@ void load_ports()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void unload_ports()
|
||||||
|
{
|
||||||
|
tidy_portlist(&pl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check status of all modem/ISDN ports.
|
* Check status of all modem/ISDN ports.
|
||||||
* If something is changed set the master rescan flag.
|
* If something is changed set the master rescan flag.
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
/* $Id$ */
|
|
||||||
|
|
||||||
#ifndef _PORTS_H
|
#ifndef _PORTS_H
|
||||||
#define _PORTS_H
|
#define _PORTS_H
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -23,6 +22,7 @@ struct _ttyinfo ttyinfo;
|
|||||||
|
|
||||||
|
|
||||||
void load_ports(void); /* Initialize portlist */
|
void load_ports(void); /* Initialize portlist */
|
||||||
|
void unload_ports(void); /* Deinitialize portlist */
|
||||||
void check_ports(void); /* Check status of all ports */
|
void check_ports(void); /* Check status of all ports */
|
||||||
|
|
||||||
|
|
||||||
|
@ -394,25 +394,23 @@ void chat_msg(char *channel, char *nick, char *msg)
|
|||||||
/*
|
/*
|
||||||
* Connect a session to the chatserver.
|
* Connect a session to the chatserver.
|
||||||
*/
|
*/
|
||||||
char *chat_connect(char *data)
|
void chat_connect_r(char *data, char *buf)
|
||||||
{
|
{
|
||||||
char *pid, *realname, *nick;
|
char *pid, *realname, *nick, *temp;
|
||||||
static char buf[200];
|
|
||||||
int count = 0, sys = FALSE;
|
int count = 0, sys = FALSE;
|
||||||
srv_list *sl;
|
srv_list *sl;
|
||||||
usr_list *tmpu;
|
usr_list *tmpu;
|
||||||
|
|
||||||
Syslog('c', "CCON:%s", data);
|
Syslog('c', "CCON:%s", data);
|
||||||
memset(&buf, 0, sizeof(buf));
|
|
||||||
|
|
||||||
if (IsSema((char *)"upsalarm")) {
|
if (IsSema((char *)"upsalarm")) {
|
||||||
snprintf(buf, 200, "100:1,*** Power failure, running on UPS;");
|
snprintf(buf, 200, "100:1,*** Power failure, running on UPS;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_bbsopen == FALSE) {
|
if (s_bbsopen == FALSE) {
|
||||||
snprintf(buf, 200, "100:1,*** The BBS is closed now;");
|
snprintf(buf, 200, "100:1,*** The BBS is closed now;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -448,38 +446,42 @@ char *chat_connect(char *data)
|
|||||||
/*
|
/*
|
||||||
* Now put welcome message into the ringbuffer and report success.
|
* Now put welcome message into the ringbuffer and report success.
|
||||||
*/
|
*/
|
||||||
snprintf(buf, 200, "MBSE BBS v%s chat server; type /help for help", VERSION);
|
temp = calloc(81, sizeof(char));
|
||||||
system_msg(tmpu->pid, buf);
|
snprintf(temp, 200, "MBSE BBS v%s chat server; type /help for help", VERSION);
|
||||||
snprintf(buf, 200, "Welcome to the Internet BBS Chat Network");
|
system_msg(tmpu->pid, temp);
|
||||||
system_msg(tmpu->pid, buf);
|
snprintf(temp, 200, "Welcome to the Internet BBS Chat Network");
|
||||||
|
system_msg(tmpu->pid, temp);
|
||||||
snprintf(buf, 200, "Current connected servers:");
|
snprintf(buf, 200, "Current connected servers:");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, temp);
|
||||||
for (sl = servers; sl; sl = sl->next) {
|
for (sl = servers; sl; sl = sl->next) {
|
||||||
snprintf(buf, 200, " %s (%d user%s)", sl->fullname, sl->users, (sl->users == 1) ? "":"s");
|
snprintf(temp, 200, " %s (%d user%s)", sl->fullname, sl->users, (sl->users == 1) ? "":"s");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, temp);
|
||||||
count += sl->users;
|
count += sl->users;
|
||||||
}
|
}
|
||||||
snprintf(buf, 200, "There %s %d user%s connected", (count != 1)?"are":"is", count, (count != 1)?"s":"");
|
snprintf(temp, 200, "There %s %d user%s connected", (count != 1)?"are":"is", count, (count != 1)?"s":"");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, temp);
|
||||||
snprintf(buf, 200, "100:0;");
|
snprintf(buf, 200, "100:0;");
|
||||||
return buf;
|
free(realname);
|
||||||
|
free(nick);
|
||||||
|
free(temp);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(realname);
|
||||||
|
free(nick);
|
||||||
snprintf(buf, 200, "100:1,Too many users connected;");
|
snprintf(buf, 200, "100:1,Too many users connected;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *chat_close(char *data)
|
void chat_close_r(char *data, char *buf)
|
||||||
{
|
{
|
||||||
static char buf[81];
|
|
||||||
char *pid;
|
char *pid;
|
||||||
usr_list *tmpu;
|
usr_list *tmpu;
|
||||||
|
|
||||||
Syslog('c', "CCLO:%s", data);
|
Syslog('c', "CCLO:%s", data);
|
||||||
memset(&buf, 0, sizeof(buf));
|
|
||||||
pid = strtok(data, ",");
|
pid = strtok(data, ",");
|
||||||
pid = strtok(NULL, ";");
|
pid = strtok(NULL, ";");
|
||||||
|
|
||||||
@ -492,20 +494,19 @@ char *chat_close(char *data)
|
|||||||
del_user(&users, CFG.myfqdn, tmpu->name);
|
del_user(&users, CFG.myfqdn, tmpu->name);
|
||||||
Syslog('c', "Closing chat for pid %s", pid);
|
Syslog('c', "Closing chat for pid %s", pid);
|
||||||
snprintf(buf, 81, "100:0;");
|
snprintf(buf, 81, "100:0;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Syslog('c', "Pid %s was not connected to chatserver");
|
Syslog('c', "Pid %s was not connected to chatserver");
|
||||||
snprintf(buf, 81, "100:1,*** ERROR - Not connected to server;");
|
snprintf(buf, 81, "100:1,*** ERROR - Not connected to server;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char *chat_put(char *data)
|
void chat_put_r(char *data, char *buf)
|
||||||
{
|
{
|
||||||
static char buf[200];
|
char *pid, *msg, *cmd, *mbuf;
|
||||||
char *pid, *msg, *cmd;
|
|
||||||
int first, count;
|
int first, count;
|
||||||
int found;
|
int found;
|
||||||
usr_list *tmpu, *tmp;
|
usr_list *tmpu, *tmp;
|
||||||
@ -513,21 +514,21 @@ char *chat_put(char *data)
|
|||||||
char temp[81];
|
char temp[81];
|
||||||
|
|
||||||
Syslog('c', "CPUT:%s", data);
|
Syslog('c', "CPUT:%s", data);
|
||||||
memset(&buf, 0, sizeof(buf));
|
|
||||||
|
|
||||||
if (IsSema((char *)"upsalarm")) {
|
if (IsSema((char *)"upsalarm")) {
|
||||||
snprintf(buf, 200, "100:2,1,*** Power alarm, running on UPS;");
|
snprintf(buf, 81, "100:2,1,*** Power alarm, running on UPS;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_bbsopen == FALSE) {
|
if (s_bbsopen == FALSE) {
|
||||||
snprintf(buf, 200, "100:2,1,*** The BBS is closed now;");
|
snprintf(buf, 81, "100:2,1,*** The BBS is closed now;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid = strtok(data, ",");
|
pid = strtok(data, ",");
|
||||||
pid = strtok(NULL, ",");
|
pid = strtok(NULL, ",");
|
||||||
msg = xstrcpy(cldecode(strtok(NULL, ";")));
|
msg = xstrcpy(cldecode(strtok(NULL, ";")));
|
||||||
|
mbuf = calloc(200, sizeof(char));
|
||||||
|
|
||||||
for (tmpu = users; tmpu; tmpu = tmpu->next) {
|
for (tmpu = users; tmpu; tmpu = tmpu->next) {
|
||||||
if (tmpu->pid == atoi(pid)) {
|
if (tmpu->pid == atoi(pid)) {
|
||||||
@ -539,15 +540,15 @@ char *chat_put(char *data)
|
|||||||
chat_help(atoi(pid));
|
chat_help(atoi(pid));
|
||||||
goto ack;
|
goto ack;
|
||||||
} else if (strncasecmp(msg, "/echo", 5) == 0) {
|
} else if (strncasecmp(msg, "/echo", 5) == 0) {
|
||||||
snprintf(buf, 200, "%s", msg);
|
snprintf(mbuf, 200, "%s", msg);
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
goto ack;
|
goto ack;
|
||||||
} else if ((strncasecmp(msg, "/exit", 5) == 0) ||
|
} else if ((strncasecmp(msg, "/exit", 5) == 0) ||
|
||||||
(strncasecmp(msg, "/quit", 5) == 0) ||
|
(strncasecmp(msg, "/quit", 5) == 0) ||
|
||||||
(strncasecmp(msg, "/bye", 4) == 0)) {
|
(strncasecmp(msg, "/bye", 4) == 0)) {
|
||||||
part(tmpu->pid, (char *)"Quitting");
|
part(tmpu->pid, (char *)"Quitting");
|
||||||
snprintf(buf, 200, "Goodbye");
|
snprintf(mbuf, 81, "Goodbye");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
goto hangup;
|
goto hangup;
|
||||||
} else if ((strncasecmp(msg, "/join", 5) == 0) ||
|
} else if ((strncasecmp(msg, "/join", 5) == 0) ||
|
||||||
(strncasecmp(msg, "/j ", 3) == 0)) {
|
(strncasecmp(msg, "/j ", 3) == 0)) {
|
||||||
@ -556,11 +557,11 @@ char *chat_put(char *data)
|
|||||||
cmd = strtok(NULL, "\0");
|
cmd = strtok(NULL, "\0");
|
||||||
Syslog('c', "\"%s\"", cmd);
|
Syslog('c', "\"%s\"", cmd);
|
||||||
if ((cmd == NULL) || (cmd[0] != '#') || (strcmp(cmd, "#") == 0)) {
|
if ((cmd == NULL) || (cmd[0] != '#') || (strcmp(cmd, "#") == 0)) {
|
||||||
snprintf(buf, 200, "** Try /join #channel");
|
snprintf(mbuf, 200, "** Try /join #channel");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
} else if (strlen(tmpu->channel)) {
|
} else if (strlen(tmpu->channel)) {
|
||||||
snprintf(buf, 200, "** Cannot join while in a channel");
|
snprintf(mbuf, 200, "** Cannot join while in a channel");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
} else {
|
} else {
|
||||||
Syslog('c', "Trying to join channel %s", cmd);
|
Syslog('c', "Trying to join channel %s", cmd);
|
||||||
join(tmpu->pid, cmd, tmpu->sysop);
|
join(tmpu->pid, cmd, tmpu->sysop);
|
||||||
@ -571,50 +572,50 @@ char *chat_put(char *data)
|
|||||||
first = TRUE;
|
first = TRUE;
|
||||||
for (tmpc = channels; tmpc; tmpc = tmpc->next) {
|
for (tmpc = channels; tmpc; tmpc = tmpc->next) {
|
||||||
if (first) {
|
if (first) {
|
||||||
snprintf(buf, 200, "Cnt Channel name Channel topic");
|
snprintf(mbuf, 200, "Cnt Channel name Channel topic");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
snprintf(buf, 200, "--- -------------------- ------------------------------------------------------");
|
snprintf(mbuf, 200, "--- -------------------- ------------------------------------------------------");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
}
|
}
|
||||||
first = FALSE;
|
first = FALSE;
|
||||||
snprintf(buf, 200, "%3d %-20s %-54s", tmpc->users, tmpc->name, tmpc->topic);
|
snprintf(mbuf, 200, "%3d %-20s %-54s", tmpc->users, tmpc->name, tmpc->topic);
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
}
|
}
|
||||||
if (first) {
|
if (first) {
|
||||||
snprintf(buf, 200, "No active channels to list");
|
snprintf(mbuf, 200, "No active channels to list");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
}
|
}
|
||||||
goto ack;
|
goto ack;
|
||||||
} else if (strncasecmp(msg, "/names", 6) == 0) {
|
} else if (strncasecmp(msg, "/names", 6) == 0) {
|
||||||
if (strlen(tmpu->channel)) {
|
if (strlen(tmpu->channel)) {
|
||||||
snprintf(buf, 200, "Present in channel %s:", tmpu->channel);
|
snprintf(mbuf, 200, "Present in channel %s:", tmpu->channel);
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
snprintf(buf, 200, "Nick Real name Flags");
|
snprintf(mbuf, 200, "Nick Real name Flags");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
snprintf(buf, 200, "---------------------------------------- ------------------------------ -------");
|
snprintf(mbuf, 200, "---------------------------------------- ------------------------------ -------");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
count = 0;
|
count = 0;
|
||||||
for (tmp = users; tmp; tmp = tmp->next) {
|
for (tmp = users; tmp; tmp = tmp->next) {
|
||||||
if (strcmp(tmp->channel, tmpu->channel) == 0) {
|
if (strcmp(tmp->channel, tmpu->channel) == 0) {
|
||||||
snprintf(temp, 81, "%s@%s", tmp->nick, tmp->server);
|
snprintf(temp, 81, "%s@%s", tmp->nick, tmp->server);
|
||||||
snprintf(buf, 200, "%-40s %-30s %s", temp, tmp->realname,
|
snprintf(mbuf, 200, "%-40s %-30s %s", temp, tmp->realname,
|
||||||
tmp->sysop ? (char *)"sysop" : (char *)"");
|
tmp->sysop ? (char *)"sysop" : (char *)"");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
snprintf(buf, 200, "%d user%s in this channel", count, (count == 1) ?"":"s");
|
snprintf(mbuf, 200, "%d user%s in this channel", count, (count == 1) ?"":"s");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf, 200, "** Not in a channel");
|
snprintf(mbuf, 200, "** Not in a channel");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
}
|
}
|
||||||
goto ack;
|
goto ack;
|
||||||
} else if (strncasecmp(msg, "/nick", 5) == 0) {
|
} else if (strncasecmp(msg, "/nick", 5) == 0) {
|
||||||
cmd = strtok(msg, " \0");
|
cmd = strtok(msg, " \0");
|
||||||
cmd = strtok(NULL, "\0");
|
cmd = strtok(NULL, "\0");
|
||||||
if ((cmd == NULL) || (strlen(cmd) == 0) || (strlen(cmd) > 9)) {
|
if ((cmd == NULL) || (strlen(cmd) == 0) || (strlen(cmd) > 9)) {
|
||||||
snprintf(buf, 200, "** Nickname must be between 1 and 9 characters");
|
snprintf(mbuf, 200, "** Nickname must be between 1 and 9 characters");
|
||||||
} else {
|
} else {
|
||||||
found = FALSE;
|
found = FALSE;
|
||||||
for (tmp = users; tmp; tmp = tmp->next) {
|
for (tmp = users; tmp; tmp = tmp->next) {
|
||||||
@ -625,16 +626,16 @@ char *chat_put(char *data)
|
|||||||
|
|
||||||
if (!found ) {
|
if (!found ) {
|
||||||
strncpy(tmpu->nick, cmd, 9);
|
strncpy(tmpu->nick, cmd, 9);
|
||||||
snprintf(buf, 200, "Nick set to \"%s\"", cmd);
|
snprintf(mbuf, 200, "Nick set to \"%s\"", cmd);
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
send_nick(tmpu->nick, tmpu->name, tmpu->realname);
|
send_nick(tmpu->nick, tmpu->name, tmpu->realname);
|
||||||
usrchg = TRUE;
|
usrchg = TRUE;
|
||||||
chat_dump();
|
chat_dump();
|
||||||
goto ack;
|
goto ack;
|
||||||
}
|
}
|
||||||
snprintf(buf, 200, "Can't set nick");
|
snprintf(mbuf, 200, "Can't set nick");
|
||||||
}
|
}
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
chat_dump();
|
chat_dump();
|
||||||
goto ack;
|
goto ack;
|
||||||
} else if (strncasecmp(msg, "/part", 5) == 0) {
|
} else if (strncasecmp(msg, "/part", 5) == 0) {
|
||||||
@ -643,36 +644,36 @@ char *chat_put(char *data)
|
|||||||
cmd = strtok(NULL, "\0");
|
cmd = strtok(NULL, "\0");
|
||||||
Syslog('c', "\"%s\"", printable(cmd, 0));
|
Syslog('c', "\"%s\"", printable(cmd, 0));
|
||||||
if (part(tmpu->pid, cmd ? cmd : (char *)"Quitting") == FALSE) {
|
if (part(tmpu->pid, cmd ? cmd : (char *)"Quitting") == FALSE) {
|
||||||
snprintf(buf, 200, "** Not in a channel");
|
snprintf(mbuf, 200, "** Not in a channel");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
}
|
}
|
||||||
chat_dump();
|
chat_dump();
|
||||||
goto ack;
|
goto ack;
|
||||||
} else if (strncasecmp(msg, "/topic", 6) == 0) {
|
} else if (strncasecmp(msg, "/topic", 6) == 0) {
|
||||||
if (strlen(tmpu->channel)) {
|
if (strlen(tmpu->channel)) {
|
||||||
snprintf(buf, 200, "** Internal system error");
|
snprintf(mbuf, 200, "** Internal system error");
|
||||||
for (tmpc = channels; tmpc; tmpc = tmpc->next) {
|
for (tmpc = channels; tmpc; tmpc = tmpc->next) {
|
||||||
if (strcmp(tmpu->channel, tmpc->name) == 0) {
|
if (strcmp(tmpu->channel, tmpc->name) == 0) {
|
||||||
if ((strcmp(tmpu->name, tmpc->owner) == 0) || (strcmp(tmpu->nick, tmpc->owner) == 0)) {
|
if ((strcmp(tmpu->name, tmpc->owner) == 0) || (strcmp(tmpu->nick, tmpc->owner) == 0)) {
|
||||||
cmd = strtok(msg, " \0");
|
cmd = strtok(msg, " \0");
|
||||||
cmd = strtok(NULL, "\0");
|
cmd = strtok(NULL, "\0");
|
||||||
if ((cmd == NULL) || (strlen(cmd) == 0) || (strlen(cmd) > 54)) {
|
if ((cmd == NULL) || (strlen(cmd) == 0) || (strlen(cmd) > 54)) {
|
||||||
snprintf(buf, 200, "** Topic must be between 1 and 54 characters");
|
snprintf(mbuf, 200, "** Topic must be between 1 and 54 characters");
|
||||||
} else {
|
} else {
|
||||||
strncpy(tmpc->topic, cmd, 54);
|
strncpy(tmpc->topic, cmd, 54);
|
||||||
snprintf(buf, 200, "Topic set to \"%s\"", cmd);
|
snprintf(mbuf, 200, "Topic set to \"%s\"", cmd);
|
||||||
send_all("TOPIC %s %s\r\n", tmpc->name, tmpc->topic);
|
send_all("TOPIC %s %s\r\n", tmpc->name, tmpc->topic);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf, 200, "** You are not the channel owner");
|
snprintf(mbuf, 200, "** You are not the channel owner");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf, 200, "** Not in a channel");
|
snprintf(mbuf, 200, "** Not in a channel");
|
||||||
}
|
}
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
chat_dump();
|
chat_dump();
|
||||||
goto ack;
|
goto ack;
|
||||||
} else {
|
} else {
|
||||||
@ -680,8 +681,8 @@ char *chat_put(char *data)
|
|||||||
* If still here, the command was not recognized.
|
* If still here, the command was not recognized.
|
||||||
*/
|
*/
|
||||||
cmd = strtok(msg, " \t\r\n\0");
|
cmd = strtok(msg, " \t\r\n\0");
|
||||||
snprintf(buf, 200, "*** \"%s\" :Unknown command", cmd+1);
|
snprintf(mbuf, 200, "*** \"%s\" :Unknown command", cmd+1);
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
goto ack;
|
goto ack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -689,8 +690,8 @@ char *chat_put(char *data)
|
|||||||
/*
|
/*
|
||||||
* Trying messages while not in a channel
|
* Trying messages while not in a channel
|
||||||
*/
|
*/
|
||||||
snprintf(buf, 200, "** No channel joined. Try /join #channel");
|
snprintf(mbuf, 200, "** No channel joined. Try /join #channel");
|
||||||
system_msg(tmpu->pid, buf);
|
system_msg(tmpu->pid, mbuf);
|
||||||
chat_dump();
|
chat_dump();
|
||||||
goto ack;
|
goto ack;
|
||||||
} else {
|
} else {
|
||||||
@ -701,20 +702,23 @@ char *chat_put(char *data)
|
|||||||
goto ack;
|
goto ack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Syslog('c', "Pid %s was not connected to chatserver");
|
Syslog('c', "Pid %s was not connected to chatserver", pid);
|
||||||
snprintf(buf, 200, "100:2,1,*** ERROR - Not connected to server;");
|
snprintf(buf, 200, "100:2,1,*** ERROR - Not connected to server;");
|
||||||
free(msg);
|
free(msg);
|
||||||
return buf;
|
free(mbuf);
|
||||||
|
return;
|
||||||
|
|
||||||
ack:
|
ack:
|
||||||
snprintf(buf, 200, "100:0;");
|
snprintf(buf, 200, "100:0;");
|
||||||
free(msg);
|
free(msg);
|
||||||
return buf;
|
free(mbuf);
|
||||||
|
return;
|
||||||
|
|
||||||
hangup:
|
hangup:
|
||||||
snprintf(buf, 200, "100:2,1,Disconnecting;");
|
snprintf(buf, 200, "100:2,1,Disconnecting;");
|
||||||
free(msg);
|
free(msg);
|
||||||
return buf;
|
free(mbuf);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -723,23 +727,21 @@ hangup:
|
|||||||
* Check for a message for the user. Return the message or signal that
|
* Check for a message for the user. Return the message or signal that
|
||||||
* nothing is there to display.
|
* nothing is there to display.
|
||||||
*/
|
*/
|
||||||
char *chat_get(char *data)
|
void chat_get_r(char *data, char *buf)
|
||||||
{
|
{
|
||||||
static char buf[200];
|
|
||||||
char *pid;
|
char *pid;
|
||||||
usr_list *tmpu;
|
usr_list *tmpu;
|
||||||
|
|
||||||
if (IsSema((char *)"upsalarm")) {
|
if (IsSema((char *)"upsalarm")) {
|
||||||
snprintf(buf, 200, "100:2,1,*** Power failure, running on UPS;");
|
snprintf(buf, 200, "100:2,1,*** Power failure, running on UPS;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_bbsopen == FALSE) {
|
if (s_bbsopen == FALSE) {
|
||||||
snprintf(buf, 200, "100:2,1,*** The BBS is closed now;");
|
snprintf(buf, 200, "100:2,1,*** The BBS is closed now;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&buf, 0, sizeof(buf));
|
|
||||||
pid = strtok(data, ",");
|
pid = strtok(data, ",");
|
||||||
pid = strtok(NULL, ";");
|
pid = strtok(NULL, ";");
|
||||||
|
|
||||||
@ -756,15 +758,15 @@ char *chat_get(char *data)
|
|||||||
*/
|
*/
|
||||||
snprintf(buf, 200, "100:2,0,%s;", clencode(chat_messages[tmpu->pointer].message));
|
snprintf(buf, 200, "100:2,0,%s;", clencode(chat_messages[tmpu->pointer].message));
|
||||||
Syslog('c', "%s", buf);
|
Syslog('c', "%s", buf);
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
snprintf(buf, 200, "100:0;");
|
snprintf(buf, 200, "100:0;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
snprintf(buf, 200, "100:2,1,*** ERROR - Not connected to server;");
|
snprintf(buf, 200, "100:2,1,*** ERROR - Not connected to server;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -772,13 +774,11 @@ char *chat_get(char *data)
|
|||||||
/*
|
/*
|
||||||
* Check for sysop present for forced chat
|
* Check for sysop present for forced chat
|
||||||
*/
|
*/
|
||||||
char *chat_checksysop(char *data)
|
void chat_checksysop_r(char *data, char *buf)
|
||||||
{
|
{
|
||||||
static char buf[20];
|
|
||||||
char *pid;
|
char *pid;
|
||||||
usr_list *tmpu;
|
usr_list *tmpu;
|
||||||
|
|
||||||
memset(&buf, 0, sizeof(buf));
|
|
||||||
pid = strtok(data, ",");
|
pid = strtok(data, ",");
|
||||||
pid = strtok(NULL, ";");
|
pid = strtok(NULL, ";");
|
||||||
|
|
||||||
@ -794,14 +794,14 @@ char *chat_checksysop(char *data)
|
|||||||
Syslog('c', "Sending ACK on check");
|
Syslog('c', "Sending ACK on check");
|
||||||
snprintf(buf, 20, "100:1,1;");
|
snprintf(buf, 20, "100:1,1;");
|
||||||
reg_sysoptalk(pid);
|
reg_sysoptalk(pid);
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(buf, 20, "100:1,0;");
|
snprintf(buf, 20, "100:1,0;");
|
||||||
return buf;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@ void chat_msg(char *, char *, char *);
|
|||||||
void system_shout(const char *, ...);
|
void system_shout(const char *, ...);
|
||||||
void chat_init(void);
|
void chat_init(void);
|
||||||
void chat_cleanuser(pid_t);
|
void chat_cleanuser(pid_t);
|
||||||
char *chat_connect(char *);
|
void chat_connect_r(char *, char *);
|
||||||
char *chat_close(char *);
|
void chat_close_r(char *, char *);
|
||||||
char *chat_put(char *);
|
void chat_put_r(char *, char *);
|
||||||
char *chat_get(char *);
|
void chat_get_r(char *, char *);
|
||||||
char *chat_checksysop(char *);
|
void chat_checksysop_r(char *, char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -332,7 +332,11 @@ char *exe_cmd(char *in)
|
|||||||
* 100:1,0; No
|
* 100:1,0; No
|
||||||
*/
|
*/
|
||||||
if (strncmp(cmd, "CISC", 4) == 0) {
|
if (strncmp(cmd, "CISC", 4) == 0) {
|
||||||
return chat_checksysop(token);
|
buf = calloc(SS_BUFSIZE, sizeof(char));
|
||||||
|
chat_checksysop_r(token, buf);
|
||||||
|
snprintf(obuf, SS_BUFSIZE, "%s", buf);
|
||||||
|
free(buf);
|
||||||
|
return obuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -343,11 +347,16 @@ char *exe_cmd(char *in)
|
|||||||
* 100:0; Ok
|
* 100:0; Ok
|
||||||
*/
|
*/
|
||||||
if (strncmp(cmd, "CCON", 4) == 0) {
|
if (strncmp(cmd, "CCON", 4) == 0) {
|
||||||
if (ibc_run)
|
if (ibc_run) {
|
||||||
return chat_connect(token);
|
buf = calloc(SS_BUFSIZE, sizeof(char));
|
||||||
else
|
chat_connect_r(token, buf);
|
||||||
|
snprintf(obuf, SS_BUFSIZE, "%s", buf);
|
||||||
|
free(buf);
|
||||||
|
return obuf;
|
||||||
|
} else {
|
||||||
return ebuf;
|
return ebuf;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close chat session
|
* Close chat session
|
||||||
@ -357,7 +366,11 @@ char *exe_cmd(char *in)
|
|||||||
* 100:0; Ok
|
* 100:0; Ok
|
||||||
*/
|
*/
|
||||||
if (strncmp(cmd, "CCLO", 4) == 0) {
|
if (strncmp(cmd, "CCLO", 4) == 0) {
|
||||||
return chat_close(token);
|
buf = calloc(SS_BUFSIZE, sizeof(char));
|
||||||
|
chat_close_r(token, buf);
|
||||||
|
snprintf(obuf, SS_BUFSIZE, "%s", buf);
|
||||||
|
free(buf);
|
||||||
|
return obuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -369,7 +382,11 @@ char *exe_cmd(char *in)
|
|||||||
* 100:0; Ok
|
* 100:0; Ok
|
||||||
*/
|
*/
|
||||||
if (strncmp(cmd, "CPUT", 4) == 0) {
|
if (strncmp(cmd, "CPUT", 4) == 0) {
|
||||||
return chat_put(token);
|
buf = calloc(SS_BUFSIZE, sizeof(char));
|
||||||
|
chat_put_r(token, buf);
|
||||||
|
snprintf(obuf, SS_BUFSIZE, "%s", buf);
|
||||||
|
free(buf);
|
||||||
|
return obuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -381,7 +398,11 @@ char *exe_cmd(char *in)
|
|||||||
* 100:0; No message
|
* 100:0; No message
|
||||||
*/
|
*/
|
||||||
if (strncmp(cmd, "CGET", 4) == 0) {
|
if (strncmp(cmd, "CGET", 4) == 0) {
|
||||||
return chat_get(token);
|
buf = calloc(SS_BUFSIZE, sizeof(char));
|
||||||
|
chat_get_r(token, buf);
|
||||||
|
snprintf(obuf, SS_BUFSIZE, "%s", buf);
|
||||||
|
free(buf);
|
||||||
|
return obuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user