fprintf_line(stdout, line_string, line_length);
}
+void printf_line_with_prefix(char *prefix, char *line_string, int line_length)
+{
+ fprintf(stdout, "%s", prefix);
+ fprintf_line(stdout, line_string, line_length);
+}
+
/* int2str() returns a number converted to a string;
the used memory is static, but will be overwritten by later calls,
*y2 = help_y;
}
+/* the "put" variants of the following file access functions check for the file
+ pointer being != NULL and return the number of bytes they have or would have
+ written; this allows for chunk writing functions to first determine the size
+ of the (not yet written) chunk, write the correct chunk size and finally
+ write the chunk itself */
+
+int getFile8BitInteger(FILE *file)
+{
+ return fgetc(file);
+}
+
+int putFile8BitInteger(FILE *file, int value)
+{
+ if (file != NULL)
+ fputc(value, file);
+
+ return 1;
+}
+
int getFile16BitInteger(FILE *file, int byte_order)
{
if (byte_order == BYTE_ORDER_BIG_ENDIAN)
(fgetc(file) << 8));
}
-void putFile16BitInteger(FILE *file, int value, int byte_order)
+int putFile16BitInteger(FILE *file, int value, int byte_order)
{
- if (byte_order == BYTE_ORDER_BIG_ENDIAN)
- {
- fputc((value >> 8) & 0xff, file);
- fputc((value >> 0) & 0xff, file);
- }
- else /* BYTE_ORDER_LITTLE_ENDIAN */
+ if (file != NULL)
{
- fputc((value >> 0) & 0xff, file);
- fputc((value >> 8) & 0xff, file);
+ if (byte_order == BYTE_ORDER_BIG_ENDIAN)
+ {
+ fputc((value >> 8) & 0xff, file);
+ fputc((value >> 0) & 0xff, file);
+ }
+ else /* BYTE_ORDER_LITTLE_ENDIAN */
+ {
+ fputc((value >> 0) & 0xff, file);
+ fputc((value >> 8) & 0xff, file);
+ }
}
+
+ return 2;
}
int getFile32BitInteger(FILE *file, int byte_order)
(fgetc(file) << 24));
}
-void putFile32BitInteger(FILE *file, int value, int byte_order)
+int putFile32BitInteger(FILE *file, int value, int byte_order)
{
- if (byte_order == BYTE_ORDER_BIG_ENDIAN)
+ if (file != NULL)
{
- fputc((value >> 24) & 0xff, file);
- fputc((value >> 16) & 0xff, file);
- fputc((value >> 8) & 0xff, file);
- fputc((value >> 0) & 0xff, file);
- }
- else /* BYTE_ORDER_LITTLE_ENDIAN */
- {
- fputc((value >> 0) & 0xff, file);
- fputc((value >> 8) & 0xff, file);
- fputc((value >> 16) & 0xff, file);
- fputc((value >> 24) & 0xff, file);
+ if (byte_order == BYTE_ORDER_BIG_ENDIAN)
+ {
+ fputc((value >> 24) & 0xff, file);
+ fputc((value >> 16) & 0xff, file);
+ fputc((value >> 8) & 0xff, file);
+ fputc((value >> 0) & 0xff, file);
+ }
+ else /* BYTE_ORDER_LITTLE_ENDIAN */
+ {
+ fputc((value >> 0) & 0xff, file);
+ fputc((value >> 8) & 0xff, file);
+ fputc((value >> 16) & 0xff, file);
+ fputc((value >> 24) & 0xff, file);
+ }
}
+
+ return 4;
}
boolean getFileChunk(FILE *file, char *chunk_name, int *chunk_size,
fputc(version_build, file);
}
+void ReadBytesFromFile(FILE *file, byte *buffer, unsigned long bytes)
+{
+ int i;
+
+ for(i = 0; i < bytes && !feof(file); i++)
+ buffer[i] = fgetc(file);
+}
+
+void WriteBytesToFile(FILE *file, byte *buffer, unsigned long bytes)
+{
+ int i;
+
+ for(i = 0; i < bytes; i++)
+ fputc(buffer[i], file);
+}
+
void ReadUnusedBytesFromFile(FILE *file, unsigned long bytes)
{
while (bytes-- && !feof(file))
result = (strcmp(value, "left") == 0 ? MV_LEFT :
strcmp(value, "right") == 0 ? MV_RIGHT :
strcmp(value, "up") == 0 ? MV_UP :
- strcmp(value, "down") == 0 ? MV_DOWN : MV_NO_MOVING);
+ strcmp(value, "down") == 0 ? MV_DOWN : MV_NONE);
}
else if (strcmp(suffix, ".anim_mode") == 0)
{
- result = (string_has_parameter(value, "none") ? ANIM_NONE :
- string_has_parameter(value, "loop") ? ANIM_LOOP :
- string_has_parameter(value, "linear") ? ANIM_LINEAR :
- string_has_parameter(value, "pingpong") ? ANIM_PINGPONG :
- string_has_parameter(value, "pingpong2") ? ANIM_PINGPONG2 :
- string_has_parameter(value, "random") ? ANIM_RANDOM :
- string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL :
- string_has_parameter(value, "vertical") ? ANIM_VERTICAL :
+ result = (string_has_parameter(value, "none") ? ANIM_NONE :
+ string_has_parameter(value, "loop") ? ANIM_LOOP :
+ string_has_parameter(value, "linear") ? ANIM_LINEAR :
+ string_has_parameter(value, "pingpong") ? ANIM_PINGPONG :
+ string_has_parameter(value, "pingpong2") ? ANIM_PINGPONG2 :
+ string_has_parameter(value, "random") ? ANIM_RANDOM :
+ string_has_parameter(value, "ce_value") ? ANIM_CE_VALUE :
+ string_has_parameter(value, "ce_score") ? ANIM_CE_SCORE :
+ string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL :
+ string_has_parameter(value, "vertical") ? ANIM_VERTICAL :
ANIM_DEFAULT);
if (string_has_parameter(value, "reverse"))
result |= ANIM_REVERSE;
+
+ if (string_has_parameter(value, "static_panel"))
+ result |= ANIM_STATIC_PANEL;
}
else /* generic parameter of type integer or boolean */
{