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

lcmaps_plugin_example.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 
00041 
00042 /*****************************************************************************
00043                             Include header files
00044 ******************************************************************************/
00045 #include "lcmaps_config.h"
00046 #include <stdio.h>
00047 #include <stdlib.h>
00048 #include <string.h>
00049 #ifdef LCMAPS_GSI_MODE
00050 #   include <gssapi.h>
00051 #endif
00052 
00053 #include "lcmaps_modules.h"
00054 #include "lcmaps_arguments.h"
00055 
00056 /******************************************************************************
00057                                 Definitions
00058 ******************************************************************************/
00059 
00060 /******************************************************************************
00061                           Module specific prototypes
00062 ******************************************************************************/
00063 
00064 /******************************************************************************
00065                        Define module specific variables
00066 ******************************************************************************/
00067 
00068 /******************************************************************************
00069 Function:   plugin_introspect
00070 Description:
00071     return list of required arguments
00072 Parameters:
00073 
00074 Returns:
00075     LCMAPS_MOD_SUCCESS : succes
00076     LCMAPS_MOD_FAIL    : failure
00077 ******************************************************************************/
00090 int plugin_introspect(
00091         int * argc,
00092         lcmaps_argument_t ** argv
00093 )
00094 {
00095     static lcmaps_argument_t argList[] = {
00096         { "job_request"  , "lcmaps_request_t" ,  1,   NULL},
00097 #ifdef LCMAPS_GSI_MODE
00098         { "user_cred"    , "gss_cred_id_t"    ,  0,   NULL},
00099 #endif
00100         { "user_dn"      , "char *"           ,  0,   NULL},
00101         { "job_request"  , "char *"           ,  0,   NULL},
00102         { NULL           , NULL               , -1,   NULL}
00103     };
00104 
00105     lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_introspect(): introspecting\n");
00106 
00107     *argv = argList;
00108     *argc = lcmaps_cntArgs(argList);
00109     lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_introspect(): address first argument: 0x%x\n",argList);
00110 
00111     return LCMAPS_MOD_SUCCESS;
00112 }
00113 
00114 
00115 /******************************************************************************
00116 Function:   plugin_initialize
00117 Description:
00118     Initialize plugin
00119 Parameters:
00120     argc, argv
00121     argv[0]: the name of the plugin
00122 Returns:
00123     LCMAPS_MOD_SUCCESS : succes
00124     LCMAPS_MOD_FAIL    : failure
00125     LCMAPS_MOD_NOFILE  : db file not found (will halt LCMAPS initialization)
00126 ******************************************************************************/
00144 int plugin_initialize(
00145         int argc,
00146         char ** argv
00147 )
00148 {
00149     int i;
00150 
00151     lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_initialize(): passed arguments:\n");
00152     for (i=0; i < argc; i++)
00153     {
00154         lcmaps_log_debug(2,"\tlcmaps_plugin_example-plugin_initialize(): arg %d is %s\n",
00155              i,argv[i]);
00156     }
00157 
00158     return LCMAPS_MOD_SUCCESS;
00159 }
00160 
00161 /******************************************************************************
00162 Function:   plugin_run
00163 Description:
00164     Gather credentials for LCMAPS
00165 Parameters:
00166     argc: number of arguments
00167     argv: list of arguments
00168 Returns:
00169     LCMAPS_MOD_SUCCESS: authorization succeeded
00170     LCMAPS_MOD_FAIL   : authorization failed
00171 ******************************************************************************/
00187 int plugin_run(
00188         int argc,
00189         lcmaps_argument_t * argv
00190 )
00191 {
00192     lcmaps_request_t * prequest=NULL;
00193 #ifdef LCMAPS_GSI_MODE
00194     gss_cred_id_t * pcred;
00195     gss_cred_id_t cred;
00196 #endif
00197 
00198     char ** pstring;
00199 
00200     lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run():\n");
00201 
00202     /*
00203      * Try to get the ordered values:
00204      */
00205     if ( ( pstring = (char **) lcmaps_getArgValue("job_request", "char *", argc, argv) ) )
00206         lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run(): job_request: %s\n",*pstring);
00207     else
00208         lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run(): could not get value of job_request !\n");
00209 
00210     if ( ( pstring = (char **) lcmaps_getArgValue("user_dn", "char *", argc, argv) ) )
00211         lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run(): user_dn: %s\n",*pstring);
00212     else
00213         lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run(): could not get value of user_dn !\n");
00214 
00215     if ( ( prequest = (lcmaps_request_t *) lcmaps_getArgValue("job_request", "lcmaps_request_t", argc, argv) ) )
00216         lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run(): job_request: %s\n",*prequest);
00217     else
00218         lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run(): could not get value of job_request !\n");
00219 
00220 #ifdef LCMAPS_GSI_MODE
00221     if ( ( pcred = (gss_cred_id_t *) lcmaps_getArgValue("user_cred", "gss_cred_id_t", argc, argv) ) )
00222     {
00223         lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run(): address user_cred: %p\n",pcred);
00224         lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run(): value user_cred: %p\n",*pcred);
00225         cred=*pcred;
00226         if (cred) {
00227             lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run(): inside value user_cred: %p\n",*(int *)(cred));
00228         }
00229     }
00230     else
00231         lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run(): could not get address of user_cred !\n");
00232 #endif
00233 
00234     lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_run(): address first argument: 0x%x\n",argv);
00235 
00236     /* succes */
00237     return LCMAPS_MOD_SUCCESS;
00238 
00239  fail_example:
00240     return LCMAPS_MOD_FAIL;
00241 }
00242 
00243 /******************************************************************************
00244 Function:   plugin_terminate
00245 Description:
00246     Terminate plugin
00247 Parameters:
00248 
00249 Returns:
00250     LCMAPS_MOD_SUCCESS : succes
00251     LCMAPS_MOD_FAIL    : failure
00252 ******************************************************************************/
00259 int plugin_terminate()
00260 {
00261     lcmaps_log_debug(1,"\tlcmaps_plugin_example-plugin_terminate(): terminating\n");
00262 
00263     return LCMAPS_MOD_SUCCESS;
00264 }
00267 /******************************************************************************
00268 CVS Information:
00269     $Source: /cvs/jra1mw/org.glite.security.lcmaps/examples/lcmaps_plugin_example.c,v $
00270     $Date: 2005/02/27 01:30:40 $
00271     $Revision: 1.4 $
00272     $Author: msteenba $
00273 ******************************************************************************/

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