-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCommandLine.cpp
104 lines (84 loc) · 2.13 KB
/
CommandLine.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "main.h"
CArrayEx<sLine*, sLine*> aCommand;
//Commands.
sLine CLine[] = {
{"-title",0},
{"-cachefix",0},
{"-sleepy",0},
{"-rd",0},
{"-ftj",0}
};
DWORD ParseStringForText(LPSTR Source,LPSTR text)
{
CHAR BUF[4059];
memset(BUF,0x00,4059);
for(unsigned int x = 0; x < strlen(Source); x++)
{
if(strlen(text) + x > strlen(Source))
break;
for(unsigned int y = 0; y < strlen(text); y++)
{
INT cC = Source[x+y];
memcpy(BUF+strlen(BUF),(LPSTR)&cC,sizeof(cC));
}
if(!_strcmpi(BUF,text))
return x;
memset(BUF,0x00,4059);
}
return -1;
}
VOID ParseCommandLine(LPSTR Command)
{
for(int x = 0; x < ArraySize(CLine); x++)
{
DWORD id = ParseStringForText(Command,CLine[x].Param);
if(id == -1)
continue;
CHAR szText[100];
BOOL bStart = false;
memset(szText,0x00,100);
if(!CLine[x].isBool)
{
for(unsigned int y = (id+(strlen(CLine[x].Param))); y < strlen(Command); y++)
{
if(Command[y] == '"')
if(bStart){
bStart = false;
break;
}
else{
bStart = true;
y++;
}
int byt = Command[y];
if(bStart)
memcpy(szText+strlen(szText),(LPSTR)&byt,sizeof(byt));
}
}
sLine *sl = new sLine;
sl->isBool = CLine[x].isBool;
strcpy_s(sl->Param,sizeof(sl->Param),CLine[x].Param);
if(!sl->isBool)
strcpy_s(sl->szText,sizeof(sl->szText),szText);
aCommand.Add(sl);
}
}
sLine *GetCommand(LPSTR Param)
{
for(int x = 0; x < aCommand.GetSize(); x++)
if(!_strcmpi(aCommand[x]->Param,Param))
return aCommand[x];
return 0;
}