upnp/src/gena/gena_device.c
static int respond_ok(
	/*! [in] Socket connection of request. */
	SOCKINFO *info,
	/*! [in] Accepted duration. */
	int time_out,
	/*! [in] Accepted subscription. */
	subscription *sub,
	/*! [in] Http request. */
	http_message_t *request)
{
    int major;
    int minor;
    membuffer response;
    int return_code;
    char timeout_str[100];
    int upnp_timeout = UPNP_TIMEOUT;
    int rc = 0;

    http_CalcResponseVersion( request->major_version,
                              request->minor_version, &major, &minor );

    if( time_out >= 0 ) {
        rc = snprintf( timeout_str, sizeof ( timeout_str ),
                       "TIMEOUT: Second-%d", time_out );
    } else {
        memset( timeout_str, 0, sizeof( timeout_str ) );
        strncpy( timeout_str, "TIMEOUT: Second-infinite",
                 sizeof ( timeout_str ) - 1);
    }
    if (rc < 0 || (unsigned int) rc >= sizeof ( timeout_str ) ) {
        error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request ); 
        return UPNP_E_OUTOF_MEMORY;
    }

    membuffer_init( &response );
    response.size_inc = 30;
    if( http_MakeMessage(
        &response, major, minor,
        "R" "D" "S" "N" "Xc" "ssc" "scc",
        HTTP_OK,
        (off_t)0,
        X_USER_AGENT,
        "SID: ", sub->sid,
        timeout_str ) != 0 ) {
        membuffer_destroy( &response );
        error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
        return UPNP_E_OUTOF_MEMORY;
    }

    return_code = http_SendMessage( info, &upnp_timeout, "b",
                                    response.buf, response.length );

    membuffer_destroy( &response );

    return return_code;
}
/*!
 * \brief Returns OK message in the case of a subscription request.
 *
 * \return UPNP_E_SUCCESS if successful, otherwise the appropriate error code.
 */
\brief Returns OK message in the case of a subscription request.
\return UPNP_E_SUCCESS if successful, otherwise the appropriate error code.
\ brief Returns OK message in the case of a subscription request . \ return UPNP_E_SUCCESS if successful otherwise the appropriate error code .
static int respond_ok(
	SOCKINFO *info,
	int time_out,
	subscription *sub,
	http_message_t *request)
{
    int major;
    int minor;
    membuffer response;
    int return_code;
    char timeout_str[100];
    int upnp_timeout = UPNP_TIMEOUT;
    int rc = 0;
    http_CalcResponseVersion( request->major_version,
                              request->minor_version, &major, &minor );
    if( time_out >= 0 ) {
        rc = snprintf( timeout_str, sizeof ( timeout_str ),
                       "TIMEOUT: Second-%d", time_out );
    } else {
        memset( timeout_str, 0, sizeof( timeout_str ) );
        strncpy( timeout_str, "TIMEOUT: Second-infinite",
                 sizeof ( timeout_str ) - 1);
    }
    if (rc < 0 || (unsigned int) rc >= sizeof ( timeout_str ) ) {
        error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request ); 
        return UPNP_E_OUTOF_MEMORY;
    }
    membuffer_init( &response );
    response.size_inc = 30;
    if( http_MakeMessage(
        &response, major, minor,
        "R" "D" "S" "N" "Xc" "ssc" "scc",
        HTTP_OK,
        (off_t)0,
        X_USER_AGENT,
        "SID: ", sub->sid,
        timeout_str ) != 0 ) {
        membuffer_destroy( &response );
        error_respond( info, HTTP_INTERNAL_SERVER_ERROR, request );
        return UPNP_E_OUTOF_MEMORY;
    }
    return_code = http_SendMessage( info, &upnp_timeout, "b",
                                    response.buf, response.length );
    membuffer_destroy( &response );
    return return_code;
}
static int respond_ok ( SOCKINFO * info , int time_out , subscription * sub , http_message_t * request ) { int major ; int minor ; membuffer response ; int return_code ; char timeout_str [ 100 ] ; int upnp_timeout = UPNP_TIMEOUT ; int rc = 0 ; http_CalcResponseVersion ( request -> major_version , request -> minor_version , & major , & minor ) ; if ( time_out >= 0 ) { rc = snprintf ( timeout_str , sizeof ( timeout_str ) , " " , time_out ) ; } else { memset ( timeout_str , 0 , sizeof ( timeout_str ) ) ; strncpy ( timeout_str , " " , sizeof ( timeout_str ) - 1 ) ; } if ( rc < 0 || ( unsigned int ) rc >= sizeof ( timeout_str ) ) { error_respond ( info , HTTP_INTERNAL_SERVER_ERROR , request ) ; return UPNP_E_OUTOF_MEMORY ; } membuffer_init ( & response ) ; response . size_inc = 30 ; if ( http_MakeMessage ( & response , major , minor , " " " " " " " " " " " " " " , HTTP_OK , ( off_t ) 0 , X_USER_AGENT , " " , sub -> sid , timeout_str ) != 0 ) { membuffer_destroy ( & response ) ; error_respond ( info , HTTP_INTERNAL_SERVER_ERROR , request ) ; return UPNP_E_OUTOF_MEMORY ; } return_code = http_SendMessage ( info , & upnp_timeout , " " , response . buf , response . length ) ; membuffer_destroy ( & response ) ; return return_code ; }
\brief Returns OK message in the case of a subscription request.
\ brief Returns OK message in the case of a subscription request .
/*! [in] Socket connection of request. */ /*! [in] Accepted duration. */ /*! [in] Accepted subscription. */ /*! [in] Http request. */