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

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