PxConfigNextString(), PxConfigNextStringCx()

Get the next entry in the current section

Synopsis:

#include <photon/PxProto.h>

const char *PxConfigNextString( char *value,
                                size_t maxlen );

const char *PxConfigNextStringCx( PxCfgContext_t *cx,
                                  char *value,
                                  size_t maxlen );

Arguments:

cx
PxConfigNextStringCx() only. The configuration file handle for the file you want to get the next string in. This handle is returned by PxConfigOpenCx().
value
A buffer where the function stores the value it reads.
maxlen
The maximum length of value. PxConfigNextString() copiesa maximum of (maxlen-1) characters (with a '\0' terminator appended) in the string into the buffer at address value.

Library:

phexlib

Description:

These functions return the next entry in the current section as a string. A pointer to the entry name is returned, and its configuration value (up to a maximum of maxlen characters including trailing NULL) is copied as a string into the buffer at address value. This may be used to process a configuration section consisting of unknown entries, but where each entry is to be processed in a similar fashion.

If there is no current section (for example, if the file has just been opened), PxConfigNextString*() seeks to the beginning of the first section, and returns the first entry.

Returns:

A string containing the next entry name within the current section if one exists, NULL otherwise.


Note: If PxConfigNextString*() detects the end of the section, it returns NULL. If you call PxConfigNextString() again, it gets the next entry in the next section.

Examples:

char *env, val[128];
if (PxConfigSection("Environment") != NULL)
    while ((env = PxConfigNextString(val, sizeof(val))) != NULL)
        setenv(env, val, ~0);

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PxConfigFirstSection*(), PxConfigNextEntry*(), PxConfigNextSection*(), PxConfigOpen*(), PxConfigSection*()