Changeset 6375 for trunk/src/kernel32
- Timestamp:
- Jul 20, 2001, 5:42:38 PM (24 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/KERNEL32.DEF
r6263 r6375 1 ; $Id: KERNEL32.DEF,v 1.11 4 2001-07-09 07:58:12sandervl Exp $1 ; $Id: KERNEL32.DEF,v 1.115 2001-07-20 15:33:28 sandervl Exp $ 2 2 3 3 ;Basis is Windows95 KERNEL32 … … 1164 1164 _Odin32GetBuildNumber@0 @1293 NONAME 1165 1165 1166 ;Export for MSACM321167 _wsnprintfA @2000 NONAME1168 1169 1166 IsExeStarted__Fv @2001 NONAME 1170 1167 CheckCurFS @2002 NONAME -
trunk/src/kernel32/dbglocal.cpp
r5587 r6375 1 /* $Id: dbglocal.cpp,v 1.1 5 2001-04-26 13:22:43sandervl Exp $ */1 /* $Id: dbglocal.cpp,v 1.16 2001-07-20 15:33:29 sandervl Exp $ */ 2 2 3 3 /* … … 16 16 #ifdef DEBUG 17 17 18 USHORT DbgEnabled [DBG_MAXFILES] = {0};19 USHORT DbgEnabledLvl2 [DBG_MAXFILES] = {0};18 USHORT DbgEnabledKERNEL32[DBG_MAXFILES] = {0}; 19 USHORT DbgEnabledLvl2KERNEL32[DBG_MAXFILES] = {0}; 20 20 21 char *DbgFileNames[DBG_MAXFILES] =21 static char *DbgFileNames[DBG_MAXFILES] = 22 22 { 23 23 "kernel32", … … 128 128 //****************************************************************************** 129 129 //****************************************************************************** 130 void ParseLogStatus ()130 void ParseLogStatusKERNEL32() 131 131 { 132 132 char *envvar = getenv(DBG_ENVNAME); … … 136 136 137 137 for(i=0;i<DBG_MAXFILES;i++) { 138 DbgEnabled [i] = 1;138 DbgEnabledKERNEL32[i] = 1; 139 139 } 140 140 … … 144 144 if(*(dbgvar-1) == '-') { 145 145 for(i=0;i<DBG_MAXFILES;i++) { 146 DbgEnabled [i] = 0;146 DbgEnabledKERNEL32[i] = 0; 147 147 } 148 148 } … … 152 152 if(dbgvar) { 153 153 if(*(dbgvar-1) == '-') { 154 DbgEnabled [i] = 0;154 DbgEnabledKERNEL32[i] = 0; 155 155 } 156 156 else 157 157 if(*(dbgvar-1) == '+') { 158 DbgEnabled [i] = 1;158 DbgEnabledKERNEL32[i] = 1; 159 159 } 160 160 } … … 166 166 if(*(dbgvar-1) == '+') { 167 167 for(i=0;i<DBG_MAXFILES;i++) { 168 DbgEnabledLvl2 [i] = 1;168 DbgEnabledLvl2KERNEL32[i] = 1; 169 169 } 170 170 } … … 174 174 if(dbgvar) { 175 175 if(*(dbgvar-1) == '-') { 176 DbgEnabledLvl2 [i] = 0;176 DbgEnabledLvl2KERNEL32[i] = 0; 177 177 } 178 178 else 179 179 if(*(dbgvar-1) == '+') { 180 DbgEnabledLvl2 [i] = 1;180 DbgEnabledLvl2KERNEL32[i] = 1; 181 181 } 182 182 } -
trunk/src/kernel32/dbglocal.h
r5587 r6375 13 13 #ifdef DEBUG 14 14 //Parses environment variable for selective enabling/disabling of logging 15 void ParseLogStatus ();15 void ParseLogStatusKERNEL32(); 16 16 17 17 #define DBG_ENVNAME "dbg_kernel32" … … 124 124 #define DBG_MAXFILES 104 125 125 126 extern USHORT DbgEnabled [DBG_MAXFILES];127 extern USHORT DbgEnabledLvl2 [DBG_MAXFILES];126 extern USHORT DbgEnabledKERNEL32[DBG_MAXFILES]; 127 extern USHORT DbgEnabledLvl2KERNEL32[DBG_MAXFILES]; 128 128 129 129 #ifdef dprintf … … 131 131 #endif 132 132 133 #define dprintf(a) if(DbgEnabled [DBG_LOCALLOG] == 1) WriteLog a133 #define dprintf(a) if(DbgEnabledKERNEL32[DBG_LOCALLOG] == 1) WriteLog a 134 134 135 135 #ifdef dprintf2 … … 137 137 #endif 138 138 139 #define dprintf2(a) if(DbgEnabledLvl2 [DBG_LOCALLOG] == 1) WriteLog a139 #define dprintf2(a) if(DbgEnabledLvl2KERNEL32[DBG_LOCALLOG] == 1) WriteLog a 140 140 141 141 #else 142 142 143 #define ParseLogStatus ()143 #define ParseLogStatusKERNEL32() 144 144 145 145 #endif //DEBUG -
trunk/src/kernel32/exceptstackdump.cpp
r4555 r6375 1 /* $Id: exceptstackdump.cpp,v 1. 3 2000-11-05 13:40:45sandervl Exp $ */1 /* $Id: exceptstackdump.cpp,v 1.4 2001-07-20 15:33:29 sandervl Exp $ */ 2 2 /* 3 3 * Stack dump code … … 30 30 31 31 #undef dprintf 32 #define dprintf(a) if(DbgEnabled [DBG_LOCALLOG] == 1) WriteLogNoEOL a32 #define dprintf(a) if(DbgEnabledKERNEL32[DBG_LOCALLOG] == 1) WriteLogNoEOL a 33 33 34 34 /* ****************************************************************** -
trunk/src/kernel32/exceptutil.asm
r6133 r6375 1 ; $Id: exceptutil.asm,v 1.1 7 2001-06-27 19:09:35sandervl Exp $1 ; $Id: exceptutil.asm,v 1.18 2001-07-20 15:33:29 sandervl Exp $ 2 2 3 3 ;/* … … 160 160 getEAX endp 161 161 162 public getEDX 163 getEDX proc near 164 mov EAX, EDX 165 ret 166 endp 167 162 168 getEBX proc near 163 169 mov eax, ebx … … 292 298 EXTRN _GetThreadTEB@0:PROC 293 299 IFDEF DEBUG 294 EXTRN DbgEnabled :DWORD300 EXTRN DbgEnabledKERNEL32:DWORD 295 301 ENDIF 296 302 … … 375 381 ; 299 dprintf(("KERNEL32: Calling handler at %p code=%lx flags=%lx\n", 376 382 IFDEF DEBUG 377 cmp word ptr DbgEnabled +020h,01h383 cmp word ptr DbgEnabledKERNEL32+020h,01h 378 384 jne @BLBL20 379 385 mov eax,[ebp+08h]; record … … 400 406 IFDEF DEBUG 401 407 ; 302 dprintf(("KERNEL32: Handler returned %lx\n", ret)); 402 cmp word ptr DbgEnabled +020h,01h408 cmp word ptr DbgEnabledKERNEL32+020h,01h 403 409 jne @BLBL21 404 410 push dword ptr [ebp-010h]; ret -
trunk/src/kernel32/initterm.cpp
r6340 r6375 58 58 #include "dbglocal.h" 59 59 60 PVOID SYSTEM _O32_GetEnvironmentStrings( VOID );61 60 BOOL fVersionWarp3 = FALSE; 62 61 … … 68 67 /*-------------------------------------------------------------------*/ 69 68 static void APIENTRY cleanup(ULONG reason); 70 71 extern "C" {72 //Win32 resource table (produced by wrc)73 extern DWORD _Resource_PEResTab;74 }75 76 //Global DLL Data77 #pragma data_seg(_GLOBALDATA)78 int globLoadNr = 0;79 #pragma data_seg()80 81 /* Tue 03.03.1998: knut */82 ULONG flAllocMem = 0; /* flag to optimize DosAllocMem to use all the memory on SMP machines */83 ULONG ulMaxAddr = 0x20000000; /* end of user address space. */84 int loadNr = 0;85 char kernel32Path[CCHMAXPATH] = "";86 static HMODULE dllHandle = 0;87 69 88 70 /****************************************************************************/ … … 110 92 case 0 : 111 93 { 112 ParseLogStatus();113 114 /*115 * Init the win32k library.116 * We will also need to tell win32k where the Odin32 environment is117 * located. Currently that is within Open32. I'm quite sure that it's118 * not relocated during run, so we're pretty well off.119 */120 if (!libWin32kInit())121 {122 rc = libWin32kSetEnvironment((PSZ)_O32_GetEnvironmentStrings(), 0, 0);123 if (rc)124 {125 dprintf(("KERNEL32: initterm: libWin32kSetEnvironment failed with rc=%d\n", rc));126 }127 }128 129 loadNr = globLoadNr++;130 131 strcpy(kernel32Path, OSLibGetDllName(hModule));132 char *endofpath = strrchr(kernel32Path, '\\');133 *(endofpath+1) = 0;134 dprintf(("kernel32 init %s %s (%x) Win32k - %s", __DATE__, __TIME__, DLLENTRYPOINT_NAME,135 libWin32kInstalled() ? "Installed" : "Not Installed"));136 94 ctordtorInit(); 137 95 138 96 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/ 139 140 OpenPrivateLogFiles();141 142 if (InitializeSharedHeap() == FALSE)143 return 0UL;144 145 if (InitializeCodeHeap() == FALSE)146 return 0UL;147 148 PROFILE_LoadOdinIni();149 dllHandle = RegisterLxDll(hModule, 0, (PVOID)&_Resource_PEResTab);150 if (dllHandle == 0)151 return 0UL;152 153 //SvL: Kernel32 is a special case; pe.exe loads it, so increase154 // the reference count here155 Win32DllBase *module = Win32DllBase::findModule(dllHandle);156 if (module)157 {158 module->AddRef();159 module->DisableUnload();160 }161 97 162 98 /*******************************************************************/ … … 169 105 return 0UL; 170 106 171 /* knut: check for high memory support */172 rc = DosQuerySysInfo(QSV_VIRTUALADDRESSLIMIT, QSV_VIRTUALADDRESSLIMIT, &ulSysinfo, sizeof(ulSysinfo));173 if (rc == 0 && ulSysinfo > 512) //VirtualAddresslimit is in MB174 {175 flAllocMem = PAG_ANY; // high memory support. Let's use it!176 ulMaxAddr = ulSysinfo * (1024*1024);177 OSLibInitWSeBFileIO();178 if (PROFILE_GetOdinIniInt(ODINSYSTEM_SECTION, HIGHMEM_KEY, 1) == 0) {179 dprintf(("WARNING: OS/2 kernel supports high memory, but support is DISABLED because of HIGHMEM odin.ini key"));180 flAllocMem = 0;181 }182 }183 else184 flAllocMem = 0; // no high memory support185 186 OSLibDosSetInitialMaxFileHandles(ODIN_DEFAULT_MAX_FILEHANDLES);187 188 //SvL: Do it here instead of during the exe object creation189 //(std handles can be used in win32 dll initialization routines190 HMInitialize(); /* store standard handles within HandleManager */191 InitDirectories(); //Must be done before InitializeTIB (which loads NTDLL -> USER32)192 InitializeTIB(TRUE); //Must be done after HMInitialize!193 RegisterDevices();194 Win32DllBase::setDefaultRenaming();195 rc = DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &ulSysinfo, sizeof(ulSysinfo));196 if (rc != 0)197 ulSysinfo = 1;198 199 107 rc = DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_VERSION_MINOR, version, sizeof(version)); 200 108 if(rc == 0){ … … 203 111 } 204 112 } 205 206 /* Setup codepage info */ 207 CODEPAGE_Init(); 208 209 InitSystemInfo(ulSysinfo); 210 //Set up environment as found in NT 211 InitEnvironment(ulSysinfo); 212 213 //InitDynamicRegistry creates/changes keys that may change (i.e. odin.ini 214 //keys that affect windows version) 215 InitDynamicRegistry(); 113 114 rc = inittermKernel32(hModule, ulFlag); 216 115 break; 217 116 } 218 117 219 118 case 1 : 220 if (dllHandle) 221 { 222 UnregisterLxDll(dllHandle); 223 } 119 rc = inittermKernel32(hModule, ulFlag); 224 120 break; 225 121 … … 237 133 static void APIENTRY cleanup(ULONG ulReason) 238 134 { 239 dprintf(("kernel32 exit %d\n", ulReason)); 240 //Flush and delete all open memory mapped files 241 Win32MemMap::deleteAll(); 242 WinExe = NULL; 135 cleanupKernel32(ulReason); 243 136 244 WriteOutProfiles();245 DestroyTIB();246 DestroySharedHeap();247 DestroyCodeHeap();248 137 ctordtorTerm(); 249 250 //NOTE: Must be done after DestroyTIB251 ClosePrivateLogFiles();252 CloseLogFile();253 254 /*255 * Terminate win32k library.256 */257 libWin32kSetEnvironment(NULL, 0, 0);258 libWin32kTerm();259 138 260 139 DosExitList(EXLST_EXIT, cleanup); -
trunk/src/kernel32/kernel32.mak
r6060 r6375 1 # $Id: kernel32.mak,v 1. 7 2001-06-21 21:07:54sandervl Exp $1 # $Id: kernel32.mak,v 1.8 2001-07-20 15:33:30 sandervl Exp $ 2 2 3 3 # … … 20 20 # Overrides. 21 21 # 22 ##CDEFINES = $(CDEFINES) -D USE_OS2SEMAPHORES22 ##CDEFINES = $(CDEFINES) -DTEST_BUILTIN 23 23 24 24 … … 66 66 $(OBJDIR)\vsemaphore.obj \ 67 67 $(OBJDIR)\initterm.obj \ 68 $(OBJDIR)\initkernel32.obj \ 68 69 $(OBJDIR)\handlemanager.obj \ 69 70 $(OBJDIR)\environ.obj \ … … 138 139 LIBS = \ 139 140 $(ODIN32_LIB)/$(ODINCRT).lib \ 141 ##$(ODIN32_LIB)\wgss.lib \ 140 142 $(ODIN32_LIB)\PMWINX.LIB \ 141 143 $(ODIN32_LIB)\LIBULS.LIB \ -
trunk/src/kernel32/time.cpp
r5818 r6375 1 /* $Id: time.cpp,v 1.1 5 2001-05-28 14:47:49 phallerExp $ */1 /* $Id: time.cpp,v 1.16 2001-07-20 15:33:30 sandervl Exp $ */ 2 2 3 3 /* … … 191 191 return O32_SetSystemTime(arg1); 192 192 } 193 194 /***********************************************************************195 * WPRINTF_ParseFormatA196 *197 * Parse a format specification. A format specification has the form:198 *199 * [-][#][0][width][.precision]type200 *201 * Return value is the length of the format specification in characters.202 */203 static INT WPRINTF_ParseFormatA( LPCSTR format, WPRINTF_FORMAT *res )204 {205 LPCSTR p = format;206 207 res->flags = 0;208 res->width = 0;209 res->precision = 0;210 if (*p == '-') { res->flags |= WPRINTF_LEFTALIGN; p++; }211 if (*p == '#') { res->flags |= WPRINTF_PREFIX_HEX; p++; }212 if (*p == '0') { res->flags |= WPRINTF_ZEROPAD; p++; }213 while ((*p >= '0') && (*p <= '9')) /* width field */214 {215 res->width = res->width * 10 + *p - '0';216 p++;217 }218 if (*p == '.') /* precision field */219 {220 p++;221 while ((*p >= '0') && (*p <= '9'))222 {223 res->precision = res->precision * 10 + *p - '0';224 p++;225 }226 }227 if (*p == 'l') { res->flags |= WPRINTF_LONG; p++; }228 else if (*p == 'h') { res->flags |= WPRINTF_SHORT; p++; }229 else if (*p == 'w') { res->flags |= WPRINTF_WIDE; p++; }230 switch(*p)231 {232 case 'c':233 res->type = (res->flags & WPRINTF_LONG) ? WPR_WCHAR : WPR_CHAR;234 break;235 case 'C':236 res->type = (res->flags & WPRINTF_SHORT) ? WPR_CHAR : WPR_WCHAR;237 break;238 case 'd':239 case 'i':240 res->type = WPR_SIGNED;241 break;242 case 's':243 res->type = (res->flags & (WPRINTF_LONG |WPRINTF_WIDE))244 ? WPR_WSTRING : WPR_STRING;245 break;246 case 'S':247 res->type = (res->flags & (WPRINTF_SHORT|WPRINTF_WIDE))248 ? WPR_STRING : WPR_WSTRING;249 break;250 case 'u':251 res->type = WPR_UNSIGNED;252 break;253 case 'X':254 res->flags |= WPRINTF_UPPER_HEX;255 /* fall through */256 case 'x':257 res->type = WPR_HEXA;258 break;259 default: /* unknown format char */260 res->type = WPR_UNKNOWN;261 p--; /* print format as normal char */262 break;263 }264 return (INT)(p - format) + 1;265 }266 267 268 /***********************************************************************269 * WPRINTF_ParseFormatW270 *271 * Parse a format specification. A format specification has the form:272 *273 * [-][#][0][width][.precision]type274 *275 * Return value is the length of the format specification in characters.276 */277 static INT WPRINTF_ParseFormatW( LPCWSTR format, WPRINTF_FORMAT *res )278 {279 LPCWSTR p = format;280 281 res->flags = 0;282 res->width = 0;283 res->precision = 0;284 if (*p == '-') { res->flags |= WPRINTF_LEFTALIGN; p++; }285 if (*p == '#') { res->flags |= WPRINTF_PREFIX_HEX; p++; }286 if (*p == '0') { res->flags |= WPRINTF_ZEROPAD; p++; }287 while ((*p >= '0') && (*p <= '9')) /* width field */288 {289 res->width = res->width * 10 + *p - '0';290 p++;291 }292 if (*p == '.') /* precision field */293 {294 p++;295 while ((*p >= '0') && (*p <= '9'))296 {297 res->precision = res->precision * 10 + *p - '0';298 p++;299 }300 }301 if (*p == 'l') { res->flags |= WPRINTF_LONG; p++; }302 else if (*p == 'h') { res->flags |= WPRINTF_SHORT; p++; }303 else if (*p == 'w') { res->flags |= WPRINTF_WIDE; p++; }304 switch((CHAR)*p)305 {306 case 'c':307 res->type = (res->flags & WPRINTF_SHORT) ? WPR_CHAR : WPR_WCHAR;308 break;309 case 'C':310 res->type = (res->flags & WPRINTF_LONG) ? WPR_WCHAR : WPR_CHAR;311 break;312 case 'd':313 case 'i':314 res->type = WPR_SIGNED;315 break;316 case 's':317 res->type = ((res->flags & WPRINTF_SHORT) && !(res->flags & WPRINTF_WIDE)) ? WPR_STRING : WPR_WSTRING;318 break;319 case 'S':320 res->type = (res->flags & (WPRINTF_LONG|WPRINTF_WIDE)) ? WPR_WSTRING : WPR_STRING;321 break;322 case 'u':323 res->type = WPR_UNSIGNED;324 break;325 case 'X':326 res->flags |= WPRINTF_UPPER_HEX;327 /* fall through */328 case 'x':329 res->type = WPR_HEXA;330 break;331 default:332 res->type = WPR_UNKNOWN;333 p--; /* print format as normal char */334 break;335 }336 return (INT)(p - format) + 1;337 }338 339 340 /***********************************************************************341 * WPRINTF_GetLen342 */343 static UINT WPRINTF_GetLen( WPRINTF_FORMAT *format, WPRINTF_DATA *arg,344 LPSTR number, UINT maxlen )345 {346 UINT len;347 348 if (format->flags & WPRINTF_LEFTALIGN) format->flags &= ~WPRINTF_ZEROPAD;349 if (format->width > maxlen) format->width = maxlen;350 switch(format->type)351 {352 case WPR_CHAR:353 case WPR_WCHAR:354 return (format->precision = 1);355 case WPR_STRING:356 if (!arg->lpcstr_view) arg->lpcstr_view = null_stringA;357 for (len = 0; !format->precision || (len < format->precision); len++)358 if (!*(arg->lpcstr_view + len)) break;359 if (len > maxlen) len = maxlen;360 return (format->precision = len);361 case WPR_WSTRING:362 if (!arg->lpcwstr_view) arg->lpcwstr_view = null_stringW;363 for (len = 0; !format->precision || (len < format->precision); len++)364 if (!*(arg->lpcwstr_view + len)) break;365 if (len > maxlen) len = maxlen;366 return (format->precision = len);367 case WPR_SIGNED:368 len = sprintf( number, "%d", arg->int_view );369 break;370 case WPR_UNSIGNED:371 len = sprintf( number, "%u", (UINT)arg->int_view );372 break;373 case WPR_HEXA:374 len = sprintf( number,375 (format->flags & WPRINTF_UPPER_HEX) ? "%X" : "%x",376 (UINT)arg->int_view);377 if (format->flags & WPRINTF_PREFIX_HEX) len += 2;378 break;379 default:380 return 0;381 }382 if (len > maxlen) len = maxlen;383 if (format->precision < len) format->precision = len;384 if (format->precision > maxlen) format->precision = maxlen;385 if ((format->flags & WPRINTF_ZEROPAD) && (format->width > format->precision))386 format->precision = format->width;387 return len;388 }389 390 /***********************************************************************391 * WPRINTF_ExtractVAPtr (Not a Windows API)392 */393 static WPRINTF_DATA WPRINTF_ExtractVAPtr( WPRINTF_FORMAT *format, va_list* args )394 {395 WPRINTF_DATA result;396 switch(format->type)397 {398 case WPR_WCHAR:399 result.wchar_view = va_arg( *args, WCHAR ); break;400 case WPR_CHAR:401 result.char_view = va_arg( *args, CHAR ); break;402 case WPR_STRING:403 result.lpcstr_view = va_arg( *args, LPCSTR); break;404 case WPR_WSTRING:405 result.lpcwstr_view = va_arg( *args, LPCWSTR); break;406 case WPR_HEXA:407 case WPR_SIGNED:408 case WPR_UNSIGNED:409 result.int_view = va_arg( *args, INT ); break;410 default:411 result.wchar_view = 0; break;412 }413 return result;414 }415 416 /***********************************************************************417 * wvsnprintfA (Not a Windows API)418 */419 INT WINAPI wvsnprintfA( LPSTR buffer, UINT maxlen, LPCSTR spec,420 va_list args )421 {422 WPRINTF_FORMAT format;423 LPSTR p = buffer;424 UINT i, len;425 CHAR number[20];426 WPRINTF_DATA argData;427 428 while (*spec && (maxlen > 1))429 {430 if (*spec != '%') { *p++ = *spec++; maxlen--; continue; }431 spec++;432 if (*spec == '%') { *p++ = *spec++; maxlen--; continue; }433 spec += WPRINTF_ParseFormatA( spec, &format );434 argData = WPRINTF_ExtractVAPtr( &format, &args );435 len = WPRINTF_GetLen( &format, &argData, number, maxlen - 1 );436 if (!(format.flags & WPRINTF_LEFTALIGN))437 for (i = format.precision; i < format.width; i++, maxlen--)438 *p++ = ' ';439 switch(format.type)440 {441 case WPR_WCHAR:442 *p = argData.wchar_view;443 if (*p != '\0') p++;444 else if (format.width > 1) *p++ = ' ';445 else len = 0;446 break;447 case WPR_CHAR:448 *p = argData.char_view;449 if (*p != '\0') p++;450 else if (format.width > 1) *p++ = ' ';451 else len = 0;452 break;453 case WPR_STRING:454 memcpy( p, argData.lpcstr_view, len );455 p += len;456 break;457 case WPR_WSTRING:458 {459 LPCWSTR ptr = argData.lpcwstr_view;460 for (i = 0; i < len; i++) *p++ = (CHAR)*ptr++;461 }462 break;463 case WPR_HEXA:464 if ((format.flags & WPRINTF_PREFIX_HEX) && (maxlen > 3))465 {466 *p++ = '0';467 *p++ = (format.flags & WPRINTF_UPPER_HEX) ? 'X' : 'x';468 maxlen -= 2;469 len -= 2;470 format.precision -= 2;471 format.width -= 2;472 }473 /* fall through */474 case WPR_SIGNED:475 case WPR_UNSIGNED:476 for (i = len; i < format.precision; i++, maxlen--) *p++ = '0';477 memcpy( p, number, len );478 p += len;479 /* Go to the next arg */480 break;481 case WPR_UNKNOWN:482 continue;483 }484 if (format.flags & WPRINTF_LEFTALIGN)485 for (i = format.precision; i < format.width; i++, maxlen--)486 *p++ = ' ';487 maxlen -= len;488 }489 *p = 0;490 //TRACE("%s\n",buffer);491 return (maxlen > 1) ? (INT)(p - buffer) : -1;492 }493 494 495 /***********************************************************************496 * wvsnprintfW (Not a Windows API)497 */498 INT WINAPI wvsnprintfW( LPWSTR buffer, UINT maxlen, LPCWSTR spec,499 va_list args )500 {501 WPRINTF_FORMAT format;502 LPWSTR p = buffer;503 UINT i, len;504 CHAR number[20];505 506 while (*spec && (maxlen > 1))507 {508 if (*spec != '%') { *p++ = *spec++; maxlen--; continue; }509 spec++;510 if (*spec == '%') { *p++ = *spec++; maxlen--; continue; }511 spec += WPRINTF_ParseFormatW( spec, &format );512 len = WPRINTF_GetLen( &format, (WPRINTF_DATA*)args, number, maxlen - 1 );513 if (!(format.flags & WPRINTF_LEFTALIGN))514 for (i = format.precision; i < format.width; i++, maxlen--)515 *p++ = ' ';516 switch(format.type)517 {518 case WPR_WCHAR:519 *p = va_arg( args, WCHAR );520 if (*p != '\0') p++;521 else if (format.width > 1) *p++ = ' ';522 else len = 0;523 break;524 case WPR_CHAR:525 *p = (WCHAR)va_arg( args, CHAR );526 if (*p != '\0') p++;527 else if (format.width > 1) *p++ = ' ';528 else len = 0;529 break;530 case WPR_STRING:531 {532 LPCSTR ptr = va_arg( args, LPCSTR );533 for (i = 0; i < len; i++) *p++ = (WCHAR)*ptr++;534 }535 break;536 case WPR_WSTRING:537 if (len) memcpy( p, va_arg( args, LPCWSTR ), len * sizeof(WCHAR) );538 p += len;539 break;540 case WPR_HEXA:541 if ((format.flags & WPRINTF_PREFIX_HEX) && (maxlen > 3))542 {543 *p++ = '0';544 *p++ = (format.flags & WPRINTF_UPPER_HEX) ? 'X' : 'x';545 maxlen -= 2;546 len -= 2;547 format.precision -= 2;548 format.width -= 2;549 }550 /* fall through */551 case WPR_SIGNED:552 case WPR_UNSIGNED:553 for (i = len; i < format.precision; i++, maxlen--) *p++ = '0';554 for (i = 0; i < len; i++) *p++ = (WCHAR)number[i];555 (void)va_arg( args, INT ); /* Go to the next arg */556 break;557 case WPR_UNKNOWN:558 continue;559 }560 if (format.flags & WPRINTF_LEFTALIGN)561 for (i = format.precision; i < format.width; i++, maxlen--)562 *p++ = ' ';563 maxlen -= len;564 }565 *p = 0;566 return (maxlen > 1) ? (INT)(p - buffer) : -1;567 }568 569 /***********************************************************************570 * wsnprintfA (Not a Windows API)571 */572 INT WINAPIV wsnprintfA( LPSTR buffer, UINT maxlen, LPCSTR spec, ... )573 {574 va_list valist;575 INT res;576 577 va_start( valist, spec );578 res = wvsnprintfA( buffer, maxlen, spec, valist );579 va_end( valist );580 return res;581 }582 583 /***********************************************************************584 * wsnprintfW (Not a Windows API)585 */586 INT WINAPIV wsnprintfW( LPWSTR buffer, UINT maxlen, LPCWSTR spec, ... )587 {588 va_list valist;589 INT res;590 591 va_start( valist, spec );592 res = wvsnprintfW( buffer, maxlen, spec, valist );593 va_end( valist );594 return res;595 }596 597 598 193 /***************************************************************************** 599 194 * Name : DWORD GetSystemTimeAsFileTime
Note:
See TracChangeset
for help on using the changeset viewer.