ARGS.C 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/main/rcs/args.c $
  15. * $Revision: 2.0 $
  16. * $Author: john $
  17. * $Date: 1995/02/27 11:31:22 $
  18. *
  19. * Functions for accessing arguments.
  20. *
  21. * $Log: args.c $
  22. * Revision 2.0 1995/02/27 11:31:22 john
  23. * New version 2.0, which has no anonymous unions, builds with
  24. * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  25. *
  26. * Revision 1.9 1994/11/29 01:07:57 john
  27. * Took out some unused vars.
  28. *
  29. * Revision 1.8 1994/11/29 01:04:30 john
  30. * Took out descent.ini stuff.
  31. *
  32. * Revision 1.7 1994/09/20 19:29:15 matt
  33. * Made args require exact (not substring), though still case insensitive.
  34. *
  35. * Revision 1.6 1994/07/25 12:33:11 john
  36. * Network "pinging" in.
  37. *
  38. * Revision 1.5 1994/06/17 18:07:50 matt
  39. * Took out printf
  40. *
  41. * Revision 1.4 1994/05/11 19:45:33 john
  42. * *** empty log message ***
  43. *
  44. * Revision 1.3 1994/05/11 18:42:11 john
  45. * Added Descent.ini config file.
  46. *
  47. * Revision 1.2 1994/05/09 17:03:30 john
  48. * Split command line parameters into arg.c and arg.h.
  49. * Also added /dma, /port, /irq to digi.c
  50. *
  51. * Revision 1.1 1994/05/09 16:49:11 john
  52. * Initial revision
  53. *
  54. *
  55. */
  56. #pragma off (unreferenced)
  57. static char rcsid[] = "$Id: args.c 2.0 1995/02/27 11:31:22 john Exp $";
  58. #pragma on (unreferenced)
  59. #include <stdio.h>
  60. #include <stdlib.h>
  61. #include <string.h>
  62. int Num_args=0;
  63. char * Args[100];
  64. int FindArg( char * s ) {
  65. int i;
  66. for (i=0; i<Num_args; i++ )
  67. if (! stricmp( Args[i], s))
  68. return i;
  69. return 0;
  70. }
  71. void InitArgs( int argc,char **argv ) {
  72. int i;
  73. //NO_DESCENT_INI FILE * fp;
  74. //NO_DESCENT_INI char line[100];
  75. Num_args=0;
  76. for (i=0; i<argc; i++ ) {
  77. Args[Num_args++] = strdup( argv[i] );
  78. }
  79. //NO_DESCENT_INI fp = fopen( "descent.ini", "rt" );
  80. //NO_DESCENT_INI if (fp!=NULL) {
  81. //NO_DESCENT_INI while( fgets( line, 100, fp ) != NULL ) {
  82. //NO_DESCENT_INI char *p;
  83. //NO_DESCENT_INI p = strchr(line,';');
  84. //NO_DESCENT_INI if (p) *p = '\0'; // Remove comments
  85. //NO_DESCENT_INI p = strchr(line,10);
  86. //NO_DESCENT_INI if (p) *p = '\0'; // Remove EOL
  87. //NO_DESCENT_INI p = strchr(line,13);
  88. //NO_DESCENT_INI if (p) *p = '\0'; // Remove CR
  89. //NO_DESCENT_INI p = strtok( line, " \t" );
  90. //NO_DESCENT_INI while( p ) {
  91. //NO_DESCENT_INI Args[Num_args++] = strdup( p );
  92. //NO_DESCENT_INI p = strtok( NULL, " \t" );
  93. //NO_DESCENT_INI }
  94. //NO_DESCENT_INI }
  95. //NO_DESCENT_INI fclose(fp);
  96. //NO_DESCENT_INI }
  97. for (i=0; i< Num_args; i++ ) {
  98. if ( Args[i][0] == '/' )
  99. Args[i][0] = '-';
  100. if ( Args[i][0] == '-' )
  101. strlwr( Args[i] ); // Convert all args to lowercase
  102. //printf( "Args[%d] = '%s'\n", i, Args[i] );
  103. }
  104. }
  105.