mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-29 14:27:50 +00:00
reran indent (whitespace changes)
Merging lai's source with this one is very irritating because they have different indentation styles. I couldn't find what profile vegard used for his version, so I used these flags (which should bring the source close to KNF): -bap -br -ce -ci4 -cli0 -d0 -di0 -i8 -ip -l79 -nbc -ncdb -ndj -ei -nfc1 -nlp -npcs -psl -sc -sob
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
|
||||
extern void fatalerror(char *s);
|
||||
|
||||
SLONG file_Length(FILE * f)
|
||||
SLONG
|
||||
file_Length(FILE * f)
|
||||
{
|
||||
ULONG r, p;
|
||||
|
||||
@@ -19,7 +20,8 @@ SLONG file_Length(FILE * f)
|
||||
return (r);
|
||||
}
|
||||
|
||||
SLONG file_ReadASCIIz(char *b, FILE * f)
|
||||
SLONG
|
||||
file_ReadASCIIz(char *b, FILE * f)
|
||||
{
|
||||
SLONG r = 0;
|
||||
|
||||
@@ -29,7 +31,8 @@ SLONG file_ReadASCIIz(char *b, FILE * f)
|
||||
return (r + 1);
|
||||
}
|
||||
|
||||
void file_WriteASCIIz(char *b, FILE * f)
|
||||
void
|
||||
file_WriteASCIIz(char *b, FILE * f)
|
||||
{
|
||||
while (*b)
|
||||
fputc(*b++, f);
|
||||
@@ -37,7 +40,8 @@ void file_WriteASCIIz(char *b, FILE * f)
|
||||
fputc(0, f);
|
||||
}
|
||||
|
||||
UWORD file_ReadWord(FILE * f)
|
||||
UWORD
|
||||
file_ReadWord(FILE * f)
|
||||
{
|
||||
UWORD r;
|
||||
|
||||
@@ -47,13 +51,15 @@ UWORD file_ReadWord(FILE * f)
|
||||
return (r);
|
||||
}
|
||||
|
||||
void file_WriteWord(UWORD w, FILE * f)
|
||||
void
|
||||
file_WriteWord(UWORD w, FILE * f)
|
||||
{
|
||||
fputc(w, f);
|
||||
fputc(w >> 8, f);
|
||||
}
|
||||
|
||||
ULONG file_ReadLong(FILE * f)
|
||||
ULONG
|
||||
file_ReadLong(FILE * f)
|
||||
{
|
||||
ULONG r;
|
||||
|
||||
@@ -65,7 +71,8 @@ ULONG file_ReadLong(FILE * f)
|
||||
return (r);
|
||||
}
|
||||
|
||||
void file_WriteLong(UWORD w, FILE * f)
|
||||
void
|
||||
file_WriteLong(UWORD w, FILE * f)
|
||||
{
|
||||
fputc(w, f);
|
||||
fputc(w >> 8, f);
|
||||
@@ -73,7 +80,8 @@ void file_WriteLong(UWORD w, FILE * f)
|
||||
fputc(w >> 24, f);
|
||||
}
|
||||
|
||||
sLibrary *lib_ReadLib0(FILE * f, SLONG size)
|
||||
sLibrary *
|
||||
lib_ReadLib0(FILE * f, SLONG size)
|
||||
{
|
||||
if (size) {
|
||||
sLibrary *l = NULL, *first = NULL;
|
||||
@@ -102,7 +110,7 @@ sLibrary *lib_ReadLib0(FILE * f, SLONG size)
|
||||
size -= 4;
|
||||
if ((l->pData = malloc(l->nByteLength))) {
|
||||
fread(l->pData, sizeof(UBYTE), l->nByteLength,
|
||||
f);
|
||||
f);
|
||||
size -= l->nByteLength;
|
||||
} else
|
||||
fatalerror("Out of memory");
|
||||
@@ -111,11 +119,11 @@ sLibrary *lib_ReadLib0(FILE * f, SLONG size)
|
||||
}
|
||||
return (first);
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
sLibrary *lib_Read(char *filename)
|
||||
sLibrary *
|
||||
lib_Read(char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
@@ -128,7 +136,6 @@ sLibrary *lib_Read(char *filename)
|
||||
fclose(f);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
fread(ID, sizeof(char), 4, f);
|
||||
ID[4] = 0;
|
||||
size -= 4;
|
||||
@@ -148,12 +155,13 @@ sLibrary *lib_Read(char *filename)
|
||||
} else {
|
||||
printf
|
||||
("Library '%s' not found, it will be created if necessary\n",
|
||||
filename);
|
||||
filename);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
BBOOL lib_Write(sLibrary * lib, char *filename)
|
||||
BBOOL
|
||||
lib_Write(sLibrary * lib, char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
@@ -172,11 +180,11 @@ BBOOL lib_Write(sLibrary * lib, char *filename)
|
||||
printf("Library '%s' closed\n", filename);
|
||||
return (1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void TruncateFileName(char *dest, char *src)
|
||||
void
|
||||
TruncateFileName(char *dest, char *src)
|
||||
{
|
||||
SLONG l;
|
||||
|
||||
@@ -187,7 +195,8 @@ void TruncateFileName(char *dest, char *src)
|
||||
strcpy(dest, &src[l + 1]);
|
||||
}
|
||||
|
||||
sLibrary *lib_Find(sLibrary * lib, char *filename)
|
||||
sLibrary *
|
||||
lib_Find(sLibrary * lib, char *filename)
|
||||
{
|
||||
char truncname[MAXNAMELENGTH];
|
||||
|
||||
@@ -203,7 +212,8 @@ sLibrary *lib_Find(sLibrary * lib, char *filename)
|
||||
return (lib);
|
||||
}
|
||||
|
||||
sLibrary *lib_AddReplace(sLibrary * lib, char *filename)
|
||||
sLibrary *
|
||||
lib_AddReplace(sLibrary * lib, char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
@@ -237,11 +247,11 @@ sLibrary *lib_AddReplace(sLibrary * lib, char *filename)
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
return (lib);
|
||||
}
|
||||
|
||||
sLibrary *lib_DeleteModule(sLibrary * lib, char *filename)
|
||||
sLibrary *
|
||||
lib_DeleteModule(sLibrary * lib, char *filename)
|
||||
{
|
||||
char truncname[MAXNAMELENGTH];
|
||||
sLibrary **pp, **first;
|
||||
@@ -276,7 +286,8 @@ sLibrary *lib_DeleteModule(sLibrary * lib, char *filename)
|
||||
return (*first);
|
||||
}
|
||||
|
||||
void lib_Free(sLibrary * lib)
|
||||
void
|
||||
lib_Free(sLibrary * lib)
|
||||
{
|
||||
while (lib) {
|
||||
sLibrary *l;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "lib/types.h"
|
||||
#include "lib/library.h"
|
||||
|
||||
// Quick and dirty...but it works
|
||||
// Quick and dirty...but it works
|
||||
#ifdef __GNUC__
|
||||
#define strcmpi strcasecmp
|
||||
#endif
|
||||
@@ -18,34 +18,35 @@
|
||||
*
|
||||
*/
|
||||
|
||||
void fatalerror(char *s)
|
||||
void
|
||||
fatalerror(char *s)
|
||||
{
|
||||
fprintf(stderr,"*ERROR* : %s\n", s);
|
||||
fprintf(stderr, "*ERROR* : %s\n", s);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the usagescreen
|
||||
*
|
||||
*/
|
||||
|
||||
void PrintUsage(void)
|
||||
void
|
||||
PrintUsage(void)
|
||||
{
|
||||
printf("xLib v" LIB_VERSION " (part of ASMotor " ASMOTOR_VERSION ")\n\n"
|
||||
"Usage: xlib library command [module1 module2 ... modulen]\n"
|
||||
"Commands:\n\ta\tAdd/replace modules to library\n"
|
||||
"\td\tDelete modules from library\n"
|
||||
"\tl\tList library contents\n"
|
||||
"\tx\tExtract modules from library\n");
|
||||
"Usage: xlib library command [module1 module2 ... modulen]\n"
|
||||
"Commands:\n\ta\tAdd/replace modules to library\n"
|
||||
"\td\tDelete modules from library\n"
|
||||
"\tl\tList library contents\n"
|
||||
"\tx\tExtract modules from library\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The main routine
|
||||
*
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
SLONG argn = 0;
|
||||
char *libname;
|
||||
@@ -90,8 +91,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
while (l) {
|
||||
printf("%10ld %s\n",
|
||||
l->nByteLength,
|
||||
l->tName);
|
||||
l->nByteLength,
|
||||
l->tName);
|
||||
l = l->pNext;
|
||||
}
|
||||
}
|
||||
@@ -106,13 +107,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
if ((f = fopen(argv[argn], "wb"))) {
|
||||
fwrite(l->pData,
|
||||
sizeof(UBYTE),
|
||||
l->nByteLength,
|
||||
f);
|
||||
sizeof(UBYTE),
|
||||
l->nByteLength,
|
||||
f);
|
||||
fclose(f);
|
||||
printf
|
||||
("Extracted module '%s'\n",
|
||||
argv[argn]);
|
||||
argv[argn]);
|
||||
} else
|
||||
fatalerror
|
||||
("Unable to write module");
|
||||
|
||||
Reference in New Issue
Block a user