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) 2001 EU DataGrid.                                                                             
00003  * For license conditions see http://www.eu-datagrid.org/license.html                                          
00004  *
00005  * Copyright (c) 2001, 2002 by 
00006  *     Martijn Steenbakkers <martijn@nikhef.nl>,
00007  *     David Groep <davidg@nikhef.nl>,
00008  *     Oscar Koeroo <okoeroo@nikhef.nl>,
00009  *     NIKHEF Amsterdam, the Netherlands
00010  */
00011 
00024 /*****************************************************************************
00025                             Include header files
00026 ******************************************************************************/
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <string.h>
00030 
00031 /* LCMAPS includes */
00032 #include "lcmaps_arguments.h"
00033 
00034 /******************************************************************************
00035 Function:   lcmaps_setArgValue
00036 Description:
00037     Set the value of argType on the reserved place in values. 
00038     The place within values is determined by the place where argName is found
00039     in the arguments list
00040 
00041 Parameters:
00042     argName: name of argument
00043     argType: type of argument
00044     argcx:   number of arguments
00045     argvx:   array of arguments structures
00046 Returns:
00047     0:  success
00048     -1: failure (could not find structure with name argName)
00049 ******************************************************************************/
00050 
00072 int lcmaps_setArgValue(
00073         char *argName,
00074         char *argType,
00075         void *value,
00076         int argcx,
00077         lcmaps_argument_t **argvx
00078 )
00079 {
00080     int argNo = -1;
00081 
00082 
00083     /* find the argument name in the introSpect arguments list */
00084     if ((argNo = lcmaps_findArgNameAndType(argName, argType, argcx, *argvx)) == -1)
00085         return -1;
00086 
00087 /*    argvx[argNo]->value = value; */
00088     ((*argvx)[argNo]).value = value;
00089     return 0;
00090 }
00091 
00092 
00093 /******************************************************************************
00094 Function:   lcmaps_getArgValue
00095 Description:
00096     Gets the value of argType from values.
00097     The place within the lcmaps_argument_t values is determined by the argName listed in 
00098     lcmaps_argument_t *argvx.
00099     Returns a void pointer to the value.
00100 
00101 Parameters:
00102     argName: name of argument
00103     argType: type of argument
00104     argcx:   number of arguments
00105     argvx:   array of arguments structures
00106 Returns:
00107     void pointer to the value or NULL
00108 ******************************************************************************/
00109 
00131 void *lcmaps_getArgValue(
00132         char *argName,
00133         char *argType,
00134         int argcx,
00135         lcmaps_argument_t *argvx
00136 )
00137 {
00138     int argNo = -1;
00139 
00140     /* find the argument name in the introSpect arguments list */
00141     if ((argNo = lcmaps_findArgNameAndType(argName, argType, argcx, argvx)) == -1)
00142         return NULL;
00143 
00144     return (argvx[argNo].value);
00145 }
00146 
00147 
00148 /******************************************************************************
00149 Function:   lcmaps_findArgName
00150 Description:
00151     Search for argName in the arguments list.
00152     Returns the index to lcmaps_argument_t element.
00153 
00154 Parameters:
00155     argName: name of argument
00156     argcx:   number of arguments
00157     argvx:   array of arguments structures
00158 Returns:
00159     index to lcmaps_argument_t element
00160 ******************************************************************************/
00161 
00179 int lcmaps_findArgName(
00180         char *argName,
00181         int argcx,
00182         lcmaps_argument_t *argvx
00183 )
00184 {
00185     int i = 0;
00186 
00187     for (i = 0; i < argcx; i++)
00188     {
00189         if (strcmp(argName, argvx[i].argName) == 0) 
00190         return i;
00191     }
00192     return -1;
00193 }
00194 
00195 
00196 /******************************************************************************
00197 Function:   lcmaps_findArgNameAndType
00198 Description:
00199     Search for argName and Type in the arguments list.
00200     Returns the index to lcmaps_argument_t element.
00201 
00202 Parameters:
00203     argName: name of argument
00204     argType: type of argument
00205     argcx:   number of arguments
00206     argvx:   array of arguments structures
00207 Returns:
00208     index to lcmaps_argument_t element
00209 ******************************************************************************/
00210 
00230 int lcmaps_findArgNameAndType(
00231         char *argName,
00232         char *argType,
00233         int argcx,
00234         lcmaps_argument_t *argvx
00235 )
00236 {
00237     int i = 0;
00238 
00239     for (i = 0; i < argcx; i++)
00240     {
00241         if ((strcmp(argName, argvx[i].argName) == 0) && 
00242             (strcmp(argType, argvx[i].argType) == 0))
00243         return i;
00244     }
00245     return -1;
00246 }
00247 
00248 /******************************************************************************
00249 Function:   lcmaps_cntArgs
00250 Description:
00251     Count the number of arguments that are defined in a plug-in
00252     Returns this number.
00253 
00254 Parameters:
00255     argvx:   array of arguments structures
00256 Returns:
00257     the number of arguments
00258 ******************************************************************************/
00259 
00273 int lcmaps_cntArgs(lcmaps_argument_t *argvx)
00274 {
00275     int i = 0;
00276 
00277     while (argvx[i].argName != NULL) { i++; }
00278 
00279     return i;
00280 }

Generated on Sat Oct 2 02:18:26 2004 for edg-lcmaps by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002