arg_test.c 715 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Test application for argc and argv handling
  4. * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <unistd.h>
  11. int main(int argc, char **argv)
  12. {
  13. int i=0;
  14. char** index=__environ;
  15. #ifdef __powerpc__
  16. {
  17. unsigned long sp;
  18. sp = (unsigned long) __builtin_frame_address(0);
  19. if(sp&0xf){
  20. printf("stack pointer is unaligned! (%08lx)\n", sp);
  21. }
  22. }
  23. #endif
  24. printf("argc=%d\n", argc);
  25. for(i=0;i<argc;i++) {
  26. printf("argv[%d]='%s'\n", i, argv[i]);
  27. }
  28. i=0;
  29. while(*index) {
  30. printf("environ[%d]='%s'\n", i++, *index++);
  31. }
  32. exit(0);
  33. }