mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-04-06 18:00:24 +08:00
Use built-in printf
hex format code
This commit is contained in:
parent
0c6fd78251
commit
3f4967f216
@ -14,13 +14,10 @@
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
static char hex[16] = "0123456789abcdef";
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
unsigned char c;
|
||||
unsigned int c0,c1;
|
||||
FILE* f = NULL;
|
||||
|
||||
if(argc > 1) {
|
||||
@ -33,12 +30,7 @@ main(int argc, char** argv)
|
||||
for(;;) {
|
||||
int ret = fread(&c, 1, 1, f);
|
||||
if(ret != 1) break;
|
||||
c1 = c;
|
||||
c0 = c1 & 0xf;
|
||||
c1 = (c1 >> 4);
|
||||
c0 = hex[c0];
|
||||
c1 = hex[c1];
|
||||
printf("%c%c",(char)c1,(char)c0);
|
||||
printf("%.2hhx", c);
|
||||
}
|
||||
if(f != stdin) fclose(f);
|
||||
return 0;
|
||||
|
@ -441,13 +441,11 @@ breadthfirst(NCZMAP* map, const char* key, NClist* stack)
|
||||
return stat;
|
||||
}
|
||||
|
||||
static char hex[16] = "0123456789abcdef";
|
||||
|
||||
static void
|
||||
printcontent(size64_t len, const char* content, OBJKIND kind)
|
||||
{
|
||||
size64_t i, count;
|
||||
unsigned int c0,c1;
|
||||
|
||||
const char* format = NULL;
|
||||
int strlen = 1;
|
||||
@ -487,12 +485,7 @@ printcontent(size64_t len, const char* content, OBJKIND kind)
|
||||
printf("%c",content[i]);
|
||||
break;
|
||||
default:
|
||||
c1 = (unsigned char)(content[i]);
|
||||
c0 = c1 & 0xf;
|
||||
c1 = (c1 >> 4);
|
||||
c0 = hex[c0];
|
||||
c1 = hex[c1];
|
||||
printf("%c%c",(char)c1,(char)c0);
|
||||
printf("%.2hhx", content[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user