summaryrefslogtreecommitdiff
path: root/tests/env.c
blob: 3dc57f74a98c8a1270ab1c0cdbb42ce779927808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

char hex[] = "0123456789ABCDEF";

char buf[20];
main(argc, argv, envp)
int argc;
char ** argv;
char ** envp;
{
   int i,j; char *p; char * str;
   int * arg = &argc;

   for(j=0; j<8; j++)
   {
      phex(arg);
      putstr(":");
      for(i=0; i<8; i++)
      {
         putstr(" ");
         phex(*arg++);
      }
      putstr("\n");
   }

#if 0
   str = alloca(sizeof(hex)+2);
   putstr("Alloca = ");
   phex(&str);
   putstr(",");
   phex(str);
   putstr("\n");
#endif

   p = (char*) &argc;

   putstr("ARGC="); phex(argc); putstr("\n");
   putstr("ARGV="); phex(argv); putstr("\n");
   putstr("ENVP="); phex(envp); putstr("\n");
   for(i=0; i<argc; i++)
   {
      phex(argv[i]);
      putstr(":");
      putstr(argv[i]);
      putstr("\n");
   }
   putstr("ENV=>\n");
   for(; *envp; envp++)
   {
      phex(envp);
      putstr(":");
      phex(*envp);
      putstr(":");
      putstr(*envp);
      putstr("\n");
   }
}

phex(val)
{
   int i;
   printf("%04x", val);
}

putstr(str)
{
   printf("%s", str);
}

#if 0
int global_var_that_needs_init = 0x201;

#asm
  loc	1		! Make sure the pointer is in the correct segment
auto_func:		! Label for bcc -M to work.
  .word	_init_vars	! Pointer to the autorun function
  .text			! So the function after is also in the correct seg.
#endasm

static void init_vars()
{
   global_var_that_needs_init = getuid();
}
#endif