MOZCE_SHUNT_API DWORD GetFullPathName(const char* lpFileName, DWORD nBufferLength, const char* lpBuffer, const char** lpFilePart) { #ifdef API_LOGGING mozce_printf("GetFullPathName called\n"); #endif DWORD len = strlen(lpFileName); if (len > nBufferLength) return len; strncpy((char*)lpBuffer, lpFileName, len); ((char*)lpBuffer)[len] = '\0'; if(lpFilePart) { char* sep = strrchr(lpBuffer, '\\'); if (sep) { sep++; // pass the seperator *lpFilePart = sep; } else *lpFilePart = lpBuffer; } #ifdef API_LOGGING mozce_printf("GetFullPathName called %s (%s)\n", lpBuffer, *lpFilePart); #endif return len; }
MOZCE_SHUNT_API char* mozce_getenv(const char* inName) { MOZCE_PRECHECK #ifdef DEBUG mozce_printf("mozce_getenv called (%s)\n", inName); #endif char* retval = NULL; #ifdef DEBUG_NSPR_ALL if (!strcmp(inName, "NSPR_LOG_MODULES")) return "all:5"; if (!strcmp(inName, "NSPR_LOG_FILE")) return "nspr.log"; #endif #ifdef TIMELINE if (!strcmp(inName, "NS_TIMELINE_LOG_FILE")) return "\\bin\\timeline.log"; if (!strcmp(inName, "NS_TIMELINE_ENABLE")) return "1"; #endif if (!_stricmp(inName, "tmp")) return "/Temp"; return retval; }
MOZCE_SHUNT_API int FrameRect(HDC inDC, CONST RECT *inRect, HBRUSH inBrush) { #ifdef API_LOGGING mozce_printf("FrameRect called\n"); #endif HBRUSH oldBrush = (HBRUSH)SelectObject(inDC, inBrush); RECT myRect = *inRect; InflateRect(&myRect, 1, 1); // The width and height of // the border are always one // logical unit. // 1 ----> 2 // // | // v // // 4 ----> 3 MoveToEx(inDC, myRect.left, myRect.top, (LPPOINT) NULL); // 1 -> 2 LineTo(inDC, myRect.right, myRect.top); // 2 -> 3 LineTo(inDC, myRect.right, myRect.bottom); // 3 -> 4 LineTo(inDC, myRect.left, myRect.bottom); SelectObject(inDC, oldBrush); return 1; }
MOZCE_SHUNT_API int open(const char *pathname, int flags, int mode) { #ifdef API_LOGGING mozce_printf("open called\n"); #endif _initfds(); char modestr[10]; *modestr = '\0'; mode2binstr(mode, modestr); if (*modestr == '\0') return -1; FILE* file = fopen(pathname, modestr); int fd = -1; if (file) { fd = _getnewfd(); _fdtab[fd].fd = fd; _fdtab[fd].file = file; fflush(file); fread(NULL, 0, 0, file); } return fd; }
MOZCE_SHUNT_API int unlink(const char *pathname) { #ifdef API_LOGGING mozce_printf("unlink called\n"); #endif return remove(pathname); }
MOZCE_SHUNT_API char* mozce_ctime(const time_t* timer) { MOZCE_PRECHECK #ifdef DEBUG mozce_printf("mozce_ctime called\n"); #endif char* retval = NULL; if(NULL != timer) { struct tm tmLocal; struct tm* localRes = NULL; localRes = mozce_localtime_r(timer, &tmLocal); if(NULL != localRes) { static char ctimeBuf[32]; size_t strftimeRes = 0; // Sat Dec 20 01:05:05 1969\n\0 strftimeRes = mozce_strftime(ctimeBuf, sizeof(ctimeBuf), "%a %b %d %H %Y\n", &tmLocal); if(0 != strftimeRes) { retval = ctimeBuf; } } } return retval; }
MOZCE_SHUNT_API HRESULT CoLockObjectExternal(IUnknown* inUnk, BOOL inLock, BOOL inLastUnlockReleases) { #ifdef API_LOGGING mozce_printf("CoLockObjectExternal called\n"); #endif HRESULT retval = S_OK; if(NULL != inUnk) { if(FALSE == inLock) { inUnk->Release(); } else { inUnk->AddRef(); } } else { retval = E_INVALIDARG; } return retval; }
MOZCE_SHUNT_API BOOL OpenIcon(HWND inWnd) { #ifdef API_LOGGING mozce_printf("OpenIcon called\n"); #endif return SetActiveWindow(inWnd) ? 1:0; }
MOZCE_SHUNT_API struct lconv * mozce_localeconv(void) { #ifdef API_LOGGING mozce_printf("mozce_localeconv called\n"); #endif return &s_locale_conv; }
MOZCE_SHUNT_API HANDLE mozce_OpenSemaphoreW(DWORD inDesiredAccess, BOOL inInheritHandle, LPCWSTR inName) { MOZCE_PRECHECK #ifdef DEBUG mozce_printf("mozce_OpenSemaphoreW called\n"); #endif HANDLE retval = NULL; HANDLE semaphore = NULL; semaphore = CreateSemaphoreW(NULL, 0, 0x7fffffff, inName); if(NULL != semaphore) { DWORD lastErr = GetLastError(); if(ERROR_ALREADY_EXISTS != lastErr) { CloseHandle(semaphore); } else { retval = semaphore; } } return retval; }
MOZCE_SHUNT_API DWORD CommDlgExtendedError() { #ifdef API_LOGGING mozce_printf("CommDlgExtendedError called\n"); #endif return -1 /*CDERR_DIALOGFAILURE*/; }
MOZCE_SHUNT_API DWORD GetLongPathNameW(LPCWSTR lpszShortPath, LPCWSTR lpszLongPath, DWORD cchBuffer) { #ifdef API_LOGGING mozce_printf("GetLongPathNameW called\n"); #endif return 0; }
MOZCE_SHUNT_API void perror(const char* inString) { #ifdef API_LOGGING mozce_printf("perror called\n"); #endif fprintf(stderr, "%s", inString); }
MOZCE_SHUNT_API int _waccess(const wchar_t *path, int mode) { #ifdef API_LOGGING mozce_printf("-- _waccess called\n"); #endif return 0; }
MOZCE_SHUNT_API void rewind(FILE* inStream) { #ifdef API_LOGGING mozce_printf("rewind called\n"); #endif fseek(inStream, 0, SEEK_SET); }
MOZCE_SHUNT_API int GetMapMode(HDC inDC) { #ifdef API_LOGGING mozce_printf("GetMapMode called\n"); #endif int retval = MM_TEXT; return retval; }
MOZCE_SHUNT_API int mozce_putenv(const char *a) { MOZCE_PRECHECK #ifdef DEBUG mozce_printf("mozce_putenv called\n"); #endif return 0; }
MOZCE_SHUNT_API void GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { #ifdef API_LOGGING mozce_printf("GetSystemTimeAsFileTime called\n"); #endif SYSTEMTIME st; GetSystemTime(&st); SystemTimeToFileTime(&st,lpSystemTimeAsFileTime); }
MOZCE_SHUNT_API size_t mozce_strftime(char *, size_t, const char *, const struct tm *) { MOZCE_PRECHECK #ifdef DEBUG mozce_printf("mozce_strftime called\n"); #endif return 0; }
MOZCE_SHUNT_API struct tm* mozce_gmtime(const time_t* inTimeT) { MOZCE_PRECHECK #ifdef DEBUG mozce_printf("tm* mozce_gmtime called\n"); #endif return mozce_gmtime_r(inTimeT, &tmStorage); }
MOZCE_SHUNT_API LONG GetMessageTime(void) { SetLastError(0); #ifdef API_LOGGING mozce_printf("GetMessageTime called\n"); #endif return gGetMessageTime; }
MOZCE_SHUNT_API FILE* fdopen(int fd, const char* inMode) { #ifdef API_LOGGING mozce_printf("-- fdopen called (mode is ignored!) \n"); #endif if(fd < 0 || fd >= MAXFDS || _fdtab[fd].fd == -1) return 0; return _fdtab[fd].file; }
MOZCE_SHUNT_API BOOL EnumChildWindows(HWND inParent, WNDENUMPROC inFunc, LPARAM inParam) { #ifdef API_LOGGING mozce_printf("EnumChildWindows called\n"); #endif ECWWindows myParams; myParams.params = inParam; myParams.func = inFunc; myParams.parent = inParent; return EnumWindows(MyEnumWindowsProc, (LPARAM) &myParams); }
MOZCE_SHUNT_API void mozce_abort(void) { MOZCE_PRECHECK #ifdef DEBUG mozce_printf("mozce_abort called\n"); #endif #if defined(DEBUG) DebugBreak(); #endif TerminateProcess((HANDLE) GetCurrentProcessId(), 3); }
MOZCE_SHUNT_API LONG RegCreateKey(HKEY inKey, LPCTSTR inSubKey, PHKEY outResult) { #ifdef API_LOGGING mozce_printf("RegCreateKey called\n"); #endif LONG retval = ERROR_SUCCESS; DWORD disp = 0; retval = RegCreateKeyEx(inKey, inSubKey, 0, NULL, 0, 0, NULL, outResult, &disp); return retval; }
MOZCE_SHUNT_API BOOL mozce_SetCurrentDirectoryW(LPCTSTR inPathName) { MOZCE_PRECHECK #ifdef DEBUG mozce_printf("mozce_SetCurrentDirectoryW called\n"); #endif BOOL retval = FALSE; SetLastError(ERROR_NOT_SUPPORTED); return retval; }
MOZCE_SHUNT_API DWORD mozce_GetGlyphOutlineW(HDC inDC, WCHAR inChar, UINT inFormat, void* inGM, DWORD inBufferSize, LPVOID outBuffer, CONST VOID* inMAT2) { MOZCE_PRECHECK #ifdef DEBUG mozce_printf("mozce_GetGlyphOutlineW called\n"); #endif DWORD retval = GDI_ERROR; SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return retval; }
MOZCE_SHUNT_API UINT GetTextCharsetInfo(HDC inDC, LPFONTSIGNATURE outSig, DWORD inFlags) { #ifdef API_LOGGING mozce_printf("GetTextCharsetInfo called\n"); #endif // Zero out the FONTSIGNATURE as we do not know how to fill it out properly. if(NULL != outSig) { memset(outSig, 0, sizeof(FONTSIGNATURE)); } return GetTextCharset(inDC); }
MOZCE_SHUNT_API int mozce_getpid(void) { MOZCE_PRECHECK #ifdef DEBUG mozce_printf("mozce_getpid called\n"); #endif int retval = 0; retval = (int)GetCurrentProcessId(); return retval; }
MOZCE_SHUNT_API struct tm* mozce_localtime_r(const time_t* inTimeT,struct tm* outRetval) { MOZCE_PRECHECK #ifdef DEBUG mozce_printf("tm* mozce_localtime_r called\n"); #endif struct tm* retval = NULL; if(NULL != inTimeT && NULL != outRetval) { SYSTEMTIME winLocalTime; time_t_2_LOCALSYSTEMTIME(winLocalTime, *inTimeT); outRetval->tm_sec = (int)winLocalTime.wSecond; outRetval->tm_min = (int)winLocalTime.wMinute; outRetval->tm_hour = (int)winLocalTime.wHour; outRetval->tm_mday = (int)winLocalTime.wDay; outRetval->tm_mon = (int)(winLocalTime.wMonth - 1); outRetval->tm_year = (int)(winLocalTime.wYear - 1900); outRetval->tm_wday = (int)winLocalTime.wDayOfWeek; outRetval->tm_isdst = -1; outRetval->tm_yday = (int)winLocalTime.wDay + sDaysOfYear[outRetval->tm_mon]; if(0 == (winLocalTime.wYear & 3)) { if(2 < winLocalTime.wMonth) { if(0 == winLocalTime.wYear % 100) { if(0 == winLocalTime.wYear % 400) { outRetval->tm_yday++; } } else { outRetval->tm_yday++; } } } retval = outRetval; } return retval; }