Quellcode durchsuchen

MHD_get_version: support extraction version number from MHD_VERSION if PACKAGE_VERSION is not defined

Evgeny Grin (Karlson2k) vor 11 Jahren
Ursprung
Commit
2ee782685c
1 geänderte Dateien mit 14 neuen und 0 gelöschten Zeilen
  1. 14 0
      src/microhttpd/daemon.c

+ 14 - 0
src/microhttpd/daemon.c

@@ -4421,7 +4421,21 @@ MHD_set_panic_func (MHD_PanicCallback cb, void *cls)
 const char *
 MHD_get_version (void)
 {
+#ifdef PACKAGE_VERSION
   return PACKAGE_VERSION;
+#else  /* !PACKAGE_VERSION */
+  static char ver[12] = "\0\0\0\0\0\0\0\0\0\0\0";
+  if (0 == ver[0])
+  {
+    int res = MHD_snprintf_(ver, sizeof(ver), "%x.%x.%x",
+                            (((int)MHD_VERSION >> 24) & 0xFF),
+                            (((int)MHD_VERSION >> 16) & 0xFF),
+                            (((int)MHD_VERSION >> 8) & 0xFF));
+    if (0 >= res || sizeof(ver) <= res)
+      return "0.0.0"; /* Can't return real version*/
+  }
+  return ver;
+#endif /* !PACKAGE_VERSION */
 }