summaryrefslogtreecommitdiff
path: root/src/include/gauger.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-06-11 16:04:51 +0200
committerChristian Grothoff <christian@grothoff.org>2015-06-11 16:04:51 +0200
commita560e79a5048ea7b9062e4a1f3b5dce7a03e81c4 (patch)
tree06f010a1023ac19a1640fee75c321e38ffdd2458 /src/include/gauger.h
parent239aaf53d49a6c6f23e060d14d69f6aa135380d7 (diff)
downloadexchange-a560e79a5048ea7b9062e4a1f3b5dce7a03e81c4.tar.gz
exchange-a560e79a5048ea7b9062e4a1f3b5dce7a03e81c4.tar.bz2
exchange-a560e79a5048ea7b9062e4a1f3b5dce7a03e81c4.zip
addig gauger.h to build to avoid FTBFS
Diffstat (limited to 'src/include/gauger.h')
-rw-r--r--src/include/gauger.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/include/gauger.h b/src/include/gauger.h
new file mode 100644
index 00000000..9fa34b9b
--- /dev/null
+++ b/src/include/gauger.h
@@ -0,0 +1,108 @@
+/** ---------------------------------------------------------------------------
+ * This software is in the public domain, furnished "as is", without technical
+ * support, and with no warranty, express or implied, as to its usefulness for
+ * any purpose.
+ *
+ * gauger.h
+ * Interface for C programs to log remotely to a gauger server
+ *
+ * Author: Bartlomiej Polot
+ * -------------------------------------------------------------------------*/
+#ifndef __GAUGER_H__
+#define __GAUGER_H__
+
+#ifndef WINDOWS
+
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/wait.h>
+
+#define GAUGER(category, counter, value, unit)\
+{\
+ const char * __gauger_v[10]; \
+ char __gauger_s[32];\
+ pid_t __gauger_p;\
+ if(!(__gauger_p=fork())){\
+ if(!fork()){\
+ sprintf(__gauger_s,"%Lf", (long double) (value));\
+ __gauger_v[0] = "gauger";\
+ __gauger_v[1] = "-n";\
+ __gauger_v[2] = (char *) counter; \
+ __gauger_v[3] = "-d";\
+ __gauger_v[4] = __gauger_s;\
+ __gauger_v[5] = "-u";\
+ __gauger_v[6] = (char *) unit; \
+ __gauger_v[7] = "-c";\
+ __gauger_v[8] = (char *) category; \
+ __gauger_v[9] = (char *) NULL;\
+ execvp("gauger", (char*const*) __gauger_v); \
+ perror("gauger");\
+ _exit(1);\
+ }else{\
+ _exit(0);\
+ }\
+ }else{\
+ waitpid(__gauger_p,NULL,0);\
+ }\
+}
+
+#define GAUGER_ID(category, counter, value, unit, id)\
+{\
+ char* __gauger_v[12];\
+ char __gauger_s[32];\
+ pid_t __gauger_p;\
+ if(!(__gauger_p=fork())){\
+ if(!fork()){\
+ sprintf(__gauger_s,"%Lf", (long double) (value));\
+ __gauger_v[0] = "gauger";\
+ __gauger_v[1] = "-n";\
+ __gauger_v[2] = (char *) counter; \
+ __gauger_v[3] = "-d";\
+ __gauger_v[4] = __gauger_s;\
+ __gauger_v[5] = "-u";\
+ __gauger_v[6] = (char *) unit; \
+ __gauger_v[7] = "-i";\
+ __gauger_v[8] = id;\
+ __gauger_v[9] = "-c";\
+ __gauger_v[10] = (char *) category; \
+ __gauger_v[11] = (char *) NULL;\
+ execvp("gauger",__gauger_v);\
+ perror("gauger");\
+ _exit(1);\
+ }else{\
+ _exit(0);\
+ }\
+ }else{\
+ waitpid(__gauger_p,NULL,0);\
+ }\
+}
+
+#else /* WINDOWS */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <windef.h>
+
+#define GAUGER(category, counter, value, unit)\
+{\
+ char __gauger_commandline[MAX_PATH];\
+ \
+ snprintf (__gauger_commandline, MAX_PATH, "gauger.py -n \"%s\" -d \"%Lf\" -u \"%s\" -c \"%s\"",\
+ counter, (long double) (value), unit, category);\
+ __gauger_commandline[MAX_PATH - 1] = '\0';\
+ system (__gauger_commandline);\
+}
+
+#define GAUGER_ID(category, counter, value, unit, id)\
+{\
+ char __gauger_commandline[MAX_PATH];\
+ \
+ snprintf (__gauger_commandline, MAX_PATH, "gauger.py -n \"%s\" -d \"%Lf\" -u \"%s\" -i \"%s\" -c \"%s\"",\
+ counter, (long double) (value), unit, id, category);\
+ __gauger_commandline[MAX_PATH - 1] = '\0';\
+ system (__gauger_commandline);\
+}
+
+#endif // WINDOWS
+
+#endif