rgblib: use errx() for error messages

This commit is contained in:
bentley
2010-01-15 16:29:20 -07:00
parent 2648ee9811
commit 913e9c9e4f
2 changed files with 14 additions and 26 deletions

View File

@@ -5,8 +5,6 @@
#include "lib/types.h" #include "lib/types.h"
#include "lib/libwrap.h" #include "lib/libwrap.h"
extern void fatalerror(char *s);
SLONG SLONG
file_Length(FILE * f) file_Length(FILE * f)
{ {
@@ -90,13 +88,13 @@ lib_ReadLib0(FILE * f, SLONG size)
if (l == NULL) { if (l == NULL) {
l = malloc(sizeof *l); l = malloc(sizeof *l);
if (!l) if (!l)
fatalerror("Out of memory"); errx(5, "Out of memory");
first = l; first = l;
} else { } else {
l->pNext = malloc(sizeof *l->pNext); l->pNext = malloc(sizeof *l->pNext);
if (!l->pNext) if (!l->pNext)
fatalerror("Out of memory"); errx(5, "Out of memory");
l = l->pNext; l = l->pNext;
} }
@@ -113,7 +111,7 @@ lib_ReadLib0(FILE * f, SLONG size)
f); f);
size -= l->nByteLength; size -= l->nByteLength;
} else } else
fatalerror("Out of memory"); errx(5, "Out of memory");
l->pNext = NULL; l->pNext = NULL;
} }
@@ -149,7 +147,7 @@ lib_Read(char *filename)
return (r); return (r);
} else { } else {
fclose(f); fclose(f);
fatalerror("Not a valid xLib library"); errx(5, "Not a valid xLib library");
return (NULL); return (NULL);
} }
} else { } else {
@@ -226,7 +224,7 @@ lib_AddReplace(sLibrary * lib, char *filename)
if ((module = lib_Find(lib, filename)) == NULL) { if ((module = lib_Find(lib, filename)) == NULL) {
module = malloc(sizeof *module); module = malloc(sizeof *module);
if (!module) if (!module)
fatalerror("Out of memory"); errx(5, "Out of memory");
module->pNext = lib; module->pNext = lib;
lib = module; lib = module;
@@ -239,7 +237,7 @@ lib_AddReplace(sLibrary * lib, char *filename)
strcpy(module->tName, truncname); strcpy(module->tName, truncname);
module->pData = malloc(module->nByteLength); module->pData = malloc(module->nByteLength);
if (!module->pData) if (!module->pData)
fatalerror("Out of memory"); errx(5, "Out of memory");
fread(module->pData, sizeof(UBYTE), module->nByteLength, f); fread(module->pData, sizeof(UBYTE), module->nByteLength, f);
@@ -279,7 +277,7 @@ lib_DeleteModule(sLibrary * lib, char *filename)
} }
if (!found) if (!found)
fatalerror("Module not found"); errx(5, "Module not found");
else else
printf("Module '%s' deleted from library\n", truncname); printf("Module '%s' deleted from library\n", truncname);

View File

@@ -1,7 +1,8 @@
#include <ctype.h>
#include <err.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h>
#include "asmotor.h" #include "asmotor.h"
@@ -13,17 +14,6 @@
#define strcmpi strcasecmp #define strcmpi strcasecmp
#endif #endif
/*
* Print out an errormessage
*
*/
void
fatalerror(char *s)
{
fprintf(stderr, "*ERROR* : %s\n", s);
exit(5);
}
/* /*
* Print the usagescreen * Print the usagescreen
* *
@@ -115,10 +105,10 @@ main(int argc, char *argv[])
("Extracted module '%s'\n", ("Extracted module '%s'\n",
argv[argn]); argv[argn]);
} else } else
fatalerror errx(5,
("Unable to write module"); "Unable to write module");
} else } else
fatalerror("Module not found"); errx(5, "Module not found");
argn += 1; argn += 1;
argc -= 1; argc -= 1;
@@ -126,12 +116,12 @@ main(int argc, char *argv[])
lib_Free(lib); lib_Free(lib);
break; break;
default: default:
fatalerror("Invalid command"); errx(5, "Invalid command");
break; break;
} }
} else { } else {
fatalerror("Invalid command"); errx(5, "Invalid command");
} }
} else } else
PrintUsage(); PrintUsage();