1 /* $Id: args.c,v 1.15 2004-12-01 12:48:13 btb 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.15 2004-12-01 12:48:13 btb Exp $";
42 char * Args[MAX_ARGS];
48 for (i=0; i<Num_args; i++ )
49 if (! stricmp( Args[i], s))
55 int FindResArg(char *prefix, int *sw, int *sh)
60 int prefixlen = strlen(prefix);
62 for (i = 0; i < Num_args; ++i)
63 if (Args[i][0] == '-' && !strnicmp(Args[i] + 1, prefix, prefixlen))
65 w = strtol(Args[i] + 1 + prefixlen, &endptr, 10);
66 if (w > 0 && endptr && endptr[0] == 'x')
68 h = strtol(endptr + 1, &endptr, 10);
69 if (h > 0 && endptr[0] == '\0')
85 for (i=0; i< Num_args; i++ )
89 void InitArgs( int argc,char **argv )
95 for (i=0; i<argc; i++ )
96 Args[Num_args++] = d_strdup( argv[i] );
99 for (i=0; i< Num_args; i++ ) {
100 if ( Args[i][0] == '-' )
101 strlwr( Args[i] ); // Convert all args to lowercase
108 void AppendArgs(void)
114 if((i=FindArg("-ini")))
115 f = PHYSFS_openRead(Args[i+1]);
117 f = PHYSFS_openRead("d2x.ini");
120 while(!PHYSFS_eof(f) && Num_args < MAX_ARGS)
122 line=fgets_unlimited(f);
123 word=splitword(line,' ');
125 Args[Num_args++] = d_strdup(word);
128 Args[Num_args++] = d_strdup(line);
130 d_free(line); d_free(word);