OSDN Git Service

[VM][I386] TRY: Import from DOSBOX(J3100) v.2019-05-20.
[csp-qt/common_source_project-fm7.git] / source / src / vm / libcpu_newdev / dosbox-i386 / include / programs.h
1 /*
2  *  Copyright (C) 2002-2015  The DOSBox Team
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18
19
20 #ifndef DOSBOX_PROGRAMS_H
21 #define DOSBOX_PROGRAMS_H
22
23 #ifndef DOSBOX_DOSBOX_H
24 #include "dosbox.h"
25 #endif
26 #ifndef DOSBOX_DOS_INC_H
27 #include "dos_inc.h"
28 #endif
29
30 #ifndef CH_LIST
31 #define CH_LIST
32 #include <list>
33 #endif
34
35 #ifndef CH_STRING
36 #define CH_STRING
37 #include <string>
38 #endif
39
40 class CommandLine {
41 public:
42         CommandLine(int argc,char const * const argv[]);
43         CommandLine(char const * const name,char const * const cmdline);
44         const char * GetFileName(){ return file_name.c_str();}
45
46         bool FindExist(char const * const name,bool remove=false);
47         bool FindHex(char const * const name,int & value,bool remove=false);
48         bool FindInt(char const * const name,int & value,bool remove=false);
49         bool FindString(char const * const name,std::string & value,bool remove=false);
50         bool FindCommand(unsigned int which,std::string & value);
51         bool FindStringBegin(char const * const begin,std::string & value, bool remove=false);
52         bool FindStringRemain(char const * const name,std::string & value);
53         bool FindStringRemainBegin(char const * const name,std::string & value);
54         bool GetStringRemain(std::string & value);
55         int GetParameterFromList(const char* const params[], std::vector<std::string> & output);
56         void FillVector(std::vector<std::string> & vector);
57         unsigned int GetCount(void);
58         void Shift(unsigned int amount=1);
59         Bit16u Get_arglength();
60
61 private:
62         typedef std::list<std::string>::iterator cmd_it;
63         std::list<std::string> cmds;
64         std::string file_name;
65         bool FindEntry(char const * const name,cmd_it & it,bool neednext=false);
66 };
67
68 class Program {
69 public:
70         Program();
71         virtual ~Program(){
72                 delete cmd;
73                 delete psp;
74         }
75         std::string temp_line;
76         CommandLine * cmd;
77         DOS_PSP * psp;
78         virtual void Run(void)=0;
79         bool GetEnvStr(const char * entry,std::string & result);
80         bool GetEnvNum(Bitu num,std::string & result);
81         Bitu GetEnvCount(void);
82         bool SetEnv(const char * entry,const char * new_string);
83         void WriteOut(const char * format,...);                         /* Write to standard output */
84         void WriteOut_NoParsing(const char * format);                           /* Write to standard output, no parsing */
85         void ChangeToLongCmd();
86
87 };
88
89 typedef void (PROGRAMS_Main)(Program * * make);
90 void PROGRAMS_MakeFile(char const * const name,PROGRAMS_Main * main);
91
92 #endif