toaruos/userspace/stack-reaper.c
Kevin Lange deaa6ad513 Rough support for environment variables
- libc functions not implemented yet
- see `env` for an example of reading variables
- see `esh` for an example of how to set and maintain variables for
  sending to other applications

  Both of the above will be the basis for the libc implementation.
2012-10-07 20:46:35 -07:00

20 lines
493 B
C

#include <stdio.h>
int main(int argc, char ** argv) {
printf("Exploring the stack...\n");
unsigned int x = 0;
unsigned int nulls = 0;
while (1) {
if (!argv[x]) { ++nulls; }
printf("argv[%.2d] = [%p] %s\n", x, argv[x], argv[x]);
++x;
if (nulls == 2) { break; }
}
printf("[ELF AuxV]\n");
while (1) {
printf("auxv[%.2d] = %.2d -> 0x%x\n", x, (unsigned int)argv[x], (unsigned int)argv[x+1]);
if (argv[x] == 0) { break; } /* AT_NULL, technically, but that's 0 */
x += 2;
}
}