external/ppp
Revisión | 1661f734d42e48458fc62f5c6413c308481b4e5a (tree) |
---|---|
Tiempo | 2009-12-15 09:33:00 |
Autor | Chia-chi Yeh <chiachi@andr...> |
Commiter | Chia-chi Yeh |
Add support to get information from environment variables.
Bug: 2325838
Change-Id: I2e1df5a71aead40063f82cc0dda222f370ad4043
@@ -360,16 +360,39 @@ main(argc, argv) | ||
360 | 360 | */ |
361 | 361 | tty_init(); |
362 | 362 | |
363 | + progname = *argv; | |
364 | + | |
363 | 365 | #ifdef ANDROID_CHANGES |
364 | 366 | { |
365 | 367 | extern void pppox_init(); |
366 | 368 | pppox_init(); |
367 | 369 | privileged = 1; |
368 | 370 | } |
371 | + { | |
372 | + char *envargs = getenv("envargs"); | |
373 | + if (envargs) { | |
374 | + int i; | |
375 | + /* Decode the arguments in-place and count the number of them. | |
376 | + * They were hex encoded using [A-P] instead of [0-9A-F]. */ | |
377 | + for (argc = 0, i = 0; envargs[i] && envargs[i + 1]; i += 2) { | |
378 | + char c = ((envargs[i] - 'A') << 4) + (envargs[i + 1] - 'A'); | |
379 | + if (c == 0) { | |
380 | + ++argc; | |
381 | + } | |
382 | + envargs[i / 2 + 1] = c; | |
383 | + } | |
384 | + if (argc == 0 || (argv = malloc(sizeof(char *) * argc)) == NULL) { | |
385 | + fatal("Failed to parse envargs!"); | |
386 | + } | |
387 | + for (envargs[0] = 0, i = 0; i < argc; ++envargs) { | |
388 | + if (envargs[0] == 0) { | |
389 | + argv[i++] = &envargs[1]; | |
390 | + } | |
391 | + } | |
392 | + } | |
393 | + } | |
369 | 394 | #endif |
370 | 395 | |
371 | - progname = *argv; | |
372 | - | |
373 | 396 | /* |
374 | 397 | * Parse, in order, the system options file, the user's options file, |
375 | 398 | * and the command line arguments. |