convert-conf: ${CONVERT_CONF_OBJS}
${PURIFY} ${CC} ${CONVERT_CONF_OBJS} ${LDFLAGS} -o convert-conf
-#
-# Make sure the anti hack checksums get included when things change
-# bleah
-#
-# Yeah, "bleah" is right. These checksums don't cover even a fraction of
-# the "important" .c files...but are useful to determine whether someone
-# actually is running the version they claim to be running or not. There
-# must be a better solution...perhaps sum all of the .c files and include
-# only that one sum?
-#
-version.c: ../include/patchlist.h version.c.SH umkpasswd \
- ../include/version.h ../include/patchlevel.h ${SRC}
+.PHONY: version.c
+version.c: version.c.SH umkpasswd
${SHELL} ${srcdir}/version.c.SH ${top_srcdir}
../include/patchlist.h:
@echo "Please remove the contents of ${DPATH} manually"
clean:
- ${RM} -f *.o *.bak ircd version.c umkpasswd convert-conf chattr.tab.c table_gen y.tab.* lex.yy.*
+ ${RM} -f *.o *.bak ircd umkpasswd convert-conf chattr.tab.c table_gen y.tab.* lex.yy.*
distclean: clean
${RM} -f Makefile stamp-m
*/
#include "config.h"
#include <unistd.h>
+#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
return 0;
}
-char *basename_into(char *tmp, char *target)
-{
- unsigned int len, ii;
-
- len = strlen(tmp);
- for (ii = len; ii > 0; )
- if (tmp[--ii] == '/')
- break;
- if (ii < len - 1)
- return tmp + ii + (tmp[ii] == '/');
- else if (tmp[ii] != '/')
- return tmp;
- else if (ii == 0)
- return tmp;
- else
- {
- while (ii > 0)
- if (tmp[--ii] == '/')
- break;
- if (tmp[ii] == '/')
- ii++;
- for (len = 0; tmp[ii] != '/'; )
- target[len++] = tmp[ii++];
- target[len] = '\0';
- return target;
- }
-}
-
void sum(char* tmp)
{
+char* str;
FILE* file;
MD5_CTX context;
int len;
-unsigned char buffer[1024], digest[16];
+unsigned char buffer[1024], digest[16], vstr[32];
+vstr[0] = '\0';
+ str = tmp + strlen(tmp);
+ while (str[-1] == '\r' || str[-1] == '\n') *--str = '\0';
if (NULL == (file = fopen(tmp, "r")))
+ {
+ fprintf(stderr, "unable to open %s: %s", tmp, strerror(errno));
exit(0);
+ }
MD5Init(&context);
- while ((len = fread (buffer, 1, 1024, file)))
+ while ((fgets((char*)buffer, sizeof(buffer), file)) != NULL)
+ {
+ MD5Update(&context, buffer, strlen(buffer));
+ str = strstr((char*)buffer, "$Id: ");
+ if (str != NULL)
+ {
+ for (str += 5; !isspace(*str); ++str) {}
+ while (isspace(*++str)) {}
+ for (len = 0; !isspace(str[len]); ++len) vstr[len] = str[len];
+ vstr[len] = '\0';
+ break;
+ }
+ }
+ while ((len = fread (buffer, 1, sizeof(buffer), file)))
MD5Update(&context, buffer, len);
MD5Final(digest, &context);
fclose(file);
- printf("%s: ", basename_into(tmp, (char*)buffer));
+ str = strrchr(tmp, '/');
+ printf(" \"[ %s: ", str ? (str + 1) : tmp);
for (len = 0; len < 16; len++)
printf ("%02x", digest[len]);
- printf("\n");
- exit(0);
+ printf(" %s ]\",\n", vstr);
}
/* dump the loaded mechs list */
char* parse_arguments(int argc, char **argv)
{
int len = 0, c = 0;
-const char* options = "a:d:lm:u:y:5:";
+const char* options = "a:d:lm:u:y:5";
umkpasswd_conf = (umkpasswd_conf_t*)MyMalloc(sizeof(umkpasswd_conf_t));
switch (c)
{
case '5':
- sum(optarg);
- break;
+ {
+ char t1[1024];
+ while (fgets(t1, sizeof(t1), stdin)) sum(t1);
+ }
+ exit(0);
case 'y':
umkpasswd_conf->operclass = atoi(optarg);
"Sources:",
!SUB!THIS!
-for file in ${srcdir}/ircd/*.[cly] ${srcdir}/ircd/version.c.SH ; do
- base=`basename $file`
- if [ $base != version.c -a $base != y.tab.c -a $base != lex.yy.c -a \
- $base != chattr.tab.c ] ; then
- vers=`grep '$Id' $file | sed -e 's/.*\$Id\://' -e 's/\$[^$]*//' | \
- awk '{ print $2; exit; }'`
- echo " \"[" `./umkpasswd -5 $file` " $vers ]\"," >> version.c
- fi
-done
+( for file in ${srcdir}/ircd/*.[cly] ${srcdir}/ircd/version.c.SH ; do
+ case `basename $file` in
+ ( version.c | y.tab.c | lex.yy.c | chattr.tab.c ) ;;
+ ( * ) echo $file ;;
+ esac done ) | ./umkpasswd -5 >> version.c
echo " \"\"," >> version.c
echo " \"Headers:\"," >> version.c
-for file in ${srcdir}/include/*.h ; do
- vers=`grep '$Id' $file | sed -e 's/.*\$Id\://' -e 's/\$[^$]*//' | \
- awk '{ print $2; exit; }'`
- echo " \"[" `./umkpasswd -5 $file` " $vers ]\"," >> version.c
-done
+( for file in ${srcdir}/include/*.h ; do echo $file ; done ) | ./umkpasswd -5 >> version.c
/bin/cat >>version.c <<!SUB!THIS!
0,