Mercurial > hg > dmlib
comparison libgfx.c @ 445:1d65efb29986
Simplify.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 04 Nov 2012 06:54:37 +0200 |
parents | 7d588807f91d |
children | 0e27860ddcfe |
comparison
equal
deleted
inserted
replaced
444:7d588807f91d | 445:1d65efb29986 |
---|---|
938 typedef struct | 938 typedef struct |
939 { | 939 { |
940 Uint32 id; | 940 Uint32 id; |
941 Uint32 size; | 941 Uint32 size; |
942 int count; | 942 int count; |
943 char str[6]; | |
943 } DMIFFChunk; | 944 } DMIFFChunk; |
944 | 945 |
945 | 946 |
946 typedef struct | 947 typedef struct |
947 { | 948 { |
978 } | 979 } |
979 else | 980 else |
980 return TRUE; | 981 return TRUE; |
981 } | 982 } |
982 | 983 |
983 static char * dmGetIFFChunkID(const DMIFFChunk *chunk, char *buf) | 984 static char * dmGetIFFChunkID(DMIFFChunk *chunk) |
984 { | 985 { |
985 buf[0] = (chunk->id >> 24) & 0xff; | 986 chunk->str[0] = (chunk->id >> 24) & 0xff; |
986 buf[1] = (chunk->id >> 16) & 0xff; | 987 chunk->str[1] = (chunk->id >> 16) & 0xff; |
987 buf[2] = (chunk->id >> 8) & 0xff; | 988 chunk->str[2] = (chunk->id >> 8) & 0xff; |
988 buf[3] = (chunk->id) & 0xff; | 989 chunk->str[3] = (chunk->id) & 0xff; |
989 buf[4] = 0; | 990 chunk->str[4] = 0; |
990 return buf; | 991 return chunk->str; |
991 } | 992 } |
992 | 993 |
993 static BOOL dmSkipIFFChunkRest(FILE *fp, const DMIFFChunk *chunk, const Uint32 used) | 994 static BOOL dmSkipIFFChunkRest(FILE *fp, const DMIFFChunk *chunk, const Uint32 used) |
994 { | 995 { |
995 if (chunk->size > used) | 996 if (chunk->size > used) |
996 return fseeko(fp, chunk->size - used, SEEK_CUR) == 0; | 997 return fseeko(fp, chunk->size - used, SEEK_CUR) == 0; |
997 else | 998 else |
998 return TRUE; | 999 return TRUE; |
999 } | 1000 } |
1000 | 1001 |
1001 static BOOL dmCheckIFFChunk(DMIFFChunk *dest, const DMIFFChunk *chunk, const BOOL multi, const Uint32 minSize) | 1002 static BOOL dmCheckIFFChunk(DMIFFChunk *dest, DMIFFChunk *chunk, |
1003 const BOOL multi, const Uint32 minSize) | |
1002 { | 1004 { |
1003 if (dest->count > 0 && !multi) | 1005 if (dest->count > 0 && !multi) |
1004 { | 1006 { |
1005 char buf[6]; | |
1006 dmError("ILBM: Multiple instances of chunk %s found.\n", | 1007 dmError("ILBM: Multiple instances of chunk %s found.\n", |
1007 dmGetIFFChunkID(chunk, buf)); | 1008 dmGetIFFChunkID(chunk)); |
1008 return FALSE; | 1009 return FALSE; |
1009 } | 1010 } |
1010 | 1011 |
1011 dest->count++; | 1012 dest->count++; |
1012 | 1013 |
1158 parsed = TRUE; | 1159 parsed = TRUE; |
1159 break; | 1160 break; |
1160 | 1161 |
1161 default: | 1162 default: |
1162 { | 1163 { |
1163 char buf[6]; | |
1164 dmMsg(3, "Unknown chunk ID '%s', size %d\n", | 1164 dmMsg(3, "Unknown chunk ID '%s', size %d\n", |
1165 dmGetIFFChunkID(&chunk, buf), chunk.size); | 1165 dmGetIFFChunkID(&chunk), chunk.size); |
1166 | 1166 |
1167 if (fseeko(fp, chunk.size, SEEK_CUR) != 0) | 1167 if (fseeko(fp, chunk.size, SEEK_CUR) != 0) |
1168 { | 1168 { |
1169 dmError("ILBM: Error skipping in file."); | 1169 dmError("ILBM: Error skipping in file."); |
1170 return DMERR_FREAD; | 1170 return DMERR_FREAD; |