ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

msvcrt20.c
Go to the documentation of this file.
00001 /*
00002  * msvcrt20 implementation
00003  *
00004  * Copyright 2002 Alexandre Julliard
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #include <stdio.h>
00022 #define _CRT_PRECOMP_H
00023 #include <internal/tls.h>
00024 #include <stdlib.h>
00025 #include <windows.h>
00026 #include <internal/wine/msvcrt.h>
00027 #include <locale.h>
00028 #include <mbctype.h>
00029 
00030 #include "wine/debug.h"
00031 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
00032 
00033 /* EXTERNAL PROTOTYPES ********************************************************/
00034 
00035 extern int BlockEnvToEnvironA(void);
00036 extern int BlockEnvToEnvironW(void);
00037 extern void FreeEnvironment(char **environment);
00038 
00039 extern unsigned int _osplatform;
00040 extern unsigned int _osver;
00041 extern unsigned int _winminor;
00042 extern unsigned int _winmajor;
00043 extern unsigned int _winver;
00044 
00045 extern char* _acmdln;        /* pointer to ascii command line */
00046 extern wchar_t* _wcmdln;     /* pointer to wide character command line */
00047 #undef _environ
00048 extern char** _environ;      /* pointer to environment block */
00049 extern char** __initenv;     /* pointer to initial environment block */
00050 extern wchar_t** _wenviron;  /* pointer to environment block */
00051 extern wchar_t** __winitenv; /* pointer to initial environment block */
00052 
00053 extern void CDECL __getmainargs(int *argc, char** *argv, char** *envp,
00054                                 int expand_wildcards, int *new_mode);
00055 extern void CDECL __wgetmainargs(int *argc, WCHAR** *wargv, WCHAR** *wenvp,
00056                                  int expand_wildcards, int *new_mode);
00057 
00058 /* LIBRARY ENTRY POINT ********************************************************/
00059 
00060 BOOL
00061 WINAPI
00062 DllMain(PVOID hinstDll, ULONG dwReason, PVOID reserved)
00063 {
00064     OSVERSIONINFOW osvi;
00065     switch (dwReason)
00066     {
00067     case DLL_PROCESS_ATTACH:
00068         /* initialize version info */
00069         TRACE("Process Attach\n");
00070         osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
00071         GetVersionExW( &osvi );
00072         _winver     = (osvi.dwMajorVersion << 8) | osvi.dwMinorVersion;
00073         _winmajor   = osvi.dwMajorVersion;
00074         _winminor   = osvi.dwMinorVersion;
00075         _osplatform = osvi.dwPlatformId;
00076         _osver      = osvi.dwBuildNumber;
00077 
00078         /* create tls stuff */
00079         if (!msvcrt_init_tls())
00080           return FALSE;
00081 
00082         if (BlockEnvToEnvironA() < 0)
00083             return FALSE;
00084 
00085         if (BlockEnvToEnvironW() < 0)
00086         {
00087             FreeEnvironment(_environ);
00088             return FALSE;
00089         }
00090 
00091         _acmdln = _strdup(GetCommandLineA());
00092         _wcmdln = _wcsdup(GetCommandLineW());
00093 
00094         /* Initialization of the WINE code */
00095         msvcrt_init_mt_locks();
00096         //if(!msvcrt_init_locale()) {
00097         //    msvcrt_free_mt_locks();
00098         //    msvcrt_free_tls_mem();
00099         //    return FALSE;
00100         //}
00101         //msvcrt_init_math();
00102         msvcrt_init_io();
00103         //msvcrt_init_console();
00104         //msvcrt_init_args();
00105         //msvcrt_init_signals();
00106         _setmbcp(_MB_CP_LOCALE);
00107         TRACE("Attach done\n");
00108         break;
00109 
00110     case DLL_THREAD_ATTACH:
00111         //msvcrt_get_thread_data creates data when first called
00112         break;
00113 
00114     case DLL_THREAD_DETACH:
00115         msvcrt_free_tls_mem();
00116         break;
00117 
00118     case DLL_PROCESS_DETACH:
00119         TRACE("Detach\n");
00120         /* Deinit of the WINE code */
00121         msvcrt_free_io();
00122         msvcrt_free_mt_locks();
00123         //msvcrt_free_console();
00124         //msvcrt_free_args();
00125         //msvcrt_free_signals();
00126         msvcrt_free_tls_mem();
00127         if (!msvcrt_free_tls())
00128           return FALSE;
00129         //MSVCRT__free_locale(MSVCRT_locale);
00130 
00131     if (__winitenv && __winitenv != _wenviron)
00132             FreeEnvironment((char**)__winitenv);
00133         if (_wenviron)
00134             FreeEnvironment((char**)_wenviron);
00135 
00136     if (__initenv && __initenv != _environ)
00137             FreeEnvironment(__initenv);
00138         if (_environ)
00139             FreeEnvironment(_environ);
00140 
00141         TRACE("Detach done\n");
00142         break;
00143     }
00144 
00145     return TRUE;
00146 }
00147 
00148 /* LIBRARY EXPORTS ************************************************************/
00149 
00150 /*********************************************************************
00151  *      __getmainargs (MSVCRT20.@)
00152  *
00153  * new_mode is not a pointer in msvcrt20.
00154  */
00155 void CDECL MSVCRT20__getmainargs( int *argc, char** *argv, char** *envp,
00156                                   int expand_wildcards, int new_mode )
00157 {
00158     __getmainargs( argc, argv, envp, expand_wildcards, &new_mode );
00159 }
00160 
00161 /*********************************************************************
00162  *      __wgetmainargs (MSVCRT20.@)
00163  *
00164  * new_mode is not a pointer in msvcrt20.
00165  */
00166 void CDECL MSVCRT20__wgetmainargs( int *argc, WCHAR** *wargv, WCHAR** *wenvp,
00167                                    int expand_wildcards, int new_mode )
00168 {
00169     __wgetmainargs( argc, wargv, wenvp, expand_wildcards, &new_mode );
00170 }
00171 
00172 /* EOF */

Generated on Sun May 27 2012 04:25:21 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.