Ignore:
Timestamp:
Apr 17, 2000, 4:26:04 AM (25 years ago)
Author:
bird
Message:

Much of the coding is done. But will have to select/change strategy for
getting the environment data soon.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/misc/env.c

    r3411 r3412  
    1 /* $Id: env.c,v 1.1 2000-04-17 01:56:50 bird Exp $
     1/* $Id: env.c,v 1.2 2000-04-17 02:26:04 bird Exp $
    22 *
    3  * Enviroment access functions
     3 * Environment access functions
    44 *
    55 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     
    99 */
    1010
     11/*******************************************************************************
     12*   Defined Constants And Macros                                               *
     13*******************************************************************************/
     14#define INCL_DOSERRORS                  /* Error codes */
     15#define INCL_OS2KRNL_VM                 /* OS2KRNL: Virtual Memory Management */
     16
    1117
    1218/*******************************************************************************
     
    1420*******************************************************************************/
    1521#include <os2.h>
     22
    1623#include "dev32.h"
    1724#include "dev32hlp.h"
     25#include "log.h"
     26#include "ptda.h"
     27#include "OS2Krnl.h"
    1828#include <string.h>
    1929
    2030#include "env.h"
    21 #include <infoseg.h>                    /* Infosegments definitions. */
    2231
    2332
    2433/**
    25  * Scans the given environment data for a given enviroment variable and returns
     34 * Scans the given environment data for a given environment variable and returns
    2635 * its value if found.
    2736 * @returns   Pointer to environment variable value for the variable given in
     
    7483/**
    7584 * Get the linear pointer to the environment data.
     85 *
    7686 * @returns   Pointer to environment data.
    7787 *            NULL on failure.
    7888 */
    79 const char *GetEnv()
     89const char *GetEnv(void)
    8090{
    8191    /*  There is probably two ways of getting the environment data for a the
     
    91101     */
    92102
    93     #if 0
    94     PPTDA   pPTDA;                      /* Current PTDA */
    95     PPTDA   pPTDAExecChild;             /* Current PTDAs pPTDAExecChild */
     103    #if 1
     104    PPTDA   pPTDACur;                   /* Pointer to the current (system context) PTDA */
     105    PPTDA   pPTDA;                      /* PTDA in question. */
    96106    USHORT  hobEnviron;                 /* Object handle of the environ block */
    97107    APIRET  rc;                         /* Return from VMObjHandleInfo. */
     
    103113     *  Get the current PTDA. (Fail if this call failes.)
    104114     *  IF pPTDAExecChild isn't NULL THEN try get environment for that first.
    105      *  IF failed or no pPTDAExecChild THEN try get enviroment from pPTDA.
     115     *  IF failed or no pPTDAExecChild THEN try get environment from pPTDA.
    106116     */
    107     pPTDA = ptdaGetCur();
    108     if (pPTDA == NULL)
     117    pPTDACur = ptdaGetCur();
     118    if (pPTDA != NULL)
     119    {
     120        pPTDA = ptdaGet_pPTDAExecChild(pPTDA);
     121        if (pPTDA != NULL)
     122        {
     123            hobEnviron = ptdaGet_ptda_environ(pPTDA);
     124            if (hobEnviron != 0)
     125            {
     126                rc = VMObjHandleInfo(hobEnviron, SSToDS(&ulAddr), SSToDS(&ushPTDA));
     127                if (rc == NO_ERROR)
     128                    return (const char *)ulAddr;
     129                kprintf(("GetEnv: VMObjHandleInfo failed with rc=%d for hob=0x%04x\n", rc, hobEnviron));
     130            }
     131        }
     132
     133        hobEnviron = ptdaGet_ptda_environ(pPTDACur);
     134        if (hobEnviron != 0)
     135        {
     136            rc = VMObjHandleInfo(hobEnviron, SSToDS(&ulAddr), SSToDS(&ushPTDA));
     137            if (rc != NO_ERROR)
     138            {
     139                kprintf(("GetEnv: VMObjHandleInfo failed with rc=%d for hob=0x%04x\n", rc, hobEnviron));
     140            }
     141        }
     142    }
     143    else
    109144    {
    110145        kprintf(("GetEnv: Failed to get current PTDA.\n"));
    111146    }
    112     pPTDAExecChild = ptdaGetpPTDAExecChild(pPTDA);
    113     if (pPTDAExecChild != NULL)
    114     {
    115         hobEnviron = ptdaGetptda_environ(pPTDAExecChild);
    116         if (hobEnviron != 0)
    117         {
    118             rc = VMObjHandleInfo(hobEnviron, &ulAddr, &ushPTDA);
    119             if (rc != NO_ERROR)
    120                 ulAddr = 0;
    121         }
    122     }
    123 
    124     if (ulAddr == 0) /* failed or non pPTDAExecChild */
    125     {
    126         hobEnviron = ptdaGetptda_environ(pPTDA);
    127         if (hobEnviron != 0)
    128         {
    129             rc = VMObjHandleInfo(hobEnviron, &ulAddr, &ushPTDA);
    130             if (rc != NO_ERROR)
    131                 ulAddr = 0;
    132         }
    133     }
    134147
    135148    return (const char *)ulAddr;
     149
    136150    #else
     151
    137152    struct InfoSegLDT * pLIS;           /* Pointer to local infosegment. */
    138153    PVOID               pv;             /* Address to return. */
     
    147162    {
    148163        kprintf(("GetEnv: Failed to get local info segment\n"));
    149         return NULL
     164        return NULL;
    150165    }
    151166
    152167    if (pLIS->LIS_AX <= 3)
    153168    {
    154         kprintf(("GetEnv: enviroment selector is %d, ie. NULL\n", pLIS->LIS_AX));
     169        kprintf(("GetEnv: environment selector is %d, ie. NULL\n", pLIS->LIS_AX));
    155170        return NULL;
    156171    }
Note: See TracChangeset for help on using the changeset viewer.