shithub: rgbds

Download patch

ref: b7ca2e2b871e1790b6c13c312b1c19e453e13d6d
parent: be13e051f43fdb2797f91150455fdd9422b06e72
author: Anthony Bentley <[email protected]>
date: Sun Nov 8 14:49:02 EST 2009

rgbfix: add warning function, separate output between stdout and stderr (lmod)

--- a/src/rgbfix/main.c
+++ b/src/rgbfix/main.c
@@ -5,6 +5,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <string.h>
 #include "asmotor.h"
 
@@ -57,10 +58,35 @@
 	exit(0);
 }
 
-void FatalError(char *s)
+void vFatalError(char *s, va_list ap)
 {
-	printf("\n***ERROR: %s\n\n", s);
-	PrintUsage();
+	fprintf(stderr, "*ERROR* : ");
+	vfprintf(stderr, s, ap);
+	fprintf(stderr, "\n");
+}
+
+void FatalError(char *s, ...)
+{
+	va_list ap;
+	va_start (ap, s);
+	vFatalError(s, ap);
+	va_end(ap);
+	exit(5);
+}
+
+void vWarning(char *s, va_list ap)
+{
+	fprintf(stderr, "*WARNING* : ");
+	vfprintf(stderr, s, ap);
+	fprintf(stderr, "\n");
+}
+
+void Warning(char *s, ...)
+{
+	va_list ap;
+	va_start(ap, s);
+	vWarning(s, ap);
+	va_end(ap);
 }
 
 long int FileSize(FILE * f)