Back to index

lightning-sunbird  0.9+nobinonly
win32A.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code, released
00017  * Jan 28, 2003.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 2003
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   Garrett Arch Blythe, 28-January-2003
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either the GNU General Public License Version 2 or later (the "GPL"), or
00029  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #include "mozce_internal.h"
00042 
00043 #include <commdlg.h>
00044 
00045 extern "C" {
00046 #if 0
00047 }
00048 #endif
00049 
00050 #define IS_INTRESOURCE(_r)   (((ULONG_PTR)(_r) >> 16) == 0)
00051 
00052 /*
00053 **  Help figure the character count of a TCHAR array.
00054 */
00055 
00056 MOZCE_SHUNT_API DWORD mozce_GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
00057 {
00058     MOZCE_PRECHECK
00059 
00060 #ifdef DEBUG
00061     mozce_printf("mozce_GetModuleFileNameA called\n");
00062 #endif
00063     
00064     TCHAR wideStr[MAX_PATH];
00065     
00066     DWORD result = w2a_buffer(wideStr, 
00067                               GetModuleFileNameW(hModule, 
00068                                                  wideStr, 
00069                                                  charcount(wideStr)), 
00070                               lpFilename, nSize);
00071     lpFilename[result] = '\0';
00072 
00073     return result;
00074 }
00075 
00076 MOZCE_SHUNT_API BOOL mozce_CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
00077 {
00078     MOZCE_PRECHECK
00079 
00080 #ifdef DEBUG
00081     mozce_printf("mozce_CreateDirectoryA called (%s)\n", lpPathName);
00082 #endif
00083     
00084     BOOL retval = FALSE;
00085     TCHAR wideStr[MAX_PATH];
00086 
00087     if(a2w_buffer(lpPathName, -1, wideStr, MAX_PATH))
00088     {
00089         retval = CreateDirectoryW(wideStr, lpSecurityAttributes);
00090     }
00091     
00092     return retval;
00093 }
00094 
00095 MOZCE_SHUNT_API BOOL mozce_RemoveDirectoryA(LPCSTR lpPathName)
00096 {
00097     MOZCE_PRECHECK
00098 
00099 #ifdef DEBUG
00100     mozce_printf("mozce_RemoveDirectoryA called\n");
00101 #endif
00102 
00103     BOOL retval = FALSE;
00104     TCHAR wideStr[MAX_PATH];
00105 
00106     if(a2w_buffer(lpPathName, -1, wideStr, MAX_PATH))
00107     {
00108         retval = RemoveDirectoryW(wideStr);
00109     }
00110     return retval;
00111 }
00112 
00113 MOZCE_SHUNT_API BOOL mozce_DeleteFileA(LPCSTR lpFileName)
00114 {
00115     MOZCE_PRECHECK
00116 
00117 #ifdef DEBUG
00118     mozce_printf("mozce_DeleteFile called\n");
00119 #endif
00120 
00121     BOOL retval = FALSE;
00122     TCHAR wideStr[MAX_PATH];
00123 
00124     if(a2w_buffer(lpFileName, -1, wideStr, MAX_PATH))
00125     {
00126         retval = DeleteFileW(wideStr);
00127     }
00128     return retval;
00129 }
00130 
00131 MOZCE_SHUNT_API BOOL mozce_MoveFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName)
00132 {
00133     MOZCE_PRECHECK
00134 
00135 #ifdef DEBUG
00136     mozce_printf("mozce_MoveFileA called (%s)\n", lpExistingFileName);
00137 #endif
00138 
00139     BOOL retval = FALSE;
00140     TCHAR wideStr[2][MAX_PATH];
00141 
00142     if(a2w_buffer(lpExistingFileName, -1, wideStr[0], MAX_PATH) &&
00143        a2w_buffer(lpNewFileName, -1, wideStr[1], MAX_PATH))
00144     {
00145         retval = MoveFileW(wideStr[0], wideStr[1]);
00146     }
00147     return retval;
00148 }
00149 
00150 
00151 MOZCE_SHUNT_API BOOL mozce_CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, BOOL bFailIfExists)
00152 {
00153     MOZCE_PRECHECK
00154 
00155 #ifdef DEBUG
00156     mozce_printf("mozce_CopyFileA called\n");
00157 #endif
00158 
00159     BOOL retval = FALSE;
00160     TCHAR wideStr[2][MAX_PATH];
00161 
00162     if(a2w_buffer(lpExistingFileName, -1, wideStr[0], MAX_PATH) &&
00163        a2w_buffer(lpNewFileName, -1, wideStr[1], MAX_PATH))
00164     {
00165         retval = CopyFileW(wideStr[0], wideStr[1], bFailIfExists);
00166     }
00167     return retval;
00168 }
00169 
00170 
00171 MOZCE_SHUNT_API HANDLE mozce_CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
00172 {
00173     MOZCE_PRECHECK
00174 
00175 #ifdef DEBUG
00176     mozce_printf("mozce_CreateFileA called (%s)\n", lpFileName);
00177 #endif
00178 
00179     HANDLE retval = INVALID_HANDLE_VALUE;
00180     TCHAR wideStr[MAX_PATH];
00181 
00182     if(a2w_buffer(lpFileName, -1, wideStr, MAX_PATH))
00183     {
00184         retval = CreateFileW(wideStr, 
00185                              dwDesiredAccess, 
00186                              dwShareMode, 
00187                              lpSecurityAttributes, 
00188                              dwCreationDisposition, 
00189                              dwFlagsAndAttributes, 
00190                              hTemplateFile);
00191     }
00192     return retval;
00193 }
00194 
00195 
00196 MOZCE_SHUNT_API DWORD mozce_GetFileAttributesA(LPCSTR lpFileName)
00197 {
00198     MOZCE_PRECHECK
00199 
00200 #ifdef DEBUG
00201     mozce_printf("mozce_GetFileAttributesA called\n");
00202 #endif
00203 
00204     DWORD retval = (DWORD)-1;
00205     TCHAR wideStr[MAX_PATH];
00206 
00207     if(a2w_buffer(lpFileName, -1, wideStr, MAX_PATH))
00208     {
00209         retval = GetFileAttributesW(wideStr);
00210     }
00211 
00212     return retval;
00213 }
00214 
00215 MOZCE_SHUNT_API HANDLE mozce_CreateMutexA(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCSTR lpName)
00216 {
00217     MOZCE_PRECHECK
00218 
00219 #ifdef DEBUG
00220     mozce_printf("mozce_CreateMutexA called\n");
00221 #endif
00222     
00223     if (!lpName)
00224         return CreateMutexW(lpMutexAttributes, bInitialOwner, NULL);
00225     
00226     LPTSTR widestr = a2w_malloc(lpName, -1, NULL);
00227     HANDLE h = CreateMutexW(lpMutexAttributes, bInitialOwner, widestr);
00228     free(widestr);
00229     return h;
00230 }
00231 
00232 MOZCE_SHUNT_API BOOL mozce_CreateProcessA(LPCSTR pszImageName, LPCSTR pszCmdLine, LPSECURITY_ATTRIBUTES psaProcess, LPSECURITY_ATTRIBUTES psaThread, BOOL fInheritHandles, DWORD fdwCreate, LPVOID pvEnvironment, LPSTR pszCurDir, LPSTARTUPINFO psiStartInfo, LPPROCESS_INFORMATION pProcInfo)
00233 {
00234     MOZCE_PRECHECK
00235 
00236 #ifdef DEBUG
00237     mozce_printf("mozce_CreateProcessA called\n");
00238 #endif
00239 
00240        LPTSTR image   = a2w_malloc(pszImageName, -1, NULL);
00241        LPTSTR cmdline = a2w_malloc(pszCmdLine, -1, NULL);
00242 
00243        BOOL retval = CreateProcessW(image, cmdline, NULL, NULL, FALSE, fdwCreate, NULL, NULL, NULL, pProcInfo);
00244 
00245        if (image)
00246               free(image);
00247        
00248        if (cmdline)
00249               free(cmdline);
00250 
00251     return retval;
00252 }
00253 
00254 
00255 MOZCE_SHUNT_API int mozce_GetLocaleInfoA(LCID Locale, LCTYPE LCType, LPSTR lpLCData, int cchData)
00256 {
00257     MOZCE_PRECHECK
00258 
00259 #ifdef DEBUG
00260     mozce_printf("mozce_GetLocaleInfoA called\n");
00261 #endif
00262 
00263     int retval = 0;
00264     int neededChars = 0;
00265 
00266     neededChars = GetLocaleInfoW(Locale, LCType, NULL, 0);
00267     if(0 != neededChars)
00268     {
00269         LPTSTR buffer = NULL;
00270 
00271         buffer = (LPTSTR)malloc(neededChars * sizeof(TCHAR));
00272         if(NULL != buffer)
00273         {
00274             int gotChars = 0;
00275 
00276             gotChars = GetLocaleInfoW(Locale, LCType, buffer, neededChars);
00277             if(0 != gotChars)
00278             {
00279                 if(0 == cchData)
00280                 {
00281                     retval = WideCharToMultiByte(CP_ACP,
00282                                                  0,
00283                                                  buffer,
00284                                                  neededChars,
00285                                                  NULL,
00286                                                  0,
00287                                                  NULL,
00288                                                  NULL
00289                                                  );
00290                     
00291                 }
00292                 else
00293                 {
00294                     retval = w2a_buffer(buffer, neededChars, lpLCData, cchData);
00295                 }
00296             }
00297 
00298             free(buffer);
00299         }
00300     }
00301 
00302     return retval;
00303 }
00304 
00305 MOZCE_SHUNT_API UINT mozce_GetWindowsDirectoryA(LPSTR inBuffer, UINT inSize)
00306 {
00307     MOZCE_PRECHECK
00308 
00309 #ifdef DEBUG
00310     mozce_printf("mozce_GetWindowsDirectoryA called\n");
00311 #endif
00312 
00313     UINT retval = 0;
00314 
00315     if(inSize < 9)
00316     {
00317         retval = 9;
00318     }
00319     else
00320     {
00321         strcpy(inBuffer, "\\WINDOWS");
00322         retval = 8;
00323     }
00324 
00325     return retval;
00326 }
00327 
00328 
00329 MOZCE_SHUNT_API UINT mozce_GetSystemDirectoryA(LPSTR inBuffer, UINT inSize)
00330 {
00331     MOZCE_PRECHECK
00332 
00333 #ifdef DEBUG
00334     mozce_printf("mozce_GetSystemDirectoryA called\n");
00335 #endif
00336 
00337     UINT retval = 0;
00338 
00339     if(inSize < 9)
00340     {
00341         retval = 9;
00342     }
00343     else
00344     {
00345         strcpy(inBuffer, "\\WINDOWS");
00346         retval = 8;
00347     }
00348     return retval;
00349 }
00350 
00351 MOZCE_SHUNT_API LONG mozce_RegOpenKeyExA(HKEY inKey, LPCSTR inSubKey, DWORD inOptions, REGSAM inSAM, PHKEY outResult)
00352 {
00353     MOZCE_PRECHECK
00354 
00355 #ifdef DEBUG
00356     mozce_printf("mozce_RegOpenKeyExA called\n");
00357 #endif
00358 
00359     LONG retval = ERROR_GEN_FAILURE;
00360 
00361     LPTSTR wSubKey = a2w_malloc(inSubKey, -1, NULL);
00362     if(NULL != wSubKey)
00363     {
00364         retval = RegOpenKeyEx(inKey, wSubKey, inOptions, inSAM, outResult);
00365         free(wSubKey);
00366     }
00367     return retval;
00368 }
00369 
00370 
00371 MOZCE_SHUNT_API LONG mozce_RegQueryValueExA(HKEY inKey, LPCSTR inValueName, LPDWORD inReserved, LPDWORD outType, LPBYTE inoutBData, LPDWORD inoutDData)
00372 {
00373     MOZCE_PRECHECK
00374         
00375 #ifdef DEBUG
00376         mozce_printf("mozce_RegQueryValueExA called\n");
00377 #endif
00378     
00379     LONG retval = ERROR_GEN_FAILURE;
00380     
00381     TCHAR wPath[MAX_PATH], tempData[MAX_PATH];
00382     DWORD tempSize = MAX_PATH;
00383     DWORD ourOutType;
00384     a2w_buffer(inValueName, -1, wPath, MAX_PATH);
00385     
00386        retval = RegQueryValueEx(inKey, inValueName ? wPath : NULL, inReserved, &ourOutType, (LPBYTE)tempData, &tempSize);
00387     
00388     if (ERROR_SUCCESS == retval)
00389     { 
00390         if(REG_EXPAND_SZ == ourOutType || REG_SZ == ourOutType)
00391         {
00392             w2a_buffer(tempData, tempSize, (LPSTR)inoutBData, *inoutDData);
00393         }
00394         else
00395         {
00396             memcpy(inoutBData, tempData, tempSize);
00397             *inoutDData = tempSize;
00398         }
00399 
00400         if (outType)
00401             *outType = ourOutType;
00402     }
00403 
00404     return retval;
00405 }
00406 
00407 
00408 
00409 MOZCE_SHUNT_API LONG mozce_RegSetValueExA(HKEY hKey, const char *valname, DWORD dwReserved, DWORD dwType, const BYTE* lpData, DWORD dwSize)
00410 {
00411     MOZCE_PRECHECK
00412 
00413 #ifdef DEBUG
00414     mozce_printf("mozce_RegSetValueExA called\n");
00415 #endif
00416 
00417   unsigned short valnamew[256];
00418   LONG res;
00419 
00420   LPTSTR wName = NULL;
00421   MultiByteToWideChar(CP_ACP, 0, valname, -1, valnamew, charcount(valnamew));
00422 
00423   if(dwType == REG_SZ || dwType == REG_EXPAND_SZ)
00424       wName = a2w_malloc((char*)lpData, -1, NULL);
00425   else
00426       return -1;
00427 
00428   res = RegSetValueExW(hKey, valname ? valnamew : NULL, dwReserved, dwType, (const BYTE*)wName, (lstrlenW(wName) + 1)*sizeof(WCHAR));
00429 
00430 
00431   return res;
00432 
00433 }
00434 
00435 MOZCE_SHUNT_API LONG mozce_RegCreateKeyExA(HKEY hKey, const char *subkey, DWORD dwRes, LPSTR lpszClass, DWORD ulOptions, REGSAM samDesired, LPSECURITY_ATTRIBUTES sec_att, PHKEY phkResult, DWORD *lpdwDisp)
00436 {
00437     MOZCE_PRECHECK
00438 
00439 #ifdef DEBUG
00440     mozce_printf("mozce_RegCreateKeyExA called\n");
00441 #endif
00442 
00443   LPTSTR wName = a2w_malloc(subkey, -1, NULL);
00444 
00445   long res = RegCreateKeyExW(hKey, wName, dwRes, NULL, ulOptions, samDesired, NULL, phkResult, lpdwDisp);
00446 
00447   free(wName);
00448   return res;
00449 }
00450 
00451 
00452 MOZCE_SHUNT_API LONG mozce_RegDeleteValueA(HKEY hKey, const char* lpValueName)
00453 {
00454   MOZCE_PRECHECK
00455         
00456 #ifdef DEBUG
00457   mozce_printf("mozce_RegDeleteValueA called\n");
00458 #endif
00459 
00460   LPTSTR wName = a2w_malloc(lpValueName, -1, NULL);
00461   long res = RegDeleteKeyW(hKey, wName);
00462   
00463   free(wName);
00464   return res;
00465 }
00466 
00467 
00468 
00469 MOZCE_SHUNT_API int mozce_MessageBoxA(HWND inWnd, LPCSTR inText, LPCSTR inCaption, UINT uType)
00470 {
00471     MOZCE_PRECHECK
00472 
00473 #ifdef DEBUG
00474     mozce_printf("mozce_MessageBoxA called\n");
00475 #endif
00476 
00477     int retval = 0;
00478     LPTSTR wCaption = a2w_malloc(inCaption, -1, NULL);
00479 
00480     if(NULL != wCaption)
00481     {
00482         LPTSTR wText = a2w_malloc(inText, -1, NULL);
00483 
00484         if(NULL != wText)
00485         {
00486             retval = MessageBox(inWnd, wText, wCaption, uType);
00487             free(wText);
00488         }
00489         free(wCaption);
00490     }
00491 
00492     return retval;
00493 }
00494 
00495 
00496 MOZCE_SHUNT_API HANDLE mozce_OpenSemaphoreA(DWORD inDesiredAccess, BOOL inInheritHandle, LPCSTR inName)
00497 {
00498     MOZCE_PRECHECK
00499 
00500 #ifdef DEBUG
00501     mozce_printf("mozce_OpenSemaphoreA called\n");
00502 #endif
00503 
00504     HANDLE retval = NULL;
00505     LPTSTR wName = a2w_malloc(inName, -1, NULL);
00506 
00507     if(NULL != wName)
00508     {
00509         extern HANDLE mozce_OpenSemaphoreW(DWORD inDesiredAccess, BOOL inInheritHandle, LPCWSTR inName);
00510         retval = mozce_OpenSemaphoreW(inDesiredAccess, inDesiredAccess, wName);
00511         free(wName);
00512     }
00513 
00514     return retval;
00515 }
00516 
00517 
00518 MOZCE_SHUNT_API HDC mozce_CreateDCA(LPCSTR inDriver, LPCSTR inDevice, LPCSTR inOutput, CONST DEVMODEA* inInitData)
00519 {
00520     MOZCE_PRECHECK
00521 
00522 #ifdef DEBUG
00523     mozce_printf("mozce_CreateDCA called\n");
00524 #endif
00525 
00526     HDC retval = NULL;
00527 
00528     LPTSTR wDriver = a2w_malloc(inDriver, -1, NULL);
00529     LPTSTR wDevice = a2w_malloc(inDevice, -1, NULL);
00530     LPTSTR wOutput = a2w_malloc(inOutput, -1, NULL);
00531 
00532     DEVMODE wInitData;
00533     if (inInitData)
00534     {
00535         memset(&wInitData, 0, sizeof(wInitData));
00536         
00537         wInitData.dmSpecVersion = inInitData->dmSpecVersion;
00538         wInitData.dmDriverVersion = inInitData->dmDriverVersion;
00539         wInitData.dmSize = inInitData->dmSize;
00540         wInitData.dmDriverExtra = inInitData->dmDriverExtra;
00541         wInitData.dmFields = inInitData->dmFields;
00542         wInitData.dmOrientation = inInitData->dmOrientation;
00543         wInitData.dmPaperSize = inInitData->dmPaperSize;
00544         wInitData.dmPaperLength = inInitData->dmPaperLength;
00545         wInitData.dmPaperWidth = inInitData->dmPaperWidth;
00546         wInitData.dmScale = inInitData->dmScale;
00547         wInitData.dmCopies = inInitData->dmCopies;
00548         wInitData.dmDefaultSource = inInitData->dmDefaultSource;
00549         wInitData.dmPrintQuality = inInitData->dmPrintQuality;
00550         wInitData.dmColor = inInitData->dmColor;
00551         wInitData.dmDuplex = inInitData->dmDuplex;
00552         wInitData.dmYResolution = inInitData->dmYResolution;
00553         wInitData.dmTTOption = inInitData->dmTTOption;
00554         wInitData.dmCollate = inInitData->dmCollate;
00555         wInitData.dmLogPixels = inInitData->dmLogPixels;
00556         wInitData.dmBitsPerPel = inInitData->dmBitsPerPel;
00557         wInitData.dmPelsWidth = inInitData->dmPelsWidth;
00558         wInitData.dmPelsHeight = inInitData->dmPelsHeight;
00559         wInitData.dmDisplayFlags = inInitData->dmDisplayFlags;
00560         wInitData.dmDisplayFrequency = inInitData->dmDisplayFrequency;
00561         a2w_buffer((LPCSTR)inInitData->dmDeviceName, -1, wInitData.dmDeviceName, charcount(wInitData.dmDeviceName));
00562         a2w_buffer((LPCSTR)inInitData->dmFormName, -1, wInitData.dmFormName, charcount(wInitData.dmFormName));
00563     }
00564     retval = CreateDC(wDriver, wDevice, wOutput, inInitData ? &wInitData : NULL);
00565     if(NULL != wDriver)
00566     {
00567         free(wDriver);
00568         wDriver = NULL;
00569     }
00570     if(NULL != wDevice)
00571     {
00572         free(wDevice);
00573         wDevice = NULL;
00574     }
00575     if(NULL != wOutput)
00576     {
00577         free(wOutput);
00578         wOutput = NULL;
00579     }
00580 
00581     return retval;
00582 }
00583 
00584 
00585 MOZCE_SHUNT_API HDC mozce_CreateDCA2(LPCSTR inDriver, LPCSTR inDevice, LPCSTR inOutput, CONST DEVMODE* inInitData)
00586 {
00587     MOZCE_PRECHECK
00588 
00589 #ifdef DEBUG
00590     mozce_printf("mozce_CreateDCA2 called\n");
00591 #endif
00592 
00593     HDC retval = NULL;
00594 
00595     LPTSTR wDriver = a2w_malloc(inDriver, -1, NULL);
00596     LPTSTR wDevice = a2w_malloc(inDevice, -1, NULL);
00597     LPTSTR wOutput = a2w_malloc(inOutput, -1, NULL);
00598 
00599     retval = CreateDC(wDriver, wDevice, wOutput, inInitData);
00600 
00601     if(NULL != wDriver)
00602     {
00603         free(wDriver);
00604         wDriver = NULL;
00605     }
00606     if(NULL != wDevice)
00607     {
00608         free(wDevice);
00609         wDevice = NULL;
00610     }
00611     if(NULL != wOutput)
00612     {
00613         free(wOutput);
00614         wOutput = NULL;
00615     }
00616 
00617     return retval;
00618 }
00619 
00620 MOZCE_SHUNT_API BOOL mozce_GetTextExtentExPointA(HDC inDC, const char * inStr, int inLen, int inMaxExtent, LPINT outFit, LPINT outDx, LPSIZE inSize)
00621 {
00622     MOZCE_PRECHECK
00623 
00624 #ifdef DEBUG
00625   mozce_printf("mozce_GetTextExtentExPointA called (%d)\n", inLen);
00626 #endif
00627 
00628     BOOL retval = FALSE;
00629 
00630     // BUG:  if inString has any embedded nulls, this function will not produce the desired effect!
00631        LPTSTR wStr = a2w_malloc(inStr, inLen, NULL);
00632        
00633     if(NULL != wStr)
00634     {
00635         retval = GetTextExtentExPointW(inDC, wStr, inLen, inMaxExtent, outFit, outDx, inSize);
00636         free(wStr);
00637     }
00638 
00639     return retval;
00640 }
00641 
00642 MOZCE_SHUNT_API BOOL mozce_ExtTextOutA(HDC inDC, int inX, int inY, UINT inOptions, LPCRECT inRect, const char* inString, UINT inCount, const LPINT inDx)
00643 {
00644     MOZCE_PRECHECK
00645 
00646 #ifdef DEBUG
00647         mozce_printf("mozce_ExtTextOutA (%s) called\n", inString);
00648 #endif
00649     
00650     BOOL retval = false;
00651     
00652     if (inCount == -1)
00653         inCount = strlen(inString);
00654     
00655     int wLen = 0;
00656     LPTSTR wStr = a2w_malloc(inString, inCount, &wLen);
00657     
00658     if(NULL != wStr)
00659     {  
00660         retval = ExtTextOutW(inDC, inX, inY, inOptions, inRect, wStr, wLen, inDx);
00661         
00662         free(wStr);
00663         wStr = NULL;
00664     }
00665     
00666     return retval;
00667 }
00668 
00669 
00670 MOZCE_SHUNT_API BOOL mozce_TextOutA(HDC hdc, int nXStart, int nYStart, const char* lpString, int cbString)
00671 {
00672     MOZCE_PRECHECK
00673 
00674 #ifdef DEBUG
00675     mozce_printf("mozce_TextOutA (%s) called\n", lpString);
00676 #endif
00677     
00678     return mozce_ExtTextOutA(hdc, nXStart, nYStart, 0, NULL, lpString, cbString, NULL);
00679 }
00680 
00681 MOZCE_SHUNT_API DWORD mozce_GetGlyphOutlineA(HDC inDC, CHAR inChar, UINT inFormat, void* inGM, DWORD inBufferSize, LPVOID outBuffer, CONST mozce_MAT2* inMAT2)
00682 {
00683     MOZCE_PRECHECK
00684 
00685 #ifdef DEBUG
00686     mozce_printf("-- mozce_GetGlyphOutlineA called\n");
00687 #endif
00688 
00689     DWORD retval = GDI_ERROR;
00690 
00691     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
00692 
00693     return retval;
00694 }
00695 
00696 MOZCE_SHUNT_API DWORD mozce_GetCurrentDirectoryA(DWORD inBufferLength, LPSTR outBuffer)
00697 {
00698     MOZCE_PRECHECK
00699 
00700 #ifdef DEBUG
00701     mozce_printf("-- mozce_GetCurrentDirectoryA called\n");
00702 #endif
00703 
00704     DWORD retval = 0;
00705 
00706     if(NULL != outBuffer && 0 < inBufferLength)
00707     {
00708         outBuffer[0] = '\0';
00709     }
00710 
00711     SetLastError(ERROR_NOT_SUPPORTED);
00712     return retval;
00713 }
00714 
00715 
00716 MOZCE_SHUNT_API BOOL mozce_SetCurrentDirectoryA(LPCSTR inPathName)
00717 {
00718     MOZCE_PRECHECK
00719 
00720 #ifdef DEBUG
00721     mozce_printf("-- mozce_SetCurrentDirectoryA called\n");
00722 #endif
00723 
00724     BOOL retval = FALSE;
00725 
00726     SetLastError(ERROR_NOT_SUPPORTED);
00727     return retval;
00728 }
00729 
00730 MOZCE_SHUNT_API LONG mozce_RegEnumKeyExA(HKEY inKey, DWORD inIndex, LPSTR outName, LPDWORD inoutName, LPDWORD inReserved, LPSTR outClass, LPDWORD inoutClass, PFILETIME inLastWriteTime)
00731 {
00732     MOZCE_PRECHECK
00733 
00734 #ifdef DEBUG
00735     mozce_printf("mozce_RegEnumKeyExA called\n");
00736 #endif
00737 
00738     LONG retval = ERROR_NOT_ENOUGH_MEMORY;
00739 
00740     LPTSTR wName = (LPTSTR)malloc(sizeof(TCHAR) * *inoutName);
00741     DWORD wNameChars = *inoutName;
00742     if(NULL != wName)
00743     {
00744         LPTSTR wClass = NULL;
00745         DWORD wClassChars = 0;
00746 
00747         if(NULL != outClass)
00748         {
00749             wClass = (LPTSTR)malloc(sizeof(TCHAR) * *inoutClass);
00750             wClassChars = *inoutClass;
00751         }
00752 
00753         if(NULL == outClass || NULL != wClass)
00754         {
00755             retval = RegEnumKeyEx(inKey, inIndex, wName, &wNameChars, inReserved, wClass, &wClassChars, inLastWriteTime);
00756             if(ERROR_SUCCESS == retval)
00757             {
00758                 *inoutName = w2a_buffer(wName, wNameChars + 1, outName, *inoutName);
00759                 if(NULL != wClass)
00760                 {
00761                     *inoutClass = w2a_buffer(wClass, wClassChars + 1, outClass, *inoutClass);
00762                 }
00763             }
00764         }
00765 
00766         if(NULL != wClass)
00767         {
00768             free(wClass);
00769         }
00770         free(wName);
00771     }
00772 
00773     return retval;
00774 }
00775 
00776 
00777 MOZCE_SHUNT_API BOOL mozce_GetFileVersionInfoA(LPSTR inFilename, DWORD inHandle, DWORD inLen, LPVOID outData)
00778 {
00779     MOZCE_PRECHECK
00780 
00781 #ifdef DEBUG
00782     mozce_printf("mozce_GetFileVersionInfoA called\n");
00783 #endif
00784 
00785     BOOL retval = FALSE;
00786     TCHAR wPath[MAX_PATH];
00787 
00788     if(0 != a2w_buffer(inFilename, -1, wPath, MAX_PATH))
00789     {
00790         retval = GetFileVersionInfo(wPath, inHandle, inLen, outData);
00791     }
00792     return retval;
00793 }
00794 
00795 
00796 MOZCE_SHUNT_API DWORD mozce_GetFileVersionInfoSizeA(LPSTR inFilename, LPDWORD outHandle)
00797 {
00798     MOZCE_PRECHECK
00799 
00800 #ifdef DEBUG
00801     mozce_printf("mozce_GetFileVersionInfoSizeA called\n");
00802 #endif
00803 
00804     DWORD retval = 0;
00805 
00806     TCHAR wPath[MAX_PATH];
00807 
00808     if(0 != a2w_buffer(inFilename, -1, wPath, MAX_PATH))
00809     {
00810         retval = GetFileVersionInfoSize(wPath, outHandle);
00811     }
00812     return retval;
00813 }
00814 
00815 
00816 MOZCE_SHUNT_API BOOL mozce_VerQueryValueA(const LPVOID inBlock, LPSTR inSubBlock, LPVOID *outBuffer, PUINT outLen)
00817 {
00818     MOZCE_PRECHECK
00819 
00820 #ifdef DEBUG
00821     mozce_printf("mozce_VerQueryValueA called.  Incomplete implementation.  Your code will have to manually convert strings.\n");
00822 #endif
00823 
00824     BOOL retval = FALSE;
00825     LPTSTR wBlock = NULL;
00826 
00827     wBlock = a2w_malloc(inSubBlock, -1, NULL);
00828     if(NULL != wBlock)
00829     {
00830         retval = VerQueryValue(inBlock, wBlock, outBuffer, outLen);
00831         free(wBlock);
00832         wBlock = NULL;
00833     }
00834     return retval;
00835 }
00836 
00837 MOZCE_SHUNT_API int mozce_LoadStringA(HINSTANCE inInstance, UINT inID, LPSTR outBuffer, int inBufferMax)
00838 {
00839     MOZCE_PRECHECK
00840 
00841 #ifdef DEBUG
00842     mozce_printf("mozce_LoadStringA called\n");
00843 #endif
00844 
00845     int retval = 0;
00846 
00847     if(NULL != outBuffer && 0 < inBufferMax)
00848     {
00849         LPTSTR wBuffer = (LPTSTR)malloc(sizeof(TCHAR) * inBufferMax);
00850         if(NULL != wBuffer)
00851         {
00852             retval = LoadString(inInstance, inID, wBuffer, inBufferMax);
00853             if(0 < retval)
00854             {
00855                 retval = w2a_buffer(wBuffer, retval + 1, outBuffer, inBufferMax);
00856             }
00857             free(wBuffer);
00858         }
00859     }
00860 
00861     return retval;
00862 }
00863 
00864 
00865 MOZCE_SHUNT_API VOID mozce_OutputDebugStringA(LPCSTR inOutputString)
00866 {
00867     MOZCE_PRECHECK
00868 
00869 #ifdef DEBUG
00870     mozce_printf("mozce_OutputDebugStringA called\n");
00871 #endif
00872 
00873     LPTSTR wideStr = NULL;
00874 
00875     wideStr = a2w_malloc(inOutputString, -1, NULL);
00876     if(NULL != wideStr)
00877     {
00878         OutputDebugString(wideStr);
00879         free(wideStr);
00880     }
00881 }
00882 
00883 
00884 MOZCE_SHUNT_API int mozce_DrawTextA(HDC inDC, LPCSTR inString, int inCount, LPRECT inRect, UINT inFormat)
00885 {
00886     MOZCE_PRECHECK
00887 
00888 #ifdef DEBUG
00889     mozce_printf("mozce_DrawTextA called\n");
00890 #endif
00891 
00892     int retval = 0;
00893     int wStringLen = 0;
00894     LPTSTR wString = a2w_malloc(inString, inCount, &wStringLen);
00895     if(NULL != wString)
00896     {
00897         retval = DrawText(inDC, wString, wStringLen, inRect, inFormat);
00898         free(wString);
00899     }
00900 
00901     return retval;
00902 }
00903 
00904 
00905 MOZCE_SHUNT_API BOOL mozce_SetDlgItemTextA(HWND inDlg, int inIDDlgItem, LPCSTR inString)
00906 {
00907     MOZCE_PRECHECK
00908 
00909 #ifdef DEBUG
00910     mozce_printf("mozce_SetDlgItemTextA called\n");
00911 #endif
00912 
00913     BOOL retval = FALSE;
00914     LPTSTR wString = a2w_malloc(inString, -1, NULL);
00915     if(NULL != wString)
00916     {
00917         retval = SetDlgItemText(inDlg, inIDDlgItem, wString);
00918         free(wString);
00919     }
00920 
00921     return retval;
00922 }
00923 
00924 
00925 MOZCE_SHUNT_API HANDLE mozce_LoadImageA(HINSTANCE inInst, LPCSTR inName, UINT inType, int inCX, int inCY, UINT inLoad)
00926 {
00927     MOZCE_PRECHECK
00928 
00929 #ifdef DEBUG
00930     mozce_printf("mozce_LoadImageA called\n");
00931 #endif
00932 
00933     HANDLE retval = NULL;
00934 
00935     LPTSTR wName = a2w_malloc(inName, -1, NULL);
00936     if(NULL != wName)
00937     {
00938         retval = LoadImage(inInst, wName, inType, inCX, inCY, inLoad);
00939         free(wName);
00940     }
00941 
00942     return retval;
00943 }
00944 
00945 
00946 MOZCE_SHUNT_API HWND mozce_FindWindowA(LPCSTR inClass, LPCSTR inWindow)
00947 {
00948     MOZCE_PRECHECK
00949 
00950 #ifdef DEBUG
00951     mozce_printf("mozce_FindWindowA called\n");
00952 #endif
00953 
00954     HWND retval = NULL;
00955 
00956     LPTSTR wClass = a2w_malloc(inClass, -1, NULL);
00957     LPTSTR wWindow = a2w_malloc(inWindow, -1, NULL); 
00958    
00959     retval = FindWindow(wClass, NULL);
00960     
00961     if (wWindow)
00962         free(wWindow);
00963 
00964     if (wClass)
00965         free(wClass);
00966 
00967     return retval;
00968 }
00969 
00970 
00971 MOZCE_SHUNT_API UINT mozce_RegisterClipboardFormatA(LPCSTR inFormat)
00972 {
00973     MOZCE_PRECHECK
00974 
00975 #ifdef DEBUG
00976     mozce_printf("mozce_RegisterClipboardFormatA called\n");
00977 #endif
00978 
00979     UINT retval = 0;
00980 
00981     LPTSTR wFormat = a2w_malloc(inFormat, -1, NULL);
00982     if(NULL != wFormat)
00983     {
00984         retval = RegisterClipboardFormat(wFormat);
00985         free(wFormat);
00986     }
00987 
00988     return retval;
00989 }
00990 
00991 
00992 MOZCE_SHUNT_API DWORD mozce_GetEnvironmentVariableA(LPSTR lpName, LPSTR lpBuffer, DWORD nSize)
00993 {
00994     MOZCE_PRECHECK
00995 
00996 #ifdef DEBUG
00997     mozce_printf("-- mozce_GetEnvironmentVariableA called\n");
00998 #endif
00999 
01000     DWORD retval = -1;
01001 
01002     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
01003 
01004     return retval; 
01005 }
01006 
01007 MOZCE_SHUNT_API DWORD mozce_SetEnvironmentVariableA(LPSTR lpName, LPSTR lpBuffer)
01008 {    
01009     MOZCE_PRECHECK
01010 
01011 #ifdef DEBUG
01012     mozce_printf("-- mozce_SetEnvironmentVariableA called\n");
01013 #endif
01014 
01015     DWORD retval = -1;
01016 
01017     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
01018 
01019     return retval; 
01020 }
01021 
01022 
01023 MOZCE_SHUNT_API LRESULT mozce_SendMessageA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
01024 {
01025     MOZCE_PRECHECK
01026 
01027 #ifdef DEBUG
01028     mozce_printf("mozce_SendMessageA called\n");
01029 #endif
01030 
01031     unsigned short *lpNewText = NULL;
01032     LRESULT res;
01033     LPARAM lParamOrig = lParam;
01034     
01035     if(msg == CB_ADDSTRING    || msg == CB_FINDSTRING   || msg == CB_FINDSTRINGEXACT ||
01036        msg == CB_INSERTSTRING || msg == CB_SELECTSTRING || msg == EM_REPLACESEL ||
01037        msg == LB_ADDSTRING    || msg == LB_FINDSTRING   || msg == LB_FINDSTRINGEXACT ||
01038        msg == LB_INSERTSTRING || msg == LB_SELECTSTRING || msg == WM_SETTEXT)
01039     {
01040         lParam = (LPARAM) a2w_malloc((char*)lParam, -1, NULL);
01041     }
01042     else if(msg == WM_GETTEXT)
01043     {
01044         lpNewText = (unsigned short*) malloc(wParam * 2);
01045         lParam = (LPARAM) lpNewText;
01046         lpNewText[0] = 0;
01047     }
01048     else if(msg == LB_GETTEXT || msg == CB_GETLBTEXT)
01049     {
01050         lpNewText = (unsigned short*) malloc(512);
01051         lParam = (LPARAM) lpNewText;
01052         lpNewText[0] = 0;
01053     }
01054 #ifdef DEBUG
01055     else if (msg == 1029)
01056     {
01057         ;//PBM_STEPIT
01058     }
01059     else if (msg >= WM_USER)
01060     {
01061         // user message -- how the heck can this be converted, or does it need to??
01062     }
01063     else
01064     {
01065         // need possible conversion??
01066 #ifdef DEBUG
01067         mozce_printf("  need possible conversion %d\n", msg);
01068 #endif
01069     }
01070 #endif
01071     
01072     res = SendMessageW(hWnd, msg, wParam, lParam);
01073     
01074     if(msg == WM_GETTEXT)
01075     {
01076         w2a_buffer(lpNewText, -1, (char*) lParamOrig, wParam);
01077     }
01078     else if(msg == LB_GETTEXT)
01079     {
01080         w2a_buffer(lpNewText, -1, (char*) lParamOrig, 512);
01081     }
01082 #ifdef DEBUG
01083     else if (msg == CB_ADDSTRING || msg == 1029 /*PBM_STEPIT*/)
01084     {
01085     }
01086     else
01087     {
01088 #ifdef DEBUG
01089         mozce_printf("  need possible out conversion %d\n", msg);        
01090 #endif
01091     }
01092 #endif
01093 
01094     if(lpNewText)
01095         free(lpNewText);
01096 
01097   return res;
01098 }
01099 
01100 
01101 MOZCE_SHUNT_API ATOM mozce_GlobalAddAtomA(LPCSTR lpString)
01102 {
01103     MOZCE_PRECHECK
01104 
01105 #ifdef DEBUG
01106     mozce_printf("mozce_GlobalAddAtomA called (%s)\n", lpString);
01107 #endif
01108 
01109     LPTSTR watom = a2w_malloc(lpString, -1, NULL);
01110     if (!watom)
01111         return NULL;
01112 
01113     ATOM a = GlobalAddAtomW(watom);
01114 
01115     free(watom);
01116     return a; 
01117 }
01118 
01119 MOZCE_SHUNT_API LRESULT mozce_PostMessageA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
01120 {
01121     MOZCE_PRECHECK
01122 
01123 #ifdef DEBUG
01124     mozce_printf("mozce_PostMessageA called (%d %d %d)\n", msg, wParam, lParam);
01125 #endif
01126 
01127     return PostMessageW(hWnd, msg, wParam, lParam);
01128 }
01129 
01130 MOZCE_SHUNT_API BOOL mozce_GetVersionExA(LPOSVERSIONINFOA lpv)
01131 {
01132     MOZCE_PRECHECK
01133 
01134 #ifdef DEBUG
01135     mozce_printf("mozce_GetVersionExA called\n");
01136 #endif
01137 
01138     OSVERSIONINFOW vw;
01139     vw.dwOSVersionInfoSize = sizeof(vw);
01140 
01141     GetVersionExW(&vw);
01142 
01143     memcpy(lpv, &vw, 5 * sizeof(DWORD));
01144 
01145     w2a_buffer(vw.szCSDVersion, -1, lpv->szCSDVersion, sizeof(lpv->szCSDVersion));    
01146     return TRUE;
01147 }
01148 
01149 
01150 MOZCE_SHUNT_API LRESULT mozce_DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
01151 {
01152     MOZCE_PRECHECK
01153 
01154 #ifdef DEBUG
01155     mozce_printf("mozce_DefWindowProcA called\n");
01156 #endif
01157 
01158     return DefWindowProcW(hWnd, Msg, wParam, lParam);
01159 }
01160 
01161 
01162 MOZCE_SHUNT_API HWND mozce_CreateWindowExA(DWORD dwExStyle, 
01163                                            LPCSTR lpClassName,
01164                                            LPCSTR lpWindowName, 
01165                                            DWORD dwStyle, 
01166                                            int x, int y, 
01167                                            int nWidth, int nHeight, 
01168                                            HWND hWndParent, 
01169                                            HMENU hMenu, 
01170                                            HINSTANCE hInstance, 
01171                                            LPVOID lpParam )
01172 {
01173     TCHAR classNameW[MAX_PATH];
01174     TCHAR windowNameW[MAX_PATH];
01175     TCHAR *pWindowNameW;
01176     TCHAR *pClassNameW;
01177     
01178     HWND hwnd;
01179     
01180     if(IsBadReadPtr(lpClassName, 1))
01181     {
01182         pClassNameW = (WCHAR *) lpClassName;
01183     }
01184     else
01185     {
01186         a2w_buffer(lpClassName, -1, classNameW, MAX_PATH);
01187         pClassNameW = classNameW;
01188     }
01189     
01190     if(lpWindowName)
01191     {
01192         a2w_buffer(lpWindowName, -1, windowNameW, MAX_PATH);
01193         pWindowNameW = windowNameW;
01194     }
01195     else
01196     {
01197         pWindowNameW = NULL;
01198     }
01199     
01200     hwnd = CreateWindowExW(dwExStyle, 
01201                            pClassNameW, 
01202                            pWindowNameW, 
01203                            dwStyle,
01204                            x, y, 
01205                            nWidth, nHeight, 
01206                            hWndParent, 
01207                            hMenu,
01208                            hInstance, 
01209                            lpParam);
01210     
01211     return hwnd;
01212 }
01213 
01214 
01215 MOZCE_SHUNT_API ATOM mozce_RegisterClassA(CONST WNDCLASSA *lpwc)
01216 {
01217     MOZCE_PRECHECK
01218 
01219 #ifdef DEBUG
01220     mozce_printf("mozce_RegisterClassA called (%s)\n", lpwc->lpszClassName);
01221 #endif
01222 
01223     WNDCLASSW wcW;
01224 
01225     LPTSTR wClassName = a2w_malloc(lpwc->lpszClassName, -1, NULL);
01226 
01227     memcpy(&wcW, lpwc, sizeof(WNDCLASSA));    
01228 
01229     wcW.lpszMenuName  = NULL;
01230     wcW.lpszClassName = wClassName;
01231     
01232     return RegisterClassW(&wcW);   
01233 }
01234 
01235 MOZCE_SHUNT_API BOOL mozce_UnregisterClassA(LPCSTR lpClassName, HINSTANCE hInstance)
01236 {
01237     MOZCE_PRECHECK
01238 
01239 #ifdef DEBUG
01240     mozce_printf("mozce_UnregisterClassA called\n");
01241 #endif
01242     LPTSTR w = a2w_malloc(lpClassName, -1, NULL);
01243     BOOL result = UnregisterClassW(w, hInstance);
01244     free(w);
01245     return result;
01246 }
01247 MOZCE_SHUNT_API UINT mozce_RegisterWindowMessageA(LPCSTR s)
01248 {
01249     MOZCE_PRECHECK
01250 
01251 #ifdef DEBUG
01252     mozce_printf("mozce_RegisterWindowMessageA called\n");
01253 #endif
01254 
01255     LPTSTR w = a2w_malloc(s, -1, NULL);
01256     UINT result = RegisterWindowMessageW(w);
01257     free(w);
01258     return result;
01259 }
01260 
01261 
01262 MOZCE_SHUNT_API BOOL mozce_GetClassInfoA(HINSTANCE hInstance, LPCSTR lpClassName, LPWNDCLASS lpWndClass)
01263 {
01264     MOZCE_PRECHECK
01265 
01266 #ifdef DEBUG
01267     mozce_printf("mozce_GetClassInfoA called\n");
01268 #endif
01269 
01270     LPTSTR wClassName = a2w_malloc(lpClassName, -1, NULL);
01271     BOOL result = GetClassInfoW(hInstance, wClassName, lpWndClass);
01272     free(wClassName);
01273     return result;
01274 }
01275 
01276 
01277 MOZCE_SHUNT_API HINSTANCE mozce_LoadLibraryA(LPCSTR lpLibFileName)
01278 {
01279     MOZCE_PRECHECK
01280 
01281 #ifdef DEBUG
01282     mozce_printf("mozce_LoadLibraryA called (%s)\n", lpLibFileName);
01283 #endif
01284 
01285     HINSTANCE retval = NULL;
01286 
01287     LPTSTR wPath = a2w_malloc(lpLibFileName, -1, NULL);
01288 
01289     if(wPath) {
01290         retval = LoadLibraryW(wPath);
01291     }
01292     
01293 #ifdef DEBUG
01294     if (!retval) {
01295         DWORD error = GetLastError();
01296         mozce_printf("LoadLibraryA failure (14==OOM)! %d\n", error);
01297         
01298         if (error == 14)
01299             MessageBoxW(NULL, L"Failed to Load Library. Out Of Memory.", wPath, 0);
01300     }
01301 #endif
01302 
01303        if (wPath)
01304               free(wPath);
01305     return retval;
01306 }
01307 
01308 
01309 MOZCE_SHUNT_API int mozce_GetObjectA(HGDIOBJ hgdiobj, int cbBuffer, LPVOID lpvObject)
01310 {
01311     MOZCE_PRECHECK
01312 
01313 #ifdef DEBUG
01314     mozce_printf("mozce_GetObjectA called\n");
01315 #endif
01316 
01317     if(cbBuffer == sizeof(LOGFONTA))
01318     {
01319         LOGFONTW lfw;
01320         LOGFONTA *plfa = (LOGFONTA *) lpvObject;
01321         int res;
01322         
01323         res = GetObjectW(hgdiobj, sizeof(LOGFONTW), &lfw);
01324         
01325         memcpy(plfa, &lfw, sizeof(LOGFONTA));
01326         
01327         w2a_buffer(lfw.lfFaceName, -1, plfa->lfFaceName, charcount(plfa->lfFaceName));
01328         return res;
01329     }
01330     return GetObjectW(hgdiobj, cbBuffer, lpvObject);
01331 }
01332 
01333 MOZCE_SHUNT_API FARPROC mozce_GetProcAddressA(HMODULE hMod, const char *name)
01334 {
01335     MOZCE_PRECHECK
01336 
01337 #ifdef DEBUG
01338     mozce_printf("mozce_GetProcAddressA called (%s)\n", name);
01339 #endif
01340 
01341     LPTSTR wName = a2w_malloc(name, -1, NULL);
01342 
01343     FARPROC p = GetProcAddressW(hMod, wName);
01344 
01345 #ifdef DEBUG
01346     if (!p)
01347         mozce_printf("NOT FOUND!!!!!!\n");
01348 #endif
01349     free(wName);
01350 
01351     return p;
01352 }
01353 
01354 MOZCE_SHUNT_API HBITMAP mozce_LoadBitmapA(HINSTANCE hInstance, LPCSTR lpCursorName)
01355 {
01356     MOZCE_PRECHECK
01357 
01358 #ifdef DEBUG
01359     mozce_printf("mozce_LoadBitmapA called\n");
01360 #endif
01361 
01362     unsigned short *bitmapNameW;
01363     HBITMAP hc;
01364     
01365     if(lpCursorName > (LPCSTR) 0xFFFF)
01366     {
01367         int len = strlen(lpCursorName);
01368         
01369         bitmapNameW = (unsigned short*)_alloca((len + 1) * 2);
01370         MultiByteToWideChar(CP_ACP, 0, lpCursorName, -1, bitmapNameW, len + 1);
01371     }
01372     else
01373     {
01374         bitmapNameW = (LPWSTR) (LPSTR) lpCursorName;
01375     }
01376     
01377     hc = LoadBitmapW(hInstance, bitmapNameW);
01378     
01379     return hc;
01380 }
01381 
01382 MOZCE_SHUNT_API HCURSOR mozce_LoadCursorA(HINSTANCE hInstance, LPCSTR lpCursorName)
01383 {
01384     MOZCE_PRECHECK
01385 
01386 #ifdef DEBUG
01387     mozce_printf("-- mozce_LoadCursorA called\n");
01388 #endif
01389 
01390        return NULL;
01391 
01392     unsigned short *lpCursorNameW;
01393     HCURSOR hc;
01394     
01395     if(lpCursorName > (LPCSTR) 0xFFFF)
01396     {
01397         int len = strlen(lpCursorName);
01398         
01399         lpCursorNameW = (unsigned short*)_alloca((len + 1) * 2);
01400         MultiByteToWideChar(CP_ACP, 0, lpCursorName, -1, lpCursorNameW, len + 1);
01401     }
01402     else
01403     {
01404         lpCursorNameW = (LPWSTR) (LPSTR) lpCursorName;
01405     }
01406     
01407     hc = LoadCursorW(hInstance, lpCursorNameW);
01408     
01409     return hc;
01410 }
01411 
01412 
01413 MOZCE_SHUNT_API int mozce_GetClassNameA(HWND hWnd, LPTSTR lpClassName, int nMaxCount)
01414 {
01415     MOZCE_PRECHECK
01416 
01417 #ifdef DEBUG
01418     mozce_printf("mozce_GetClassNameA called\n");
01419 #endif
01420 
01421     WCHAR classNameW[126];
01422     int res;
01423     
01424     if((res = GetClassNameW(hWnd, classNameW, sizeof(classNameW))) == 0)
01425         return res;
01426     
01427     w2a_buffer(classNameW, -1, (char*)lpClassName, nMaxCount);
01428     return res;
01429 }
01430 
01431 
01432 
01433 MOZCE_SHUNT_API BOOL mozce_GetOpenFileNameA(LPOPENFILENAMEA lpofna)
01434 {
01435     MOZCE_PRECHECK
01436 
01437 #ifdef DEBUG
01438     mozce_printf("-- mozce_GetOpenFileNameA called\n");
01439 #endif
01440 
01441     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
01442     return FALSE;
01443 }
01444 
01445 MOZCE_SHUNT_API BOOL mozce_GetSaveFileNameA(LPOPENFILENAMEA lpofna)
01446 {
01447     MOZCE_PRECHECK
01448 
01449 #ifdef DEBUG
01450     mozce_printf("-- mozce_GetSaveFileNameA called\n");
01451 #endif
01452 
01453     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
01454     return FALSE;
01455 }
01456 
01457 
01458 MOZCE_SHUNT_API HMODULE mozce_GetModuleHandleA(const char *lpName)
01459 {
01460     MOZCE_PRECHECK
01461 
01462 #ifdef DEBUG
01463     mozce_printf("mozce_GetModuleHandleA called (%s)\n", lpName);
01464 #endif
01465 
01466     if (lpName == NULL)
01467         return GetModuleHandleW(NULL);
01468 
01469     TCHAR wideStr[MAX_PATH];
01470     if(a2w_buffer(lpName, -1, wideStr, MAX_PATH))
01471         return GetModuleHandleW(wideStr);
01472 
01473     return NULL;
01474 }
01475 
01476 MOZCE_SHUNT_API HICON mozce_LoadIconA(HINSTANCE hInstance, LPCSTR lpIconName)
01477 {
01478     MOZCE_PRECHECK
01479 
01480 #ifdef DEBUG
01481     mozce_printf("mozce_LoadIconA called\n");
01482 #endif
01483 
01484     HICON hi = NULL;
01485 
01486     if (! IS_INTRESOURCE(lpIconName))
01487     {
01488 
01489         TCHAR wideStr[MAX_PATH];
01490         if(a2w_buffer(lpIconName, -1, wideStr, MAX_PATH))
01491         {
01492             hi = LoadIconW(hInstance, wideStr);
01493         }
01494     }
01495     else
01496         hi = LoadIconW(hInstance, (const unsigned short*) lpIconName);
01497 
01498     return hi;
01499 }
01500 
01501 MOZCE_SHUNT_API HRSRC mozce_FindResourceA(HMODULE  hModule, LPCSTR  lpName, LPCSTR  lpType)
01502 {
01503     MOZCE_PRECHECK
01504 
01505     HRSRC hr;
01506     if (! IS_INTRESOURCE(lpName) && IS_INTRESOURCE(lpType))
01507     {
01508         LPTSTR wName = a2w_malloc(lpName, -1, NULL);
01509         LPTSTR wType = a2w_malloc(lpType, -1, NULL);
01510         
01511         hr = FindResourceW(hModule, wName, wType);
01512         free(wName);
01513         free(wType);
01514     }
01515     else
01516     {
01517         hr = FindResourceW(hModule, (const unsigned short*)lpName, (const unsigned short*)lpType);
01518     }
01519 
01520 #ifdef DEBUG
01521     if (hr == NULL)
01522         mozce_printf("hr == %d\n", GetLastError());
01523 #endif
01524     return hr;
01525 }
01526 
01527 MOZCE_SHUNT_API UINT mozce_GetDlgItemTextA(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount)
01528 {
01529     MOZCE_PRECHECK
01530 
01531 #ifdef DEBUG
01532     mozce_printf("mozce_GetDlgItemTextA called\n");
01533 #endif
01534     
01535     UINT res;
01536     
01537     LPWSTR stringW = (unsigned short*) malloc ((nMaxCount + 1) * 2);
01538     
01539     res = GetDlgItemTextW(hDlg, nIDDlgItem, stringW, nMaxCount);
01540     
01541     if(res >= 0)
01542         w2a_buffer(stringW, -1, lpString, nMaxCount);
01543 
01544     free(stringW);
01545     return res;
01546 }
01547 
01548 MOZCE_SHUNT_API HANDLE mozce_CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, const char *lpName)
01549 {
01550     MOZCE_PRECHECK
01551 
01552 #ifdef DEBUG
01553     mozce_printf("mozce_CreateEventA called\n");
01554 #endif
01555     
01556     HANDLE hEvent;
01557     unsigned short *lpNameNew = NULL;
01558     int len;
01559     
01560     if(lpName)
01561     {
01562         len = strlen(lpName) + 1;
01563         lpNameNew = (unsigned short*)malloc(len * 2);
01564         
01565         MultiByteToWideChar(CP_ACP, 0, lpName, -1, lpNameNew, len);
01566     }
01567     
01568     hEvent = CreateEventW(lpEventAttributes, bManualReset, bInitialState, lpNameNew);
01569     
01570     free(lpNameNew);
01571     
01572     return hEvent;
01573 }
01574 
01575 MOZCE_SHUNT_API HMENU mozce_LoadMenuA(HINSTANCE hInstance, LPCSTR lpMenuName)
01576 {
01577     MOZCE_PRECHECK
01578 
01579 #ifdef DEBUG
01580     mozce_printf("mozce_LoadMenuA called\n");
01581 #endif
01582     
01583     HMENU hr;
01584     if (! IS_INTRESOURCE(lpMenuName))
01585     {
01586         LPTSTR wName = a2w_malloc(lpMenuName, -1, NULL);
01587         hr = LoadMenuW(hInstance, wName);
01588         free(wName);
01589     }
01590     else
01591     {
01592         hr = LoadMenuW(hInstance, (const unsigned short*)lpMenuName);
01593     }
01594     
01595     return NULL;
01596 }
01597 
01598 
01599 #ifdef GetProp
01600 #undef GetProp
01601 #endif
01602 #define GetProp GetProp
01603 
01604 MOZCE_SHUNT_API HANDLE mozce_GetPropA(HWND hWnd, const char* lpString)
01605 {
01606     MOZCE_PRECHECK
01607 
01608 #ifdef DEBUG
01609     mozce_printf("mozce_GetPropA called\n");
01610 #endif
01611     
01612     HANDLE h = NULL;
01613 
01614     if (IS_INTRESOURCE(lpString))
01615         return GetProp(hWnd, (const unsigned short *)lpString);
01616 
01617     LPTSTR wString = a2w_malloc(lpString, -1, NULL);
01618     if (wString) {
01619         h = GetProp(hWnd, wString);
01620         free(wString);
01621     }
01622     return h;
01623 }
01624 
01625 #ifdef SetProp
01626 #undef SetProp
01627 #endif
01628 #define SetProp SetProp
01629 
01630 MOZCE_SHUNT_API BOOL mozce_SetPropA(HWND hWnd, const char* lpString, HANDLE hData)
01631 {
01632     MOZCE_PRECHECK
01633 
01634 #ifdef DEBUG
01635     mozce_printf("mozce_SetPropA called\n");
01636 #endif
01637     
01638     BOOL b = FALSE;
01639     if (!lpString)
01640         return b;
01641 
01642     if (IS_INTRESOURCE(lpString))
01643         return SetProp(hWnd, (const unsigned short *)lpString, hData);
01644 
01645     LPTSTR wString = a2w_malloc(lpString, -1, NULL);
01646     if (wString) {
01647         b = SetProp(hWnd, wString, hData);
01648         free(wString);
01649     }
01650     return b;
01651 }
01652 #ifdef RemoveProp
01653 #undef RemoveProp
01654 #endif
01655 #define RemoveProp RemoveProp
01656 
01657 MOZCE_SHUNT_API HANDLE mozce_RemovePropA(HWND hWnd, const char* lpString)
01658 {
01659     MOZCE_PRECHECK
01660 
01661 #ifdef DEBUG
01662     mozce_printf("mozce_RemovePropA called\n");
01663 #endif
01664     
01665     HANDLE h = NULL;
01666 
01667     if (IS_INTRESOURCE(lpString))
01668         return RemoveProp(hWnd, (const unsigned short *)lpString);
01669 
01670     unsigned short* wString = a2w_malloc(lpString, -1, NULL);
01671     if (wString) {
01672         h = RemoveProp(hWnd, wString);
01673         free(wString);
01674     }
01675     return h;
01676 }
01677 
01678 
01679 MOZCE_SHUNT_API HANDLE mozce_FindFirstFileA(const char* lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
01680 {
01681     MOZCE_PRECHECK
01682 
01683 #ifdef DEBUG
01684     mozce_printf("mozce_FindFirstFileA called\n");
01685 #endif
01686     
01687     HANDLE h = NULL;
01688     if (!lpFindFileData || !lpFileName)
01689         return h;
01690 
01691     LPTSTR wString = a2w_malloc(lpFileName, -1, NULL);
01692     if (!wString) 
01693         return INVALID_HANDLE_VALUE;
01694 
01695     WIN32_FIND_DATAW findData;
01696     h = FindFirstFileW(wString, &findData);
01697     free(wString);
01698         
01699     if (!h || h == INVALID_HANDLE_VALUE)
01700         return INVALID_HANDLE_VALUE;
01701 
01702     lpFindFileData->dwFileAttributes   = findData.dwFileAttributes;
01703     lpFindFileData->dwReserved0        = findData.dwOID;
01704     lpFindFileData->ftCreationTime     = findData.ftCreationTime;
01705     lpFindFileData->ftLastAccessTime   = findData.ftLastAccessTime;
01706     lpFindFileData->ftLastWriteTime    = findData.ftLastWriteTime;
01707     lpFindFileData->nFileSizeHigh      = findData.nFileSizeHigh;
01708     lpFindFileData->nFileSizeLow       = findData.nFileSizeLow;    
01709     lpFindFileData->cAlternateFileName[0] = NULL;    
01710     
01711     if (!w2a_buffer(findData.cFileName, -1, lpFindFileData->cFileName, charcount(lpFindFileData->cFileName)))
01712         return INVALID_HANDLE_VALUE;
01713     
01714     return h;
01715 }
01716 
01717 MOZCE_SHUNT_API BOOL mozce_FindNextFileA(HANDLE hFindFile, WIN32_FIND_DATAA* lpFindFileData)
01718 {
01719     MOZCE_PRECHECK
01720 
01721 #ifdef DEBUG
01722     mozce_printf("mozce_FindNextFileA called\n");
01723 #endif
01724     
01725     WIN32_FIND_DATAW findData;
01726     
01727     findData.dwFileAttributes  = lpFindFileData->dwFileAttributes;
01728     findData.dwOID             = lpFindFileData->dwReserved0;
01729     findData.ftCreationTime    = lpFindFileData->ftCreationTime;
01730     findData.ftLastAccessTime  = lpFindFileData->ftLastAccessTime;
01731     findData.ftLastWriteTime   = lpFindFileData->ftLastWriteTime;
01732     findData.nFileSizeHigh     = lpFindFileData->nFileSizeHigh;
01733     findData.nFileSizeLow      = lpFindFileData->nFileSizeLow;    
01734 
01735     
01736     if (FindNextFileW(hFindFile, &findData))
01737     {
01738         lpFindFileData->dwFileAttributes      = findData.dwFileAttributes;
01739         lpFindFileData->ftCreationTime        = findData.ftCreationTime;
01740         lpFindFileData->ftLastAccessTime      = findData.ftLastAccessTime;
01741         lpFindFileData->ftLastWriteTime       = findData.ftLastWriteTime;
01742         lpFindFileData->nFileSizeHigh         = findData.nFileSizeHigh;
01743         lpFindFileData->nFileSizeLow          = findData.nFileSizeLow;    
01744         lpFindFileData->dwReserved0           = findData.dwOID;
01745         lpFindFileData->cAlternateFileName[0] = NULL;
01746 
01747         w2a_buffer(findData.cFileName, -1, lpFindFileData->cFileName, MAX_PATH);
01748 
01749         return TRUE;
01750     }
01751     return FALSE;
01752 }
01753  
01754 MOZCE_SHUNT_API HANDLE mozce_CreateFileMappingA(HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCSTR lpName)
01755 {
01756     MOZCE_PRECHECK
01757 
01758 #ifdef DEBUG
01759     mozce_printf("mozce_CreateFileMappingA called\n");
01760 #endif
01761     
01762     HANDLE h = NULL;
01763     
01764     LPTSTR wString = a2w_malloc(lpName, -1, NULL);
01765     if (wString) {
01766         h = CreateFileMappingW(hFile, lpFileMappingAttributes, flProtect, dwMaximumSizeHigh, dwMaximumSizeLow, wString);
01767         free(wString);
01768     }
01769     return h;
01770 }
01771 
01772 MOZCE_SHUNT_API DWORD mozce_FormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, va_list* Arguments)
01773 {
01774     MOZCE_PRECHECK
01775 
01776 #ifdef DEBUG
01777     mozce_printf("mozce_FormatMessageA called\n");
01778 #endif
01779     
01780     DWORD d = -1;
01781     LPTSTR wString = a2w_malloc(lpBuffer, nSize, NULL);
01782     if (wString) {
01783         d = FormatMessageW(dwFlags, lpSource, dwMessageId, dwLanguageId, wString, nSize*2, Arguments); 
01784         free(wString);
01785     }
01786     return d;
01787 }
01788 
01789 MOZCE_SHUNT_API HANDLE mozce_CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCSTR lpName)
01790 {
01791     MOZCE_PRECHECK
01792 
01793 #ifdef DEBUG
01794     mozce_printf("mozce_CreateSemaphoreA called\n");
01795 #endif
01796     
01797     HANDLE h = NULL;
01798     
01799     if (!lpName)
01800         return CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, NULL);
01801 
01802     LPTSTR wString = a2w_malloc(lpName, -1, NULL);
01803     if (wString) {
01804         h = CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, wString);
01805         free(wString);
01806     }
01807     return h;
01808 }
01809 
01810 MOZCE_SHUNT_API int mozce_StartDocA(HDC hdc, CONST DOCINFO* lpdi)
01811 {
01812     MOZCE_PRECHECK
01813 
01814 #ifdef DEBUG
01815     mozce_printf("-- mozce_StartDocA called\n");
01816 #endif
01817 
01818     DWORD retval = GDI_ERROR;
01819 
01820     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
01821 
01822     return retval;
01823 }
01824 
01825 MOZCE_SHUNT_API HFONT mozce_CreateFontIndirectA(CONST LOGFONTA* lplf)
01826 {
01827     MOZCE_PRECHECK
01828 
01829 #ifdef DEBUG
01830     mozce_printf("mozce_CreateFontIndirectA called\n");
01831 #endif
01832     
01833     LOGFONTW lfw;
01834     HFONT hFont;
01835     
01836     lfw.lfHeight         = lplf->lfHeight;
01837     lfw.lfWidth          = lplf->lfWidth;
01838     lfw.lfEscapement     = lplf->lfEscapement;
01839     lfw.lfOrientation    = lplf->lfOrientation;
01840     lfw.lfWeight         = lplf->lfWeight;
01841     lfw.lfItalic         = lplf->lfItalic;
01842     lfw.lfUnderline      = lplf->lfUnderline;
01843     lfw.lfStrikeOut      = lplf->lfStrikeOut;
01844     lfw.lfCharSet        = lplf->lfCharSet;
01845     lfw.lfOutPrecision   = lplf->lfOutPrecision;
01846     lfw.lfClipPrecision  = lplf->lfClipPrecision;
01847     lfw.lfQuality        = lplf->lfQuality;
01848     lfw.lfPitchAndFamily = lplf->lfPitchAndFamily;
01849     
01850     a2w_buffer(lplf->lfFaceName, -1, lfw.lfFaceName, LF_FACESIZE);
01851     hFont = CreateFontIndirectW(&lfw);
01852     
01853 #ifdef DEBUG
01854     mozce_printf("CreateFontIndirectW %x\n", hFont);
01855 #endif
01856     return hFont;
01857 }
01858 
01859 
01860 
01861 typedef struct _MyEnumFontFamArg
01862 {
01863   FONTENUMPROC fn;
01864   LPARAM lParam;
01865 } MYENUMFONTFAMARG;
01866 
01867 
01868 
01869 // typedef int (CALLBACK* FONTENUMPROC)(CONST LOGFONT *, CONST TEXTMETRIC *, DWORD, LPARAM);
01870 
01871 static int CALLBACK
01872 MyEnumFontFamProc(CONST LOGFONT *lf, CONST TEXTMETRIC *tm, DWORD fonttype, LPARAM lParam)
01873 {
01874     MYENUMFONTFAMARG *parg = (MYENUMFONTFAMARG *) lParam;
01875     FONTENUMPROC fn = parg->fn;
01876 
01877     LOGFONTW lfw;
01878     memcpy(&lfw, lf, sizeof(LOGFONTA));    
01879     a2w_buffer((const char*)lf->lfFaceName, -1, lfw.lfFaceName, LF_FACESIZE);
01880 
01881     return (*fn) (&lfw, tm, fonttype, parg->lParam);
01882 }
01883 
01884 MOZCE_SHUNT_API int mozce_EnumFontFamiliesA(HDC hdc, const char* lpszFamily, FONTENUMPROC lpEnumFontFamProc, LPARAM lParam)
01885 {
01886     MOZCE_PRECHECK
01887 
01888 #ifdef DEBUG
01889     mozce_printf("mozce_EnumFontFamilies called\n");
01890 #endif
01891     
01892     MYENUMFONTFAMARG arg;
01893     unsigned short *lpszFamilyW = NULL;
01894     
01895     if(lpszFamily != NULL)
01896         lpszFamilyW = a2w_malloc(lpszFamily, -1, NULL);
01897     
01898     arg.fn = lpEnumFontFamProc;
01899     arg.lParam = lParam;
01900     
01901     int result = EnumFontFamiliesW(hdc, lpszFamilyW, (FONTENUMPROC) MyEnumFontFamProc, (LPARAM) &arg);
01902 
01903     free(lpszFamilyW);
01904     
01905     return result;
01906 
01907 }
01908 
01909 
01910 MOZCE_SHUNT_API int mozce_GetTextFaceA(HDC hdc, int nCount, const char* lpFaceName)
01911 {
01912     MOZCE_PRECHECK
01913 
01914 #ifdef DEBUG
01915     mozce_printf("mozce_GetTextFaceA called\n");
01916 #endif
01917     
01918     if (!lpFaceName)
01919         return GetTextFaceW(hdc, 0, NULL);
01920 
01921     TCHAR* wBuffer = (TCHAR*) malloc(sizeof(TCHAR) * (nCount+1));
01922 
01923     if (!wBuffer)
01924         return GDI_ERROR;
01925 
01926     int res = GetTextFaceW(hdc, nCount, wBuffer);
01927     if(res != GDI_ERROR && res != 0 && lpFaceName) 
01928     {
01929         int result = w2a_buffer(wBuffer, -1, (char*)lpFaceName, nCount);
01930         if (result == 0)
01931             res = result;
01932 
01933 #ifdef DEBUG
01934         mozce_printf("textface: %s\n", lpFaceName);
01935 #endif
01936     }
01937     
01938     free(wBuffer);
01939     return res;
01940 }
01941 
01942 MOZCE_SHUNT_API BOOL mozce_GetTextMetricsA(HDC hdc, TEXTMETRICA*  lptma)
01943 {
01944     MOZCE_PRECHECK
01945 
01946 #ifdef DEBUG
01947     mozce_printf("mozce_GetTextMetricsA called\n");
01948 #endif
01949 
01950     if (!lptma)
01951         return 0;
01952 
01953     TEXTMETRICW tmw;
01954     BOOL res;
01955     
01956     res = GetTextMetricsW(hdc, &tmw);
01957     
01958     if (res==0)
01959         return res;
01960     
01961     lptma->tmHeight = tmw.tmHeight;
01962     lptma->tmAscent = tmw.tmAscent;
01963     lptma->tmDescent = tmw.tmDescent;
01964     lptma->tmInternalLeading = tmw.tmInternalLeading;
01965     lptma->tmExternalLeading = tmw.tmExternalLeading;
01966     lptma->tmAveCharWidth = tmw.tmAveCharWidth;
01967     lptma->tmMaxCharWidth = tmw.tmMaxCharWidth;
01968     lptma->tmWeight = tmw.tmWeight;
01969     lptma->tmOverhang = tmw.tmOverhang;
01970     lptma->tmDigitizedAspectX = tmw.tmDigitizedAspectX;
01971     lptma->tmDigitizedAspectY = tmw.tmDigitizedAspectY;
01972     lptma->tmItalic = tmw.tmItalic;
01973     lptma->tmUnderlined = tmw.tmUnderlined;
01974     lptma->tmStruckOut = tmw.tmStruckOut;
01975     lptma->tmPitchAndFamily = tmw.tmPitchAndFamily;
01976     lptma->tmCharSet = tmw.tmCharSet;
01977 
01978     w2a_buffer(&tmw.tmFirstChar, 1, &lptma->tmFirstChar, 1);
01979     w2a_buffer(&tmw.tmDefaultChar, 1, &lptma->tmDefaultChar, 1);
01980     w2a_buffer(&tmw.tmBreakChar, 1, &lptma->tmBreakChar, 1);
01981 
01982     return res;
01983 }
01984 
01985 MOZCE_SHUNT_API BOOL mozce_SetWindowTextA(HWND hWnd, LPCSTR lpString)
01986 {
01987     MOZCE_PRECHECK
01988 
01989 #ifdef DEBUG
01990     mozce_printf("mozce_SetWindowTextA called\n");
01991 #endif
01992 
01993     LPTSTR wstr = a2w_malloc(lpString, -1, NULL);
01994     BOOL result = SetWindowTextW(hWnd, wstr); 
01995     
01996     if (wstr)
01997         free(wstr);
01998 
01999     return result;
02000 }
02001 
02002 
02003 #if 0
02004 {
02005 #endif
02006 } /* extern "C" */