ref: 913e9c9e4fe8b169e40b23a19d6f47fd01bbb90e
parent: 2648ee9811cbc3c8f9f4202769b34bd9a52b0d61
author: bentley <[email protected]>
date: Fri Jan 15 11:29:20 EST 2010
rgblib: use errx() for error messages
--- a/src/lib/library.c
+++ b/src/lib/library.c
@@ -5,8 +5,6 @@
#include "lib/types.h"
#include "lib/libwrap.h"
-extern void fatalerror(char *s);
-
SLONG
file_Length(FILE * f)
{
@@ -90,13 +88,13 @@
if (l == NULL) {
l = malloc(sizeof *l);
if (!l)
- fatalerror("Out of memory");
+ errx(5, "Out of memory");
first = l;
} else {
l->pNext = malloc(sizeof *l->pNext);
if (!l->pNext)
- fatalerror("Out of memory");
+ errx(5, "Out of memory");
l = l->pNext;
}
@@ -113,7 +111,7 @@
f);
size -= l->nByteLength;
} else
- fatalerror("Out of memory");
+ errx(5, "Out of memory");
l->pNext = NULL;
}
@@ -149,7 +147,7 @@
return (r);
} else {
fclose(f);
- fatalerror("Not a valid xLib library");
+ errx(5, "Not a valid xLib library");
return (NULL);
}
} else {
@@ -226,7 +224,7 @@
if ((module = lib_Find(lib, filename)) == NULL) {
module = malloc(sizeof *module);
if (!module)
- fatalerror("Out of memory");
+ errx(5, "Out of memory");
module->pNext = lib;
lib = module;
@@ -239,7 +237,7 @@
strcpy(module->tName, truncname);
module->pData = malloc(module->nByteLength);
if (!module->pData)
- fatalerror("Out of memory");
+ errx(5, "Out of memory");
fread(module->pData, sizeof(UBYTE), module->nByteLength, f);
@@ -279,7 +277,7 @@
}
if (!found)
- fatalerror("Module not found");
+ errx(5, "Module not found");
else
printf("Module '%s' deleted from library\n", truncname);
--- a/src/lib/main.c
+++ b/src/lib/main.c
@@ -1,7 +1,8 @@
+#include <ctype.h>
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
#include "asmotor.h"
@@ -14,17 +15,6 @@
#endif
/*
- * Print out an errormessage
- *
- */
-
-void
-fatalerror(char *s)
-{
- fprintf(stderr, "*ERROR* : %s\n", s);
- exit(5);
-}
-/*
* Print the usagescreen
*
*/
@@ -115,10 +105,10 @@
("Extracted module '%s'\n",
argv[argn]);
} else
- fatalerror
- ("Unable to write module");
+ errx(5,
+ "Unable to write module");
} else
- fatalerror("Module not found");
+ errx(5, "Module not found");
argn += 1;
argc -= 1;
@@ -126,12 +116,12 @@
lib_Free(lib);
break;
default:
- fatalerror("Invalid command");
+ errx(5, "Invalid command");
break;
}
} else {
- fatalerror("Invalid command");
+ errx(5, "Invalid command");
}
} else
PrintUsage();