1 /* $Id: args.c,v 1.17 2005-02-25 05:20:36 chris Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Functions for accessing arguments.
26 static char rcsid[] = "$Id: args.c,v 1.17 2005-02-25 05:20:36 chris Exp $";
41 char * Args[MAX_ARGS];
47 for (i=0; i<Num_args; i++ )
48 if (! stricmp( Args[i], s))
54 int FindResArg(char *prefix, int *sw, int *sh)
59 int prefixlen = strlen(prefix);
61 for (i = 0; i < Num_args; ++i)
62 if (Args[i][0] == '-' && !strnicmp(Args[i] + 1, prefix, prefixlen))
64 w = strtol(Args[i] + 1 + prefixlen, &endptr, 10);
65 if (w > 0 && endptr && endptr[0] == 'x')
67 h = strtol(endptr + 1, &endptr, 10);
68 if (h > 0 && endptr[0] == '\0')
84 for (i=0; i< Num_args; i++ )
88 void InitArgs( int argc,char **argv )
94 for (i=0; i<argc; i++ )
95 Args[Num_args++] = d_strdup( argv[i] );
98 for (i=0; i< Num_args; i++ ) {
99 if ( Args[i][0] == '-' )
100 strlwr( Args[i] ); // Convert all args to lowercase
107 void AppendArgs(void)
113 if((i=FindArg("-ini")))
114 f = PHYSFSX_openReadBuffered(Args[i+1]);
116 f = PHYSFSX_openReadBuffered("d2x.ini");
119 while(!PHYSFS_eof(f) && Num_args < MAX_ARGS)
121 line=fgets_unlimited(f);
122 word=splitword(line,' ');
124 Args[Num_args++] = d_strdup(word);
127 Args[Num_args++] = d_strdup(line);
129 d_free(line); d_free(word);