summaryrefslogtreecommitdiff
path: root/src/common/utils.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-08-04 16:24:49 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-08-04 16:24:49 +0000
commita8952b3c7b1067f304e24237bd035263e6b62ed9 (patch)
tree5b9bbc59f59f38101e2bcd7a7d10cbd89a4e81ed /src/common/utils.c
parent65ee11a599f904bdece45c55dd41eb2633da575f (diff)
downloadhercules-a8952b3c7b1067f304e24237bd035263e6b62ed9.tar.gz
hercules-a8952b3c7b1067f304e24237bd035263e6b62ed9.tar.bz2
hercules-a8952b3c7b1067f304e24237bd035263e6b62ed9.tar.xz
hercules-a8952b3c7b1067f304e24237bd035263e6b62ed9.zip
Some all-around code reformatting/cleaning
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10947 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/utils.c')
-rw-r--r--src/common/utils.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/common/utils.c b/src/common/utils.c
index 00b6dc290..15d1d2e68 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -20,41 +20,40 @@
#include <sys/stat.h>
#endif
-#ifdef UTIL_DUMP
-void dump(const unsigned char* buffer, int num)
+// generate a hex dump of the first 'length' bytes of 'buffer'
+void dump(FILE* fp, const unsigned char* buffer, int length)
{
- int icnt, jcnt;
+ int i, j;
- printf(" Hex ASCII\n");
- printf(" ----------------------------------------------- ----------------");
+ fprintf(fp, " Hex ASCII\n");
+ fprintf(fp, " ----------------------------------------------- ----------------");
- for (icnt = 0; icnt < num; icnt += 16)
+ for (i = 0; i < length; i += 16)
{
- printf("\n%p ", &buffer[icnt]);
- for (jcnt = icnt; jcnt < icnt + 16; ++jcnt)
+ fprintf(fp, "\n%p ", &buffer[i]);
+ for (j = i; j < i + 16; ++j)
{
- if (jcnt < num)
- printf("%02hX ", buffer[jcnt]);
+ if (j < length)
+ fprintf(fp, "%02hX ", buffer[j]);
else
- printf(" ");
+ fprintf(fp, " ");
}
- printf(" | ");
+ fprintf(fp, " | ");
- for (jcnt = icnt; jcnt < icnt + 16; ++jcnt)
+ for (j = i; j < i + 16; ++j)
{
- if (jcnt < num) {
- if (buffer[jcnt] > 31 && buffer[jcnt] < 127)
- printf("%c", buffer[jcnt]);
+ if (j < length) {
+ if (buffer[j] > 31 && buffer[j] < 127)
+ fprintf(fp, "%c", buffer[j]);
else
- printf(".");
+ fprintf(fp, ".");
} else
- printf(" ");
+ fprintf(fp, " ");
}
}
- printf("\n");
+ fprintf(fp, "\n");
}
-#endif
// Allocate a StringBuf [MouseJstr]
struct StringBuf * StringBuf_Malloc()