diff --git a/ftk/Makefile b/ftk/Makefile index 0ccf1f3..4b2e3f2 100644 --- a/ftk/Makefile +++ b/ftk/Makefile @@ -1098,7 +1098,7 @@ ifdef netware_target $(ec)$(gprintf) "option start = f_nlmEntryPoint\n" >> $(4) $(ec)$(gprintf) "option exit = f_nlmExitPoint\n" >> $(4) $(ec)$(gprintf) "option nodefaultlibs\n" >> $(4) - $(ec)$(gprintf) "option pseudopreemption\n" >> $(4) + $(ec)$(gprintf) "option xdcdata=nlm.xdc\n" >> $(4) $(ec)$(gprintf) "debug all debug novell\n" >> $(4) $(ec)$(gprintf) "form novell nlm '$(2)'\n" >> $(4) $(ec)$(gprintf) "name $(call ppath,$(1)/$(2)$(exe_suffix))\n" >> $(4) @@ -1133,7 +1133,7 @@ ifdef netware_target $(ec)$(gprintf) "option start = _LibCPrelude\n" >> $(4) $(ec)$(gprintf) "option exit = _LibCPostlude\n" >> $(4) $(ec)$(gprintf) "option nodefaultlibs\n" >> $(4) - $(ec)$(gprintf) "option pseudopreemption\n" >> $(4) + $(ec)$(gprintf) "option xdcdata=nlm.xdc\n" >> $(4) $(ec)$(gprintf) "debug all debug novell\n" >> $(4) $(ec)$(gprintf) "form novell nlm '$(2)'\n" >> $(4) $(ec)$(gprintf) "name $(call ppath,$(1)/$(2)$(exe_suffix))\n" >> $(4) @@ -1219,7 +1219,6 @@ ifdef netware_target $(ec)$(gprintf) "import kMutexFree\n" >> $(1) $(ec)$(gprintf) "import kMutexLock\n" >> $(1) $(ec)$(gprintf) "import kMutexUnlock\n" >> $(1) - $(ec)$(gprintf) "import kQueCount\n" >> $(1) $(ec)$(gprintf) "import kReturnCurrentProcessorID\n" >> $(1) $(ec)$(gprintf) "import kScheduleThread\n" >> $(1) $(ec)$(gprintf) "import kSemaphoreAlloc\n" >> $(1) @@ -1263,14 +1262,12 @@ ifdef netware_target $(ec)$(gprintf) "import SetFileSize\n" >> $(1) $(ec)$(gprintf) "import SGUIDCreate\n" >> $(1) $(ec)$(gprintf) "import SizeOfAllocBlock\n" >> $(1) - $(ec)$(gprintf) "import StopBell\n" >> $(1) $(ec)$(gprintf) "import SwitchToDirectFileMode\n" >> $(1) $(ec)$(gprintf) "import SwitchToDirectFileMode\n" >> $(1) $(ec)$(gprintf) "import UngetKey\n" >> $(1) $(ec)$(gprintf) "import UnImportPublicSymbol\n" >> $(1) $(ec)$(gprintf) "import UnloadRules\n" >> $(1) $(ec)$(gprintf) "import VMGetDirectoryEntry\n" >> $(1) - $(ec)$(gprintf) "import WorkToDoListHead\n" >> $(1) $(ec)$(gprintf) "import WriteFile\n" >> $(1) $(ec)$(gprintf) "import WS2_32_bind\n" >> $(1) $(ec)$(gprintf) "import WS2_32_closesocket\n" >> $(1) diff --git a/ftk/src/ftkdir.cpp b/ftk/src/ftkdir.cpp index 1e2dedd..3f93d1e 100644 --- a/ftk/src/ftkdir.cpp +++ b/ftk/src/ftkdir.cpp @@ -132,12 +132,39 @@ Desc: const char * FLMAPI F_DirHdl::currentItemName( void) { const char * pszName = NULL; + +#ifndef FLM_RING_ZERO_NLM if( RC_OK( m_rc)) { pszName = m_szFileName; } +#else + + FLMUINT uiLength; + + if( RC_OK( m_rc)) + { + if( !m_FindData.pCurrentItem) + { + return( NULL); + } + + uiLength = sizeof( m_FindData.ucTempBuffer) - 1; + if( m_FindData.pCurrentItem->DFileNameLength < uiLength) + { + uiLength = m_FindData.pCurrentItem->DFileNameLength; + } + + f_strncpy( m_FindData.ucTempBuffer, + (const char *)m_FindData.pCurrentItem->DFileName, uiLength); + m_FindData.ucTempBuffer[ uiLength] = 0; + pszName = m_FindData.ucTempBuffer; + } + +#endif + return( pszName); } @@ -150,7 +177,11 @@ FINLINE void FLMAPI F_DirHdl::currentItemPath( if( RC_OK( m_rc)) { f_strcpy( pszPath, m_szDirectoryPath); - f_getFileSysPtr()->pathAppend( pszPath, m_szFileName); +#ifdef FLM_RING_ZERO_NLM + f_pathAppend( pszPath, currentItemName()); +#else + f_pathAppend( pszPath, m_szFileName); +#endif } } @@ -167,12 +198,12 @@ FLMBOOL FLMAPI F_DirHdl::currentItemIsDir( void) #elif defined( FLM_RING_ZERO_NLM) - if( !m_FindData.m_pCurrentItem) + if( !m_FindData.pCurrentItem) { return( FALSE); } - return( (m_FindData.m_pCurrentItem->DFileAttributes & SUBDIRECTORY_BIT) + return( (m_FindData.pCurrentItem->DFileAttributes & SUBDIRECTORY_BIT) ? TRUE : FALSE); @@ -198,9 +229,9 @@ FLMUINT64 FLMAPI F_DirHdl::currentItemSize( void) #elif defined( FLM_UNIX) || defined ( FLM_LIBC_NLM) ui64Size = m_FindData.FileStat.st_size; #elif defined( FLM_RING_ZERO_NLM) - if( m_FindData.m_pCurrentItem != NULL ) + if( m_FindData.pCurrentItem != NULL ) { - ui64Size = m_FindData.m_pCurrentItem->DFileSize; + ui64Size = m_FindData.pCurrentItem->DFileSize; } #endif } @@ -287,11 +318,11 @@ RCODE FLMAPI F_DirHdl::next( void) for( ;;) { - if( (lError = DirectorySearch( 0, m_FindData.m_lVolumeNumber, - m_FindData.m_lDirectoryNumber, LONGNameSpace, - m_FindData.m_lCurrentEntryNumber, (BYTE *)"\x02\xFF*", - -1, &m_FindData.m_pCurrentItem, - &m_FindData.m_lCurrentEntryNumber)) != 0) + if( (lError = DirectorySearch( 0, m_FindData.lVolumeNumber, + m_FindData.lDirectoryNumber, LONGNameSpace, + m_FindData.lCurrentEntryNumber, (BYTE *)"\x02\xFF*", + -1, &m_FindData.pCurrentItem, + &m_FindData.lCurrentEntryNumber)) != 0) { if( (lError == ERR_NO_FILES_FOUND) || (lError == ERR_INVALID_PATH)) { @@ -306,7 +337,7 @@ RCODE FLMAPI F_DirHdl::next( void) } if( pFileSystem->doesFileMatch( - (const char *)m_FindData.m_pCurrentItem->DFileName, m_szPattern)) + (const char *)m_FindData.pCurrentItem->DFileName, m_szPattern)) { break; } @@ -321,6 +352,7 @@ Exit: /**************************************************************************** Desc: Open a directory ****************************************************************************/ +#ifndef FLM_RING_ZERO_NLM RCODE FLMAPI F_DirHdl::openDir( const char * pszDirName, const char * pszPattern) @@ -333,11 +365,6 @@ RCODE FLMAPI F_DirHdl::openDir( m_uiAttrib = 0; f_memset( &m_FindData, 0, sizeof( m_FindData)); - -#ifdef FLM_RING_ZERO_NLM - m_FindData.m_lCurrentEntryNumber = 0xFFFFFFFFL; -#endif - f_strcpy( m_szDirectoryPath, pszDirName); if( pszPattern) @@ -350,11 +377,101 @@ RCODE FLMAPI F_DirHdl::openDir( f_strcpy( m_szPattern, pszPattern); } + else + { + m_szPattern[ 0] = 0; + } Exit: return( rc); } +#endif + +/**************************************************************************** +Desc: Open a directory +Notes: + 1. DOS file names, not long file names ! If we want to support long + file names, then increase the size of the filename buffer and change + the name space. + 2. '*.*' doesn't work as a pattern. '*' seems to do the trick. + 3. These Netware APIs are case sensitive. If you want to specify a + a pattern like "*.db" make sure that the files you are looking for + were created with lowercase "db" extensions. + + The path needs to match the case also. For example, + sys:\_netware won't work. SYS:\_NETWARE will. + 4. Server names are not supported by ConvertPathString + 'Connecting to remote servers' is not supported by this code. +****************************************************************************/ +#ifdef FLM_RING_ZERO_NLM +RCODE FLMAPI F_DirHdl::openDir( + const char * pszDirName, + const char * pszPattern) +{ + RCODE rc = NE_FLM_OK; + LONG lError = 0; + LONG unused; + FLMBYTE pseudoLNamePath[ F_PATH_MAX_SIZE + 1]; + FLMBYTE LNamePath[ F_PATH_MAX_SIZE]; + LONG lLNamePathCount; + + m_rc = NE_FLM_OK; + m_bFirstTime = TRUE; + m_bFindOpen = FALSE; + m_uiAttrib = 0; + f_strcpy( m_szDirectoryPath, pszDirName); + + f_memset( &m_FindData, 0, sizeof( m_FindData)); + m_FindData.lVolumeNumber = F_NW_DEFAULT_VOLUME_NUMBER; + m_FindData.lCurrentEntryNumber = 0xFFFFFFFF; + m_FindData.lDirectoryNumber = 0xFFFFFFFF; + + LNamePath[0] = 0; + lLNamePathCount = 0; + + f_strcpy( (char *)&pseudoLNamePath[1], pszDirName); + pseudoLNamePath[ 0] = (FLMBYTE)f_strlen( (const char *)&pseudoLNamePath[ 1]); + + if( (lError = ConvertPathString( 0, 0, pseudoLNamePath, + &m_FindData.lVolumeNumber, + &unused, (BYTE *)LNamePath, &lLNamePathCount)) != 0) + { + goto Exit; + } + + if( (lError = MapPathToDirectoryNumber( 0, m_FindData.lVolumeNumber, 0, + (BYTE *)LNamePath, lLNamePathCount, LONGNameSpace, + &m_FindData.lDirectoryNumber, &unused)) != 0) + { + goto Exit; + } + + if( pszPattern) + { + if( f_strlen( pszPattern) >= (FLMINT)sizeof( m_szPattern)) + { + rc = RC_SET( NE_FLM_MEM); + goto Exit; + } + + f_strcpy( m_szPattern, pszPattern); + } + else + { + m_szPattern[ 0] = 0; + } + +Exit: + + if( lError != 0) + { + m_rc = f_mapPlatformError( lError, NE_FLM_OPENING_FILE); + } + + return( m_rc); +} +#endif /**************************************************************************** Desc: Create a directory (and parent directories if necessary). diff --git a/ftk/src/ftkftx.cpp b/ftk/src/ftkftx.cpp index efdd100..6a40cce 100644 --- a/ftk/src/ftkftx.cpp +++ b/ftk/src/ftkftx.cpp @@ -568,12 +568,12 @@ RCODE FLMAPI FTXInit( ftxDisplayReset(); ftxDisplayGetSize( &(gv_pFtxInfo->uiCols), &(gv_pFtxInfo->uiRows)); - if( gv_pFtxInfo->uiCols > uiCols) + if( uiCols && gv_pFtxInfo->uiCols > uiCols) { gv_pFtxInfo->uiCols = uiCols; } - if( gv_pFtxInfo->uiRows > uiRows) + if( uiRows && gv_pFtxInfo->uiRows > uiRows) { gv_pFtxInfo->uiRows = uiRows; } diff --git a/ftk/src/ftkmem.cpp b/ftk/src/ftkmem.cpp index d34c3e1..bb925f0 100644 --- a/ftk/src/ftkmem.cpp +++ b/ftk/src/ftkmem.cpp @@ -126,17 +126,17 @@ Desc: #endif #ifdef FLM_DEBUG -static FLMBOOL gv_bMemTrackingInitialized = FALSE; -static FLMUINT gv_uiInitThreadId = 0; -static F_MUTEX gv_hMemTrackingMutex = F_MUTEX_NULL; -static FLMUINT gv_uiMemTrackingPtrArraySize = 0; -static FLMUINT gv_uiNumMemPtrs = 0; -static void ** gv_ppvMemTrackingPtrs = NULL; -static FLMUINT gv_uiNextMemPtrSlotToUse = 0; -static FLMUINT gv_uiAllocCnt = 0; -static FLMBOOL gv_bTrackLeaks = TRUE; -static FLMBOOL gv_bStackWalk = TRUE; -static FLMBOOL gv_bLogLeaks = FALSE; + static FLMBOOL gv_bMemTrackingInitialized = FALSE; + static FLMUINT gv_uiInitThreadId = 0; + static F_MUTEX gv_hMemTrackingMutex = F_MUTEX_NULL; + static FLMUINT gv_uiMemTrackingPtrArraySize = 0; + static FLMUINT gv_uiNumMemPtrs = 0; + static void ** gv_ppvMemTrackingPtrs = NULL; + static FLMUINT gv_uiNextMemPtrSlotToUse = 0; + static FLMUINT gv_uiAllocCnt = 0; + static FLMBOOL gv_bTrackLeaks = FALSE; + static FLMBOOL gv_bStackWalk = FALSE; + static FLMBOOL gv_bLogLeaks = FALSE; #endif #ifdef FLM_WIN @@ -1094,6 +1094,9 @@ FSTATIC FLMBOOL initMemTracking( void) SymSetOptions( SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS); gv_hMemProcess = GetCurrentProcess(); SymInitialize( gv_hMemProcess, NULL, TRUE); + + gv_bTrackLeaks = TRUE; + gv_bStackWalk = TRUE; #endif gv_bMemTrackingInitialized = TRUE; } @@ -1246,13 +1249,13 @@ FSTATIC void freeMemTrackingInfo( FLMUINT uiId, FLMUINT * puiStack) { - if (uiId) + if( uiId) { // NOTE: If uiId is non-zero, it means we had to have // successfully initialized, so we are guaranteed to // have a mutex. - if ( !bMutexAlreadyLocked) + if( !bMutexAlreadyLocked) { f_mutexLock( gv_hMemTrackingMutex); } @@ -1261,9 +1264,12 @@ FSTATIC void freeMemTrackingInfo( // is never zero - a value of zero means that the allocation // does not have a slot for tracking it in the array. - gv_ppvMemTrackingPtrs [uiId - 1] = NULL; - f_assert( gv_uiNumMemPtrs); - gv_uiNumMemPtrs--; + if( gv_ppvMemTrackingPtrs) + { + gv_ppvMemTrackingPtrs[ uiId - 1] = NULL; + f_assert( gv_uiNumMemPtrs); + gv_uiNumMemPtrs--; + } if ( !bMutexAlreadyLocked) { @@ -1273,7 +1279,7 @@ FSTATIC void freeMemTrackingInfo( // Free the stack information, if any. - if (puiStack) + if( puiStack) { os_free( puiStack); } diff --git a/ftk/src/ftknlm.cpp b/ftk/src/ftknlm.cpp index f5c8d3c..02f083d 100644 --- a/ftk/src/ftknlm.cpp +++ b/ftk/src/ftknlm.cpp @@ -595,13 +595,6 @@ FSTATIC zDIO_WRITE_FUNC gv_zDIOWriteFunc = NULL; FSTATIC zRENAME_FUNC gv_zRenameFunc = NULL; - static unsigned long yieldTimeSlice = 0; - static unsigned long stackFrame[0x100] = {0}; - static unsigned long * ThreadFeederQue = 0; - static struct OldPerCpuStruct * pPerCpuDataArea = 0; - - extern "C" unsigned long CpuCurrentProcessor; - extern "C" unsigned long WorkToDoListHead; static void * gv_MyModuleHandle = NULL; static FLMATOMIC gv_NetWareStartupCount = 0; rtag_t gv_lAllocRTag = 0; @@ -613,16 +606,6 @@ static FLMBOOL gv_bMainRunning = FALSE; static F_EXIT_FUNC gv_fnExit = NULL; - struct OldPerCpuStruct - { - unsigned long reserved0[24]; - unsigned long reserved1[3]; - unsigned long PSD_ThreadStartClocks; - unsigned long reserved2[4]; - unsigned long reserved3[40]; - unsigned long PSD_LocalWTDHead; - }; - #if !defined( __MWERKS__) extern unsigned long ReadInternalClock(void); #else @@ -3829,160 +3812,13 @@ FSTATIC void ConvertToQualifiedNWPath( } #endif -/**************************************************************************** -Desc: This API is called once the first time NWYieldIfTime() is called if - kYieldIfTimeSliceUp isn't supported by the host OS. -****************************************************************************/ -#if defined( FLM_RING_ZERO_NLM) -FSTATIC int LocalYieldInit(void) -{ - unsigned char * buffer; - unsigned char * pointer; - unsigned long ccode; - unsigned long address; - unsigned long (*ConvertMicroSecondsToClocks)(unsigned long data); - - // Fixup ThreadFeededQue - - buffer = (unsigned char *)"SERVER.NLM|ThreadFeederQue"; - - // Get the address from the debugger - - ccode = CEvaluateExpression( &buffer, &stackFrame[0], &address); - if (ccode != 0) - { - return( -1); - } - - ThreadFeederQue = (unsigned long *)address; - - // Setup yieldTimeSlice - // First get a pointer to ConvertMicroSecondsToClocks and then verify it - - pointer = (unsigned char *)(&StopBell); - pointer = pointer + 0x1ea; - if (pointer[0] != 0x8b || - pointer[1] != 0x44 || - pointer[2] != 0x24 || - pointer[3] != 0x04 || - pointer[4] != 0x33 || - pointer[5] != 0xd2 || - pointer[6] != 0xf7) - { - return( -1); - } - - *(unsigned long *)(&ConvertMicroSecondsToClocks) = (unsigned long)pointer; - - // Now calculate our desired time slice in clocks - - yieldTimeSlice = (*ConvertMicroSecondsToClocks)(200); - - // Get a pointer to the per-CPU data area - - buffer = (unsigned char *)"LOADER.NLM|PerCpuDataArea"; - ccode = CEvaluateExpression( &buffer, &stackFrame[0], &address); - if (ccode != 0) - { - return( -1); - } - - pPerCpuDataArea = (struct OldPerCpuStruct *)address; - return( 0); -} -#endif - -/**************************************************************************** -Desc: This routine does everything that kYieldIfTimeSliceUp() does, and it is - compatible with 5.0 SP4 and 5.1 release. It shouldn't be used on host - OSs that support kYieldIfTimeSliceUp(). -****************************************************************************/ -#if defined( FLM_RING_ZERO_NLM) -FSTATIC void OldOSCompatibleYield(void) -{ - unsigned long timeStamp; - unsigned long threadStartTime; - - if ((CpuCurrentProcessor == 0) && (WorkToDoListHead != 0)) - { - - // If we are P0 and there is legacy WTD waiting, then yield - - kYieldThread(); - return; - } - - if ((pPerCpuDataArea->PSD_LocalWTDHead != 0) || - (kQueCount( ThreadFeederQue[CpuCurrentProcessor]) != 0)) - { - - // If there is MPK WTD or a feederQ thread waiting, then yield - - kYieldThread(); - return; - } - - timeStamp = ReadInternalClock(); - threadStartTime = pPerCpuDataArea->PSD_ThreadStartClocks; - - // Note 32 bit arithmetic is sufficient and less overhead - - if ((timeStamp - threadStartTime) > yieldTimeSlice) - { - kYieldThread(); - } -} -#endif - -/**************************************************************************** -Desc: This is the routine to call for time sensitive yielding. The first - time it is called, it will change itself to a JMP to the appropriate - yield procedure. If it is on 5.1 SP1 or greater, it will jump to - kYieldIfTimeSliceUp(). If it is on 5.0 SP4 or 5.1 release, it will - jump to OldOSCompatibleYield(). Otherwise it will jump to - kYieldThread(). -****************************************************************************/ -#if defined( FLM_RING_ZERO_NLM) -void NWYieldIfTime( void) -{ - unsigned char * fixup; - unsigned long address; - - *(unsigned long *)(&address) = ImportPublicSymbol( - (unsigned long)f_getNLMHandle(), - (unsigned char *)"\x13" "kYieldIfTimeSliceUp"); - - fixup = (unsigned char *)(&NWYieldIfTime); - - if (address == 0) - { - // We couldn't import the procedure, so see if our local routine - // is compatible. - - if (LocalYieldInit() == 0) - { - address = (unsigned long)(&OldOSCompatibleYield); - } - else - { - address = (unsigned long)(&kYieldThread); - } - } - - fixup[0] = 0xE9; - ++fixup; - address = address - (4 + (unsigned long)fixup); - *(unsigned long *)fixup = address; -} -#endif - /**************************************************************************** Desc: ****************************************************************************/ #if defined( FLM_RING_ZERO_NLM) void FLMAPI f_yieldCPU( void) { - NWYieldIfTime(); + kYieldIfTimeSliceUp(); } #endif @@ -4109,7 +3945,7 @@ Desc: Startup routine for the NLM - that gets the main going in its own thread. *********************************************************************/ #if defined( FLM_RING_ZERO_NLM) -extern "C" static void * f_nlmMainStub( +extern "C" void * f_nlmMainStub( void * hThread, void * pData) { @@ -4130,7 +3966,7 @@ extern "C" static void * f_nlmMainStub( gv_bMainRunning = FALSE; - if (!gv_bUnloadCalled) + if( !gv_bUnloadCalled) { KillMe( moduleHandle); } @@ -4172,9 +4008,12 @@ extern "C" LONG f_nlmEntryPoint( ARG_DATA * pArgData = NULL; LONG sdRet = 0; char * pszThreadName; - int iTmpLen; + char * pszModuleName; + int iModuleNameLen; + int iThreadNameLen; + int iLoadDirPathSize; void * hThread = NULL; - + (void)initScreen; (void)uninitializedDataLength; (void)fileHandle; @@ -4213,7 +4052,10 @@ extern "C" LONG f_nlmEntryPoint( sdRet = 1; goto Exit; } - + + pszModuleName = (char *)(&moduleHandle->LDFileName[ 1]); + iModuleNameLen = (int)(moduleHandle->LDFileName[ 0]); + // First pass: Count the arguments in the command line // and determine how big of a buffer we will need. // Second pass: Put argments into allocated buffer. @@ -4222,13 +4064,16 @@ Parse_Args: iTotalArgChars = 0; iArgC = 0; - - iArgSize = f_strlen( (const char *)loadDirectoryPath); - if (!bFirstPass) + + iLoadDirPathSize = f_strlen( (const char *)loadDirectoryPath); + iArgSize = iLoadDirPathSize + iModuleNameLen; + + if( !bFirstPass) { - ppszArgV [iArgC] = pszDestArg; - f_memcpy( pszDestArg, loadDirectoryPath, iArgSize); - pszDestArg [iArgSize] = 0; + ppszArgV[ iArgC] = pszDestArg; + f_memcpy( pszDestArg, loadDirectoryPath, iLoadDirPathSize); + f_memcpy( &pszDestArg[ iLoadDirPathSize], pszModuleName, iModuleNameLen); + pszDestArg[ iArgSize] = 0; pszDestArg += (iArgSize + 1); } @@ -4240,17 +4085,17 @@ Parse_Args: { // Skip leading blanks. - while ((*pszTmp) && (*pszTmp == ' ')) + while( *pszTmp && *pszTmp == ' ') { pszTmp++; } - if (!(*pszTmp)) + if( *pszTmp == 0) { break; } - if ((*pszTmp == '"') || (*pszTmp == '\'')) + if( *pszTmp == '"' || *pszTmp == '\'') { cEnd = *pszTmp; pszTmp++; @@ -4259,32 +4104,35 @@ Parse_Args: { cEnd = ' '; } + pszArgStart = pszTmp; iArgSize = 0; // Count the characters in the parameter. - while ((*pszTmp) && (*pszTmp != cEnd)) + while( *pszTmp && *pszTmp != cEnd) { iArgSize++; pszTmp++; } - if ((!iArgSize) && (cEnd == ' ')) + if( !iArgSize && cEnd == ' ') { break; } // If 2nd pass, save the argument. - if (!bFirstPass) + if( !bFirstPass) { - ppszArgV [iArgC] = pszDestArg; - if (iArgSize) + ppszArgV[ iArgC] = pszDestArg; + + if( iArgSize) { f_memcpy( pszDestArg, pszArgStart, iArgSize); } - pszDestArg [iArgSize] = 0; + + pszDestArg[ iArgSize] = 0; pszDestArg += (iArgSize + 1); } @@ -4293,13 +4141,13 @@ Parse_Args: // Skip trailing quote or blank. - if (*pszTmp) + if( *pszTmp) { pszTmp++; } } - if (bFirstPass) + if( bFirstPass) { if ((ppszArgV = (char **)Alloc( sizeof( char *) * iArgC, gv_lAllocRTag)) == NULL) @@ -4308,7 +4156,7 @@ Parse_Args: goto Exit; } - if ((pszArgs = (char *)Alloc( iTotalArgChars + iArgC, + if( (pszArgs = (char *)Alloc( iTotalArgChars + iArgC, gv_lAllocRTag)) == NULL) { sdRet = 1; @@ -4320,19 +4168,18 @@ Parse_Args: goto Parse_Args; } - pszTmp = (char *)(&moduleHandle->LDName [1]); - iTmpLen = (int)(moduleHandle->LDName [0]); - - if ((pszThreadName = (char *)Alloc( iTmpLen + 1, gv_lAllocRTag)) == NULL) + iThreadNameLen = (int)(moduleHandle->LDName[ 0]); + + if( (pszThreadName = (char *)Alloc( iThreadNameLen + 1, gv_lAllocRTag)) == NULL) { sdRet = 1; goto Exit; } - f_memcpy( pszThreadName, pszTmp, iTmpLen); - pszThreadName [iTmpLen] = 0; + f_memcpy( pszThreadName, (char *)(&moduleHandle->LDName[ 1]), iThreadNameLen); + pszThreadName[ iThreadNameLen] = 0; - if ((pArgData = (ARG_DATA *)Alloc( sizeof( ARG_DATA), + if( (pArgData = (ARG_DATA *)Alloc( sizeof( ARG_DATA), gv_lAllocRTag)) == NULL) { sdRet = 1; @@ -4347,16 +4194,15 @@ Parse_Args: gv_bMainRunning = TRUE; - if ((hThread = kCreateThread( (BYTE *)"FTK main", - f_nlmMainStub, NULL, 32768, - (void *)pArgData)) == NULL) + if( (hThread = kCreateThread( (BYTE *)"FTK main", + f_nlmMainStub, NULL, 32768, (void *)pArgData)) == NULL) { gv_bMainRunning = FALSE; sdRet = 2; goto Exit; } - if (kSetThreadLoadHandle( hThread, (LONG)moduleHandle) != 0) + if( kSetThreadLoadHandle( hThread, (LONG)moduleHandle) != 0) { (void)kDestroyThread( hThread); gv_bMainRunning = FALSE; @@ -4364,7 +4210,7 @@ Parse_Args: goto Exit; } - if (kScheduleThread( hThread) != 0) + if( kScheduleThread( hThread) != 0) { (void)kDestroyThread( hThread); gv_bMainRunning = FALSE; @@ -4374,44 +4220,44 @@ Parse_Args: // Synchronized start - if (moduleHandle->LDFlags & 4) + if( moduleHandle->LDFlags & 4) { (void)kSemaphoreWait( gv_lFlmSyncSem); } Exit: - if (sdRet != 0) + if( sdRet != 0) { f_atomicDec( &gv_NetWareStartupCount); - if (ppszArgV) + if( ppszArgV) { Free( ppszArgV); } - if (pszArgs) + if( pszArgs) { Free( pszArgs); } - if (pszThreadName) + if( pszThreadName) { Free( pszThreadName); } - if (pArgData) + if( pArgData) { Free( pArgData); } - if (gv_lFlmSyncSem) + if( gv_lFlmSyncSem) { kSemaphoreFree( gv_lFlmSyncSem); gv_lFlmSyncSem = 0; } - if (!gv_bUnloadCalled) + if( !gv_bUnloadCalled) { KillMe( moduleHandle); } diff --git a/ftk/src/ftknlm.h b/ftk/src/ftknlm.h index 283772e..d01841e 100644 --- a/ftk/src/ftknlm.h +++ b/ftk/src/ftknlm.h @@ -850,6 +850,8 @@ void * StackAddressHigh, LONG StackSize, void * Argument); + + extern "C" void kYieldIfTimeSliceUp( void); extern "C" int kSetThreadName( void * ThreadHandle, @@ -1255,16 +1257,6 @@ FLMUINT * allocatedNodes, FLMUINT * totalMemory); - extern "C" void StopBell( void); - - extern "C" unsigned long kQueCount( - unsigned long uiQueHandle); - - extern "C" unsigned long CEvaluateExpression( - unsigned char ** commandLine, - unsigned long * stackFrame, - unsigned long * number); - extern "C" LONG atomic_xchg( volatile LONG * address, LONG value); diff --git a/ftk/src/ftkprntf.cpp b/ftk/src/ftkprntf.cpp index ad39d9f..e71783b 100644 --- a/ftk/src/ftkprntf.cpp +++ b/ftk/src/ftkprntf.cpp @@ -774,17 +774,17 @@ FLMINT FLMAPI f_printf( const char * pszFormat, ...) { -#ifndef FLM_RING_ZERO_NLM - FLMINT iLen; - va_list args; + FLMINT iLen; + f_va_list args; + char szTmpBuf[ 512]; - va_start(args, pszFormat); - iLen = vprintf( pszFormat, args); - va_end(args); + f_va_start( args, pszFormat); + iLen = f_vsprintf( szTmpBuf, pszFormat, &args); + f_va_end(args); + +#ifndef FLM_RING_ZERO_NLM + printf( szTmpBuf); +#endif return( iLen); -#else - F_UNREFERENCED_PARM( pszFormat); - return( 0); -#endif } diff --git a/ftk/src/ftksem.cpp b/ftk/src/ftksem.cpp index 24534bb..658863e 100644 --- a/ftk/src/ftksem.cpp +++ b/ftk/src/ftksem.cpp @@ -258,7 +258,7 @@ void FLMAPI f_mutexUnlock( /**************************************************************************** Desc: ****************************************************************************/ -#if defined( FLM_UNIX) || defined( FLM_LIBC_NLM) +#if defined( FLM_UNIX) || defined( FLM_NLM) void FLMAPI f_assertMutexLocked( F_MUTEX) { diff --git a/ftk/src/ftksys.h b/ftk/src/ftksys.h index bd68370..9507e0e 100644 --- a/ftk/src/ftksys.h +++ b/ftk/src/ftksys.h @@ -1216,11 +1216,11 @@ typedef struct { - LONG m_lVolumeNumber; - LONG m_lDirectoryNumber; - LONG m_lCurrentEntryNumber; - struct DirectoryStructure * m_pCurrentItem; - char m_ucTempBuffer[ F_FILENAME_SIZE]; + LONG lVolumeNumber; + LONG lDirectoryNumber; + LONG lCurrentEntryNumber; + struct DirectoryStructure * pCurrentItem; + char ucTempBuffer[ F_FILENAME_SIZE]; } F_IO_FIND_DATA; #else @@ -1265,14 +1265,14 @@ char m_szDirectoryPath[ F_PATH_MAX_SIZE]; char m_szPattern[ F_PATH_MAX_SIZE]; - FLMUINT32 m_ui32RefCount; RCODE m_rc; FLMBOOL m_bFirstTime; FLMBOOL m_bFindOpen; - FLMBOOL m_EOF; - char m_szFileName[ F_PATH_MAX_SIZE]; FLMUINT m_uiAttrib; F_IO_FIND_DATA m_FindData; + #ifndef FLM_RING_ZERO_NLM + char m_szFileName[ F_PATH_MAX_SIZE]; + #endif friend class F_FileSystem; }; diff --git a/ftk/src/ftkthrd.cpp b/ftk/src/ftkthrd.cpp index 065a55f..27a2e12 100644 --- a/ftk/src/ftkthrd.cpp +++ b/ftk/src/ftkthrd.cpp @@ -548,7 +548,7 @@ RCODE FLMAPI F_Thread::startThread( if( (hThread = kCreateThread( (BYTE *)((m_pszThreadName) ? (BYTE *)m_pszThreadName - : (BYTE *)"NDSDB"), + : (BYTE *)"FTK"), threadStub, NULL, (LONG)m_uiStackSize, (void *)this)) == NULL) {