298 |
return now; |
return now; |
299 |
} |
} |
300 |
|
|
301 |
int my_system(const char* cmd) |
int my_system(const char* cmd, std::string* response) |
302 |
{ |
{ |
303 |
FILE* p; |
FILE* p; |
304 |
if ((p = popen(cmd,"w")) == NULL) |
if ((p = popen(cmd,"r")) == NULL) |
305 |
return (-1); |
return (-1); |
306 |
|
|
307 |
|
if (response) |
308 |
|
{ |
309 |
|
std::string output; |
310 |
|
char buf[256]; |
311 |
|
while(!feof(p)) |
312 |
|
{ |
313 |
|
int len = fread(buf,1,255, p); |
314 |
|
buf[len] = 0; |
315 |
|
output += buf; |
316 |
|
} |
317 |
|
*response = output; |
318 |
|
} |
319 |
|
|
320 |
return (pclose(p)); |
return (pclose(p)); |
321 |
} |
} |
322 |
|
|