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) 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  *     NIKHEF Amsterdam, the Netherlands
00016  */
00017 
00032 #ifndef LCMAPS_RUNVARS_C
00033 #define LCMAPS_RUNVARS_C
00034 
00035 /*****************************************************************************
00036                             Include header files
00037 ******************************************************************************/
00038 #include "lcmaps_config.h"
00039 #include <stdio.h>
00040 #include <stdlib.h>
00041 #include <string.h>
00042 #ifdef LCMAPS_GSI_MODE
00043 #   include <gssapi.h>
00044 #endif
00045 
00046 /* LCMAPS includes */
00047 #include "lcmaps_log.h"
00048 #include "lcmaps_types.h"
00049 #include "lcmaps_utils.h"
00050 #include "lcmaps_arguments.h"
00051 #include "_lcmaps_runvars.h"
00052 #include "_lcmaps_credential.h"
00053 
00054 /******************************************************************************
00055                              Define constants
00056 ******************************************************************************/
00057 #ifdef LCMAPS_GSI_MODE
00058 #   define NUMBER_OF_RUNVARS ((int)8)
00059 #else
00060 #   define NUMBER_OF_RUNVARS ((int)6)
00061 #endif
00062 
00063 /******************************************************************************
00064                                Type definitions
00065 ******************************************************************************/
00066 
00067 /******************************************************************************
00068                           Module specific prototypes
00069 ******************************************************************************/
00070 
00071 /******************************************************************************
00072                        Define module specific variables
00073 ******************************************************************************/
00074 
00075 static lcmaps_argument_t runvars_list[] = {
00076     { "user_dn"     , "char *"           ,  0,   NULL},
00077     { "lcmaps_cred" , "lcmaps_cred_id_t" ,  0,   NULL},
00078     { "job_request" , "lcmaps_request_t" ,  0,   NULL},
00079     { "job_request" , "char *"           ,  0,   NULL},
00080     { "fqan_list"   , "char **"          ,  0,   NULL},
00081     { "nfqan"       , "int"              ,  0,   NULL},
00082 #ifdef LCMAPS_GSI_MODE
00083     { "user_cred"   , "gss_cred_id_t"    ,  0,   NULL},
00084     { "gss_context" , "gss_ctx_id_t"     ,  0,   NULL},
00085 #endif /* LCMAPS_GSI_MODE */
00086     { NULL          , NULL               , -1,   NULL}
00087 }; 
00089 static lcmaps_request_t job_request;
00090 static lcmaps_cred_id_t lcmaps_credential;
00091 
00092 /******************************************************************************
00093 Function:       lcmaps_extractRunVars()
00094 Description:    extract the variables from user credential that can be used by the plugins
00095 Parameters:
00096                 request:     the job request (RSL)
00097                 lcmaps_cred: the credential presented by the user
00098 Returns:        0 succes
00099                 1 failure
00100 ******************************************************************************/
00119 int lcmaps_extractRunVars(
00120         lcmaps_request_t request,
00121         lcmaps_cred_id_t lcmaps_cred
00122 )
00123 {
00124     int number_of_runvars=0;
00125 
00126     /* Get the number of variables
00127      */
00128     number_of_runvars = lcmaps_cntArgs(runvars_list);
00129     if (NUMBER_OF_RUNVARS != number_of_runvars)
00130     {
00131         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): conflict in number of run variables:\n");
00132         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): estimated = %d, defined = %d\n",
00133                      number_of_runvars,NUMBER_OF_RUNVARS);
00134         return 1;
00135     }
00136     lcmaps_log_debug(2,"Number of runvars: %d\n",NUMBER_OF_RUNVARS);
00137     lcmaps_log_debug(2,"Address of runvars_list (first element): 0x%x\n",runvars_list);
00138 
00139     /* Save request en credential in static variables
00140      */
00141     job_request=request;
00142     lcmaps_credential=lcmaps_cred;
00143 
00144     /* decompose request en credential heen
00145      * doe voor elke variabele lcmaps_setRunVars(name, type, value)
00146      */
00147     /* Set user_dn */
00148     lcmaps_log_debug(2,"Setting \"user_dn\": %s, address: 0x%x\n",
00149                      lcmaps_credential.dn, &(lcmaps_credential.dn));
00150     if (lcmaps_setRunVars("user_dn" , "char *", (void *) &(lcmaps_credential.dn)) != 0)
00151     {
00152         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"user_dn\" variable\n");
00153         return 1;
00154     }
00155 
00156     /* Set the list of FQANs */
00157     lcmaps_log_debug(2,"Setting \"fqan_list\", address: 0x%x\n", &(lcmaps_credential.fqan));
00158     if (lcmaps_setRunVars("fqan_list" , "char **", (void *) &(lcmaps_credential.fqan)) != 0)
00159     {
00160         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"fqan_list\" variable\n");
00161         return 1;
00162     }
00163     /* Set the number of FQANs */
00164     lcmaps_log_debug(2,"Setting \"nfqan\": %d, address: 0x%x\n",
00165                      lcmaps_credential.nfqan, &(lcmaps_credential.nfqan));
00166     if (lcmaps_setRunVars("nfqan" , "int", (void *) &(lcmaps_credential.nfqan)) != 0)
00167     {
00168         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"nfqan\" variable\n");
00169         return 1;
00170     }
00171 
00172 #ifdef LCMAPS_GSI_MODE
00173     /* Set user_cred */
00174     lcmaps_log_debug(2,"Setting \"user_cred\"\n");
00175     if (lcmaps_setRunVars("user_cred" , "gss_cred_id_t", (void *) &(lcmaps_credential.cred)) != 0)
00176     {
00177         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"user_cred\" variable\n");
00178         return 1;
00179     }
00180     
00181     /* Set security context */
00182     lcmaps_log_debug(2,"Setting \"gss_context\"\n");
00183     if (lcmaps_setRunVars("gss_context" , "gss_ctx_id_t", (void *) &(lcmaps_credential.context)) != 0)
00184     {
00185         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"gss_context\" variable\n");
00186         return 1;
00187     }
00188 #endif /* LCMAPS_GSI_MODE */
00189 
00190     /* Set lcmaps cred */
00191     lcmaps_log_debug(2,"Setting \"lcmaps_cred\"\n");
00192     if (lcmaps_setRunVars("lcmaps_cred" , "lcmaps_cred_id_t", (void *) &lcmaps_credential) != 0)
00193     {
00194         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"lcmaps_cred\" variable\n");
00195         return 1;
00196     }
00197 
00198     /* Set job_request */
00199     lcmaps_log_debug(2,"Setting \"job_request\" of type \"lcmaps_request_t\"\n");
00200     if (lcmaps_setRunVars("job_request" , "lcmaps_request_t", (void *) &job_request) != 0)
00201     {
00202         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"job_request\" variable of type \"lcmaps_request_t\"\n");
00203         return 1;
00204     }
00205     lcmaps_log_debug(2,"Setting \"job_request\" of type \"char *\"\n");
00206     if (lcmaps_setRunVars("job_request" , "char *", (void *) &job_request) != 0)
00207     {
00208         lcmaps_log(0,"lcmaps.mod-lcmaps_extractRunVars(): error while setting \"job_request\" variable of type \"char *\"\n");
00209         return 1;
00210     }
00211 
00212     return 0;
00213 }
00214 
00215 /******************************************************************************
00216 Function:       lcmaps_getRunVars()
00217 Description:    returns a void pointer to the requested value
00218 Parameters:
00219                 argName: name of the variable
00220                 argType: type of the variable
00221 
00222 Returns:        void pointer to the value or NULL
00223 ******************************************************************************/
00241 void * lcmaps_getRunVars(
00242         char *argName,
00243         char *argType
00244 )
00245 {
00246     /* do lcmaps_getArgValue with runvars_list and NUMBER_OF_RUNVARS
00247      */
00248     return lcmaps_getArgValue(argName, argType, NUMBER_OF_RUNVARS, runvars_list);
00249 }
00250 
00251 /******************************************************************************
00252 Function:       lcmaps_setRunVars()
00253 Description:    fill the runvars_list with a value for argName and argType
00254 Parameters:
00255                 argName: name of the runvars variable
00256                 argType: type of the runvars variable
00257                 values:  void pointer to the value
00258 
00259 Returns:        0 succes
00260                 -1 failure
00261 ******************************************************************************/
00282 int lcmaps_setRunVars(
00283         char *argName,
00284         char *argType,
00285         void *value
00286 )
00287 {
00288     lcmaps_argument_t *pargument=NULL;
00289 
00290     /* store address of 1st element of runvars_list in pargument,
00291      * the address of which can be passed on to lcmaps_setArgValue
00292      * (the address of runvars_list does not exist, since its only a symbol, not a value)
00293      */
00294     pargument=runvars_list;
00295 
00296     lcmaps_log_debug(2,"In lcmaps_setRunVars: Address of first element of runvars_list: 0x%x\n",runvars_list);
00297     lcmaps_log_debug(2,"In lcmaps_setRunVars: Address of address of first element of runvars_list: 0x%x\n",&pargument);
00298 
00299     return lcmaps_setArgValue(argName, argType, value, NUMBER_OF_RUNVARS, &pargument);
00300 }
00301 
00302 #endif /* LCMAPS_RUNVARS_C */
00303 
00304 /******************************************************************************
00305 CVS Information:
00306     $Source: /cvs/jra1mw/org.glite.security.lcmaps/src/grid_credential_handling/lcmaps_runvars.c,v $
00307     $Date: 2005/02/27 01:30:41 $
00308     $Revision: 1.2 $
00309     $Author: msteenba $
00310 ******************************************************************************/

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