alternate non-git extra version specifier

This commit is contained in:
joonicks 2018-04-29 15:53:00 +02:00
parent 017f85e1ee
commit fae35e0a28
2 changed files with 45 additions and 3 deletions

View File

@ -510,12 +510,50 @@ void datestamp(void)
t->tm_year + 1900,hourampm[t->tm_hour],t->tm_min,(t->tm_hour <= 11) ? "am" : "pm"); 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) void githash(void)
{ {
int i,fd,verlines,sloc;
#ifdef HAVE_GIT #ifdef HAVE_GIT
system("./lib/git.sh > githash.h"); system("./lib/git.sh > githash.h");
#else #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 #endif
} }

View File

@ -496,6 +496,8 @@ void to_user(const char *target, const char *format, ...)
#endif /* DEBUG */ #endif /* DEBUG */
} }
#endif /* ifndef GENCMD_C */
/* /*
* Read any data waiting on a socket or file descriptor * Read any data waiting on a socket or file descriptor
* and return any complete lines to the caller * and return any complete lines to the caller
@ -522,7 +524,7 @@ char *sockread(int s, char *rest, char *line)
while(*src) while(*src)
*(dst++) = *(src++); *(dst++) = *(src++);
*dst = 0; *dst = 0;
#ifdef DEBUG #if defined(DEBUG) && !defined(GENCMD_C)
debug("(in) {%i} %s\n",s,line); debug("(in) {%i} %s\n",s,line);
#endif /* DEBUG */ #endif /* DEBUG */
return((*line) ? line : NULL); return((*line) ? line : NULL);
@ -583,11 +585,13 @@ void readline(int fd, int (*callback)(char *))
close(fd); close(fd);
#ifdef DEBUG #if defined(DEBUG) && !defined(GENCMD_C)
debug("(readline) done reading lines\n"); debug("(readline) done reading lines\n");
#endif /* DEBUG */ #endif /* DEBUG */
} }
#ifndef GENCMD_C
void remove_ks(KillSock *ks) void remove_ks(KillSock *ks)
{ {
KillSock *ksp; KillSock *ksp;