Hello

I hope you are doing well. I have been trying to get the attributes of a
remote file using the Globus GridFtp Client API. I am using the
globus_ftp_client_stat function to get the listing. However the function id
returning success but I am getting a NULL when I am seeing in the buffer. I
think the problem is somewhat allocating space to the pointers. I am a
novice in the area so any kind of help would be really appreciable.

Here's the part of my code:

int grid_ftp_getattributes(char *url){

    globus_byte_t **stat_buffer;
    globus_size_t *stat_buffer_length;globus_ftp_client_operationattr_t
attr;
    char *data;
    int result = 0;

    stat_buffer = (globus_byte_t **) malloc(sizeof(struct stat));
    stat_buffer_length = (globus_size_t *) malloc(8*sizeof(globus_size_t));

    if (globus_module_activate(GLOBUS_FTP_CLIENT_MODULE) != GLOBUS_SUCCESS)
{
         globus_libc_printf("\n\t\t ERROR : Failed to activate the FTP
Client module\n");
         return 1;
    }

    if (globus_ftp_client_operationattr_init(&attr) != GLOBUS_SUCCESS) {
         globus_libc_printf("\n\t\t ERROR : Failed to initialize
operationattr\n");
         return 1;
    }

globus_ftp_client_operationattr_set_authorization(&attr,GSS_C_NO_CREDENTIAL,
NULL,NULL,NULL,"CREDINTIALS HERE");

    globus_ftp_client_handleattr_t hattr;
    globus_ftp_client_handleattr_init(&hattr);

    if (globus_ftp_client_handle_init(&handle,&hattr) != GLOBUS_SUCCESS) {
         globus_libc_printf("\n\t\t ERROR : Failed to initialize the
handle\n");
         return 1;
    }
    done=GLOBUS_FALSE;
    result = globus_ftp_client_stat(&handle, url, &attr, stat_buffer,
stat_buffer_length, get_file_done_cb, 0);
    if (result != GLOBUS_SUCCESS) {
        printf("\nError in result\n");
        globus_object_t * err;
        err = globus_error_get(result);
        globus_libc_printf( "\n ERROR : %s",
globus_object_printable_to_string(err)); //??
        done = GLOBUS_TRUE;
    }
    data =(char *) *stat_buffer;
    printf("The values in actual buffer are %s \n", data);

    free(stat_buffer);
    free(stat_buffer_length);

    /* Block until the mutual exclusion lock, mutex, is acquired */
    globus_mutex_lock(&lock);
    while (!done) {

          /* Atomically release mutex and wait on cond. When the
             function returns, mutex has been reacquired*/
         globus_cond_wait(&cond, &lock);
    }
    /* Unlock the mutual exclusion lock, mutex, enabling
       another thread to acquire the mutex */
    globus_mutex_unlock(&lock);
    globus_ftp_client_handle_destroy(&handle);
    globus_module_deactivate(GLOBUS_FTP_CLIENT_MODULE);
    return 0;
}


I don't know where is the problem exactly. Actually my aim is to obtain the
attributes of remote file and copy then to a local "stat" structure. If you
be really helpful if you can throw some light on the same. I have been
trying for 2 days and no much help. Waiting for the reply.

Thanks in advance
-- 
Shobhit Puri
Fourth Year Undergraduate Student
Department of Information Technology
Indian Institute of Information Technology, Allahabad, India
Currently Intern at Karlsruhe Institute of Technology, Karlsruhe, Germany
Email: [email protected], [email protected]
 Phone: +49-15736153084, +91-9457011377

Reply via email to