USER.C 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. Copyright (C) 1994-1995 Apogee Software, Ltd.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. /**********************************************************************
  16. module: USER.C
  17. author: James R. Dose
  18. date: April 26, 1994
  19. Routines to parse command line options.
  20. (c) Copyright 1994 James R. Dose. All Rights Reserved.
  21. **********************************************************************/
  22. #include <dos.h>
  23. #include <string.h>
  24. #include "user.h"
  25. #define TRUE ( 1 == 1 )
  26. #define FALSE ( !TRUE )
  27. extern int _argc;
  28. extern char **_argv;
  29. /*---------------------------------------------------------------------
  30. Function: USER_CheckParameter
  31. Checks if the specified string is present in the command line.
  32. ---------------------------------------------------------------------*/
  33. int USER_CheckParameter
  34. (
  35. const char *parameter
  36. )
  37. {
  38. int i;
  39. int found;
  40. char *ptr;
  41. found = FALSE;
  42. i = 1;
  43. while( i < _argc )
  44. {
  45. ptr = _argv[ i ];
  46. // Only check parameters preceded by - or /
  47. if ( ( *ptr == '-' ) || ( *ptr == '/' ) )
  48. {
  49. ptr++;
  50. if ( stricmp( parameter, ptr ) == 0 )
  51. {
  52. found = TRUE;
  53. break;
  54. }
  55. }
  56. i++;
  57. }
  58. return( found );
  59. }
  60. /*---------------------------------------------------------------------
  61. Function: USER_GetText
  62. Checks if the specified string is present in the command line
  63. and returns a pointer to the text following it.
  64. ---------------------------------------------------------------------*/
  65. char *USER_GetText
  66. (
  67. const char *parameter
  68. )
  69. {
  70. int i;
  71. char *text;
  72. char *ptr;
  73. text = NULL;
  74. i = 1;
  75. while( i < _argc )
  76. {
  77. ptr = _argv[ i ];
  78. // Only check parameters preceded by - or /
  79. if ( ( *ptr == '-' ) || ( *ptr == '/' ) )
  80. {
  81. ptr++;
  82. if ( stricmp( parameter, ptr ) == 0 )
  83. {
  84. i++;
  85. text = _argv[ i ];
  86. break;
  87. }
  88. }
  89. i++;
  90. }
  91. return( text );
  92. }