src/microspdy/structures.c File Reference

Functions for handling most of the structures in defined in structures.h. More...

#include "platform.h"
#include "structures.h"
#include "internal.h"
#include "session.h"
#include <ctype.h>
Include dependency graph for structures.c:

Go to the source code of this file.

Functions

int SPDYF_name_value_is_empty (struct SPDY_NameValue *container)
struct SPDY_NameValueSPDY_name_value_create ()
int SPDY_name_value_add (struct SPDY_NameValue *container, const char *name, const char *value)
const char *const * SPDY_name_value_lookup (struct SPDY_NameValue *container, const char *name, int *num_values)
void SPDY_name_value_destroy (struct SPDY_NameValue *container)
int SPDY_name_value_iterate (struct SPDY_NameValue *container, SPDY_NameValueIterator iterator, void *iterator_cls)
void SPDY_destroy_response (struct SPDY_Response *response)
struct SPDYF_Response_QueueSPDYF_response_queue_create (bool is_data, void *data, size_t data_size, struct SPDY_Response *response, struct SPDYF_Stream *stream, bool closestream, SPDYF_ResponseQueueResultCallback frqcb, void *frqcb_cls, SPDY_ResponseResultCallback rrcb, void *rrcb_cls)
void SPDYF_response_queue_destroy (struct SPDYF_Response_Queue *response_queue)
ssize_t SPDYF_name_value_to_stream (struct SPDY_NameValue *container[], int num_containers, void **stream)
int SPDYF_name_value_from_stream (void *stream, size_t size, struct SPDY_NameValue **container)

Detailed Description

Functions for handling most of the structures in defined in structures.h.

Author:
Andrey Uzunov

Definition in file structures.c.


Function Documentation

void SPDY_destroy_response ( struct SPDY_Response response  ) 

Destroy a response structure. It should be called for all objects returned by SPDY_build_response*() functions to free the memory associated with the prepared response. It is safe to call this function not before being sure that the response will not be used by the lib anymore, this means after SPDY_ResponseResultCallback callbacks were called for all calls to SPDY_queue_response() passing this response.

Parameters:
response to destroy

Definition at line 273 of file structures.c.

References SPDY_Response::data, SPDY_Response::headers, and NULL.

Referenced by curl_header_cb(), response_done_callback(), run(), and spdy_callback_response_done().

Here is the caller graph for this function:

int SPDY_name_value_add ( struct SPDY_NameValue container,
const char *  name,
const char *  value 
)

Add name/value pair to a NameValue structure. SPDY_NO will be returned if the name/value pair is already in the structure. It is legal to add different values for the same name.

Parameters:
container structure to which the new pair is added
name for the value. Null-terminated string.
value the value itself. Null-terminated string.
Returns:
SPDY_NO on error or SPDY_YES on success

Definition at line 56 of file structures.c.

References SPDY_NameValue::name, SPDY_NameValue::next, NULL, SPDY_NameValue::num_values, SPDY_NameValue::prev, SPDY_INPUT_ERROR, SPDY_NO, SPDY_YES, SPDYF_name_value_is_empty(), and SPDY_NameValue::value.

Referenced by curl_header_cb(), SPDY_build_response(), spdy_handler_new_stream(), and SPDYF_name_value_from_stream().

Here is the call graph for this function:

Here is the caller graph for this function:

struct SPDY_NameValue* SPDY_name_value_create (  )  [read]

Create a new NameValue structure. It is needed for putting inside the HTTP headers and their values for a response. The user should later destroy alone the structure.

Returns:
hendler to the new empty structure or NULL on error

Definition at line 42 of file structures.c.

References NULL.

Referenced by SPDY_build_response(), spdy_handler_new_stream(), SPDYF_name_value_from_stream(), and standard_request_handler().

Here is the caller graph for this function:

void SPDY_name_value_destroy ( struct SPDY_NameValue container  ) 

Destroy a NameValue structure. Use this function to destroy only objects which, after passed to, will not be destroied by other functions.

Definition at line 212 of file structures.c.

References SPDY_NameValue::name, SPDY_NameValue::next, NULL, SPDY_NameValue::num_values, and SPDY_NameValue::value.

Referenced by curl_header_cb(), run(), SPDY_build_response(), SPDY_destroy_request(), spdy_handler_new_stream(), SPDYF_name_value_from_stream(), and SPDYF_stream_destroy().

Here is the caller graph for this function:

int SPDY_name_value_iterate ( struct SPDY_NameValue container,
SPDY_NameValueIterator  iterator,
void *  iterator_cls 
)

Iterate over name/value structure.

Parameters:
container structure which to iterate over
iterator callback to call on each name/value pair; maybe NULL (then just count headers)
iterator_cls extra argument to iterator
Returns:
number of entries iterated over

Definition at line 231 of file structures.c.

References SPDY_NameValue::name, SPDY_NameValue::next, NULL, SPDY_NameValue::num_values, SPDY_INPUT_ERROR, SPDY_YES, SPDYF_name_value_is_empty(), and SPDY_NameValue::value.

Referenced by standard_request_handler().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* const* SPDY_name_value_lookup ( struct SPDY_NameValue container,
const char *  name,
int *  num_values 
)

Lookup value for a name in a name/value structure.

Parameters:
container structure in which to lookup
name the name to look for
num_values length of the returned array with values
Returns:
NULL if no such item was found, or an array containing the values

Definition at line 184 of file structures.c.

References SPDY_NameValue::name, SPDY_NameValue::next, NULL, SPDY_NameValue::num_values, SPDYF_name_value_is_empty(), and SPDY_NameValue::value.

