Back to index

tetex-bin  3.0
rc.h
Go to the documentation of this file.
00001 /*
00002  *  rc.h -- declarations for configuration file processing
00003  *
00004  *  AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 
00022 #define DIALOGRC ".dialogrc"
00023 #define VAR_LEN 30
00024 #define COMMENT_LEN 70
00025 
00026 /* Types of values */
00027 #define VAL_INT  0
00028 #define VAL_STR  1
00029 #define VAL_BOOL 2
00030 #define VAL_ATTR 3
00031 
00032 /* Type of line in configuration file */
00033 #define LINE_BLANK    2
00034 #define LINE_COMMENT  1
00035 #define LINE_OK       0
00036 #define LINE_ERROR   -1
00037 
00038 /* number of configuration variables */
00039 #define VAR_COUNT        (sizeof(vars) / sizeof(vars_st))
00040 
00041 /* check if character is white space */
00042 #define whitespace(c)    (c == ' ' || c == '\t')
00043 
00044 /* check if character is string quoting characters */
00045 #define isquote(c)       (c == '"' || c == '\'')
00046 
00047 /* get last character of string */
00048 #define lastch(str)      str[strlen(str)-1]
00049 
00050 /*
00051  * Configuration variables
00052  */
00053 typedef struct {
00054   char      name[VAR_LEN];  /* name of configuration variable as in DIALOGRC */
00055   void     *var;            /* address of actually variable to change */
00056   int       type;           /* type of value */
00057   char      comment[COMMENT_LEN];    /* comment to put in "rc" file */
00058 } vars_st;
00059 
00060 vars_st vars[] = {
00061   {  "use_shadow",
00062      &use_shadow,
00063      VAL_BOOL,
00064      "Shadow dialog boxes? This also turns on color."                        },
00065 
00066   {  "use_colors",
00067      &use_colors,
00068      VAL_BOOL,
00069      "Turn color support ON or OFF"                                          },
00070 
00071   {  "screen_color",
00072      color_table[0],
00073      VAL_ATTR,
00074      "Screen color"                                                          },
00075 
00076   {  "shadow_color",
00077      color_table[1],
00078      VAL_ATTR,
00079      "Shadow color"                                                          },
00080 
00081   {  "dialog_color",
00082      color_table[2],
00083      VAL_ATTR,
00084      "Dialog box color"                                                      },
00085 
00086   {  "title_color",
00087      color_table[3],
00088      VAL_ATTR,
00089      "Dialog box title color"                                                },
00090 
00091   {  "border_color",
00092      color_table[4],
00093      VAL_ATTR,
00094      "Dialog box border color"                                               },
00095 
00096   {  "button_active_color",
00097      color_table[5],
00098      VAL_ATTR,
00099      "Active button color"                                                   },
00100 
00101   {  "button_inactive_color",
00102      color_table[6],
00103      VAL_ATTR,
00104      "Inactive button color"                                                 },
00105 
00106   {  "button_key_active_color",
00107      color_table[7],
00108      VAL_ATTR,
00109      "Active button key color"                                               },
00110 
00111   {  "button_key_inactive_color",
00112      color_table[8],
00113      VAL_ATTR,
00114      "Inactive button key color"                                             },
00115 
00116   {  "button_label_active_color",
00117      color_table[9],
00118      VAL_ATTR,
00119      "Active button label color"                                             },
00120 
00121   {  "button_label_inactive_color",
00122      color_table[10],
00123      VAL_ATTR,
00124      "Inactive button label color"                                           },
00125 
00126   {  "inputbox_color",
00127      color_table[11],
00128      VAL_ATTR,
00129      "Input box color"                                                       },
00130 
00131   {  "inputbox_border_color",
00132      color_table[12],
00133      VAL_ATTR,
00134      "Input box border color"                                                },
00135 
00136   {  "searchbox_color",
00137      color_table[13],
00138      VAL_ATTR,
00139      "Search box color"                                                      },
00140 
00141   {  "searchbox_title_color",
00142      color_table[14],
00143      VAL_ATTR,
00144      "Search box title color"                                                },
00145 
00146   {  "searchbox_border_color",
00147      color_table[15],
00148      VAL_ATTR,
00149      "Search box border color"                                               },
00150 
00151   {  "position_indicator_color",
00152      color_table[16],
00153      VAL_ATTR,
00154      "File position indicator color"                                         },
00155 
00156   {  "menubox_color",
00157      color_table[17],
00158      VAL_ATTR,
00159      "Menu box color"                                                        },
00160 
00161   {  "menubox_border_color",
00162      color_table[18],
00163      VAL_ATTR,
00164      "Menu box border color"                                                 },
00165 
00166   {  "item_color",
00167      color_table[19],
00168      VAL_ATTR,
00169      "Item color"                                                            },
00170 
00171   {  "item_selected_color",
00172      color_table[20],
00173      VAL_ATTR,
00174      "Selected item color"                                                   },
00175 
00176   {  "tag_color",
00177      color_table[21],
00178      VAL_ATTR,
00179      "Tag color"                                                             },
00180 
00181   {  "tag_selected_color",
00182      color_table[22],
00183      VAL_ATTR,
00184      "Selected tag color"                                                    },
00185 
00186   {  "tag_key_color",
00187      color_table[23],
00188      VAL_ATTR,
00189      "Tag key color"                                                         },
00190 
00191   {  "tag_key_selected_color",
00192      color_table[24],
00193      VAL_ATTR,
00194      "Selected tag key color"                                                },
00195 
00196   {  "check_color",
00197      color_table[25],
00198      VAL_ATTR,
00199      "Check box color"                                                       },
00200 
00201   {  "check_selected_color",
00202      color_table[26],
00203      VAL_ATTR,
00204      "Selected check box color"                                              },
00205 
00206   {  "uarrow_color",
00207      color_table[27],
00208      VAL_ATTR,
00209      "Up arrow color"                                                        },
00210 
00211   {  "darrow_color",
00212      color_table[28],
00213      VAL_ATTR,
00214      "Down arrow color"                                                      }
00215 };    /* vars */
00216 
00217 
00218 
00219 /*
00220  * Routines to process configuration file
00221  */
00222 void create_rc(char *filename);
00223 int parse_rc(void);