Add request parsing helper, add TIMEVAL_* macros, move timestamps to identify module
[matches/MCTX3420.git] / server / common.h
index eba4902..c2edd3d 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * @file common.h
- * @purpose Common header includes
+ * @brief Common header includes
  */
 
 #ifndef _COMMON_H
@@ -10,6 +10,9 @@
 #define _BSD_SOURCE
 #define _XOPEN_SOURCE 600
 
+/** The current API version **/
+#define API_VERSION 0
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdbool.h>
@@ -25,4 +28,9 @@
 #include "fastcgi.h"
 #include "thread.h"
 
+/**Converts a timeval to a double**/
+#define TIMEVAL_TO_DOUBLE(tv) ((tv).tv_sec + 1e-6 * ((tv).tv_usec))
+/**Takes the tv1-tv2 between two timevals and returns the result as a double*/
+#define TIMEVAL_DIFF(tv1, tv2) ((tv1).tv_sec - (tv2).tv_sec + 1e-6 * ((tv1).tv_usec - (tv2).tv_usec))
+
 #endif //_COMMON_H

UCC git Repository :: git.ucc.asn.au