minor related updates: warnings, hostinfo, calc, debug, ...

This commit is contained in:
joonicks
2025-09-21 16:26:51 +02:00
parent c26b51deda
commit 746c93f367
7 changed files with 48 additions and 12 deletions

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-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 */

View File

@@ -336,7 +336,7 @@ void select_monitor() __page(CORE_SEG);
void process_monitor() __page(CORE_SEG); 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);
@@ -419,7 +419,7 @@ 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) __page(CORE_SEG); LS void doit(void) __page(CORE_SEG);
LS int main(int argc, char **argv, char **envp) __page(CFG1_SEG); LS int main(int argc, char **argv, char **envp) __page(INIT_SEG);
/* net.c */ /* net.c */

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

@@ -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

@@ -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