CBind * CreateConfigBind(char *& buf) { if (strncasecmp(buf,configname,strlen(configname))) return 0; StripWord(buf);char * num=StripWord(buf); Bitu code=ConvDecWord(num); if (usescancodes) { if (code<MAX_SDLKEYS) code=scancode_map[code]; else code=0; } CBind * bind=CreateKeyBind((SDLKey)code); return bind; }
CBind * CreateConfigBind(char *& buf) { if (strncasecmp(configname,buf,strlen(configname))) return 0; StripWord(buf);char * type=StripWord(buf); CBind * bind=0; if (!strcasecmp(type,"axis")) { Bitu ax=ConvDecWord(StripWord(buf)); bool pos=ConvDecWord(StripWord(buf)) > 0; bind=CreateAxisBind(ax,pos); } else if (!strcasecmp(type,"button")) { Bitu but=ConvDecWord(StripWord(buf)); bind=CreateButtonBind(but); } return bind; }
void SetFlags(char * buf) { char * word; while (*(word=StripWord(buf))) { if (!strcasecmp(word,"mod1")) mods|=BMOD_Mod1; if (!strcasecmp(word,"mod2")) mods|=BMOD_Mod2; if (!strcasecmp(word,"mod3")) mods|=BMOD_Mod3; if (!strcasecmp(word,"hold")) flags|=BFLG_Hold; } }
void DOS_Shell::CMD_VER(char *args) { HELP("VER"); if(args && *args) { char* word = StripWord(args); if(strcasecmp(word,"set")) return; word = StripWord(args); if (!*args && !*word) { //Reset dos.version.major = 7; dos.version.minor = 10; } else if (*args == 0 && *word && (strchr(word,'.') != 0)) { //Allow: ver set 7.10 const char * p = strchr(word,'.'); dos.version.major = (Bit8u)(atoi(word)); dos.version.minor = (Bit8u)(atoi(p+1)); } else { //Official syntax: ver set 7 10 dos.version.major = (Bit8u)(atoi(word)); dos.version.minor = (Bit8u)(atoi(args)); } if (autolfn) uselfn=dos.version.major>=7; } else WriteOut(MSG_Get("SHELL_CMD_VER_VER"),VERSION,dos.version.major,dos.version.minor,uselfn?"enabled":"disabled"); }
void DOS_Shell::CMD_IF(char * args) { HELP("IF"); StripSpaces(args,'='); bool has_not=false; while (strncasecmp(args,"NOT",3) == 0) { if (!isspace(*reinterpret_cast<unsigned char*>(&args[3])) && (args[3] != '=')) break; args += 3; //skip text //skip more spaces StripSpaces(args,'='); has_not = !has_not; } if(strncasecmp(args,"ERRORLEVEL",10) == 0) { args += 10; //skip text //Strip spaces and == StripSpaces(args,'='); char* word = StripWord(args); if(!isdigit(*word)) { WriteOut(MSG_Get("SHELL_CMD_IF_ERRORLEVEL_MISSING_NUMBER")); return; } Bit8u n = 0; do n = n * 10 + (*word - '0'); while (isdigit(*++word)); if(*word && !isspace(*word)) { WriteOut(MSG_Get("SHELL_CMD_IF_ERRORLEVEL_INVALID_NUMBER")); return; } /* Read the error code from DOS */ if ((dos.return_code>=n) ==(!has_not)) DoCommand(args); return; } if(strncasecmp(args,"EXIST ",6) == 0) { args += 6; //Skip text StripSpaces(args); char* word = StripArg(args); if (!*word) { WriteOut(MSG_Get("SHELL_CMD_IF_EXIST_MISSING_FILENAME")); return; } { /* DOS_FindFirst uses dta so set it to our internal dta */ RealPt save_dta=dos.dta(); dos.dta(dos.tables.tempdta); bool ret=DOS_FindFirst(word,0xffff & ~DOS_ATTR_VOLUME); dos.dta(save_dta); if (ret==(!has_not)) DoCommand(args); } return; } /* Normal if string compare */ char* word1 = args; // first word is until space or = while (*args && !isspace(*reinterpret_cast<unsigned char*>(args)) && (*args != '=')) args++; char* end_word1 = args; // scan for = while (*args && (*args != '=')) args++; // check for == if ((*args==0) || (args[1] != '=')) { SyntaxError(); return; } args += 2; StripSpaces(args,'='); char* word2 = args; // second word is until space or = while (*args && !isspace(*reinterpret_cast<unsigned char*>(args)) && (*args != '=')) args++; if (*args) { *end_word1 = 0; // mark end of first word *args++ = 0; // mark end of second word StripSpaces(args,'='); if ((strcmp(word1,word2)==0)==(!has_not)) DoCommand(args); } }