globus_ftp_client_debug_plugin.example

The following example illustrates a typical use of the debug plugin. In this case, we configure a plugin instance to output log messages preceded by the process name and pid to a file named gridftp.log.

00001 int main(int argc, char *argv[])
00002 {
00003     globus_ftp_client_plugin_t restart_plugin;
00004     globus_ftp_client_handleattr_t handleattr;
00005     globus_ftp_client_handle_t handle;
00006     FILE * log;
00007     char text[256];
00008 
00009     /* Activate the necessary modules */
00010     globus_module_activate(GLOBUS_FTP_CLIENT_MODULE);
00011     globus_module_activate(GLOBUS_FTP_CLIENT_DEBUG_PLUGIN_MODULE);
00012 
00013     /* Configure plugin to show custom text, and send plugin data to
00014      * a custom log file
00015      */
00016     log = fopen("gridftp.log", "a");
00017     sprintf(text, "%s:%ld", argv[0], (long) getpid());
00018 
00019     globus_ftp_client_debug_plugin_init(&debug_plugin, log, text);
00020 
00021     /* Set up our client handle to use the new plugin */
00022     globus_ftp_client_handleattr_init(&handleattr);
00023     globus_ftp_client_handleattr_add_plugin(&handleattr, &debug_plugin);
00024     globus_ftp_client_handle_init(&handle, &handleattr);
00025 
00026     /* As this get is processed, data will be appended to our gridftp.log
00027      * file
00028      */
00029     globus_ftp_client_get(&handle,
00030                           "ftp://ftp.globus.org/pub/globus/README",
00031                           GLOBUS_NULL,
00032                           GLOBUS_NULL,
00033                           callback_fn,
00034                           GLOBUS_NULL);
00035 }

Generated on 5 Sep 2016 for globus_ftp_client by  doxygen 1.4.7