WinDom: Configuration Library

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

# Configuration Library
[Reference documentation]

Group of functions devoted to WinDom configuration file management. More...

## Functions
int | mt_ConfRead (APPvar *app)
| read the configuration file and set the WinDom parameters
int | mt_ConfInquire (APPvar *app, char *keyword, char *fmt,...)
| read an user variable in the configuration file
int | mt_ConfGetLine (APPvar *app, char *line)
| read acces by line in the configuration file
int | mt_ConfWrite (APPvar *app, char *keyword, char *fmt,...)
| write the windom config file
int | mt_ConfWindom (APPvar *app)
| load winconf (windom configurator)
int | ConfInquire (char *keyword, char *fmt,...)
| see mt_ConfInquire()
int | ConfWrite (char *keyword, char *fmt,...)
| see mt_ConfWrite()

## Detailed Description

Group of functions devoted to WinDom configuration file management.

## Function Documentation

int ConfInquire | ( | char * | keyword,
|  | char * | fmt,
|  |  | ...
| ) |

| see mt_ConfInquire()

int ConfWrite | ( | char * | keyword,
|  | char * | fmt,
|  |  | ...
| ) |

| see mt_ConfWrite()

int mt_ConfGetLine | ( | APPvar * | app,
|  | char * | string
| ) |

  | read acces by line in the configuration file Parameters:
  | app | application descriptor
  | string | pointer to a buffer to store the line
  Return values:
  | 0 | no more lines to read
  | >0 | number of the line read
mt_ConfGetLine() provides a line acces to read the configuration file. It can only read a line with the following format:
     variable = value
If the string parameter is NULL, the line pointer inside the file is set to the begin of the application area. Note: string should pointer to a sufficially big buffer to store See also: mt_ConfInquire(), mt_ConfRead(), mt_ConfWrite()

int mt_ConfInquire | ( | APPvar * | app,
|  | char * | keyword,
|  | char * | fmt,
|  |  | ...
| ) |

  | read an user variable in the configuration file Parameters:
  | app | application descriptor
  | keyword | name of variable to read
  | fmt | format of value (see below)
  | ... | address(es) of variable(s) to fill-in.
  Return values:
  | >=0 | is the number of values read
  | -1 | variable not found
  | -33 | configuration file not found
mt_ConfInquire() read a variable from the configuration file in the application area is defined or in the Default Settings area if defined. If the variable is not found or if no configuration area addressing the application is not found, the function returns -1. The syntax of variable definition in the configuration file have the following structure:
     keyword = value[, value[, ...]]
The '[]' notation means an optional argument. The `format` parameter have a similar syntax than printf(). Possible variable are : %d : 16-bit integer, %f : single real (32-bit), %c : a character delimited by a quote ((!U)'(!u)), %b : a boolean variable (true, on, 1, false, off, 0), %B : the boolean value in set in a specific bit of the variable (see EXAMPLES), %s : a string. The string can be delimited by a double quote charactere ((!U)"(!u)) if the string contains space characters. %S : equivalent to s, it is an obsolet mode but kept for higher compatibility. Example of configuration file:
    appli.font.name = "Helvetica Bold"
    appli.system.path = C:\APPLI\system\
    appli.window.size = 400,300
    appli.window.sizer = 'S'
    appli.parameters.save = TRUE
    appli.parameters.bubble = TRUE
and here is the corresponding code (in the application) :
    void InitAppl( void)
    {
        char FontName[33], path[128];
        int width, height;
        char car;
    #define PARAM_SAVE  0x1
    #define PARAM_BUBBLE 0x2
        int param;

        if( ConfInquire( "appli.font.name", "%s", FontName) != 1)
            strcpy( FontName, "Times");
        if( ConfInquire( "appli.system.path", "%s", path) != 1)
            strcpy( path, "");
        if( ConfInquire( "appli.window.size", "%d,%d", &width, &height) != 2)
            width = height = 200;
        if( ConfInquire( "appli.window.sizer", "%s", &car) != 1)
            car = 'S';
        ConfInquire( "appli.parameters.save", "%B", &param,   PARAM_SAVE);
        ConfInquire( "appli.parameters.bubble", "%B", &param, PARAM_BUBBLE);
    }
See also: mt_ConfRead(), mt_ConfWrite(), mt_ConfGetLine()

int mt_ConfRead | ( | APPvar * | app | ) |

  | read the configuration file and set the WinDom parameters Parameters:
  | app | application descriptor
  Return values:
  | 0 | success
  | -1 | application not find in the configuration file
  | -33 | configuration file not found
mt_ConfRead() reads in the WinDom configuration file the settings of the application. Only WinDom parameters are set. This file can contain other parameters readable with the functions mt_ConfGetLine() and mt_ConfInquire(). These parameters are specific to the application. This function is used by mt_ApplInit() to initialize the WinDom settings and by mt_EvntWindom() when it receives the `AP_CONF` message. The WinDom configuration file is an unique text file grouping the configuration of all WinDom application in a similar way then the '.Xdefaults' X11 file for example. This file is typically located in the HOME folder. Actually, WinDom searchs this file in the following directories : the application directory, the $HOME/Defaults directory, the $HOME directory, the $ETCDIR directory, the $PATH directories (can be multiple), the 'C:\' directory This file is nammed 'windom.cnf' or '.windomrc' if the file system supports the long name file. Bug: Each line has the following syntax :
     keyword = value list ...
A space character is required between the keyword and the '=' character. See also: mt_ApplInit(), mt_EvntWindom(), mt_ConfInquire(), mt_ConfGetLine()

int mt_ConfWindom | ( | APPvar * | app | ) |

  | load winconf (windom configurator) Parameters:
  | app | application descriptor
Returns: -33 if winconf.app is not found, or the result of the loading done by mt_ShelWrite()

int mt_ConfWrite | ( | APPvar * | app,
|  | char * | name,
|  | char * | fmt,
|  |  | ...
| ) |

  | write the windom config file Parameters:
  | app | application descriptior
  | name | name of variable to write
  | fmt | format of value (similar to printf)
  | ... | variables (%d or %s etc... of fmt)
  Return values:
  | 0 | success
  | <0 | error
This function will add a "variable = value" string in the configuration file. If the config file is not found, a new one will be created. See also: mt_ConfGetLine() mt_ConfInquire() mt_ConfRead()