|
8 | 8 |
|
9 | 9 | // execute external command and store result in result
|
10 | 10 | string execute(const char *command) {
|
11 |
| - char buffer[1024]; |
12 |
| - char result[1024] = {0}; |
13 |
| - FILE *ptr; |
14 |
| - strcpy(result, command); |
15 |
| - if((ptr = popen(result, "r"))) { |
16 |
| - while (fgets(buffer, 1024, ptr)) { |
17 |
| - strcat(result, buffer); |
18 |
| - if (strlen(result) > 1024) { |
19 |
| - break; |
20 |
| - } |
21 |
| - } |
22 |
| - pclose(ptr); |
23 |
| - ptr = NULL; |
24 |
| - } |
25 |
| - return result; |
| 11 | + char buffer[2048]; |
| 12 | + char result[2048] = {0}; |
| 13 | + FILE *ptr; |
| 14 | + strcpy(result, command); |
| 15 | + if ((ptr = popen(result, "r"))) { |
| 16 | + while (fgets(buffer, 2048, ptr)) { |
| 17 | + if (strlen(result) + strlen(buffer) <= 2048) { |
| 18 | + strcat(result, buffer); |
| 19 | + } |
| 20 | + } |
| 21 | + pclose(ptr); |
| 22 | + ptr = NULL; |
| 23 | + } |
| 24 | + return result; |
26 | 25 | }
|
27 | 26 |
|
28 | 27 | // update function
|
29 | 28 | void update() {
|
30 |
| - // get version number from https://junlang.imjcj.eu.org/VERSION |
31 |
| - string result = execute("curl -s https://junlang.imjcj.eu.org/VERSION").substr(44); |
32 |
| - // compare version number with _VERSION_ |
33 |
| - if (result != _VERSION_ + '\n') { |
34 |
| - cout << "Warning: Please update: \"https://junlang.imjcj.eu.org\"" << endl; |
35 |
| - } |
36 |
| - return; |
| 29 | + // get version number from https://junlang.imjcj.eu.org/VERSION |
| 30 | + string result = execute("curl -s https://junlang.imjcj.eu.org/VERSION"); |
| 31 | + result = result.substr(44); |
| 32 | + // compare version number with _VERSION_ |
| 33 | + if (result != _VERSION_ + '\n') { |
| 34 | + cout << "Warning: Please update: \"https://junlang.imjcj.eu.org\"" << endl; |
| 35 | + } |
| 36 | + return; |
37 | 37 | }
|
0 commit comments