Changeset df49c60 in rtems for tools/cpu/sh/shgen.c
- Timestamp:
- 06/12/00 15:00:15 (23 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- edeed26
- Parents:
- 0ab65474
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/cpu/sh/shgen.c
r0ab65474 rdf49c60 1 1 /* 2 * Copyright (c) 1998 -1999Ralf Corsepius (corsepiu@faw.uni-ulm.de)2 * Copyright (c) 1998,1999,2000 Ralf Corsepius (corsepiu@faw.uni-ulm.de) 3 3 * 4 4 * See the file COPYING for copyright notice. … … 12 12 #include "sci.h" 13 13 14 static void usage( char *prog )14 static void usage( FILE* ofile, char *prog ) 15 15 { 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" ); 25 27 } 28 29 #if HAVE_GETOPT_LONG 30 #define NOARG 0 31 #define HASARG 1 32 #define OPTARG 2 33 34 static 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 26 44 27 45 static void shgen_header( FILE *file ) 28 46 { 29 47 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 ); 31 50 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" ); 33 52 fprintf( file, 34 53 "\n/* This file is not copyrighted */\n\n" ); … … 38 57 { 39 58 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 42 67 { 43 68 switch ( optopt ) … … 52 77 break ; 53 78 case 'H' : 54 sscanf( optarg, "%lf", &Phi ); 79 sscanf( optarg, "%lf", &Phi ); 55 80 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); 56 87 default : 57 usage( argv[0] ); 88 usage( stderr, argv[0] ); 89 exit(1); 58 90 break ; 59 91 } … … 61 93 62 94 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 65 100 shgen_header( stdout ); 66 101 … … 70 105 } 71 106 else 72 usage( argv[0] ); 107 { 108 fprintf( stderr, "%s: Invalid argument: driver\n", argv[0] ); 109 exit(1); 110 } 73 111 74 112 return 0 ;
Note: See TracChangeset
for help on using the changeset viewer.