Release 950727
[wine/multimedia.git] / loader / selector.c
blobab211bdeb371cfd49f84c1e31ca66286a69e01ed
1 /*
2 * Selector manipulation functions
4 * Copyright 1993 Robert J. Amstadt
5 * Copyright 1995 Alexandre Julliard
6 */
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <unistd.h>
13 #ifndef WINELIB
15 #include "windows.h"
16 #include "global.h"
17 #include "module.h"
18 #include "stddebug.h"
19 /* #define DEBUG_SELECTORS */
20 #include "debug.h"
23 #define MAX_ENV_SIZE 16384 /* Max. environment size (ought to be dynamic) */
25 static HANDLE EnvironmentHandle = 0;
28 extern char WindowsPath[256];
30 extern char **environ;
34 WNDPROC GetWndProcEntry16( char *name )
36 WORD ordinal;
37 static HMODULE hModule = 0;
39 if (!hModule) hModule = GetModuleHandle( "WINPROCS" );
40 ordinal = MODULE_GetOrdinal( hModule, name );
41 return MODULE_GetEntryPoint( hModule, ordinal );
45 /***********************************************************************
46 * GetDOSEnvironment (KERNEL.131)
48 SEGPTR GetDOSEnvironment(void)
50 return WIN16_GlobalLock( EnvironmentHandle );
54 /**********************************************************************
55 * CreateEnvironment
57 static HANDLE CreateEnvironment(void)
59 HANDLE handle;
60 char **e;
61 char *p;
63 handle = GlobalAlloc( GMEM_MOVEABLE, MAX_ENV_SIZE );
64 if (!handle) return 0;
65 p = (char *) GlobalLock( handle );
68 * Fill environment with Windows path, the Unix environment,
69 * and program name.
71 strcpy(p, "PATH=");
72 strcat(p, WindowsPath);
73 p += strlen(p) + 1;
75 for (e = environ; *e; e++)
77 if (strncasecmp(*e, "path", 4))
79 strcpy(p, *e);
80 p += strlen(p) + 1;
84 *p++ = '\0';
87 * Display environment
89 p = (char *) GlobalLock( handle );
90 dprintf_selectors(stddeb, "Environment at %p\n", p);
91 for (; *p; p += strlen(p) + 1) dprintf_selectors(stddeb, " %s\n", p);
93 return handle;
98 /**********************************************************************
99 * CreateSelectors
101 void CreateSelectors(void)
103 if(!EnvironmentHandle) EnvironmentHandle = CreateEnvironment();
107 #endif /* ifndef WINELIB */