added some code & compiler information to cmd_netinfo
authorpk910 <philipp@zoelle1.de>
Fri, 9 Sep 2011 14:15:51 +0000 (16:15 +0200)
committerpk910 <philipp@zoelle1.de>
Fri, 9 Sep 2011 14:26:47 +0000 (16:26 +0200)
.gitignore
Makefile
bot_NeonServ.c
cmd_neonserv_netinfo.c
main.h
version.h [new file with mode: 0644]
version.sh [new file with mode: 0644]

index 299bb98e503bd7220af1d7f2cf3f1c0809ac7b75..57678a92d860d7e34d790d22e17a06c47352293e 100644 (file)
@@ -1 +1,2 @@
-config.h
\ No newline at end of file
+config.h
+version.c
\ No newline at end of file
index 0f5bdbda87af0e69bde65bc4113a48ad1461d3d3..99a2c5058300e74bf5ceed249e3b9b29a24c0001 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,8 @@ LIBS=-I. -I/usr/include/mysql
 LINK=-lmysqlclient
 
 all:
+       ./version.sh
+       gcc -g -O2 ${LIBS} -c version.c -o version.o ${CFLAGS}
        gcc -g -O2 ${LIBS} -c IRCEvents.c -o IRCEvents.o ${CFLAGS}
        gcc -g -O2 ${LIBS} -c main.c -o main.o ${CFLAGS}
        gcc -g -O2 ${LIBS} -c ChanNode.c -o ChanNode.o ${CFLAGS}
index bb832f76ae0562e63bf953140e79fb2d6f857c5d..27c9d6c16683a3ac0978c910f7af0a5079cdb9f0 100644 (file)
@@ -14,6 +14,7 @@
 #include "DBHelper.h"
 #include "tools.h"
 #include "timeq.h"
+#include "version.h"
 
 #define BOTID 1
 
@@ -138,6 +139,12 @@ static const struct default_language_entry msgtab[] = {
     {"NS_NETINFO_CHANNEL", "  Channel:"},
     {"NS_NETINFO_USER", "  User:"},
     {"NS_NETINFO_CHANUSER", "  Channel-User:"},
+    {"NS_NETINFO_VERSION", "Version:"},
+    {"NS_NETINFO_CODE", "Code:"},
+    {"NS_NETINFO_CODE_VALUE", "%s lines c code (view it at http://git.pk910.de/?p=NeonServV5.git;a=summary)"},
+    {"NS_NETINFO_COMPILER", "Compiler:"},
+    {"NS_NETINFO_COMPILER_VALUE", "%s  (%s)"},
+    
     {NULL, NULL}
 };
 
index a8aece74f697091490a63391fedb7f673486d75b..d7b1b7fe55c62aeaeb13955cb94b68fd52f288c0 100644 (file)
@@ -7,7 +7,7 @@ static CMD_BIND(neonserv_cmd_netinfo) {
     reply(getTextBot(), user, "NS_NETINFO_HEADER");
     char tmp[MAXLEN];
     struct Table *table;
-    table = table_init(2, 7, 0);
+    table = table_init(2, 10, 0);
     char *content[2];
     
     content[0] = get_language_string(user, "NS_NETINFO_UPTIME");
@@ -62,6 +62,22 @@ static CMD_BIND(neonserv_cmd_netinfo) {
     content[1] = tmp;
     table_add(table, content);
     
+    if(strcmp(revision, ""))
+        sprintf(tmp, "%s  (%s)", NEONSERV_VERSION, revision);
+    else 
+        strcpy(tmp, NEONSERV_VERSION);
+    content[0] = get_language_string(user, "NS_NETINFO_VERSION");
+    content[1] = tmp;
+    table_add(table, content);
+    
+    content[0] = get_language_string(user, "NS_NETINFO_COMPILER");
+    content[1] = build_language_string(user, tmp, "NS_NETINFO_COMPILER_VALUE", COMPILER, creation);
+    table_add(table, content);
+    
+    content[0] = get_language_string(user, "NS_NETINFO_CODE");
+    content[1] = build_language_string(user, tmp, "NS_NETINFO_CODE_VALUE", codelines);
+    table_add(table, content);
+    
     char **table_lines = table_end(table);
     int i;
     for(i = 0; i < table->entrys; i++) {
diff --git a/main.h b/main.h
index bf72d283d5dd345a76771d234ba4045f5ec60a5e..71b98db1beb5f2795212420e43155b649dc91461 100644 (file)
--- a/main.h
+++ b/main.h
@@ -1,6 +1,8 @@
 #ifndef _main_h
 #define _main_h
 
+#define NEONSERV_VERSION "5.0.1-dev"
+
 #include "config.h"
 
 #include <stdio.h>
 #define UNUSED_ARG(ARG) ARG
 #endif
 
+#define STRINGIFY_(x) #x
+#define STRINGIFY(x) STRINGIFY_(x)
+#if defined(__GNUC__)
+#if defined(__GNUC_PATCHLEVEL__)
+#define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__) "." STRINGIFY(__GNUC_PATCHLEVEL__)
+#else
+#define COMPILER "GCC" " " STRINGIFY(__GNUC__) "." STRINGIFY(__GNUC_MINOR__)
+#endif
+#elif defined (__IMAGECRAFT__)
+#define COMPILER "ICCAVR"
+#else
+#define COMPILER "Unknown"
+#endif
+
 #define SOCKET_SELECT_TIME 2
 
 #define NICKLEN         30
diff --git a/version.h b/version.h
new file mode 100644 (file)
index 0000000..06f4b0a
--- /dev/null
+++ b/version.h
@@ -0,0 +1,11 @@
+#ifndef _version_h
+#define _version_h
+
+#include "main.h"
+
+extern const char *compilation;
+extern const char *creation;
+extern const char *revision;
+extern const char *codelines;
+
+#endif
\ No newline at end of file
diff --git a/version.sh b/version.sh
new file mode 100644 (file)
index 0000000..17f2382
--- /dev/null
@@ -0,0 +1,47 @@
+#! /bin/sh
+echo "Extracting version.c ..."
+
+if test -r version.c
+then
+   compilation=`sed -n 's/^const char \*compilation = \"\(.*\)\";/\1/p' < version.c`
+   if test ! "$compilation" ; then compilation=0; fi
+else
+   compilation=0
+fi
+
+compilation=`expr $compilation + 1`
+
+creation=`date | \
+awk '{if (NF == 6) \
+        { print $1 " " $2 " " $3 " " $6 " at " $4 " " $5 } \
+else \
+        { print $1 " " $2 " " $3 " " $7 " at " $4 " " $5 " " $6 }}'`
+
+codelines=`find . -type f -regex '\./.*\.h' -or -regex '\./.*\.c' |xargs cat|wc -l`
+
+svn_revision=`svn info | grep Revision | grep -o -E '[0-9]+'`
+if test "x$svn_revision" = "x" ; then
+  svn_revision=`git log -n 1 --pretty="format:%h"`
+  if test "x$svn_revision" = "x" ; then
+    svn_revision="0"
+  else
+    git_commitcount=`git rev-list --all | wc -l | sed "s/[ \t]//g"`
+    svn_revision="git-$git_commitcount-$svn_revision"
+  fi
+else
+  svn_revision="svn-$svn_revision"
+fi
+
+
+/bin/cat >version.c <<!SUB!THIS!
+//Auto generated file!
+
+#include "version.h"
+
+const char *compilation = "$compilation";
+const char *creation = "$creation";
+const char *revision = "$svn_revision";
+const char *codelines = "$codelines";
+
+!SUB!THIS!
+