tools: Add support for generating cursor files from SVG.
[wine.git] / dlls / crtdll / crtdll_main.c
blobac5677f5cf8ddce5150ad7665bac06d1d72ad12e
1 /*
2 * Old C RunTime DLL - All functionality is provided by msvcrt.
4 * Copyright 2000 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
23 #include <stdarg.h>
24 #ifdef HAVE_SYS_STAT_H
25 # include <sys/stat.h>
26 #endif
28 #include "windef.h"
29 #include "winbase.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(crtdll);
35 /* from msvcrt */
36 extern void CDECL __getmainargs( int *argc, char ***argv, char ***envp,
37 int expand_wildcards, int *new_mode );
39 /* The following data items are not exported from msvcrt */
40 unsigned int CRTDLL__basemajor_dll = 0;
41 unsigned int CRTDLL__baseminor_dll = 0;
42 unsigned int CRTDLL__baseversion_dll = 0;
43 unsigned int CRTDLL__cpumode_dll = 0;
44 unsigned int CRTDLL__osmajor_dll = 0;
45 unsigned int CRTDLL__osminor_dll = 0;
46 unsigned int CRTDLL__osmode_dll = 0;
47 unsigned int CRTDLL__osversion_dll = 0;
49 /* dev_t is a short in crtdll but an unsigned int in msvcrt */
50 typedef short crtdll_dev_t;
52 struct crtdll_stat
54 crtdll_dev_t st_dev;
55 _ino_t st_ino;
56 unsigned short st_mode;
57 short st_nlink;
58 short st_uid;
59 short st_gid;
60 crtdll_dev_t st_rdev;
61 _off_t st_size;
62 time_t st_atime;
63 time_t st_mtime;
64 time_t st_ctime;
67 /* convert struct _stat from crtdll format to msvcrt format */
68 static void convert_struct_stat( struct crtdll_stat *dst, const struct _stat *src )
70 dst->st_dev = src->st_dev;
71 dst->st_ino = src->st_ino;
72 dst->st_mode = src->st_mode;
73 dst->st_nlink = src->st_nlink;
74 dst->st_uid = src->st_uid;
75 dst->st_gid = src->st_gid;
76 dst->st_rdev = src->st_rdev;
77 dst->st_size = src->st_size;
78 dst->st_atime = src->st_atime;
79 dst->st_mtime = src->st_mtime;
80 dst->st_ctime = src->st_ctime;
84 /*********************************************************************
85 * DllMain (CRTDLL.init)
87 BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
89 TRACE("(%p,%d,%p)\n",hinstDLL,fdwReason,lpvReserved);
91 if (fdwReason == DLL_PROCESS_ATTACH)
93 DWORD version = GetVersion();
95 DisableThreadLibraryCalls(hinstDLL);
97 CRTDLL__basemajor_dll = (version >> 24) & 0xFF;
98 CRTDLL__baseminor_dll = (version >> 16) & 0xFF;
99 CRTDLL__baseversion_dll = (version >> 16);
100 CRTDLL__cpumode_dll = 1; /* FIXME */
101 CRTDLL__osmajor_dll = (version>>8) & 0xFF;
102 CRTDLL__osminor_dll = (version & 0xFF);
103 CRTDLL__osmode_dll = 1; /* FIXME */
104 CRTDLL__osversion_dll = (version & 0xFFFF);
106 return TRUE;
110 /*********************************************************************
111 * __GetMainArgs (CRTDLL.@)
113 void CDECL __GetMainArgs( int *argc, char ***argv, char ***envp, int expand_wildcards )
115 int new_mode = 0;
116 __getmainargs( argc, argv, envp, expand_wildcards, &new_mode );
120 /*********************************************************************
121 * _fstat (CRTDLL.@)
123 int CDECL CRTDLL__fstat(int fd, struct crtdll_stat* buf)
125 struct _stat st;
126 int ret;
128 if (!(ret = _fstat( fd, &st ))) convert_struct_stat( buf, &st );
129 return ret;
133 /*********************************************************************
134 * _stat (CRTDLL.@)
136 int CDECL CRTDLL__stat(const char* path, struct crtdll_stat * buf)
138 struct _stat st;
139 int ret;
141 if (!(ret = _stat( path, &st ))) convert_struct_stat( buf, &st );
142 return ret;
146 /*********************************************************************
147 * _strdec (CRTDLL.@)
149 char * CDECL _strdec(const char *str1, const char *str2)
151 return (char *)(str2 - 1);
155 /*********************************************************************
156 * _strinc (CRTDLL.@)
158 char * CDECL _strinc(const char *str)
160 return (char *)(str + 1);
164 /*********************************************************************
165 * _strncnt (CRTDLL.@)
167 size_t CDECL _strncnt(const char *str, size_t maxlen)
169 size_t len = strlen(str);
170 return (len > maxlen) ? maxlen : len;
174 /*********************************************************************
175 * _strnextc (CRTDLL.@)
177 unsigned int CDECL _strnextc(const char *str)
179 return (unsigned char)str[0];
183 /*********************************************************************
184 * _strninc (CRTDLL.@)
186 char * CDECL _strninc(const char *str, size_t len)
188 return (char *)(str + len);
192 /*********************************************************************
193 * _strspnp (CRTDLL.@)
195 char * CDECL _strspnp( const char *str1, const char *str2)
197 str1 += strspn( str1, str2 );
198 return *str1 ? (char*)str1 : NULL;