X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fexternal-ppp.git;a=blobdiff_plain;f=pppd%2Fmain.c;fp=pppd%2Fmain.c;h=64efefe049e3625be136c6fc030b231e97e5692f;hp=adb57f17169df495fd713fc091e74977d1ffc797;hb=cd833afad15fedab2ca1f2c39ea2d450cd41c2df;hpb=6e2a095b1792c0e54f80e54521f2ec1d1e8e405a diff --git a/pppd/main.c b/pppd/main.c index adb57f1..64efefe 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -360,16 +360,39 @@ main(argc, argv) */ tty_init(); + progname = *argv; + #ifdef ANDROID_CHANGES { extern void pppox_init(); pppox_init(); privileged = 1; } + { + char *envargs = getenv("envargs"); + if (envargs) { + int i; + /* Decode the arguments in-place and count the number of them. + * They were hex encoded using [A-P] instead of [0-9A-F]. */ + for (argc = 0, i = 0; envargs[i] && envargs[i + 1]; i += 2) { + char c = ((envargs[i] - 'A') << 4) + (envargs[i + 1] - 'A'); + if (c == 0) { + ++argc; + } + envargs[i / 2 + 1] = c; + } + if (argc == 0 || (argv = malloc(sizeof(char *) * argc)) == NULL) { + fatal("Failed to parse envargs!"); + } + for (envargs[0] = 0, i = 0; i < argc; ++envargs) { + if (envargs[0] == 0) { + argv[i++] = &envargs[1]; + } + } + } + } #endif - progname = *argv; - /* * Parse, in order, the system options file, the user's options file, * and the command line arguments.