Several small changes and fixes
This commit is contained in:
parent
a2da4208c3
commit
a894a7b08e
@ -8,6 +8,8 @@ v0.83.18 01-Apr-2006
|
||||
|
||||
mbtask:
|
||||
Removed some debug logging.
|
||||
Fixed a small bug.
|
||||
Code cleanup.
|
||||
|
||||
|
||||
v0.83.17 27-Mar-2006 - 01-Apr-2006
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: mbtask - calllist
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2005
|
||||
* Copyright (C) 1997-2006
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -56,11 +56,12 @@ extern struct taskrec TCFG;
|
||||
|
||||
|
||||
/*
|
||||
* Check the actual list of nodes to call.
|
||||
* Check the actual list of nodes to call.
|
||||
* Returns number of systems to call.
|
||||
*/
|
||||
int check_calllist(void)
|
||||
{
|
||||
int i, found, call_work;
|
||||
int i, found, call_work = 0;
|
||||
struct _alist *tmp;
|
||||
char *buf;
|
||||
|
||||
@ -88,7 +89,6 @@ 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)) &&
|
||||
|
@ -1097,7 +1097,7 @@ void scheduler(void)
|
||||
struct passwd *pw;
|
||||
int rlen, rc, running = 0, i, found, call_work = 0, len;
|
||||
static int LOADhi = FALSE, oldmin = 70, olddo = 70, oldsec = 70, call_entry = MAXTASKS;
|
||||
char *cmd = NULL, opts[41], port[21], crbuf[512];
|
||||
char *cmd = NULL, *opts, port[21], crbuf[512];
|
||||
static char doing[32], buf[2048];
|
||||
time_t now;
|
||||
struct tm tm, utm;
|
||||
@ -1110,7 +1110,7 @@ void scheduler(void)
|
||||
socklen_t sl;
|
||||
struct sockaddr_in ffrom;
|
||||
|
||||
Syslog('+', "Starting scheduler thread");
|
||||
Syslog('+', "Starting scheduler loop");
|
||||
pw = getpwuid(getuid());
|
||||
|
||||
/*
|
||||
@ -1120,7 +1120,7 @@ void scheduler(void)
|
||||
/*
|
||||
* Poll UNIX Datagram socket and IBC UDP socket until the defined
|
||||
* timeout of one second.
|
||||
* This means we listen of a MBSE BBS client program has something
|
||||
* This means we listen if a MBSE BBS client program has something
|
||||
* to tell. Timeout is one second, after the timeout the rest of the
|
||||
* mainloop is executed.
|
||||
*/
|
||||
@ -1146,19 +1146,22 @@ void scheduler(void)
|
||||
} else if (rc) {
|
||||
if (pfd[0].revents & POLLIN) {
|
||||
/*
|
||||
* Process the clients request
|
||||
* Process the clients request for mbtask commands.
|
||||
*/
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
fromlen = sizeof(from);
|
||||
rlen = recvfrom(sock, buf, sizeof(buf) -1, 0, (struct sockaddr *)&from, &fromlen);
|
||||
if (rlen == -1) {
|
||||
Syslog('?', "$recvfrom() for command receiver");
|
||||
WriteError("$recvfrom() for command receiver");
|
||||
} else {
|
||||
do_cmd(buf);
|
||||
}
|
||||
}
|
||||
if ((pfd[1].revents & POLLIN || pfd[1].revents & POLLERR ||
|
||||
pfd[1].revents & POLLHUP || pfd[1].revents & POLLNVAL) && Run_IBC) {
|
||||
/*
|
||||
* IBC chat command received.
|
||||
*/
|
||||
sl = sizeof(myaddr_in);
|
||||
memset(&clientaddr_in, 0, sizeof(struct sockaddr_in));
|
||||
memset(&crbuf, 0, sizeof(crbuf));
|
||||
@ -1169,6 +1172,9 @@ void scheduler(void)
|
||||
}
|
||||
}
|
||||
if (pfd[2].revents & POLLIN || pfd[2].revents & POLLERR || pfd[2].revents & POLLHUP || pfd[2].revents & POLLNVAL) {
|
||||
/*
|
||||
* Ping reply received.
|
||||
*/
|
||||
sl = sizeof(ffrom);
|
||||
if ((len = recvfrom(ping_isocket, &buf, sizeof(buf)-1, 0,(struct sockaddr *)&ffrom, &sl)) != -1) {
|
||||
ping_receive(buf, len);
|
||||
@ -1490,6 +1496,7 @@ void scheduler(void)
|
||||
default: port[0] = '\0';
|
||||
break;
|
||||
}
|
||||
opts = calloc(41, sizeof(char));
|
||||
if (calllist[call_entry].addr.point) {
|
||||
snprintf(opts, 41, "%sp%u.f%u.n%u.z%u.%s", port, calllist[call_entry].addr.point,
|
||||
calllist[call_entry].addr.node, calllist[call_entry].addr.net,
|
||||
@ -1504,6 +1511,7 @@ void scheduler(void)
|
||||
calllist[call_entry].calling = TRUE;
|
||||
running = checktasks(0);
|
||||
rescan = TRUE;
|
||||
free(opts);
|
||||
free(cmd);
|
||||
cmd = NULL;
|
||||
}
|
||||
@ -1703,7 +1711,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/*
|
||||
* Not reached
|
||||
* Not reached in daemon mode.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
@ -242,14 +242,13 @@ void checkdir(char *boxpath, faddr *fa, char flavor)
|
||||
|
||||
|
||||
/*
|
||||
* Scan outbound, the call status is set in three counters: internet,
|
||||
* ISDN and POTS (analogue modems).
|
||||
* Scan outbound, the call status is set in three counters: internet, ISDN and POTS (analogue modems).
|
||||
* For all systems the CM and Txx flags are checked and for official
|
||||
* FidoNet nodes the Zone Mail Hour wich belongs to the destination
|
||||
* zone.
|
||||
* All nodes are qualified, if there is a way to call them or not on
|
||||
* this moment.
|
||||
* FidoNet nodes the Zone Mail Hour wich belongs to the destination zone.
|
||||
* All nodes are qualified if there is a way to call them or not on this moment.
|
||||
* The method how to call a node is decided as well.
|
||||
*
|
||||
* On success, return 0.
|
||||
*/
|
||||
int outstat()
|
||||
{
|
||||
|
@ -316,13 +316,11 @@ void init_pingsocket(void)
|
||||
*/
|
||||
void check_ping(void)
|
||||
{
|
||||
int rc = 0;
|
||||
time_t now;
|
||||
int rc = 0;
|
||||
time_t now;
|
||||
|
||||
// Syslog('p', "Ping: 1=%s 2=%s nr=%d", pingresult[0] ? "TRUE":"FALSE", pingresult[1] ? "TRUE":"FALSE", pingnr);
|
||||
now = time(NULL);
|
||||
if ((int)now >= (int)ping_next) {
|
||||
// Syslog('p', "Ping: time for next");
|
||||
/*
|
||||
* Was previous ping received?
|
||||
*/
|
||||
@ -349,27 +347,22 @@ void check_ping(void)
|
||||
}
|
||||
}
|
||||
|
||||
// Syslog('p', "Ping: 1=%s 2=%s nr=%d", pingresult[0] ? "TRUE":"FALSE", pingresult[1] ? "TRUE":"FALSE", pingnr);
|
||||
|
||||
ping_next = (time_t)(now + 20);
|
||||
|
||||
if (inet_aton(pingaddress, &paddr)) {
|
||||
pingresult[pingnr - 1] = FALSE;
|
||||
rc = ping_send(paddr);
|
||||
// Syslog('p', "Ping: %d sent to %s rc=%d", pingnr, pingaddress, rc);
|
||||
if (rc) {
|
||||
if (icmp_errs++ < ICMP_MAX_ERRS)
|
||||
Syslog('?', "ping: to %s rc=%d", pingaddress, rc);
|
||||
} else {
|
||||
ping_sent = now;
|
||||
pingresult[pingnr - 1] = FALSE;
|
||||
// Syslog('p', "Ping: 1=%s 2=%s nr=%d", pingresult[0] ? "TRUE":"FALSE", pingresult[1] ? "TRUE":"FALSE", pingnr);
|
||||
return; // Don't check right after send
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Syslog('p', "Ping: 1=%s 2=%s nr=%d", pingresult[0] ? "TRUE":"FALSE", pingresult[1] ? "TRUE":"FALSE", pingnr);
|
||||
/*
|
||||
* Evaluate the result of the ping test
|
||||
*/
|
||||
|
@ -113,7 +113,7 @@ void load_ports()
|
||||
FILE *fp;
|
||||
pp_list new;
|
||||
int stdflag;
|
||||
char *p, *q, *capflags;
|
||||
char *p, *q, *capflags = NULL;
|
||||
nodelist_modem **tmpm;
|
||||
|
||||
tidy_portlist(&pl);
|
||||
@ -165,12 +165,14 @@ void load_ports()
|
||||
fill_portlist(&pl, &new);
|
||||
if (capflags)
|
||||
free(capflags);
|
||||
capflags = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
tty_time = file_time(ttyfn);
|
||||
Syslog('+', "Detected %d modem port%s and %d ISDN port%s",
|
||||
if (pots_lines || isdn_lines)
|
||||
Syslog('+', "Detected %d modem port%s and %d ISDN port%s",
|
||||
pots_lines, (pots_lines == 1)?"":"s", isdn_lines, (isdn_lines == 1)?"":"s");
|
||||
}
|
||||
|
||||
|
@ -395,10 +395,11 @@ void chat_msg(char *channel, char *nick, char *msg)
|
||||
*/
|
||||
void chat_connect_r(char *data, char *buf)
|
||||
{
|
||||
char *pid, *realname, *nick, *temp;
|
||||
char *realname, *nick, *temp;
|
||||
int count = 0, sys = FALSE;
|
||||
srv_list *sl;
|
||||
usr_list *tmpu;
|
||||
pid_t pid;
|
||||
|
||||
Syslog('c', "CCON:%s", data);
|
||||
|
||||
@ -420,8 +421,8 @@ void chat_connect_r(char *data, char *buf)
|
||||
/*
|
||||
* Register with IBC
|
||||
*/
|
||||
pid = strtok(data, ","); /* Should be 3 */
|
||||
pid = strtok(NULL, ","); /* The pid */
|
||||
strtok(data, ","); /* Should be 3 */
|
||||
pid = (pid_t)atoi(strtok(NULL, ",")); /* The pid */
|
||||
realname = xstrcpy(cldecode(strtok(NULL, ",")));/* Username */
|
||||
nick = xstrcpy(cldecode(strtok(NULL, ","))); /* Nickname */
|
||||
sys = atoi(strtok(NULL, ";")); /* Sysop flag */
|
||||
@ -437,7 +438,7 @@ void chat_connect_r(char *data, char *buf)
|
||||
/*
|
||||
* Oke, found
|
||||
*/
|
||||
tmpu->pid = atoi(pid);
|
||||
tmpu->pid = pid;
|
||||
tmpu->pointer = buffer_head;
|
||||
tmpu->sysop = sys;
|
||||
usrchg = TRUE;
|
||||
@ -479,27 +480,27 @@ void chat_connect_r(char *data, char *buf)
|
||||
|
||||
void chat_close_r(char *data, char *buf)
|
||||
{
|
||||
char *pid;
|
||||
pid_t pid;
|
||||
usr_list *tmpu;
|
||||
|
||||
Syslog('c', "CCLO:%s", data);
|
||||
pid = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ";"));
|
||||
|
||||
for (tmpu = users; tmpu; tmpu = tmpu->next) {
|
||||
if (tmpu->pid == atoi(pid)) {
|
||||
if (tmpu->pid == pid) {
|
||||
/*
|
||||
* Remove from IBC network
|
||||
*/
|
||||
send_at((char *)"QUIT", tmpu->name, (char *)"Leaving chat");
|
||||
del_user(&users, CFG.myfqdn, tmpu->name);
|
||||
Syslog('c', "Closing chat for pid %s", pid);
|
||||
Syslog('c', "Closing chat for pid %d", (int)pid);
|
||||
snprintf(buf, 81, "100:0;");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Syslog('c', "Pid %s was not connected to chatserver");
|
||||
Syslog('c', "Pid %d was not connected to chatserver", (int)pid);
|
||||
snprintf(buf, 81, "100:1,*** ERROR - Not connected to server;");
|
||||
return;
|
||||
}
|
||||
@ -508,10 +509,11 @@ void chat_close_r(char *data, char *buf)
|
||||
|
||||
void chat_put_r(char *data, char *buf)
|
||||
{
|
||||
char *p, *q, *pid, *msg, *cmd, *mbuf, *flags, temp[81];
|
||||
char *p, *q, *msg, *cmd, *mbuf, *flags, temp[81];
|
||||
int first, count, owner = FALSE, found;
|
||||
usr_list *tmpu, *tmp;
|
||||
chn_list *tmpc;
|
||||
pid_t pid;
|
||||
|
||||
if (IsSema((char *)"upsalarm")) {
|
||||
snprintf(buf, 81, "100:2,1,*** Power alarm, running on UPS;");
|
||||
@ -523,13 +525,13 @@ void chat_put_r(char *data, char *buf)
|
||||
return;
|
||||
}
|
||||
|
||||
pid = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ","));
|
||||
msg = xstrcpy(cldecode(strtok(NULL, ";")));
|
||||
mbuf = calloc(200, sizeof(char));
|
||||
|
||||
for (tmpu = users; tmpu; tmpu = tmpu->next) {
|
||||
if (tmpu->pid == atoi(pid)) {
|
||||
if (tmpu->pid == pid) {
|
||||
if (msg[0] == '/') {
|
||||
/*
|
||||
* A command, process this but first se if we are in a channel
|
||||
@ -545,7 +547,7 @@ void chat_put_r(char *data, char *buf)
|
||||
Syslog('c', "IBC: process command, in channel %s and we are %sthe owner", tmpu->channel, owner ? "":"not ");
|
||||
}
|
||||
if (strncasecmp(msg, "/help", 5) == 0) {
|
||||
chat_help(atoi(pid), owner);
|
||||
chat_help(pid, owner);
|
||||
goto ack;
|
||||
} else if (strncasecmp(msg, "/echo", 5) == 0) {
|
||||
snprintf(mbuf, 200, "%s", msg);
|
||||
@ -777,8 +779,9 @@ hangup:
|
||||
*/
|
||||
void chat_get_r(char *data, char *buf)
|
||||
{
|
||||
char *pid, *p;
|
||||
char *p;
|
||||
usr_list *tmpu;
|
||||
pid_t pid;
|
||||
|
||||
if (IsSema((char *)"upsalarm")) {
|
||||
snprintf(buf, 200, "100:2,1,*** Power failure, running on UPS;");
|
||||
@ -790,11 +793,11 @@ void chat_get_r(char *data, char *buf)
|
||||
return;
|
||||
}
|
||||
|
||||
pid = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ";"));
|
||||
|
||||
for (tmpu = users; tmpu; tmpu = tmpu->next) {
|
||||
if (atoi(pid) == tmpu->pid) {
|
||||
if (pid == tmpu->pid) {
|
||||
while (tmpu->pointer != buffer_head) {
|
||||
if (tmpu->pointer < MAXMESSAGES)
|
||||
tmpu->pointer++;
|
||||
@ -827,12 +830,11 @@ void chat_get_r(char *data, char *buf)
|
||||
*/
|
||||
void chat_checksysop_r(char *data, char *buf)
|
||||
{
|
||||
char *pid;
|
||||
pid_t pid;
|
||||
usr_list *tmpu;
|
||||
|
||||
pid = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
|
||||
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ";"));
|
||||
|
||||
if (reg_ispaging(pid)) {
|
||||
Syslog('c', "Check sysopchat for pid %s, user has paged", pid);
|
||||
@ -841,7 +843,7 @@ void chat_checksysop_r(char *data, char *buf)
|
||||
* Now check if sysop is present in the sysop channel
|
||||
*/
|
||||
for (tmpu = users; tmpu; tmpu = tmpu->next) {
|
||||
if (atoi(pid) != tmpu->pid) {
|
||||
if (pid != tmpu->pid) {
|
||||
if (strlen(tmpu->channel) && (strcasecmp(tmpu->channel, "#sysop") == 0) && tmpu->sysop) {
|
||||
Syslog('c', "Sending ACK on check");
|
||||
snprintf(buf, 20, "100:1,1;");
|
||||
|
@ -61,8 +61,8 @@ int userlog(char *param)
|
||||
int rc;
|
||||
|
||||
lfn[0] = '\0';
|
||||
strcpy(token, strtok(param, ","));
|
||||
strcpy(token, strtok(NULL, ","));
|
||||
strncpy(token, strtok(param, ","), 14);
|
||||
strncpy(token, strtok(NULL, ","), 14);
|
||||
snprintf(lfn, PATH_MAX, "%s/log/%s", getenv("MBSE_ROOT"), token);
|
||||
prname = strtok(NULL, ",");
|
||||
prpid = strtok(NULL, ",");
|
||||
@ -90,18 +90,18 @@ char *exe_cmd(char *in)
|
||||
int result;
|
||||
char *buf;
|
||||
|
||||
strcpy(ibuf, in);
|
||||
strncpy(ibuf, in, SS_BUFSIZE);
|
||||
strncpy(cmd, ibuf, 4);
|
||||
token[0] = '\0';
|
||||
strcpy(ebuf, "200:1,Syntax error;");
|
||||
// token[0] = '\0';
|
||||
strncpy(ebuf, "200:1,Syntax error;", 19);
|
||||
|
||||
/*
|
||||
* Split the commandline after the colon so we can give the
|
||||
* options directly to the actual functions. Also set a default
|
||||
* and most used answer.
|
||||
*/
|
||||
strcpy(token, &ibuf[5]);
|
||||
strcpy(obuf, "100:0;");
|
||||
strncpy(token, &ibuf[5], SS_BUFSIZE);
|
||||
strncpy(obuf, "100:0;", SS_BUFSIZE);
|
||||
|
||||
|
||||
/*
|
||||
@ -496,13 +496,13 @@ char *exe_cmd(char *in)
|
||||
* GDST:0; Obsolete!
|
||||
* 100:n,data1,..,data10;
|
||||
*/
|
||||
if (strncmp(cmd, "GDST", 4) == 0) {
|
||||
buf = calloc(SS_BUFSIZE, sizeof(char));
|
||||
disk_getfs_r(buf);
|
||||
snprintf(obuf, SS_BUFSIZE, "%s", buf);
|
||||
free(buf);
|
||||
return obuf;
|
||||
}
|
||||
// if (strncmp(cmd, "GDST", 4) == 0) {
|
||||
// buf = calloc(SS_BUFSIZE, sizeof(char));
|
||||
// disk_getfs_r(buf);
|
||||
// snprintf(obuf, SS_BUFSIZE, "%s", buf);
|
||||
// free(buf);
|
||||
// return obuf;
|
||||
// }
|
||||
|
||||
/*
|
||||
* GSYS:0;
|
||||
|
@ -1778,7 +1778,7 @@ void ibc_receiver(char *crbuf)
|
||||
}
|
||||
|
||||
/*
|
||||
* First check fr a fixed IP address.
|
||||
* First check for a fixed IP address.
|
||||
*/
|
||||
inlist = FALSE;
|
||||
for (tnsl = ncsl; tnsl; tnsl = tnsl->next) {
|
||||
|
@ -47,17 +47,17 @@ int ipmailers = 0; /* TCP/IP mail sessions */
|
||||
*
|
||||
* Search for a pid.
|
||||
*/
|
||||
int reg_find(char *);
|
||||
int reg_find(char *pids)
|
||||
int reg_find(pid_t);
|
||||
int reg_find(pid_t pids)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAXCLIENT; i++) {
|
||||
if ((int)reginfo[i].pid == atoi(pids))
|
||||
if (reginfo[i].pid == pids)
|
||||
return i;
|
||||
}
|
||||
|
||||
Syslog('?', "Panic, pid %s not found", pids);
|
||||
WriteError("Panic, pid %d not found", (int)pids);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -70,12 +70,13 @@ int reg_find(char *pids)
|
||||
|
||||
int reg_newcon(char *data)
|
||||
{
|
||||
char *cnt, *pid, *tty, *uid, *prg, *city;
|
||||
char *tty, *uid, *prg, *city;
|
||||
int retval;
|
||||
pid_t pid;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
tty = strtok(NULL, ",");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ","));
|
||||
tty = xstrcpy(strtok(NULL, ","));
|
||||
uid = xstrcpy(cldecode(strtok(NULL, ",")));
|
||||
prg = xstrcpy(cldecode(strtok(NULL, ",")));
|
||||
city = xstrcpy(cldecode(strtok(NULL, ";")));
|
||||
@ -83,39 +84,38 @@ int reg_newcon(char *data)
|
||||
/*
|
||||
* Abort if no empty record is found
|
||||
*/
|
||||
if ((retval = reg_find((char *)"0")) == -1) {
|
||||
if ((retval = reg_find((pid_t)0)) == -1) {
|
||||
Syslog('?', "Maximum clients (%d) reached", MAXCLIENT);
|
||||
free(uid);
|
||||
free(prg);
|
||||
free(city);
|
||||
return -1;
|
||||
retval = -1;
|
||||
} else {
|
||||
memset((char *)®info[retval], 0, sizeof(reg_info));
|
||||
reginfo[retval].pid = pid;
|
||||
strncpy((char *)®info[retval].tty, tty, 6);
|
||||
strncpy((char *)®info[retval].uname, uid, 35);
|
||||
strncpy((char *)®info[retval].prg, prg, 14);
|
||||
strncpy((char *)®info[retval].city, city, 35);
|
||||
strcpy((char *)®info[retval].doing, "-");
|
||||
reginfo[retval].started = (int)time(NULL);
|
||||
reginfo[retval].lastcon = (int)time(NULL);
|
||||
reginfo[retval].altime = 600;
|
||||
|
||||
/*
|
||||
* Everyone says do not disturb, unless the flag
|
||||
* is cleared by the owner of this process.
|
||||
*/
|
||||
reginfo[retval].silent = 1;
|
||||
|
||||
stat_inc_clients();
|
||||
if (strcmp(prg, (char *)"mbcico") == 0)
|
||||
mailers++;
|
||||
Syslog('-', "Registered client pgm \"%s\", pid %d, slot %d, mailers %d, TCP/IP %d",
|
||||
prg, (int)pid, retval, mailers, ipmailers);
|
||||
}
|
||||
|
||||
memset((char *)®info[retval], 0, sizeof(reg_info));
|
||||
reginfo[retval].pid = atoi(pid);
|
||||
strncpy((char *)®info[retval].tty, tty, 6);
|
||||
strncpy((char *)®info[retval].uname, uid, 35);
|
||||
strncpy((char *)®info[retval].prg, prg, 14);
|
||||
strncpy((char *)®info[retval].city, city, 35);
|
||||
strcpy((char *)®info[retval].doing, "-");
|
||||
reginfo[retval].started = (int)time(NULL);
|
||||
reginfo[retval].lastcon = (int)time(NULL);
|
||||
reginfo[retval].altime = 600;
|
||||
|
||||
/*
|
||||
* Everyone says do not disturb, unless the flag
|
||||
* is cleared by the owner of this process.
|
||||
*/
|
||||
reginfo[retval].silent = 1;
|
||||
|
||||
stat_inc_clients();
|
||||
if (strcmp(prg, (char *)"mbcico") == 0)
|
||||
mailers++;
|
||||
Syslog('-', "Registered client pgm \"%s\", pid %s, slot %d, mailers %d, TCP/IP %d",
|
||||
prg, pid, retval, mailers, ipmailers);
|
||||
free(uid);
|
||||
free(prg);
|
||||
free(city);
|
||||
free(tty);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -123,23 +123,24 @@ int reg_newcon(char *data)
|
||||
|
||||
int reg_closecon(char *data)
|
||||
{
|
||||
char *cnt, *pid;
|
||||
pid_t pid;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ";"));
|
||||
if ((rec = reg_find(pid)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(reginfo[rec].prg, (char *)"mbcico") == 0)
|
||||
mailers--;
|
||||
if (reginfo[rec].istcp)
|
||||
ipmailers--;
|
||||
if ((strcmp(reginfo[rec].prg, (char *)"mbsebbs") == 0) || (strcmp(reginfo[rec].prg, (char *)"mbmon") == 0))
|
||||
chat_cleanuser(atoi(pid));
|
||||
chat_cleanuser(pid);
|
||||
|
||||
Syslog('-', "Unregistered client pgm \"%s\", pid %s, slot %d, mailers %d, TCP/IP %d",
|
||||
reginfo[rec].prg, pid, rec, mailers, ipmailers);
|
||||
Syslog('-', "Unregistered client pgm \"%s\", pid %d, slot %d, mailers %d, TCP/IP %d",
|
||||
reginfo[rec].prg, (int)pid, rec, mailers, ipmailers);
|
||||
memset(®info[rec], 0, sizeof(reg_info));
|
||||
stat_dec_clients();
|
||||
return 0;
|
||||
@ -202,11 +203,12 @@ void reg_check(void)
|
||||
*/
|
||||
int reg_doing(char *data)
|
||||
{
|
||||
char *cnt, *pid, *line;
|
||||
char *line;
|
||||
int rec;
|
||||
pid_t pid;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ","));
|
||||
line = xstrcpy(cldecode(strtok(NULL, ";")));
|
||||
|
||||
if ((rec = reg_find(pid)) == -1) {
|
||||
@ -227,19 +229,20 @@ int reg_doing(char *data)
|
||||
*/
|
||||
int reg_ip(char *data)
|
||||
{
|
||||
char *cnt, *pid;
|
||||
pid_t pid;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ";"));
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
if ((rec = reg_find(pid)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
reginfo[rec].istcp = TRUE;
|
||||
reginfo[rec].lastcon = (int)time(NULL);
|
||||
ipmailers++;
|
||||
Syslog('?', "TCP/IP session registered (%s), now %d sessions", pid, ipmailers);
|
||||
Syslog('?', "TCP/IP session registered (%d), now %d sessions", (int)pid, ipmailers);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -250,14 +253,16 @@ int reg_ip(char *data)
|
||||
*/
|
||||
int reg_nop(char *data)
|
||||
{
|
||||
char *cnt, *pid;
|
||||
pid_t pid;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ";"));
|
||||
|
||||
if ((rec = reg_find(pid)) == -1) {
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
reginfo[rec].lastcon = (int)time(NULL);
|
||||
return 0;
|
||||
}
|
||||
@ -269,30 +274,31 @@ int reg_nop(char *data)
|
||||
*/
|
||||
int reg_timer(int Set, char *data)
|
||||
{
|
||||
char *pid;
|
||||
pid_t pid;
|
||||
int cnt, rec, val;
|
||||
|
||||
cnt = atoi(strtok(data, ","));
|
||||
if (Set) {
|
||||
if (cnt != 2)
|
||||
return -1;
|
||||
pid = strtok(NULL, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ","));
|
||||
val = atoi(strtok(NULL, ";"));
|
||||
if (val < 600)
|
||||
val = 600;
|
||||
} else {
|
||||
if (cnt != 1)
|
||||
return -1;
|
||||
pid = strtok(NULL, ";");
|
||||
pid = (pid_t)atoi(strtok(NULL, ";"));
|
||||
val = 600;
|
||||
}
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
if ((rec = reg_find(pid)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
reginfo[rec].altime = val;
|
||||
reginfo[rec].lastcon = (int)time(NULL);
|
||||
Syslog('r', "Set timeout value for %d to %d", reginfo[rec].pid, val);
|
||||
Syslog('r', "Set timeout value for %d to %d", (int)pid, val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -303,18 +309,22 @@ int reg_timer(int Set, char *data)
|
||||
*/
|
||||
int reg_tty(char *data)
|
||||
{
|
||||
char *cnt, *pid, *tty;
|
||||
char *tty;
|
||||
int rec;
|
||||
pid_t pid;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
tty = strtok(NULL, ";");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ","));
|
||||
tty = xstrcpy(strtok(NULL, ";"));
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
if ((rec = reg_find(pid)) == -1) {
|
||||
free(tty);
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
strncpy((char *)®info[rec].tty, tty, 6);
|
||||
reginfo[rec].lastcon = (int)time(NULL);
|
||||
free(tty);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -325,17 +335,18 @@ int reg_tty(char *data)
|
||||
*/
|
||||
int reg_silent(char *data)
|
||||
{
|
||||
char *cnt, *pid, *line;
|
||||
int rec;
|
||||
int rec, line;
|
||||
pid_t pid;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
line = strtok(NULL, ";");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ","));
|
||||
line = atoi(strtok(NULL, ";"));
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
if ((rec = reg_find(pid)) == -1) {
|
||||
return -1;
|
||||
|
||||
reginfo[rec].silent = atoi(line);
|
||||
}
|
||||
|
||||
reginfo[rec].silent = line;
|
||||
reginfo[rec].lastcon = (int)time(NULL);
|
||||
return 0;
|
||||
}
|
||||
@ -347,11 +358,12 @@ int reg_silent(char *data)
|
||||
*/
|
||||
int reg_user(char *data)
|
||||
{
|
||||
char *cnt, *pid, *user, *city;
|
||||
char *user, *city;
|
||||
int rec;
|
||||
pid_t pid;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ","));
|
||||
user = xstrcpy(cldecode(strtok(NULL, ",")));
|
||||
city = xstrcpy(cldecode(strtok(NULL, ";")));
|
||||
|
||||
@ -376,11 +388,11 @@ int reg_user(char *data)
|
||||
*/
|
||||
int reg_sysop(char *data)
|
||||
{
|
||||
char *cnt, *pid;
|
||||
pid_t pid;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ","));
|
||||
sysop_present = atoi(strtok(NULL, ";"));
|
||||
|
||||
if ((rec = reg_find(pid)) != -1) {
|
||||
@ -398,13 +410,14 @@ int reg_sysop(char *data)
|
||||
*/
|
||||
void reg_ipm_r(char *data, char *buf)
|
||||
{
|
||||
char *cnt, *pid, *name, *msg;
|
||||
int rec;
|
||||
char *name, *msg;
|
||||
int rec;
|
||||
pid_t pid;
|
||||
|
||||
buf[0] = '\0';
|
||||
snprintf(buf, SS_BUFSIZE, "100:0;");
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ";"));
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return;
|
||||
@ -437,10 +450,10 @@ void reg_ipm_r(char *data, char *buf)
|
||||
*/
|
||||
int reg_spm(char *data)
|
||||
{
|
||||
char *cnt, *from, *too, *txt, *logm;
|
||||
char *from, *too, *txt, *logm;
|
||||
int i;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
strtok(data, ",");
|
||||
from = xstrcpy(cldecode(strtok(NULL, ",")));
|
||||
too = xstrcpy(cldecode(strtok(NULL, ",")));
|
||||
txt = xstrcpy(cldecode(strtok(NULL, ";")));
|
||||
@ -588,14 +601,15 @@ void get_reginfo_r(int first, char *buf)
|
||||
*/
|
||||
int reg_page(char *data)
|
||||
{
|
||||
char *cnt, *pid, *reason;
|
||||
char *reason;
|
||||
int i, rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
pid_t pid;
|
||||
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ","));
|
||||
reason = xstrcpy(cldecode(strtok(NULL, ";")));
|
||||
|
||||
Syslog('+', "reg_page: pid=%d, reason=\"%s\"", pid, reason);
|
||||
Syslog('+', "reg_page: pid=%d, reason=\"%s\"", (int)pid, reason);
|
||||
|
||||
if (!sysop_present) {
|
||||
free(reason);
|
||||
@ -607,7 +621,7 @@ int reg_page(char *data)
|
||||
* If so, mark sysop busy.
|
||||
*/
|
||||
for (i = 1; i < MAXCLIENT; i++) {
|
||||
if (reginfo[i].pid && (reginfo[i].pid != atoi(pid)) && (reginfo[i].paging || reginfo[i].haspaged)) {
|
||||
if (reginfo[i].pid && (reginfo[i].pid != pid) && (reginfo[i].paging || reginfo[i].haspaged)) {
|
||||
free(reason);
|
||||
return 1;
|
||||
}
|
||||
@ -634,13 +648,13 @@ int reg_page(char *data)
|
||||
*/
|
||||
int reg_cancel(char *data)
|
||||
{
|
||||
char *cnt, *pid;
|
||||
pid_t pid;
|
||||
int rec;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
strtok(data, ",");
|
||||
pid = (pid_t)atoi(strtok(NULL, ";"));
|
||||
|
||||
Syslog('+', "reg_cancel: pid=%s", pid);
|
||||
Syslog('+', "reg_cancel: pid=%d", (int)pid);
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
@ -649,6 +663,7 @@ int reg_cancel(char *data)
|
||||
reginfo[rec].paging = FALSE;
|
||||
reginfo[rec].haspaged = TRUE;
|
||||
}
|
||||
|
||||
reginfo[rec].lastcon = (int)time(NULL);
|
||||
return 0;
|
||||
}
|
||||
@ -681,7 +696,7 @@ void reg_checkpage_r(char *data, char *buf)
|
||||
/*
|
||||
* Check if this user has paged or is paging
|
||||
*/
|
||||
int reg_ispaging(char *pid)
|
||||
int reg_ispaging(pid_t pid)
|
||||
{
|
||||
int rec;
|
||||
|
||||
@ -696,7 +711,7 @@ int reg_ispaging(char *pid)
|
||||
/*
|
||||
* Mark that this user is now talking to the sysop
|
||||
*/
|
||||
void reg_sysoptalk(char *pid)
|
||||
void reg_sysoptalk(pid_t pid)
|
||||
{
|
||||
int rec;
|
||||
|
||||
|
@ -54,8 +54,8 @@ int reg_sysop(char *); /* Registrate sysop presence */
|
||||
int reg_page(char *); /* Page sysop for chat */
|
||||
int reg_cancel(char *); /* Cancel sysop page */
|
||||
void reg_checkpage_r(char *, char *); /* Check paging status */
|
||||
int reg_ispaging(char *); /* Check if user with pid paged */
|
||||
void reg_sysoptalk(char *); /* Is now talking to the sysop */
|
||||
int reg_ispaging(pid_t); /* Check if user with pid paged */
|
||||
void reg_sysoptalk(pid_t); /* Is now talking to the sysop */
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -430,16 +430,17 @@ void sem_status_r(char *data, char *buf)
|
||||
|
||||
void sem_create_r(char *data, char *buf)
|
||||
{
|
||||
char *cnt, *sem;
|
||||
char *sem;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
sem = strtok(NULL, ";");
|
||||
strtok(data, ",");
|
||||
sem = xstrcpy(strtok(NULL, ";"));
|
||||
|
||||
if (sem_set(sem, TRUE))
|
||||
snprintf(buf, 40, "100:0;");
|
||||
else
|
||||
snprintf(buf, 40, "200:1,16;");
|
||||
|
||||
free(sem);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -447,16 +448,17 @@ void sem_create_r(char *data, char *buf)
|
||||
|
||||
void sem_remove_r(char *data, char *buf)
|
||||
{
|
||||
char *cnt, *sem;
|
||||
char *sem;
|
||||
|
||||
cnt = strtok(data, ",");
|
||||
sem = strtok(NULL, ";");
|
||||
strtok(data, ",");
|
||||
sem = xstrcpy(strtok(NULL, ";"));
|
||||
|
||||
if (sem_set(sem, FALSE))
|
||||
snprintf(buf, 40, "100:0;");
|
||||
else
|
||||
snprintf(buf, 40, "200:1,16;");
|
||||
|
||||
free(sem);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user