Back to index

cell-binutils  2.17cvs20070401
Defines | Functions
bin2c.c File Reference
#include "bfd.h"
#include "bucomm.h"

Go to the source code of this file.

Defines

#define SET_BINARY(f)   (void) 0
#define O_BINARY   0
#define O_TEXT   0

Functions

int main (int argc, char *argv[])

Define Documentation

#define O_BINARY   0

Definition at line 45 of file bin2c.c.

#define O_TEXT   0

Definition at line 46 of file bin2c.c.

#define SET_BINARY (   f)    (void) 0

Definition at line 44 of file bin2c.c.


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 50 of file bin2c.c.

{
  int c;
  int i;

#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
  setlocale (LC_MESSAGES, "");
#endif
#if defined (HAVE_SETLOCALE)
  setlocale (LC_CTYPE, "");
#endif
  bindtextdomain (PACKAGE, LOCALEDIR);
  textdomain (PACKAGE);

  if (argc != 1)
    {
      int ishelp = 0;
      int isvers = 0;
      FILE *stream;

      if (argc == 2 && argv[1][0] == '-')
       {
         const char *opt = &argv[1][1];
         if (*opt == '-')
           ++opt;
         ishelp = *opt == 'h' || *opt == 'H';
         isvers = *opt == 'v' || *opt == 'V';
       }

      if (isvers)
       print_version ("bin2c");

      stream = ishelp ? stdout : stderr;
      fprintf (stream, _("Usage: %s < input_file > output_file\n"), argv[0]);
      fprintf (stream, _("Prints bytes from stdin in hex format.\n"));
      exit (!ishelp);
    }

  SET_BINARY (fileno (stdin));

  i = 0;
  while ((c = getc (stdin)) != EOF)
    {
      printf ("0x%02x,", c);
      if (++i == 16)
       {
         printf ("\n");
         i = 0;
       }
    }
  if (i != 0)
    printf ("\n");

  exit (0);
}

Here is the call graph for this function: