int main (void) { // Get Service ds3_client* client; ds3_request* request; ds3_error* error; ds3_get_service_response *response; uint64_t i; // Create a client from environment variables error = ds3_create_client_from_env(&client); handle_error(error); // Create the get service request. All requests to a DS3 appliance start this way. // All ds3_init_* functions return a ds3_request struct request = ds3_init_get_service(); // This performs the request to a DS3 appliance. // If there is an error 'error' will not be NULL // If the request completed successfully then 'error' will be NULL error = ds3_get_service(client, request, &response); ds3_free_request(request); handle_error(error); if(response->num_buckets == 0) { printf("No buckets returned\n"); ds3_free_service_response(response); ds3_free_creds(client->creds); ds3_free_client(client); return 0; } for (i = 0; i < response->num_buckets; i++) { ds3_bucket bucket = response->buckets[i]; printf("Bucket: (%s) created on %s\n", bucket.name->value, bucket.creation_date->value); } ds3_free_service_response(response); ds3_free_creds(client->creds); ds3_free_client(client); ds3_cleanup(); return 0; }
void stat_destroy_state(stat_state_t * State) { if (State->_service_response) ds3_free_service_response(State->_service_response); if (State->_bucket_response) ds3_free_bucket_response(State->_bucket_response); if (State->_bucket_name) free(State->_bucket_name); if (State->_object_name) free(State->_object_name); if (State->_marker) free(State->_marker); }
void dsi_init(globus_gfs_operation_t Operation, globus_gfs_session_info_t * SessionInfo) { config_t * config = NULL; globus_result_t result = GLOBUS_SUCCESS; char * access_id = NULL; char * secret_key = NULL; ds3_creds * bp_creds = NULL; ds3_client * bp_client = NULL; GlobusGFSName(dsi_init); /* Read in the config */ result = config_init(&config); if (result != GLOBUS_SUCCESS) goto cleanup; /* Lookup the access ID */ result = access_id_lookup(config->AccessIDFile, SessionInfo->username, &access_id, &secret_key); if (result != GLOBUS_SUCCESS) goto cleanup; /* Create the credentials */ bp_creds = ds3_create_creds(access_id, secret_key); if (!bp_creds) { result = GlobusGFSErrorMemory("ds3_create_creds"); goto cleanup; } /* Create the client */ bp_client = ds3_create_client(config->EndPoint, bp_creds); if (!bp_client) { result = GlobusGFSErrorMemory("ds3_create_client"); goto cleanup; } /* Test the credentials with a get-service call. */ ds3_get_service_response * response = NULL; result = gds3_get_service(bp_client, &response); ds3_free_service_response(response); if (result) goto cleanup; result = commands_init(Operation); cleanup: /* * Inform the server that we are done. If we do not pass in a username, the * server will use the name we mapped to with GSI. If we do not pass in a * home directory, the server will (1) look it up if we are root or * (2) leave it as the unprivileged user's home directory. * * As far as I can tell, the server keeps a pointer to home_directory and frees * it when it is done. */ globus_gridftp_server_finished_session_start(Operation, result, bp_client, // Session variable NULL, // username "/"); // home directory config_destroy(config); if (access_id) globus_free(access_id); if (secret_key) globus_free(secret_key); if (result != GLOBUS_SUCCESS) { ds3_free_creds(bp_creds); ds3_free_client(bp_client); } }