Merge pull request #30 from joonicks/dev

calc, hostinfo, code segment layout, debug info etc
This commit is contained in:
joonicks 2025-09-21 17:10:19 +02:00 committed by GitHub
commit fc915b62ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 559 additions and 425 deletions

View File

@ -1,7 +1,7 @@
/* /*
EnergyMech, IRC bot software EnergyMech, IRC bot software
Copyright (c) 2001-2018 proton Copyright (c) 2001-2024 proton
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -434,6 +434,7 @@ See also: passwd, setpass
*/ */
void do_auth(COMMAND_ARGS) void do_auth(COMMAND_ARGS)
{ {
Auth *au;
#ifdef BOTNET #ifdef BOTNET
char *checksum; char *checksum;
#endif /* BOTNET */ #endif /* BOTNET */
@ -443,7 +444,21 @@ void do_auth(COMMAND_ARGS)
int hostmatch; int hostmatch;
if ((pass = chop(&rest)) == NULL) if ((pass = chop(&rest)) == NULL)
{
if (get_authaccess(from,MATCH_ALL) == 100)
{
/* empty pass + owner: List active auths */
table_buffer("\037Active Auths\037");
if (current->authlist == NULL)
table_buffer("(none)");
for(au=current->authlist;au;au=au->next)
{
table_buffer("%s\t%i\t%s\t%s",au->user->name,au->user->x.x.access,au->nuh,idle2str(now - au->active,TRUE));
}
table_send(from,3);
}
return; return;
}
/* /*
* chop chop * chop chop

View File

@ -1,7 +1,7 @@
/* /*
EnergyMech, IRC bot software EnergyMech, IRC bot software
Copyright (c) 2020-2021 proton Copyright (c) 2020-2024 proton
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -92,7 +92,9 @@ const char *calculate(const char *input, CalcOp *cop, char *prepin)
*dst = 0; *dst = 0;
input = prepin; input = prepin;
#ifdef TEST
printf("%s\n",prepin); printf("%s\n",prepin);
#endif /* TEST */
cop_count = 0; cop_count = 0;
maxdeci = 0; maxdeci = 0;
goto new_blank; goto new_blank;
@ -140,14 +142,21 @@ op_or_num:
input++; input++;
goto parse_num; goto parse_num;
} }
if (*input >= '0' && *input <= '9') if (*input == '*')
{
op = OPER_MUL;
input++;
para++;
goto parse_num;
}
if ((*input >= '0' && *input <= '9') || *input == '.')
goto parse_num; goto parse_num;
if (*input == 0) if (*input == 0)
goto new_op_or_num; goto new_op_or_num;
goto parsing_error; goto parsing_error;
parse_num: parse_num:
if (*input == '-' || *input == '+') if (*input == '-' || *input == '+' || *input == '*')
{ {
goto new_op_or_num; goto new_op_or_num;
} }
@ -176,7 +185,7 @@ parsing_error:
calculate_result: calculate_result:
x = 20; x = 20;
/* find most decimals and convert all other numbers */ /* find most decimals and convert all other numbers */
for(i=0;i<=cop_count;i++) /* for(i=0;i<=cop_count;i++)
{ {
if (cop[i].decimals < maxdeci) if (cop[i].decimals < maxdeci)
{ {
@ -188,6 +197,7 @@ calculate_result:
cop[i].decimals = maxdeci; cop[i].decimals = maxdeci;
} }
} }
*/
r = 0; r = 0;
iterate: iterate:
/* find highest paralevel */ /* find highest paralevel */
@ -195,7 +205,8 @@ iterate:
for(i=0;i<=cop_count;i++) for(i=0;i<=cop_count;i++)
{ {
if (cop[i].paralevel >= 0) if (cop[i].paralevel >= 0)
printf("number %lli, operation %i, decimals %i, paralevel %i\n",cop[i].number,cop[i].operation,cop[i].decimals,cop[i].paralevel); printf("number %lu, operation %i, decimals %i, paralevel %i\n",
cop[i].number,cop[i].operation,cop[i].decimals,cop[i].paralevel);
if (cop[i].paralevel >= para) if (cop[i].paralevel >= para)
para = cop[i].paralevel; para = cop[i].paralevel;
} }
@ -210,6 +221,18 @@ iterate:
r += cop[i].number; r += cop[i].number;
cop[i].paralevel = -1; cop[i].paralevel = -1;
} }
if (cop[i].paralevel == para && op == 2 && cop[i].operation == OPER_MUL)
{
cop[i-1].number = cop[i-1].number * cop[i].number;
/* if (cop[i-1].decimals > cop[i].decimals)*/
{
#ifdef TEST
printf("decimals adjust %i > %i\n",cop[i-1].decimals,cop[i].decimals);
#endif /* TEST */
/* cop[i-1].number /= decival[cop[i-1].decimals - cop[i].decimals];*/
}
cop[i].paralevel = -1;
}
} }
} }
if (x--<0) if (x--<0)
@ -232,21 +255,6 @@ return_result:
return(prepin); return(prepin);
} }
void do_calc(COMMAND_ARGS)
{
CalcOp cop[MAX_COP];
int cp = 0;
memset(&cop,0,sizeof(cop));
/* start with a numeral, or '-' */
if (*rest != '-' && (attrtab[(uchar)*rest] & NUM) == 0)
{
/* malformed */
return;
}
}
void mkbin(char *dst, int num, int bits) void mkbin(char *dst, int num, int bits)
{ {
int lim; int lim;
@ -317,6 +325,23 @@ int bas2int(const char *src, int base)
#if !defined(TEST) #if !defined(TEST)
void do_calc(COMMAND_ARGS)
{
char prep[MSGLEN];
CalcOp cop[MAX_COP];
int cp = 0;
memset(&cop,0,sizeof(cop));
/* start with a numeral, or '.', or '-' */
if (*rest != '-' && *rest != '.' && (attrtab[(uchar)*rest] & NUM) == 0)
{
/* malformed */
return;
}
to_user_q(from,"%s",calculate(rest,cop,prep));
}
void do_convert(COMMAND_ARGS) void do_convert(COMMAND_ARGS)
{ {
char output[200]; char output[200];
@ -416,7 +441,7 @@ void do_convert(COMMAND_ARGS)
if (dst != output) if (dst != output)
*(dst++) = ' '; *(dst++) = ' ';
sprintf(dst,"oct 0%o",num,num); sprintf(dst,"oct 0%o",num);
} }
if (tohex) if (tohex)
@ -461,8 +486,11 @@ void do_convert(COMMAND_ARGS)
const char *test[] = { const char *test[] = {
"1 - .2 + .03 - .004", "1 - .2 + .03 - .004",
"2.008 + 9 + .992", "2.008 + 9 + .992",
/* "999 - 555.66", "999 - 555.66",
"1+2-3+4-5+6-7+8-9",*/ "1+2-3+4-5+6-7+8-9",
"100*200",
"10-10*10+10",
".001*1000",
NULL NULL
}; };
@ -470,7 +498,6 @@ int main(int argc, char **argv, char **envp)
{ {
char prep[MSGLEN]; char prep[MSGLEN];
CalcOp cop[MAX_COP]; CalcOp cop[MAX_COP];
char *tmp;
int i; int i;
for(i=0;test[i];i++) for(i=0;test[i];i++)

View File

@ -1,7 +1,7 @@
/* /*
EnergyMech, IRC bot software EnergyMech, IRC bot software
Parts Copyright (c) 1997-2018 proton Parts Copyright (c) 1997-2024 proton
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -29,6 +29,10 @@
#include "mcmd.h" #include "mcmd.h"
#include "settings.h" #include "settings.h"
#ifdef HOSTINFO
#include <sys/utsname.h>
#endif /* HOSTINFO */
#ifdef IDWRAP #ifdef IDWRAP
void unlink_identfile(void) void unlink_identfile(void)
@ -444,6 +448,13 @@ void signoff(char *from, char *reason)
Free(&current->lastcmds[i]); Free(&current->lastcmds[i]);
} }
/*
* little of this n that
*/
Free((char**)&current->nick);
Free((char**)&current->wantnick);
Free((char**)&current->userhost);
/* /*
* These 2 are used by do_die() to pass reason and doer. * These 2 are used by do_die() to pass reason and doer.
*/ */
@ -1251,6 +1262,10 @@ void do_version(COMMAND_ARGS)
void do_core(COMMAND_ARGS) void do_core(COMMAND_ARGS)
{ {
#ifdef HOSTINFO
char *h,hostname[256];
struct utsname un;
#endif /* HOSTINFO */
char tmp[MSGLEN]; /* big buffers at the top */ char tmp[MSGLEN]; /* big buffers at the top */
Server *sp; Server *sp;
Chan *chan; Chan *chan;
@ -1330,6 +1345,16 @@ void do_core(COMMAND_ARGS)
table_buffer(TEXT_CURRSERVERNOT); table_buffer(TEXT_CURRSERVERNOT);
table_buffer(TEXT_SERVERONTIME,idle2str(now - current->ontime,FALSE)); table_buffer(TEXT_SERVERONTIME,idle2str(now - current->ontime,FALSE));
table_buffer(TEXT_BOTMODES,(*current->modes) ? current->modes : TEXT_NONE); table_buffer(TEXT_BOTMODES,(*current->modes) ? current->modes : TEXT_NONE);
#ifdef HOSTINFO
hostname[255] = 0;
if (gethostname(hostname,250) < 0)
h = "(hostname error)";
else
h = hostname;
if (uname(&un) == 0)
table_buffer(TEXT_HOSTINFO,h,un.sysname,un.release,un.machine);
#endif /* HOSTINFO */
table_buffer(TEXT_CURRENTTIME,time2str(now)); table_buffer(TEXT_CURRENTTIME,time2str(now));
table_buffer(TEXT_BOTSTARTED,time2str(uptime)); table_buffer(TEXT_BOTSTARTED,time2str(uptime));
table_buffer(TEXT_BOTUPTIME,idle2str(now - uptime,FALSE)); table_buffer(TEXT_BOTUPTIME,idle2str(now - uptime,FALSE));

View File

@ -1,7 +1,7 @@
/* /*
EnergyMech, IRC bot software EnergyMech, IRC bot software
Copyright (c) 1997-2021 proton Copyright (c) 1997-2024 proton
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -108,59 +108,68 @@ LS const struct
#endif #endif
{ NULL, }}; { NULL, }};
#define CORE_SE ,"CORE"
#define CFG1_SE ,"CFG1"
#define CMD1_SE ,"CMD1"
#define INIT_SE ,"INIT"
#define RARE_SE ,"RARE"
#define DBUG_SE ,"DBUG"
LS struct LS struct
{ {
void *func; void *func;
char *name; char *name;
char segment[5];
int num; int num;
int size; int size;
int mall_size; int mall_size;
} ProcList[] = } ProcList[] =
{ {
{ SockConnect, "SockConnect" }, { SockConnect, "SockConnect" CORE_SE },
{ add_bot, "add_bot" }, { add_bot, "add_bot" CFG1_SE },
{ add_server, "add_server" }, { add_server, "add_server" CFG1_SE },
{ add_shit, "add_shit" }, { add_shit, "add_shit" },
{ add_user, "add_user" }, { add_user, "add_user" },
{ addtouser, "addtouser" }, { addtouser, "addtouser" CORE_SE },
{ cfg_opt, "cfg_opt" }, { cfg_opt, "cfg_opt" CFG1_SE },
{ cfg_pass, "cfg_pass" }, { cfg_pass, "cfg_pass" CFG1_SE },
{ cfg_user, "cfg_user" }, { cfg_user, "cfg_user" CFG1_SE },
{ change_authnick, "change_authnick" }, { change_authnick, "change_authnick" },
{ ctcp_dcc, "ctcp_dcc" }, { ctcp_dcc, "ctcp_dcc" },
{ copy_vars, "copy_vars" }, { copy_vars, "copy_vars" CFG1_SE },
{ dcc_chat, "dcc_chat" }, { dcc_chat, "dcc_chat" CMD1_SE },
{ do_die, "do_die" }, { do_die, "do_die" RARE_SE },
{ do_nick, "do_nick" }, { do_nick, "do_nick" CMD1_SE },
{ do_kicksay, "do_kicksay" }, { do_kicksay, "do_kicksay" CMD1_SE },
{ do_servergroup, "do_servergroup" }, { do_servergroup, "do_servergroup" CMD1_SE },
{ do_set, "do_set" }, { do_set, "do_set" CMD1_SE },
{ do_spy, "do_spy" }, { do_spy, "do_spy" CMD1_SE },
{ join_channel, "join_channel" }, { join_channel, "join_channel" CFG1_SE },
{ killsock, "killsock" }, { killsock, "killsock" },
{ make_auth, "make_auth" }, { make_auth, "make_auth" },
{ make_ban, "make_ban" }, { make_ban, "make_ban" },
{ make_chanuser, "make_chanuser" }, { make_chanuser, "make_chanuser" },
{ make_ireq, "make_ireq" }, { make_ireq, "make_ireq" CMD1_SE },
{ make_strp, "make_strp" }, { make_strp, "make_strp" CORE_SE },
{ mirror_user, "mirror_user" }, { mirror_user, "mirror_user" CORE_SE },
{ on_join, "on_join" }, { on_join, "on_join" CORE_SE },
{ on_kick, "on_kick" }, { on_kick, "on_kick" CORE_SE },
{ on_mode, "on_mode" }, { on_mode, "on_mode" CORE_SE },
{ on_msg, "on_msg" }, { on_msg, "on_msg" CORE_SE },
{ on_nick, "on_nick" }, { on_nick, "on_nick" CORE_SE },
{ parse_311, "parse_311" }, { parse_311, "parse_311" },
{ randstring_getline, "randstring_getline" }, { randstring_getline, "randstring_getline" CMD1_SE },
{ readcfgfile, "readcfgfile" }, { readcfgfile, "readcfgfile" },
{ recover_client, "recover_client" INIT_SE },
{ reverse_topic, "reverse_topic" }, { reverse_topic, "reverse_topic" },
{ to_user, "to_user" }, { to_user, "to_user" },
{ to_user_q, "to_user_q" }, { to_user_q, "to_user_q" },
{ send_kick, "send_kick" }, { send_kick, "send_kick" },
{ send_mode, "send_mode" }, { send_mode, "send_mode" },
{ set_str_varc, "set_str_varc" }, { set_str_varc, "set_str_varc" CFG1_SE },
{ setbotnick, "setbotnick" }, { setbotnick, "setbotnick" },
{ sig_hup, "sig_hup" }, { sig_hup, "sig_hup" RARE_SE },
{ table_buffer, "table_buffer" }, { table_buffer, "table_buffer" },
#ifdef ALIAS #ifdef ALIAS
{ do_alias, "do_alias" }, { do_alias, "do_alias" },
@ -187,7 +196,7 @@ LS struct
#endif /* HOSTINFO */ #endif /* HOSTINFO */
#ifdef NOTE #ifdef NOTE
{ catch_note, "catch_note" }, { catch_note, "catch_note" },
{ do_note, "do_note" }, { do_note, "do_note" CMD1_SE },
#endif /* NOTE */ #endif /* NOTE */
#ifdef NOTIFY #ifdef NOTIFY
{ catch_whois, "catch_whois" }, { catch_whois, "catch_whois" },
@ -201,10 +210,10 @@ LS struct
#ifdef RAWDNS #ifdef RAWDNS
{ rawdns, "rawdns" }, { rawdns, "rawdns" },
{ parse_query, "parse_query" }, { parse_query, "parse_query" },
{ read_dnsroot, "read_dnsroot" }, { read_dnsroot, "read_dnsroot" CFG1_SE },
#endif /* RAWDNS */ #endif /* RAWDNS */
#ifdef REDIRECT #ifdef REDIRECT
{ begin_redirect, "begin_redirect" }, { begin_redirect, "begin_redirect" CORE_SE },
#endif /* REDIRECT */ #endif /* REDIRECT */
#ifdef SEEN #ifdef SEEN
{ make_seen, "make_seen" }, { make_seen, "make_seen" },
@ -219,19 +228,19 @@ LS struct
{ check_telnet, "check_telnet" }, { check_telnet, "check_telnet" },
#endif /* TELNET */ #endif /* TELNET */
#ifdef TOYBOX #ifdef TOYBOX
{ read_bigcharset_callback, "read_bigcharset_callback" }, { read_bigcharset_callback, "read_bigcharset_callback" CMD1_SE },
#endif /* TOYBOX */ #endif /* TOYBOX */
#ifdef TRIVIA #ifdef TRIVIA
{ trivia_check, "trivia_check" }, { trivia_check, "trivia_check" CMD1_SE },
{ trivia_question, "trivia_question" }, { trivia_question, "trivia_question" CMD1_SE },
{ trivia_score_callback, "trivia_score_callback" }, { trivia_score_callback, "trivia_score_callback" CMD1_SE },
#endif /* TRIVIA */ #endif /* TRIVIA */
#ifdef UPTIME #ifdef UPTIME
{ init_uptime, "init_uptime" }, { init_uptime, "init_uptime" CFG1_SE },
{ send_uptime, "send_uptime" }, { send_uptime, "send_uptime" CORE_SE },
#endif /* UPTIME */ #endif /* UPTIME */
#ifdef URLCAPTURE #ifdef URLCAPTURE
{ urlcapture, "urlcapture" }, { urlcapture, "urlcapture" CORE_SE },
#endif /* URLCAPTURE */ #endif /* URLCAPTURE */
{ 0, "(unknown)" }, { 0, "(unknown)" },
{ NULL, }}; { NULL, }};
@ -445,6 +454,42 @@ const char *proc_lookup(void *addr, int size)
return(NULL); return(NULL);
} }
void proc_list(void)
{
int i,sel;
void *a,*b,*l;
a = l = NULL;
do
{
b = NULL;
for(i=0;ProcList[i].name;i++)
{
if ((ProcList[i].func > a) && ((b == NULL) || (ProcList[i].func < b)))
{
b = ProcList[i].func;
sel = i;
}
}
if (b)
{
if (l == NULL)
l = b;
if (strlen(ProcList[sel].name) < 14)
a = "\t\t";
else
if (strlen(ProcList[sel].name) < 20)
a = "\t";
else
a = " ";
debug("; %s%s"mx_pfmt" (+%i) [%s]\n",ProcList[sel].name,a,b,b-l,ProcList[sel].segment);
a = b;
}
}
while (b);
}
char *atime(time_t when) char *atime(time_t when)
{ {
char *pt,*zp; char *pt,*zp;
@ -573,6 +618,9 @@ void debug_memory(void)
#ifdef ALIAS #ifdef ALIAS
Alias *alias; Alias *alias;
#endif /* ALIAS */ #endif /* ALIAS */
#ifdef URLCAPTURE
Strp *sp;
#endif /* URLCAPTURE */
Chan *chan; Chan *chan;
Mech *bot; Mech *bot;
aMEA *mea; aMEA *mea;
@ -588,6 +636,12 @@ void debug_memory(void)
memtouch(alias->format); memtouch(alias->format);
} }
#endif /* ALIAS */ #endif /* ALIAS */
#ifdef URLCAPTURE
for(sp=urlhistory;sp;sp=sp->next)
{
memtouch(sp);
}
#endif /* URLCAPTURE */
for(bot=botlist;bot;bot=bot->next) for(bot=botlist;bot;bot=bot->next)
{ {
for(i=CHANSET_SIZE;VarName[i].name;i++) for(i=CHANSET_SIZE;VarName[i].name;i++)
@ -607,6 +661,7 @@ void debug_memory(void)
{ {
memtouch(bot->lastcmds[i]); memtouch(bot->lastcmds[i]);
} }
memtouch(bot->userhost);
} }
debug("> Memory allocations\n"); debug("> Memory allocations\n");
for(mea=mrrec;(mea);mea=mea->next) for(mea=mrrec;(mea);mea=mea->next)
@ -737,7 +792,10 @@ void debug_botnet(void)
debug(" ; lsid\t\t%i\n",bn->lsid); debug(" ; lsid\t\t%i\n",bn->lsid);
debug(" ; rsid\t\t%i\n",bn->rsid); debug(" ; rsid\t\t%i\n",bn->rsid);
debug(" ; opt.pta\t\t%s\n",boolstr(bn->opt.pta)); debug(" ; opt.pta\t\t%s\n",boolstr(bn->opt.pta));
if (bn->controller)
debug(" ; controller\t\t"mx_pfmt" { guid = %i }\n",(mx_ptr)bn->controller,bn->controller->guid); debug(" ; controller\t\t"mx_pfmt" { guid = %i }\n",(mx_ptr)bn->controller,bn->controller->guid);
else
debug(" ; controller\t\tnot set (NULL)\n");
debug(" ; when\t\t%s (%lu)\n",atime(bn->when),bn->when); debug(" ; when\t\t%s (%lu)\n",atime(bn->when),bn->when);
debug(" > botinfo\t\t"mx_pfmt"\n",(mx_ptr)bn->botinfo); debug(" > botinfo\t\t"mx_pfmt"\n",(mx_ptr)bn->botinfo);
debug_botinfo(bn->botinfo); debug_botinfo(bn->botinfo);
@ -789,7 +847,7 @@ void debug_core(void)
debug("> StructList\n"); debug("> StructList\n");
for(i=0;StructList[i].name;i++) for(i=0;StructList[i].name;i++)
{ {
debug(" ; %s\t\t%i\n",StructList[i].name,StructList[i].size); debug(" ; %s\t%s%i\n",StructList[i].name,(strlen(StructList[i].name) < 12) ? "\t" : "",StructList[i].size);
} }
debug(" ; ---\n"); debug(" ; ---\n");
if (current) if (current)
@ -1356,6 +1414,9 @@ void run_debug(void)
#endif /* SCRIPTING */ #endif /* SCRIPTING */
debug_memory(); debug_memory();
debug("> functions\n");
proc_list();
debug("; ---\n");
} }
int wrap_debug(void) int wrap_debug(void)

