adding memory dump...

master
steffen 13 years ago
parent 095f214710
commit 5832946569

@ -169,6 +169,38 @@ void d_print_init() {
};
#define D_PRINT_COL 16
void d_print_data (char *data, int len) {
int i, j;
int val;
char txt1 [256] = {0};
char txt2 [256] = {0};
char left [256] = {0};
char right [256] = {0};
d_printf ("memdump: len:%d", len);
for (i = 0; i < len; i++) {
val = data[i] & 0x00FF;
sprintf (txt1, "%2x ", val);
if (data[i] >= ' ' && data[i] <= '~') sprintf (txt2, "%c", data[i]);
else sprintf (txt2, ".");
strncat (left, txt1, 256);
strncat (right, txt2, 256);
if ((i%D_PRINT_COL)==D_PRINT_COL-1 || i == len-1) {
sprintf (txt1, " ");
sprintf (txt2, " ");
for (j = i%D_PRINT_COL; j != 0 && j < D_PRINT_COL; j++) {
strncat (left, txt1, 256);
strncat (right, txt2, 256);
}
d_printf (" |%s | %s |", left, right);
memset (left, 0x0, 256);
memset (right, 0x0, 256);
}
}
};
unsigned long long int getticks () {
static unsigned long long int ticks = 0;
@ -303,24 +335,24 @@ void memswap (void *mem1, void *mem2, int size) {
};
#endif
struct stat *file_exist (char *fn) {
static struct stat fs;
int file_exist (char *fn) {
struct stat fs;
if (stat(fn, &fs) != 0)
return NULL;
return 0;
return &fs;
return 1;
};
struct stat *dir_exist (char *fn) {
static struct stat fs;
int dir_exist (char *fn) {
struct stat fs;
if (stat(fn, &fs) == 0) {
if (S_ISDIR(fs.st_mode))
return &fs;
return 1;
}
return NULL;
return 0;
}

@ -98,6 +98,7 @@ extern void d_printf (char *fmt,...);
extern void d_print_init();
extern void d_print_backtrace ();
extern void d_print_stat ();
extern void d_print_data (char *data, int len);
extern void errorexit (int nr);
extern int execcall (struct s_execcall *p, char *prg, char **argv);
@ -114,8 +115,8 @@ extern char *memstrpop (void *mem, void *dest, int *size);
extern void memswap (void *mem1, void *mem2, int size); // maximum 32 bytes
#endif
struct stat *file_exist (char *fn);
struct stat *dir_exist (char *fn);
int file_exist (char *fn);
int dir_exist (char *fn);
extern char* flags2text (int f, char *text);

Loading…
Cancel
Save