Release 950522
[wine.git] / loader / selector.c
blobd04e4f1a6fa79c4f2fd5c536d686dbbbba0ee0c3
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 <sys/types.h>
12 #include <sys/stat.h>
13 #include <fcntl.h>
14 #include <unistd.h>
16 #ifndef WINELIB
18 #ifdef __linux__
19 #include <sys/mman.h>
20 #include <linux/unistd.h>
21 #include <linux/head.h>
22 #include <linux/mman.h>
23 #include <linux/a.out.h>
24 #include <linux/ldt.h>
25 #endif
26 #if defined(__NetBSD__) || defined(__FreeBSD__)
27 #include <sys/mman.h>
28 #include <machine/segments.h>
29 #endif
31 #include "windows.h"
32 #include "ldt.h"
33 #include "wine.h"
34 #include "global.h"
35 #include "dlls.h"
36 #include "neexe.h"
37 #include "prototypes.h"
38 #include "module.h"
39 #include "stddebug.h"
40 /* #define DEBUG_SELECTORS */
41 #include "debug.h"
44 #define MAX_ENV_SIZE 16384 /* Max. environment size (ought to be dynamic) */
46 static HANDLE EnvironmentHandle = 0;
49 extern char WindowsPath[256];
51 extern char **environ;
55 WNDPROC GetWndProcEntry16( char *name )
57 WORD ordinal;
58 static HMODULE hModule = 0;
60 if (!hModule) hModule = GetModuleHandle( "WINPROCS" );
61 ordinal = MODULE_GetOrdinal( hModule, name );
62 return MODULE_GetEntryPoint( hModule, ordinal );
66 /***********************************************************************
67 * GetDOSEnvironment (KERNEL.131)
69 SEGPTR GetDOSEnvironment(void)
71 return WIN16_GlobalLock( EnvironmentHandle );
75 /**********************************************************************
76 * CreateEnvironment
78 static HANDLE CreateEnvironment(void)
80 HANDLE handle;
81 char **e;
82 char *p;
84 handle = GlobalAlloc( GMEM_MOVEABLE, MAX_ENV_SIZE );
85 if (!handle) return 0;
86 p = (char *) GlobalLock( handle );
89 * Fill environment with Windows path, the Unix environment,
90 * and program name.
92 strcpy(p, "PATH=");
93 strcat(p, WindowsPath);
94 p += strlen(p) + 1;
96 for (e = environ; *e; e++)
98 if (strncasecmp(*e, "path", 4))
100 strcpy(p, *e);
101 p += strlen(p) + 1;
105 *p++ = '\0';
108 * Display environment
110 p = (char *) GlobalLock( handle );
111 dprintf_selectors(stddeb, "Environment at %p\n", p);
112 for (; *p; p += strlen(p) + 1) dprintf_selectors(stddeb, " %s\n", p);
114 return handle;
119 /**********************************************************************
120 * CreateSelectors
122 void CreateSelectors(void)
124 if(!EnvironmentHandle) EnvironmentHandle = CreateEnvironment();
128 #endif /* ifndef WINELIB */