10 |
#include <stdexcept> |
#include <stdexcept> |
11 |
#include <time.h> |
#include <time.h> |
12 |
#include <sys/time.h> |
#include <sys/time.h> |
13 |
|
#include <sys/types.h> |
14 |
|
#include <sys/wait.h> |
15 |
|
#include <errno.h> |
16 |
#include <stdlib.h> |
#include <stdlib.h> |
17 |
|
|
18 |
#include <cstring> |
#include <cstring> |
269 |
|
|
270 |
string str_gsm2latin(string str) |
string str_gsm2latin(string str) |
271 |
{ |
{ |
272 |
for (unsigned i=0; i<str.size(); i++) { |
for (unsigned i=0; i<str.size(); i++) |
273 |
|
{ |
274 |
str.at(i) = char_def_alphabet_decode(str.at(i)); |
str.at(i) = char_def_alphabet_decode(str.at(i)); |
275 |
} |
} |
276 |
return str; |
return str; |
278 |
|
|
279 |
string str_latin2gsm(string str) |
string str_latin2gsm(string str) |
280 |
{ |
{ |
281 |
for (unsigned i=0; i<str.size(); i++) { |
for (unsigned i=0; i<str.size(); i++) |
282 |
|
{ |
283 |
str.at(i) = char_def_alphabet_encode(str.at(i)); |
str.at(i) = char_def_alphabet_encode(str.at(i)); |
284 |
} |
} |
285 |
return str; |
return str; |
286 |
} |
} |
287 |
|
|
288 |
|
/* deprecated, use HttpClient instead |
289 |
string readUrl(string url, string tempfile) |
string readUrl(string url, string tempfile) |
290 |
{ |
{ |
291 |
char buf[128000]; |
char buf[128000]; |
320 |
unlink(tempfile.c_str()); |
unlink(tempfile.c_str()); |
321 |
|
|
322 |
return document; |
return document; |
323 |
} |
}*/ |
324 |
|
|
325 |
|
|
326 |
|
|
423 |
return (pclose(p)); |
return (pclose(p)); |
424 |
} |
} |
425 |
|
|
426 |
|
int my_system2 (const char *command) |
427 |
|
{ |
428 |
|
int pid, status; |
429 |
|
|
430 |
|
if (command == 0) |
431 |
|
return 1; |
432 |
|
// printf("forking ...\n"); |
433 |
|
pid = fork(); |
434 |
|
if (pid == -1) |
435 |
|
return -1; |
436 |
|
if (pid == 0) |
437 |
|
{ |
438 |
|
char *argv[4]; |
439 |
|
argv[0] = (char*) "sh"; |
440 |
|
argv[1] = (char*) "-c"; |
441 |
|
argv[2] = (char *) command; |
442 |
|
argv[3] = 0; |
443 |
|
// printf("chaining ...\n"); |
444 |
|
execve("/bin/sh", argv, environ); |
445 |
|
// printf("Chaining failed!\n"); |
446 |
|
exit(127); |
447 |
|
} |
448 |
|
do |
449 |
|
{ |
450 |
|
// printf("Waiting on PID: %d\n",pid); |
451 |
|
if (waitpid(pid, &status, 0) == -1) |
452 |
|
{ |
453 |
|
// printf("erc: %d\n",errno); |
454 |
|
if (errno != EINTR) |
455 |
|
return -1; |
456 |
|
} |
457 |
|
else |
458 |
|
{ |
459 |
|
// printf("status: %d\n",status); |
460 |
|
return status; |
461 |
|
} |
462 |
|
} |
463 |
|
while (1); |
464 |
|
} |
465 |
|
|
466 |
|
|
467 |
string readfile(string filename) |
string readfile(string filename) |
468 |
{ |
{ |
469 |
string str; |
string str; |