Changeset df49c60 in rtems for tools/cpu/sh/shgen.c


Ignore:
Timestamp:
06/12/00 15:00:15 (23 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
edeed26
Parents:
0ab65474
Message:

Merged from 4.5.0-beta3a

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/cpu/sh/shgen.c

    r0ab65474 rdf49c60  
    11/*
    2  * Copyright (c) 1998-1999 Ralf Corsepius (corsepiu@faw.uni-ulm.de)
     2 * Copyright (c) 1998,1999,2000 Ralf Corsepius (corsepiu@faw.uni-ulm.de)
    33 *
    44 * See the file COPYING for copyright notice.
     
    1212#include "sci.h"
    1313
    14 static void usage( char *prog )
     14static void usage( FILE* ofile, char *prog )
    1515{
    16   fprintf( stderr, "usage: %s [options] driver\n", prog );
    17   fprintf( stderr, "options:\n" );
    18   fprintf( stderr, "\t-M Phi      .. processor frequency [MHz]\n" );
    19   fprintf( stderr, "\t-K Phi      .. processor frequency [KHz]\n" );
    20   fprintf( stderr, "\t-H Phi      .. processor frequency [Hz]\n" );
    21   fprintf( stderr, "\t\t..default 20MHz" );
    22   fprintf( stderr, "driver:\n" );
    23   fprintf( stderr, "\tsci .. bitrate table for sci\n" );
    24   exit ( 1 );
     16  fprintf( ofile, "Usage: %s [options] driver\n", prog );
     17  fprintf( ofile, "\nOptions:\n" );
     18  fprintf( ofile, "Processor frequency (default 20MHz):\n") ;
     19  fprintf( ofile, "\t-M Phi      .. processor frequency [MHz]\n" );
     20  fprintf( ofile, "\t-K Phi      .. processor frequency [KHz]\n" );
     21  fprintf( ofile, "\t-H Phi      .. processor frequency [Hz]\n" );
     22  fprintf( ofile, "Driver:\n" );
     23  fprintf( ofile, "\tsci         .. bitrate table for sci\n" );
     24
     25  fprintf( ofile, "\nWritten by Ralf Corsepius <corsepiu@faw.uni-ulm.de>\n" );
     26  fprintf( ofile, "\nCopyright (c) 1998,1999,2000\tRalf Corsepius\n" );
    2527}
     28
     29#if HAVE_GETOPT_LONG
     30#define NOARG   0
     31#define HASARG  1
     32#define OPTARG  2
     33
     34static struct option long_options[] =
     35{
     36  { "version",          NOARG,  NULL, 'v' },
     37  { "help",             NOARG,  NULL, 'h' },
     38  { "mega-hertz",       HASARG, NULL, 'M' },
     39  { "kilo-hertz",       HASARG, NULL, 'K' },
     40  { "hertz",            HASARG, NULL, 'H' },
     41  { 0, 0, 0, 0 }
     42};
     43#endif
    2644
    2745static void shgen_header( FILE *file )
    2846{
    2947  fprintf( file,
    30     "/*\n * DO NOT EDIT - this file is automatically generated by shgen 0.3\n" );
     48    "/*\n * DO NOT EDIT - this file is automatically generated by shgen %s\n",
     49    VERSION );
    3150  fprintf( file,
    32     " * Copyright (c) 1998-1999, Ralf Corsepius (corsepiu@faw.uni-ulm.de)\n */\n" );
     51    " * Copyright (c) 1998,1999,2000 Ralf Corsepius (corsepiu@faw.uni-ulm.de)\n */\n" );
    3352  fprintf( file,
    3453    "\n/* This file is not copyrighted */\n\n" );
     
    3857{
    3958  double        Phi = 20.0 ;
    40  
    41   while ( ( optopt = getopt( argc, argv, "M:K:H:" ) ) > 0 )
     59
     60#if HAVE_GETOPT_LONG 
     61  int option_index = 0 ;
     62  while( ( optopt = getopt_long( argc, argv, "M:K:H:hv",
     63      long_options, &option_index ) ) > 0 )
     64#else
     65  while ( ( optopt = getopt( argc, argv, "M:K:H:hv" ) ) > 0 )
     66#endif
    4267  {
    4368    switch ( optopt )
     
    5277      break ;
    5378    case 'H' :
    54       sscanf( optarg, "%lf", &Phi ); 
     79      sscanf( optarg, "%lf", &Phi );
    5580      break ;
     81    case 'h' :
     82      usage( stdout, argv[0] );
     83      exit(0);
     84    case 'v' :
     85      fprintf( stdout, "%s version %s\n", argv[0], VERSION );
     86      exit(0);
    5687    default  :
    57       usage( argv[0] );
     88      usage( stderr, argv[0] );
     89      exit(1);
    5890      break ;
    5991    }
     
    6193
    6294  if ( argc - optind != 1 )
    63     usage( argv[0] );
    64 
     95  {
     96    fprintf( stderr, "%s: Missing argument: driver\n", argv[0] );
     97    exit(1);
     98  }
     99 
    65100  shgen_header( stdout );
    66101     
     
    70105  }
    71106  else
    72     usage( argv[0] );
     107  {
     108    fprintf( stderr, "%s: Invalid argument: driver\n", argv[0] );
     109    exit(1);
     110  }
    73111     
    74112  return 0 ;
Note: See TracChangeset for help on using the changeset viewer.