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