[Previous] [Contents] [Index] [Next]

PxConfigOpen()

Open a configuration file

Synopsis:

#include <photon/PxProto.h>

int PxConfigOpen( const char *cfgfile, 
                  int mode);

Description:

PxConfigOpen() opens the configuration file specified by cfgfile for reading. The file should be closed using PxConfigClose() when the configuration procedure is complete. Only one configuration file may be opened at any one time.

The mode parameter is a bitfield specifying what operations may be performed on the configuration file; it consists of any number of the following values:

PXCONFIG_READ
Allow reading of the config file. This access is always permitted.
PXCONFIG_WRITE
Allow writing (modification) of the config file, using PxConfigWrite*() and PxConfigDelete*().
PXCONFIG_CREATE
Create a new config file, erasing the file if it exists (be sure to specify PXCONFIG_WRITE as well).

The configuration file consists of simple text and is divided into sections, introduced by [section_name]. Section names are currently limited to 50 characters. Each section is made up of entries (one per line) of the form:

entry_name = value

Entry names are currently limited to 64 characters. Values are limited to 512 characters. Comments follow #, anywhere on a line. Here's an example:

    [WWW Section]
    Heading Font  =  swiss
    Body Font     =  dutch
    Link Color    =  0000FF
    Visited Color =  008080
    Cache Size    =  10240

    [File Section]
    File Font     =  swiss12
    Print Command =  lp @
    Display Mode  =  1

See PxConfigSection() for further details on the configuration.

Returns:

Pt_TRUE
The given configuration file exists and has been opened.
Pt_FALSE
Otherwise.

Examples:

if (PxConfigOpen(fname, PXCONFIG_READ)) {
    // read parameters from the file
    PxConfigClose();
}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PxConfigClose(), PxConfigDeleteEntry(), PxConfigDeleteSection(), PxConfigForceEmptySection(), PxConfigNextSection(), PxConfigNextString(), PxConfigReadBool(), PxConfigReadChar(), PxConfigReadInt(), PxConfigReadLong(), PxConfigReadShort(), PxConfigReadString(), PxConfigSection(), PxConfigWriteBool(), PxConfigWriteChar(), PxConfigWriteInt(), PxConfigWriteLong(), PxConfigWriteShort(), PxConfigWriteString()


[Previous] [Contents] [Index] [Next]