Main Page | Data Structures | File List | Data Fields | Globals

clflags.c

Go to the documentation of this file.
00001 /*
00002  *                     OpenBIOS - free your system!
00003  *                         ( FCode tokenizer )
00004  *
00005  *  This program is part of a free implementation of the IEEE 1275-1994
00006  *  Standard for Boot (Initialization Configuration) Firmware.
00007  *
00008  *  Copyright (C) 2001-2005 Stefan Reinauer, <stepan@openbios.org>
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; version 2 of the License.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
00022  *
00023  */
00024 
00025 /* **************************************************************************
00026  *
00027  *      Command-Line Flags are used to control certain non-Standard
00028  *          variant behaviors of the Tokenizer.
00029  *      Support Functions for setting, clearing, displaying, etc.
00030  *      Call them "Special-Feature Flags" in messages to the User
00031  *
00032  *      (C) Copyright 2005 IBM Corporation.  All Rights Reserved.
00033  *      Module Author:  David L. Paktor    dlpaktor@us.ibm.com
00034  *
00035  **************************************************************************** */
00036 
00037 /* **************************************************************************
00038  *
00039  *          For a given CLFlag name, the user may enter either:
00040  *
00041  *                   -f CLFlagName
00042  *              or
00043  *                   -f noCLFlagName
00044  *
00045  *          to either enable or disable the associated function
00046  *
00047  **************************************************************************** */
00048 
00049 /* **************************************************************************
00050  *
00051  *      Functions Exported:
00052  *          set_cl_flag                 Set (or clear) a CL Flag Variable
00053  *          show_all_cl_flag_settings   Show CL Flags' settings unconditionally.
00054  *          list_cl_flag_settings       Display CL Flags' settings if changed.
00055  *          list_cl_flag_names          Display just the names of the CL Flags.
00056  *          cl_flags_help               Help Message for CL Flags
00057  *
00058  **************************************************************************** */
00059 
00060 /* **************************************************************************
00061  *
00062  *      Revision History:
00063  *          Updated Mon, 08 Aug 2005 by David L. Paktor
00064  *          They're not just for setting from the Command-Line anymore,
00065  *              but let's still keep these names for internal use....
00066  *
00067  **************************************************************************** */
00068 
00069 /* **************************************************************************
00070  *
00071  *          The CL_FLAGS data structure has a field for the CLFlagName,
00072  *          one for a text explanation of the function it controls, and
00073  *          one for the address of the boolean variable ("flag")
00074  *
00075  **************************************************************************** */
00076 
00077 #include <stdio.h>
00078 #include <stdlib.h>
00079 #include <string.h>
00080 
00081 #include "clflags.h"
00082 #include "errhandler.h"
00083 
00084 
00085 /* **************************************************************************
00086  *
00087  *          Global Variables Exported
00088  *              (The "flags" controlled by this means)
00089  *
00090  **************************************************************************** */
00091 
00092 bool ibm_locals = FALSE ;
00093 bool ibm_locals_legacy_separator = TRUE ;
00094 bool ibm_legacy_separator_message = TRUE ;
00095 bool enable_abort_quote = TRUE ;
00096 bool sun_style_abort_quote = TRUE ;
00097 bool abort_quote_throw = TRUE ;
00098 bool string_remark_escape = TRUE ;
00099 bool hex_remark_escape = TRUE ;
00100 bool c_style_string_escape = TRUE ;
00101 bool always_headers = FALSE ;
00102 bool always_external = FALSE ;
00103 bool verbose_dup_warning = TRUE ;
00104 bool obso_fcode_warning = TRUE ;
00105 bool trace_conditionals = FALSE ;
00106 bool big_end_pci_image_rev = FALSE ;
00107 
00108 /*  And one to trigger a "help" message  */
00109 bool clflag_help = FALSE;
00110 
00111 /* **************************************************************************
00112  *
00113  *     The addition of the "upper/lower-case-tokens" flags introduces
00114  *         some complications.  These are the variables we will actually
00115  *         be exporting:
00116  *
00117  **************************************************************************** */
00118 
00119 bool force_tokens_case       = FALSE ;
00120 bool force_lower_case_tokens = FALSE ;
00121 
00122 /* **************************************************************************
00123  *
00124  *         but we will be entering two static variables into the table,
00125  *         and keep two more to detect when a change is made...
00126  *
00127  **************************************************************************** */
00128 static bool upper_case_tokens = FALSE ;
00129 static bool lower_case_tokens = FALSE ;
00130 static bool was_upper_case_tk = FALSE ;
00131 static bool was_lower_case_tk = FALSE ;
00132 
00133 /* **************************************************************************
00134  *
00135  *              Internal Static Variables
00136  *     cl_flag_change        A change was made to any of the CL Flags
00137  *              Internal Static Constants
00138  *     cl_flags_list         List of CL Flags and their data.
00139  *
00140  **************************************************************************** */
00141 
00142 static bool cl_flag_change = FALSE;
00143 
00144 static const cl_flag_t cl_flags_list[] = {
00145   /*  The clflag_tabs field takes at least one tab.
00146    *  If the name has fewer than 16 characters,
00147    *  stick in an extra tab, and yet another tab
00148    *  if the name is shorter than 8 characters
00149    *  to make the formatting of the "explanation"
00150    *  come out prettier.
00151    */
00152   { "Local-Values",
00153         &ibm_locals,
00154         "\t\t",
00155             "Support IBM-style Local Values (\"LV\"s)"     } ,
00156 
00157   { "LV-Legacy-Separator",
00158         &ibm_locals_legacy_separator,
00159         "\t",
00160             "Allow Semicolon for Local Values Separator (\"Legacy\")"     } ,
00161 
00162   { "LV-Legacy-Message",
00163         &ibm_legacy_separator_message,
00164         "\t",
00165             "Display a Message when Semicolon is used as the "
00166                 "Local Values Separator" } ,
00167 
00168   { "ABORT-Quote",
00169         &enable_abort_quote,
00170         "\t\t",
00171             "Allow ABORT\" macro"     } ,
00172 
00173   { "Sun-ABORT-Quote",
00174         &sun_style_abort_quote,
00175         "\t\t",
00176             "ABORT\" with implicit IF ... THEN"     } ,
00177 
00178   { "ABORT-Quote-Throw",
00179         &abort_quote_throw,
00180         "\t",
00181             "Use -2 THROW in an Abort\" phrase, rather than ABORT"     } ,
00182 
00183   { "String-remark-escape",
00184         &string_remark_escape,
00185         "\t",
00186             "Allow \"\\ (Quote-Backslash) to interrupt string parsing"     } ,
00187 
00188   { "Hex-remark-escape",
00189         &hex_remark_escape,
00190         "\t",
00191             "Allow \\ (Backslash) to interrupt "
00192                 "hex-sequence parsing within a string"     } ,
00193 
00194   { "C-Style-string-escape",
00195         &c_style_string_escape ,
00196         "\t",
00197             "Allow \\n \\t and \\xx\\ for special chars in string parsing"  } ,
00198 
00199   { "Always-Headers",
00200         &always_headers ,
00201         "\t\t",
00202             "Override \"headerless\" and force to \"headers\"" } ,
00203 
00204   { "Always-External",
00205         &always_external ,
00206         "\t\t",
00207             "Override \"headerless\" and \"headers\" and "
00208                 "force to \"external\"" } ,
00209 
00210   { "Warn-if-Duplicate",
00211         &verbose_dup_warning ,
00212         "\t",
00213             "Display a WARNING message when a duplicate definition is made" } ,
00214 
00215   { "Obsolete-FCode-Warning",
00216         &obso_fcode_warning ,
00217         "\t",
00218             "Display a WARNING message when an \"obsolete\" "
00219                 "(per the Standard) FCode is used" } ,
00220 
00221   { "Trace-Conditionals",
00222         &trace_conditionals,
00223         "\t",
00224             "Display ADVISORY messages about the state of "
00225                 "Conditional Tokenization" } ,
00226 
00227   { "Upper-Case-Token-Names",
00228         &upper_case_tokens,
00229         "\t",
00230             "Convert Token-Names to UPPER-Case" } ,
00231 
00232 
00233   { "Lower-Case-Token-Names",
00234         &lower_case_tokens,
00235         "\t",
00236             "Convert Token-Names to lower-Case" } ,
00237 
00238 
00239   { "Big-End-PCI-Rev-Level",
00240         &big_end_pci_image_rev,
00241         "\t",
00242             "Save the Vendor's Rev Level field of the PCI Header"
00243                 " in Big-Endian format" } ,
00244 
00245 
00246   /*  Keep the "help" pseudo-flag last in the list  */
00247   { "help",
00248         &clflag_help,
00249             /*  Two extra tabs if the name is shorter than 8 chars  */
00250         "\t\t\t",
00251             "Print this \"Help\" message for the Special-Feature Flags" }
00252 
00253 };
00254 
00255 static const int number_of_cl_flags =
00256          sizeof(cl_flags_list)/sizeof(cl_flag_t);
00257 
00258 
00259 /* **************************************************************************
00260  *
00261  *          CL Flags whose settings are changed in the source file should
00262  *              not stay in effect for the duration of the entire batch of
00263  *              tokenizations (i.e., if multiple input files are named on
00264  *              the command line) the way command-line settings should.
00265  *          To accomplish this we will collect the state of the flags into
00266  *              a bit-mapped variable after the command line has been parsed
00267  *              and restore them to their collected saved state before an
00268  *              input file is processed.
00269  *
00270  **************************************************************************** */
00271 
00272 static long int cl_flags_bit_map;
00273 /*  If the number of CL Flags ever exceeds the number of bits in a long
00274  *      (presently 32), we will need to change both this variable and
00275  *      the routines that use it.  Of course, if the number of CL Flags
00276  *      ever gets that high, it will be *seriously* unwieldy...   ;-}
00277  */
00278 
00279 /* **************************************************************************
00280  *
00281  *      Function name:  adjust_case_flags
00282  *      Synopsis:       If the last CL Flag Variable setting changed one of
00283  *                          the "upper/lower-case-tokens" flags, make the 
00284  *                          appropriate adjustments.
00285  *
00286  *      Inputs:
00287  *         Parameters:                NONE
00288  *         Local Static Variables:
00289  *             was_upper_case_tk      State of "upper-case-tokens" flag before
00290  *                                        last CL Flag Variable was processed
00291  *             was_lower_case_tk      State of "lower-case-tokens" flag, before
00292  *             upper_case_tokens      State of "upper-case-tokens" flag after
00293  *                                        last CL Flag V'ble was processed
00294  *             lower_case_tokens      State of "lower-case-tokens" flag, after
00295  *         Global Variables:
00296  *
00297  *      Outputs:
00298  *         Returned Value:            NONE
00299  *         Global Variables:
00300  *             force_tokens_case          TRUE if "upper/lower-case-tokens"
00301  *                                            flag is in effect
00302  *             force_lower_case_tokens    If force_tokens_case is TRUE, then
00303  *                                            this switches between "upper"
00304  *                                            or "lower" case
00305  *
00306  *      Process Explanation:
00307  *          We cannot come out of this with both  upper_case_tokens  and
00308  *               lower_case_tokens  being TRUE, though they may both be FALSE.
00309  *          If neither has changed state, we need not do anything here.
00310  *              If one has gone to TRUE, we must force the other to FALSE and
00311  *                  we will set  force_tokens_case  to TRUE.
00312  *              If one has gone to FALSE, turn  force_tokens_case  to FALSE.
00313  *              If  force_tokens_case  is TRUE after all this, we must adjust
00314  *                   force_lower_case_tokens  according to  lower_case_tokens
00315  *
00316  **************************************************************************** */
00317 
00318 static void adjust_case_flags( void)
00319 {
00320     static bool *case_tokens[2] = { &upper_case_tokens, &lower_case_tokens };
00321     static bool *was_case_tk[2] = { &was_upper_case_tk, &was_lower_case_tk };
00322     int the_one = 0;
00323     int the_other = 1;
00324 
00325     for ( ; the_one < 2 ; the_one++ , the_other-- )
00326     {
00327         /*  If one has changed state   */
00328         if ( *(case_tokens[the_one]) != *(was_case_tk[the_one]) )
00329         {
00330             if ( *(case_tokens[the_one]) )
00331             {
00332                 /*  If it has gone to TRUE, force the other to FALSE.  */
00333                 *(case_tokens[the_other]) = FALSE;
00334                 /*      and set  force_tokens_case  to TRUE  */
00335                 force_tokens_case = TRUE;
00336             }else{
00337                 /*  If it has gone to FALSE turn  force_tokens_case FALSE  */
00338                 force_tokens_case = FALSE;
00339             }
00340             if ( force_tokens_case )
00341             {
00342                 force_lower_case_tokens = lower_case_tokens;
00343             }
00344             break;  /*  Only one can have changed state.   */
00345         }
00346     }
00347 }
00348 
00349 
00350 
00351 
00352 /* **************************************************************************
00353  *
00354  *      Function name:  set_cl_flag
00355  *      Synopsis:       Set (or clear) the named CL Flag Variable
00356  *
00357  *      Inputs:
00358  *         Parameters:
00359  *             flag_name           The name as supplied by the user
00360  *             from_src            TRUE if called from source-input file
00361  *         Static Constants:
00362  *             cl_flags_list
00363  *             number_of_cl_flags
00364  *
00365  *      Outputs:
00366  *         Returned Value:         TRUE if supplied name is not valid
00367  *         Global Variables:
00368  *             The CL Flag Variable associated with the supplied name will
00369  *                 be set or cleared according to the leading "no"
00370  *         Local Static Variables:
00371  *             cl_flag_change      TRUE if associated variable has changed
00372  *         Printout:
00373  *             If  from_src  is TRUE, print "En" or "Dis" abling:
00374  *                 followed by the explanation
00375  *
00376  *      Error Detection:
00377  *          If the supplied name is not a valid CL Flag name, or if
00378  *              it's too short to be a valid CL Flag name, return TRUE.
00379  *          Print a message;  either a simple print if this function was
00380  *              called from a command-line argument, or an ERROR if it
00381  *              was called from a line in the from source-input file.
00382  *
00383  *      Process Explanation:
00384  *          Save the current state of the "upper/lower-case-tokens" flags
00385  *          If the given name has a leading "no", make note of that fact
00386  *              and remove the leading "no" from the comparison.
00387  *          Compare with the list of valid CL Flag names.
00388  *          If no match was found, Error.  See under Error Detection.
00389  *          If a match:
00390  *              Change the associated variable according to the leading "no"
00391  *              Set  cl_flag_change  to TRUE  unless the variable is the one
00392  *                  associated with the "help" flag; this permits the
00393  *                  "Default" vs "Setting" part of  cl_flags_help() to
00394  *                  work properly...
00395  *              Do the conditional Printout (see above)
00396  *          Adjust the "upper/lower-case-tokens" flags if one has changed.
00397  *
00398  **************************************************************************** */
00399 static bool first_err_msg = TRUE;  /*  Need extra carr-ret for first err msg  */
00400 bool set_cl_flag(char *flag_name, bool from_src)
00401 {
00402     bool retval = TRUE;
00403 
00404     was_upper_case_tk = upper_case_tokens;
00405     was_lower_case_tk = lower_case_tokens;
00406 
00407     if ( strlen(flag_name) > 3 )
00408     {
00409         int indx;
00410         bool flagval = TRUE;
00411         char *compar = flag_name;
00412 
00413         if ( strncasecmp( flag_name, "no", 2) == 0 )
00414         {
00415             flagval = FALSE;
00416             compar += 2;
00417         }
00418         for ( indx = 0 ; indx < number_of_cl_flags ; indx++ )
00419         {
00420             if ( strcasecmp( compar, cl_flags_list[indx].clflag_name ) == 0 )
00421             {
00422                 retval = FALSE;
00423                 *(cl_flags_list[indx].flag_var) = flagval;
00424 
00425                 /*  The "help" flag is the last one in the list  */
00426                 if ( indx != number_of_cl_flags - 1 )
00427                 {
00428                     cl_flag_change = TRUE;
00429                 }
00430                 if ( from_src )
00431                 {
00432                     tokenization_error(INFO,
00433                     "%sabling:  %s\n",
00434                     flagval ? "En" : "Dis", cl_flags_list[indx].clflag_expln);
00435                 }
00436                 break;
00437             }
00438         }
00439     }
00440 
00441     if ( retval )
00442     {
00443        const char* msg_txt = "Unknown Special-Feature Flag:  %s\n" ;
00444        if ( from_src )
00445        {
00446            tokenization_error( TKERROR, (char *)msg_txt, flag_name);
00447        }else{
00448            if ( first_err_msg )
00449            {
00450                printf( "\n");
00451                first_err_msg = FALSE;
00452            }
00453            printf( msg_txt, flag_name);
00454        }
00455     }
00456 
00457     adjust_case_flags();
00458 
00459     return ( retval );
00460 }
00461 
00462 /* **************************************************************************
00463  *
00464  *      Function name:  show_all_cl_flag_settings
00465  *      Synopsis:       Display the settings of the CL Flags, (except "help")
00466  *                          regardless of whether they have been changed.
00467  *
00468  *      Associated Tokenizer directive(s):        [FLAGS]
00469  *                                                #FLAGS
00470  *                                                [#FLAGS]
00471  *                                                SHOW-FLAGS
00472  *          This routine may also be invoked by a combination of
00473  *              options on the command-line.
00474  *
00475  *      Inputs:
00476  *         Parameters:
00477  *             from_src                TRUE if called from source-input file
00478  *         Macro:
00479  *             ERRMSG_DESTINATION        Error message destination;
00480  *                                           (Development-time switch)
00481  *         Static Constants:
00482  *             cl_flags_list
00483  *             number_of_cl_flags
00484  *
00485  *      Outputs:
00486  *         Returned Value:                  NONE
00487  *         Printout:    Directed to  stdout or to stderr 
00488  *                          (see definition of ERRMSG_DESTINATION)
00489  *             A header line, followed by the names of the CL Flags,
00490  *                  with "No" preceding name if value is FALSE, one to a line.
00491  *
00492  *      Process Explanation:
00493  *          If from_src is TRUE, print the header line as a Message, and
00494  *              then direct output to  ERRMSG_DESTINATION .
00495  *          Don't print the "help" trigger (the last flag in the array).
00496  *
00497  **************************************************************************** */
00498 
00499 void show_all_cl_flag_settings(bool from_src)
00500 {
00501     const char* hdr_txt = "Special-Feature Flag settings:" ;
00502     int indx;
00503 
00504     if ( from_src )
00505     {
00506         tokenization_error(MESSAGE, (char *)hdr_txt);
00507     }else{
00508         printf("\n%s\n", hdr_txt);
00509     }
00510 
00511     for ( indx = 0 ; indx < (number_of_cl_flags - 1) ; indx++ )
00512     {
00513         fprintf( from_src ? ERRMSG_DESTINATION : stdout ,
00514             "\t%s%s\n",
00515                 *(cl_flags_list[indx].flag_var) ? "  " : "No" ,
00516                     cl_flags_list[indx].clflag_name );
00517     }
00518     if ( from_src )   fprintf( ERRMSG_DESTINATION, "\n");
00519 }
00520 
00521 /* **************************************************************************
00522  *
00523  *      Function name:  list_cl_flag_settings
00524  *      Synopsis:       Display the settings of the CL Flags, (except "help")
00525  *                          if any of them have been changed
00526  *
00527  *      Inputs:
00528  *         Parameters:                 NONE
00529  *         Local Static Variables:        
00530  *             cl_flag_change          TRUE if a Flag setting has been changed.
00531  *
00532  *      Outputs:
00533  *         Returned Value:             NONE
00534  *         Printout:
00535  *             Settings of the CL Flags.  See   show_all_cl_flag_settings()
00536  *
00537  *      Process Explanation:
00538  *          Don't print anything if  cl_flag_change  is not TRUE
00539  *
00540  **************************************************************************** */
00541 
00542 void list_cl_flag_settings(void)
00543 {
00544 
00545     if ( cl_flag_change )
00546     {
00547         show_all_cl_flag_settings( FALSE);
00548     }
00549 }
00550 
00551 
00552 /* **************************************************************************
00553  *
00554  *      Function name:  list_cl_flag_names
00555  *      Synopsis:       Display just the names of the CL Flags
00556  *                      for the Usage message
00557  *
00558  *      Inputs:
00559  *         Parameters:                      NONE
00560  *         Static Constants:
00561  *             cl_flags_list                
00562  *             number_of_cl_flags           
00563  *
00564  *      Outputs:
00565  *         Returned Value:                  NONE
00566  *         Printout:
00567  *             A header line, followed by the names of the CL Flags,
00568  *
00569  **************************************************************************** */
00570 
00571 void list_cl_flag_names(void)
00572 {
00573     int indx;
00574 
00575     printf("Valid Special-Feature Flags are:\n");
00576     for ( indx = 0 ; indx < number_of_cl_flags ; indx++ )
00577     {
00578         printf("\t%s\n", cl_flags_list[indx].clflag_name );
00579     }
00580 }
00581 
00582 /* **************************************************************************
00583  *
00584  *      Function name:  cl_flags_help
00585  *      Synopsis:       Display Usage of the CL Flags and their defaults
00586  *                      
00587  *
00588  *      Inputs:
00589  *         Parameters::                      NONE
00590  *         Static Constants:
00591  *             cl_flags_list
00592  *             number_of_cl_flags
00593  *         Local Static Variables:
00594  *             cl_flag_change                TRUE if setting has been changed.
00595  *
00596  *      Outputs:
00597  *         Returned Value:                   NONE
00598  *         Printout:
00599  *             A few lines of header, followed by the default, the name
00600  *             and the "explanation" of each of the CL Flags, one to a line.
00601  *
00602  *      Extraneous Remarks:
00603  *          We take advantage of the facts that this routine is called
00604  *              (1) only from the command-line, before any settings
00605  *              have been changed, and (2) via changing the flag for
00606  *              "help" to TRUE.  (Technically, I suppose, the default
00607  *              for the "help" feature is "no", but showing will, I
00608  *              think be more confusing than enlightening to the user.)
00609  *          Also, I suppose a perverse user could change setting(s) on
00610  *              the same command-line with a "-f help" request; we cannot
00611  *              stop users from aiming at their boot and pulling the
00612  *              trigger.  As my buddies in Customer Support would say:
00613  *              "KMAC YOYO"  (Approximately, "You're On Your Own, Clown")...
00614  *
00615  *      Revision History:
00616  *          Oh, all right.  If the user changed setting(s), we can do
00617  *              them the minor courtesy of printing "Setting" instead
00618  *              of "Default".
00619  *
00620  *
00621  **************************************************************************** */
00622 
00623 void cl_flags_help(void )
00624 {
00625     int indx;
00626 
00627     printf("\n"
00628            "Special-Feature Flags usage:\n"
00629            "  -f   FlagName   to enable the feature associated with FlagName,\n"
00630            "or\n"
00631            "  -f noFlagName   to disable the feature.\n\n"
00632                 "%s   Flag-Name\t\t  Feature:\n\n",
00633                     cl_flag_change ? "Setting" : "Default" );
00634 
00635    for ( indx = 0 ; indx < number_of_cl_flags ; indx++ )
00636     {
00637         printf("  %s    %s%s%s\n",
00638             *(cl_flags_list[indx].flag_var) ? "  " : "no" ,
00639             cl_flags_list[indx].clflag_name,
00640             cl_flags_list[indx].clflag_tabs,
00641             cl_flags_list[indx].clflag_expln);
00642     }
00643 
00644 }
00645 
00646 
00647 
00648 /* **************************************************************************
00649  *
00650  *      Function name:  save_cl_flags
00651  *      Synopsis:       Collect the state of the CL Flags
00652  *
00653  *      Inputs:
00654  *         Parameters:                     NONE
00655  *         Local Static Variables:
00656  *             cl_flags_list
00657  *         Static Constants:
00658  *             number_of_cl_flags
00659  *
00660  *      Outputs:
00661  *         Returned Value:                 NONE
00662  *         Local Static Variables:
00663  *             cl_flags_bit_map            Will be set to reflect the state
00664  *                                             of the CL Flags in the list.
00665  *
00666  *      Process Explanation:
00667  *          The correspondence of bits to the list is that the first item
00668  *              in the list corresponds to the low-order bit, and so on
00669  *              moving toward the high-order with each successive item.
00670  *          Do not save the "help" flag (last item on the list).
00671  *          This routine is called after the command line has been parsed.
00672  *
00673  **************************************************************************** */
00674 
00675 void save_cl_flags(void)
00676 {
00677     int indx;
00678     long int moving_bit = 1;
00679 
00680     cl_flags_bit_map = 0;
00681     for ( indx = 0 ; indx < (number_of_cl_flags - 1) ; indx++ )
00682     {
00683         if ( *(cl_flags_list[indx].flag_var) )
00684         {
00685             cl_flags_bit_map |= moving_bit;  /*  The moving finger writes,  */
00686         }
00687         moving_bit <<= 1;                    /*  and having writ, moves on. */
00688     }
00689 }
00690 
00691 /* **************************************************************************
00692  *
00693  *      Function name:  reset_cl_flags
00694  *      Synopsis:       Restore the CL Flags to the state that was saved.
00695  *
00696  *      Inputs:
00697  *         Parameters:                     NONE
00698  *         Local Static Variables:
00699  *             cl_flags_bit_map            Reflects the state of the CL Flags
00700  *         Static Constants:
00701  *             number_of_cl_flags
00702  *
00703  *      Outputs:
00704  *         Returned Value:                  NONE
00705  *         Local Static Variables:
00706  *             cl_flags_list
00707  *         Global Variables:
00708  *             The CL Flag Variables will be set or cleared
00709  *                 to their saved state
00710  *
00711  *      Process Explanation:
00712  *          This routine is called before starting a new input file.
00713  *              Any changes made in the source file will not stay
00714  *              in effect for the next tokenization.
00715  *
00716  **************************************************************************** */
00717 
00718 void reset_cl_flags(void)
00719 {
00720     int indx;
00721     long int moving_bit = 1;
00722 
00723     for ( indx = 0 ; indx < (number_of_cl_flags - 1) ; indx++ )
00724     {
00725         *(cl_flags_list[indx].flag_var) =
00726             BOOLVAL( cl_flags_bit_map & moving_bit) ;
00727         moving_bit <<= 1;
00728     }
00729 }

Generated on Fri Aug 18 14:03:38 2006 for Toke1.0 by  doxygen 1.4.4