Annotation of os2sdk/demos/examples/getenv/getenv.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Example of DOSGETENV usage
                      3:  *
                      4:  * This call gets the addresses of the environment strings and command
                      5:  * line arguments belonging to the current process
                      6:  *
                      7:  * Compile as: cl -AL -Lp -G2 getenv.c
                      8:  *
                      9:  * Copyright (C) Microsoft Corp. 1986
                     10:  */
                     11: 
                     12: #include  <doscalls.h>
                     13: 
                     14: main()
                     15: {
                     16:        unsigned int EnvSegment;      /* Segment handle to the env strings */
                     17:        unsigned int CmdOffset;       /* Offset within EnvSegment where the
                     18:                                          command line arguments can be found */
                     19:        char *arg;                    /* Pointer to data */
                     20: 
                     21:        DOSGETENV(&EnvSegment,&CmdOffset); /* Get environment information */
                     22: 
                     23:        /* Set arg to point to the environment strings */
                     24:        arg = (char *)((long)EnvSegment << 16);
                     25: 
                     26:        /* Print first environment string */
                     27:        printf("Environment parameter #1: %s\n",arg);
                     28: 
                     29:        /* Set arg to point to the command line arguments */
                     30:        arg = (char *)(((long)EnvSegment << 16) + CmdOffset);
                     31: 
                     32:        /* Print first command line argument */
                     33:        printf("Command line argument #1: %s\n",arg);
                     34: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.