2 * Selector manipulation functions
4 * Copyright 1993 Robert J. Amstadt
5 * Copyright 1995 Alexandre Julliard
11 #include <sys/types.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>
26 #if defined(__NetBSD__) || defined(__FreeBSD__)
28 #include <machine/segments.h>
37 #include "prototypes.h"
40 /* #define DEBUG_SELECTORS */
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
)
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 /**********************************************************************
78 static HANDLE
CreateEnvironment(void)
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,
93 strcat(p
, WindowsPath
);
96 for (e
= environ
; *e
; e
++)
98 if (strncasecmp(*e
, "path", 4))
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
);
119 /**********************************************************************
122 void CreateSelectors(void)
124 if(!EnvironmentHandle
) EnvironmentHandle
= CreateEnvironment();
128 #endif /* ifndef WINELIB */