1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Ben Parnell
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 /****************************************************************/
24 /* This file contains code for parsing command-line */
27 /****************************************************************/
33 #include "../../types.h"
36 void ParseEA(int x, int argc, char *argv[], ARGPSTRUCT *argsps)
44 ParseEA(x,argc,argv,(void *)argsps[y].var);
48 if(!strcmp(argv[x],argsps[y].name)) // A match.
54 if(argsps[y].substype&0x8000)
56 *(int *)argsps[y].subs&=~(argsps[y].substype&(~0x8000));
57 *(int *)argsps[y].subs|=atoi(argv[x+1])?(argsps[y].substype&(~0x8000)):0;
60 switch(argsps[y].substype&(~0x4000))
63 *(int *)argsps[y].subs=atoi(argv[x+1]);
66 if(argsps[y].substype&0x4000)
68 if(*(char **)argsps[y].subs)
69 free(*(char **)argsps[y].subs);
70 if(!( *(char **)argsps[y].subs=malloc(strlen(argv[x+1])+1) ))
73 strcpy(*(char **)argsps[y].subs,argv[x+1]);
81 } while(argsps[y].var || argsps[y].subs);
84 void ParseArguments(int argc, char *argv[], ARGPSTRUCT *argsps)
89 ParseEA(x,argc,argv,argsps);