[Tux4kids-tuxtype-dev] portable error()?

Jeremy C. Reed reed at reedmedia.net
Fri Feb 1 01:11:02 UTC 2008


src/tuxmathadmin.c uses "error" which is available with glibc and error.h.

This is not on some other platforms.

The following was a quick hack based on some GPL code from vpnc.

Probably the correct way is to detect and include the code conditionally 
as needed.


--- tuxmath_w_fonts-1.6.0/src/tuxmathadmin.c.orig	2007-12-12 05:11:52.000000000 -0600
+++ tuxmath_w_fonts-1.6.0/src/tuxmathadmin.c	2008-01-31 19:06:35.000000000 -0600
@@ -753,3 +753,23 @@
   }
 }
 
+
+#include <stdarg.h>
+void error(int status, int errornum, const char *fmt, ...)
+{
+        char *buf2;
+        va_list ap;
+
+        va_start(ap, fmt);
+        vasprintf(&buf2, fmt, ap);
+        va_end(ap);
+        fprintf(stderr, "%s", buf2);
+        if (errornum)
+                fprintf(stderr, ": %s\n", strerror(errornum));
+        else
+                fprintf(stderr, "\n");
+        free(buf2);
+
+        if (status)
+                exit(status);
+}

  Jeremy C. Reed




More information about the Tux4kids-tuxtype-dev mailing list