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

lcmaps_runvars.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  *     NIKHEF Amsterdam, the Netherlands
00009  */
00010 
00025 /*****************************************************************************
00026                             Include header files
00027 ******************************************************************************/
00028 #include "lcmaps_config.h"
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031 #include <string.h>
00032 #include <gssapi.h>
00033 
00034 /* LCMAPS includes */
00035 #include "lcmaps_log.h"
00036 #include "lcmaps_types.h"
00037 #include "lcmaps_utils.h"
00038 #include "lcmaps_arguments.h"
00039 #include "_lcmaps_runvars.h"
00040 
00041 /******************************************************************************
00042                              Define constants
00043 ******************************************************************************/
00044 #define NUMBER_OF_RUNVARS ((int)5)
00045 
00046 /******************************************************************************
00047                                Type definitions
00048 ******************************************************************************/
00049 
00050 /******************************************************************************
00051                           Module specific prototypes
00052 ******************************************************************************/
00053 
00054 /******************************************************************************
00055                        Define module specific variables
00056 ******************************************************************************/
00057 
00058 static lcmaps_argument_t runvars_list[] = {
00059     { "user_dn"     , "char *"           ,  0,   NULL},
00060     { "user_cred"   , "gss_cred_id_t"    ,  0,   NULL},
00061     { "lcmaps_cred" , "lcmaps_cred_id_t" ,  0,   NULL},
00062     { "job_request" , "lcmaps_request_t" ,  0,   NULL},
00063     { "job_request" , "char *"           ,  0,   NULL},
00064     { NULL          , NULL               , -1,   NULL}
00065 }; 
00067 static lcmaps_request_t job_request;
00068 static lcmaps_cred_id_t lcmaps_credential;
00069 
00070 /******************************************************************************
00071 Function:       lcmaps_extractRunVars()
00072 Description:    extract the variables from user credential that can be used by the plugins
00073 Parameters:
00074                 request:     the job request (RSL)
00075                 lcmaps_cred: the credential presented by the user
00076 Returns:        0 succes
00077                 1 failure
00078 ******************************************************************************/
00097 int lcmaps_extractRunVars(
00098         lcmaps_request_t request,
00099         lcmaps_cred_id_t lcmaps_cred
00100 )
00101 {
00102     int number_of_runvars=0;
00103 
00104     /* Get the number of variables
00105      */
00106     number_of_runvars = lcmaps_cntArgs(runvars_list);
00107     if (NUMBER_OF_RUNVARS != number_of_runvars)
00108     {
00109         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): conflict in number of run variables:\n");
00110         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): estimated = %d, defined = %d\n",
00111                      number_of_runvars,NUMBER_OF_RUNVARS);
00112         return 1;
00113     }
00114     lcmaps_log_debug(2,"Number of runvars: %d\n",NUMBER_OF_RUNVARS);
00115     lcmaps_log_debug(2,"Address of runvars_list (first element): 0x%x\n",runvars_list);
00116 
00117     /* Save request en credential in static variables
00118      */
00119     job_request=request;
00120     lcmaps_credential=lcmaps_cred;
00121 
00122     /* decompose request en credential heen
00123      * doe voor elke variabele lcmaps_setRunVars(name, type, value)
00124      */
00125     /* Set user_dn */
00126     lcmaps_log_debug(2,"Setting \"user_dn\": %s, address: 0x%x\n",lcmaps_credential.dn,&(lcmaps_credential.dn));
00127     if (lcmaps_setRunVars("user_dn" , "char *", (void *) &(lcmaps_credential.dn)) != 0)
00128     {
00129         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"user_dn\" variable\n");
00130         return 1;
00131     }
00132 
00133     /* Set user_cred */
00134     lcmaps_log_debug(2,"Setting \"user_cred\"\n");
00135     if (lcmaps_setRunVars("user_cred" , "gss_cred_id_t", (void *) &(lcmaps_credential.cred)) != 0)
00136     {
00137         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"user_cred\" variable\n");
00138         return 1;
00139     }
00140 
00141     /* Set lcmaps cred */
00142     lcmaps_log_debug(2,"Setting \"lcmaps_cred\"\n");
00143     if (lcmaps_setRunVars("lcmaps_cred" , "lcmaps_cred_id_t", (void *) &lcmaps_credential) != 0)
00144     {
00145         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"lcmaps_cred\" variable\n");
00146         return 1;
00147     }
00148 
00149     /* Set job_request */
00150     lcmaps_log_debug(2,"Setting \"job_request\" of type \"lcmaps_request_t\"\n");
00151     if (lcmaps_setRunVars("job_request" , "lcmaps_request_t", (void *) &job_request) != 0)
00152     {
00153         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"job_request\" variable of type \"lcmaps_request_t\"\n");
00154         return 1;
00155     }
00156     lcmaps_log_debug(2,"Setting \"job_request\" of type \"char *\"\n");
00157     if (lcmaps_setRunVars("job_request" , "char *", (void *) &job_request) != 0)
00158     {
00159         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"job_request\" variable of type \"char *\"\n");
00160         return 1;
00161     }
00162 
00163     return 0;
00164 }
00165 
00166 /******************************************************************************
00167 Function:       lcmaps_getRunVars()
00168 Description:    returns a void pointer to the requested value
00169 Parameters:
00170                 argName: name of the variable
00171                 argType: type of the variable
00172 
00173 Returns:        void pointer to the value or NULL
00174 ******************************************************************************/
00192 void * lcmaps_getRunVars(
00193         char *argName,
00194         char *argType
00195 )
00196 {
00197     /* do lcmaps_getArgValue with runvars_list and NUMBER_OF_RUNVARS
00198      */
00199     return lcmaps_getArgValue(argName, argType, NUMBER_OF_RUNVARS, runvars_list);
00200 }
00201 
00202 /******************************************************************************
00203 Function:       lcmaps_setRunVars()
00204 Description:    fill the runvars_list with a value for argName and argType
00205 Parameters:
00206                 argName: name of the runvars variable
00207                 argType: type of the runvars variable
00208                 values:  void pointer to the value
00209 
00210 Returns:        0 succes
00211                 -1 failure
00212 ******************************************************************************/
00233 int lcmaps_setRunVars(
00234         char *argName,
00235         char *argType,
00236         void *value
00237 )
00238 {
00239     lcmaps_argument_t *pargument=NULL;
00240 
00241     /* store address of 1st element of runvars_list in pargument,
00242      * the address of which can be passed on to lcmaps_setArgValue
00243      * (the address of runvars_list does not exist, since its only a symbol, not a value)
00244      */
00245     pargument=runvars_list;
00246 
00247     lcmaps_log_debug(2,"In lcmaps_setRunVars: Address of first element of runvars_list: 0x%x\n",runvars_list);
00248     lcmaps_log_debug(2,"In lcmaps_setRunVars: Address of address of first element of runvars_list: 0x%x\n",&pargument);
00249 
00250     return lcmaps_setArgValue(argName, argType, value, NUMBER_OF_RUNVARS, &pargument);
00251 }

Generated at Thu Mar 4 17:39:03 2004 for edg-lcmaps by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001