View File

@ -32,8 +32,8 @@
#ifndef TEST #ifndef TEST
LS char timebuf[24]; /* max format lentgh == 20+1, round up to nearest longword -> 24 */ LS char timebuf[32]; /* max format lentgh == 20+1, round up to 32 */
LS char idlestr[36]; /* max format lentgh == 24+1, round up to nearest longword -> 28 */ LS char idlestr[36]; /* max format lentgh == 24+1, round up to 36 */
LS const char monlist[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; LS const char monlist[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
LS const char daylist[7][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; LS const char daylist[7][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };

View File

@ -1,7 +1,7 @@
/* /*
EnergyMech, IRC bot software EnergyMech, IRC bot software
Copyright (c) 1997-2020 proton Copyright (c) 1997-2025 proton
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -70,6 +70,7 @@ struct
{ 0, "RAND", "do_rand", 0 | CBANG | SUPRES }, { 0, "RAND", "do_rand", 0 | CBANG | SUPRES },
#endif /* TOYBOX */ #endif /* TOYBOX */
{ 0, "CV", "do_convert", 0 | CBANG | SUPRES }, { 0, "CV", "do_convert", 0 | CBANG | SUPRES },
{ 0, "CALC", "do_calc", 0 | CBANG | SUPRES },
/* /*
* Level 10 * Level 10
@ -238,7 +239,7 @@ struct
* Level 100 * Level 100
*/ */
#ifdef HOSTINFO #ifdef HOSTINFO
{ 0, "HOSTINFO", "do_hostinfo", 100 | CCPW | GAXS }, { 0, "SYSINFO", "do_sysinfo", 100 | CCPW | GAXS },
{ 0, "MEMINFO", "do_meminfo", 100 | CCPW | GAXS }, { 0, "MEMINFO", "do_meminfo", 100 | CCPW | GAXS },
{ 0, "CPUINFO", "do_cpuinfo", 100 | CCPW | GAXS }, { 0, "CPUINFO", "do_cpuinfo", 100 | CCPW | GAXS },
{ 0, "FILEMON", "do_filemon", 100 | CCPW | GAXS | CARGS }, { 0, "FILEMON", "do_filemon", 100 | CCPW | GAXS | CARGS },

View File

@ -1,7 +1,7 @@
/* /*
EnergyMech, IRC bot software EnergyMech, IRC bot software
Copyright (c) 1997-2018 proton Copyright (c) 1997-2024 proton
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -42,8 +42,8 @@
#define DEFAULTCMDCHAR '-' #define DEFAULTCMDCHAR '-'
#define MECHUSERLOGIN "v3.energymech.net" #define MECHUSERLOGIN "v3.energymech.net"
BEG const char VERSION[] MDEF("3.1p" GITHASH); BEG const char VERSION[] MDEF("3.2p" GITHASH);
BEG const char SRCDATE[] MDEF("April 14th, 2018"); BEG const char SRCDATE[] MDEF("May 13th, 2024");
#ifdef __CYGWIN__ #ifdef __CYGWIN__
BEG const char BOTCLASS[] MDEF("WinMech"); BEG const char BOTCLASS[] MDEF("WinMech");
#else /* ! CYGWIN */ #else /* ! CYGWIN */

301
src/h.h
View File

@ -1,7 +1,7 @@
/* /*
EnergyMech, IRC bot software EnergyMech, IRC bot software
Copyright (c) 1997-2020 proton Copyright (c) 1997-2024 proton
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -116,16 +116,16 @@ LS void do_unalias(COMMAND_ARGS) __page(CMD1_SEG);
/* auth.c */ /* auth.c */
LS char *cipher(char *); LS char *cipher(char *) __page(CMD1_SEG);
LS char *makepass(char *); LS char *makepass(char *) __page(CMD1_SEG);
LS int passmatch(char *, char *); LS int passmatch(char *, char *) __page(CMD1_SEG);
LS void delete_auth(char *); LS void delete_auth(char *) __page(CMD1_SEG);
LS void remove_auth(Auth *); LS void remove_auth(Auth *) __page(CMD1_SEG);
LS void change_authnick(char *, char *); LS void change_authnick(char *, char *) __page(CORE_SEG);
LS void aucheck(User *); LS void aucheck(User *) __page(CORE_SEG);
LS User *get_authuser(const char *, const char *) __page(CORE_SEG); LS User *get_authuser(const char *, const char *) __page(CORE_SEG);
LS int get_authaccess(const char *, const char *) __page(CORE_SEG); LS int get_authaccess(const char *, const char *) __page(CORE_SEG);
LS int make_auth(const char *, const User *); LS int make_auth(const char *, const User *) __page(CMD1_SEG);
LS void do_auth(COMMAND_ARGS) __page(CMD1_SEG); LS void do_auth(COMMAND_ARGS) __page(CMD1_SEG);
/* bounce.c */ /* bounce.c */
@ -133,12 +133,13 @@ LS void do_auth(COMMAND_ARGS) __page(CMD1_SEG);
void bounce_parse(ircLink *, char *); void bounce_parse(ircLink *, char *);
void bounce_cleanup(void); void bounce_cleanup(void);
void new_port_bounce(const struct Setting *); void new_port_bounce(const struct Setting *);
void select_bounce(void); void select_bounce(void) __page(CORE_SEG);
void process_bounce(void); void process_bounce(void) __page(CORE_SEG);
/* calc.c */ /* calc.c */
LS void do_convert(COMMAND_ARGS) __page(CMD1_SEG); LS void do_convert(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_calc(COMMAND_ARGS) __page(CMD1_SEG);
/* channel.c */ /* channel.c */
@ -146,24 +147,24 @@ void check_idlekick(void);
LS Chan *find_channel(const char *, int) __attr(CORE_SEG, __regparm(2)); LS Chan *find_channel(const char *, int) __attr(CORE_SEG, __regparm(2));
LS Chan *find_channel_ac(const char *) __attr(CORE_SEG, __regparm(1)); LS Chan *find_channel_ac(const char *) __attr(CORE_SEG, __regparm(1));
LS Chan *find_channel_ny(const char *) __attr(CORE_SEG, __regparm(1)); LS Chan *find_channel_ny(const char *) __attr(CORE_SEG, __regparm(1));
void remove_chan(Chan *); void remove_chan(Chan *) __page(CMD1_SEG);
void join_channel(char *, char *); void join_channel(char *, char *) __page(CFG1_SEG);
void reverse_topic(Chan *, char *, char *); void reverse_topic(Chan *, char *, char *) __page(CORE_SEG);
void cycle_channel(Chan *); void cycle_channel(Chan *) __page(CMD1_SEG);
int reverse_mode(char *, Chan *, int, int); int reverse_mode(char *, Chan *, int, int) __page(CORE_SEG);
void chan_modestr(Chan *, char *); void chan_modestr(Chan *, char *) __page(CORE_SEG);
char *find_nuh(char *); char *find_nuh(char *) __page(CORE_SEG);
Ban *make_ban(Ban **, char *, char *, time_t); Ban *make_ban(Ban **, char *, char *, time_t);
void delete_ban(Chan *, char *); void delete_ban(Chan *, char *);
void delete_modemask(Chan *, char *, int); void delete_modemask(Chan *, char *, int);
void channel_massmode(const Chan *, char *, int, char, char); void channel_massmode(const Chan *, char *, int, char, char);
void channel_massunban(Chan *, char *, time_t); void channel_massunban(Chan *, char *, time_t);
LS ChanUser *find_chanuser(Chan *, const char *); LS ChanUser *find_chanuser(Chan *, const char *) __page(CORE_SEG);
LS ChanUser *find_chanbot(Chan *, const char *); LS ChanUser *find_chanbot(Chan *, const char *) __page(CORE_SEG);
LS void remove_chanuser(Chan *, const char *); LS void remove_chanuser(Chan *, const char *) __page(CORE_SEG);
LS void make_chanuser(char *, char *); LS void make_chanuser(char *, char *) __page(CORE_SEG);
LS void purge_chanusers(Chan *); LS void purge_chanusers(Chan *) __page(CMD1_SEG);
LS char *get_nuh(const ChanUser *); LS char *get_nuh(const ChanUser *) __page(CORE_SEG);
LS void do_join(COMMAND_ARGS) __page(CMD1_SEG); LS void do_join(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_part(COMMAND_ARGS) __page(CMD1_SEG); LS void do_part(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_cycle(COMMAND_ARGS) __page(CMD1_SEG); LS void do_cycle(COMMAND_ARGS) __page(CMD1_SEG);
@ -183,24 +184,24 @@ LS void do_idle(COMMAND_ARGS) __page(CMD1_SEG);
/* core.c */ /* core.c */
void unlink_identfile(void); void unlink_identfile(void);
int conf_callback(char *line); int conf_callback(char *line) __page(CFG1_SEG);
void readcfgfile(void); void readcfgfile(void) __page(CFG1_SEG);
int write_session(void); int write_session(void) __page(CORE_SEG);
void setbotnick(Mech *bot, char *nick); void setbotnick(Mech *bot, char *nick) __page(CFG1_SEG);
Mech *add_bot(int guid, char *nick); Mech *add_bot(int guid, char *nick) __page(CFG1_SEG);
void signoff(char *from, char *reason); void signoff(char *from, char *reason) __page(RARE_SEG);
void kill_all_bots(char *reason) __attr(RARE_SEG, __noreturn__);; void kill_all_bots(char *reason) __attr(RARE_SEG, __noreturn__);;
Server *add_server(char *host, int port, char *pass); Server *add_server(char *host, int port, char *pass) __page(CFG1_SEG);
ServerGroup *getservergroup(const char *name); ServerGroup *getservergroup(const char *name);
ServerGroup *getservergroupid(int id); ServerGroup *getservergroupid(int id);
Server *find_server(int id); Server *find_server(int id) __page(CORE_SEG);
int try_server(Server *sp, char *hostname); int try_server(Server *sp, char *hostname) __page(CORE_SEG);
void connect_to_server(void); void connect_to_server(void) __page(CORE_SEG);
void register_with_server(void); void register_with_server(void) __page(CORE_SEG);
int sub_compile_timer(int, uint32_t *, uint32_t *, char *); int sub_compile_timer(int, uint32_t *, uint32_t *, char *) __page(CFG1_SEG);
int compile_timer(HookTimer *, char *); int compile_timer(HookTimer *, char *) __page(CFG1_SEG);
void update(SequenceTime *this); void update(SequenceTime *this) __page(CORE_SEG);
void process_server_input(void); void process_server_input(void) __page(CORE_SEG);
void do_version(COMMAND_ARGS) __page(CMD1_SEG); void do_version(COMMAND_ARGS) __page(CMD1_SEG);
void do_core(COMMAND_ARGS) __page(CMD1_SEG); void do_core(COMMAND_ARGS) __page(CMD1_SEG);
void do_die(COMMAND_ARGS) __page(RARE_SEG); void do_die(COMMAND_ARGS) __page(RARE_SEG);
@ -223,12 +224,12 @@ int dcc_sendfile(char *target, char *filename);
void dcc_pushfile(Client *client, off_t where); void dcc_pushfile(Client *client, off_t where);
int dcc_freeslots(int uaccess); int dcc_freeslots(int uaccess);
void parse_dcc(Client *client); void parse_dcc(Client *client);
void process_dcc(void); void process_dcc(void) __page(CORE_SEG);
void ctcp_dcc(char *from, char *to, char *rest); void ctcp_dcc(char *from, char *to, char *rest) __page(CORE_SEG);
void ctcp_finger(char *from, char *to, char *rest); void ctcp_finger(char *from, char *to, char *rest) __page(CORE_SEG);
void ctcp_ping(char *from, char *to, char *rest); void ctcp_ping(char *from, char *to, char *rest) __page(CORE_SEG);
void ctcp_version(char *from, char *to, char *rest); void ctcp_version(char *from, char *to, char *rest) __page(CORE_SEG);
void on_ctcp(char *from, char *to, char *rest); void on_ctcp(char *from, char *to, char *rest) __page(CORE_SEG);
void do_ping_ctcp(COMMAND_ARGS) __page(CMD1_SEG); void do_ping_ctcp(COMMAND_ARGS) __page(CMD1_SEG);
void do_send(COMMAND_ARGS) __page(CMD1_SEG); void do_send(COMMAND_ARGS) __page(CMD1_SEG);
@ -254,22 +255,22 @@ void run_debug(void);
int wrap_debug(void); int wrap_debug(void);
void do_debug(COMMAND_ARGS) __page(CMD1_SEG); void do_debug(COMMAND_ARGS) __page(CMD1_SEG);
void do_crash(COMMAND_ARGS) __page(RARE_SEG); void do_crash(COMMAND_ARGS) __page(RARE_SEG);
void debug(char *format, ...); void debug(char *format, ...) __page(CORE_SEG);
/* dns.c */ /* dns.c */
void init_rawdns(void); void init_rawdns(void) __page(CFG1_SEG);
struct in_addr dnsroot_lookup(const char *hostname); struct in_addr dnsroot_lookup(const char *hostname);
const char *get_dns_token(const char *src, const char *packet, char *dst, int sz); const char *get_dns_token(const char *src, const char *packet, char *dst, int sz);
int make_query(char *packet, const char *hostname); int make_query(char *packet, const char *hostname);
struct in_addr *get_stored_ip(const char *ipdata); struct in_addr *get_stored_ip(const char *ipdata);
void dns_hook(char *host, char * resolved); void dns_hook(char *host, char * resolved);
void parse_query(int psz, dnsQuery *query); void parse_query(int psz, dnsQuery *query);
void rawdns(const char *hostname); void rawdns(const char *hostname) __page(CORE_SEG);
void select_rawdns(void); void select_rawdns(void) __page(CORE_SEG);
void process_rawdns(void); void process_rawdns(void) __page(CORE_SEG);
char *poll_rawdns(char *hostname); char *poll_rawdns(char *hostname) __page(CORE_SEG);
int read_dnsroot(char *line); int read_dnsroot(char *line) __page(CFG1_SEG);
uint32_t rawdns_get_ip(const char *host); uint32_t rawdns_get_ip(const char *host);
void do_dnsroot(COMMAND_ARGS) __page(CMD1_SEG); void do_dnsroot(COMMAND_ARGS) __page(CMD1_SEG);
void do_dnsserver(COMMAND_ARGS) __page(CMD1_SEG); void do_dnsserver(COMMAND_ARGS) __page(CMD1_SEG);
@ -316,26 +317,26 @@ LS int is_safepath(const char *, int) __attr(CORE_SEG, __regparm(2));
/* greet.c */ /* greet.c */
void greet(void); void greet(void) __page(CORE_SEG);
void do_greet(COMMAND_ARGS) __page(CMD1_SEG); void do_greet(COMMAND_ARGS) __page(CMD1_SEG);
/* help.c */ /* help.c */
void print_help(char *from, char *line, int len); void print_help(char *from, char *line, int len) __page(CMD1_SEG);
int do_help_callback(char *line); int do_help_callback(char *line) __page(CMD1_SEG);
void usage_command(char *to, const char *arg); void usage_command(char *to, const char *arg) __page(CMD1_SEG);
void usage(char *to); void usage(char *to) __page(CMD1_SEG);
void do_help(COMMAND_ARGS) __page(CMD1_SEG); void do_help(COMMAND_ARGS) __page(CMD1_SEG);
void do_usage(COMMAND_ARGS) __page(CMD1_SEG); void do_usage(COMMAND_ARGS) __page(CMD1_SEG);
/* hostinfo.c */ /* hostinfo.c */
int monitor_fs(const char *); int monitor_fs(const char *);
void select_monitor(); void select_monitor() __page(CORE_SEG);
void process_monitor(); void process_monitor() __page(CORE_SEG);
int parse_proc_status(char *line) __page(CMD1_SEG); int parse_proc_status(char *line) __page(CMD1_SEG);
int parse_proc_cpuinfo(char *line) __page(CMD1_SEG); int parse_proc_cpuinfo(char *line) __page(CMD1_SEG);
void do_hostinfo(COMMAND_ARGS) __page(CMD1_SEG); void do_sysinfo(COMMAND_ARGS) __page(CMD1_SEG);
void do_meminfo(COMMAND_ARGS) __page(CMD1_SEG); void do_meminfo(COMMAND_ARGS) __page(CMD1_SEG);
void do_cpuinfo(COMMAND_ARGS) __page(CMD1_SEG); void do_cpuinfo(COMMAND_ARGS) __page(CMD1_SEG);
void do_filemon(COMMAND_ARGS) __page(CMD1_SEG); void do_filemon(COMMAND_ARGS) __page(CMD1_SEG);
@ -348,12 +349,12 @@ LS int SockOpts(void) __page(CORE_SEG);
LS int SockListener(int) __page(CORE_SEG); LS int SockListener(int) __page(CORE_SEG);
LS int SockConnect(char *, int, int) __page(CORE_SEG); LS int SockConnect(char *, int, int) __page(CORE_SEG);
LS int SockAccept(int) __page(CORE_SEG); LS int SockAccept(int) __page(CORE_SEG);
int to_file(int sock, const char *format, ...); int to_file(const int sock, const char *format, ...) __page(CORE_SEG);
void to_server(char *format, ...); void to_server(char *format, ...) __page(CORE_SEG);
void to_user_q(const char *, const char *, ...); void to_user_q(const char *, const char *, ...) __page(CMD1_SEG);
void to_user(const char *, const char *, ...); void to_user(const char *, const char *, ...) __page(CORE_SEG);
char *sockread(int, char *, char *); char *sockread(int, char *, char *) __page(CORE_SEG);
void readline(int, int (*)(char *)); void readline(int, int (*)(char *)) __page(CMD1_SEG);
void remove_ks(KillSock *); void remove_ks(KillSock *);
int killsock(int); int killsock(int);
LS void do_clearqueue(COMMAND_ARGS) __page(CMD1_SEG); LS void do_clearqueue(COMMAND_ARGS) __page(CMD1_SEG);
@ -392,9 +393,9 @@ LS char *tolowercat(char *, const char *) __attr(CORE_SEG, __regparm(2));
/* main.c */ /* main.c */
void mech_exec(void); void mech_exec(void) __page(RARE_SEG);
int randstring_count(char *line); int randstring_count(char *line) __page(CMD1_SEG);
int randstring_getline(char *line); int randstring_getline(char *line) __page(CMD1_SEG);
LS char *randstring(const char *) __page(CORE_SEG); LS char *randstring(const char *) __page(CORE_SEG);
LS int sig_hup_callback(char *) __page(RARE_SEG); /* rare */ LS int sig_hup_callback(char *) __page(RARE_SEG); /* rare */
LS void do_sighup(void) __page(CMD1_SEG); LS void do_sighup(void) __page(CMD1_SEG);
@ -417,8 +418,8 @@ LS void sig_segv(int, siginfo_t *, void *) __attr(RARE_SEG, __noreturn__);
LS void sig_segv(int) __attr(RARE_SEG, __noreturn__); LS void sig_segv(int) __attr(RARE_SEG, __noreturn__);
#endif #endif
LS void sig_term(int) __attr(RARE_SEG, __noreturn__); /* rare */ LS void sig_term(int) __attr(RARE_SEG, __noreturn__); /* rare */
LS void doit(void); LS void doit(void) __page(CORE_SEG);
LS int main(int argc, char **argv, char **envp); LS int main(int argc, char **argv, char **envp) __page(INIT_SEG);
/* net.c */ /* net.c */
@ -451,8 +452,8 @@ void ushareTick(BotNet *bn, char *rest);
void ushareDelete(BotNet *bn, char *rest); void ushareDelete(BotNet *bn, char *rest);
void parse_botnet(BotNet *bn, char *rest); void parse_botnet(BotNet *bn, char *rest);
void botnet_newsock(void); void botnet_newsock(void);
void select_botnet(void); void select_botnet(void) __page(CORE_SEG);
void process_botnet(void); void process_botnet(void) __page(CORE_SEG);
void do_link(COMMAND_ARGS) __page(CMD1_SEG); void do_link(COMMAND_ARGS) __page(CMD1_SEG);
void do_cmd(COMMAND_ARGS) __page(CMD1_SEG); void do_cmd(COMMAND_ARGS) __page(CMD1_SEG);
@ -483,31 +484,31 @@ void do_notify(COMMAND_ARGS) __page(CMD1_SEG);
LS uint32_t makecrc(const char *) __page(CORE_SEG); LS uint32_t makecrc(const char *) __page(CORE_SEG);
LS void send_suppress(const char *, const char *) __page(CORE_SEG); LS void send_suppress(const char *, const char *) __page(CORE_SEG);
LS void on_kick(char *from, char *rest); LS void on_kick(char *from, char *rest) __page(CORE_SEG);
LS void on_join(Chan *chan, char *from); LS void on_join(Chan *chan, char *from) __page(CORE_SEG);
LS void on_nick(char *from, char *newnick); LS void on_nick(char *from, char *newnick) __page(CORE_SEG);
LS void on_msg(char *from, char *to, char *rest); LS void on_msg(char *from, char *to, char *rest) __page(CORE_SEG);
LS void on_mode(char *from, char *channel, char *rest); LS void on_mode(char *from, char *channel, char *rest) __page(CORE_SEG);
LS void common_public(Chan *chan, char *from, char *spyformat, char *rest); LS void common_public(Chan *chan, char *from, char *spyformat, char *rest) __page(CORE_SEG);
LS void on_action(char *from, char *to, char *rest); LS void on_action(char *from, char *to, char *rest) __page(CORE_SEG);
LS int access_needed(char *name); LS int access_needed(char *name) __page(CORE_SEG);
LS void do_chaccess(COMMAND_ARGS) __page(CMD1_SEG); LS void do_chaccess(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_last(COMMAND_ARGS) __page(CMD1_SEG); LS void do_last(COMMAND_ARGS) __page(CMD1_SEG);
/* parse.c */ /* parse.c */
LS void parse_error(char *from, char *rest); LS void parse_error(char *from, char *rest) __page(CORE_SEG);
LS void parse_invite(char *from, char *rest); LS void parse_invite(char *from, char *rest) __page(CMD1_SEG);
LS void parse_join(char *from, char *rest); LS void parse_join(char *from, char *rest) __page(CORE_SEG);
LS void parse_mode(char *from, char *rest); LS void parse_mode(char *from, char *rest) __page(CORE_SEG);
LS void parse_notice(char *from, char *rest); LS void parse_notice(char *from, char *rest) __page(CORE_SEG);
LS void parse_part(char *from, char *rest); LS void parse_part(char *from, char *rest) __page(CORE_SEG);
LS void parse_ping(char *from, char *rest); LS void parse_ping(char *from, char *rest) __page(CORE_SEG);
LS void parse_pong(char *from, char *rest); LS void parse_pong(char *from, char *rest) __page(CORE_SEG);
LS void parse_privmsg(char *from, char *rest); LS void parse_privmsg(char *from, char *rest) __page(CORE_SEG);
LS void parse_quit(char *from, char *rest); LS void parse_quit(char *from, char *rest) __page(CORE_SEG);
LS void parse_topic(char *from, char *rest); LS void parse_topic(char *from, char *rest) __page(CORE_SEG);
LS void parse_wallops(char *from, char *rest); LS void parse_wallops(char *from, char *rest) __page(CORE_SEG);
LS void parse_213(char *from, char *rest); LS void parse_213(char *from, char *rest);
LS void parse_219(char *from, char *rest); LS void parse_219(char *from, char *rest);
LS void parse_251(char *from, char *rest); LS void parse_251(char *from, char *rest);
@ -537,8 +538,8 @@ LS void parse_346(char *from, char *rest);
LS void parse_348(char *from, char *rest); LS void parse_348(char *from, char *rest);
LS void parse_368(char *from, char *rest); LS void parse_368(char *from, char *rest);
LS void parse_005(char *from, char *rest); LS void parse_005(char *from, char *rest);
LS uint32_t stringhash(char *s); LS uint32_t stringhash(char *s) __page(CORE_SEG);
LS void parse_server_input(char *rest); LS void parse_server_input(char *rest) __page(CORE_SEG);
/* partyline.c */ /* partyline.c */
@ -610,10 +611,10 @@ void do_pythonscript(COMMAND_ARGS) __page(CMD1_SEG);
/* reset.c */ /* reset.c */
char *recover_client(char *env); char *recover_client(char *env) __page(INIT_SEG);
char *recover_debug(char *env); char *recover_debug(char *env) __page(INIT_SEG);
char *recover_server(char *env); char *recover_server(char *env) __page(INIT_SEG);
void recover_reset(void); void recover_reset(void) __page(INIT_SEG);
void do_reset(COMMAND_ARGS) __page(RARE_SEG); void do_reset(COMMAND_ARGS) __page(RARE_SEG);
/* seen.c */ /* seen.c */
@ -641,17 +642,17 @@ void do_clearshit(COMMAND_ARGS) __page(CMD1_SEG);
/* spy.c */ /* spy.c */
void send_spy(const char *src, const char *format, ...); void send_spy(const char *src, const char *format, ...) __page(CORE_SEG);
void send_global(const char *src, const char *format, ...); void send_global(const char *src, const char *format, ...) __page(CORE_SEG);
void spy_typecount(Mech *bot); void spy_typecount(Mech *bot) __page(CORE_SEG);
int spy_source(char *from, int *t_src, const char **src); int spy_source(char *from, int *t_src, const char **src) __page(CORE_SEG);
char *urlhost(const char *); char *urlhost(const char *) __page(CORE_SEG);
LS void urlcapture(const char *) __page(CORE_SEG); LS void urlcapture(const char *) __page(CORE_SEG);
int begin_redirect(char *, char *); int begin_redirect(char *, char *) __page(CORE_SEG);
void send_redirect(char *); void send_redirect(char *) __page(CORE_SEG);
void end_redirect(void); void end_redirect(void) __page(CORE_SEG);
void stats_loghour(Chan *chan, char *filename, int hour); void stats_loghour(Chan *chan, char *filename, int hour) __page(CORE_SEG);
void stats_plusminususer(Chan *chan, int plusminus); void stats_plusminususer(Chan *chan, int plusminus) __page(CORE_SEG);
void do_spy(COMMAND_ARGS) __page(CMD1_SEG); void do_spy(COMMAND_ARGS) __page(CMD1_SEG);
void do_rspy(COMMAND_ARGS) __page(CMD1_SEG); void do_rspy(COMMAND_ARGS) __page(CMD1_SEG);
void do_info(COMMAND_ARGS) __page(CMD1_SEG); void do_info(COMMAND_ARGS) __page(CMD1_SEG);
@ -687,22 +688,22 @@ LS void do_tcl(COMMAND_ARGS) __page(CMD1_SEG);
/* toybox.c */ /* toybox.c */
LS int read_bigcharset_callback(char *); LS int read_bigcharset_callback(char *) __page(CMD1_SEG);
LS int read_bigcharset(char *); LS int read_bigcharset(char *) __page(CMD1_SEG);
LS int read_ascii(char *); LS int read_ascii(char *) __page(CMD1_SEG);
LS void trivia_week_toppers(void); LS void trivia_week_toppers(void) __page(CMD1_SEG);
LS void hint_one(void); LS void hint_one(void) __page(CMD1_SEG);
LS void hint_two(void); LS void hint_two(void) __page(CMD1_SEG);
LS void hint_three(void); LS void hint_three(void) __page(CMD1_SEG);
LS void trivia_cleanup(void); LS void trivia_cleanup(void) __page(CMD1_SEG);
LS void trivia_check(Chan *, char *); LS void trivia_check(Chan *, char *) __page(CMD1_SEG);
LS void trivia_no_answer(void); LS void trivia_no_answer(void) __page(CMD1_SEG);
LS char *random_question(char *); LS char *random_question(char *) __page(CMD1_SEG);
LS void trivia_question(void); LS void trivia_question(void) __page(CMD1_SEG);
LS void trivia_tick(void); LS void trivia_tick(void) __page(CMD1_SEG);
LS void write_triviascore(void); LS void write_triviascore(void) __page(CMD1_SEG);
LS int trivia_score_callback(char *); LS int trivia_score_callback(char *) __page(CMD1_SEG);
LS void read_triviascore(void); LS void read_triviascore(void) __page(CMD1_SEG);
LS void do_bigsay(COMMAND_ARGS) __page(CMD1_SEG); LS void do_bigsay(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_random_msg(COMMAND_ARGS) __page(CMD1_SEG); LS void do_random_msg(COMMAND_ARGS) __page(CMD1_SEG);
LS void do_randtopic(COMMAND_ARGS) __page(CMD1_SEG); LS void do_randtopic(COMMAND_ARGS) __page(CMD1_SEG);
@ -714,10 +715,10 @@ LS void do_trivia(COMMAND_ARGS) __page(CMD1_SEG);
/* uptime.c */ /* uptime.c */
void init_uptime(void); void init_uptime(void) __page(CFG1_SEG);
void send_uptime(int type); void send_uptime(int type) __page(CORE_SEG);
void uptime_death(int type); void uptime_death(int type) __page(RARE_SEG);
void process_uptime(void); void process_uptime(void) __page(CORE_SEG);
void do_upsend(COMMAND_ARGS) __page(CMD1_SEG); void do_upsend(COMMAND_ARGS) __page(CMD1_SEG);
/* user.c */ /* user.c */
@ -746,11 +747,11 @@ void remove_user(User *);
User *add_user(char *, char *, int); User *add_user(char *, char *, int);
User *find_handle(const char *); User *find_handle(const char *);
int userhaschannel(const User *, const char *); int userhaschannel(const User *, const char *);
User *get_user(const char *, const char *); User *get_user(const char *, const char *) __page(CORE_SEG);
int get_useraccess(const char *, const char *); int get_useraccess(const char *, const char *) __page(CORE_SEG);
int get_maxaccess(const char *); int get_maxaccess(const char *) __page(CORE_SEG);
int is_bot(const char *); int is_bot(const char *) __page(CORE_SEG);
int get_protaction(Chan *, char *); int get_protaction(Chan *, char *) __page(CORE_SEG);
int usercanmodify(const char *, const User *); int usercanmodify(const char *, const User *);
void change_pass(User *, char *) __page(CMD1_SEG); void change_pass(User *, char *) __page(CMD1_SEG);
void do_access(COMMAND_ARGS) __page(CMD1_SEG); void do_access(COMMAND_ARGS) __page(CMD1_SEG);
@ -764,23 +765,23 @@ void do_load(COMMAND_ARGS) __page(CMD1_SEG);
/* vars.c */ /* vars.c */
void set_str_varc(Chan *, int, char *); void set_str_varc(Chan *, int, char *) __page(CFG1_SEG);
int find_setting(const char *); int find_setting(const char *) __page(CORE_SEG);
void copy_vars(UniVar *, UniVar *); void copy_vars(UniVar *, UniVar *) __page(CFG1_SEG);
void set_binarydefault(UniVar *); void set_binarydefault(UniVar *) __page(CFG1_SEG);
void delete_vars(UniVar *, int); void delete_vars(UniVar *, int) __page(CMD1_SEG);
void var_resolve_host(const struct Setting *); void var_resolve_host(const struct Setting *);
void nobo_strcpy(const char *); void nobo_strcpy(const char *) __page(CMD1_SEG);
void ec_access(char *, const char *); void ec_access(char *, const char *) __page(CMD1_SEG);
void ec_capabilities(char *, const char *); void ec_capabilities(char *, const char *) __page(CMD1_SEG);
void ec_cc(char *, const char *); void ec_cc(char *, const char *) __page(CMD1_SEG);
void ec_channels(char *, const char *); void ec_channels(char *, const char *) __page(CMD1_SEG);
void ec_time(char *, const char *); void ec_time(char *, const char *) __page(CMD1_SEG);
void ec_set(char *, const char *); void ec_set(char *, const char *) __page(CMD1_SEG);
void ec_on(char *, const char *); void ec_on(char *, const char *) __page(CMD1_SEG);
void ec_server(char *, const char *); void ec_server(char *, const char *) __page(CMD1_SEG);
void ec_up(char *, const char *); void ec_up(char *, const char *) __page(CMD1_SEG);
void ec_ver(char *, const char *); void ec_ver(char *, const char *) __page(CMD1_SEG);
void do_esay(COMMAND_ARGS) __page(CMD1_SEG); void do_esay(COMMAND_ARGS) __page(CMD1_SEG);
void do_set(COMMAND_ARGS) __page(CMD1_SEG); void do_set(COMMAND_ARGS) __page(CMD1_SEG);

View File

@ -1,7 +1,7 @@
/* /*
EnergyMech, IRC bot software EnergyMech, IRC bot software
Copyright (c) 2020 proton Copyright (c) 2020-2024 proton
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -141,7 +141,7 @@ int parse_proc_status(char *line)
key = chop(&line); key = chop(&line);
#ifdef DEBUG #ifdef DEBUG
debug("pps key = %s (%s)\n",key,line); debug("(parse_proc_status) pps key = %s (%s)\n",key,line);
#endif #endif
if (key == NULL) if (key == NULL)
return(FALSE); return(FALSE);
@ -267,7 +267,7 @@ void process_monitor()
FileMon *fmon; FileMon *fmon;
struct inotify_event *ivent; struct inotify_event *ivent;
char tmp[256]; char tmp[256];
int n; int n,m;
for(fmon=filemonlist;fmon;fmon=fmon->next) for(fmon=filemonlist;fmon;fmon=fmon->next)
{ {
@ -277,14 +277,14 @@ void process_monitor()
n = read(fmon->fd,globaldata,sizeof(struct inotify_event)); n = read(fmon->fd,globaldata,sizeof(struct inotify_event));
if (ivent->len > 0) if (ivent->len > 0)
read(fmon->fd,ivent->name,ivent->len); m = read(fmon->fd,ivent->name,ivent->len);
else else
*ivent->name = 0; *ivent->name = 0;
#ifdef DEBUG #ifdef DEBUG
debug("ino %i, n %i, sz %i\n",fmon->fd,n,sizeof(in2str)); debug("(process_monitor) ino %i, n %i, sz %i\n",fmon->fd,n,sizeof(in2str));
debug("wd %i, mask %lu, cookie %lu, len %lu, name %s\n", debug("(process_monitor) wd %i, mask %lu, cookie %lu, len %lu, name %s\n",
ivent->wd,ivent->mask,ivent->cookie,ivent->len,ivent->name); ivent->wd,ivent->mask,ivent->cookie,ivent->len,ivent->name);
debug("%s\n",inomask2str(ivent->mask,tmp)); debug("(process_monitor) %s\n",inomask2str(ivent->mask,tmp));
debug("(process_monitor) ino %i bytes read, int wd = %i, uint32_t mask = %s (%lu), " debug("(process_monitor) ino %i bytes read, int wd = %i, uint32_t mask = %s (%lu), "
"uint32_t cookie = %lu, uint32_t len = %lu, char name = %s\n", "uint32_t cookie = %lu, uint32_t len = %lu, char name = %s\n",
n,ivent->wd,inomask2str(ivent->mask,tmp),ivent->mask,ivent->cookie,ivent->len,ivent->name); n,ivent->wd,inomask2str(ivent->mask,tmp),ivent->mask,ivent->cookie,ivent->len,ivent->name);
@ -302,13 +302,13 @@ void process_monitor()
/*---------------------------------------------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------------------------------------------*/
/* /*
help:HOSTINFO:(no arguments) help:SYSINFO:(no arguments)
Equivalent to ``uname -orm'' Equivalent to ``uname -orm''
See also: meminfo, cpuinfo See also: meminfo, cpuinfo
*/ */
void do_hostinfo(COMMAND_ARGS) void do_sysinfo(COMMAND_ARGS)
{ {
char *h,hostname[256]; char *h,hostname[256];
struct utsname un; struct utsname un;
@ -363,7 +363,7 @@ See also: hostinfo, meminfo
*/ */
void do_cpuinfo(COMMAND_ARGS) void do_cpuinfo(COMMAND_ARGS)
{ {
char bogostr[64],cpustr[64]; char bogostr[256],cpustr[64];
char *a1,*a2,*a3,*dst; char *a1,*a2,*a3,*dst;
int fd,n; int fd,n;
double loads[3]; double loads[3];
@ -375,13 +375,6 @@ void do_cpuinfo(COMMAND_ARGS)
else else
stringcpy(bogostr,"/proc/cpuinfo"); stringcpy(bogostr,"/proc/cpuinfo");
if ((fd = open(bogostr,O_RDONLY)) < 0) if ((fd = open(bogostr,O_RDONLY)) < 0)
/*
if ((fd = open("/home/git/cpuinfo/mips3",O_RDONLY)) < 0)
if ((fd = open("/home/git/cpuinfo/mips2",O_RDONLY)) < 0)
if ((fd = open("/home/git/cpuinfo/mips1",O_RDONLY)) < 0)
if ((fd = open("/home/git/cpuinfo/intel1",O_RDONLY)) < 0)
if ((fd = open("/home/git/cpuinfo/cosmiccow",O_RDONLY)) < 0)
*/
#endif #endif
if ((fd = open("/proc/cpuinfo",O_RDONLY)) < 0) if ((fd = open("/proc/cpuinfo",O_RDONLY)) < 0)
#ifdef DEBUG #ifdef DEBUG

View File

@ -269,7 +269,7 @@ int SockAccept(int sock)
/* /*
* Format text and send to a socket or file descriptor * Format text and send to a socket or file descriptor
*/ */
int to_file(int sock, const char *format, ...) int to_file(const int sock, const char *format, ...)
{ {
va_list msg; va_list msg;
#if defined(DEBUG) && !defined(GENCMD_C) #if defined(DEBUG) && !defined(GENCMD_C)
@ -357,7 +357,8 @@ void to_user_q(const char *target, const char *format, ...)
if (STARTUP_ECHOTOCONSOLE) if (STARTUP_ECHOTOCONSOLE)
{ {
write(1,message,strlen(message)); int n;
n = write(1,message,strlen(message));
return; return;
} }

View File

@ -61,10 +61,10 @@ SECTIONS
*(.text.hot .text.hot.*) *(.text.hot .text.hot.*)
*(.text.e) /* RARE */ *(.text.e) /* RARE */
*(.text.d) /* INIT */ *(.text.d) /* INIT */
*(.text.b) /* CFG1 */
*(.text.c) /* CMD1 */ *(.text.c) /* CMD1 */
*(.text.a) /* CORE */ *(.text.a) /* CORE */
*(.text.f) /* DBUG */ *(.text.f) /* DBUG */
*(.text.b) /* CFG1 */
*(.text .stub .text.* .gnu.linkonce.t.*) *(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */ /* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning) *(.gnu.warning)

View File

@ -1287,6 +1287,10 @@ int main(int argc, char **argv, char **envp)
if (startup == STARTUP_TESTRUN) if (startup == STARTUP_TESTRUN)
{ {
#ifdef DEBUG
if (debug_on_exit == TRUE)
run_debug();
#endif /* DEBUG */
to_file(1,"init: test run completed, exiting...\n"); to_file(1,"init: test run completed, exiting...\n");
_exit(0); _exit(0);
} }

View File

@ -1,7 +1,7 @@
/* /*
EnergyMech, IRC bot software EnergyMech, IRC bot software
Parts Copyright (c) 1997-2009 proton Parts Copyright (c) 1997-2024 proton
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -591,31 +591,6 @@ recheck_alias:
CurrentNick,uaccess,command,(int)acmd[i]); CurrentNick,uaccess,command,(int)acmd[i]);
} }
/*
* list of last LASTCMDSIZE commands
*/
if (from != CoreUser.name)
{
Free(&current->lastcmds[LASTCMDSIZE-1]);
for(j=LASTCMDSIZE-2;j>=0;j--)
current->lastcmds[j+1] = current->lastcmds[j];
if ((pt = STRCHR(from,'@')) == NULL)
pt = from;
set_mallocdoer(on_msg);
current->lastcmds[0] = (char*)Calloc(strlen(pt) + 45);
if (CurrentUser)
{
sprintf(current->lastcmds[0],"[%s] %s\r%s[%-3i]\t(*%s)",
time2medium(now),command,CurrentUser->name,
(CurrentUser->x.x.access),pt);
}
else
{
sprintf(current->lastcmds[0],"[%s] %s\r%s[---]\t(*%s)",
time2medium(now),command,CurrentNick,pt);
}
}
/* /*
* CAXS check: first argument might be a channel * CAXS check: first argument might be a channel
* check user access on target channel * check user access on target channel
@ -647,6 +622,31 @@ recheck_alias:
return; return;
} }
/*
* list of last LASTCMDSIZE commands
*/
if (from != CoreUser.name)
{
Free(&current->lastcmds[LASTCMDSIZE-1]);
for(j=LASTCMDSIZE-2;j>=0;j--)
current->lastcmds[j+1] = current->lastcmds[j];
if ((pt = STRCHR(from,'@')) == NULL)
pt = from;
set_mallocdoer(on_msg);
current->lastcmds[0] = (char*)Calloc(strlen(pt) + 45);
if (CurrentUser)
{
sprintf(current->lastcmds[0],"[%s] %s\r%s[%-3i]\t(*%s)",
time2medium(now),command,CurrentUser->name,
(CurrentUser->x.x.access),pt);
}
else
{
sprintf(current->lastcmds[0],"[%s] %s\r%s[---]\t(*%s)",
time2medium(now),command,CurrentNick,pt);
}
}
/* /*
* CARGS check: at least one argument is required * CARGS check: at least one argument is required
*/ */

View File

@ -69,6 +69,9 @@ static int basepos(char c)
return(63); return(63);
return(0); return(0);
} }
#if defined(SHACRYPT) || defined(MD5CRYPT)
char *CRYPT_FUNC(const char *, const char *);
#endif
void send_spy(const char *src, const char *format, ...) void send_spy(const char *src, const char *format, ...)
{ {
@ -130,12 +133,12 @@ void send_spy(const char *src, const char *format, ...)
SHA-512 | 86 characters SHA-512 | 86 characters
*/ */
#ifdef SHACRYPT #ifdef SHACRYPT
sprintf(tempdata,"$6$%04x",(now & 0xFFFF)); sprintf(tempdata,"$6$%04x",(uint32_t)(now & 0xFFFF));
rnd = CRYPT_FUNC(tempsrc,tempdata); rnd = CRYPT_FUNC(tempsrc,tempdata);
#endif /* SHACRYPT */ #endif /* SHACRYPT */
#if !defined(SHACRYPT) && defined(MD5CRYPT) #if !defined(SHACRYPT) && defined(MD5CRYPT)
sprintf(tempdata,"$1$%04x",(now & 0xFFFF)); sprintf(tempdata,"$1$%04x",(uint32_t)(now & 0xFFFF));
rnd = CRYPT_FUNC(tempsrc,tempdata); rnd = CRYPT_FUNC(tempsrc,tempdata);
#endif /* !SHACRYPT && MD5CRYPT */ #endif /* !SHACRYPT && MD5CRYPT */
@ -164,7 +167,9 @@ void send_spy(const char *src, const char *format, ...)
#endif /* DEBUG */ #endif /* DEBUG */
if ((fd = open(spy->dest,O_WRONLY|O_CREAT|O_APPEND,NEWFILEMODE)) >= 0) if ((fd = open(spy->dest,O_WRONLY|O_CREAT|O_APPEND,NEWFILEMODE)) >= 0)
{ {
write(fd,tempdata,dst - tempdata); int n;
n = write(fd,tempdata,dst - tempdata);
close(fd); close(fd);
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
EnergyMech, IRC bot software EnergyMech, IRC bot software
Copyright (c) 2000-2018 proton Copyright (c) 2000-2024 proton
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -102,6 +102,7 @@
#define TEXT_BOTUPTIME "Uptime\t%s" #define TEXT_BOTUPTIME "Uptime\t%s"
#define TEXT_BOTVERSION "Version\t%s (%s)" #define TEXT_BOTVERSION "Version\t%s (%s)"
#define TEXT_BOTFEATURES "Features\t%s" #define TEXT_BOTFEATURES "Features\t%s"
#define TEXT_HOSTINFO "Host\t%s %s %s %s"
#define TEXT_CSERV "Current Server: %s:%i" #define TEXT_CSERV "Current Server: %s:%i"
#define TEXT_CSERVNOT "Current Server: " TEXT_NOTINSERVLIST #define TEXT_CSERVNOT "Current Server: " TEXT_NOTINSERVLIST

View File

@ -125,7 +125,7 @@ char *webread(int s, char *rest, char *line)
return(NULL); return(NULL);
} }
#define NOBO if (dest == &mem[MSGLEN-2]) { write(s,mem,dest-mem); dest = mem; } #define NOBO if (dest == &mem[MSGLEN-2]) { int n; n = write(s,mem,dest-mem); dest = mem; }
void eml_fmt(WebSock *client, char *format) void eml_fmt(WebSock *client, char *format)
{ {
@ -133,6 +133,7 @@ void eml_fmt(WebSock *client, char *format)
char *src,*dest,*org; char *src,*dest,*org;
int out; int out;
int s = client->sock; int s = client->sock;
int n;
org = NULL; org = NULL;
out = TRUE; out = TRUE;
@ -230,8 +231,8 @@ restart:
format++; format++;
} }
if (dest-mem > 0) if (dest-mem > 0)
write(s,mem,dest-mem); n = write(s,mem,dest-mem);
write(s,"\r\n",2); n = write(s,"\r\n",2);
} }
void web_raw(WebSock *client, char *url) void web_raw(WebSock *client, char *url)
@ -240,8 +241,7 @@ void web_raw(WebSock *client, char *url)
char path[MSGLEN]; char path[MSGLEN];
char *src,*dest; char *src,*dest;
ino_t ino; ino_t ino;
int fd; int fd,eml,n;
int eml;
size_t sz; size_t sz;
eml = (matches("*.html",url)) ? TRUE : FALSE; eml = (matches("*.html",url)) ? TRUE : FALSE;
@ -293,7 +293,7 @@ void web_raw(WebSock *client, char *url)
#endif /* DEBUG */ #endif /* DEBUG */
set_mallocdoer(web_raw); set_mallocdoer(web_raw);
src = Calloc(sz+1); src = Calloc(sz+1);
read(fd,src,sz); n = read(fd,src,sz);
if (eml) if (eml)
{ {
to_file(client->sock,"%s\r\n",src); to_file(client->sock,"%s\r\n",src);