getconf is a C program that can retrieve NAME=VALUE pairs from a configuration file.. #Retrieve NAME #Retrieve VALUE #Configuration file #Getconf #Retrieve #NAME
getconf is a C program that can retrieve NAME=VALUE pairs from a configuration file.
#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; }
getconf 0.1
add to watchlist add to download basket send us an update REPORT- runs on:
- Linux
- filename:
- getconf.tar.gz
- main category:
- Utilities
- developer:
- visit homepage