Referenced by curl_header_cb().

Here is the call graph for this function:

Here is the caller graph for this function:

int SPDYF_name_value_from_stream ( void *  stream,
size_t  size,
struct SPDY_NameValue **  container 
)

Transforms raw binary decomressed stream of headers into SPDY_NameValue, containing all of the headers and values.

Parameters:
stream that is to be transformed
size length of the stream
container will contain the newly created SPDY_NameValue container. Should point to NULL.
Returns:
SPDY_YES on success SPDY_NO on memory error SPDY_INPUT_ERROR if the provided stream is not valid

Definition at line 539 of file structures.c.

References SPDY_NameValue::name, NULL, SPDY_INPUT_ERROR, SPDY_name_value_add(), SPDY_name_value_create(), SPDY_name_value_destroy(), SPDY_NO, SPDY_YES, and SPDY_NameValue::value.

Referenced by spdyf_handler_read_syn_stream().

Here is the call graph for this function:

Here is the caller graph for this function:

int SPDYF_name_value_is_empty ( struct SPDY_NameValue container  ) 

Checks if the container is empty, i.e. created but no values were added to it.

Parameters:
container 
Returns:
SPDY_YES if empty SPDY_NO if not

Definition at line 35 of file structures.c.

References SPDY_NameValue::name, NULL, SPDY_NO, SPDY_YES, SPDYF_ASSERT, and SPDY_NameValue::value.

Referenced by SPDY_build_response(), SPDY_name_value_add(), SPDY_name_value_iterate(), and SPDY_name_value_lookup().

Here is the caller graph for this function:

ssize_t SPDYF_name_value_to_stream ( struct SPDY_NameValue container[],
int  num_containers,
void **  stream 
)

Transforms array of objects of name/values tuples, containing HTTP headers, into raw binary stream. The resulting stream is ready to be compressed and sent.

Parameters:
container one or more SPDY_NameValue objects. Each object contains multiple number of name/value tuples.
num_containers length of the array
stream will contain the resulting stream. Should point to NULL.
Returns:
length of stream or value less than 0 indicating error

Definition at line 449 of file structures.c.

References SPDY_NameValue::name, SPDY_NameValue::next, NULL, SPDY_NameValue::num_values, SPDYF_ASSERT, and SPDY_NameValue::value.

Referenced by SPDY_build_response().

Here is the caller graph for this function:

struct SPDYF_Response_Queue* SPDYF_response_queue_create ( bool  is_data,
void *  data,
size_t  data_size,
struct SPDY_Response response,
struct SPDYF_Stream stream,
bool  closestream,
SPDYF_ResponseQueueResultCallback  frqcb,
void *  frqcb_cls,
SPDY_ResponseResultCallback  rrcb,
void *  rrcb_cls 
) [read]

Creates one or more new SPDYF_Response_Queue object to be put on the response queue.

Parameters:
is_data whether new data frame or new control frame will be crerated
data the row stream which will be used as the body of the frame
data_size length of data
response object, part of which is the frame
stream on which data is to be sent
closestream TRUE if the frame must close the stream (with flag)
frqcb callback to notify application layer when the frame has been sent or discarded
frqcb_cls closure for frqcb
rrcb callback used by the application layer to notify the application when the frame has been sent or discarded. frqcb will call it
rrcb_cls closure for rrcb
Returns:
double linked list of SPDYF_Response_Queue structures: one or more frames are returned based on the size of the data

Definition at line 284 of file structures.c.

References SPDYF_Response_Queue::control_frame, SPDYF_Response_Queue::data, SPDYF_Response_Queue::data_frame, SPDYF_Response_Queue::data_size, SPDYF_Response_Queue::frqcb, SPDYF_Response_Queue::frqcb_cls, SPDYF_Response_Queue::is_data, SPDYF_Response_Queue::next, NULL, SPDYF_Response_Queue::prev, SPDYF_Response_Queue::process_response_handler, SPDY_Response::rcb, SPDYF_Response_Queue::response, SPDYF_Response_Queue::rrcb, SPDYF_Response_Queue::rrcb_cls, SPDY_CONTROL_FRAME_TYPES_SYN_REPLY, SPDY_DATA_FLAG_FIN, SPDY_MAX_SUPPORTED_FRAME_SIZE, SPDY_SYN_REPLY_FLAG_FIN, SPDY_VERSION, SPDYF_ASSERT, SPDYF_handler_write_data(), SPDYF_handler_write_syn_reply(), SPDYF_Response_Queue::stream, and SPDYF_Stream::stream_id.

Referenced by SPDY_queue_response(), and SPDYF_handler_write_data().

Here is the call graph for this function:

Here is the caller graph for this function:

void SPDYF_response_queue_destroy ( struct SPDYF_Response_Queue response_queue  ) 

Destroys SPDYF_Response_Queue structure and whatever is in it.

Parameters:
response_queue to destroy

Definition at line 429 of file structures.c.

References SPDYF_Response_Queue::control_frame, SPDYF_Response_Queue::data, SPDYF_Response_Queue::data_frame, SPDYF_Response_Queue::is_data, SPDY_CONTROL_FRAME_TYPES_GOAWAY, and SPDY_CONTROL_FRAME_TYPES_RST_STREAM.

Referenced by SPDY_queue_response(), SPDYF_session_destroy(), and SPDYF_session_write().

Here is the caller graph for this function:


Generated on 15 Oct 2014 for GNU libmicrohttpd by  doxygen 1.6.1