Leser: 1
8 Einträge, 1 Seite |
1
2
3
4
5
if ( $_[0] =~ /REM IF ([^ ]*) ([^ ]*) \'([^']*)\'/ ) {
$variable = $1;
$operator = $2;
$text = $3;
}
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
void FreeSplit(char **data) {
int i;
if(data == NULL) return;
for(i = 0; i < 3; i++) {
if(data[i]) free(data[i]);
}
free(data);
}
char **SplitConstruct(const char *var) {
char **retval = NULL;
const char *ptr = NULL;
int len = 0, i = 0;
ptr = strstr(var, "REM IF ");
if(ptr == NULL) return NULL;
ptr += 7; // 7 == strlen("REM IF ");
retval = (char **)malloc(sizeof(char *) * 3);
memset(retval, 0, sizeof(char *) * 3);
for(i = 0; i < 3; i++) {
ptr = strchr(ptr, ' ');
if(ptr == NULL) break;
len = ptr - var;
retval[i] = (char *)malloc(len + 16);
strncpy(retval[i], ptr, len);
ptr += len + 1;
} while(0);
if(i != 3) { // error
FreeSplit(retval);
retval = NULL;
}
return retval;
}
8 Einträge, 1 Seite |