diff options
author | Chia-chi Yeh <chiachi@android.com> | 2009-12-15 03:55:47 +0800 |
---|---|---|
committer | Chia-chi Yeh <chiachi@android.com> | 2009-12-15 08:33:00 +0800 |
commit | 1661f734d42e48458fc62f5c6413c308481b4e5a (patch) | |
tree | 9d313bdf6a27499d031634f65ba6237c1559b700 | |
parent | a09909acb81d23631b63010a53d715c15e462071 (diff) | |
download | ppp-1661f734d42e48458fc62f5c6413c308481b4e5a.tar.gz |
Add support to get information from environment variables.android-sdk-2.1_r1android-2.1_r2.1sandroid-2.1_r2.1p2android-2.1_r2.1pandroid-2.1_r2android-2.1_r1eclair-sholes-release2eclair-releaseeclair-passion-release
Bug: 2325838
Change-Id: I2e1df5a71aead40063f82cc0dda222f370ad4043
-rw-r--r-- | pppd/main.c | 27 |
1 files changed, 25 insertions, 2 deletions
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. |