[Scummvm-cvs-logs] SF.net SVN: scummvm:[40547] tools/trunk
sev at users.sourceforge.net
sev at users.sourceforge.net
Thu May 14 06:33:43 CEST 2009
Revision: 40547
http://scummvm.svn.sourceforge.net/scummvm/?rev=40547&view=rev
Author: sev
Date: 2009-05-14 04:33:43 +0000 (Thu, 14 May 2009)
Log Message:
-----------
Fix code formatting.
Modified Paths:
--------------
tools/trunk/compress_gob.cpp
tools/trunk/extract_gob_stk.cpp
Modified: tools/trunk/compress_gob.cpp
===================================================================
--- tools/trunk/compress_gob.cpp 2009-05-13 23:38:11 UTC (rev 40546)
+++ tools/trunk/compress_gob.cpp 2009-05-14 04:33:43 UTC (rev 40547)
@@ -64,6 +64,7 @@
outFilename = new char[strlen(argv[1]) + 5];
strcpy(outFilename, argv[1]);
tmpStr = strstr(outFilename, ".");
+
if (tmpStr != 0)
strncpy(tmpStr, ".stk\0", 5);
else
@@ -103,6 +104,7 @@
// first read (signature, not yet used)
fscanf(gobConf, "%s", buffer);
fscanf(gobConf, "%s", buffer);
+
while (!feof(gobConf)) {
strcpy(curChunk->name, buffer);
fscanf(gobConf, "%s", buffer);
@@ -121,8 +123,7 @@
return chunks;
}
-void *writeBody (FILE *stk, uint16 chunkCount, Chunk *chunks)
-{
+void *writeBody (FILE *stk, uint16 chunkCount, Chunk *chunks) {
Chunk *curChunk = chunks;
FILE *src;
char buffer[4096];
@@ -136,16 +137,20 @@
for (;;) {
if (!(src = fopen(curChunk->name, "rb")))
error("Couldn't open conf file \"%s\"", curChunk->name);
+
curChunk->size = 0;
+
for (;;) {
- count=fread(buffer, 1, 4096, src);
+ count = fread(buffer, 1, 4096, src);
fwrite(buffer, 1, count, stk);
curChunk->size += count;
+
if (count < 4096)
break;
}
printf("%s taille %d\n", curChunk->name, curChunk->size);
fclose(src);
+
if (curChunk->next != 0)
curChunk = curChunk->next;
else
@@ -154,8 +159,7 @@
return 0;
}
-void *rewriteHeader (FILE *stk, uint16 chunkCount, Chunk *chunks)
-{
+void *rewriteHeader (FILE *stk, uint16 chunkCount, Chunk *chunks) {
uint16 i;
char buffer[1024];
Chunk *curChunk = chunks;
@@ -176,9 +180,9 @@
buffer[0] = chunkCount & 0xFF;
buffer[1] = chunkCount >> 8;
fwrite(buffer, 1, 2, stk);
+
// TODO : Implement STK21
- for (;;)
- {
+ for (;;) {
for (i = 0; i < 13; i++)
if (i < strlen(curChunk->name))
buffer[i] = curChunk->name[i];
Modified: tools/trunk/extract_gob_stk.cpp
===================================================================
--- tools/trunk/extract_gob_stk.cpp 2009-05-13 23:38:11 UTC (rev 40546)
+++ tools/trunk/extract_gob_stk.cpp 2009-05-14 04:33:43 UTC (rev 40547)
@@ -63,6 +63,7 @@
outFilename = new char[strlen(argv[1])+5];
strcpy(outFilename, argv[1]);
tmpStr = strstr(outFilename, ".");
+
if (tmpStr != 0)
strncpy(tmpStr, ".gob\0", 5);
else
@@ -74,12 +75,10 @@
if (fread(signature, 1, 6, stk) < 6)
error("Unexpected EOF while reading signature in \"%s\"", argv[1]);
- if (strncmp(signature, "STK2.1", 6) == 0)
- {
+ if (strncmp(signature, "STK2.1", 6) == 0) {
warning("Signature of new STK format (STK 2.1) detected in file \"%s\"", argv[1]);
fprintf(gobConf, "%s\n", confSTK21);
chunks = readChunkListV2(stk, gobConf);
-
} else {
fprintf(gobConf, "%s\n", confSTK10);
rewind(stk);
@@ -164,11 +163,13 @@
if (fread(buffer, 1, 14, stk) < 14)
extractError(stk, gobConf, chunks, "Unexpected EOF");
+
buffer[14]='\0';
sprintf(debugStr, "File generated on %s by ", buffer);
if (fread(buffer, 1, 8, stk) < 8)
extractError(stk, gobConf, chunks, "Unexpected EOF");
+
buffer[8] = '\0';
strcat(debugStr, buffer);
printf("%s\n",debugStr);
@@ -180,7 +181,7 @@
// + 04 bytes : Number of files stored in STK/ITK
// + 04 bytes : Start position of Misc Section
- if (fseek(stk, filenamePos, SEEK_SET)!=0)
+ if (fseek(stk, filenamePos, SEEK_SET) != 0)
extractError(stk, gobConf, chunks, "Unable to locate Filename Section");
numDataChunks = readUint32LE(stk);
@@ -220,15 +221,15 @@
filePos = readUint32LE(stk);
compressFlag = readUint32LE(stk);
- if (compressFlag == 1)
+ if (compressFlag == 1) {
curChunk->packed = true;
- else {
- if ((curChunk->size != decompSize) | (compressFlag != 0))
- {
+ } else {
+ if ((curChunk->size != decompSize) | (compressFlag != 0)) {
sprintf(debugStr, "Unexpected value in compress flag : %d - Size : %d Uncompressed size : %d", compressFlag, curChunk->size, decompSize);
extractError(stk, gobConf, chunks, debugStr);
- } else
+ } else {
curChunk->packed=false;
+ }
}
// Filenames
@@ -271,7 +272,6 @@
while (curChunk != 0) {
printf("Extracting \"%s\"\n", curChunk->name);
-
FILE *chunkFile;
if (!(chunkFile = fopen(curChunk->name, "wb")))
extractError(stk, 0, chunks, "Couldn't write file");
@@ -289,9 +289,7 @@
if (curChunk->preGob) {
unpackedData = unpackPreGobData(data, realSize, curChunk->size);
- }
- else
- {
+ } else {
unpackedData = unpackData(data, realSize);
}
@@ -300,9 +298,10 @@
delete[] unpackedData;
- } else
+ } else {
if (fwrite((char *) data, curChunk->size, 1, chunkFile) < 1)
extractError(stk, chunkFile, chunks, "Couldn't write");
+ }
delete[] data;
fclose(chunkFile);
@@ -345,10 +344,10 @@
tmpIndex++;
tmpIndex %= 4096;
counter--;
+
if (counter == 0)
break;
} else { /* copy string */
-
off = *src++;
off |= (*src & 0xF0) << 4;
len = (*src & 0x0F) + 3;
@@ -425,12 +424,13 @@
tmpBuf[tmpIndex] = *src;
src++;
newCounter--;
+
if (newCounter == 0)
break;
+
tmpIndex++;
tmpIndex %= 4096;
} else { /* copy string */
-
off = *src++;
off |= (*src & 0xF0) << 4;
len = (*src & 0x0F) + 3;
@@ -450,4 +450,4 @@
}
return unpacked;
-}
\ No newline at end of file
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list