Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

Configuration

Expose values from MACS configuration file. More...

Functions

const char * macs_get_cf (macs_session *sess)
 Find the configuration file.

char * macs_get_config (macs_session *sess, const char *key,...)
 Fetch a configuration value.

char ** macs_get_configs (macs_session *sess, int *nodes, const char *key,...)
 Fetch several configuration values.

char ** macs_get_methods (macs_session *sess, int svc)
 Fetch a list of available methods.


Detailed Description

Expose values from MACS configuration file.

The Configuration routines expose MACS context configuration information, such as the location of the services.


Function Documentation

const char* macs_get_cf macs_session   sess
 

Find the configuration file.

Parameters:
sess A MACS session pointer
Returns:
The name of the currently loaded configuration file, or NULL if the library is not currently configured from a file. SHOULD NOT be free()d
This is an easy way to determine if a session has been initialized.

char* macs_get_config macs_session   sess,
const char *    key,
...   
 

Fetch a configuration value.

Parameters:
sess A MACS session
key A NULL-terminated list of strings which make up the key.
Returns:
The value associated with the key, or NULL if the key was not found. Should be free()d
Expose key/value pairs stored from the configuration file. If an environment variable, whose name is the concatenation of the strings which make up the key, the value of that variable is returned, overriding the value from the configuration file. Example usage:
 void showLIA(macs_session *sess) {
   char *value;
   fputs("(normal) Fetching cgi/LIA:",stderr);
   value=macs_get_config(sess,"cgi","LIA",NULL);
   if (!value) { fputs("No cgi/LIA found.\n",stderr); return; }
   fprintf(stderr,"%s\n",value);
   free(value);
 }
 
In this example, the environment variable "cgiLIA" would override the value in the configuration file.

char** macs_get_configs macs_session   sess,
int *    nodes,
const char *    key,
...   
 

Fetch several configuration values.

Parameters:
sess A MACS session
nodes The number of values in the array will be stored here.
key A NULL-terminated list of strings which make up the key.
Returns:
On success, a NULL-terminated array of strings, or NULL if the key was not found. Each string, and the array, should be free()d
Expose all values of named configuration array. Example usage:
 void showSFSs() {
   char **values;
   int nodes, i;
   fputs("(array) Fetching SFS/p",stderr);
   values=macs_get_configs(ctxp,&nodes,"SFS","p",NULL);
   if (!values) { fputs("No SFS/p found.\n",stderr); return; }
   fprintf(stderr,"(%d):",nodes);
   for (i=0; i < nodes; i++) {
     fprintf(stderr,"%s%s",values[i],i==nodes-1?"\n":",");
     free(values[i]);
   }
   if (!values) return;
   free(values);
 }
 
Note that there is no environment-variable override in this function.

char** macs_get_methods macs_session   sess,
int    service
 

Fetch a list of available methods.

Parameters:
sess A MACS session
service The service whose methods to list. One of MACS_AUS, MACS_RPS or MACS_ATS.
Returns:
On success, a NULL-terminated array of strings, or NULL if there was an error. Each string, and the array, should be free()d


Generated on Fri Aug 8 09:53:44 2003 for MACS Client C API by doxygen1.3-rc3