14887Schin /*********************************************************************** 24887Schin * * 34887Schin * This software is part of the ast package * 4*8462SApril.Chin@Sun.COM * Copyright (c) 1985-2008 AT&T Intellectual Property * 54887Schin * and is licensed under the * 64887Schin * Common Public License, Version 1.0 * 7*8462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 84887Schin * * 94887Schin * A copy of the License is available at * 104887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 124887Schin * * 134887Schin * Information and Software Systems Research * 144887Schin * AT&T Research * 154887Schin * Florham Park NJ * 164887Schin * * 174887Schin * Glenn Fowler <gsf@research.att.com> * 184887Schin * David Korn <dgk@research.att.com> * 194887Schin * Phong Vo <kpv@research.att.com> * 204887Schin * * 214887Schin ***********************************************************************/ 224887Schin #pragma prototyped 234887Schin 244887Schin /* 254887Schin * ast dynamic data initialization 264887Schin */ 274887Schin 284887Schin #ifdef _UWIN 294887Schin 304887Schin #define _std_def_cfree 1 314887Schin 324887Schin #include <sfio_t.h> 334887Schin #include <ast.h> 344887Schin 354887Schin #undef strcoll 364887Schin 374887Schin #include <ast_windows.h> 384887Schin 394887Schin extern Sfio_t _Sfstdin; 404887Schin extern Sfio_t _Sfstdout; 414887Schin extern Sfio_t _Sfstderr; 424887Schin 434887Schin #include "sfhdr.h" 444887Schin 454887Schin #undef sfstdin 464887Schin #undef sfstdout 474887Schin #undef sfstderr 484887Schin 494887Schin #if defined(__EXPORT__) 504887Schin #define extern __EXPORT__ 514887Schin #endif 524887Schin 534887Schin /* 544887Schin * for backward compatibility with early UNIX 554887Schin */ 564887Schin 574887Schin extern void 584887Schin cfree(void* addr) 594887Schin { 604887Schin free(addr); 614887Schin } 624887Schin 634887Schin extern void 644887Schin _ast_libinit(void* in, void* out, void* err) 654887Schin { 664887Schin Sfio_t* sp; 674887Schin 684887Schin sp = (Sfio_t*)in; 694887Schin *sp = _Sfstdin; 704887Schin sfstdin = sp; 714887Schin sp = (Sfio_t*)out; 724887Schin *sp = _Sfstdout; 734887Schin sfstdout = sp; 744887Schin sp = (Sfio_t*)err; 754887Schin *sp = _Sfstderr; 764887Schin sfstderr = sp; 774887Schin } 784887Schin 794887Schin extern void 804887Schin _ast_init(void) 814887Schin { 824887Schin struct _astdll* ap = _ast_getdll(); 834887Schin 844887Schin _ast_libinit(ap->_ast_stdin,ap->_ast_stdout,ap->_ast_stderr); 854887Schin } 864887Schin 874887Schin extern void 884887Schin _ast_exit(void) 894887Schin { 904887Schin if (_Sfcleanup) 914887Schin (*_Sfcleanup)(); 924887Schin } 934887Schin 944887Schin BOOL WINAPI 954887Schin DllMain(HINSTANCE hinst, DWORD reason, VOID* reserved) 964887Schin { 974887Schin switch (reason) 984887Schin { 994887Schin case DLL_PROCESS_ATTACH: 1004887Schin break; 1014887Schin case DLL_PROCESS_DETACH: 1024887Schin _ast_exit(); 1034887Schin break; 1044887Schin } 1054887Schin return 1; 1064887Schin } 1074887Schin 1084887Schin #else 1094887Schin 1104887Schin #include <ast.h> 1114887Schin 1124887Schin #if _dll_data_intercept && ( _DLL_BLD || _BLD_DLL ) 1134887Schin 1144887Schin #undef environ 1154887Schin 1164887Schin extern char** environ; 1174887Schin 1184887Schin struct _astdll _ast_dll = { &environ }; 1194887Schin 1204887Schin struct _astdll* 1214887Schin _ast_getdll(void) 1224887Schin { 1234887Schin return &_ast_dll; 1244887Schin } 1254887Schin 1264887Schin #else 1274887Schin 1284887Schin NoN(astdynamic) 1294887Schin 1304887Schin #endif 1314887Schin 1324887Schin #endif 133