Beispiel #1
0
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;
}
Beispiel #2
0
void hb_compChkAddIncPaths( HB_COMP_DECL )
{
   char * szInclude = hb_getenv( "INCLUDE" );

   if( szInclude )
   {
      if( szInclude[ 0 ] != '\0' )
         hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, szInclude, HB_FALSE );
      hb_xfree( szInclude );
   }
}
Beispiel #3
0
int main( int argc, char * argv[] )
{
   char *         szFile         = NULL, * szRuleFile = NULL, * szWordFile = NULL, * szVerFile = NULL;
   char *         szLogFile      = NULL;
   BOOL           fQuiet         = FALSE, fWrite = FALSE, fChgLog = FALSE;
   char *         szChangeLogID  = NULL, * szLastEntry = NULL;
   int            iResult        = 0, i;
   PHB_PP_STATE   pState;

   pState = hb_pp_new();

   if( argc >= 2 )
   {
      szFile = argv[ 1 ];
      for( i = 2; szFile && i < argc; i++ )
      {
         if( ! HB_ISOPTSEP( argv[ i ][ 0 ] ) )
            szFile = NULL;
         else
         {
            switch( argv[ i ][ 1 ] )
            {
               case 'q':
               case 'Q':
                  if( argv[ i ][ 2 ] )
                     szFile = NULL;
                  else
                     fQuiet = TRUE;
                  break;

               case 'w':
               case 'W':
                  if( argv[ i ][ 2 ] )
                     szFile = NULL;
                  else
                     fWrite = TRUE;
                  break;

               case 'c':
               case 'C':
                  fChgLog = TRUE;
                  if( argv[ i ][ 2 ] )
                     szLogFile = argv[ i ] + 2;
                  break;

               case 'i':
               case 'I':
                  if( argv[ i ][ 2 ] )
                     hb_pp_addSearchPath( pState, argv[ i ] + 2, FALSE );
                  else
                     szFile = NULL;
                  break;

               case 'o':
               case 'O':
                  if( argv[ i ][ 2 ] )
                     szRuleFile = argv[ i ] + 2;
                  else
                     szFile = NULL;
                  break;

               case 'x':
               case 'X':
                  if( argv[ i ][ 2 ] )
                     szWordFile = argv[ i ] + 2;
                  else
                     szWordFile = NULL;
                  break;

               case 'v':
               case 'V':
                  if( argv[ i ][ 2 ] )
                     szVerFile = argv[ i ] + 2;
                  else
                     szFile = NULL;
                  break;

               default:
                  szFile = NULL;
                  break;
            }
         }
      }
   }

   if( szFile )
   {
      hb_pp_init( pState, fQuiet, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );
      if( hb_pp_inFile( pState, szFile, TRUE, NULL, TRUE ) )
      {
         char * szSVNID = ( char * ) hb_xgrab( 10 );
         char * szSVNDateID = ( char * ) hb_xgrab( 10 );
         if( fWrite )
         {
            char        szFileName[ HB_PATH_MAX ];
            PHB_FNAME   pFileName;

            pFileName               = hb_fsFNameSplit( szFile );
            pFileName->szExtension  = ".ppo";
            hb_fsFNameMerge( szFileName, pFileName );
            hb_xfree( pFileName );

            hb_pp_outFile( pState, szFileName, NULL );
         }

         if( fChgLog )
            iResult = hb_pp_parseChangelog( pState, szLogFile, fQuiet,
                                            szSVNID, szSVNDateID, &szChangeLogID, &szLastEntry );

         if( iResult == 0 )
            iResult = hb_pp_preprocesfile( pState, szRuleFile, szWordFile );

         if( iResult == 0 && szVerFile )
            iResult = hb_pp_generateVerInfo( szVerFile, szSVNID, szSVNDateID,
                                             szChangeLogID, szLastEntry );

         hb_xfree( szSVNID );
         hb_xfree( szSVNDateID );
      }
      else
         iResult = 1;
   }
   else
   {
      hb_pp_usage( argv[ 0 ] );
      iResult = 1;
   }

   if( szChangeLogID )
      hb_xfree( szChangeLogID );
   if( szLastEntry )
      hb_xfree( szLastEntry );

   hb_pp_free( pState );

   return iResult;
}
Beispiel #4
0
static void hb_compChkEnvironVar( HB_COMP_DECL, const char * szSwitch )
{
   if( szSwitch && ! HB_COMP_PARAM->fExit )
   {
      const char * s = szSwitch;

      /* If szSwitch doesn't start with a HB_OSOPTSEP char
       * show an error
       */
      if( ! HB_ISOPTSEP( *s ) )
         hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
      else
      {
         s++;
         switch( *s )
         {
            case 'a':
            case 'A':
               if( *( s + 1 ) == '-' )
                  HB_COMP_PARAM->fAutoMemvarAssume = HB_FALSE;
               else
                  HB_COMP_PARAM->fAutoMemvarAssume = HB_TRUE;
               break;

            case 'b':
            case 'B':
            {
               unsigned int i = 0;
               char *szOption = hb_strupr( hb_strdup( s ) );

               while( i < strlen( szOption ) && ! HB_ISOPTSEP( szOption[ i ] ) )
                  i++;
               szOption[ i ] = '\0';

               if( strcmp( szOption, "BUILD" ) == 0 )
                  HB_COMP_PARAM->fBuildInfo = HB_TRUE;
               else
               {
                  if( *( s + 1 ) == '-' )
                     HB_COMP_PARAM->fDebugInfo = HB_FALSE;
                  else
                  {
                     HB_COMP_PARAM->fDebugInfo = HB_TRUE;
                     HB_COMP_PARAM->fLineNumbers = HB_TRUE;
                  }
               }

               hb_xfree( szOption );
               break;
            }

            case 'c':
            case 'C':
            {
               unsigned int i = 0;
               char *szOption = hb_strupr( hb_strdup( s ) );

               while( i < strlen( szOption ) && ! HB_ISOPTSEP( szOption[ i ] ) )
                  i++;
               szOption[ i ] = '\0';

               if( strcmp( szOption, "CREDITS" ) == 0 ||
                   strcmp( szOption, "CREDIT" ) == 0 ||
                   strcmp( szOption, "CREDI" ) == 0 ||
                   strcmp( szOption, "CRED" ) == 0 )
                  HB_COMP_PARAM->fCredits = HB_TRUE;
               else
                  hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, szOption, NULL );

               hb_xfree( szOption );
               break;
            }

            case 'd':
            case 'D':
               /* NOTE: Ignore these -d switches will be processed separately */
               break;

            case 'e':
            case 'E':
               if( *( s + 1 ) == 's' || *( s + 1 ) == 'S' )
               {
                  switch( *( s + 2 ) )
                  {
                     case '\0':
                     case '0':
                        HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DEFAULT;
                        break;

                     case '1':
                        HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_SETEXIT;
                        break;

                     case '2':
                        HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DELTARGET;
                        break;

                     default:
                        hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
                  }
               }
               else
                  hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );

               break;

            case 'g':
            case 'G':
               switch( *( s + 1 ) )
               {
                  case 'c':
                  case 'C':
                     HB_COMP_PARAM->iLanguage = HB_LANG_C;

                     switch( *( s + 2 ) )
                     {
                        case '3':
                           HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_REALCODE;
                           break;

                        case '2':
                           HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_VERBOSE;
                           break;

                        case '1':
                           HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_NORMAL;
                           break;

                        case '\0':
                        case '0':
                           HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_COMPACT;
                           break;

                        default:
                           hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
                     }
                     break;

                  case 'h':
                  case 'H':
                     HB_COMP_PARAM->iLanguage = HB_LANG_PORT_OBJ;
                     break;

                  case 'd':
                  case 'D':
                     if( HB_COMP_PARAM->szDepExt )
                     {
                        hb_xfree( HB_COMP_PARAM->szDepExt );
                        HB_COMP_PARAM->szDepExt = NULL;
                     }
                     if( s[ 2 ] == '-' )
                        HB_COMP_PARAM->iTraceInclude = 0;
                     else if( s[ 2 ] == '.' || s[ 2 ] == '\0' )
                     {
                        HB_COMP_PARAM->iTraceInclude = 2;
                        if( s[ 2 ] != '\0' )
                           HB_COMP_PARAM->szDepExt = hb_strdup( s + 2 );
                     }
                     else
                        hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
                     break;

                  case 'e':
                  case 'E':
                     switch( *( s + 2 ) )
                     {
                        case '1':
                           HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_IDE;
                           break;

                        case '\0':
                        case '0':
                           HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_CLIPPER;
                           break;

                        default:
                           hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
                     }
                     break;

                  default:
                     hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_UNSUPPORTED_LANG, NULL, NULL );
                     break;
               }
               break;

               /* NOTE:
                  h or H from HELP or help
                */
            case 'h':
            case 'H':
            case '?':
               break;

               /* NOTE:
                  It already has support for several include files
                */
            case 'i':
            case 'I':
               switch( *( s + 1 ) )
               {
                  case '-':
                     HB_COMP_PARAM->fINCLUDE = HB_FALSE;
                     break;

                  case '+':
                     HB_COMP_PARAM->fINCLUDE = HB_TRUE;
                     break;

                  default:
                     hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, s + 1, HB_FALSE );
               }
               break;

            case 'j':
            case 'J':
               HB_COMP_PARAM->fI18n = HB_TRUE;
               if( s[ 1 ] )
                  HB_COMP_PARAM->pI18nFileName = hb_fsFNameSplit( s + 1 );
               break;

            case 'k':
            case 'K':
            {
               int i = 1;

               while( s[ i ] && ! HB_COMP_PARAM->fExit )
               {
                  switch( s[ i++ ] )
                  {
                     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':
                     case 'H':
                        /* default Harbour mode */
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HARBOUR;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_HARBOUR;
                        break;

                     case 'c':
                     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':
                     case 'X':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_XBASE;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_XBASE;
                        break;

                     case 'i':
                     case 'I':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HB_INLINE;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_HB_INLINE;
                        break;

                     case 'j':
                     case 'J':
                        if( s[ i ] == '+' )
                        {
                           i++;
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP;
                        }
                        else
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_OPTJUMP;
                        break;

                     case 'm':
                     case 'M':
                        if( s[ i ] == '+' )
                        {
                           i++;
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_MACROTEXT;
                        }
                        else
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACROTEXT;
                        break;

                     case 'd':
                     case 'D':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACRODECL;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_MACRODECL;
                        break;

                     case 'r':
                     case 'R':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_RT_MACRO;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_RT_MACRO;
                        break;

                     case 's':
                     case 'S':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_ARRSTR;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_ARRSTR;
                        break;

                     case 'o':
                     case 'O':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_EXTOPT;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_EXTOPT;
                        break;

                     case 'u':
                     case 'U':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_USERCP;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_USERCP;
                        break;

                     default:
                        hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
                        break;
                  }
               }
               break;
            }

            case 'l':
            case 'L':
               if( *( s + 1 ) == '-' )
                  HB_COMP_PARAM->fLineNumbers = HB_TRUE;
               else
                  HB_COMP_PARAM->fLineNumbers = HB_FALSE;
               break;

            case 'm':
            case 'M':
               if( *( s + 1 ) == '-' )
                  HB_COMP_PARAM->fSingleModule = HB_FALSE;
               else
                  HB_COMP_PARAM->fSingleModule = HB_TRUE;
               break;

            case 'n':
            case 'N':
               HB_COMP_PARAM->fNoStartUp = s[ 1 ] == '1';
               switch( s[ 1 ] )
               {
                  case '-':
                     HB_COMP_PARAM->iStartProc = 0;
                     break;
                  case '\0':
                  case '0':
                  case '1':
                     HB_COMP_PARAM->iStartProc = 1;
                     break;
                  case '2':
                     HB_COMP_PARAM->iStartProc = 2;
                     break;
                  default:
                     hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
               }
               break;

            case 'o':
            case 'O':
               HB_COMP_PARAM->pOutPath = hb_fsFNameSplit( s + 1 );
               break;

               /* Added for preprocessor needs */
            case 'p':
            case 'P':
               if( s[ 1 ] == '+' && s[ 2 ] == '\0' )
                  HB_COMP_PARAM->fPPT = HB_TRUE;
               else
               {
                  if( HB_COMP_PARAM->pPpoPath )
                  {
                     hb_xfree( HB_COMP_PARAM->pPpoPath );
                     HB_COMP_PARAM->pPpoPath = NULL;
                  }
                  if( s[ 1 ] == '-' && s[ 2 ] == '\0' )
                     HB_COMP_PARAM->fPPO = HB_FALSE;
                  else
                  {
                     if( s[ 1 ] )
                        HB_COMP_PARAM->pPpoPath = hb_fsFNameSplit( s + 1 );
                     HB_COMP_PARAM->fPPO = HB_TRUE;
                  }
               }
               break;

            case 'q':
            case 'Q':
               switch( *( s + 1 ) )
               {
                  case '2':
                     HB_COMP_PARAM->fFullQuiet = HB_TRUE;
                  case '0':
                     HB_COMP_PARAM->fLogo = HB_FALSE;
                  default:
                     HB_COMP_PARAM->fQuiet = HB_TRUE;
               }
               break;

            case 'r':
            case 'R':
               if( *( s + 1 ) == ':' )
               {
                  int iOverflow;
                  int iCycles = ( int ) hb_strValInt( s + 2, &iOverflow );

                  if( ! iOverflow && iCycles > 0 )
                     HB_COMP_PARAM->iMaxTransCycles = iCycles;
               }
               else
               {
                  /* TODO: Implement this switch */
                  hb_notSupportedInfo( HB_COMP_PARAM, s );
               }
               break;

            case 's':
            case 'S':
               switch( *( s + 1 ) )
               {
                  case '\0':
                     HB_COMP_PARAM->iSyntaxCheckOnly = 1;
                     break;
                  case '-':
                     HB_COMP_PARAM->iSyntaxCheckOnly = 0;
                     break;
                  case 'm':
                  case 'M':
                     if( s[ 2 ] == '\0' )
                     {
                        HB_COMP_PARAM->iSyntaxCheckOnly = 2;
                        break;
                     }
                  default:
                     hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
               }
               break;

            case 't':
            case 'T':
               /* TODO: Implement this switch */
               hb_notSupportedInfo( HB_COMP_PARAM, s );
               break;

            case 'u':
            case 'U':
               if( ( s[ 1 ] == 'N' || s[ 1 ] == 'n' ) &&
                   ( s[ 2 ] == 'D' || s[ 2 ] == 'd' ) &&
                   ( s[ 3 ] == 'E' || s[ 3 ] == 'e' ) &&
                   ( s[ 4 ] == 'F' || s[ 4 ] == 'f' ) && s[ 5 ] == ':' )
               {
                  /* NOTE: Ignore these -undef: switches (will be processed
                   *       separately) except -undef:.arch.
                   */
                  if( s[ 6 ] == '.' &&
                      ( s[  7 ] == 'A' || s[  7 ] == 'a' ) &&
                      ( s[  8 ] == 'R' || s[  8 ] == 'r' ) &&
                      ( s[  9 ] == 'C' || s[  9 ] == 'c' ) &&
                      ( s[ 10 ] == 'H' || s[ 10 ] == 'h' ) &&
                      s[ 11 ] == '.' )
                  {
                     HB_COMP_PARAM->fNoArchDefs = HB_TRUE;
                  }
                  break;
               }
               /* extended definitions file (-u+<file>) */
               if( s[ 1 ] == '+' )
               {
                  if( s[ 2 ] )
                  {
                     if( HB_COMP_PARAM->iStdChExt == 0 )
                        HB_COMP_PARAM->szStdChExt = ( char ** )
                           hb_xgrab( sizeof( char * ) );
                     else
                        HB_COMP_PARAM->szStdChExt = ( char ** )
                           hb_xrealloc( HB_COMP_PARAM->szStdChExt,
                                        ( HB_COMP_PARAM->iStdChExt + 1 ) *
                                        sizeof( char * ) );
                     HB_COMP_PARAM->szStdChExt[ HB_COMP_PARAM->iStdChExt++ ] =
                           hb_strdup( s + 2 );
                  }
                  else
                     hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
               }
               else
               {
                  if( HB_COMP_PARAM->szStdCh )
                     hb_xfree( HB_COMP_PARAM->szStdCh );
                  HB_COMP_PARAM->szStdCh = hb_strdup( s + 1 );
               }
               break;

            case 'v':
            case 'V':
               if( *( s + 1 ) == '-' )
                  HB_COMP_PARAM->fForceMemvars = HB_FALSE;
               else
                  HB_COMP_PARAM->fForceMemvars = HB_TRUE;
               break;

            case 'w':
            case 'W':
               HB_COMP_PARAM->iWarnings = 1;
               if( s[ 1 ] )       /* there is -w<0,1,2,3> probably */
               {
                  HB_COMP_PARAM->iWarnings = s[ 1 ] - '0';
                  if( HB_COMP_PARAM->iWarnings < 0 || HB_COMP_PARAM->iWarnings > 3 )
                     hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
               }
               break;

            case 'x':
            case 'X':
            {
               unsigned int i = 1;
               while( s[ i ] && ! HB_ISOPTSEP( s[ i ] ) &&
                      i < sizeof( HB_COMP_PARAM->szPrefix ) - 1 )
               {
                  ++i;
               }
               if( i > 1 )
               {
                  memcpy( HB_COMP_PARAM->szPrefix, s + 1, i - 1 );
                  HB_COMP_PARAM->szPrefix[ i - 1 ] = '_';
                  HB_COMP_PARAM->szPrefix[ i ] = '\0';
               }
               else
               {
                  hb_snprintf( HB_COMP_PARAM->szPrefix,
                               sizeof( HB_COMP_PARAM->szPrefix ),
                               "%08lX_", PackDateTime() );
               }
               break;
            }

