Esempio n. 1
0
static int free_and_copy(char **s, const char *v) {
        int r;
        char *t;

        assert(s);

        r = strdup_or_null(isempty(v) ? NULL : v, &t);
        if (r < 0)
                return r;

        free(*s);
        *s = t;

        return 0;
}
Esempio n. 2
0
 
 // manifest request?
 if( request_type == AG_REQUEST_MANIFEST ) {
    
    con_data->pubinfo = CALLOC_LIST( struct AG_driver_publish_info, 1 );
    memcpy( con_data->pubinfo, &pubinfo, sizeof( struct AG_driver_publish_info ) );
 }
 
 con_data->ctx.hostname = md_con_data->remote_host;           // WARNING: not a copy; don't free this!
 con_data->ctx.method = md_con_data->method;
 con_data->ctx.size = ms_client_get_volume_blocksize( state->ms );
 con_data->ctx.err = 0;
 con_data->ctx.http_status = 0;
 con_data->ctx.driver = mi->driver;
 con_data->ctx.request_type = request_type;
 con_data->ctx.query_string = strdup_or_null( mi->query_string );
 
 // connection context is set up.
 // set up the driver state.
 if( con_data->ctx.request_type == AG_REQUEST_BLOCK ) {
    rc = AG_driver_connect_block( con_data->ctx.driver, &con_data->ctx );
 }
 
 AG_release_state( state );
 
 if( rc != 0 ) {
    
    errorf("AG_driver_connect_block(%s) rc = %d\n", md_con_data->url_path, rc );
    
    AG_HTTP_driver_error( md_con_data, AG_get_driver_HTTP_status( &con_data->ctx, 502 ) );