the Environment API


Typical usage

#include"adflib.h"


void MyVer(char *msg)
{
    fprintf(stderr,"Verbose [%s]\n",msg);
}


int main()
{
    BOOL boolPr = TRUE;

    adfEnvInitDefault();

    /* to use the dir cache blocks, default is FALSE */
    adfChgEnvProp(PR_USEDIRC, (void*)&boolPr);      // optional
	
    /* to override the verbose callback */
    adfChgEnvProp(PR_VFCT, MyVer);                  // optional

    adfEnvCleanUp();
}

adfEnvInitDefault()

Syntax

void adfEnvInitDefault()

Description

Initialise the library data structures and default values. Must be done before any other call to the library.

There is 4 callback functions which can be (and must be) overridden, the library must not write anything to the console.

By default, those functions write a message to stderr.

Another environment property is the ability to use or not the dir cache blocks to get the content of a directory. By default, it is not used.

See adfChgEnvProp() to learn how to change those properties.

Internals

  1. Set the default values
  2. Prints the library version with the verbose callback.
  3. Allocate the native functions structure
  4. Calls adfInitNativeFct()

adfChgEnvProp()

Syntax

void adfChgEnvProp(int propertyName, void* new value)

Description

Change the default or lastest value of one of the environment property. The new value has the void*, this is the only way to transmit it for several types. A cast is made depending of the property name inside adfChgEnvProp().

Here's the list of the properties, and their types :

For the non pointer types (int with PR_USEDIRC), you have to use a temporary variable. To override successfully a function, the easiest is to reuse the default function located in adf_env.c, and to change it for your needs.


adfEnvCleanUp()

Syntax

void adfEnvCleanUp()

Description

Cleans up the environment.

Internals

Frees the native functions structure.

adfEnvCleanUp() : Obsolete

Syntax

void adfSetEnvFct( void(*eFct)(char*) error, void(*wFct)(char*) warning, void(*vFct)(char*) verbose, void(*notFct)(SECTNUM,int) notify )

Obsolete : use adfChgEnvProp() instead.


adfGetVersionNumber()

Syntax

char* adfGetVersionNumber()

Description

Returns the current numeric ADFlib version.


adfGetVersionDate()

Syntax

char* adfGetVersionDate()

Description

Returns the date of the ADFlib current version.