#ifdef YYDEBUG
            case 'y':
            case 'Y':
               yydebug = HB_TRUE;
               break;
#endif

            case 'z':
            case 'Z':
               if( *( s + 1 ) == '-' )
                  HB_COMP_PARAM->supported |= HB_COMPFLAG_SHORTCUTS;
               else
                  HB_COMP_PARAM->supported &= ~HB_COMPFLAG_SHORTCUTS;
               break;

            default:
               hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
               break;
         }
      }
   }
}
Beispiel #5
0
int main( int argc, char * argv[] )
{
   char * szFile = NULL, * szRuleFile = NULL, * szVerFile = NULL;
   char * szStdCh = NULL, * szLogFile = NULL, * szInclude;
   HB_BOOL fWrite = HB_FALSE, fChgLog = HB_FALSE;
   char * szChangeLogID = NULL, * szLastEntry = NULL;
   int iRevID = 0, iResult = 0, iQuiet = 0, i;
   char * szPPRuleFuncName = NULL;
   PHB_PP_STATE pState;

   pState = hb_pp_new();

   if( argc >= 2 )
   {
      szFile = argv[ 1 ];
      for( i = 2; szFile && i < argc; i++ )
      {
         if( ! HB_ISOPTSEP( argv[ i ][ 0 ] ) )
            szFile = NULL;
         else
         {
            switch( argv[ i ][ 1 ] )
            {
               case 'q':
               case 'Q':
                  if( ! argv[ i ][ 2 ] )
                     iQuiet = 1;
                  else if( argv[ i ][ 2 ] == '-' && ! argv[ i ][ 3 ] )
                     iQuiet = 0;
                  else if( argv[ i ][ 2 ] >= '0' && argv[ i ][ 2 ] <= '2' && ! argv[ i ][ 3 ] )
                     iQuiet = argv[ i ][ 2 ] - '0';
                  else
                     szFile = NULL;
                  break;

               case 'd':
               case 'D':
                  if( ! argv[ i ][ 2 ] )
                     szFile = NULL;
                  else
                  {
                     char * szDefText = hb_strdup( argv[ i ] + 2 ), * szAssign;

                     szAssign = strchr( szDefText, '=' );
                     if( szAssign )
                        *szAssign++ = '\0';
                     hb_pp_addDefine( pState, szDefText, szAssign );
                     hb_xfree( szDefText );
                  }
                  break;

               case 'e':
               case 'E':
                  if( argv[ i ][ 2 ] )
                     szPPRuleFuncName = argv[ i ] + 2;
                  else
                     szPPRuleFuncName = NULL;
                  break;

               case 'w':
               case 'W':
                  if( argv[ i ][ 2 ] )
                     szFile = NULL;
                  else
                     fWrite = HB_TRUE;
                  break;

               case 'c':
               case 'C':
                  fChgLog = HB_TRUE;
                  if( argv[ i ][ 2 ] )
                     szLogFile = argv[ i ] + 2;
                  break;

               case 'i':
               case 'I':
                  if( argv[ i ][ 2 ] )
                     hb_pp_addSearchPath( pState, argv[ i ] + 2, HB_FALSE );
                  else
                     szFile = NULL;
                  break;

               case 'o':
               case 'O':
                  if( argv[ i ][ 2 ] )
                     szRuleFile = argv[ i ] + 2;
                  else
                     szFile = NULL;
                  break;

               case 'v':
               case 'V':
                  if( argv[ i ][ 2 ] )
                     szVerFile = argv[ i ] + 2;
                  else
                     szFile = NULL;
                  break;

               case 'u':
               case 'U':
                  if( argv[ i ][ 2 ] )
                     szStdCh = argv[ i ] + 2;
                  else
                     szStdCh = NULL;
                  break;

               default:
                  szFile = NULL;
                  break;
            }
         }
      }
   }

   if( iQuiet < 2 )
   {
      printf( "Harbour Preprocessor %d.%d.%d%s\n",
              HB_VER_MAJOR, HB_VER_MINOR, HB_VER_RELEASE, HB_VER_STATUS );
      printf( "Copyright (c) 1999-2014, http://harbour-project.org/\n" );
   }

   if( szFile )
   {
      if( ! szRuleFile && ! szVerFile )
         fWrite = HB_TRUE;

      hb_pp_init( pState, iQuiet != 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );

      szInclude = hb_getenv( "INCLUDE" );
      if( szInclude )
      {
         if( szInclude[ 0 ] )
            hb_pp_addSearchPath( pState, szInclude, HB_FALSE );
         hb_xfree( szInclude );
      }

      if( szStdCh )
         hb_pp_readRules( pState, szStdCh );

      if( hb_pp_inFile( pState, szFile, HB_TRUE, NULL, HB_TRUE ) )
      {
         if( fWrite )
         {
            char szFileName[ HB_PATH_MAX ];
            PHB_FNAME pFileName;

            pFileName = hb_fsFNameSplit( szFile );
            pFileName->szExtension = ".ppo";
            hb_fsFNameMerge( szFileName, pFileName );
            hb_xfree( pFileName );

            hb_pp_outFile( pState, szFileName, NULL );
         }

         if( fChgLog )
            iResult = hb_pp_parseChangelog( pState, szLogFile, iQuiet,
                                            &iRevID, &szChangeLogID, &szLastEntry );

         if( iResult == 0 )
            iResult = hb_pp_preprocesfile( pState, szRuleFile, szPPRuleFuncName );

         if( iResult == 0 && szVerFile )
            iResult = hb_pp_generateVerInfo( szVerFile, iRevID,
                                             szChangeLogID, szLastEntry );
         if( iResult == 0 && hb_pp_errorCount( pState ) > 0 )
            iResult = 1;
      }
      else
         iResult = 1;
   }
   else
   {
      hb_pp_usage( argv[ 0 ] );
      iResult = 1;
   }

   if( szChangeLogID )
      hb_xfree( szChangeLogID );
   if( szLastEntry )
      hb_xfree( szLastEntry );

   hb_pp_free( pState );

   return iResult;
}