HB_BOOL hb_cmdargIsInternal( const char * szArg, int * piLen ) { HB_TRACE( HB_TR_DEBUG, ( "hb_cmdargIsInternal(%s, %p)", szArg, piLen ) ); /* NOTE: Not checking for '--' here, as it would filter out valid command-line options used by applications. [vszakats] */ if( hb_strnicmp( szArg, "--hb:", 5 ) == 0 || hb_strnicmp( szArg, "//hb:", 5 ) == 0 ) { if( piLen ) *piLen = 5; return HB_TRUE; } else if( strlen( szArg ) >= 2 && szArg[ 0 ] == '/' && szArg[ 1 ] == '/' ) { if( piLen ) *piLen = 2; return HB_TRUE; } return HB_FALSE; }
static int hb_gt_gui_optionId( const char * pszOption ) { if( pszOption ) { HB_SIZE nSize; int i; while( HB_ISSPACE( *pszOption ) ) pszOption++; nSize = strlen( pszOption ); while( nSize > 0 && HB_ISSPACE( pszOption[ nSize - 1 ] ) ) nSize--; if( nSize >= 2 && nSize <= 9 ) { for( i = 0; i < ( int ) _HB_BUTTON_COUNT; ++i ) { if( nSize == s_buttons[ i ].len && hb_strnicmp( s_buttons[ i ].name, pszOption, nSize ) == 0 ) { return s_buttons[ i ].id; } } } } return 0; }
static const char * s_findStringMimeType( const char * cData, HB_ISIZ nLen ) { int iCount; for( iCount = 0; iCount < MIME_TABLE_SIZE; iCount++ ) { const MIME_ENTRY * elem = s_mimeTable + iCount; HB_ISIZ nPos = elem->pos; HB_ISIZ nDataLen = strlen( elem->pattern ); if( ( elem->flags & MIME_FLAG_CONTINUE ) == MIME_FLAG_CONTINUE ) continue; /* trim spaces if required */ while( nPos < nLen && ( ( ( elem->flags & MIME_FLAG_TRIMSPACES ) == MIME_FLAG_TRIMSPACES && ( cData[ nPos ] == ' ' || cData[ nPos ] == '\r' || cData[ nPos ] == '\n' ) ) || ( ( elem->flags & MIME_FLAG_TRIMTABS ) == MIME_FLAG_TRIMSPACES && cData[ nPos ] == '\t' ) ) ) { nPos++; } if( nPos >= nLen ) continue; if( nLen - nPos < nDataLen ) continue; if( ( elem->flags & MIME_FLAG_CASEINSENS ) == MIME_FLAG_CASEINSENS ) { if( ( *elem->pattern == 0 && cData[ nPos ] == 0 ) || hb_strnicmp( cData + nPos, elem->pattern, nDataLen ) == 0 ) { /* is this the begin of a match tree? */ if( elem->next != 0 ) return s_findMimeStringInTree( cData, nLen, iCount + elem->next ); else return elem->mime_type; } } else { if( ( *elem->pattern == 0 && cData[ nPos ] == 0 ) || strncmp( cData + nPos, elem->pattern, nDataLen ) == 0 ) { if( elem->next != 0 ) return s_findMimeStringInTree( cData, nLen, iCount + elem->next ); else return elem->mime_type; } } } return NULL; }
static HB_BOOL hb_IsLegacyDevice( const char * pszPrinterName ) { static const char * s_pszPrnDev[] = { "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "com1", "com2", "com3", "com4", NULL }; int i; for( i = 0; s_pszPrnDev[ i ]; ++i ) { if( hb_strnicmp( pszPrinterName, s_pszPrnDev[ i ], strlen( s_pszPrnDev[ i ] ) ) == 0 ) return HB_TRUE; } return HB_FALSE; }
static const char * s_findMimeStringInTree( const char * cData, HB_ISIZ nLen, int iElem ) { const MIME_ENTRY * elem = s_mimeTable + iElem; HB_ISIZ nPos = elem->pos; HB_ISIZ nDataLen = strlen( elem->pattern ); /* allow \0 to be used for matches */ if( nDataLen == 0 ) nDataLen = 1; /* trim spaces if required */ while( nPos < nLen && ( ( ( elem->flags & MIME_FLAG_TRIMSPACES ) == MIME_FLAG_TRIMSPACES && ( cData[ nPos ] == ' ' || cData[ nPos ] == '\r' || cData[ nPos ] == '\n' ) ) || ( ( elem->flags & MIME_FLAG_TRIMTABS ) == MIME_FLAG_TRIMSPACES && cData[ nPos ] == '\t' ) ) ) { nPos++; } if( ( nPos < nLen ) && ( nLen - nPos >= nDataLen ) ) { if( ( elem->flags & MIME_FLAG_CASEINSENS ) == MIME_FLAG_CASEINSENS ) { if( ( *elem->pattern == 0 && cData[ nPos ] == 0 ) || hb_strnicmp( cData + nPos, elem->pattern, nDataLen ) == 0 ) { /* is this the begin of a match tree? */ if( elem->next != 0 ) return s_findMimeStringInTree( cData, nLen, iElem + elem->next ); else return elem->mime_type; } } else { if( ( *elem->pattern == 0 && cData[ nPos ] == 0 ) || strncmp( cData + nPos, elem->pattern, nDataLen ) == 0 ) { if( elem->next != 0 ) return s_findMimeStringInTree( cData, nLen, iElem + elem->next ); else return elem->mime_type; } } } /* match failed! */ if( elem->alternate != 0 ) return s_findMimeStringInTree( cData, nLen, iElem + elem->alternate ); return NULL; /* total giveup */ }
static int hb_i18n_pluralformfind( const char * szLang ) { int i; for( i = 0; i < ( int ) HB_PLURAL_FOMRS_COUNT; ++i ) { if( hb_stricmp( szLang, s_plural_forms[ i ].szLangID ) == 0 ) return s_plural_forms[ i ].iForm; } if( strlen( szLang ) > 2 ) { for( i = 0; i < ( int ) HB_PLURAL_FOMRS_COUNT; ++i ) { if( hb_strnicmp( szLang, s_plural_forms[ i ].szLangID, 2 ) == 0 ) return s_plural_forms[ i ].iForm; } } return 0; }
static HB_BOOL s_fileAccept( PHB_FILE_FUNCS pFuncs, const char * pszFileName ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; HB_BOOL fResult = HB_FALSE; if( hb_strnicmp( pszFileName, pIO->prefix, pIO->prefix_len ) == 0 ) { if( s_hasMethod( pIO, IOUSR_ACCEPT ) ) { s_pushMethod( pIO, IOUSR_ACCEPT ); hb_vmPushString( pszFileName, strlen( pszFileName ) ); hb_vmDo( 1 ); fResult = hb_parl( -1 ); } else if( pIO->prefix_len > 0 ) fResult = HB_TRUE; } return fResult; }
static HB_BOOL s_fileAccept( PHB_FILE_FUNCS pFuncs, const char * pszFileName ) { HB_SYMBOL_UNUSED( pFuncs ); return hb_strnicmp( pszFileName, FILE_PREFIX, FILE_PREFIX_LEN ) == 0; }
/* * find a field expression index, this function strips _FIELD->, FIELD->, * alias-> prefixes */ HB_USHORT hb_rddFieldExpIndex( AREAP pArea, const char * szField ) { int n; while( HB_ISSPACE( *szField ) ) ++szField; if( strchr( szField, '>' ) != NULL ) { char szAlias[ HB_RDD_MAX_ALIAS_LEN + 1 ]; int i, j, l; n = 0; if( SELF_ALIAS( pArea, szAlias ) == HB_SUCCESS ) l = ( int ) strlen( szAlias ); else l = 0; /* * strip the _FIELD-> and FIELD-> prefix, it could be nested * so repeat this process until all prefixes will be removed */ do { j = n; i = 0; if( HB_ISFIRSTIDCHAR( szField[ n ] ) ) { ++i; while( HB_ISNEXTIDCHAR( szField[ n + i ] ) ) ++i; if( ! ( ( i == l && hb_strnicmp( &szField[ n ], szAlias, l ) == 0 ) ) && ! ( i >= 4 && i <= 5 && hb_strnicmp( &szField[ n ], "FIELD", i ) == 0 ) && ! ( i >= 4 && i <= 6 && hb_strnicmp( &szField[ n ], "_FIELD", i ) == 0 ) ) { i = 0; } } if( i > 0 ) { i += n; while( HB_ISSPACE( szField[ i ] ) ) i++; if( szField[ i ] == '-' && szField[ i + 1 ] == '>' ) { n = i + 2; while( szField[ n ] == ' ' ) n++; } } } while( n != j ); szField = &szField[ n ]; } return hb_rddFieldIndex( pArea, szField ); }
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; }
static const char * hb_compChkParseSwitch( HB_COMP_DECL, const char * szSwitch, HB_BOOL fEnv ) { const char * szSwPtr = szSwitch; if( szSwPtr[ 0 ] == '-' && szSwPtr[ 1 ] == '-' ) { if( strncmp( szSwPtr + 2, "version", 7 ) == 0 ) { szSwPtr += 9; HB_COMP_PARAM->fLogo = HB_TRUE; HB_COMP_PARAM->fQuiet = HB_TRUE; } else if( strncmp( szSwPtr + 2, "help", 4 ) == 0 ) { szSwPtr += 6; HB_COMP_PARAM->fLogo = HB_TRUE; HB_COMP_PARAM->fQuiet = HB_FALSE; HB_COMP_PARAM->fExit = HB_FALSE; } } else if( HB_ISOPTSEP( *szSwPtr ) ) { ++szSwPtr; switch( HB_TOUPPER( *szSwPtr ) ) { case 'A': ++szSwPtr; if( *szSwPtr == '-' ) { ++szSwPtr; HB_COMP_PARAM->fAutoMemvarAssume = HB_FALSE; } else HB_COMP_PARAM->fAutoMemvarAssume = HB_TRUE; break; case 'B': { char *szOption = hb_compChkOptionDup( szSwPtr ); if( strcmp( szOption, "BUILD" ) == 0 ) { HB_COMP_PARAM->fBuildInfo = HB_TRUE; szSwPtr += 5; } else if( szSwPtr[ 1 ] == '-' ) { HB_COMP_PARAM->fDebugInfo = HB_FALSE; szSwPtr += 2; } else { HB_COMP_PARAM->fDebugInfo = HB_TRUE; HB_COMP_PARAM->fLineNumbers = HB_TRUE; ++szSwPtr; } hb_xfree( szOption ); break; } case 'C': { char *szOption = hb_compChkOptionDup( szSwPtr ); if( strlen( szOption ) >= 4 && strncmp( "CREDITS", szOption, strlen( szOption ) ) == 0 ) { HB_COMP_PARAM->fCredits = HB_TRUE; szSwPtr += strlen( szOption ); } hb_xfree( szOption ); break; } case 'D': szSwPtr = hb_compChkAddDefine( HB_COMP_PARAM, szSwPtr + 1, HB_TRUE, fEnv ); break; case 'E': if( HB_TOUPPER( szSwPtr[ 1 ] ) == 'S' ) { switch( szSwPtr[ 2 ] ) { case '1': szSwPtr += 3; HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_SETEXIT; break; case '2': szSwPtr += 3; HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DELTARGET; break; case '0': ++szSwPtr; /* no break; */ default: szSwPtr += 2; HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DEFAULT; break; } } break; case 'F': switch( HB_TOUPPER( szSwPtr[ 1 ] ) ) { case 'N': if( szSwPtr[ 2 ] == ':' ) { if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'U' ) { szSwPtr += 4; hb_setSetFileCase( HB_SET_CASE_UPPER ); } else if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'L' ) { szSwPtr += 4; hb_setSetFileCase( HB_SET_CASE_LOWER ); } } else { szSwPtr += 2; if( *szSwPtr == '-' ) ++szSwPtr; hb_setSetFileCase( HB_SET_CASE_MIXED ); } break; case 'D': if( szSwPtr[ 2 ] == ':' ) { if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'U' ) { szSwPtr += 4; hb_setSetDirCase( HB_SET_CASE_UPPER ); } else if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'L' ) { szSwPtr += 4; hb_setSetDirCase( HB_SET_CASE_LOWER ); } } else { szSwPtr += 2; if( *szSwPtr == '-' ) ++szSwPtr; hb_setSetDirCase( HB_SET_CASE_MIXED ); } break; case 'P': szSwPtr += 2; if( *szSwPtr == ':' ) { if( szSwPtr[ 1 ] && szSwPtr[ 1 ] != ' ' ) { hb_setSetDirSeparator( szSwPtr[ 1 ] ); szSwPtr += 2; } } else { if( *szSwPtr == '-' ) ++szSwPtr; hb_setSetDirSeparator( HB_OS_PATH_DELIM_CHR ); } break; case 'S': szSwPtr += 2; if( *szSwPtr == '-' ) { ++szSwPtr; hb_setSetTrimFileName( HB_FALSE ); } else hb_setSetTrimFileName( HB_TRUE ); } break; case 'G': switch( HB_TOUPPER( szSwPtr[ 1 ] ) ) { case 'C': HB_COMP_PARAM->iLanguage = HB_LANG_C; szSwPtr += 2; switch( *szSwPtr ) { case '1': ++szSwPtr; HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_NORMAL; break; case '2': ++szSwPtr; HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_VERBOSE; break; case '3': ++szSwPtr; HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_REALCODE; break; case '0': ++szSwPtr; /* no break; */ default: HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_COMPACT; break; } break; case 'H': HB_COMP_PARAM->iLanguage = HB_LANG_PORT_OBJ; szSwPtr += 2; break; case 'D': if( HB_COMP_PARAM->szDepExt ) { hb_xfree( HB_COMP_PARAM->szDepExt ); HB_COMP_PARAM->szDepExt = NULL; } szSwPtr += 2; if( *szSwPtr == '-' ) { HB_COMP_PARAM->iTraceInclude = 0; ++szSwPtr; } else { HB_COMP_PARAM->iTraceInclude = 2; if( *szSwPtr == '.' ) szSwPtr = hb_compChkOptionGet( szSwPtr, &HB_COMP_PARAM->szDepExt, fEnv ); } break; case 'E': szSwPtr += 2; switch( *szSwPtr ) { case '1': ++szSwPtr; HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_IDE; break; case '0': ++szSwPtr; /* no break; */ default: HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_CLIPPER; break; } break; default: hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_UNSUPPORTED_LANG, NULL, NULL ); break; } break; case 'H': case '?': /* HELP message */ break; case 'I': ++szSwPtr; switch( *szSwPtr ) { case '-': HB_COMP_PARAM->fINCLUDE = HB_FALSE; ++szSwPtr; break; case '+': HB_COMP_PARAM->fINCLUDE = HB_TRUE; ++szSwPtr; break; default: szSwPtr = hb_compChkOptionAddPath( HB_COMP_PARAM, szSwPtr, fEnv ); } break; case 'J': ++szSwPtr; HB_COMP_PARAM->fI18n = HB_TRUE; if( *szSwPtr ) szSwPtr = hb_compChkOptionFName( szSwPtr, &HB_COMP_PARAM->pI18nFileName, fEnv ); break; case 'K': ++szSwPtr; while( *szSwPtr && ! HB_COMP_PARAM->fExit ) { int ch = HB_TOUPPER( *szSwPtr ); ++szSwPtr; switch( ch ) { case '?': hb_compPrintLogo( HB_COMP_PARAM ); hb_compPrintModes( HB_COMP_PARAM ); HB_COMP_PARAM->fLogo = HB_FALSE; HB_COMP_PARAM->fQuiet = HB_TRUE; break; case 'H': /* default Harbour mode */ if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HARBOUR; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_HARBOUR; break; case 'C': /* clear all flags - minimal set of features */ HB_COMP_PARAM->supported &= HB_COMPFLAG_SHORTCUTS; HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP | HB_COMPFLAG_MACROTEXT; break; case 'X': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_XBASE; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_XBASE; break; case 'I': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HB_INLINE; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_HB_INLINE; break; case 'J': if( *szSwPtr == '+' ) { HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP; ++szSwPtr; } else HB_COMP_PARAM->supported &= ~HB_COMPFLAG_OPTJUMP; break; case 'M': if( *szSwPtr == '+' ) { HB_COMP_PARAM->supported |= HB_COMPFLAG_MACROTEXT; ++szSwPtr; } else HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACROTEXT; break; case 'D': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACRODECL; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_MACRODECL; break; case 'R': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_RT_MACRO; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_RT_MACRO; break; case 'S': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_ARRSTR; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_ARRSTR; break; case 'O': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_EXTOPT; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_EXTOPT; break; case 'U': if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported &= ~HB_COMPFLAG_USERCP; ++szSwPtr; } else HB_COMP_PARAM->supported |= HB_COMPFLAG_USERCP; break; default: ch = -1; --szSwPtr; } if( ch == -1 ) break; } break; case 'L': ++szSwPtr; if( *szSwPtr == '-' ) { HB_COMP_PARAM->fLineNumbers = HB_TRUE; ++szSwPtr; } else HB_COMP_PARAM->fLineNumbers = HB_FALSE; break; case 'M': ++szSwPtr; if( *szSwPtr == '-' ) { HB_COMP_PARAM->fSingleModule = HB_FALSE; ++szSwPtr; } else HB_COMP_PARAM->fSingleModule = HB_TRUE; break; case 'N': ++szSwPtr; HB_COMP_PARAM->fNoStartUp = *szSwPtr == '1'; switch( *szSwPtr ) { case '-': HB_COMP_PARAM->iStartProc = 0; ++szSwPtr; break; case '2': HB_COMP_PARAM->iStartProc = 2; ++szSwPtr; break; case '0': case '1': ++szSwPtr; /* no break; */ default: HB_COMP_PARAM->iStartProc = 1; break; } break; case 'O': szSwPtr = hb_compChkOptionFName( szSwPtr + 1, &HB_COMP_PARAM->pOutPath, fEnv ); break; case 'P': ++szSwPtr; if( *szSwPtr == '+' ) { HB_COMP_PARAM->fPPT = HB_TRUE; ++szSwPtr; } else { if( HB_COMP_PARAM->pPpoPath ) { hb_xfree( HB_COMP_PARAM->pPpoPath ); HB_COMP_PARAM->pPpoPath = NULL; } if( *szSwPtr == '-' ) { HB_COMP_PARAM->fPPT = HB_COMP_PARAM->fPPO = HB_FALSE; ++szSwPtr; } else { if( *szSwPtr ) szSwPtr = hb_compChkOptionFName( szSwPtr, &HB_COMP_PARAM->pPpoPath, fEnv ); HB_COMP_PARAM->fPPO = HB_TRUE; } } break; case 'Q': ++szSwPtr; switch( *szSwPtr ) { case 'l': case 'L': HB_COMP_PARAM->fGauge = HB_FALSE; ++szSwPtr; break; case '2': HB_COMP_PARAM->fFullQuiet = HB_TRUE; /* no break */ case '0': HB_COMP_PARAM->fLogo = HB_FALSE; ++szSwPtr; /* no break */ default: HB_COMP_PARAM->fQuiet = HB_TRUE; } break; case 'R': ++szSwPtr; if( szSwPtr[ 0 ] == ':' ) { if( HB_ISDIGIT( szSwPtr[ 1 ] ) ) { int iCycles = 0; ++szSwPtr; while( HB_ISDIGIT( *szSwPtr ) ) iCycles = iCycles * 10 + *szSwPtr++ - '0'; if( iCycles > 0 ) HB_COMP_PARAM->iMaxTransCycles = iCycles; } } else { /* NOTE: ignored for Cl*pper compatibility: /r[<lib>] request linker to search <lib> (or none) */ hb_compChkIgnoredInfo( HB_COMP_PARAM, "-r[<lib>]" ); szSwPtr = hb_compChkOptionGet( szSwPtr, NULL, fEnv ); } break; case 'S': ++szSwPtr; switch( *szSwPtr ) { case '-': HB_COMP_PARAM->iSyntaxCheckOnly = 0; ++szSwPtr; break; case 'm': case 'M': HB_COMP_PARAM->iSyntaxCheckOnly = 2; ++szSwPtr; break; default: HB_COMP_PARAM->iSyntaxCheckOnly = 1; break; } break; case 'T': /* NOTE: ignored for Cl*pper compatibility: /t<path> path for temp file creation */ hb_compChkIgnoredInfo( HB_COMP_PARAM, "-t<path>" ); szSwPtr = hb_compChkOptionGet( szSwPtr + 1, NULL, fEnv ); break; case 'U': if( hb_strnicmp( szSwPtr, "UNDEF:", 6 ) == 0 ) { if( hb_strnicmp( szSwPtr + 6, ".ARCH.", 6 ) == 0 ) { HB_COMP_PARAM->fNoArchDefs = HB_TRUE; szSwPtr += 12; } else szSwPtr = hb_compChkAddDefine( HB_COMP_PARAM, szSwPtr + 6, HB_FALSE, fEnv ); break; } ++szSwPtr; /* extended definitions file: -u+<file> */ if( *szSwPtr == '+' ) { if( szSwPtr[ 1 ] && hb_compChkOptionLen( szSwPtr + 1, fEnv ) > 0 ) { HB_COMP_PARAM->szStdChExt = ( char ** ) ( HB_COMP_PARAM->iStdChExt == 0 ? hb_xgrab( sizeof( char * ) ) : hb_xrealloc( HB_COMP_PARAM->szStdChExt, ( HB_COMP_PARAM->iStdChExt + 1 ) * sizeof( char * ) ) ); szSwPtr = hb_compChkOptionGet( szSwPtr + 1, &HB_COMP_PARAM->szStdChExt[ HB_COMP_PARAM->iStdChExt++ ], fEnv ); } } else { if( HB_COMP_PARAM->szStdCh ) hb_xfree( HB_COMP_PARAM->szStdCh ); szSwPtr = hb_compChkOptionGet( szSwPtr, &HB_COMP_PARAM->szStdCh, fEnv ); } break; case 'V': ++szSwPtr; if( *szSwPtr == '-' ) { HB_COMP_PARAM->fForceMemvars = HB_FALSE; ++szSwPtr; } else HB_COMP_PARAM->fForceMemvars = HB_TRUE; break; case 'W': ++szSwPtr; HB_COMP_PARAM->iWarnings = 1; if( *szSwPtr >= '0' && *szSwPtr <= '3' ) { HB_COMP_PARAM->iWarnings = *szSwPtr - '0'; ++szSwPtr; } break; #ifdef YYDEBUG case 'Y': ++szSwPtr; extern int hb_comp_yydebug; hb_comp_yydebug = HB_TRUE; break; #endif case 'Z': ++szSwPtr; if( *szSwPtr == '-' ) { HB_COMP_PARAM->supported |= HB_COMPFLAG_SHORTCUTS; ++szSwPtr; } else HB_COMP_PARAM->supported &= ~HB_COMPFLAG_SHORTCUTS; break; } } if( ! HB_COMP_PARAM->fExit ) { if( szSwPtr - szSwitch <= 1 || ( *szSwPtr != '\0' && *szSwPtr != ' ' && ! HB_ISOPTSEP( *szSwPtr ) ) ) hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', fEnv ? HB_COMP_ERR_BADOPTION : HB_COMP_ERR_BADPARAM, szSwitch, NULL ); else return szSwPtr; } return ""; }
static char * hb_cmdargGet( const char * pszName, HB_BOOL bRetValue ) { char * pszRetVal = NULL; char * pszEnvVar; int i; int iPrefixLen; HB_TRACE( HB_TR_DEBUG, ( "hb_cmdargGet(%s, %d)", pszName, ( int ) bRetValue ) ); /* Check the command-line first */ for( i = 1; i < s_argc; i++ ) { if( hb_cmdargIsInternal( s_argv[ i ], &iPrefixLen ) && hb_strnicmp( s_argv[ i ] + iPrefixLen, pszName, strlen( pszName ) ) == 0 ) { if( bRetValue ) { #if defined( HB_OS_WIN ) if( s_lpArgV ) { LPCTSTR lpPos = s_lpArgV[ i ] + iPrefixLen + strlen( pszName ); if( *lpPos == TEXT( ':' ) ) lpPos++; return HB_OSSTRDUP( lpPos ); } else #endif { char * pszPos = s_argv[ i ] + iPrefixLen + strlen( pszName ); if( *pszPos == ':' ) pszPos++; return hb_osStrDecode( pszPos ); } } else return ( char * ) ""; } } /* Check the environment variable */ pszEnvVar = hb_getenv( "HARBOUR" ); if( ! pszEnvVar || pszEnvVar[ 0 ] == '\0' ) { if( pszEnvVar ) hb_xfree( pszEnvVar ); #ifdef HB_CLP_STRICT pszEnvVar = hb_getenv( "CLIPPER" ); #else pszEnvVar = NULL; #endif } if( pszEnvVar && pszEnvVar[ 0 ] != '\0' ) { char * pszNext = pszEnvVar; /* Step through all envvar switches. */ /* NOTE: CA-Cl*pper doesn't need the switches to be separated by any chars at all, Harbour is more strict/standard in this respect, it requires the switches to be separated. */ i = ( int ) strlen( pszName ); while( *pszNext ) { static const char * s_szSeparator = " ;,\t"; char * pszEnd; /* Skip the separators */ while( *pszNext && strchr( s_szSeparator, *pszNext ) ) pszNext++; /* The // is optional in the envvar */ if( hb_cmdargIsInternal( pszNext, &iPrefixLen ) ) pszNext += iPrefixLen; pszEnd = pszNext; /* Search for the end of this switch */ while( *pszEnd && strchr( s_szSeparator, *pszEnd ) == NULL ) pszEnd++; /* Check the switch */ if( hb_strnicmp( pszNext, pszName, i ) == 0 ) { if( bRetValue ) { HB_SIZE nLen; pszNext += i; /* Skip value separator colon. */ if( *pszNext == ':' ) pszNext++; nLen = pszEnd > pszNext ? pszEnd - pszNext : 0; pszRetVal = ( char * ) hb_xgrab( nLen + 1 ); hb_strncpy( pszRetVal, pszNext, nLen ); } else pszRetVal = ( char * ) ""; break; } /* Step to the next switch */ pszNext = pszEnd; } } if( pszEnvVar ) hb_xfree( pszEnvVar ); return pszRetVal; }
static HB_BOOL hb_pp_CompilerSwitch( void * cargo, const char * szSwitch, int * piValue, HB_BOOL fSet ) { HB_COMP_DECL = ( PHB_COMP ) cargo; HB_BOOL fError = HB_FALSE; int iValue, i; iValue = *piValue; i = ( int ) strlen( szSwitch ); if( i > 1 && ( ( int ) ( szSwitch[ i - 1 ] - '0' ) ) == iValue ) --i; if( i == 1 ) { switch( szSwitch[ 0 ] ) { case 'a': case 'A': if( fSet ) HB_COMP_PARAM->fAutoMemvarAssume = iValue != 0; else iValue = HB_COMP_PARAM->fAutoMemvarAssume ? 1 : 0; break; case 'b': case 'B': if( fSet ) HB_COMP_PARAM->fDebugInfo = iValue != 0; else iValue = HB_COMP_PARAM->fDebugInfo ? 1 : 0; break; case 'j': case 'J': if( fSet ) HB_COMP_PARAM->fI18n = iValue != 0; else iValue = HB_COMP_PARAM->fI18n ? 1 : 0; break; case 'l': case 'L': if( fSet ) HB_COMP_PARAM->fLineNumbers = iValue != 0; else iValue = HB_COMP_PARAM->fLineNumbers ? 1 : 0; break; case 'n': case 'N': if( fSet ) fError = HB_TRUE; else iValue = HB_COMP_PARAM->iStartProc; break; case 'p': case 'P': if( fSet ) HB_COMP_PARAM->fPPO = iValue != 0; else iValue = HB_COMP_PARAM->fPPO ? 1 : 0; break; case 'q': case 'Q': if( fSet ) HB_COMP_PARAM->fQuiet = iValue != 0; else iValue = HB_COMP_PARAM->fQuiet ? 1 : 0; break; case 'v': case 'V': if( fSet ) HB_COMP_PARAM->fForceMemvars = iValue != 0; else iValue = HB_COMP_PARAM->fForceMemvars ? 1 : 0; break; case 'w': case 'W': if( fSet ) { if( iValue >= 0 && iValue <= 3 ) HB_COMP_PARAM->iWarnings = iValue; else fError = HB_TRUE; } else iValue = HB_COMP_PARAM->iWarnings; break; case 'z': case 'Z': if( fSet ) { if( iValue ) HB_COMP_PARAM->supported &= ~HB_COMPFLAG_SHORTCUTS; else HB_COMP_PARAM->supported |= HB_COMPFLAG_SHORTCUTS; } else iValue = ( HB_COMP_PARAM->supported & HB_COMPFLAG_SHORTCUTS ) ? 0 : 1; break; default: fError = HB_TRUE; } } else if( i == 2 ) { if( szSwitch[ 0 ] == 'k' || szSwitch[ 0 ] == 'K' ) { int iFlag = 0; /* -k? parameters are case sensitive */ switch( szSwitch[ 1 ] ) { case '?': if( fSet ) HB_COMP_PARAM->supported = iValue; else iValue = HB_COMP_PARAM->supported; break; case 'c': case 'C': if( fSet ) { /* clear all flags - minimal set of features */ HB_COMP_PARAM->supported &= HB_COMPFLAG_SHORTCUTS; HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP | HB_COMPFLAG_MACROTEXT; } else { iValue = ( HB_COMP_PARAM->supported & ~HB_COMPFLAG_SHORTCUTS ) == ( HB_COMPFLAG_OPTJUMP | HB_COMPFLAG_MACROTEXT ) ? 1 : 0; } break; case 'h': case 'H': iFlag = HB_COMPFLAG_HARBOUR; break; case 'o': case 'O': iFlag = HB_COMPFLAG_EXTOPT; break; case 'i': case 'I': iFlag = HB_COMPFLAG_HB_INLINE; break; case 'r': case 'R': iFlag = HB_COMPFLAG_RT_MACRO; break; case 'x': case 'X': iFlag = HB_COMPFLAG_XBASE; break; case 'j': case 'J': iFlag = HB_COMPFLAG_OPTJUMP; iValue = ! iValue; break; case 'm': case 'M': iFlag = HB_COMPFLAG_MACROTEXT; iValue = ! iValue; break; case 'd': case 'D': iFlag = HB_COMPFLAG_MACRODECL; break; case 's': case 'S': iFlag = HB_COMPFLAG_ARRSTR; break; default: fError = HB_TRUE; } if( ! fError && iFlag ) { if( fSet ) { if( iValue ) HB_COMP_PARAM->supported |= iFlag; else HB_COMP_PARAM->supported &= ~iFlag; } else { if( iValue ) iValue = HB_COMP_PARAM->supported & iFlag ? 0 : 1; else iValue = HB_COMP_PARAM->supported & iFlag ? 1 : 0; } } } else if( hb_strnicmp( szSwitch, "es", 2 ) == 0 ) { if( fSet ) { if( iValue == HB_EXITLEVEL_DEFAULT || iValue == HB_EXITLEVEL_SETEXIT || iValue == HB_EXITLEVEL_DELTARGET ) HB_COMP_PARAM->iExitLevel = iValue; } else iValue = HB_COMP_PARAM->iExitLevel; } else if( hb_stricmp( szSwitch, "p+" ) == 0 ) { if( fSet ) HB_COMP_PARAM->fPPT = iValue != 0; else iValue = HB_COMP_PARAM->fPPT ? 1 : 0; } else fError = HB_TRUE; } /* xHarbour extension */ else if( i >= 4 && hb_strnicmp( szSwitch, "TEXTHIDDEN", i ) == 0 ) { if( fSet ) { if( iValue >= 0 && iValue <= 1 ) HB_COMP_PARAM->iHidden = iValue; } else iValue = HB_COMP_PARAM->iHidden; } else fError = HB_TRUE; *piValue = iValue; return fError; }
HB_BOOL hb_printerIsReady( const char * pszPrinterName ) { HB_BOOL bIsPrinter; #if defined( HB_OS_DOS ) /* NOTE: MS-DOS specific solution, using BIOS interrupt */ { int iPort; if( pszPrinterName == NULL ) pszPrinterName = "LPT1"; if( hb_strnicmp( pszPrinterName, "PRN", 3 ) == 0 ) { union REGS regs; regs.h.ah = 2; regs.HB_XREGS.dx = 0; /* LPT1 */ HB_DOS_INT86( 0x17, ®s, ®s ); bIsPrinter = ( regs.h.ah == 0x90 ); } else if( strlen( pszPrinterName ) >= 4 && hb_strnicmp( pszPrinterName, "LPT", 3 ) == 0 && ( iPort = atoi( pszPrinterName + 3 ) ) > 0 ) { union REGS regs; regs.h.ah = 2; regs.HB_XREGS.dx = iPort - 1; HB_DOS_INT86( 0x17, ®s, ®s ); bIsPrinter = ( regs.h.ah == 0x90 ); } else bIsPrinter = HB_FALSE; } #else /* NOTE: Platform independent method, at least it will compile and run on any platform, but the result may not be the expected one, since Unix/Linux doesn't support LPT/COM by nature, other OSs may not reflect the actual physical presence of the printer when trying to open it, since we are talking to the spooler. [vszakats] */ { HB_FHANDLE fhnd; if( pszPrinterName == NULL ) #if defined( HB_OS_UNIX ) pszPrinterName = "/dev/lp0"; #else pszPrinterName = "LPT1"; #endif fhnd = hb_fsOpen( pszPrinterName, FO_WRITE | FO_SHARED | FO_PRIVATE ); bIsPrinter = ( fhnd != FS_ERROR ); hb_fsClose( fhnd ); } #endif return bIsPrinter; }
static char *s_findStringMimeType( char *cData, int iLen ) { int iCount; BOOL bFormFeed; for ( iCount = 0; iCount < MIME_TABLE_SIZE; iCount ++ ) { MIME_ENTRY *elem = s_mimeTable + iCount; int iPos = elem->pos; int iDataLen = strlen( elem->pattern ); if ( (elem->flags & MIME_FLAG_CONTINUE) == MIME_FLAG_CONTINUE ) { continue; } /* trim spaces if required */ while ( iPos < iLen && ( (( elem->flags & MIME_FLAG_TRIMSPACES ) == MIME_FLAG_TRIMSPACES && ( cData[iPos] == ' ' || cData[iPos] == '\r' || cData[iPos] == '\n') ) || (( elem->flags & MIME_FLAG_TRIMTABS ) == MIME_FLAG_TRIMSPACES && cData[iPos] == '\t') ) ) { iPos ++; } if ( iPos >= iLen ) { continue; } if ( iLen - iPos < iDataLen ) { continue; } if ( (elem->flags & MIME_FLAG_CASEINSENS) == MIME_FLAG_CASEINSENS ) { if ( (*elem->pattern == 0 && cData[iPos] == 0) || hb_strnicmp( cData + iPos, elem->pattern, iDataLen ) == 0) { /* is this the begin of a match tree? */ if ( elem->next != 0 ) { return s_findMimeStringInTree( cData, iLen, iCount + elem->next ); } else { return elem->mime_type; } } } else { if ( (*elem->pattern == 0 && cData[iPos] == 0) || strncmp( cData + iPos, elem->pattern, iDataLen ) == 0) { if ( elem->next != 0 ) { return s_findMimeStringInTree( cData, iLen, iCount + elem->next ); } else { return elem->mime_type; } } } } /* Failure; let's see if it's a text/plain. */ bFormFeed = FALSE; iCount = 0; while ( iCount < iLen ) { /* form feed? */ if ( cData[ iCount ] == '\x0C' ) { bFormFeed = TRUE; } /* esc sequence? */ else if ( cData[iCount] == '\x1B' ) { bFormFeed = TRUE; iCount ++; if ( cData[iCount] <= 27 ) { iCount ++; } if ( cData[iCount] <= 27 ) { iCount ++; } } else if ( (cData[iCount] < 27 && cData[iCount] != '\t' && cData[iCount] != '\n' && cData[iCount] == '\r') || cData[iCount] == '\xFF') { /* not an ASCII file, we surrender */ return NULL; } iCount++; } if ( bFormFeed ) { /* we have escape sequences, seems a PRN/terminal file */ return "application/remote-printing"; } return "text/plain"; }
static char *s_findMimeStringInTree( char *cData, int iLen, int iElem ) { MIME_ENTRY *elem = s_mimeTable + iElem; int iPos = elem->pos; int iDataLen = strlen( elem->pattern ); /* allow \0 to be used for matches */ if ( iDataLen == 0 ) { iDataLen = 1; } /* trim spaces if required */ while ( iPos < iLen && ( (( elem->flags & MIME_FLAG_TRIMSPACES ) == MIME_FLAG_TRIMSPACES && ( cData[iPos] == ' ' || cData[iPos] == '\r' || cData[iPos] == '\n') ) || (( elem->flags & MIME_FLAG_TRIMTABS ) == MIME_FLAG_TRIMSPACES && cData[iPos] == '\t') ) ) { iPos ++; } if ( (iPos < iLen) && (iLen - iPos >= iDataLen) ) { if ( (elem->flags & MIME_FLAG_CASEINSENS) == MIME_FLAG_CASEINSENS ) { if ( (*elem->pattern == 0 && cData[iPos] == 0) || hb_strnicmp( cData + iPos, elem->pattern, iDataLen ) == 0) { /* is this the begin of a match tree? */ if ( elem->next != 0 ) { return s_findMimeStringInTree( cData, iLen, iElem + elem->next ); } else { return elem->mime_type; } } } else { if ( (*elem->pattern == 0 && cData[iPos] == 0) || strncmp( cData + iPos, elem->pattern, iDataLen ) == 0) { if ( elem->next != 0 ) { return s_findMimeStringInTree( cData, iLen, iElem + elem->next ); } else { return elem->mime_type; } } } } /* match failed! */ if ( elem->alternate != 0 ) { return s_findMimeStringInTree( cData, iLen, iElem + elem->alternate ); } /* total giveup */ return NULL; }