upnp/src/gena/gena_device.c
static int create_url_list(
	/*! [in] . */
	memptr *url_list,
	/*! [out] . */
	URL_list *out)
{
    size_t URLcount = 0;
    size_t i;
    int return_code = 0;
    uri_type temp;
    token urls;
    token *URLS;

    urls.buff = url_list->buf;
    urls.size = url_list->length;
    URLS = &urls;

    out->size = 0;
    out->URLs = NULL;
    out->parsedURLs = NULL;

    for( i = 0; i < URLS->size; i++ ) {
        if( ( URLS->buff[i] == '<' ) && ( i + 1 < URLS->size ) ) {
            if( ( ( return_code = parse_uri( &URLS->buff[i + 1],
                                             URLS->size - i + 1,
                                             &temp ) ) == HTTP_SUCCESS )
                && ( temp.hostport.text.size != 0 ) ) {
                URLcount++;
            } else {
                if( return_code == UPNP_E_OUTOF_MEMORY ) {
                    return return_code;
                }
            }
        }
    }

    if( URLcount > 0 ) {
        out->URLs = malloc(URLS->size + 1);
        out->parsedURLs = malloc(sizeof(uri_type) * URLcount);
        if (!out->URLs || !out->parsedURLs) {
            free(out->URLs);
            free(out->parsedURLs);
            out->URLs = NULL;
            out->parsedURLs = NULL;
            return UPNP_E_OUTOF_MEMORY;
        }
        memcpy( out->URLs, URLS->buff, URLS->size );
        out->URLs[URLS->size] = 0;
        URLcount = 0;
        for( i = 0; i < URLS->size; i++ ) {
            if( ( URLS->buff[i] == '<' ) && ( i + 1 < URLS->size ) ) {
                if( ( ( return_code =
                        parse_uri( &out->URLs[i + 1], URLS->size - i + 1,
                                   &out->parsedURLs[URLcount] ) ) ==
                      HTTP_SUCCESS )
                    && ( out->parsedURLs[URLcount].hostport.text.size !=
                         0 ) ) {
                    URLcount++;
                } else {
                    if( return_code == UPNP_E_OUTOF_MEMORY ) {
                        free( out->URLs );
                        free( out->parsedURLs );
                        out->URLs = NULL;
                        out->parsedURLs = NULL;
                        return return_code;
                    }
                }
            }
        }
    }
    out->size = URLcount;

    return (int)URLcount;
}
/*!
 * \brief Function to parse the Callback header value in subscription requests.
 *
 * Takes in a buffer containing URLS delimited by '<' and '>'. The entire buffer
 * is copied into dynamic memory and stored in the URL_list. Pointers to the
 * individual urls within this buffer are allocated and stored in the URL_list.
 * Only URLs with network addresses are considered (i.e. host:port or domain name).
 *
 * \return The number of URLs parsed if successful, otherwise UPNP_E_OUTOF_MEMORY.
 */
\brief Function to parse the Callback header value in subscription requests.
Takes in a buffer containing URLS delimited by '<' and '>'. The entire buffer
is copied into dynamic memory and stored in the URL_list. Pointers to the
individual urls within this buffer are allocated and stored in the URL_list.
Only URLs with network addresses are considered .

