diff --git a/mediachanger/castorrmc/common/getconfent.c b/mediachanger/castorrmc/common/getconfent.c index ce4abd591012fb36002c12967738b95592e73de9..7aa62d1fe9c592b26be7e964c4a977d790e7ad7a 100644 --- a/mediachanger/castorrmc/common/getconfent.c +++ b/mediachanger/castorrmc/common/getconfent.c @@ -4,7 +4,7 @@ */ #ifndef lint -static char cvsId[] = "@(#)$RCSfile: getconfent.c,v $ $Revision: 1.13 $ $Date: 2005/04/18 11:03:14 $ CERN IT-PDP/DM Olof Barring"; +static char cvsId[] = "@(#)$RCSfile: getconfent.c,v $ $Revision: 1.14 $ $Date: 2005/05/23 08:49:16 $ CERN IT-PDP/DM Olof Barring"; #endif /* not lint */ #include <stdio.h> @@ -143,3 +143,65 @@ char DLL_DECL *getconfent_fromfile(filename,category, name, flags) return(getconfent_r(filename,category,name,flags,value,BUFSIZ+1)); } + +int DLL_DECL getconfent_parser(conf_val, result, count) + char **conf_val; + char ***result; + int **count; +{ + char *p,*q,*last; + int i=0; + + /* Counting the number of strings for the array */ + if ((p = strdup(*conf_val)) == NULL) { return -1; } + for (q = strtok(p," \t"); q != NULL; q = strtok(NULL," \t")) i++; + + /* Saving the index information to pass on later */ + (*count) = (int *)calloc(1, sizeof(int)); + **count = i; + + /* Allocating the necessary space and parsing the string */ + if ((p = strdup(*conf_val)) == NULL) { return -1; } + (*result) = (char **)calloc((i+1), sizeof(char *)); + if (result == NULL) { return -1; } + + i = 0 ; + for (q = strtok(p," \t");q != NULL; q = strtok(NULL," \t")) { (*result)[i++] = strdup(q); } + + return 0; +} + +int DLL_DECL getconfent_multi_fromfile(filename, category, name, flags, result, count) + char *filename; + char *category; + char *name; + int flags; + char ***result; + int **count; +{ + char *conf_val; + + if((conf_val = getconfent_fromfile(filename,category,name,flags)) == NULL){ return -1; } + + if ( getconfent_parser(&conf_val, result, count) == -1 ) {return -1;} + + return 0; +} + + + +int DLL_DECL getconfent_multi(category, name, flags, result, count) + char *category; + char *name; + int flags; + char ***result; + int **count; +{ + char *conf_val; + + if((conf_val = getconfent(category,name,flags)) == NULL) { return -1; } + + if( getconfent_parser(&conf_val, result, count) == -1 ) {return -1;} + + return 0; +} diff --git a/mediachanger/castorrmc/h/getconfent.h b/mediachanger/castorrmc/h/getconfent.h index 400ffb505d76fc8fd35b1b72bebdfacf42ab5dd9..88314af2b44499ac31081f25f943a54ba941d067 100644 --- a/mediachanger/castorrmc/h/getconfent.h +++ b/mediachanger/castorrmc/h/getconfent.h @@ -1,5 +1,5 @@ /* - * $Id: getconfent.h,v 1.1 2005/04/18 10:59:02 jdurand Exp $ + * $Id: getconfent.h,v 1.2 2005/05/23 08:49:46 mmarques Exp $ */ #ifndef __getconfent_h @@ -9,6 +9,8 @@ EXTERN_C char DLL_DECL *getconfent _PROTO((char *, char *, int)); EXTERN_C char DLL_DECL *getconfent_fromfile _PROTO((char *, char *, char *, int)); - +EXTERN_C int DLL_DECL getconfent_multi _PROTO((char *, char *, int, char ***, int **)); +EXTERN_C int DLL_DECL getconfent_multi_fromfile _PROTO((char *, char *, char *, int, char ***, int **)); +EXTERN_C int DLL_DECL getcontent_parser _PROTO((char **, char ***, int **)); #endif /* __getconfent_h */