/***********************************************************
* Artsoft Retro-Game Library *
*----------------------------------------------------------*
-* (c) 1994-2000 Artsoft Entertainment *
+* (c) 1994-2001 Artsoft Entertainment *
* Holger Schemel *
* Detmolder Strasse 189 *
* 33604 Bielefeld *
" -l, --level directory alternative level directory\n"
" -s, --serveronly only start network server\n"
" -n, --network network multiplayer game\n"
- " -v, --verbose verbose mode\n",
+ " -v, --verbose verbose mode\n"
+ " --debug display debugging information\n",
program.command_basename);
exit(0);
}
{
char *process_name = "";
FILE *error = stderr;
+ char *newline = "\n";
/* display warnings only when running in verbose mode */
if (mode & ERR_WARN && !options.verbose)
return;
#if !defined(PLATFORM_UNIX)
+ newline = "\r\n";
+
if ((error = openErrorFile()) == NULL)
{
- printf("Cannot write to error output file!\n");
+ printf("Cannot write to error output file!%s", newline);
program.exit_function(1);
}
#endif
vfprintf(error, format, ap);
va_end(ap);
- fprintf(error, "\n");
+ fprintf(error, "%s", newline);
}
if (mode & ERR_HELP)
- fprintf(error, "%s: Try option '--help' for more information.\n",
- program.command_basename);
+ fprintf(error, "%s: Try option '--help' for more information.%s",
+ program.command_basename, newline);
if (mode & ERR_EXIT)
- fprintf(error, "%s%s: aborting\n", program.command_basename, process_name);
+ fprintf(error, "%s%s: aborting%s",
+ program.command_basename, process_name, newline);
if (error != stderr)
fclose(error);
return ptr;
}
+void *checked_realloc(void *ptr, unsigned long size)
+{
+ ptr = realloc(ptr, size);
+
+ if (ptr == NULL)
+ Error(ERR_EXIT, "cannot allocate %d bytes -- out of memory", size);
+
+ return ptr;
+}
+
short getFile16BitInteger(FILE *file, int byte_order)
{
if (byte_order == BYTE_ORDER_BIG_ENDIAN)
}
}
-void getFileChunk(FILE *file, char *chunk_buffer, int *chunk_length,
- int byte_order)
+boolean getFileChunk(FILE *file, char *chunk_name, int *chunk_size,
+ int byte_order)
{
- const int chunk_identifier_length = 4;
+ const int chunk_name_length = 4;
+
+ /* read chunk name */
+ fgets(chunk_name, chunk_name_length + 1, file);
- /* read chunk identifier */
- fgets(chunk_buffer, chunk_identifier_length + 1, file);
+ /* read chunk size */
+ *chunk_size = getFile32BitInteger(file, byte_order);
- /* read chunk length */
- *chunk_length = getFile32BitInteger(file, byte_order);
+ return (feof(file) || ferror(file) ? FALSE : TRUE);
}
-void putFileChunk(FILE *file, char *chunk_name, int chunk_length,
+void putFileChunk(FILE *file, char *chunk_name, int chunk_size,
int byte_order)
{
- /* write chunk identifier */
+ /* write chunk name */
fputs(chunk_name, file);
- /* write chunk length */
- putFile32BitInteger(file, chunk_length, byte_order);
+ /* write chunk size */
+ putFile32BitInteger(file, chunk_size, byte_order);
}
#define TRANSLATE_KEYSYM_TO_KEYNAME 0