\return The number of URLs parsed if successful, otherwise UPNP_E_OUTOF_MEMORY.
\ brief Function to parse the Callback header value in subscription requests . Takes in a buffer containing URLS delimited by ' < ' and ' > ' . The entire buffer is copied into dynamic memory and stored in the URL_list . Pointers to the individual urls within this buffer are allocated and stored in the URL_list . Only URLs with network addresses are considered . \ return The number of URLs parsed if successful otherwise UPNP_E_OUTOF_MEMORY .
static int create_url_list(
	memptr *url_list,
	URL_list *out)
{
    size_t URLcount = 0;
    size_t i;
    int return_code = 0;
    uri_type temp;
    token urls;
    token *URLS;
    urls.buff = url_list->buf;
    urls.size = url_list->length;
    URLS = &urls;
    out->size = 0;
    out->URLs = NULL;
    out->parsedURLs = NULL;
    for( i = 0; i < URLS->size; i++ ) {
        if( ( URLS->buff[i] == '<' ) && ( i + 1 < URLS->size ) ) {
            if( ( ( return_code = parse_uri( &URLS->buff[i + 1],
                                             URLS->size - i + 1,
                                             &temp ) ) == HTTP_SUCCESS )
                && ( temp.hostport.text.size != 0 ) ) {
                URLcount++;
            } else {
                if( return_code == UPNP_E_OUTOF_MEMORY ) {
                    return return_code;
                }
            }
        }
    }
    if( URLcount > 0 ) {
        out->URLs = malloc(URLS->size + 1);
        out->parsedURLs = malloc(sizeof(uri_type) * URLcount);
        if (!out->URLs || !out->parsedURLs) {
            free(out->URLs);
            free(out->parsedURLs);
            out->URLs = NULL;
            out->parsedURLs = NULL;
            return UPNP_E_OUTOF_MEMORY;
        }
        memcpy( out->URLs, URLS->buff, URLS->size );
        out->URLs[URLS->size] = 0;
        URLcount = 0;
        for( i = 0; i < URLS->size; i++ ) {
            if( ( URLS->buff[i] == '<' ) && ( i + 1 < URLS->size ) ) {
                if( ( ( return_code =
                        parse_uri( &out->URLs[i + 1], URLS->size - i + 1,
                                   &out->parsedURLs[URLcount] ) ) ==
                      HTTP_SUCCESS )
                    && ( out->parsedURLs[URLcount].hostport.text.size !=
                         0 ) ) {
                    URLcount++;
                } else {
                    if( return_code == UPNP_E_OUTOF_MEMORY ) {
                        free( out->URLs );
                        free( out->parsedURLs );
                        out->URLs = NULL;
                        out->parsedURLs = NULL;
                        return return_code;
                    }
                }
            }
        }
    }
    out->size = URLcount;
    return (int)URLcount;
}
static int create_url_list ( memptr * url_list , URL_list * out ) { size_t URLcount = 0 ; size_t i ; int return_code = 0 ; uri_type temp ; token urls ; token * URLS ; urls . buff = url_list -> buf ; urls . size = url_list -> length ; URLS = & urls ; out -> size = 0 ; out -> URLs = NULL ; out -> parsedURLs = NULL ; for ( i = 0 ; i < URLS -> size ; i ++ ) { if ( ( URLS -> buff [ i ] == ' ' ) && ( i + 1 < URLS -> size ) ) { if ( ( ( return_code = parse_uri ( & URLS -> buff [ i + 1 ] , URLS -> size - i + 1 , & temp ) ) == HTTP_SUCCESS ) && ( temp . hostport . text . size != 0 ) ) { URLcount ++ ; } else { if ( return_code == UPNP_E_OUTOF_MEMORY ) { return return_code ; } } } } if ( URLcount > 0 ) { out -> URLs = malloc ( URLS -> size + 1 ) ; out -> parsedURLs = malloc ( sizeof ( uri_type ) * URLcount ) ; if ( ! out -> URLs || ! out -> parsedURLs ) { free ( out -> URLs ) ; free ( out -> parsedURLs ) ; out -> URLs = NULL ; out -> parsedURLs = NULL ; return UPNP_E_OUTOF_MEMORY ; } memcpy ( out -> URLs , URLS -> buff , URLS -> size ) ; out -> URLs [ URLS -> size ] = 0 ; URLcount = 0 ; for ( i = 0 ; i < URLS -> size ; i ++ ) { if ( ( URLS -> buff [ i ] == ' ' ) && ( i + 1 < URLS -> size ) ) { if ( ( ( return_code = parse_uri ( & out -> URLs [ i + 1 ] , URLS -> size - i + 1 , & out -> parsedURLs [ URLcount ] ) ) == HTTP_SUCCESS ) && ( out -> parsedURLs [ URLcount ] . hostport . text . size != 0 ) ) { URLcount ++ ; } else { if ( return_code == UPNP_E_OUTOF_MEMORY ) { free ( out -> URLs ) ; free ( out -> parsedURLs ) ; out -> URLs = NULL ; out -> parsedURLs = NULL ; return return_code ; } } } } } out -> size = URLcount ; return ( int ) URLcount ; }
\brief Function to parse the Callback header value in subscription requests.
\ brief Function to parse the Callback header value in subscription requests .
/*! [in] . */ /*! [out] . */