Category : Recently Uploaded Files
Archive   : SNIP9503.ZIP
Filename : HEXDUMP.C

 
Output of file : HEXDUMP.C contained in archive : SNIP9503.ZIP
/*
** HEXDUMP.C - Dump a file.
**
** This Program Written By Paul Edwards w/ modifications by Bob Stout
** Released to the public domain
*/

#include
#include
#include
#include

static void dodump(FILE *fp, long start, long count);
static void skipb(FILE *fp, long start);

main(int argc, char **argv)
{
FILE *fp;
long start, count;

if (argc < 2)
{
puts("Usage: HEXDUMP file_name [start] [length]");
return (EXIT_FAILURE);
}
if (argc > 2)
start = atol(*(argv + 2));
else start = 0L;
if (argc > 3)
count = atol(*(argv + 3));
else count = -1L;
fp = fopen(*(argv + 1), "rb");
if (fp == NULL)
{
printf("unable to open file %s for input\n", *(argv+1));
return (EXIT_FAILURE);
}
skipb(fp, start);
dodump(fp, start, count);
return (EXIT_SUCCESS);
}

static void dodump(FILE *fp, long start, long count)
{
int c, pos1, pos2;
long x = 0L;
char prtln[100];

while (((c = fgetc(fp)) != EOF) && (x != count))
{
if (x%16 == 0)
{
memset(prtln,' ',sizeof prtln);
sprintf(prtln,"%0.6X ", start + x);
pos1 = 8;
pos2 = 45;
}
sprintf(prtln + pos1, "%0.2X", c);
if (isprint(c))
sprintf(prtln + pos2, "%c", c);
else sprintf(prtln + pos2, ".");
pos1 += 2;
*(prtln+pos1) = ' ';
pos2++;
if (x % 4 == 3)
*(prtln + pos1++) = ' ';
if (x % 16 == 15)
printf("%s\n", prtln);
x++;
}
if (x % 16 != 15)
printf("%s\n", prtln);
return;
}

static void skipb(FILE *fp, long start)
{
long x = 0;

if (start == 0)
return;
while (x < start)
{
fgetc(fp);
x++;
}
return;
}


  3 Responses to “Category : Recently Uploaded Files
Archive   : SNIP9503.ZIP
Filename : HEXDUMP.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/