getconf 0.1

getconf is a C program that can retrieve NAME=VALUE pairs from a configuration file.
getconf is a C program that can retrieve NAME=VALUE pairs from a configuration file.

Sample:

#include < stdio.h >
#include < stdlib.h >
#include < string.h >
#include "getconf.h"

int main( int argc, char *argv[] )
{
struct config c;
char *vars[MAX_LINES];
char *vals[MAX_LINES];
char *configfile = "getconf_test.conf";
int lines;
int count;

lines = open_file( configfile );
if ( lines < 0 )
{
fprintf( stderr, "Could not read config file %sn", configfile );
exit( EXIT_FAILURE );
}

get_config( &c );

for ( count = 0 ; count < lines ; count++ )
{
*(vars+count)=(char *)malloc(strlen(c.var[count]));
*(vals+count)=(char *)malloc(strlen(c.val[count]));
strcpy( *(vars+count), c.var[count] );
strcpy( *(vals+count), c.val[count] );
printf( "Variable: %sttValue: %sn", *(vars+count), *(vals+count) );
}

/* now cleanup */
for ( count = 0 ; count < lines ; count++ )
{
free( vars[count] );
free( vals[count] );
}
return 0;
}

last updated on:
March 13th, 2007, 15:53 GMT
price:
FREE!
developed by:
Kevin Waldron
license type:
GPL (GNU General Public License) 
category:
ROOT \ Utilities

FREE!

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Add your review!

SUBMIT