- Timestamp:
- Sep 5, 2001, 2:58:00 PM (24 years ago)
- Location:
- trunk/src
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/DPlayX/initterm.cpp
r5135 r6646 1 /* 1 /* $Id: initterm.cpp,v 1.7 2001-09-05 12:51:21 bird Exp $ 2 * 2 3 * DLL entry point 3 4 * … … 69 70 70 71 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/ 71 72 72 73 dllHandle = RegisterLxDll(hModule, DPLAYX_LibMain, (PVOID)&_Resource_PEResTab); 73 74 if(dllHandle == 0) -
trunk/src/ddraw/initterm.cpp
r5326 r6646 1 /* 1 /* $Id: initterm.cpp,v 1.19 2001-09-05 12:50:39 bird Exp $ 2 * 2 3 * DLL entry point 3 4 * … … 91 92 case 0 : 92 93 { 93 94 94 APIRET rc; 95 95 96 #ifdef __IBMCPP__ 96 97 ctordtorInit(); … … 99 100 char *endofpath = strrchr(ddrawPath, '\\'); 100 101 if (endofpath) 101 102 *(endofpath+1) = '\0'; 102 103 103 104 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/ … … 107 108 IMAGE_SUBSYSTEM_WINDOWS_GUI); 108 109 if (dllHandle == 0) 109 110 return 0UL; 110 111 111 112 rc = DosExitList(EXITLIST_NONCOREDLL | EXLST_ADD, cleanup); 112 113 if (rc) 113 114 return 0UL; 114 115 115 116 break; … … 117 118 case 1 : 118 119 if(dllHandle) { 119 120 UnregisterLxDll(dllHandle); 120 121 } 121 122 break; -
trunk/src/ddraw/os2fsdd.cpp
r5330 r6646 1 /* 1 /* $Id: os2fsdd.cpp,v 1.2 2001-09-05 12:50:39 bird Exp $ 2 * 2 3 * Few routines for full-screen DirectDraw on OS/2 3 4 * -
trunk/src/driverdll/testdrv.cpp
r6457 r6646 1 /* $Id: testdrv.cpp,v 1.3 2001-09-05 12:52:27 bird Exp $ */ 1 2 //****************************************************************************** 2 3 //****************************************************************************** … … 16 17 #define INCL_DOSPROCESS /* DOS Process values */ 17 18 #define INCL_DOSMISC /* DOS Miscellanous values */ 18 #include <os2wrap.h> 19 #include <os2wrap.h> //Odin32 OS/2 api wrappers 19 20 20 21 #include <winconst.h> … … 24 25 #include <win\winioctl.h> 25 26 26 #define TESTDRV_CATEGORY 27 #define TESTDRV_CATEGORY 0x40 27 28 28 29 //****************************************************************************** … … 54 55 55 56 tryopen: 56 rc = DosOpen( 57 58 59 60 61 62 63 57 rc = DosOpen( "TESTDRV$", /* File path name */ 58 &hfFileHandle, /* File handle */ 59 &ulAction, /* Action taken */ 60 0, 61 FILE_NORMAL, 62 FILE_OPEN, 63 sharetype, 64 0L); /* No extended attribute */ 64 65 65 66 if(rc == ERROR_TOO_MANY_OPEN_FILES) { … … 67 68 LONG ReqCount = 32; 68 69 69 70 71 72 73 74 75 70 rc = DosSetRelMaxFH(&ReqCount, &CurMaxFH); 71 if(rc) { 72 dprintf(("DosSetRelMaxFH returned %d", rc)); 73 return rc; 74 } 75 dprintf(("DosOpen failed -> increased nr open files to %d", CurMaxFH)); 76 goto tryopen; 76 77 } 77 78 78 79 if(rc == NO_ERROR) { 79 80 return hfFileHandle; 80 81 } 81 82 else return -1; … … 105 106 *lpBytesReturned = nOutBufferSize; 106 107 107 rc = DosDevIOCtl(hDevice, TESTDRV_CATEGORY, ioctl, 108 rc = DosDevIOCtl(hDevice, TESTDRV_CATEGORY, ioctl, 108 109 lpInBuffer, nInBufferSize, &nInBufferSize, 109 110 lpOutBuffer, nOutBufferSize, lpBytesReturned); -
trunk/src/dsound/initterm.cpp
r5305 r6646 1 /* 1 /* $Id: initterm.cpp,v 1.17 2001-09-05 12:53:02 bird Exp $ 2 * 2 3 * DLL entry point 3 4 * -
trunk/src/gdi32/initgdi32.cpp
r6467 r6646 1 /* 1 /* $Id: initgdi32.cpp,v 1.5 2001-09-05 12:53:52 bird Exp $ 2 * 2 3 * DLL entry point 3 4 * … … 34 35 #include <odinlx.h> 35 36 #include <misc.h> /*PLF Wed 98-03-18 23:18:15*/ 36 #define DBG_LOCALLOG 37 #define DBG_LOCALLOG DBG_initterm 37 38 #include "dbglocal.h" 38 39 #include "region.h" … … 51 52 { 52 53 case DLL_PROCESS_ATTACH: 53 54 return TRUE; 54 55 55 56 case DLL_THREAD_ATTACH: 56 57 case DLL_THREAD_DETACH: 57 58 return TRUE; 58 59 59 60 case DLL_PROCESS_DETACH: 60 61 61 ctordtorTerm(); 62 return TRUE; 62 63 } 63 64 return FALSE; … … 88 89 InitializeKernel32(); 89 90 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/ 90 91 91 if(InitRegionSpace() == FALSE) { 92 return 0UL; 92 93 } 93 94 dllHandle = RegisterLxDll(hModule, OdinLibMain, (PVOID)&gdi32_PEResTab, 94 95 GDI32_MAJORIMAGE_VERSION, GDI32_MINORIMAGE_VERSION, 95 96 IMAGE_SUBSYSTEM_NATIVE); 96 if(dllHandle == 0) 97 97 if(dllHandle == 0) 98 return 0UL; 98 99 99 100 dprintf(("gdi32 init %s %s (%x)", __DATE__, __TIME__, inittermGdi32)); … … 102 103 case 1 : 103 104 if(dllHandle) { 104 105 UnregisterLxDll(dllHandle); 105 106 } 106 107 break; -
trunk/src/gdi32/initterm.cpp
r6467 r6646 1 /* 1 /* $Id: initterm.cpp,v 1.20 2001-09-05 12:53:52 bird Exp $ 2 * 2 3 * DLL entry point 3 4 * … … 34 35 #include <odinlx.h> 35 36 #include <misc.h> /*PLF Wed 98-03-18 23:18:15*/ 36 #define DBG_LOCALLOG 37 #define DBG_LOCALLOG DBG_initterm 37 38 #include "dbglocal.h" 38 39 #include "region.h" -
trunk/src/imagehlp/initterm.cpp
r5135 r6646 1 /* 1 /* $Id: initterm.cpp,v 1.7 2001-09-05 12:55:49 bird Exp $ 2 * 2 3 * DLL entry point 3 4 * … … 53 54 case DLL_THREAD_ATTACH: 54 55 case DLL_THREAD_DETACH: 55 56 return IMAGEHLP_LibMain(hinstDLL, fdwReason, fImpLoad); 56 57 57 58 case DLL_PROCESS_DETACH: 58 59 60 59 IMAGEHLP_LibMain(hinstDLL, fdwReason, fImpLoad); 60 ctordtorTerm(); 61 return TRUE; 61 62 } 62 63 return FALSE; … … 88 89 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/ 89 90 90 91 if(dllHandle == 0) 92 91 dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab); 92 if(dllHandle == 0) 93 return 0UL; 93 94 94 95 break; 95 96 case 1 : 96 97 if(dllHandle) { 97 98 UnregisterLxDll(dllHandle); 98 99 } 99 100 break; -
trunk/src/kernel32/codepage.cpp
r5764 r6646 1 /* 1 /* $Id: codepage.cpp,v 1.17 2001-09-05 12:57:58 bird Exp $ 2 * 2 3 * Code page functions 3 4 * 4 5 * Based on Wine code (memory\codepage.c) 5 * 6 * 6 7 * Copyright 2000 Alexandre Julliard 7 8 * … … 25 26 #include "codepage.h" 26 27 27 #define DBG_LOCALLOG 28 #define DBG_LOCALLOG DBG_codepage 28 29 #include "dbglocal.h" 29 30 #endif … … 92 93 93 94 if (!ansi_cptable) init_codepages(); /* just in case */ 94 95 95 96 if ((table = get_locale_cp( lcid, LOCALE_IDEFAULTANSICODEPAGE ))) ansi_cptable = table; 96 97 if ((table = get_locale_cp( lcid, LOCALE_IDEFAULTMACCODEPAGE ))) mac_cptable = table; … … 197 198 #endif 198 199 199 if (!table) 200 if (!table) 200 201 { 201 202 SetLastError( ERROR_INVALID_PARAMETER ); … … 366 367 * dstlen [in] Length of destination buffer 367 368 * defchar [in] Default character to use for conversion if no exact 368 * 369 * conversion can be made 369 370 * used [out] Set if default character was used in the conversion 370 371 * -
trunk/src/kernel32/hmmailslot.cpp
r5587 r6646 1 /* 1 /* $Id: hmmailslot.cpp,v 1.2 2001-09-05 12:57:58 bird Exp $ 2 * 2 3 * Win32 mailslot APIs 3 4 * … … 22 23 #include "dbglocal.h" 23 24 24 HMMailSlotInfo::HMMailSlotInfo(LPCSTR lpszName, HANDLE hPipe, DWORD nMaxMessageSize, 25 HMMailSlotInfo::HMMailSlotInfo(LPCSTR lpszName, HANDLE hPipe, DWORD nMaxMessageSize, 25 26 DWORD lReadTimeout, BOOL fServer, 26 27 LPSECURITY_ATTRIBUTES lpSecurityAttributes) … … 129 130 strcat(pipename, lpName); 130 131 //TODO: lookup name and fail if exists 131 hPipe = CreateNamedPipeA(pipename, PIPE_ACCESS_INBOUND, 132 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT, 133 PIPE_UNLIMITED_INSTANCES, MAILSLOT_SIZE, 134 (nMaxMessageSize) ? nMaxMessageSize : MAILSLOT_SIZE, 132 hPipe = CreateNamedPipeA(pipename, PIPE_ACCESS_INBOUND, 133 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT, 134 PIPE_UNLIMITED_INSTANCES, MAILSLOT_SIZE, 135 (nMaxMessageSize) ? nMaxMessageSize : MAILSLOT_SIZE, 135 136 lReadTimeout, lpSecurityAttributes); 136 137 137 if(hPipe == INVALID_HANDLE_VALUE) { 138 if(hPipe == INVALID_HANDLE_VALUE) { 138 139 dprintf(("CreateMailslotA: unable to create pipe %s", pipename)); 139 140 return FALSE; … … 146 147 } 147 148 else 148 if(lReadTimeout != 0) { 149 if(lReadTimeout != 0) { 149 150 dprintf(("WARNING: timeout %x not supported", lReadTimeout)); 150 151 } … … 168 169 * Variables : 169 170 * Result : 170 * Remark : 171 * Remark : 171 172 * Status : NO_ERROR - API succeeded 172 173 * other - what is to be set in SetLastError … … 202 203 pHMHandleData->dwFlags, 0); 203 204 204 if(hPipe == INVALID_HANDLE_VALUE) { 205 if(hPipe == INVALID_HANDLE_VALUE) { 205 206 if(pipename[11] == '*') { 206 207 dprintf(("pipename with asterix not supported; connect only to one mailslot")); -
trunk/src/kernel32/initkernel32.cpp
r6468 r6646 1 /* 1 /* $Id: initkernel32.cpp,v 1.7 2001-09-05 12:57:58 bird Exp $ 2 * 2 3 * KERNEL32 DLL entry point 3 4 * … … 84 85 APIRET rc; 85 86 ULONG ulSysinfo, version[2]; 86 87 87 88 /*-------------------------------------------------------------------------*/ 88 89 /* If ulFlag is zero then the DLL is being loaded so initialization should */ -
trunk/src/kernel32/initterm.cpp
r6468 r6646 1 /* 1 /* $Id: initterm.cpp,v 1.63 2001-09-05 12:57:58 bird Exp $ 2 * 2 3 * KERNEL32 DLL entry point 3 4 * … … 88 89 APIRET rc; 89 90 ULONG ulSysinfo, version[2]; 90 91 91 92 /*-------------------------------------------------------------------------*/ 92 93 /* If ulFlag is zero then the DLL is being loaded so initialization should */ … … 122 123 } 123 124 } 124 125 125 126 rc = inittermKernel32(hModule, ulFlag); 126 127 break; -
trunk/src/kernel32/mailslot.cpp
r5587 r6646 1 /* 1 /* $Id: mailslot.cpp,v 1.2 2001-09-05 12:57:59 bird Exp $ 2 * 2 3 * Win32 mailslot APIs 3 4 * … … 37 38 * If the function fails, the return value is INVALID_HANDLE_VALUE. 38 39 * Remark : 39 * Status : 40 * Status : 40 41 * 41 42 * Author : SvL … … 66 67 * If the function fails, the return value is INVALID_HANDLE_VALUE. 67 68 * Remark : 68 * Status : 69 * Status : 69 70 * 70 71 * Author : SvL … … 96 97 * Result : TRUE / FALSE 97 98 * Remark : 98 * Status : 99 * Status : 99 100 * 100 101 * Author : SvL … … 120 121 * Result : TRUE / FALSE 121 122 * Remark : 122 * Status : 123 * Status : 123 124 * 124 125 * Author : SvL -
trunk/src/kernel32/module.cpp
r5587 r6646 1 /* 1 /* $Id: module.cpp,v 1.3 2001-09-05 12:57:59 bird Exp $ 2 * 2 3 * GetBinaryTypeA/W (Wine Port) 3 4 * … … 13 14 #include <misc.h> 14 15 15 #define DBG_LOCALLOG 16 #define DBG_LOCALLOG DBG_module 16 17 #include "dbglocal.h" 17 18 … … 38 39 || (!(ReadFile(hfile, modtab, ne->ne_cmod*sizeof(WORD), &len, NULL))) 39 40 || (len != ne->ne_cmod*sizeof(WORD)) ) 40 41 goto broken; 41 42 42 43 /* read imported names table */ … … 45 46 || (!(ReadFile(hfile, nametab, ne->ne_enttab - ne->ne_imptab, &len, NULL))) 46 47 || (len != ne->ne_enttab - ne->ne_imptab) ) 47 48 goto broken; 48 49 49 50 for (i=0; i < ne->ne_cmod; i++) 50 51 { 51 52 53 54 55 56 57 58 52 LPSTR module = &nametab[modtab[i]]; 53 TRACE("modref: %.*s\n", module[0], &module[1]); 54 if (!(strncmp(&module[1], "KERNEL", module[0]))) 55 { /* very old Windows file */ 56 MESSAGE("This seems to be a very old (pre-3.0) Windows executable. Expect crashes, especially if this is a real-mode binary !\n"); 57 type = SCS_WOW_BINARY; 58 goto good; 59 } 59 60 } 60 61 … … 107 108 /* Seek to the start of the file and read the DOS header information. 108 109 */ 109 if ( SetFilePointer( hfile, 0, NULL, SEEK_SET ) != -1 110 if ( SetFilePointer( hfile, 0, NULL, SEEK_SET ) != -1 110 111 && ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL ) 111 112 && len == sizeof(mz_header) ) … … 132 133 ( mz_header.e_lfarlc >= sizeof(IMAGE_DOS_HEADER) ) ) 133 134 if ( mz_header.e_lfanew >= sizeof(IMAGE_DOS_HEADER) 134 && SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ) != -1 135 && SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ) != -1 135 136 && ReadFile( hfile, magic, sizeof(magic), &len, NULL ) 136 137 && len == sizeof(magic) ) … … 162 163 * "extended header is a Windows executable (NE) 163 164 * header." This can mean either a 16-bit OS/2 164 * or a 16-bit Windows or even a DOS program 165 * or a 16-bit Windows or even a DOS program 165 166 * (running under a DOS extender). To decide 166 167 * which, we'll have to read the NE header. … … 168 169 169 170 IMAGE_OS2_HEADER ne; 170 if ( SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ) != -1 171 if ( SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET ) != -1 171 172 && ReadFile( hfile, &ne, sizeof(ne), &len, NULL ) 172 173 && len == sizeof(ne) ) … … 177 178 case 5: *lpBinaryType = SCS_DOS_BINARY; return TRUE; 178 179 default: *lpBinaryType = 179 180 180 MODULE_Decide_OS2_OldWin(hfile, &mz_header, &ne); 181 return TRUE; 181 182 } 182 183 } … … 187 188 { 188 189 /* Unknown extended header, but this file is nonetheless 189 190 DOS-executable. 190 191 */ 191 192 *lpBinaryType = SCS_DOS_BINARY; 192 193 return TRUE; 193 194 } 194 195 } -
trunk/src/kernel32/ole2nls.cpp
r6607 r6646 1 /* 2 * National Language Support library 1 /* $Id: ole2nls.cpp,v 1.14 2001-09-05 12:57:59 bird Exp $ 3 2 * 4 * Copyright 1995 Martin von Loewis 3 * National Language Support library 4 * 5 * Copyright 1995 Martin von Loewis 5 6 * Copyright 1998 David Lee Lambert 6 7 * Copyright 2000 Julio César Gázquez … … 41 42 #include <unicode.h> 42 43 43 #define DBG_LOCALLOG 44 #define DBG_LOCALLOG DBG_kernel32 44 45 #include "dbglocal.h" 45 46 … … 49 50 DEFAULT_DEBUG_CHANNEL(string); 50 51 51 /* Locale name to id map. used by EnumSystemLocales, GetLocaleInfoA 52 /* Locale name to id map. used by EnumSystemLocales, GetLocaleInfoA 52 53 * MUST contain all #defines from winnls.h 53 54 * last entry has NULL name, 0 id. 54 */ 55 #define LOCALE_ENTRY(x) 55 */ 56 #define LOCALE_ENTRY(x) {#x,LOCALE_##x} 56 57 static const struct tagLOCALE_NAME2ID { 57 const char 58 LCTYPE 58 const char *name; 59 LCTYPE id; 59 60 } locale_name2id[]= { 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 61 LOCALE_ENTRY(ILANGUAGE), 62 LOCALE_ENTRY(SLANGUAGE), 63 LOCALE_ENTRY(SENGLANGUAGE), 64 LOCALE_ENTRY(SABBREVLANGNAME), 65 LOCALE_ENTRY(SNATIVELANGNAME), 66 LOCALE_ENTRY(ICOUNTRY), 67 LOCALE_ENTRY(SCOUNTRY), 68 LOCALE_ENTRY(SENGCOUNTRY), 69 LOCALE_ENTRY(SABBREVCTRYNAME), 70 LOCALE_ENTRY(SNATIVECTRYNAME), 71 LOCALE_ENTRY(IDEFAULTLANGUAGE), 72 LOCALE_ENTRY(IDEFAULTCOUNTRY), 73 LOCALE_ENTRY(IDEFAULTCODEPAGE), 74 LOCALE_ENTRY(IDEFAULTANSICODEPAGE), 75 LOCALE_ENTRY(IDEFAULTMACCODEPAGE), 76 LOCALE_ENTRY(SLIST), 77 LOCALE_ENTRY(IMEASURE), 78 LOCALE_ENTRY(SDECIMAL), 79 LOCALE_ENTRY(STHOUSAND), 80 LOCALE_ENTRY(SGROUPING), 81 LOCALE_ENTRY(IDIGITS), 82 LOCALE_ENTRY(ILZERO), 83 LOCALE_ENTRY(INEGNUMBER), 84 LOCALE_ENTRY(SNATIVEDIGITS), 85 LOCALE_ENTRY(SCURRENCY), 86 LOCALE_ENTRY(SINTLSYMBOL), 87 LOCALE_ENTRY(SMONDECIMALSEP), 88 LOCALE_ENTRY(SMONTHOUSANDSEP), 89 LOCALE_ENTRY(SMONGROUPING), 90 LOCALE_ENTRY(ICURRDIGITS), 91 LOCALE_ENTRY(IINTLCURRDIGITS), 92 LOCALE_ENTRY(ICURRENCY), 93 LOCALE_ENTRY(INEGCURR), 94 LOCALE_ENTRY(SDATE), 95 LOCALE_ENTRY(STIME), 96 LOCALE_ENTRY(SSHORTDATE), 97 LOCALE_ENTRY(SLONGDATE), 98 LOCALE_ENTRY(STIMEFORMAT), 99 LOCALE_ENTRY(IDATE), 100 LOCALE_ENTRY(ILDATE), 101 LOCALE_ENTRY(ITIME), 102 LOCALE_ENTRY(ITIMEMARKPOSN), 103 LOCALE_ENTRY(ICENTURY), 104 LOCALE_ENTRY(ITLZERO), 105 LOCALE_ENTRY(IDAYLZERO), 106 LOCALE_ENTRY(IMONLZERO), 107 LOCALE_ENTRY(S1159), 108 LOCALE_ENTRY(S2359), 109 LOCALE_ENTRY(ICALENDARTYPE), 110 LOCALE_ENTRY(IOPTIONALCALENDAR), 111 LOCALE_ENTRY(IFIRSTDAYOFWEEK), 112 LOCALE_ENTRY(IFIRSTWEEKOFYEAR), 113 LOCALE_ENTRY(SDAYNAME1), 114 LOCALE_ENTRY(SDAYNAME2), 115 LOCALE_ENTRY(SDAYNAME3), 116 LOCALE_ENTRY(SDAYNAME4), 117 LOCALE_ENTRY(SDAYNAME5), 118 LOCALE_ENTRY(SDAYNAME6), 119 LOCALE_ENTRY(SDAYNAME7), 120 LOCALE_ENTRY(SABBREVDAYNAME1), 121 LOCALE_ENTRY(SABBREVDAYNAME2), 122 LOCALE_ENTRY(SABBREVDAYNAME3), 123 LOCALE_ENTRY(SABBREVDAYNAME4), 124 LOCALE_ENTRY(SABBREVDAYNAME5), 125 LOCALE_ENTRY(SABBREVDAYNAME6), 126 LOCALE_ENTRY(SABBREVDAYNAME7), 127 LOCALE_ENTRY(SMONTHNAME1), 128 LOCALE_ENTRY(SMONTHNAME2), 129 LOCALE_ENTRY(SMONTHNAME3), 130 LOCALE_ENTRY(SMONTHNAME4), 131 LOCALE_ENTRY(SMONTHNAME5), 132 LOCALE_ENTRY(SMONTHNAME6), 133 LOCALE_ENTRY(SMONTHNAME7), 134 LOCALE_ENTRY(SMONTHNAME8), 135 LOCALE_ENTRY(SMONTHNAME9), 136 LOCALE_ENTRY(SMONTHNAME10), 137 LOCALE_ENTRY(SMONTHNAME11), 138 LOCALE_ENTRY(SMONTHNAME12), 139 LOCALE_ENTRY(SMONTHNAME13), 140 LOCALE_ENTRY(SABBREVMONTHNAME1), 141 LOCALE_ENTRY(SABBREVMONTHNAME2), 142 LOCALE_ENTRY(SABBREVMONTHNAME3), 143 LOCALE_ENTRY(SABBREVMONTHNAME4), 144 LOCALE_ENTRY(SABBREVMONTHNAME5), 145 LOCALE_ENTRY(SABBREVMONTHNAME6), 146 LOCALE_ENTRY(SABBREVMONTHNAME7), 147 LOCALE_ENTRY(SABBREVMONTHNAME8), 148 LOCALE_ENTRY(SABBREVMONTHNAME9), 149 LOCALE_ENTRY(SABBREVMONTHNAME10), 150 LOCALE_ENTRY(SABBREVMONTHNAME11), 151 LOCALE_ENTRY(SABBREVMONTHNAME12), 152 LOCALE_ENTRY(SABBREVMONTHNAME13), 153 LOCALE_ENTRY(SPOSITIVESIGN), 154 LOCALE_ENTRY(SNEGATIVESIGN), 155 LOCALE_ENTRY(IPOSSIGNPOSN), 156 LOCALE_ENTRY(INEGSIGNPOSN), 157 LOCALE_ENTRY(IPOSSYMPRECEDES), 158 LOCALE_ENTRY(IPOSSEPBYSPACE), 159 LOCALE_ENTRY(INEGSYMPRECEDES), 160 LOCALE_ENTRY(INEGSEPBYSPACE), 161 LOCALE_ENTRY(FONTSIGNATURE), 162 LOCALE_ENTRY(SISO639LANGNAME), 163 LOCALE_ENTRY(SISO3166CTRYNAME), 164 {NULL,0} 164 165 }; 165 166 … … 168 169 #ifndef __WIN32OS2__ 169 170 /*********************************************************************** 170 * 171 * 171 * GetUserDefaultLCID (KERNEL32.@) 172 * GetUserDefaultLCID (OLE2NLS.1) 172 173 */ 173 174 LCID WINAPI GetUserDefaultLCID(void) 174 175 { 175 176 return MAKELCID( GetUserDefaultLangID() , SORT_DEFAULT ); 176 177 } 177 178 178 179 /*********************************************************************** 179 * 180 * 180 * GetSystemDefaultLCID (KERNEL32.@) 181 * GetSystemDefaultLCID (OLE2NLS.2) 181 182 */ 182 183 LCID WINAPI GetSystemDefaultLCID(void) 183 184 { 184 185 return GetUserDefaultLCID(); 185 186 } 186 187 #endif //__WIN32OS2__ … … 222 223 if(l_data->lang && strlen(l_data->lang) > 0 && !strcasecmp(l_data->lang, buf_language)) 223 224 { 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 225 if(l_data->country && strlen(l_data->country) > 0) 226 { 227 if(!strcasecmp(l_data->country, buf_country)) 228 { 229 l_data->found_lang_id[0] = LangID; 230 l_data->n_found = 1; 231 TRACE("Found lang_id %04X for %s_%s\n", LangID, l_data->lang, l_data->country); 232 return FALSE; /* stop enumeration */ 233 } 234 } 235 else /* l_data->country not specified */ 236 { 237 if(l_data->n_found < NLS_MAX_LANGUAGES) 238 { 239 l_data->found_lang_id[l_data->n_found] = LangID; 240 strncpy(l_data->found_country[l_data->n_found], buf_country, 3); 241 strncpy(l_data->found_language[l_data->n_found], buf_language, 3); 242 l_data->n_found++; 243 TRACE("Found lang_id %04X for %s\n", LangID, l_data->lang); 244 return TRUE; /* continue search */ 245 } 246 } 246 247 } 247 248 … … 256 257 if(l_data->lang && strlen(l_data->lang) > 0 && !strcasecmp(l_data->lang, buf_en_language)) 257 258 { 258 259 260 261 262 259 l_data->found_lang_id[l_data->n_found] = LangID; 260 strncpy(l_data->found_country[l_data->n_found], buf_country, 3); 261 strncpy(l_data->found_language[l_data->n_found], buf_language, 3); 262 l_data->n_found++; 263 TRACE("Found lang_id %04X for %s\n", LangID, l_data->lang); 263 264 } 264 265 … … 270 271 * 271 272 * INPUT: 272 * 273 * 274 * 275 * 273 * Lang: a string whose two first chars are the iso name of a language. 274 * Country: a string whose two first chars are the iso name of country 275 * Charset: a string defining the chossen charset encoding 276 * Dialect: a string defining a variation of the locale 276 277 * 277 * 278 * 278 * all those values are from the standardized format of locale 279 * name in unix which is: Lang[_Country][.Charset][@Dialect] 279 280 * 280 281 * RETURNS: 281 * 282 * the numeric code of the language used by Windows 282 283 * 283 284 * FIXME: Charset and Dialect are not handled … … 290 291 if(!Lang) 291 292 { 292 293 293 l_data.found_lang_id[0] = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT); 294 goto END; 294 295 } 295 296 … … 298 299 299 300 if(Country && strlen(Country) > 0) 300 301 strncpy(l_data.country, Country, sizeof(l_data.country)); 301 302 302 303 EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA, 303 304 (LPCSTR)LOCALE_ILANGUAGE, NLS_FindLanguageID_ProcA, (LONG)&l_data); 304 305 305 306 strcpy(lang_string, l_data.lang); 306 307 if(l_data.country && strlen(l_data.country) > 0) 307 308 { 308 309 309 strcat(lang_string, "_"); 310 strcat(lang_string, l_data.country); 310 311 } 311 312 312 313 if(!l_data.n_found) 313 314 { 314 315 316 317 318 319 320 315 if(l_data.country && strlen(l_data.country) > 0) 316 { 317 MESSAGE("Warning: Language '%s' was not found, retrying without country name...\n", lang_string); 318 l_data.country[0] = 0; 319 EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA, 320 (LPCSTR)LOCALE_ILANGUAGE, NLS_FindLanguageID_ProcA, (LONG)&l_data); 321 } 321 322 } 322 323 … … 325 326 if(l_data.country && strlen(l_data.country) > 0) 326 327 { 327 328 328 strcat(lang_string, "_"); 329 strcat(lang_string, l_data.country); 329 330 } 330 331 331 332 if(!l_data.n_found) 332 333 { 333 334 334 MESSAGE("Warning: Language '%s' was not recognized, defaulting to English\n", lang_string); 335 l_data.found_lang_id[0] = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT); 335 336 } 336 337 else 337 338 { 338 339 340 341 342 343 344 345 346 347 348 349 350 339 if(l_data.n_found == 1) 340 TRACE("For language '%s' lang_id %04X was found\n", lang_string, l_data.found_lang_id[0]); 341 else /* l_data->n_found > 1 */ 342 { 343 int i; 344 MESSAGE("For language '%s' several language ids were found:\n", lang_string); 345 for(i = 0; i < l_data.n_found; i++) 346 MESSAGE("%s_%s - %04X; ", l_data.found_language[i], l_data.found_country[i], l_data.found_lang_id[i]); 347 348 MESSAGE("\nInstead of using first in the list, suggest to define\n" 349 "your LANG environment variable like this: LANG=%s_%s\n", 350 l_data.found_language[0], l_data.found_country[0]); 351 } 351 352 } 352 353 END: … … 356 357 #ifndef __WIN32OS2__ 357 358 /*********************************************************************** 358 * 359 * 359 * GetUserDefaultLangID (KERNEL32.@) 360 * GetUserDefaultLangID (OLE2NLS.3) 360 361 */ 361 362 LANGID WINAPI GetUserDefaultLangID(void) 362 363 { 363 364 static LANGIDuserLCID = 0;365 366 364 /* caching result, if defined from environment, which should (?) not change during a WINE session */ 365 static LANGID userLCID = 0; 366 367 if (userLCID == 0) 367 368 { 368 369 char buf[256]; 369 370 371 372 373 374 375 376 377 370 char *lang,*country,*charset,*dialect,*next; 371 372 if (GetEnvironmentVariableA( "LANGUAGE", buf, sizeof(buf) )) goto ok; 373 if (GetEnvironmentVariableA( "LANG", buf, sizeof(buf) )) goto ok; 374 if (GetEnvironmentVariableA( "LC_ALL", buf, sizeof(buf) )) goto ok; 375 if (GetEnvironmentVariableA( "LC_MESSAGES", buf, sizeof(buf) )) goto ok; 376 if (GetEnvironmentVariableA( "LC_CTYPE", buf, sizeof(buf) )) goto ok; 377 378 return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ); 378 379 379 380 ok: 380 381 if (!strcmp(buf,"POSIX") || !strcmp(buf,"C")) 381 382 return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ); 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 383 384 lang=buf; 385 386 do { 387 next=strchr(lang,':'); if (next) *next++='\0'; 388 dialect=strchr(lang,'@'); if (dialect) *dialect++='\0'; 389 charset=strchr(lang,'.'); if (charset) *charset++='\0'; 390 country=strchr(lang,'_'); if (country) *country++='\0'; 391 392 userLCID = NLS_GetLanguageID(lang, country, charset, dialect); 393 394 lang=next; 395 } while (lang && !userLCID); 396 397 if (!userLCID) 397 398 { 398 399 MESSAGE( "Warning: language '%s' not recognized, defaulting to English\n", … … 400 401 userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT ); 401 402 } 402 403 403 } 404 return userLCID; 404 405 } 405 406 406 407 /*********************************************************************** 407 * 408 * 408 * GetSystemDefaultLangID (KERNEL32.@) 409 * GetSystemDefaultLangID (OLE2NLS.4) 409 410 */ 410 411 LANGID WINAPI GetSystemDefaultLangID(void) 411 412 { 412 413 return GetUserDefaultLangID(); 413 414 } 414 415 #endif //__WIN32OS2__ 415 416 /****************************************************************************** 416 * 417 * ConvertDefaultLocale (KERNEL32.@) 417 418 */ 418 419 LCID WINAPI ConvertDefaultLocale (LCID lcid) 419 { 420 421 422 423 424 425 426 } 427 420 { switch (lcid) 421 { case LOCALE_SYSTEM_DEFAULT: 422 return GetSystemDefaultLCID(); 423 case LOCALE_USER_DEFAULT: 424 return GetUserDefaultLCID(); 425 case LOCALE_NEUTRAL: 426 return MAKELCID (LANG_NEUTRAL, SUBLANG_NEUTRAL); 427 } 428 return MAKELANGID( PRIMARYLANGID(lcid), SUBLANG_NEUTRAL); 428 429 } 429 430 … … 447 448 hmem = LoadResource(hModule, hrsrc); 448 449 if(!hmem) return 0; 449 450 450 451 #ifdef __WIN32OS2__ 451 452 p = (WCHAR*)LockResource(hmem); … … 455 456 string_num = res_id & 0x000f; 456 457 for(i = 0; i < string_num; i++) 457 458 458 p += *p + 1; 459 459 460 TRACE("strlen = %d\n", (int)*p ); 460 461 461 462 if (buffer == NULL) return *p; 462 463 i = min(buflen - 1, *p); 463 464 if (i > 0) { 464 465 465 memcpy(buffer, p + 1, i * sizeof (WCHAR)); 466 buffer[i] = (WCHAR) 0; 466 467 } else { 467 468 468 if (buflen > 1) 469 buffer[0] = (WCHAR) 0; 469 470 } 470 471 … … 475 476 #ifndef __WIN32OS2__ 476 477 /****************************************************************************** 477 * 478 * GetLocaleInfoA (KERNEL32.@) 478 479 * 479 * NOTES 480 * NOTES 480 481 * LANG_NEUTRAL is equal to LOCALE_SYSTEM_DEFAULT 481 482 * … … 487 488 { 488 489 LPCSTR retString = NULL; 489 int 490 int found = 0, i; 490 491 char *pacKey; 491 492 char acBuffer[128]; … … 497 498 if (len && (! buf) ) { 498 499 SetLastError(ERROR_INSUFFICIENT_BUFFER); 499 500 501 502 503 500 return 0; 501 } 502 503 if (lcid == LOCALE_NEUTRAL || lcid == LANG_SYSTEM_DEFAULT) 504 { 504 505 lcid = GetSystemDefaultLCID(); 505 } 506 507 506 } 507 else if (lcid == LANG_USER_DEFAULT) /*0x800*/ 508 { 508 509 lcid = GetUserDefaultLCID(); 509 510 } 510 511 511 512 /* LOCALE_NOUSEROVERRIDE means: do not get user redefined settings … … 513 514 NoUserOverride = (LCType & LOCALE_NOUSEROVERRIDE) != 0; 514 515 515 516 LCType &= ~(LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP); 516 517 517 518 /* First, check if it's in the registry. */ … … 524 525 sprintf( acRealKey, "Control Panel\\International\\%s", pacKey ); 525 526 526 if ( RegOpenKeyExA( HKEY_CURRENT_USER, acRealKey, 527 if ( RegOpenKeyExA( HKEY_CURRENT_USER, acRealKey, 527 528 0, KEY_READ, &hKey) == ERROR_SUCCESS ) 528 529 { 529 if ( RegQueryValueExA( hKey, NULL, NULL, NULL, (LPBYTE)acBuffer, 530 if ( RegQueryValueExA( hKey, NULL, NULL, NULL, (LPBYTE)acBuffer, 530 531 &dwBufferSize ) == ERROR_SUCCESS ) 531 532 { … … 539 540 /* If not in the registry, get it from the NLS entries. */ 540 541 if(!found) { 541 542 543 544 545 546 547 548 549 550 542 WCHAR wcBuffer[128]; 543 int res_size; 544 545 /* check if language is registered in the kernel32 resources */ 546 if((res_size = NLS_LoadStringExW(GetModuleHandleA("KERNEL32"), LANGIDFROMLCID(lcid), 547 LCType, wcBuffer, sizeof(wcBuffer)/sizeof(wcBuffer[0])))) { 548 WideCharToMultiByte(CP_ACP, 0, wcBuffer, res_size, acBuffer, dwBufferSize, NULL, NULL); 549 retString = acBuffer; 550 found = 1; 551 } 551 552 } 552 553 553 554 /* if not found report a most descriptive error */ 554 555 if(!found) { 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 return 0; 556 retString=0; 557 /* If we are through all of this, retLen should not be zero anymore. 558 If it is, the value is not supported */ 559 i=0; 560 while (locale_name2id[i].name!=NULL) { 561 if (LCType == locale_name2id[i].id) { 562 retString = locale_name2id[i].name; 563 break; 564 } 565 i++; 566 } 567 if(!retString) 568 FIXME("Unkown LC type %lX\n", LCType); 569 else 570 FIXME("'%s' is not defined for your language (%04X).\n" 571 "Please define it in dlls/kernel/nls/YourLanguage.nls\n" 572 "and submit patch for inclusion into the next Wine release.\n", 573 retString, LOWORD(lcid)); 574 SetLastError(ERROR_INVALID_PARAMETER); 575 return 0; 575 576 } 576 577 … … 578 579 if (LCType == LOCALE_FONTSIGNATURE) { 579 580 if (len) { 580 581 len = (len < sizeof(FONTSIGNATURE)) ? len : sizeof(FONTSIGNATURE); 581 582 memcpy(buf, retString, len); 582 583 583 return len; 584 } 584 585 return sizeof(FONTSIGNATURE); 585 586 } 586 587 /* if len=0 return only the length, don't touch the buffer*/ 587 588 if (len) { 588 589 589 lstrcpynA(buf,retString,len); 590 return strlen(buf) + 1; 590 591 } 591 592 return strlen(retString)+1; … … 593 594 594 595 /****************************************************************************** 595 * 596 * GetLocaleInfoW (KERNEL32.@) 596 597 * 597 598 * NOTES … … 601 602 */ 602 603 INT WINAPI GetLocaleInfoW(LCID lcid,LCTYPE LCType,LPWSTR wbuf,INT len) 603 { 604 605 606 607 608 609 610 611 612 613 614 if (wlen && len)/* if len=0 return only the length*/604 { WORD wlen; 605 LPSTR abuf; 606 607 if (len && (! wbuf) ) 608 { SetLastError(ERROR_INSUFFICIENT_BUFFER); 609 return 0; 610 } 611 612 abuf = (LPSTR)HeapAlloc(GetProcessHeap(),0,len); 613 wlen = GetLocaleInfoA(lcid, LCType, abuf, len); 614 615 if (wlen && len) /* if len=0 return only the length*/ 615 616 MultiByteToWideChar( CP_ACP, 0, abuf, -1, wbuf, len ); 616 617 617 618 618 HeapFree(GetProcessHeap(),0,abuf); 619 return wlen; 619 620 } 620 621 #endif //__WIN32OS2__ … … 622 623 /****************************************************************************** 623 624 * 624 * 625 * GetLocaleSubkeyName [helper function] 625 626 * 626 627 * - For use with the registry. … … 730 731 break; 731 732 732 /* The following are not listed under MSDN as supported, 733 /* The following are not listed under MSDN as supported, 733 734 * but seem to be used and also stored in the registry. 734 735 */ … … 755 756 756 757 /****************************************************************************** 757 * SetLocaleInfoA[KERNEL32.656]758 * SetLocaleInfoA [KERNEL32.656] 758 759 */ 759 760 BOOL WINAPI SetLocaleInfoA(DWORD lcid, DWORD lctype, LPCSTR data) … … 766 767 { 767 768 sprintf( acRealKey, "Control Panel\\International\\%s", pacKey ); 768 if ( RegCreateKeyA( HKEY_CURRENT_USER, acRealKey, 769 if ( RegCreateKeyA( HKEY_CURRENT_USER, acRealKey, 769 770 &hKey ) == ERROR_SUCCESS ) 770 771 { 771 if ( RegSetValueExA( hKey, NULL, 0, REG_SZ, 772 if ( RegSetValueExA( hKey, NULL, 0, REG_SZ, 772 773 #ifdef __WIN32OS2__ 773 774 (LPBYTE)data, strlen(data)+1 ) != ERROR_SUCCESS ) … … 829 830 830 831 /****************************************************************************** 831 * IsValidLocale[KERNEL32.489]832 * IsValidLocale [KERNEL32.489] 832 833 */ 833 834 BOOL WINAPI IsValidLocale(LCID lcid,DWORD flags) … … 840 841 /* check if language is registered in the kernel32 resources */ 841 842 if(!FindResourceExW(GetModuleHandleA("KERNEL32"), RT_STRINGW, (LPCWSTR)LOCALE_ILANGUAGE, LOWORD(lcid))) 842 843 return FALSE; 843 844 else 844 845 return TRUE; 845 846 #endif 846 847 } 847 848 848 849 static BOOL CALLBACK EnumResourceLanguagesProcW(HMODULE hModule, LPCWSTR type, 849 850 LPCWSTR name, WORD LangID, LONG lParam) 850 851 { 851 852 CHAR bufA[20]; … … 858 859 859 860 /****************************************************************************** 860 * EnumSystemLocalesW[KERNEL32.209]861 * EnumSystemLocalesW [KERNEL32.209] 861 862 */ 862 863 BOOL WINAPI EnumSystemLocalesW( LOCALE_ENUMPROCW lpfnLocaleEnum, … … 866 867 867 868 EnumResourceLanguagesW(GetModuleHandleA("KERNEL32"), RT_STRINGW, 868 869 869 (LPCWSTR)LOCALE_ILANGUAGE, EnumResourceLanguagesProcW, 870 (LONG)lpfnLocaleEnum); 870 871 871 872 return TRUE; … … 873 874 874 875 static BOOL CALLBACK EnumResourceLanguagesProcA(HMODULE hModule, LPCSTR type, 875 876 LPCSTR name, WORD LangID, LONG lParam) 876 877 { 877 878 CHAR bufA[20]; … … 882 883 883 884 /****************************************************************************** 884 * EnumSystemLocalesA[KERNEL32.208]885 * EnumSystemLocalesA [KERNEL32.208] 885 886 */ 886 887 BOOL WINAPI EnumSystemLocalesA(LOCALE_ENUMPROCA lpfnLocaleEnum, … … 890 891 891 892 EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA, 892 893 893 (LPCSTR)LOCALE_ILANGUAGE, EnumResourceLanguagesProcA, 894 (LONG)lpfnLocaleEnum); 894 895 895 896 return TRUE; … … 1156 1157 }; 1157 1158 1158 const WORD OLE2NLS_CT_CType3_LUT[] = { 1159 const WORD OLE2NLS_CT_CType3_LUT[] = { 1159 1160 0x0000, /* - 0 */ 1160 1161 0x0000, /* - 1 */ … … 1417 1418 1418 1419 /****************************************************************************** 1419 * GetStringTypeA[KERNEL32.396]1420 * GetStringTypeA [KERNEL32.396] 1420 1421 */ 1421 1422 BOOL WINAPI GetStringTypeA(LCID locale,DWORD dwInfoType,LPCSTR src, 1422 1423 INT cchSrc,LPWORD chartype) 1423 1424 { 1424 1425 return GetStringTypeExA(locale,dwInfoType,src,cchSrc,chartype); 1425 1426 } 1426 1427 1427 1428 /****************************************************************************** 1428 * GetStringTypeExA[KERNEL32.397]1429 * GetStringTypeExA [KERNEL32.397] 1429 1430 * 1430 1431 * FIXME: Ignores the locale. … … 1433 1434 INT cchSrc,LPWORD chartype) 1434 1435 { 1435 inti;1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 for (i=0;i<cchSrc;i++) 1449 1450 1451 1452 1453 1454 1455 1456 1457 1436 int i; 1437 1438 if ((src==NULL) || (chartype==NULL) || (src==(LPSTR)chartype)) 1439 { 1440 SetLastError(ERROR_INVALID_PARAMETER); 1441 return FALSE; 1442 } 1443 1444 if (cchSrc==-1) 1445 cchSrc=strlen(src)+1; 1446 1447 switch (dwInfoType) { 1448 case CT_CTYPE1: 1449 for (i=0;i<cchSrc;i++) 1450 { 1451 chartype[i] = 0; 1452 if (isdigit(src[i])) chartype[i]|=C1_DIGIT; 1453 if (isalpha(src[i])) chartype[i]|=C1_ALPHA; 1454 if (islower(src[i])) chartype[i]|=C1_LOWER; 1455 if (isupper(src[i])) chartype[i]|=C1_UPPER; 1456 if (isspace(src[i])) chartype[i]|=C1_SPACE; 1457 if (ispunct(src[i])) chartype[i]|=C1_PUNCT; 1458 if (iscntrl(src[i])) chartype[i]|=C1_CNTRL; 1458 1459 /* FIXME: isblank() is a GNU extension */ 1459 /* 1460 1461 1462 1463 1464 1465 1466 for (i=0;i<cchSrc;i++) 1467 1468 1469 1470 1471 1472 1473 for (i=0;i<cchSrc;i++) 1474 1475 1476 1477 1478 1479 1480 1481 1482 1460 /* if (isblank(src[i])) chartype[i]|=C1_BLANK; */ 1461 if ((src[i] == ' ') || (src[i] == '\t')) chartype[i]|=C1_BLANK; 1462 /* C1_XDIGIT */ 1463 } 1464 return TRUE; 1465 1466 case CT_CTYPE2: 1467 for (i=0;i<cchSrc;i++) 1468 { 1469 chartype[i]=(WORD)CT_CType2_LUT[i]; 1470 } 1471 return TRUE; 1472 1473 case CT_CTYPE3: 1474 for (i=0;i<cchSrc;i++) 1475 { 1476 chartype[i]=OLE2NLS_CT_CType3_LUT[i]; 1477 } 1478 return TRUE; 1479 1480 default: 1481 ERR("Unknown dwInfoType:%ld\n",dwInfoType); 1482 return FALSE; 1483 } 1483 1484 } 1484 1485 … … 1489 1490 { 1490 1491 if(!szLang) 1491 1492 return 0; 1492 1493 1493 1494 return GetLocaleInfoA(MAKELCID(wLang, SORT_DEFAULT), LOCALE_SENGLANGUAGE, szLang, nSize); … … 1500 1501 { 1501 1502 if(!szLang) 1502 1503 return 0; 1503 1504 1504 1505 return GetLocaleInfoW(MAKELCID(wLang, SORT_DEFAULT), LOCALE_SENGLANGUAGE, szLang, nSize); 1505 1506 } 1506 1507 1507 1508 1508 1509 static const unsigned char LCM_Unicode_LUT[] = { 1509 6 , 3, /* - 1 */ 1510 6 , 4, /* - 2 */ 1511 6 , 5, /* - 3 */ 1512 6 , 6, /* - 4 */ 1513 6 , 7, /* - 5 */ 1514 6 , 8, /* - 6 */ 1515 6 , 9, /* - 7 */ 1516 6 , 10, /* - 8 */ 1517 7 , 5, /* - 9 */ 1518 7 , 6, /* - 10 */ 1519 7 , 7, /* - 11 */ 1520 7 , 8, /* - 12 */ 1521 7 , 9, /* - 13 */ 1522 6 , 11, /* - 14 */ 1523 6 , 12, /* - 15 */ 1524 6 , 13, /* - 16 */ 1525 6 , 14, /* - 17 */ 1526 6 , 15, /* - 18 */ 1527 6 , 16, /* - 19 */ 1528 6 , 17, /* - 20 */ 1529 6 , 18, /* - 21 */ 1530 6 , 19, /* - 22 */ 1531 6 , 20, /* - 23 */ 1532 6 , 21, /* - 24 */ 1533 6 , 22, /* - 25 */ 1534 6 , 23, /* - 26 */ 1535 6 , 24, /* - 27 */ 1536 6 , 25, /* - 28 */ 1537 6 , 26, /* - 29 */ 1538 6 , 27, /* - 30 */ 1539 6 , 28, /* - 31 */ 1510 6 , 3, /* - 1 */ 1511 6 , 4, /* - 2 */ 1512 6 , 5, /* - 3 */ 1513 6 , 6, /* - 4 */ 1514 6 , 7, /* - 5 */ 1515 6 , 8, /* - 6 */ 1516 6 , 9, /* - 7 */ 1517 6 , 10, /* - 8 */ 1518 7 , 5, /* - 9 */ 1519 7 , 6, /* - 10 */ 1520 7 , 7, /* - 11 */ 1521 7 , 8, /* - 12 */ 1522 7 , 9, /* - 13 */ 1523 6 , 11, /* - 14 */ 1524 6 , 12, /* - 15 */ 1525 6 , 13, /* - 16 */ 1526 6 , 14, /* - 17 */ 1527 6 , 15, /* - 18 */ 1528 6 , 16, /* - 19 */ 1529 6 , 17, /* - 20 */ 1530 6 , 18, /* - 21 */ 1531 6 , 19, /* - 22 */ 1532 6 , 20, /* - 23 */ 1533 6 , 21, /* - 24 */ 1534 6 , 22, /* - 25 */ 1535 6 , 23, /* - 26 */ 1536 6 , 24, /* - 27 */ 1537 6 , 25, /* - 28 */ 1538 6 , 26, /* - 29 */ 1539 6 , 27, /* - 30 */ 1540 6 , 28, /* - 31 */ 1540 1541 7 , 2, /* - 32 */ 1541 1542 7 , 28, /* ! - 33 */ … … 1768 1769 #define LCM_Diacritic_Start 131 1769 1770 1770 static const unsigned char LCM_Diacritic_LUT[] = { 1771 static const unsigned char LCM_Diacritic_LUT[] = { 1771 1772 123, /* - 131 */ 1772 1773 2, /* - 132 */ … … 1900 1901 * OLE2NLS_isPunctuation [INTERNAL] 1901 1902 */ 1902 static int OLE2NLS_isPunctuation(unsigned char c) 1903 { 1904 /* "punctuation character" in this context is a character which is 1903 static int OLE2NLS_isPunctuation(unsigned char c) 1904 { 1905 /* "punctuation character" in this context is a character which is 1905 1906 considered "less important" during word sort comparison. 1906 See LCMapString implementation for the precise definition 1907 See LCMapString implementation for the precise definition 1907 1908 of "less important". */ 1908 1909 … … 1913 1914 * OLE2NLS_isNonSpacing [INTERNAL] 1914 1915 */ 1915 static int OLE2NLS_isNonSpacing(unsigned char c) 1916 { 1917 /* This function is used by LCMapStringA. Characters 1916 static int OLE2NLS_isNonSpacing(unsigned char c) 1917 { 1918 /* This function is used by LCMapStringA. Characters 1918 1919 for which it returns true are ignored when mapping a 1919 1920 string with NORM_IGNORENONSPACE */ … … 1924 1925 * OLE2NLS_isSymbol [INTERNAL] 1925 1926 */ 1926 static int OLE2NLS_isSymbol(unsigned char c) 1927 { 1928 /* This function is used by LCMapStringA. Characters 1927 static int OLE2NLS_isSymbol(unsigned char c) 1928 { 1929 /* This function is used by LCMapStringA. Characters 1929 1930 for which it returns true are ignored when mapping a 1930 1931 string with NORM_IGNORESYMBOLS */ … … 1937 1938 1938 1939 /****************************************************************************** 1939 * identity[Internal]1940 * identity [Internal] 1940 1941 */ 1941 1942 #ifdef __WIN32OS2__ … … 1963 1964 * NOTES 1964 1965 * If called with scrlen = -1, the function will compute the length 1965 * of the 0-terminated string strsrc by itself. 1966 * 1967 * If called with dstlen = 0, returns the buffer length that 1966 * of the 0-terminated string strsrc by itself. 1967 * 1968 * If called with dstlen = 0, returns the buffer length that 1968 1969 * would be required. 1969 1970 * 1970 1971 * NORM_IGNOREWIDTH means to compare ASCII and wide characters 1971 * as if they are equal. 1972 * as if they are equal. 1972 1973 * In the only code page implemented so far, there may not be 1973 1974 * wide characters in strings passed to LCMapStringA, … … 1976 1977 #ifdef __WIN32OS2__ 1977 1978 ODINFUNCTION6(INT, LCMapStringA, 1978 LCID, lcid, /* [in] locale identifier created with MAKELCID; 1979 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are 1979 LCID, lcid, /* [in] locale identifier created with MAKELCID; 1980 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are 1980 1981 predefined values. */ 1981 1982 1983 1984 1985 1982 DWORD, mapflags, /* [in] flags */ 1983 LPCSTR, srcstr, /* [in] source buffer */ 1984 INT, srclen, /* [in] source length */ 1985 LPSTR, dststr, /* [out] destination buffer */ 1986 INT, dstlen) /* [in] destination buffer length */ 1986 1987 #else 1987 1988 INT WINAPI LCMapStringA( 1988 LCID lcid, /* [in] locale identifier created with MAKELCID; 1989 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are 1989 LCID lcid, /* [in] locale identifier created with MAKELCID; 1990 LOCALE_SYSTEM_DEFAULT and LOCALE_USER_DEFAULT are 1990 1991 predefined values. */ 1991 1992 1993 1994 1995 1992 DWORD mapflags, /* [in] flags */ 1993 LPCSTR srcstr, /* [in] source buffer */ 1994 INT srclen, /* [in] source length */ 1995 LPSTR dststr, /* [out] destination buffer */ 1996 INT dstlen) /* [in] destination buffer length */ 1996 1997 #endif 1997 1998 { … … 1999 2000 2000 2001 TRACE("(0x%04lx,0x%08lx,%s,%d,%p,%d)\n", 2001 2002 lcid,mapflags,srcstr,srclen,dststr,dstlen); 2002 2003 2003 2004 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) ) … … 2007 2008 return 0; 2008 2009 } 2009 if (srclen == -1) 2010 if (srclen == -1) 2010 2011 srclen = strlen(srcstr) + 1 ; /* (include final '\0') */ 2011 2012 … … 2018 2019 NORM_IGNOREWIDTH | \ 2019 2020 NORM_IGNOREKANATYPE) 2020 /* FIXME: as long as we don't support Katakana nor Hiragana 2021 /* FIXME: as long as we don't support Katakana nor Hiragana 2021 2022 * characters, we can support NORM_IGNOREKANATYPE 2022 2023 */ … … 2024 2025 { 2025 2026 FIXME("(0x%04lx,0x%08lx,%p,%d,%p,%d): " 2026 2027 2028 2029 2030 2031 2032 2033 2027 "unimplemented flags: 0x%08lx\n", 2028 lcid, 2029 mapflags, 2030 srcstr, 2031 srclen, 2032 dststr, 2033 dstlen, 2034 mapflags & ~LCMAPSTRINGA_SUPPORTED_FLAGS 2034 2035 ); 2035 2036 } … … 2039 2040 int i,j; 2040 2041 #ifdef __WIN32OS2__ 2041 int (* _Optlink f)(int) = identity; 2042 int (* _Optlink f)(int) = identity; 2042 2043 #else 2043 int (* f)(int) = identity; 2044 int (* f)(int) = identity; 2044 2045 #endif 2045 2046 int flag_ignorenonspace = mapflags & NORM_IGNORENONSPACE; … … 2048 2049 if (flag_ignorenonspace || flag_ignoresymbols) 2049 2050 { 2050 /* For some values of mapflags, the length of the resulting 2051 2052 2053 2051 /* For some values of mapflags, the length of the resulting 2052 string is not known at this point. Windows does map the string 2053 and does not SetLastError ERROR_INSUFFICIENT_BUFFER in 2054 these cases. */ 2054 2055 if (dstlen==0) 2055 2056 { 2056 2057 2058 2059 2060 2061 2062 2063 2057 /* Compute required length */ 2058 for (i=j=0; i < srclen; i++) 2059 { 2060 if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i])) 2061 && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) ) 2062 j++; 2063 } 2064 return j; 2064 2065 } 2065 2066 } … … 2067 2068 { 2068 2069 if (dstlen==0) 2069 return srclen; 2070 if (dstlen<srclen) 2071 2072 2073 2074 2070 return srclen; 2071 if (dstlen<srclen) 2072 { 2073 SetLastError(ERROR_INSUFFICIENT_BUFFER); 2074 return 0; 2075 } 2075 2076 } 2076 2077 if (mapflags & LCMAP_UPPERCASE) … … 2082 2083 { 2083 2084 if ( !(flag_ignorenonspace && OLE2NLS_isNonSpacing(srcstr[i])) 2084 2085 && !(flag_ignoresymbols && OLE2NLS_isSymbol(srcstr[i])) ) 2085 2086 { 2086 2087 2087 dststr[j] = (CHAR) f(srcstr[i]); 2088 j++; 2088 2089 } 2089 2090 } … … 2109 2110 int ofs; 2110 2111 unsigned char source_char = srcstr[i]; 2111 if (source_char!='\0') 2112 if (source_char!='\0') 2112 2113 { 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 } 2114 if (flag_stringsort || !OLE2NLS_isPunctuation(source_char)) 2115 { 2116 unicode_len++; 2117 if ( LCM_Unicode_LUT[-2+2*source_char] & ~15 ) 2118 unicode_len++; /* double letter */ 2119 } 2120 else 2121 { 2122 delayed_punctuation_len++; 2123 } 2123 2124 } 2124 2125 2125 2126 if (isupper(source_char)) 2126 case_len=unicode_len; 2127 case_len=unicode_len; 2127 2128 2128 2129 ofs = source_char - LCM_Diacritic_Start; 2129 2130 if ((ofs>=0) && (LCM_Diacritic_LUT[ofs]!=2)) 2130 2131 diacritic_len=unicode_len; 2131 2132 } 2132 2133 2133 2134 if (mapflags & NORM_IGNORECASE) 2134 case_len=0; 2135 case_len=0; 2135 2136 if (mapflags & NORM_IGNORENONSPACE) 2136 2137 diacritic_len=0; … … 2143 2144 + 1 ; /* terminal '\0' */ 2144 2145 if (dstlen==0) 2145 return room; 2146 return room; 2146 2147 else if (dstlen<room) 2147 2148 { … … 2159 2160 /* locate each component, write separators */ 2160 2161 diacritic_component = dststr + 2*unicode_len ; 2161 *diacritic_component++ = '\1'; 2162 *diacritic_component++ = '\1'; 2162 2163 case_component = diacritic_component + diacritic_len ; 2163 *case_component++ = '\1'; 2164 *case_component++ = '\1'; 2164 2165 delayed_punctuation_component = case_component + case_len ; 2165 2166 *delayed_punctuation_component++ = '\1'; 2166 2167 *delayed_punctuation_component++ = '\1'; 2167 2168 2168 /* read source string char by char, write 2169 /* read source string char by char, write 2169 2170 corresponding weight in each component. */ 2170 2171 for (i=0,count=0;i<srclen;i++) 2171 2172 { 2172 2173 unsigned char source_char=srcstr[i]; 2173 if (source_char!='\0') 2174 if (source_char!='\0') 2174 2175 { 2175 2176 2177 2178 2179 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char)) 2180 2181 2182 2183 2176 int type,longcode; 2177 type = LCM_Unicode_LUT[-2+2*source_char]; 2178 longcode = type >> 4; 2179 type &= 15; 2180 if (!flag_stringsort && OLE2NLS_isPunctuation(source_char)) 2181 { 2182 WORD encrypted_location = (1<<15) + 7 + 4*count; 2183 *delayed_punctuation_component++ = (unsigned char) (encrypted_location>>8); 2184 *delayed_punctuation_component++ = (unsigned char) (encrypted_location&255); 2184 2185 /* big-endian is used here because it lets string comparison be 2185 2186 2187 2188 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char]; 2189 /* assumption : a punctuation character is never a 2190 2191 2192 2193 2194 2195 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char]; 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode); 2207 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1 2208 32 in the first column of LCM_Unicode_LUT --> longcode = 2 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2186 compatible with numerical comparison */ 2187 2188 *delayed_punctuation_component++ = type; 2189 *delayed_punctuation_component++ = LCM_Unicode_LUT[-1+2*source_char]; 2190 /* assumption : a punctuation character is never a 2191 double or accented letter */ 2192 } 2193 else 2194 { 2195 dststr[2*count] = type; 2196 dststr[2*count+1] = LCM_Unicode_LUT[-1+2*source_char]; 2197 if (longcode) 2198 { 2199 if (count<case_len) 2200 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ; 2201 if (count<diacritic_len) 2202 diacritic_component[count] = 2; /* assumption: a double letter 2203 is never accented */ 2204 count++; 2205 2206 dststr[2*count] = type; 2207 dststr[2*count+1] = *(LCM_Unicode_LUT_2 - 1 + longcode); 2208 /* 16 in the first column of LCM_Unicode_LUT --> longcode = 1 2209 32 in the first column of LCM_Unicode_LUT --> longcode = 2 2210 48 in the first column of LCM_Unicode_LUT --> longcode = 3 */ 2211 } 2212 2213 if (count<case_len) 2214 case_component[count] = ( isupper(source_char) ? 18 : 2 ) ; 2215 if (count<diacritic_len) 2216 { 2217 int ofs = source_char - LCM_Diacritic_Start; 2218 diacritic_component[count] = (ofs>=0 ? LCM_Diacritic_LUT[ofs] : 2); 2219 } 2220 count++; 2221 } 2221 2222 } 2222 2223 } … … 2225 2226 } 2226 2227 } 2227 2228 2228 2229 /************************************************************************* 2229 2230 * LCMapStringW [KERNEL32.493] … … 2237 2238 #ifdef __WIN32OS2__ 2238 2239 ODINFUNCTION6(INT, LCMapStringW, 2239 2240 2240 LCID, lcid,DWORD, mapflags,LPCWSTR, srcstr,INT, srclen,LPWSTR, dststr, 2241 INT, dstlen) 2241 2242 #else 2242 2243 INT WINAPI LCMapStringW( 2243 2244 2244 LCID lcid,DWORD mapflags,LPCWSTR srcstr,INT srclen,LPWSTR dststr, 2245 INT dstlen) 2245 2246 #endif 2246 2247 { 2247 2248 int i; 2248 2249 2249 2250 TRACE("(0x%04lx,0x%08lx,%p,%d,%p,%d)\n", 2250 2251 lcid, mapflags, srcstr, srclen, dststr, dstlen); 2251 2252 2252 2253 if ( ((dstlen!=0) && (dststr==NULL)) || (srcstr==NULL) ) 2253 2254 { … … 2256 2257 return 0; 2257 2258 } 2258 if (srclen==-1) 2259 if (srclen==-1) 2259 2260 srclen = strlenW(srcstr)+1; 2260 2261 … … 2263 2264 * parameter the application must set the "LC_COLLATE" or "LC_ALL" 2264 2265 * environment variable prior to invoking this function. */ 2265 if (mapflags & LCMAP_SORTKEY) 2266 if (mapflags & LCMAP_SORTKEY) 2266 2267 { 2267 2268 /* Possible values of LC_COLLATE. */ … … 2320 2321 * current value is backed up so it can be restored after the 2321 2322 * last LC_COLLATE sensitive function returns. 2322 * 2323 * 2323 2324 * Even though the locale is adjusted for a minimum amount of 2324 2325 * time a race condition exists where other threads may be … … 2360 2361 { 2361 2362 LPSTR srcstr_ascii = (LPSTR)HEAP_strdupWtoA(GetProcessHeap(), 2362 2363 0, srcstr); 2363 2364 ERR("wcstombs failed. The string specified (%s) may contains an " 2364 2365 "invalid character.\n", srcstr_ascii); … … 2373 2374 { 2374 2375 src_native[src_native_len - 1] = 0; 2375 ERR("wcstombs returned a string (%s) that was longer (%d bytes) " 2376 ERR("wcstombs returned a string (%s) that was longer (%d bytes) " 2376 2377 "than expected (%d bytes).\n", src_native, returned_len, 2377 2378 dst_native_len); … … 2415 2416 * not sure what those tables are. */ 2416 2417 returned_len = strxfrm(dst_native, src_native, dst_native_len) + 1; 2417 2418 2418 2419 if(returned_len > dst_native_len) 2419 2420 { 2420 2421 dst_native[dst_native_len - 1] = 0; 2421 ERR("strxfrm returned a string (%s) that was longer (%d bytes) " 2422 ERR("strxfrm returned a string (%s) that was longer (%d bytes) " 2422 2423 "than expected (%d bytes).\n", dst_native, returned_len, 2423 2424 dst_native_len); … … 2434 2435 } 2435 2436 dst_native_len = returned_len; 2436 2437 2437 2438 TRACE("dst_native = %s dst_native_len = %d\n", 2438 2439 dst_native, dst_native_len); … … 2457 2458 /* Restore LC_COLLATE now that the last LC_COLLATE sensitive 2458 2459 * function has returned. */ 2459 setlocale(LC_COLLATE, lc_collate_default); 2460 setlocale(LC_COLLATE, lc_collate_default); 2460 2461 2461 2462 if(returned_len == 0) … … 2474 2475 if(returned_len > dstlen) 2475 2476 { 2476 ERR("mbstowcs returned a string that was longer (%d chars) " 2477 ERR("mbstowcs returned a string that was longer (%d chars) " 2477 2478 "than the buffer provided (%d chars).\n", returned_len, 2478 2479 dstlen); … … 2482 2483 if(dst_native) HeapFree(GetProcessHeap(), 0, dst_native); 2483 2484 if(dststr_libc) HeapFree(GetProcessHeap(), 0, dststr_libc); 2484 return 0; 2485 return 0; 2485 2486 } 2486 2487 dstlen = returned_len; … … 2511 2512 { 2512 2513 #ifdef __WIN32OS2__ 2513 int (* _Optlink f)(int) = identity; 2514 int (* _Optlink f)(int) = identity; 2514 2515 #else 2515 int (*f)(int)=identity; 2516 int (*f)(int)=identity; 2516 2517 #endif 2517 2518 2518 2519 if (dstlen==0) 2519 return srclen; 2520 if (dstlen<srclen) 2520 return srclen; 2521 if (dstlen<srclen) 2521 2522 { 2522 2523 SetLastError(ERROR_INSUFFICIENT_BUFFER); … … 2547 2548 */ 2548 2549 static inline int OLE2NLS_EstimateMappingLength(LCID lcid, DWORD dwMapFlags, 2549 2550 LPCSTR str, DWORD len) 2550 2551 { 2551 2552 /* Estimate only for small strings to keep the estimation error from … … 2556 2557 2557 2558 /****************************************************************************** 2558 * CompareStringA[KERNEL32.143]2559 * CompareStringA [KERNEL32.143] 2559 2560 * Compares two strings using locale 2560 2561 * … … 2569 2570 * SORT_STRINGSORT is set. 2570 2571 * Calls SetLastError for ERROR_INVALID_FLAGS, ERROR_INVALID_PARAMETER. 2571 * 2572 * 2572 2573 * BUGS 2573 2574 * … … 2575 2576 * 2576 2577 * FIXME 2577 * 2578 * 2578 2579 * Quite inefficient. 2579 2580 */ … … 2591 2592 LPSTR sk1,sk2; 2592 2593 TRACE("%s and %s\n", 2593 2594 debugstr_a (s1), debugstr_a (s2)); 2594 2595 2595 2596 if ( (s1==NULL) || (s2==NULL) ) 2596 { 2597 { 2597 2598 ERR("(s1=%s,s2=%s): Invalid NULL string\n", s1, s2); 2598 2599 SetLastError(ERROR_INVALID_PARAMETER); … … 2605 2606 if (l1 == -1) l1 = strlen(s1); 2606 2607 if (l2 == -1) l2 = strlen(s2); 2607 2608 2608 2609 mapstring_flags = LCMAP_SORTKEY | fdwStyle ; 2609 2610 len1 = OLE2NLS_EstimateMappingLength(lcid, mapstring_flags, s1, l1); … … 2616 2617 sk2 = sk1 + len1; 2617 2618 if ( (!LCMapStringA(lcid,mapstring_flags,s1,l1,sk1,len1)) 2618 2619 || (!LCMapStringA(lcid,mapstring_flags,s2,l2,sk2,len2)) ) 2619 2620 { 2620 2621 ERR("Bug in LCmapStringA.\n"); … … 2638 2639 2639 2640 /****************************************************************************** 2640 * CompareStringW[KERNEL32.144]2641 * CompareStringW [KERNEL32.144] 2641 2642 * This implementation ignores the locale 2642 2643 * FIXME : Does only string sort. Should 2643 2644 * be reimplemented the same way as CompareStringA. 2644 2645 */ 2645 UINT WINAPI CompareStringW(DWORD lcid, DWORD fdwStyle, 2646 UINT WINAPI CompareStringW(DWORD lcid, DWORD fdwStyle, 2646 2647 LPCWSTR s1, DWORD l1, LPCWSTR s2,DWORD l2) 2647 2648 { 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2649 int len,ret; 2650 if(fdwStyle & NORM_IGNORENONSPACE) 2651 FIXME("IGNORENONSPACE not supprted\n"); 2652 if(fdwStyle & NORM_IGNORESYMBOLS) 2653 FIXME("IGNORESYMBOLS not supported\n"); 2654 2655 /* Is strcmp defaulting to string sort or to word sort?? */ 2656 /* FIXME: Handle NORM_STRINGSORT */ 2657 l1 = (l1==-1)?strlenW(s1):l1; 2658 l2 = (l2==-1)?strlenW(s2):l2; 2659 len = l1<l2 ? l1:l2; 2660 ret = (fdwStyle & NORM_IGNORECASE) ? strncmpiW(s1,s2,len) : strncmpW(s1,s2,len); 2661 /* not equal, return 1 or 3 */ 2662 if(ret!=0) { 2663 /* need to translate result */ 2664 return ((int)ret < 0) ? 1 : 3; 2665 } 2666 /* same len, return 2 */ 2667 if(l1==l2) return 2; 2668 /* the longer one is lexically greater */ 2669 return (l1<l2)? 1 : 3; 2669 2670 } 2670 2671 2671 2672 /****************************************************************************** 2672 * OLE_GetFormatA[Internal]2673 * OLE_GetFormatA [Internal] 2673 2674 * 2674 2675 * FIXME 2675 2676 * If datelen == 0, it should return the reguired string length. 2676 2677 * 2677 This function implements stuff for GetDateFormat() and 2678 This function implements stuff for GetDateFormat() and 2678 2679 GetTimeFormat(). 2679 2680 … … 2703 2704 '' (within a quoted string) indicates a literal ' 2704 2705 2705 These functions REQUIRE valid locale, date, and format. 2706 These functions REQUIRE valid locale, date, and format. 2706 2707 */ 2707 2708 static INT OLE_GetFormatA(LCID locale, 2708 2709 2710 2711 LPCSTR _format,/*in*/2712 LPSTR date,/*out*/2713 2709 DWORD flags, 2710 DWORD tflags, 2711 LPSYSTEMTIME xtime, 2712 LPCSTR _format, /*in*/ 2713 LPSTR date, /*out*/ 2714 INT datelen) 2714 2715 { 2715 2716 INT inpos, outpos; … … 2721 2722 2722 2723 const char * _dgfmt[] = { "%d", "%02d" }; 2723 const char ** dgfmt = _dgfmt - 1; 2724 const char ** dgfmt = _dgfmt - 1; 2724 2725 2725 2726 /* report, for debugging */ 2726 2727 TRACE("(0x%lx,0x%lx, 0x%lx, time(y=%d m=%d wd=%d d=%d,h=%d,m=%d,s=%d), fmt=%p \'%s\' , %p, len=%d)\n", 2727 2728 2729 2730 2728 locale, flags, tflags, 2729 xtime->wYear,xtime->wMonth,xtime->wDayOfWeek,xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond, 2730 _format, _format, date, datelen); 2731 2731 2732 if(datelen == 0) { 2732 2733 FIXME("datelen = 0, returning 255\n"); … … 2739 2740 type = '\0'; 2740 2741 date[0] = buf[0] = '\0'; 2741 2742 2742 2743 strcpy(format,_format); 2743 2744 2744 2745 /* alter the formatstring, while it works for all languages now in wine 2745 its possible that it fails when the time looks like ss:mm:hh as example*/ 2746 its possible that it fails when the time looks like ss:mm:hh as example*/ 2746 2747 if (tflags & (TIME_NOMINUTESORSECONDS)) 2747 2748 { if ((pos = strstr ( format, ":mm"))) … … 2754 2755 } 2755 2756 } 2756 2757 2757 2758 for (inpos = 0;; inpos++) { 2758 2759 /* TRACE("STATE inpos=%2d outpos=%2d count=%d inquote=%d type=%c buf,date = %c,%c\n", inpos, outpos, count, inquote, type, buf[inpos], date[outpos]); */ 2759 2760 if (inquote) { 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2761 if (format[inpos] == '\'') { 2762 if (format[inpos+1] == '\'') { 2763 inpos += 1; 2764 date[outpos++] = '\''; 2765 } else { 2766 inquote = 0; 2767 continue; /* we did nothing to the output */ 2768 } 2769 } else if (format[inpos] == '\0') { 2770 date[outpos++] = '\0'; 2771 if (outpos > datelen) Overflow = 1; 2772 break; 2773 } else { 2774 date[outpos++] = format[inpos]; 2775 if (outpos > datelen) { 2776 Overflow = 1; 2777 date[outpos-1] = '\0'; /* this is the last place where 2778 it's safe to write */ 2779 break; 2780 } 2781 } 2781 2782 } else if ( (count && (format[inpos] != type)) 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 GetLocaleInfoA(locale, 2793 LOCALE_SABBREVDAYNAME1 2794 2795 2796 2797 2798 2799 2800 2801 GetLocaleInfoA(locale, 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2783 || count == 4 2784 || (count == 2 && strchr("ghHmst", type)) ) { 2785 if (type == 'h' && (tflags & TIME_FORCE24HOURFORMAT)) type= 'H'; 2786 if (type == 'd') { 2787 if (count == 4) { 2788 GetLocaleInfoA(locale, 2789 LOCALE_SDAYNAME1 2790 + (xtime->wDayOfWeek+6)%7, 2791 buf, sizeof(buf)); 2792 } else if (count == 3) { 2793 GetLocaleInfoA(locale, 2794 LOCALE_SABBREVDAYNAME1 2795 + (xtime->wDayOfWeek+6)%7, 2796 buf, sizeof(buf)); 2797 } else { 2798 sprintf(buf, dgfmt[count], xtime->wDay); 2799 } 2800 } else if (type == 'M') { 2801 if (count == 3) { 2802 GetLocaleInfoA(locale, 2803 LOCALE_SABBREVMONTHNAME1 2804 + xtime->wMonth - 1, 2805 buf, sizeof(buf)); 2806 } else if (count == 4) { 2807 GetLocaleInfoA(locale, 2808 LOCALE_SMONTHNAME1 2809 + xtime->wMonth - 1, 2810 buf, sizeof(buf)); 2811 } else { 2812 sprintf(buf, dgfmt[count], xtime->wMonth); 2813 } 2814 } else if (type == 'y') { 2815 if (count == 4) { 2816 sprintf(buf, "%d", xtime->wYear); 2817 } else if (count == 3) { 2818 strcpy(buf, "yyy"); 2819 WARN("unknown format, c=%c, n=%d\n", type, count); 2820 } else { 2821 sprintf(buf, dgfmt[count], xtime->wYear % 100); 2822 } 2823 } else if (type == 'g') { 2824 if (count == 2) { 2825 FIXME("LOCALE_ICALENDARTYPE unimp.\n"); 2826 strcpy(buf, "AD"); 2827 } else { 2828 strcpy(buf, "g"); 2829 WARN("unknown format, c=%c, n=%d\n", type, count); 2830 } 2831 } else if (type == 'h') { 2832 /* gives us hours 1:00 -- 12:00 */ 2833 sprintf(buf, dgfmt[count], (xtime->wHour-1)%12 +1); 2834 } else if (type == 'H') { 2835 /* 24-hour time */ 2836 sprintf(buf, dgfmt[count], xtime->wHour); 2837 } else if ( type == 'm') { 2838 sprintf(buf, dgfmt[count], xtime->wMinute); 2839 } else if ( type == 's') { 2840 sprintf(buf, dgfmt[count], xtime->wSecond); 2841 } else if (type == 't') { 2841 2842 if ((tflags & TIME_NOTIMEMARKER)) 2842 2843 buf[0]='\0'; 2843 2844 else if (count == 1) { 2844 2845 sprintf(buf, "%c", (xtime->wHour < 12) ? 'A' : 'P'); 2845 2846 } else if (count == 2) { 2846 2847 /* sprintf(buf, "%s", (xtime->wHour < 12) ? "AM" : "PM"); */ 2847 2848 GetLocaleInfoA(locale, 2848 (xtime->wHour<12) 2849 (xtime->wHour<12) 2849 2850 ? LOCALE_S1159 : LOCALE_S2359, 2850 2851 buf, sizeof(buf)); 2851 2852 } 2852 2853 2854 /* we need to check the next char in the format string 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2853 }; 2854 2855 /* we need to check the next char in the format string 2856 again, no matter what happened */ 2857 inpos--; 2858 2859 /* add the contents of buf to the output */ 2860 buflen = strlen(buf); 2861 if (outpos + buflen < datelen) { 2862 date[outpos] = '\0'; /* for strcat to hook onto */ 2863 strcat(date, buf); 2864 outpos += buflen; 2865 } else { 2866 date[outpos] = '\0'; 2867 strncat(date, buf, datelen - outpos); 2868 date[datelen - 1] = '\0'; 2869 SetLastError(ERROR_INSUFFICIENT_BUFFER); 2870 WARN("insufficient buffer\n"); 2871 return 0; 2872 } 2873 2874 /* reset the variables we used to keep track of this item */ 2875 count = 0; 2876 type = '\0'; 2877 } else if (format[inpos] == '\0') { 2878 /* we can't check for this at the loop-head, because 2879 that breaks the printing of the last format-item */ 2880 date[outpos] = '\0'; 2881 break; 2881 2882 } else if (count) { 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2883 /* continuing a code for an item */ 2884 count +=1; 2885 continue; 2886 } else if (strchr("hHmstyMdg", format[inpos])) { 2887 type = format[inpos]; 2888 count = 1; 2889 continue; 2890 } else if (format[inpos] == '\'') { 2891 inquote = 1; 2892 continue; 2892 2893 } else { 2893 2894 2894 date[outpos++] = format[inpos]; 2895 } 2895 2896 /* now deal with a possible buffer overflow */ 2896 2897 if (outpos >= datelen) { … … 2900 2901 } 2901 2902 } 2902 2903 2903 2904 if (Overflow) { 2904 2905 SetLastError(ERROR_INSUFFICIENT_BUFFER); … … 2910 2911 if (outpos > datelen-1) outpos = datelen-1; 2911 2912 date[outpos] = '\0'; 2912 2913 2913 2914 TRACE("returns string '%s', len %d\n", date, outpos); 2914 2915 return outpos; … … 2919 2920 */ 2920 2921 static INT OLE_GetFormatW(LCID locale, DWORD flags, DWORD tflags, 2921 2922 2923 2922 LPSYSTEMTIME xtime, 2923 LPCWSTR format, 2924 LPWSTR output, INT outlen) 2924 2925 { 2925 2926 INT inpos, outpos; … … 2940 2941 /* make a debug report */ 2941 2942 TRACE("args: 0x%lx, 0x%lx, 0x%lx, time(d=%d,h=%d,m=%d,s=%d), fmt:%s (at %p), " 2942 2943 2944 2945 2946 2943 "%p with max len %d\n", 2944 locale, flags, tflags, 2945 xtime->wDay, xtime->wHour, xtime->wMinute, xtime->wSecond, 2946 debugstr_w(format), format, output, outlen); 2947 2947 2948 if(outlen == 0) { 2948 2949 FIXME("outlen = 0, returning 255\n"); … … 2956 2957 /* this is really just a sanity check */ 2957 2958 output[0] = buf[0] = 0; 2958 2959 2959 2960 /* this loop is the core of the function */ 2960 2961 for (inpos = 0; /* we have several break points */ ; inpos++) { 2961 2962 if (inquote) { 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 output[outpos-1] = 0; 2979 2980 2981 2963 if (format[inpos] == (WCHAR) '\'') { 2964 if (format[inpos+1] == '\'') { 2965 inpos++; 2966 output[outpos++] = '\''; 2967 } else { 2968 inquote = 0; 2969 continue; 2970 } 2971 } else if (format[inpos] == 0) { 2972 output[outpos++] = 0; 2973 if (outpos > outlen) Overflow = 1; 2974 break; /* normal exit (within a quote) */ 2975 } else { 2976 output[outpos++] = format[inpos]; /* copy input */ 2977 if (outpos > outlen) { 2978 Overflow = 1; 2979 output[outpos-1] = 0; 2980 break; 2981 } 2982 } 2982 2983 } else if ( (count && (format[inpos] != type)) 2983 2984 2985 2986 2987 2988 2989 2990 2991 2984 || ( (count==4 && type =='y') || 2985 (count==4 && type =='M') || 2986 (count==4 && type =='d') || 2987 (count==2 && type =='g') || 2988 (count==2 && type =='h') || 2989 (count==2 && type =='H') || 2990 (count==2 && type =='m') || 2991 (count==2 && type =='s') || 2992 (count==2 && type =='t') ) ) { 2992 2993 switch(type) 2993 2994 { 2994 2995 case 'd': 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 2996 if (count == 4) { 2997 GetLocaleInfoW(locale, 2998 LOCALE_SDAYNAME1 + (xtime->wDayOfWeek +6)%7, 2999 buf, sizeof(buf)/sizeof(WCHAR) ); 3000 } else if (count == 3) { 3001 GetLocaleInfoW(locale, 3002 LOCALE_SABBREVDAYNAME1 + 3003 (xtime->wDayOfWeek +6)%7, 3004 buf, sizeof(buf)/sizeof(WCHAR) ); 3005 } else { 3005 3006 sprintf( tmp, "%.*d", count, xtime->wDay ); 3006 3007 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) ); 3007 3008 } 3008 3009 break; 3009 3010 3010 3011 case 'M': 3011 3012 3013 3014 3015 3016 3017 3018 3019 3012 if (count == 4) { 3013 GetLocaleInfoW(locale, LOCALE_SMONTHNAME1 + 3014 xtime->wMonth -1, buf, 3015 sizeof(buf)/sizeof(WCHAR) ); 3016 } else if (count == 3) { 3017 GetLocaleInfoW(locale, LOCALE_SABBREVMONTHNAME1 + 3018 xtime->wMonth -1, buf, 3019 sizeof(buf)/sizeof(WCHAR) ); 3020 } else { 3020 3021 sprintf( tmp, "%.*d", count, xtime->wMonth ); 3021 3022 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) ); 3022 3023 } 3023 3024 break; 3024 3025 case 'y': 3025 3026 if (count == 4) { 3026 3027 sprintf( tmp, "%d", xtime->wYear ); 3027 3028 } else if (count == 3) { 3028 3029 strcpy( tmp, "yyy" ); 3029 3030 } else { 3030 3031 sprintf( tmp, "%.*d", count, xtime->wYear % 100 ); 3031 3032 } 3032 3033 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) ); 3033 3034 break; 3034 3035 3035 3036 case 'g': 3036 3037 3037 if (count == 2) { 3038 FIXME("LOCALE_ICALENDARTYPE unimplemented\n"); 3038 3039 strcpy( tmp, "AD" ); 3039 3040 3040 } else { 3041 /* Win API sez we copy it verbatim */ 3041 3042 strcpy( tmp, "g" ); 3042 3043 } 3043 3044 MultiByteToWideChar( CP_ACP, 0, tmp, -1, buf, sizeof(buf)/sizeof(WCHAR) ); 3044 3045 break; … … 3066 3067 3067 3068 case 't': 3068 3069 3070 3071 3072 3073 3069 GetLocaleInfoW(locale, (xtime->wHour < 12) ? 3070 LOCALE_S1159 : LOCALE_S2359, 3071 buf, sizeof(buf) ); 3072 if (count == 1) { 3073 buf[1] = 0; 3074 } 3074 3075 break; 3075 3076 } 3076 3077 3077 /* no matter what happened, we need to check this next 3078 3079 3080 3081 3082 3083 3078 /* no matter what happened, we need to check this next 3079 character the next time we loop through */ 3080 inpos--; 3081 3082 /* cat buf onto the output */ 3083 outlen = strlenW(buf); 3084 if (outpos + buflen < outlen) { 3084 3085 strcpyW( output + outpos, buf ); 3085 3086 3086 outpos += buflen; 3087 } else { 3087 3088 lstrcpynW( output + outpos, buf, outlen - outpos ); 3088 3089 3090 3091 3092 3093 3094 3089 Overflow = 1; 3090 break; /* Abnormal exit */ 3091 } 3092 3093 /* reset the variables we used this time */ 3094 count = 0; 3095 type = '\0'; 3095 3096 } else if (format[inpos] == 0) { 3096 /* we can't check for this at the beginning, because that 3097 would keep us from printing a format spec that ended the 3098 3099 3100 3097 /* we can't check for this at the beginning, because that 3098 would keep us from printing a format spec that ended the 3099 string */ 3100 output[outpos] = 0; 3101 break; /* NORMAL EXIT */ 3101 3102 } else if (count) { 3102 3103 3104 3103 /* how we keep track of the middle of a format spec */ 3104 count++; 3105 continue; 3105 3106 } else if ( (datevars && (format[inpos]=='d' || 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3107 format[inpos]=='M' || 3108 format[inpos]=='y' || 3109 format[inpos]=='g') ) || 3110 (timevars && (format[inpos]=='H' || 3111 format[inpos]=='h' || 3112 format[inpos]=='m' || 3113 format[inpos]=='s' || 3114 format[inpos]=='t') ) ) { 3115 type = format[inpos]; 3116 count = 1; 3117 continue; 3117 3118 } else if (format[inpos] == '\'') { 3118 3119 3119 inquote = 1; 3120 continue; 3120 3121 } else { 3121 3122 3122 /* unquoted literals */ 3123 output[outpos++] = format[inpos]; 3123 3124 } 3124 3125 } … … 3135 3136 3136 3137 TRACE(" returning %s\n", debugstr_w(output)); 3137 3138 3138 3139 return (!Overflow) ? outlen : 0; 3139 3140 3140 3141 } 3141 3142 3142 3143 3143 3144 /****************************************************************************** 3144 * GetDateFormatA[KERNEL32.310]3145 * GetDateFormatA [KERNEL32.310] 3145 3146 * Makes an ASCII string of the date 3146 3147 * … … 3164 3165 */ 3165 3166 INT WINAPI GetDateFormatA(LCID locale,DWORD flags, 3166 3167 LPCSTR format, LPSTR date,INT datelen) 3168 { 3169 3167 LPSYSTEMTIME xtime, 3168 LPCSTR format, LPSTR date,INT datelen) 3169 { 3170 3170 3171 char format_buf[40]; 3171 3172 LPCSTR thisformat; … … 3178 3179 3179 3180 TRACE("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n", 3180 3181 3181 locale,flags,xtime,format,date,datelen); 3182 3182 3183 if (!locale) { 3183 3184 locale = LOCALE_SYSTEM_DEFAULT; 3184 3185 }; 3185 3186 3186 3187 if (locale == LOCALE_SYSTEM_DEFAULT) { 3187 3188 thislocale = GetSystemDefaultLCID(); … … 3200 3201 /*FIXME: SystemTimeToFileTime doesn't yet do that ckeck*/ 3201 3202 if(!res) 3202 3203 3204 3205 3206 FileTimeToSystemTime(&ft,&t); 3207 3203 { 3204 SetLastError(ERROR_INVALID_PARAMETER); 3205 return 0; 3206 } 3207 FileTimeToSystemTime(&ft,&t); 3208 3208 3209 }; 3209 3210 thistime = &t; 3210 3211 3211 3212 if (format == NULL) { 3212 GetLocaleInfoA(thislocale, ((flags&DATE_LONGDATE) 3213 3214 3215 3213 GetLocaleInfoA(thislocale, ((flags&DATE_LONGDATE) 3214 ? LOCALE_SLONGDATE 3215 : LOCALE_SSHORTDATE), 3216 format_buf, sizeof(format_buf)); 3216 3217 thisformat = format_buf; 3217 3218 } else { … … 3219 3220 }; 3220 3221 3221 3222 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat, 3223 3224 3222 3223 ret = OLE_GetFormatA(thislocale, flags, 0, thistime, thisformat, 3224 date, datelen); 3225 3225 3226 3226 3227 TRACE( 3227 3228 3228 "GetDateFormatA() returning %d, with data=%s\n", 3229 ret, date); 3229 3230 return ret; 3230 3231 } 3231 3232 3232 3233 /****************************************************************************** 3233 * GetDateFormatW[KERNEL32.311]3234 * GetDateFormatW [KERNEL32.311] 3234 3235 * Makes a Unicode string of the date 3235 3236 * … … 3239 3240 */ 3240 3241 INT WINAPI GetDateFormatW(LCID locale,DWORD flags, 3241 3242 3243 3242 LPSYSTEMTIME xtime, 3243 LPCWSTR format, 3244 LPWSTR date, INT datelen) 3244 3245 { 3245 3246 // convert "format" on passing in into ASCII 3246 3247 LPSTR pszAsciiFormat = UnicodeToAsciiString((LPWSTR) format); 3247 3248 LPSTR pszAsciiDate = (char *)alloca(datelen); 3248 3249 3249 3250 TRACE("Kernel32-ole2nls: GetDateFormatW(0x%04lx,0x%08lx,%p,%s,%p,%d) not yet complete\n", 3250 3251 locale,flags,xtime,pszAsciiFormat,date,datelen); 3251 3252 3252 3253 // call ASCII variant … … 3257 3258 pszAsciiDate, 3258 3259 datelen); // is in "characters", not bytes 3259 3260 3260 3261 FreeAsciiString(pszAsciiFormat); 3261 3262 3262 3263 // convert "date" on returning to UNICODE 3263 3264 if (datelen != 0) … … 3266 3267 lstrcpynAtoW(date, pszAsciiDate, rc); 3267 3268 } 3268 3269 3269 3270 return rc; 3270 3271 3271 3272 #if PH_OFF 3272 3273 unsigned short datearr[] = {'1','9','9','4','-','1','-','1',0}; 3273 3274 3274 FIXME("STUB (should call OLE_GetFormatW)\n"); 3275 FIXME("STUB (should call OLE_GetFormatW)\n"); 3275 3276 lstrcpynW(date, datearr, datelen); 3276 3277 return ( datelen < 9) ? datelen : 9; … … 3279 3280 3280 3281 /************************************************************************** 3281 * EnumDateFormatsA 3282 * EnumDateFormatsA (KERNEL32.198) 3282 3283 */ 3283 3284 BOOL WINAPI EnumDateFormatsA( 3284 3285 DATEFMT_ENUMPROCA lpDateFmtEnumProc, LCID Locale, DWORD dwFlags) 3285 3286 { 3286 LCID Loc = GetUserDefaultLCID(); 3287 LCID Loc = GetUserDefaultLCID(); 3287 3288 if(!lpDateFmtEnumProc) 3288 3289 { … … 3299 3300 { 3300 3301 case DATE_SHORTDATE: 3301 3302 3303 3304 3305 3302 if(!(*lpDateFmtEnumProc)("dd.MM.yy")) return TRUE; 3303 if(!(*lpDateFmtEnumProc)("d.M.yyyy")) return TRUE; 3304 if(!(*lpDateFmtEnumProc)("d.MM.yy")) return TRUE; 3305 if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE; 3306 return TRUE; 3306 3307 case DATE_LONGDATE: 3307 3308 if(!(*lpDateFmtEnumProc)("dddd,d. MMMM yyyy")) return TRUE; 3308 3309 if(!(*lpDateFmtEnumProc)("d. MMMM yyyy")) return TRUE; 3309 3310 if(!(*lpDateFmtEnumProc)("d. MMM yyyy")) return TRUE; 3310 3311 return TRUE; 3311 3312 default: 3312 FIXME("Unknown date format (%ld)\n", dwFlags); 3313 3314 3313 FIXME("Unknown date format (%ld)\n", dwFlags); 3314 SetLastError(ERROR_INVALID_PARAMETER); 3315 return FALSE; 3315 3316 } 3316 } 3317 } 3317 3318 3318 3319 case 0x0000040c: /* (Loc,"fr_FR") */ … … 3321 3322 { 3322 3323 case DATE_SHORTDATE: 3323 3324 3325 3326 3327 3324 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE; 3325 if(!(*lpDateFmtEnumProc)("dd.MM.yy")) return TRUE; 3326 if(!(*lpDateFmtEnumProc)("dd-MM-yy")) return TRUE; 3327 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE; 3328 return TRUE; 3328 3329 case DATE_LONGDATE: 3329 3330 if(!(*lpDateFmtEnumProc)("dddd d MMMM yyyy")) return TRUE; 3330 3331 if(!(*lpDateFmtEnumProc)("d MMM yy")) return TRUE; 3331 3332 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE; 3332 3333 return TRUE; 3333 3334 default: 3334 FIXME("Unknown date format (%ld)\n", dwFlags); 3335 3336 3335 FIXME("Unknown date format (%ld)\n", dwFlags); 3336 SetLastError(ERROR_INVALID_PARAMETER); 3337 return FALSE; 3337 3338 } 3338 3339 } … … 3343 3344 { 3344 3345 case DATE_SHORTDATE: 3345 3346 3347 3348 3349 3346 if(!(*lpDateFmtEnumProc)("yy-MM-dd")) return TRUE; 3347 if(!(*lpDateFmtEnumProc)("dd-MM-yy")) return TRUE; 3348 if(!(*lpDateFmtEnumProc)("yy MM dd")) return TRUE; 3349 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE; 3350 return TRUE; 3350 3351 case DATE_LONGDATE: 3351 3352 if(!(*lpDateFmtEnumProc)("d MMMM, yyyy")) return TRUE; 3352 3353 if(!(*lpDateFmtEnumProc)("d MMM yyyy")) return TRUE; 3353 3354 return TRUE; 3354 3355 default: 3355 FIXME("Unknown date format (%ld)\n", dwFlags); 3356 3357 3356 FIXME("Unknown date format (%ld)\n", dwFlags); 3357 SetLastError(ERROR_INVALID_PARAMETER); 3358 return FALSE; 3358 3359 } 3359 3360 } 3360 3361 3361 case 0x00000809: /* (Loc,"en_UK") */ 3362 { 3362 case 0x00000809: /* (Loc,"en_UK") */ 3363 { 3363 3364 switch(dwFlags) 3364 3365 { 3365 3366 case DATE_SHORTDATE: 3366 3367 3368 3369 3370 3367 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE; 3368 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE; 3369 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE; 3370 if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE; 3371 return TRUE; 3371 3372 case DATE_LONGDATE: 3372 3373 if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE; 3373 3374 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE; 3374 3375 return TRUE; 3375 3376 default: 3376 FIXME("Unknown date format (%ld)\n", dwFlags); 3377 3378 3377 FIXME("Unknown date format (%ld)\n", dwFlags); 3378 SetLastError(ERROR_INVALID_PARAMETER); 3379 return FALSE; 3379 3380 } 3380 3381 } 3381 3382 3382 case 0x00000c09: /* (Loc,"en_AU") */ 3383 { 3383 case 0x00000c09: /* (Loc,"en_AU") */ 3384 { 3384 3385 switch(dwFlags) 3385 3386 { 3386 3387 case DATE_SHORTDATE: 3387 3388 3389 3390 3388 if(!(*lpDateFmtEnumProc)("d/MM/yy")) return TRUE; 3389 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE; 3390 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE; 3391 return TRUE; 3391 3392 case DATE_LONGDATE: 3392 3393 if(!(*lpDateFmtEnumProc)("dddd,d MMMM yyyy")) return TRUE; 3393 3394 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE; 3394 3395 return TRUE; 3395 3396 default: 3396 FIXME("Unknown date format (%ld)\n", dwFlags); 3397 3398 3397 FIXME("Unknown date format (%ld)\n", dwFlags); 3398 SetLastError(ERROR_INVALID_PARAMETER); 3399 return FALSE; 3399 3400 } 3400 3401 } 3401 3402 3402 case 0x00001009: /* (Loc,"en_CA") */ 3403 { 3403 case 0x00001009: /* (Loc,"en_CA") */ 3404 { 3404 3405 switch(dwFlags) 3405 3406 { 3406 3407 case DATE_SHORTDATE: 3407 3408 3409 3410 3411 3408 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE; 3409 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE; 3410 if(!(*lpDateFmtEnumProc)("yy-MM-dd")) return TRUE; 3411 if(!(*lpDateFmtEnumProc)("M/dd/yy")) return TRUE; 3412 return TRUE; 3412 3413 case DATE_LONGDATE: 3413 3414 if(!(*lpDateFmtEnumProc)("d-MMM-yy")) return TRUE; 3414 3415 if(!(*lpDateFmtEnumProc)("MMMM d, yyyy")) return TRUE; 3415 3416 return TRUE; 3416 3417 default: 3417 FIXME("Unknown date format (%ld)\n", dwFlags); 3418 3419 3418 FIXME("Unknown date format (%ld)\n", dwFlags); 3419 SetLastError(ERROR_INVALID_PARAMETER); 3420 return FALSE; 3420 3421 } 3421 3422 } 3422 3423 3423 case 0x00001409: /* (Loc,"en_NZ") */ 3424 { 3424 case 0x00001409: /* (Loc,"en_NZ") */ 3425 { 3425 3426 switch(dwFlags) 3426 3427 { 3427 3428 case DATE_SHORTDATE: 3428 3429 3430 3431 3429 if(!(*lpDateFmtEnumProc)("d/MM/yy")) return TRUE; 3430 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE; 3431 if(!(*lpDateFmtEnumProc)("d.MM.yy")) return TRUE; 3432 return TRUE; 3432 3433 case DATE_LONGDATE: 3433 3434 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE; 3434 3435 if(!(*lpDateFmtEnumProc)("dddd, d MMMM yyyy")) return TRUE; 3435 3436 return TRUE; 3436 3437 default: 3437 FIXME("Unknown date format (%ld)\n", dwFlags); 3438 3439 3438 FIXME("Unknown date format (%ld)\n", dwFlags); 3439 SetLastError(ERROR_INVALID_PARAMETER); 3440 return FALSE; 3440 3441 } 3441 3442 } 3442 3443 3443 case 0x00001809: /* (Loc,"en_IE") */ 3444 { 3444 case 0x00001809: /* (Loc,"en_IE") */ 3445 { 3445 3446 switch(dwFlags) 3446 3447 { 3447 3448 case DATE_SHORTDATE: 3448 3449 3450 3451 3449 if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE; 3450 if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE; 3451 if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE; 3452 return TRUE; 3452 3453 case DATE_LONGDATE: 3453 3454 if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE; 3454 3455 if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE; 3455 3456 return TRUE; 3456 3457 default: 3457 FIXME("Unknown date format (%ld)\n", dwFlags); 3458 3459 3458 FIXME("Unknown date format (%ld)\n", dwFlags); 3459 SetLastError(ERROR_INVALID_PARAMETER); 3460 return FALSE; 3460 3461 } 3461 3462 } 3462 3463 3463 case 0x00001c09: /* (Loc,"en_ZA") */ 3464 { 3464 case 0x00001c09: /* (Loc,"en_ZA") */ 3465 { 3465 3466 switch(dwFlags) 3466 3467 { 3467 3468 case DATE_SHORTDATE: 3468 3469 3469 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE; 3470 return TRUE; 3470 3471 case DATE_LONGDATE: 3471 3472 if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE; 3472 3473 return TRUE; 3473 3474 default: 3474 FIXME("Unknown date format (%ld)\n", dwFlags); 3475 3476 3475 FIXME("Unknown date format (%ld)\n", dwFlags); 3476 SetLastError(ERROR_INVALID_PARAMETER); 3477 return FALSE; 3477 3478 } 3478 3479 } 3479 3480 3480 case 0x00002009: /* (Loc,"en_JM") */ 3481 { 3481 case 0x00002009: /* (Loc,"en_JM") */ 3482 { 3482 3483 switch(dwFlags) 3483 3484 { 3484 3485 case DATE_SHORTDATE: 3485 3486 3486 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE; 3487 return TRUE; 3487 3488 case DATE_LONGDATE: 3488 3489 if(!(*lpDateFmtEnumProc)("dddd,MMMM dd,yyyy")) return TRUE; … … 3490 3491 if(!(*lpDateFmtEnumProc)("dddd,dd MMMM,yyyy")) return TRUE; 3491 3492 if(!(*lpDateFmtEnumProc)("dd MMMM,yyyy")) return TRUE; 3492 3493 return TRUE; 3493 3494 default: 3494 FIXME("Unknown date format (%ld)\n", dwFlags); 3495 3496 3495 FIXME("Unknown date format (%ld)\n", dwFlags); 3496 SetLastError(ERROR_INVALID_PARAMETER); 3497 return FALSE; 3497 3498 } 3498 3499 } 3499 3500 3500 3501 case 0x00002809: /* (Loc,"en_BZ") */ 3501 case 0x00002c09: /* (Loc,"en_TT") */ 3502 { 3502 case 0x00002c09: /* (Loc,"en_TT") */ 3503 { 3503 3504 switch(dwFlags) 3504 3505 { 3505 3506 case DATE_SHORTDATE: 3506 3507 3507 if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE; 3508 return TRUE; 3508 3509 case DATE_LONGDATE: 3509 3510 if(!(*lpDateFmtEnumProc)("dddd,dd MMMM yyyy")) return TRUE; 3510 3511 return TRUE; 3511 3512 default: 3512 FIXME("Unknown date format (%ld)\n", dwFlags); 3513 3514 3513 FIXME("Unknown date format (%ld)\n", dwFlags); 3514 SetLastError(ERROR_INVALID_PARAMETER); 3515 return FALSE; 3515 3516 } 3516 3517 } … … 3521 3522 { 3522 3523 case DATE_SHORTDATE: 3523 3524 3525 3526 3527 3528 3529 3524 if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE; 3525 if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE; 3526 if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE; 3527 if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE; 3528 if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE; 3529 if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE; 3530 return TRUE; 3530 3531 case DATE_LONGDATE: 3531 3532 if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE; … … 3533 3534 if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE; 3534 3535 if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE; 3535 3536 return TRUE; 3536 3537 default: 3537 FIXME("Unknown date format (%ld)\n", dwFlags); 3538 3539 3538 FIXME("Unknown date format (%ld)\n", dwFlags); 3539 SetLastError(ERROR_INVALID_PARAMETER); 3540 return FALSE; 3540 3541 } 3541 3542 } … … 3544 3545 3545 3546 /************************************************************************** 3546 * EnumDateFormatsW 3547 * EnumDateFormatsW (KERNEL32.199) 3547 3548 */ 3548 3549 BOOL WINAPI EnumDateFormatsW( … … 3555 3556 3556 3557 /************************************************************************** 3557 * EnumTimeFormatsA 3558 * EnumTimeFormatsA (KERNEL32.210) 3558 3559 */ 3559 3560 BOOL WINAPI EnumTimeFormatsA( 3560 3561 TIMEFMT_ENUMPROCA lpTimeFmtEnumProc, LCID Locale, DWORD dwFlags) 3561 3562 { 3562 LCID Loc = GetUserDefaultLCID(); 3563 LCID Loc = GetUserDefaultLCID(); 3563 3564 if(!lpTimeFmtEnumProc) 3564 3565 { … … 3568 3569 if(dwFlags) 3569 3570 { 3570 FIXME("Unknown time format (%ld)\n", dwFlags); 3571 FIXME("Unknown time format (%ld)\n", dwFlags); 3571 3572 } 3572 3573 … … 3575 3576 case 0x00000407: /* (Loc,"de_DE") */ 3576 3577 { 3577 if(!(*lpTimeFmtEnumProc)("HH.mm")) return TRUE; 3578 if(!(*lpTimeFmtEnumProc)("HH.mm")) return TRUE; 3578 3579 if(!(*lpTimeFmtEnumProc)("HH:mm:ss")) return TRUE; 3579 3580 if(!(*lpTimeFmtEnumProc)("H:mm:ss")) return TRUE; … … 3581 3582 if(!(*lpTimeFmtEnumProc)("H.mm'Uhr'")) return TRUE; 3582 3583 return TRUE; 3583 } 3584 } 3584 3585 3585 3586 case 0x0000040c: /* (Loc,"fr_FR") */ … … 3595 3596 3596 3597 case 0x00000809: /* (Loc,"en_UK") */ 3597 case 0x00000c09: /* (Loc,"en_AU") */ 3598 case 0x00000c09: /* (Loc,"en_AU") */ 3598 3599 case 0x00001409: /* (Loc,"en_NZ") */ 3599 case 0x00001809: /* (Loc,"en_IE") */ 3600 case 0x00001809: /* (Loc,"en_IE") */ 3600 3601 { 3601 3602 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE; … … 3605 3606 } 3606 3607 3607 case 0x00001c09: /* (Loc,"en_ZA") */ 3608 case 0x00001c09: /* (Loc,"en_ZA") */ 3608 3609 case 0x00002809: /* (Loc,"en_BZ") */ 3609 case 0x00002c09: /* (Loc,"en_TT") */ 3610 case 0x00002c09: /* (Loc,"en_TT") */ 3610 3611 { 3611 3612 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE; 3612 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE; 3613 return TRUE; 3613 if(!(*lpTimeFmtEnumProc)("hh:mm:ss tt")) return TRUE; 3614 return TRUE; 3614 3615 } 3615 3616 3616 default: /* default to US style "en_US" */ 3617 default: /* default to US style "en_US" */ 3617 3618 { 3618 3619 if(!(*lpTimeFmtEnumProc)("h:mm:ss tt")) return TRUE; … … 3626 3627 3627 3628 /************************************************************************** 3628 * EnumTimeFormatsW 3629 * EnumTimeFormatsW (KERNEL32.211) 3629 3630 */ 3630 3631 BOOL WINAPI EnumTimeFormatsW( … … 3639 3640 * This function is used just locally ! 3640 3641 * Description: Inverts a string. 3641 */ 3642 */ 3642 3643 static void OLE_InvertString(char* string) 3643 { 3644 { 3644 3645 char sTmpArray[128]; 3645 3646 INT counter, i = 0; … … 3658 3659 * Description: Test if the given string (psNumber) is valid or not. 3659 3660 * The valid characters are the following: 3660 * - Characters '0' through '9'. 3661 * - One decimal point (dot) if the number is a floating-point value. 3662 * - A minus sign in the first character position if the number is 3661 * - Characters '0' through '9'. 3662 * - One decimal point (dot) if the number is a floating-point value. 3663 * - A minus sign in the first character position if the number is 3663 3664 * a negative value. 3664 3665 * If the function succeeds, psBefore/psAfter will point to the string 3665 * on the right/left of the decimal symbol. pbNegative indicates if the 3666 * on the right/left of the decimal symbol. pbNegative indicates if the 3666 3667 * number is negative. 3667 3668 */ 3668 3669 static INT OLE_GetNumberComponents(char* pInput, char* psBefore, char* psAfter, BOOL* pbNegative) 3669 3670 { 3670 char 3671 BOOL 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3671 char sNumberSet[] = "0123456789"; 3672 BOOL bInDecimal = FALSE; 3673 3674 /* Test if we do have a minus sign */ 3675 if ( *pInput == '-' ) 3676 { 3677 *pbNegative = TRUE; 3678 pInput++; /* Jump to the next character. */ 3679 } 3680 3681 while(*pInput != '\0') 3682 { 3683 /* Do we have a valid numeric character */ 3684 if ( strchr(sNumberSet, *pInput) != NULL ) 3685 { 3686 if (bInDecimal == TRUE) 3686 3687 *psAfter++ = *pInput; 3687 3688 else 3688 3689 *psBefore++ = *pInput; 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3690 } 3691 else 3692 { 3693 /* Is this a decimal point (dot) */ 3694 if ( *pInput == '.' ) 3695 { 3696 /* Is it the first time we find it */ 3697 if ((bInDecimal == FALSE)) 3698 bInDecimal = TRUE; 3699 else 3700 return -1; /* ERROR: Invalid parameter */ 3701 } 3702 else 3703 { 3704 /* It's neither a numeric character, nor a decimal point. 3705 * Thus, return an error. 3705 3706 */ 3706 3707 3708 3707 return -1; 3708 } 3709 } 3709 3710 pInput++; 3710 3711 3712 3713 3714 3715 3716 return 0; 3711 } 3712 3713 /* Add an End of Line character to the output buffers */ 3714 *psBefore = '\0'; 3715 *psAfter = '\0'; 3716 3717 return 0; 3717 3718 } 3718 3719 3719 3720 /************************************************************************** 3720 3721 * This function is used just locally ! 3721 * Description: A number could be formatted using different numbers 3722 * Description: A number could be formatted using different numbers 3722 3723 * of "digits in group" (example: 4;3;2;0). 3723 3724 * The first parameter of this function is an array … … 3742 3743 memcpy(sData, sRule+index, 1); 3743 3744 memcpy(sData+1, "\0", 1); 3744 nData = atoi(sData); 3745 } 3746 3745 nData = atoi(sData); 3746 } 3747 3747 3748 else 3748 3749 { 3749 3750 memcpy(sData, sRule+nRuleSize-1, 1); 3750 3751 memcpy(sData+1, "\0", 1); 3751 nData = atoi(sData); 3752 } 3753 3752 nData = atoi(sData); 3753 } 3754 3754 3755 return nData; 3755 3756 } 3756 3757 3757 3758 /************************************************************************** 3758 * GetNumberFormatA 3759 * GetNumberFormatA (KERNEL32.355) 3759 3760 */ 3760 3761 INT WINAPI GetNumberFormatA(LCID locale, DWORD dwflags, 3761 3762 3762 LPCSTR lpvalue, const NUMBERFMTA * lpFormat, 3763 LPSTR lpNumberStr, int cchNumber) 3763 3764 { 3764 3765 char sNumberDigits[3], sDecimalSymbol[5], sDigitsInGroup[11], sDigitGroupSymbol[5], sILZero[2]; 3765 3766 INT nNumberDigits, nNumberDecimal, i, j, nCounter, nStep, nRuleIndex, nGrouping, nDigits, retVal, nLZ; 3766 3767 char sNumber[128], sDestination[128], sDigitsAfterDecimal[10], sDigitsBeforeDecimal[128]; 3767 char sRule[10], sSemiColumn[]=";", sBuffer[5], sNegNumber[2]; 3768 char sRule[10], sSemiColumn[]=";", sBuffer[5], sNegNumber[2]; 3768 3769 char *pStr = NULL, *pTmpStr = NULL; 3769 3770 LCID systemDefaultLCID; 3770 3771 BOOL bNegative = FALSE; 3771 enum Operations 3772 enum Operations 3772 3773 { 3773 3774 USE_PARAMETER, … … 3800 3801 { 3801 3802 if (dwflags == 0) 3802 used_operation = USE_PARAMETER; 3803 used_operation = USE_PARAMETER; 3803 3804 } 3804 3805 else … … 3844 3845 3845 3846 nNumberDigits = atoi(sNumberDigits); 3846 3847 3847 3848 /* Remove the ";" */ 3848 3849 i=0; … … 3860 3861 memcpy(sRule, sBuffer, 1); /* Number of digits in the groups ( used by OLE_GetGrouping() ) */ 3861 3862 memcpy(sRule + j, "\0", 1); 3862 3863 3863 3864 /* First, format the digits before the decimal. */ 3864 if ((nNumberDecimal>0) && (atoi(sDigitsBeforeDecimal) != 0)) 3865 if ((nNumberDecimal>0) && (atoi(sDigitsBeforeDecimal) != 0)) 3865 3866 { 3866 3867 /* Working on an inverted string is easier ! */ … … 3870 3871 nRuleIndex = 1; 3871 3872 nGrouping = OLE_GetGrouping(sRule, nRuleIndex); 3872 3873 3873 3874 /* Here, we will loop until we reach the end of the string. 3874 * An internal counter (j) is used in order to know when to 3875 * An internal counter (j) is used in order to know when to 3875 3876 * insert the "digit group symbol". 3876 3877 */ … … 3902 3903 nLZ = atoi(sILZero); 3903 3904 if (nLZ != 0) 3904 { 3905 { 3905 3906 /* Use 0.xxx instead of .xxx */ 3906 3907 memcpy(sDestination, "0", 1); … … 3917 3918 if ( (nDigits>0) && (pStr = strstr (sNumber, ".")) ) 3918 3919 { 3919 i = strlen(sNumber) - strlen(pStr) + 1; 3920 i = strlen(sNumber) - strlen(pStr) + 1; 3920 3921 strncpy ( sDigitsAfterDecimal, sNumber + i, nNumberDigits); 3921 3922 j = strlen(sDigitsAfterDecimal); 3922 3923 if (j < nNumberDigits) 3923 nCounter = nNumberDigits-j; 3924 nCounter = nNumberDigits-j; 3924 3925 } 3925 3926 for (i=0;i<nCounter;i++) 3926 memcpy(sDigitsAfterDecimal+i+j, "0", 1); 3927 memcpy(sDigitsAfterDecimal + nNumberDigits, "\0", 1); 3927 memcpy(sDigitsAfterDecimal+i+j, "0", 1); 3928 memcpy(sDigitsAfterDecimal + nNumberDigits, "\0", 1); 3928 3929 3929 3930 i = strlen(sDestination); 3930 3931 j = strlen(sDigitsAfterDecimal); 3931 3932 /* Finally, construct the resulting formatted string. */ 3932 3933 3933 3934 for (nCounter=0; nCounter<i; nCounter++) 3934 3935 memcpy(sNumber + nCounter, sDestination + nCounter, 1); 3935 3936 3936 3937 memcpy(sNumber + nCounter, sDecimalSymbol, strlen(sDecimalSymbol)); 3937 3938 … … 3939 3940 memcpy(sNumber + nCounter+i+strlen(sDecimalSymbol), sDigitsAfterDecimal + i, 1); 3940 3941 memcpy(sNumber + nCounter+i+strlen(sDecimalSymbol), "\0", 1); 3941 3942 3942 3943 /* Is it a negative number */ 3943 3944 if (bNegative == TRUE) … … 3947 3948 pTmpStr = sNumber; 3948 3949 switch (i) 3949 { 3950 { 3950 3951 case 0: 3951 3952 *pStr++ = '('; 3952 3953 while (*sNumber != '\0') 3953 3954 *pStr++ = *pTmpStr++; 3954 *pStr++ = ')'; 3955 break; 3955 *pStr++ = ')'; 3956 break; 3956 3957 case 1: 3957 3958 *pStr++ = '-'; … … 3985 3986 strcpy(sDestination, sNumber); 3986 3987 3987 /* If cchNumber is zero, then returns the number of bytes or characters 3988 /* If cchNumber is zero, then returns the number of bytes or characters 3988 3989 * required to hold the formatted number string 3989 3990 */ 3990 3991 if (cchNumber==0) 3991 3992 retVal = strlen(sDestination) + 1; 3992 else 3993 else 3993 3994 { 3994 3995 strncpy (lpNumberStr, sDestination, cchNumber-1); … … 3996 3997 retVal = strlen(lpNumberStr); 3997 3998 } 3998 3999 3999 4000 return retVal; 4000 4001 } 4001 4002 4002 4003 /************************************************************************** 4003 * GetNumberFormatW 4004 * GetNumberFormatW (KERNEL32.@) 4004 4005 */ 4005 4006 INT WINAPI GetNumberFormatW(LCID locale, DWORD dwflags, 4006 4007 4007 LPCWSTR lpvalue, const NUMBERFMTW * lpFormat, 4008 LPWSTR lpNumberStr, int cchNumber) 4008 4009 { 4009 4010 FIXME("%s: stub, no reformating done\n",debugstr_w(lpvalue)); … … 4014 4015 4015 4016 /************************************************************************** 4016 * GetCurrencyFormatA 4017 * GetCurrencyFormatA (KERNEL32.302) 4017 4018 */ 4018 4019 INT WINAPI GetCurrencyFormatA(LCID locale, DWORD dwflags, 4019 4020 4020 LPCSTR lpvalue, const CURRENCYFMTA * lpFormat, 4021 LPSTR lpCurrencyStr, int cchCurrency) 4021 4022 { 4022 4023 UINT nPosOrder, nNegOrder; … … 4028 4029 LCID systemDefaultLCID; 4029 4030 BOOL bIsPositive = FALSE, bValidFormat = FALSE; 4030 enum Operations 4031 enum Operations 4031 4032 { 4032 4033 USE_PARAMETER, … … 4043 4044 { 4044 4045 if (dwflags == 0) 4045 used_operation = USE_PARAMETER; 4046 used_operation = USE_PARAMETER; 4046 4047 } 4047 4048 else … … 4056 4057 switch(used_operation) 4057 4058 { 4058 case USE_LOCALEINFO: 4059 case USE_LOCALEINFO: 4059 4060 /* Specific to CURRENCYFMTA*/ 4060 4061 GetLocaleInfoA(locale, LOCALE_INEGCURR, sNegOrder, sizeof(sNegOrder)); 4061 4062 GetLocaleInfoA(locale, LOCALE_ICURRENCY, sPosOrder, sizeof(sPosOrder)); 4062 4063 GetLocaleInfoA(locale, LOCALE_SCURRENCY, sCurrencySymbol, sizeof(sCurrencySymbol)); 4063 4064 4064 4065 nPosOrder = atoi(sPosOrder); 4065 4066 nNegOrder = atoi(sNegOrder); 4066 4067 break; 4067 case USE_PARAMETER: 4068 case USE_PARAMETER: 4068 4069 /* Specific to CURRENCYFMTA*/ 4069 4070 nNegOrder = lpFormat->NegativeOrder; … … 4072 4073 break; 4073 4074 case USE_SYSTEMDEFAULT: 4074 systemDefaultLCID = GetSystemDefaultLCID(); 4075 systemDefaultLCID = GetSystemDefaultLCID(); 4075 4076 /* Specific to CURRENCYFMTA*/ 4076 4077 GetLocaleInfoA(systemDefaultLCID, LOCALE_INEGCURR, sNegOrder, sizeof(sNegOrder)); 4077 4078 GetLocaleInfoA(systemDefaultLCID, LOCALE_ICURRENCY, sPosOrder, sizeof(sPosOrder)); 4078 4079 GetLocaleInfoA(systemDefaultLCID, LOCALE_SCURRENCY, sCurrencySymbol, sizeof(sCurrencySymbol)); 4079 4080 4080 4081 nPosOrder = atoi(sPosOrder); 4081 4082 nNegOrder = atoi(sNegOrder); … … 4085 4086 return 0; 4086 4087 } 4087 4088 4088 4089 /* Construct a temporary number format structure */ 4089 4090 if (lpFormat != NULL) … … 4109 4110 retVal = GetNumberFormatA(locale,0,lpvalue,(bValidFormat)?&numberFmt:NULL,pNumberFormated,128); 4110 4111 } 4111 4112 4112 4113 if (retVal == 0) 4113 4114 return 0; … … 4224 4225 break; 4225 4226 case 14: /* format: ($ 1.1) */ 4226 strcpy (pDestination, "("); 4227 strcpy (pDestination, "("); 4227 4228 strcat (pDestination, sCurrencySymbol); 4228 4229 strcat (pDestination, " "); … … 4231 4232 break; 4232 4233 case 15: /* format: (1.1 $) */ 4233 strcpy (pDestination, "("); 4234 strcpy (pDestination, "("); 4234 4235 strcat (pDestination, pNumberFormated); 4235 4236 strcat (pDestination, " "); … … 4251 4252 *(lpCurrencyStr+cchCurrency-1) = '\0'; /* ensure we got a NULL at the end */ 4252 4253 return strlen(lpCurrencyStr); 4253 } 4254 } 4254 4255 } 4255 4256 4256 4257 /************************************************************************** 4257 * GetCurrencyFormatW 4258 * GetCurrencyFormatW (KERNEL32.303) 4258 4259 */ 4259 4260 INT WINAPI GetCurrencyFormatW(LCID locale, DWORD dwflags, 4260 4261 4261 LPCWSTR lpvalue, const CURRENCYFMTW * lpFormat, 4262 LPWSTR lpCurrencyStr, int cchCurrency) 4262 4263 { 4263 4264 FIXME("This API function is NOT implemented !\n"); … … 4266 4267 4267 4268 /****************************************************************************** 4268 * OLE2NLS_CheckLocale[intern]4269 */ 4269 * OLE2NLS_CheckLocale [intern] 4270 */ 4270 4271 static LCID OLE2NLS_CheckLocale (LCID locale) 4271 4272 { 4272 if (!locale) 4273 4274 4275 4276 if (locale == LOCALE_SYSTEM_DEFAULT) 4277 4278 } 4279 else if (locale == LOCALE_USER_DEFAULT) 4280 4281 4282 4283 4284 4273 if (!locale) 4274 { locale = LOCALE_SYSTEM_DEFAULT; 4275 } 4276 4277 if (locale == LOCALE_SYSTEM_DEFAULT) 4278 { return GetSystemDefaultLCID(); 4279 } 4280 else if (locale == LOCALE_USER_DEFAULT) 4281 { return GetUserDefaultLCID(); 4282 } 4283 else 4284 { return locale; 4285 } 4285 4286 } 4286 4287 /****************************************************************************** 4287 * GetTimeFormatA[KERNEL32.422]4288 * GetTimeFormatA [KERNEL32.422] 4288 4289 * Makes an ASCII string of the time 4289 4290 * … … 4303 4304 * 4304 4305 */ 4305 INT WINAPI 4306 INT WINAPI 4306 4307 GetTimeFormatA(LCID locale, /* [in] */ 4307 4308 LPSYSTEMTIME xtime, /* [in] */ 4309 4310 4311 INT timelen /* [in] */) 4308 DWORD flags, /* [in] */ 4309 LPSYSTEMTIME xtime, /* [in] */ 4310 LPCSTR format, /* [in] */ 4311 LPSTR timestr, /* [out] */ 4312 INT timelen /* [in] */) 4312 4313 { char format_buf[40]; 4313 4314 LPCSTR thisformat; … … 4317 4318 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */ 4318 4319 INT ret; 4319 4320 4320 4321 TRACE("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags,xtime,format,timestr,timelen); 4321 4322 4322 4323 thislocale = OLE2NLS_CheckLocale ( locale ); 4323 4324 4324 if (format == NULL) 4325 if (format == NULL) 4325 4326 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/ 4326 4327 { thislocale = GetSystemDefaultLCID(); … … 4329 4330 thisformat = format_buf; 4330 4331 } 4331 else 4332 else 4332 4333 { thisformat = format; 4333 4334 } 4334 4335 4335 4336 if (xtime == NULL) /* NULL means use the current local time*/ 4336 4337 { GetLocalTime(&t); 4337 4338 thistime = &t; 4338 } 4339 } 4339 4340 else 4340 4341 { thistime = xtime; … … 4342 4343 } 4343 4344 ret = OLE_GetFormatA(thislocale, thisflags, flags, thistime, thisformat, 4344 4345 timestr, timelen); 4345 4346 return ret; 4346 4347 } … … 4348 4349 4349 4350 /****************************************************************************** 4350 * GetTimeFormatW[KERNEL32.423]4351 * GetTimeFormatW [KERNEL32.423] 4351 4352 * Makes a Unicode string of the time 4352 4353 */ 4353 INT WINAPI 4354 INT WINAPI 4354 4355 GetTimeFormatW(LCID locale, /* [in] */ 4355 4356 LPSYSTEMTIME xtime, /* [in] */ 4357 4358 4359 INT timelen /* [in] */) 4360 { 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 if (format == NULL) 4374 4375 4376 4377 4378 4379 } 4380 else 4381 4382 4383 4384 4385 4386 4387 } 4388 4389 4390 4391 4392 4393 4394 4356 DWORD flags, /* [in] */ 4357 LPSYSTEMTIME xtime, /* [in] */ 4358 LPCWSTR format, /* [in] */ 4359 LPWSTR timestr, /* [out] */ 4360 INT timelen /* [in] */) 4361 { WCHAR format_buf[40]; 4362 LPCWSTR thisformat; 4363 SYSTEMTIME t; 4364 LPSYSTEMTIME thistime; 4365 LCID thislocale=0; 4366 DWORD thisflags=LOCALE_STIMEFORMAT; /* standart timeformat */ 4367 INT ret; 4368 4369 TRACE("GetTimeFormat(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",locale,flags, 4370 xtime,debugstr_w(format),timestr,timelen); 4371 4372 thislocale = OLE2NLS_CheckLocale ( locale ); 4373 4374 if (format == NULL) 4375 { if (flags & LOCALE_NOUSEROVERRIDE) /*use system default*/ 4376 { thislocale = GetSystemDefaultLCID(); 4377 } 4378 GetLocaleInfoW(thislocale, thisflags, format_buf, 40); 4379 thisformat = format_buf; 4380 } 4381 else 4382 { thisformat = format; 4383 } 4384 4385 if (xtime == NULL) /* NULL means use the current local time*/ 4386 { GetLocalTime(&t); 4387 thistime = &t; 4388 } 4389 else 4390 { thistime = xtime; 4391 } 4392 4393 ret = OLE_GetFormatW(thislocale, thisflags, flags, thistime, thisformat, 4394 timestr, timelen); 4395 return ret; 4395 4396 } 4396 4397 4397 4398 /****************************************************************************** 4398 * EnumCalendarInfoA[KERNEL32.196]4399 * EnumCalendarInfoA [KERNEL32.196] 4399 4400 */ 4400 4401 BOOL WINAPI EnumCalendarInfoA( 4401 4402 CALINFO_ENUMPROCA calinfoproc,LCID locale,CALID calendar,CALTYPE caltype 4402 4403 ) { 4403 4404 4404 FIXME("(%p,0x%04lx,0x%08lx,0x%08lx),stub!\n",calinfoproc,locale,calendar,caltype); 4405 return FALSE; 4405 4406 } 4406 4407 -
trunk/src/kernel32/ordinals.cpp
r5308 r6646 1 2 /*1 /* $Id: ordinals.cpp,v 1.4 2001-09-05 12:58:00 bird Exp $ 2 * 3 3 * Win32 KERNEL32 Subsystem for OS/2 4 4 * … … 57 57 58 58 /********************************************************************** 59 * 59 * _KERNEL32_100 60 60 */ 61 61 BOOL WINAPI KERNEL32_100(HANDLE threadid,DWORD exitcode,DWORD x) 62 62 { 63 64 63 dprintf(("_KERNEL32_100 (%d,%ld,0x%08lx): STUB",threadid,exitcode,x)); 64 return TRUE; 65 65 } 66 66 … … 101 101 // it's some function dispatcher 102 102 SetLastError(0x78); 103 103 104 104 //@@@PH we should now get the correct CL value */ 105 105 BYTE CL; … … 114 114 default: ret = 0; break; 115 115 } 116 116 117 117 // select jump function 118 118 VOID* pfn = (VOID*)pFunctionTable[CL & 0x0F]; … … 127 127 * Variables : 128 128 * Result : Unknown 129 * Remark : 129 * Remark : 130 130 * Status : UNTESTED STUB 131 131 * -
trunk/src/kernel32/stubs.cpp
r5587 r6646 1 2 /*1 /* $Id: stubs.cpp,v 1.32 2001-09-05 12:58:00 bird Exp $ 2 * 3 3 * Win32 KERNEL32 Subsystem for OS/2 4 4 *
Note:
See TracChangeset
for help on using the changeset viewer.