Line | |
---|
1 | #ifndef AAFPANEL_GLOBAL_H |
---|
2 | #define AAFPANEL_GLOBAL_H |
---|
3 | |
---|
4 | #define MAXTOKENS 256 |
---|
5 | |
---|
6 | char **str_split(char *string, char *delim) { |
---|
7 | char **tokens = NULL; |
---|
8 | char *working = NULL; |
---|
9 | char *token = NULL; |
---|
10 | int idx = 0; |
---|
11 | |
---|
12 | tokens = malloc(sizeof(char *) * MAXTOKENS); |
---|
13 | if(tokens == NULL) |
---|
14 | return NULL; |
---|
15 | |
---|
16 | working = malloc(sizeof(char) * strlen(string) + 1); |
---|
17 | if(working == NULL) |
---|
18 | return NULL; |
---|
19 | |
---|
20 | /* to make sure, copy string to a safe place */ |
---|
21 | strcpy(working, string); |
---|
22 | for(idx = 0; idx < MAXTOKENS; idx++) |
---|
23 | tokens[idx] = NULL; |
---|
24 | |
---|
25 | token = strtok(working, delim); |
---|
26 | idx = 0; |
---|
27 | |
---|
28 | /* always keep the last entry NULL termindated */ |
---|
29 | while((idx < (MAXTOKENS - 1)) && (token != NULL)) { |
---|
30 | tokens[idx] = malloc(sizeof(char) * strlen(token) + 1); |
---|
31 | if(tokens[idx] != NULL) { |
---|
32 | strcpy(tokens[idx], token); |
---|
33 | idx++; |
---|
34 | token = strtok(NULL, delim); |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | free(working); |
---|
39 | return tokens; |
---|
40 | } |
---|
41 | |
---|
42 | int checkbeta(void) |
---|
43 | { |
---|
44 | char* tmpstr = NULL; |
---|
45 | int betasvn = 0; |
---|
46 | |
---|
47 | tmpstr = command("cat /var/etc/ipkg/official-feed.conf | cut -d '/' -f5"); |
---|
48 | |
---|
49 | if(strstr(tmpstr, "svn") != 0) betasvn = 1; |
---|
50 | free(tmpstr); |
---|
51 | |
---|
52 | return betasvn; |
---|
53 | |
---|
54 | } |
---|
55 | |
---|
56 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.