| 1 | /* $Id: dbglocal.cpp,v 1.1 2001-06-13 04:45:32 bird Exp $ | 
|---|
| 2 | * | 
|---|
| 3 | * debug logging functions for OS/2 | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright 2000 Sander van Leeuwen | 
|---|
| 6 | * | 
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 8 | */ | 
|---|
| 9 |  | 
|---|
| 10 |  | 
|---|
| 11 | /******************************************************************************* | 
|---|
| 12 | *   Internal Functions                                                         * | 
|---|
| 13 | *******************************************************************************/ | 
|---|
| 14 | #include <os2wrap.h> | 
|---|
| 15 | #include <stdlib.h> | 
|---|
| 16 | #include <stdio.h> | 
|---|
| 17 | #include <string.h> | 
|---|
| 18 | #include "dbglocal.h" | 
|---|
| 19 |  | 
|---|
| 20 | #ifdef DEBUG | 
|---|
| 21 |  | 
|---|
| 22 | /******************************************************************************* | 
|---|
| 23 | *   Global Variables                                                           * | 
|---|
| 24 | *******************************************************************************/ | 
|---|
| 25 | USHORT DbgEnabled[DBG_MAXFILES] = {0}; | 
|---|
| 26 | USHORT DbgEnabledLvl2[DBG_MAXFILES] = {0}; | 
|---|
| 27 |  | 
|---|
| 28 | char  *DbgFileNames[DBG_MAXFILES] = | 
|---|
| 29 | { | 
|---|
| 30 | "vdmdbg", | 
|---|
| 31 | }; | 
|---|
| 32 |  | 
|---|
| 33 | /** | 
|---|
| 34 | * Parses the log env.vars and inits the DbgEnabled and DbgEnabledLvl2 | 
|---|
| 35 | * arrays accordingly. | 
|---|
| 36 | */ | 
|---|
| 37 | void ParseLogStatus() | 
|---|
| 38 | { | 
|---|
| 39 | char *pszEnvVar = getenv(DBG_ENVNAME); | 
|---|
| 40 | char *pszEnvVar2= getenv(DBG_ENVNAME_LVL2); | 
|---|
| 41 | char *pszDbgVar; | 
|---|
| 42 | int   i; | 
|---|
| 43 |  | 
|---|
| 44 | for (i = 0; i < DBG_MAXFILES; i++) | 
|---|
| 45 | { | 
|---|
| 46 | DbgEnabled[i] = 1; | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | if (pszEnvVar) | 
|---|
| 50 | { | 
|---|
| 51 | pszDbgVar = strstr(pszEnvVar, "dll"); | 
|---|
| 52 | if (pszDbgVar) | 
|---|
| 53 | { | 
|---|
| 54 | if (*(pszDbgVar-1) == '-') | 
|---|
| 55 | { | 
|---|
| 56 | for (i = 0; i < DBG_MAXFILES; i++) | 
|---|
| 57 | { | 
|---|
| 58 | DbgEnabled[i] = 0; | 
|---|
| 59 | } | 
|---|
| 60 | } | 
|---|
| 61 | } | 
|---|
| 62 | for (i = 0; i < DBG_MAXFILES; i++) | 
|---|
| 63 | { | 
|---|
| 64 | pszDbgVar = strstr(pszEnvVar, DbgFileNames[i]); | 
|---|
| 65 | if (pszDbgVar) | 
|---|
| 66 | { | 
|---|
| 67 | if (*(pszDbgVar-1) == '-') | 
|---|
| 68 | { | 
|---|
| 69 | DbgEnabled[i] = 0; | 
|---|
| 70 | } | 
|---|
| 71 | else if (*(pszDbgVar-1) == '+') | 
|---|
| 72 | { | 
|---|
| 73 | DbgEnabled[i] = 1; | 
|---|
| 74 | } | 
|---|
| 75 | } | 
|---|
| 76 | } | 
|---|
| 77 | } | 
|---|
| 78 | if (pszEnvVar2) | 
|---|
| 79 | { | 
|---|
| 80 | pszDbgVar = strstr(pszEnvVar2, "dll"); | 
|---|
| 81 | if (pszDbgVar) | 
|---|
| 82 | { | 
|---|
| 83 | if (*(pszDbgVar-1) == '+') | 
|---|
| 84 | { | 
|---|
| 85 | for (i = 0;i < DBG_MAXFILES; i++) | 
|---|
| 86 | { | 
|---|
| 87 | DbgEnabledLvl2[i] = 1; | 
|---|
| 88 | } | 
|---|
| 89 | } | 
|---|
| 90 | } | 
|---|
| 91 | for (i = 0; i < DBG_MAXFILES; i++) | 
|---|
| 92 | { | 
|---|
| 93 | pszDbgVar = strstr(pszEnvVar2, DbgFileNames[i]); | 
|---|
| 94 | if (pszDbgVar) | 
|---|
| 95 | { | 
|---|
| 96 | if (*(pszDbgVar-1) == '-') | 
|---|
| 97 | { | 
|---|
| 98 | DbgEnabledLvl2[i] = 0; | 
|---|
| 99 | } | 
|---|
| 100 | else if (*(pszDbgVar-1) == '+') | 
|---|
| 101 | { | 
|---|
| 102 | DbgEnabledLvl2[i] = 1; | 
|---|
| 103 | } | 
|---|
| 104 | } | 
|---|
| 105 | } | 
|---|
| 106 | } | 
|---|
| 107 | } | 
|---|
| 108 |  | 
|---|
| 109 | #endif | 
|---|