diff --git a/src/gencmd.c b/src/gencmd.c index 0e86544..4aaa47e 100644 --- a/src/gencmd.c +++ b/src/gencmd.c @@ -510,12 +510,50 @@ void datestamp(void) t->tm_year + 1900,hourampm[t->tm_hour],t->tm_min,(t->tm_hour <= 11) ? "am" : "pm"); } +#ifndef HAVE_GIT + +const char *srcfile[] = { "../configure", "../Makefile", "Makefile.in", "alias.c", "auth.c", "bounce.c", //"calc.c", + "channel.c", "config.h", "config.h.in", "core.c", "ctcp.c", "debug.c", "defines.h", "dns.c", "function.c", + "gencmd.c", "global.h", "greet.c", "h.h", "help.c", "hostinfo.c", "io.c", "irc.c", "lib/string.c", "main.c", + "net.c", "note.c", "ons.c", "parse.c", "partyline.c", "perl.c", "prot.c", "python.c", "reset.c", "seen.c", + "settings.h", "shit.c", "spy.c", "structs.h", "tcl.c", "text.h", "toybox.c", "uptime.c", "usage.h", "user.c", + "vars.c", "web.c", NULL }; + +int linecount; + +int countcallback(char *line) +{ + linecount++; + return(FALSE); +} + +int countlines(const char *filename) +{ + int fd; + + linecount = 0; + if ((fd = open(filename,O_RDONLY)) < 0) + return(0); + readline(fd,&countcallback); /* readline closes fd */ + return(linecount); +} + +#endif + void githash(void) { + int i,fd,verlines,sloc; + #ifdef HAVE_GIT system("./lib/git.sh > githash.h"); #else - system("echo '#define GITHASH \"\"' > githash.h"); + sloc = verlines = countlines("../VERSIONS"); + for(i=0;srcfile[i];i++) + sloc += countlines(srcfile[i]); + + fd = open("githash.h",O_WRONLY|O_CREAT|O_TRUNC,0644); + to_file(fd,"#define GITHASH \" (src:%i/%i)\"\n",verlines,sloc); + close(fd); #endif } diff --git a/src/io.c b/src/io.c index 82bfa49..55983f9 100644 --- a/src/io.c +++ b/src/io.c @@ -496,6 +496,8 @@ void to_user(const char *target, const char *format, ...) #endif /* DEBUG */ } +#endif /* ifndef GENCMD_C */ + /* * Read any data waiting on a socket or file descriptor * and return any complete lines to the caller @@ -522,7 +524,7 @@ char *sockread(int s, char *rest, char *line) while(*src) *(dst++) = *(src++); *dst = 0; -#ifdef DEBUG +#if defined(DEBUG) && !defined(GENCMD_C) debug("(in) {%i} %s\n",s,line); #endif /* DEBUG */ return((*line) ? line : NULL); @@ -583,11 +585,13 @@ void readline(int fd, int (*callback)(char *)) close(fd); -#ifdef DEBUG +#if defined(DEBUG) && !defined(GENCMD_C) debug("(readline) done reading lines\n"); #endif /* DEBUG */ } +#ifndef GENCMD_C + void remove_ks(KillSock *ks) { KillSock *ksp;