progress (#18)

* Added: Signal handlers for SIGILL and SIGABRT ifdef DEBUG
 * Added: New command: CRASH, for debugging/development...
 * Changed: configure now defaults to optimizing for code size.
 * Added: configuration option --optimize=speed or --optimize=size
changes to configure #17
This commit is contained in:
joonicks
2018-03-21 22:49:46 +01:00
committed by GitHub
parent cf37c9b728
commit badf9f2771
19 changed files with 541 additions and 218 deletions

View File

@@ -22,6 +22,10 @@
#include "config.h"
#include "structs.h"
char gsockdata[MAXLEN];
#include "socket.c"
/*
These are defined in config.h
@@ -48,8 +52,8 @@
struct
{
int pass;
char *name;
char *func;
const char *name;
const char *func;
ulong flags;
char *cmdarg;
@@ -129,7 +133,7 @@ struct
{ 0, "USERHOST", "do_ircwhois", 40 | CCPW | CARGS },
{ 0, "VOICE", "do_opvoice", 40 | CCPW | CAXS , "v+" },
{ 0, "WALL", "do_wall", 40 | CCPW | CAXS | CARGS | ACCHAN },
{ 0, "WHO", "do_showusers", 40 | CCPW | CAXS | DCC },
{ 0, "WHO", "do_who", 40 | CCPW | CAXS | DCC },
{ 0, "WHOIS", "do_ircwhois", 40 | CCPW | CARGS | DCC | REDIR | LBUF },
#ifdef NOTE
{ 0, "NOTE", "do_note", 40 | CCPW | CARGS },
@@ -242,6 +246,7 @@ struct
{ 0, "SHUTDOWN", "do_shutdown", 100 | CCPW | GAXS | NOPUB | NOCMD },
#ifdef DEBUG
{ 0, "DEBUG", "do_debug", 100 | CCPW | GAXS },
{ 0, "CRASH", "do_crash", 100 | CCPW | GAXS },
#endif /* DEBUG */
#ifdef PYTHON
#ifdef PLEASE_HACK_MY_SHELL
@@ -264,33 +269,31 @@ struct
#define __struct_acces 2
#define __struct_print 1
int main(int argc, char **argv)
void make_mcmd(void)
{
FILE *of;
usercombo combo;
char tmp[100];
char *pt,*tabs;
int i,j,wh;
int pass;
int ct;
int sl;
const char *pt;
char tmp[100],*tabs;
int i,j,wh,pass,ct,sl,fd;
OnMsg v;
unlink("mcmd.h");
fd = open("mcmd.h",O_WRONLY|O_CREAT|O_TRUNC,0644);
pass = __define_strng;
ct = 0;
printf("/""* This file is automatically generated from gencmd.c *""/\n");
printf("#ifndef TEST\n#ifndef MCMD_H\n#define MCMD_H 1\n\n");
to_file(fd,"/""* This file is automatically generated from gencmd.c *""/\n");
to_file(fd,"#ifndef TEST\n#ifndef MCMD_H\n#define MCMD_H 1\n\n");
while(pass)
{
if (pass == __struct_print)
{
printf("LS const OnMsg mcmd[] =\n{\n");
to_file(fd,"LS const OnMsg mcmd[] =\n{\n");
}
if (pass == __struct_acces)
{
printf("LS OnMsg_access acmd[] = \n{\n");
to_file(fd,"LS OnMsg_access acmd[] = \n{\n");
}
for(i=0;pre_mcmd[i].name;i++)
{
@@ -315,17 +318,17 @@ int main(int argc, char **argv)
}
if (pass == __define_strng)
{
//printf("#define S_%s%s\t\"%s\"\n",pt,((strlen(pt) + 2) < 8) ? "\t" : "",pt);
//to_file(fd,"#define S_%s%s\t\"%s\"\n",pt,((strlen(pt) + 2) < 8) ? "\t" : "",pt);
}
if (pass == __define_print)
{
//printf("#define C_%s%s\tmcmd[%i].name\n",pt,((strlen(pt) + 2) < 8) ? "\t" : "",ct);
printf("BEG const char C_%s[]%s\tMDEF(\"%s\");\n",pt,((strlen(pt) + 3) < 8) ? "\t" : "",pt);
//to_file(fd,"#define C_%s%s\tmcmd[%i].name\n",pt,((strlen(pt) + 2) < 8) ? "\t" : "",ct);
to_file(fd,"BEG const char C_%s[]%s\tMDEF(\"%s\");\n",pt,((strlen(pt) + 3) < 8) ? "\t" : "",pt);
ct++;
}
if (pass == __struct_acces)
{
printf("\t%i,\t/""* %s *""/\n",
to_file(fd,"\t%i,\t/""* %s *""/\n",
pre_mcmd[wh].flags & CLEVEL,
pt);
}
@@ -370,7 +373,7 @@ int main(int argc, char **argv)
sl = (sl & ~7) / 8;
tabs += sl;
printf( (pre_mcmd[wh].cmdarg) ? "{ C_%s,%s\t%s,%s%s\t, \"%s\"\t},\n" : "{ C_%s,%s\t%s,%s%s\t},\n",
to_file(fd,(pre_mcmd[wh].cmdarg) ? "{ C_%s,%s\t%s,%s%s\t, \"%s\"\t},\n" : "{ C_%s,%s\t%s,%s%s\t},\n",
pt,
((strlen(pt) + 5) < 8) ? "\t" : "",
pre_mcmd[wh].func,
@@ -387,57 +390,97 @@ int main(int argc, char **argv)
}
if (pass == __define_print)
{
printf("\n#ifdef MAIN_C\n\n");
to_file(fd,"\n#ifdef MAIN_C\n\n");
}
if (pass == __struct_print)
{
printf("{ NULL, }};\n\n");
to_file(fd,"{ NULL, }};\n\n");
}
if (pass == __struct_acces)
{
printf("};\n\n");
to_file(fd,"};\n\n");
}
pass--;
}
printf("#define LOCALHOST_ULONG %lu\n",inet_addr("127.1"));
printf("#else /""* MAIN_C *""/\n\n");
printf("extern OnMsg mcmd[];\n");
printf("extern OnMsg_access acmd[];\n\n");
printf("#endif /""* MAIN_C *""/\n\n");
printf("#endif /""* MCMD_H *""/\n\n");
printf("#endif /""* TEST *""/\n\n");
to_file(fd,"#define LOCALHOST_ULONG %lu\n",inet_addr("127.1"));
to_file(fd,"#else /""* MAIN_C *""/\n\n");
to_file(fd,"extern OnMsg mcmd[];\n");
to_file(fd,"extern OnMsg_access acmd[];\n\n");
to_file(fd,"#endif /""* MAIN_C *""/\n\n");
to_file(fd,"#endif /""* MCMD_H *""/\n\n");
to_file(fd,"#endif /""* TEST *""/\n\n");
close(fd);
exit(0);
}
void make_usercombo(void)
{
usercombo combo;
int fd;
unlink("usercombo.h");
of = fopen("usercombo.h","w");
fd = open("usercombo.h",O_WRONLY|O_CREAT|O_TRUNC,0644);
fprintf(of,"/""* This file is automatically generated from gencmd.c *""/\n");
to_file(fd,"/""* This file is automatically generated from gencmd.c *""/\n");
#ifdef BOTNET
combo.comboflags = 0; combo.x.noshare = 1;
fprintf(of,"#define COMBO_NOSHARE\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_NOSHARE\t0x%x\n",combo.comboflags);
combo.comboflags = 0; combo.x.readonly = 1;
fprintf(of,"#define COMBO_READONLY\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_READONLY\t0x%x\n",combo.comboflags);
#endif /* BOTNET */
#ifdef GREET
combo.comboflags = 0; combo.x.greetfile = 1;
fprintf(of,"#define COMBO_GREETFILE\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_GREETFILE\t0x%x\n",combo.comboflags);
combo.comboflags = 0; combo.x.randline = 1;
fprintf(of,"#define COMBO_RANDLINE\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_RANDLINE\t0x%x\n",combo.comboflags);
#endif /* GREET */
#ifdef BOUNCE
combo.comboflags = 0; combo.x.bounce = 1;
fprintf(of,"#define COMBO_BOUNCE\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_BOUNCE\t0x%x\n",combo.comboflags);
#endif /* BOUNCE */
combo.comboflags = 0; combo.x.echo = 1;
fprintf(of,"#define COMBO_ECHO\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_ECHO\t0x%x\n",combo.comboflags);
combo.comboflags = 0; combo.x.aop = 1;
fprintf(of,"#define COMBO_AOP\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_AOP\t0x%x\n",combo.comboflags);
combo.comboflags = 0; combo.x.avoice = 1;
fprintf(of,"#define COMBO_AVOICE\t0x%x\n",combo.comboflags);
to_file(fd,"#define COMBO_AVOICE\t0x%x\n",combo.comboflags);
close(fd);
exit(0);
}
void test_help(void)
{
char tmp[PATH_MAX];
struct stat st;
int i,r;
for(i=0;pre_mcmd[i].name;i++)
{
sprintf(tmp,"../help/%s",pre_mcmd[i].name);
r = stat(tmp,&st);
if (r == -1 && errno == ENOENT)
to_file(1,"help for %s is missing\n",pre_mcmd[i].name);
}
exit(0);
}
int main(int argc, char **argv)
{
if (argv[1] && strcmp(argv[1],"usercombo.h") == 0)
make_usercombo();
if (argv[1] && strcmp(argv[1],"mcmd.h") == 0)
make_mcmd();
if (argv[1] && strcmp(argv[1],"testhelp") == 0)
test_help();
fclose(of);
return(0);
}