bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Submission of new app for core/file utils


From: m . mohr
Subject: Submission of new app for core/file utils
Date: Thu, 11 Mar 2004 10:24:00 -0800 (PST)

Hi:

I don't know how I should do this, but I would like to submit a new
program to your project.  I wrote this for a few reasons, but mainly
because I couldn't find an existing utility to do what I wanted.  I needed
to be able to generate a binary file if given a set of bytes in ASCII.
Yes, you can use a hex editor to do this, but why?  A hex editor is way
overblown for my uses, and this is much faster anyhow.

Initially this program started out as a way to encode DVD title keys for
use with efdtt and FindKey.  It could also be used (for example) to add
the 5-byte control code that mydoom uses to the beginning of an executable
file (e.g. write a program to remove mydoom then release it).  Of course,
these aren't the only uses...

Input is taken as hex bytes typed in ASCII and printed to stdout.

I'd appreciate any feedback, especially if you won't accept this
submission.

Thank you for your time.

Regards,
Michael Mohr

/*
ihex.c by Michael Mohr
address@hidden

This source is released into the public domain under the GPL.
*/

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
      int i;
      char bytes[(argc-1)]; /* yes this violates ISO C */

      if(argc == 1)
      { /* Print usage */
        printf("%s: Convert specified ASCII bytes into binary.\n",argv[0]);
        printf("Usage: %s [hex bytes, e.g. 0A FF 68]\n",argv[0]);
      }

      for( i=1; i<argc; i++ )
      { /* convert and print the bytes */
        bytes[i] = strtol( argv[i], 0, 16 );
        printf("%c",bytes[i]);
      }

      return 1;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]