static const char * hb_compChkOptionGet( const char * szSwitch, char ** pszResult, HB_BOOL fEnv ) { HB_SIZE nLen = hb_compChkOptionLen( szSwitch, fEnv ); if( pszResult ) *pszResult = hb_strndup( szSwitch, nLen ); return szSwitch + nLen; }
static int hb_regexec( PHB_REGEX pRegEx, const char * szString, HB_SIZE nLen, int iMatches, HB_REGMATCH * aMatches ) { #if defined( HB_HAS_PCRE ) int iResult, i; iResult = pcre_exec( pRegEx->re_pcre, NULL /* pcre_extra */, szString, ( int ) nLen, 0 /* startoffset */, pRegEx->iEFlags, aMatches, HB_REGMATCH_SIZE( iMatches ) ); if( iResult == 0 ) { for( i = 0; i < iMatches; i++ ) { if( HB_REGMATCH_EO( aMatches, i ) != -1 ) iResult = i + 1; } } return iResult; #elif defined( HB_POSIX_REGEX ) char * szBuffer = NULL; int iResult, i; if( szString[ nLen ] != 0 ) { szBuffer = hb_strndup( szString, nLen ); szString = szBuffer; } for( i = 0; i < iMatches; i++ ) HB_REGMATCH_EO( aMatches, i ) = -1; iResult = regexec( &pRegEx->reg, szString, iMatches, aMatches, pRegEx->iEFlags ); if( iResult == 0 ) { for( i = 0; i < iMatches; i++ ) { if( HB_REGMATCH_EO( aMatches, i ) != -1 ) iResult = i + 1; } } else iResult = -1; if( szBuffer ) hb_xfree( szBuffer ); return iResult; #else HB_SYMBOL_UNUSED( pRegEx ); HB_SYMBOL_UNUSED( szString ); HB_SYMBOL_UNUSED( nLen ); HB_SYMBOL_UNUSED( iMatches ); HB_SYMBOL_UNUSED( aMatches ); return -1; #endif }
BOOL hb_fsIsDirectory( const char * pszFilename ) { BOOL bResult = FALSE; char * pszFree = NULL; HB_SIZE iLen; HB_TRACE( HB_TR_DEBUG, ( "hb_fsIsDirectory(%s)", pszFilename ) ); pszFilename = hb_fsNameConv( pszFilename, &pszFree ); iLen = strlen( pszFilename ); while( iLen && strchr( HB_OS_PATH_DELIM_CHR_LIST, pszFilename[ iLen - 1 ] ) ) --iLen; if( iLen && iLen <= ( HB_PATH_MAX - 1 ) ) { #if defined( HB_OS_WIN ) { DWORD dAttr = GetFileAttributes( ( LPCTSTR ) pszFilename ); bResult = ( dAttr == INVALID_FILE_ATTRIBUTES ? FALSE : ( dAttr & FILE_ATTRIBUTE_DIRECTORY ) ); } #else { PHB_FFIND ffind; if( pszFilename[ iLen ] ) { if( pszFree ) pszFree[ iLen ] = '\0'; else pszFilename = pszFree = hb_strndup( pszFilename, iLen ); } if( ( ffind = hb_fsFindFirst( pszFilename, HB_FA_DIRECTORY ) ) != NULL ) { if( ( ffind->attr & HB_FA_DIRECTORY ) == HB_FA_DIRECTORY ) bResult = TRUE; hb_fsFindClose( ffind ); } } #endif } hb_fsSetError( 0 ); if( pszFree ) hb_xfree( pszFree ); return bResult; }
static const char * hb_compChkAddDefine( HB_COMP_DECL, const char * szSwitch, HB_BOOL fAdd, HB_BOOL fEnv ) { const char * szSwPtr = szSwitch; HB_SIZE nValue = 0; while( *szSwPtr && *szSwPtr != ' ' && ! HB_ISOPTSEP( *szSwPtr ) ) { if( *szSwPtr == '=' ) { nValue = szSwPtr - szSwitch; szSwPtr += hb_compChkOptionLen( szSwPtr, fEnv ); break; } ++szSwPtr; } if( szSwPtr > szSwitch && *szSwitch != '=' ) { char * szDefine = hb_strndup( szSwitch, szSwPtr - szSwitch ); char * szValue = NULL; PHB_PPDEFINE * pDefinePtr; if( nValue ) { szValue = szDefine + nValue; *szValue++ = '\0'; } if( ! fAdd ) szValue = s_szUndefineMarker; pDefinePtr = &HB_COMP_PARAM->ppdefines; while( *pDefinePtr != NULL && strcmp( ( *pDefinePtr )->szName, szDefine ) != 0 ) pDefinePtr = &( *pDefinePtr )->pNext; if( *pDefinePtr == NULL ) { *pDefinePtr = ( PHB_PPDEFINE ) hb_xgrab( sizeof( HB_PPDEFINE ) ); ( *pDefinePtr )->pNext = NULL; } else hb_xfree( ( *pDefinePtr )->szName ); ( *pDefinePtr )->szName = szDefine; ( *pDefinePtr )->szValue = szValue; } return szSwPtr; }
static const char * hb_compChkOptionAddPath( HB_COMP_DECL, const char * szSwitch, HB_BOOL fEnv ) { HB_SIZE nLen = hb_compChkOptionLen( szSwitch, fEnv ); if( nLen > 0 ) { if( szSwitch[ nLen ] != '\0' ) { char * szVal = hb_strndup( szSwitch, nLen ); hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, szSwitch, HB_FALSE ); hb_xfree( szVal ); } else hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, szSwitch, HB_FALSE ); } return szSwitch + nLen; }
static const char * hb_compChkOptionFName( const char * szSwitch, PHB_FNAME * pResult, HB_BOOL fEnv ) { HB_SIZE nLen = hb_compChkOptionLen( szSwitch, fEnv ); if( nLen > 0 ) { if( *pResult ) hb_xfree( *pResult ); if( szSwitch[ nLen ] != '\0' ) { char * szVal = hb_strndup( szSwitch, nLen ); *pResult = hb_fsFNameSplit( szVal ); hb_xfree( szVal ); } else *pResult = hb_fsFNameSplit( szSwitch ); } return szSwitch + nLen; }
HB_BOOL hb_fsIsDirectory( const char * pszFilename ) { HB_BOOL bResult = HB_FALSE; PHB_FFIND ffind; char * pszFree = NULL; int iLen; HB_TRACE( HB_TR_DEBUG, ( "hb_fsIsDirectory(%s)", pszFilename ) ); iLen = ( int ) strlen( pszFilename ); while( iLen && strchr( HB_OS_PATH_DELIM_CHR_LIST, pszFilename[ iLen - 1 ] ) ) --iLen; if( pszFilename[ iLen ] ) pszFilename = pszFree = hb_strndup( pszFilename, iLen ); if( iLen && iLen <= ( HB_PATH_MAX - 1 ) ) { if( ( ffind = hb_fsFindFirst( pszFilename, HB_FA_DIRECTORY ) ) != NULL ) { do { if( ( ffind->attr & HB_FA_DIRECTORY ) == HB_FA_DIRECTORY ) { bResult = HB_TRUE; break; } } while( hb_fsFindNext( ffind ) ); hb_fsFindClose( ffind ); } } if( pszFree ) hb_xfree( pszFree ); return bResult; }
static PHB_FILE s_fileOpen( PHB_FILE_FUNCS pFuncs, const char * pszName, const char * pszDefExt, HB_FATTR nExFlags, const char * pPaths, PHB_ITEM pError ) { const char * pszHost = pszName + FILE_PREFIX_LEN, * ptr; PHB_FILE pFile = NULL; HB_ERRCODE errcode = 0; HB_SIZE nLen = 0; int iPort = 0; HB_MAXINT timeout = -1; HB_SYMBOL_UNUSED( pFuncs ); HB_SYMBOL_UNUSED( pszDefExt ); HB_SYMBOL_UNUSED( pPaths ); if( ( ptr = strchr( pszHost, ':' ) ) != NULL && ptr != pszHost ) { nLen = ptr - pszHost; ++ptr; while( HB_ISDIGIT( * ptr ) ) iPort = iPort * 10 + ( * ptr++ - '0' ); if( * ptr == ':' ) { ++ptr; while( HB_ISDIGIT( * ptr ) ) timeout = HB_MAX( timeout, 0 ) * 10 + ( * ptr++ - '0' ); } if( * ptr != 0 && * ptr != ':' ) iPort = 0; } if( iPort > 0 ) { char * pszAddr, * pszIpAddr; hb_socketAutoInit(); pszAddr = hb_strndup( pszHost, nLen ); pszIpAddr = hb_socketResolveAddr( pszAddr, HB_SOCKET_AF_INET ); hb_xfree( pszAddr ); if( pszIpAddr ) { HB_SOCKET sd = hb_socketOpen( HB_SOCKET_PF_INET, HB_SOCKET_PT_STREAM, 0 ); if( sd != HB_NO_SOCKET ) { void * pSockAddr; unsigned uiLen; if( hb_socketInetAddr( &pSockAddr, &uiLen, pszIpAddr, iPort ) ) { hb_socketSetKeepAlive( sd, HB_TRUE ); if( hb_socketConnect( sd, pSockAddr, uiLen, timeout ) == 0 ) { PHB_SOCKEX sock; switch( nExFlags & ( FO_READ | FO_WRITE | FO_READWRITE ) ) { case FO_READ: hb_socketShutdown( sd, HB_SOCKET_SHUT_WR ); break; case FO_WRITE: hb_socketShutdown( sd, HB_SOCKET_SHUT_RD ); break; } sock = hb_sockexNew( sd, NULL, NULL ); if( sock ) { hb_sockexSetShutDown( sock, HB_TRUE ); hb_sockexSetAutoFlush( sock, HB_TRUE ); pFile = s_fileNew( sock, timeout ); sd = HB_NO_SOCKET; } } hb_xfree( pSockAddr ); } if( sd != HB_NO_SOCKET ) { errcode = hb_socketGetError(); hb_socketClose( sd ); } } hb_xfree( pszIpAddr ); } if( errcode == 0 && pFile == NULL ) errcode = hb_socketGetError(); } else errcode = HB_SOCKET_ERR_WRONGADDR; hb_fsSetError( errcode ); if( pError ) { hb_errPutFileName( pError, pszName ); if( pFile == NULL ) { hb_errPutOsCode( pError, errcode ); hb_errPutGenCode( pError, ( HB_ERRCODE ) EG_OPEN ); } } return pFile; }
static int s_filePortParams( const char * pszName, int * piTimeout, int * piBaud, int * piParity, int * piSize, int * piStop, int * piFlow ) { int iPort = 0, iLen, iValue; *piTimeout = -1; *piBaud = *piParity = *piSize = *piStop = *piFlow = 0; pszName += 3; if( *pszName == '$' ) { const char * pszParams = strchr( pszName, ':' ); if( pszParams != NULL && pszParams - pszName > 1 ) { char * pszPort = hb_strndup( pszName + 1, pszParams - pszName - 1 ); iPort = hb_comFindPort( pszPort, HB_TRUE ); hb_xfree( pszPort ); pszName = pszParams; } } else { while( HB_ISDIGIT( *pszName ) ) iPort = iPort * 10 + ( *pszName++ - '0' ); } while( iPort > 0 && *pszName ) { if( HB_ISDIGIT( *pszName ) ) { iValue = s_fileGetValue( pszName, &iLen ); if( iLen == 1 ) { if( iValue >= 1 && iValue <= 2 && *piStop == 0 ) *piStop = iValue; else if( iValue >= 5 && iValue <= 8 && *piSize == 0 ) *piSize = iValue; else iPort = -1; } else if( iLen == 2 && *piStop == 0 && *piSize == 0 ) { if( pszName[ 0 ] >= '1' && pszName[ 0 ] <= '2' && pszName[ 1 ] >= '5' && pszName[ 1 ] <= '8' ) { *piStop = pszName[ 0 ] - '0'; *piSize = pszName[ 1 ] - '0'; } else if( pszName[ 0 ] >= '5' && pszName[ 0 ] <= '8' && pszName[ 1 ] >= '1' && pszName[ 1 ] <= '2' ) { *piStop = pszName[ 1 ] - '0'; *piSize = pszName[ 0 ] - '0'; } else if( *piBaud ) iPort = -1; else *piBaud = iValue; } else if( *piBaud ) iPort = -1; else *piBaud = iValue; pszName += iLen; } else if( HB_ISALPHA( *pszName ) ) { if( hb_strnicmp( pszName, "RTS", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_IRTSCTS; pszName += 3; } else if( hb_strnicmp( pszName, "CTS", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_ORTSCTS; pszName += 3; } else if( hb_strnicmp( pszName, "DTR", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_IDTRDSR; pszName += 3; } else if( hb_strnicmp( pszName, "DSR", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_ODTRDSR; pszName += 3; } else if( hb_strnicmp( pszName, "DCD", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_DCD; pszName += 3; } else if( hb_strnicmp( pszName, "XOFF", 4 ) == 0 ) { *piFlow |= HB_COM_FLOW_XOFF; pszName += 4; } else if( hb_strnicmp( pszName, "XON", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_XON; pszName += 3; } else if( *piParity == 0 && ! HB_ISALPHA( pszName[ 1 ] ) ) { switch( *pszName ) { case 'N': case 'n': case 'E': case 'e': case 'O': case 'o': case 'S': case 's': case 'M': case 'm': *piParity = HB_TOUPPER( *pszName ); pszName++; break; default: iPort = -1; break; } } else iPort = -1; } else if( *pszName == ':' || *pszName == ',' || *pszName == ' ' ) pszName++; else iPort = -1; } if( *piBaud == 0 ) *piBaud = 9600; if( *piParity == 0 ) *piParity = 'N'; if( *piSize == 0 ) *piSize = 8; if( *piStop == 0 ) *piStop = 1; return iPort; }
PHB_DEBUGINFO hb_compGetDebugInfo( HB_COMP_DECL ) { PHB_DEBUGINFO pLineInfo = NULL, pInfo = NULL; HB_SIZE nPos, nSkip, nOffset; HB_ULONG ulLine; const char * pszModuleName = "", * ptr; PFUNCTION pFunc; pFunc = HB_COMP_PARAM->functions.pFirst; while( pFunc ) { if( ( pFunc->funFlags & FUN_FILE_DECL ) == 0 ) { nPos = ulLine = 0; while( nPos < pFunc->nPCodePos ) { nSkip = 0; switch( pFunc->pCode[ nPos ] ) { case HB_P_LINE: ulLine = HB_PCODE_MKUSHORT( &pFunc->pCode[ nPos + 1 ] ); break; case HB_P_MODULENAME: pszModuleName = ( const char * ) &pFunc->pCode[ nPos + 1 ]; pInfo = NULL; break; /* * This enables checking also code block bodies, * if it's not necessary then simply remove the * code below. [druzus] */ case HB_P_PUSHBLOCKLARGE: nSkip = 8 + HB_PCODE_MKUSHORT( &pFunc->pCode[ nPos + 6 ] ) * 2; break; case HB_P_PUSHBLOCK: nSkip = 7 + HB_PCODE_MKUSHORT( &pFunc->pCode[ nPos + 5 ] ) * 2; break; case HB_P_PUSHBLOCKSHORT: nSkip = 2; break; } if( ulLine != 0 ) { if( ! pInfo ) { int i; ptr = strchr( pszModuleName, ':' ); i = ptr ? ( int ) ( ptr - pszModuleName ) : ( int ) strlen( pszModuleName ); pInfo = pLineInfo; while( pInfo != NULL ) { if( strncmp( pszModuleName, pInfo->pszModuleName, i ) == 0 && ( pInfo->pszModuleName[ i ] == '\0' || pInfo->pszModuleName[ i ] == ':' ) ) break; pInfo = pInfo->pNext; } if( ! pInfo ) { pInfo = ( PHB_DEBUGINFO ) hb_xgrab( sizeof( HB_DEBUGINFO ) ); pInfo->pszModuleName = hb_strndup( pszModuleName, i ); pInfo->ulFirstLine = pInfo->ulLastLine = ulLine; /* * allocate memory in 256 bytes chunks (for 2048 lines) * The last 1 byte is reserved for additional 0 byte if * the caller will want to use the returned buffer as * parameter to hb_compGenPushString(). [druzus] */ pInfo->ulAllocated = ( ( ulLine >> 3 ) + 0x100 ) & 0xFFFFFF00L; pInfo->pLineMap = ( HB_BYTE * ) hb_xgrab( pInfo->ulAllocated + 1 ); memset( pInfo->pLineMap, 0, pInfo->ulAllocated + 1 ); pInfo->pNext = pLineInfo; pLineInfo = pInfo; } } nOffset = ulLine >> 3; if( pInfo->ulAllocated <= nOffset ) { HB_ULONG ulNewSize = ( ( ulLine >> 3 ) + 0x100 ) & 0xFFFFFF00L; pInfo->pLineMap = ( HB_BYTE * ) hb_xrealloc( pInfo->pLineMap, ulNewSize + 1 ); memset( pInfo->pLineMap + pInfo->ulAllocated, 0, ulNewSize - pInfo->ulAllocated + 1 ); pInfo->ulAllocated = ulNewSize; } pInfo->pLineMap[ nOffset ] |= 1 << ( ulLine & 0x7 ); /* * It's possible the the line number will be ascending * if some external file is included more then once. [druzus] */ if( pInfo->ulFirstLine > ulLine ) pInfo->ulFirstLine = ulLine; if( pInfo->ulLastLine < ulLine ) pInfo->ulLastLine = ulLine; ulLine = 0; }
char * hb_osStrEncodeN( const char * pszName, HB_SIZE nLen ) { return hb_strndup( pszName, nLen ); }
static char * hb_compChkOptionDup( const char * szSwitch ) { return hb_strupr( hb_strndup( szSwitch, hb_compChkOptionLen( szSwitch, HB_TRUE ) ) ); }
void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, const char * const Args[] ) { /* If iArg is passed check the command line options */ if( iArg ) { int i; /* Check all switches in command line They start with an OS_OPT_DELIMITER char */ for( i = 1; i < iArg && ! HB_COMP_PARAM->fExit; i++ ) { const char * szSwitch = Args[ i ]; if( ! HB_ISOPTSEP( szSwitch[ 0 ] ) ) continue; if( szSwitch[ 0 ] == '-' ) { int j = 1; char Switch[ 7 ]; Switch[ 0 ] = '-'; while( szSwitch[ j ] && ! HB_COMP_PARAM->fExit ) { Switch[ 1 ] = szSwitch[ j ]; if( szSwitch[ j + 1 ] == '-' ) { Switch[ 2 ] = '-'; Switch[ 3 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 2; continue; } else { switch( Switch[ 1 ] ) { case 'b': case 'B': if( ( szSwitch[ j + 1 ] == 'U' || szSwitch[ j + 1 ] == 'u' ) && ( szSwitch[ j + 2 ] == 'I' || szSwitch[ j + 2 ] == 'i' ) && ( szSwitch[ j + 3 ] == 'L' || szSwitch[ j + 3 ] == 'l' ) && ( szSwitch[ j + 4 ] == 'D' || szSwitch[ j + 4 ] == 'd' ) ) { Switch[ 2 ] = 'U'; Switch[ 3 ] = 'I'; Switch[ 4 ] = 'L'; Switch[ 5 ] = 'D'; Switch[ 6 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 5; continue; } else if( ! szSwitch[ j + 1 ] ) { Switch[ 2 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 1; continue; } break; case 'c': case 'C': if( ( szSwitch[ j + 1 ] == 'R' || szSwitch[ j + 1 ] == 'r' ) && ( szSwitch[ j + 2 ] == 'E' || szSwitch[ j + 2 ] == 'e' ) && ( szSwitch[ j + 3 ] == 'D' || szSwitch[ j + 3 ] == 'd' ) ) { Switch[ 2 ] = 'R'; Switch[ 3 ] = 'E'; Switch[ 4 ] = 'D'; Switch[ 5 ] = '\0'; j += 4; if( szSwitch[ j ] == 'I' || szSwitch[ j ] == 'i' ) { j++; if( szSwitch[ j ] == 'T' || szSwitch[ j ] == 't' ) { j++; if( szSwitch[ j ] == 'S' || szSwitch[ j ] == 's' ) { j++; } } } hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); } else { Switch[ 2 ] = '\0'; hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL ); } continue; case 'd': case 'D': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as part of #define and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case 'e': case 'E': if( ( szSwitch[ j + 1 ] == 'S' || szSwitch[ j + 1 ] == 's' ) && HB_ISDIGIT( szSwitch[ j + 2 ] ) ) { Switch[ 2 ] = 'S'; Switch[ 3 ] = szSwitch[ j + 2 ]; Switch[ 4 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 3; } else { Switch[ 2 ] = '\0'; hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL ); } continue; case 'g': case 'G': if( szSwitch[ j + 1 ] == 'd' || szSwitch[ j + 1 ] == 'D' ) { szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); j = ( int ) strlen( szSwitch ); } else { /* Required argument */ Switch[ 2 ] = szSwitch[ j + 1 ]; if( Switch[ 2 ] ) { if( HB_ISDIGIT( szSwitch[ j + 2 ] ) ) { /* Optional argument */ Switch[ 3 ] = szSwitch[ j + 2 ]; Switch[ 4 ] = '\0'; j += 3; } else { /* No optional argument */ Switch[ 3 ] = '\0'; j += 2; } hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); } else hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL ); } continue; case 'i': case 'I': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as IncludePath and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case 'j': case 'J': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); j = ( int ) strlen( szSwitch ); continue; case 'k': case 'K': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as part of #define and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case 'n': case 'N': /* Required argument */ if( szSwitch[ j + 1 ] ) { /* Optional argument */ Switch[ 2 ] = szSwitch[ j + 1 ]; Switch[ 3 ] = '\0'; j += 2; } else { /* No optional argument */ Switch[ 2 ] = '\0'; j += 1; } hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); continue; case 'o': case 'O': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as OutputPath and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case 'p': case 'P': if( szSwitch[ j + 1 ] ) { szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as PPOPath and continue with next Args[]. */ j += ( int ) strlen( szSwitch ) - 1; } else { Switch[ 2 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j++; } continue; case 'q': case 'Q': if( HB_ISDIGIT( szSwitch[ j + 1 ] ) ) { Switch[ 2 ] = szSwitch[ j + 1 ]; Switch[ 3 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 2; continue; } else { Switch[ 2 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); } break; case 'r': case 'R': hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); j = ( int ) strlen( szSwitch ) - 1; break; case 's': case 'S': ++j; Switch[ 2 ] = Switch[ 3 ] = Switch[ 4 ] = '\0'; if( szSwitch[ j ] == 'm' || szSwitch[ j ] == 'M' ) { Switch[ 2 ] = szSwitch[ j++ ]; if( HB_ISDIGIT( szSwitch[ j ] ) || szSwitch[ j ] == '-' ) Switch[ 3 ] = szSwitch[ j++ ]; } hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); continue; case 'u': case 'U': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as part of .ch Path or "undef:<id>" and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case 'w': case 'W': if( HB_ISDIGIT( szSwitch[ j + 1 ] ) ) { Switch[ 2 ] = szSwitch[ j + 1 ]; Switch[ 3 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); j += 2; continue; } else { Switch[ 2 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); } break; case 'x': case 'X': szSwitch += ( j - 1 ); hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); /* Accept rest as INIT Symbol and continue with next Args[]. */ j = ( int ) strlen( szSwitch ); continue; case '-': { int l = ++j; while( szSwitch[ j ] && ! HB_ISOPTSEP( szSwitch[ j ] ) ) j++; if( szSwitch[ l - 1 ] == '-' && j - l == 7 && memcmp( &szSwitch[ l ], "version", 7 ) == 0 ) { HB_COMP_PARAM->fLogo = HB_TRUE; HB_COMP_PARAM->fQuiet = HB_TRUE; } else if( szSwitch[ l - 1 ] == '-' && j - l == 4 && memcmp( &szSwitch[ l ], "help", 4 ) == 0 ) { HB_COMP_PARAM->fLogo = HB_TRUE; HB_COMP_PARAM->fQuiet = HB_FALSE; HB_COMP_PARAM->fExit = HB_FALSE; } else hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, &szSwitch[ l ], NULL ); if( szSwitch[ j ] ) ++j; continue; } default: Switch[ 2 ] = '\0'; hb_compChkEnvironVar( HB_COMP_PARAM, Switch ); } } j++; } continue; } while( ! HB_COMP_PARAM->fExit ) { int j = 1; const char * szSwitch1 = szSwitch + j; /* hack to avoid what is seems a bug in 'Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)' / XCode 4.1 [vszakats] */ while( *szSwitch1 && ! HB_ISOPTSEP( *szSwitch1 ) ) { j++; szSwitch1++; } if( szSwitch[ j ] == '/' ) { char * szTmp = hb_strndup( szSwitch, j ); hb_compChkEnvironVar( HB_COMP_PARAM, szTmp ); hb_xfree( szTmp ); szSwitch += j; } else { hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); break; } } } } else /* Check the environment variables */ { /* NOTE: CLIPPERCMD enviroment variable is overriden if HARBOURCMD exists */ char * szStrEnv = hb_getenv( "HARBOURCMD" ); if( ! szStrEnv || szStrEnv[ 0 ] == '\0' ) { if( szStrEnv ) hb_xfree( szStrEnv ); szStrEnv = hb_getenv( "CLIPPERCMD" ); } if( szStrEnv ) { char * szSwitch, * szPtr; szPtr = szStrEnv; while( *szPtr && ! HB_COMP_PARAM->fExit ) { while( *szPtr == ' ' ) ++szPtr; szSwitch = szPtr; if( *szSwitch ) { while( *++szPtr ) { if( *szPtr == ' ' ) { *szPtr++ = '\0'; break; } } hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); } } hb_xfree( szStrEnv ); } } }