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

lcmaps_arguments.c

Go to the documentation of this file.
00001 /*                                                                                                            
00002  * Copyright (c) Members of the EGEE Collaboration. 2004.
00003  * See http://eu-egee.org/partners/ for details on the copyright holders.
00004  * For license conditions see the license file or
00005  * http://eu-egee.org/license.html
00006  */
00007 
00008 /*                                                                                                            
00009  * Copyright (c) 2001 EU DataGrid.                                                                             
00010  * For license conditions see http://www.eu-datagrid.org/license.html                                          
00011  *
00012  * Copyright (c) 2001, 2002 by 
00013  *     Martijn Steenbakkers <martijn@nikhef.nl>,
00014  *     David Groep <davidg@nikhef.nl>,
00015  *     Oscar Koeroo <okoeroo@nikhef.nl>,
00016  *     NIKHEF Amsterdam, the Netherlands
00017  */
00018 
00031 /*****************************************************************************
00032                             Include header files
00033 ******************************************************************************/
00034 #include <stdio.h>
00035 #include <stdlib.h>
00036 #include <string.h>
00037 
00038 /* LCMAPS includes */
00039 #include "lcmaps_arguments.h"
00040 
00041 /******************************************************************************
00042 Function:   lcmaps_setArgValue
00043 Description:
00044     Fill the "value" field of the argument with name "argName" and type "argType"
00045     with value.
00046     The argument list is searched for the combination (argName,argType).
00047 
00048 Parameters:
00049     argName: name of argument
00050     argType: type of argument
00051     argcx:   number of arguments
00052     argvx:   array of arguments structures
00053 Returns:
00054     0:  success
00055     -1: failure (could not find structure with name argName)
00056 ******************************************************************************/
00057 
00080 int lcmaps_setArgValue(
00081         char *argName,
00082         char *argType,
00083         void *value,
00084         int argcx,
00085         lcmaps_argument_t **argvx
00086 )
00087 {
00088     int argNo = -1;
00089 
00090 
00091     /* find the argument name in the introSpect arguments list */
00092     if ((argNo = lcmaps_findArgNameAndType(argName, argType, argcx, *argvx)) == -1)
00093         return -1;
00094 
00095     ((*argvx)[argNo]).value = value;
00096     return 0;
00097 }
00098 
00099 
00100 /******************************************************************************
00101 Function:   lcmaps_getArgValue
00102 Description:
00103     Gets the value of argType from values.
00104     The place within the lcmaps_argument_t values is determined by the argName listed in 
00105     lcmaps_argument_t *argvx.
00106     Returns a void pointer to the value.
00107 
00108 Parameters:
00109     argName: name of argument
00110     argType: type of argument
00111     argcx:   number of arguments
00112     argvx:   array of arguments structures
00113 Returns:
00114     void pointer to the value or NULL
00115 ******************************************************************************/
00116 
00138 void *lcmaps_getArgValue(
00139         char *argName,
00140         char *argType,
00141         int argcx,
00142         lcmaps_argument_t *argvx
00143 )
00144 {
00145     int argNo = -1;
00146 
00147     /* find the argument name in the introSpect arguments list */
00148     if ((argNo = lcmaps_findArgNameAndType(argName, argType, argcx, argvx)) == -1)
00149         return NULL;
00150 
00151     return (argvx[argNo].value);
00152 }
00153 
00154 
00155 /******************************************************************************
00156 Function:   lcmaps_findArgName
00157 Description:
00158     Search for argName in the arguments list.
00159     Returns the index to lcmaps_argument_t element.
00160 
00161 Parameters:
00162     argName: name of argument
00163     argcx:   number of arguments
00164     argvx:   array of arguments structures
00165 Returns:
00166     index to lcmaps_argument_t element
00167 ******************************************************************************/
00168 
00186 int lcmaps_findArgName(
00187         char *argName,
00188         int argcx,
00189         lcmaps_argument_t *argvx
00190 )
00191 {
00192     int i = 0;
00193 
00194     for (i = 0; i < argcx; i++)
00195     {
00196         if (strcmp(argName, argvx[i].argName) == 0) 
00197         return i;
00198     }
00199     return -1;
00200 }
00201 
00202 
00203 /******************************************************************************
00204 Function:   lcmaps_findArgNameAndType
00205 Description:
00206     Search for argName and Type in the arguments list.
00207     Returns the index to lcmaps_argument_t element.
00208 
00209 Parameters:
00210     argName: name of argument
00211     argType: type of argument
00212     argcx:   number of arguments
00213     argvx:   array of arguments structures
00214 Returns:
00215     index to lcmaps_argument_t element
00216 ******************************************************************************/
00217 
00237 int lcmaps_findArgNameAndType(
00238         char *argName,
00239         char *argType,
00240         int argcx,
00241         lcmaps_argument_t *argvx
00242 )
00243 {
00244     int i = 0;
00245 
00246     for (i = 0; i < argcx; i++)
00247     {
00248         if ((strcmp(argName, argvx[i].argName) == 0) && 
00249             (strcmp(argType, argvx[i].argType) == 0))
00250         return i;
00251     }
00252     return -1;
00253 }
00254 
00255 /******************************************************************************
00256 Function:   lcmaps_cntArgs
00257 Description:
00258     Count the number of arguments that are defined in a plug-in
00259     Returns this number.
00260 
00261 Parameters:
00262     argvx:   array of arguments structures
00263 Returns:
00264     the number of arguments
00265 ******************************************************************************/
00266 
00280 int lcmaps_cntArgs(lcmaps_argument_t *argvx)
00281 {
00282     int i = 0;
00283 
00284     while (argvx[i].argName != NULL) { i++; }
00285 
00286     return i;
00287 }

Generated on Sun May 29 21:22:10 2005 for lcmaps by doxygen 1.3.5