GSK Reference Manual | ||||
---|---|---|---|---|
GskXmlrpcArray; GskXmlrpcStruct; GskXmlrpcValue; GskXmlrpcNamedValue; GskXmlrpcRequest; GskXmlrpcResponse; GskXmlrpcParser; enum GskXmlrpcType; GskXmlrpcStruct* gsk_xmlrpc_struct_new (void); void gsk_xmlrpc_struct_free (GskXmlrpcStruct *structure); void gsk_xmlrpc_struct_add_int32 (GskXmlrpcStruct *structure, const char *member_name, gint32 value); void gsk_xmlrpc_struct_add_boolean (GskXmlrpcStruct *structure, const char *member_name, gboolean value); void gsk_xmlrpc_struct_add_double (GskXmlrpcStruct *structure, const char *member_name, gdouble value); void gsk_xmlrpc_struct_add_string (GskXmlrpcStruct *structure, const char *member_name, const char *value); void gsk_xmlrpc_struct_add_date (GskXmlrpcStruct *structure, const char *member_name, gulong value); void gsk_xmlrpc_struct_add_data (GskXmlrpcStruct *structure, const char *member_name, GByteArray *data); void gsk_xmlrpc_struct_add_struct (GskXmlrpcStruct *structure, const char *member_name, GskXmlrpcStruct *substructure); void gsk_xmlrpc_struct_add_array (GskXmlrpcStruct *structure, const char *member_name, GskXmlrpcArray *array); gboolean gsk_xmlrpc_struct_peek_date (GskXmlrpcStruct *structure, const char *member_name, gulong *out); gboolean gsk_xmlrpc_struct_peek_boolean (GskXmlrpcStruct *structure, const char *member_name, gboolean *out); gboolean gsk_xmlrpc_struct_peek_double (GskXmlrpcStruct *structure, const char *member_name, double *out); GskXmlrpcStruct* gsk_xmlrpc_struct_peek_struct (GskXmlrpcStruct *structure, const char *member_name); const GByteArray* gsk_xmlrpc_struct_peek_data (GskXmlrpcStruct *structure, const char *member_name); GskXmlrpcArray* gsk_xmlrpc_struct_peek_array (GskXmlrpcStruct *structure, const char *member_name); const char* gsk_xmlrpc_struct_peek_string (GskXmlrpcStruct *structure, const char *member_name); gboolean gsk_xmlrpc_struct_peek_int32 (GskXmlrpcStruct *structure, const char *member_name, gint32 *out); GskXmlrpcArray* gsk_xmlrpc_array_new (void); void gsk_xmlrpc_array_free (GskXmlrpcArray *array); void gsk_xmlrpc_array_add_int32 (GskXmlrpcArray *array, gint32 value); void gsk_xmlrpc_array_add_boolean (GskXmlrpcArray *array, gboolean value); void gsk_xmlrpc_array_add_double (GskXmlrpcArray *array, gdouble value); void gsk_xmlrpc_array_add_string (GskXmlrpcArray *array, const char *value); void gsk_xmlrpc_array_add_date (GskXmlrpcArray *array, gulong value); void gsk_xmlrpc_array_add_data (GskXmlrpcArray *array, GByteArray *data); void gsk_xmlrpc_array_add_struct (GskXmlrpcArray *array, GskXmlrpcStruct *substructure); void gsk_xmlrpc_array_add_array (GskXmlrpcArray *array, GskXmlrpcArray *subarray); GskXmlrpcRequest* gsk_xmlrpc_request_new (GskXmlrpcStream *xmlrpc_stream); GskXmlrpcRequest* gsk_xmlrpc_request_ref (GskXmlrpcRequest *request); void gsk_xmlrpc_request_unref (GskXmlrpcRequest *request); void gsk_xmlrpc_request_set_name (GskXmlrpcRequest *request, const char *name); void gsk_xmlrpc_request_add_int32 (GskXmlrpcRequest *request, gint32 value); void gsk_xmlrpc_request_add_boolean (GskXmlrpcRequest *request, gboolean value); void gsk_xmlrpc_request_add_double (GskXmlrpcRequest *request, gdouble value); void gsk_xmlrpc_request_add_string (GskXmlrpcRequest *request, const char *value); void gsk_xmlrpc_request_add_date (GskXmlrpcRequest *request, gulong value); void gsk_xmlrpc_request_add_data (GskXmlrpcRequest *request, GByteArray *data); void gsk_xmlrpc_request_add_struct (GskXmlrpcRequest *request, GskXmlrpcStruct *substructure); void gsk_xmlrpc_request_add_array (GskXmlrpcRequest *request, GskXmlrpcArray *array); GskXmlrpcResponse* gsk_xmlrpc_response_new (void); GskXmlrpcResponse* gsk_xmlrpc_response_ref (GskXmlrpcResponse *response); void gsk_xmlrpc_response_unref (GskXmlrpcResponse *response); void gsk_xmlrpc_response_add_int32 (GskXmlrpcResponse *response, gint32 value); void gsk_xmlrpc_response_add_boolean (GskXmlrpcResponse *response, gboolean value); void gsk_xmlrpc_response_add_double (GskXmlrpcResponse *response, gdouble value); void gsk_xmlrpc_response_add_string (GskXmlrpcResponse *response, const char *value); void gsk_xmlrpc_response_add_date (GskXmlrpcResponse *response, gulong value); void gsk_xmlrpc_response_add_data (GskXmlrpcResponse *response, GByteArray *data); void gsk_xmlrpc_response_add_struct (GskXmlrpcResponse *response, GskXmlrpcStruct *substructure); void gsk_xmlrpc_response_add_array (GskXmlrpcResponse *response, GskXmlrpcArray *array); void gsk_xmlrpc_response_fault (GskXmlrpcResponse *response, GskXmlrpcStruct *structure); GskXmlrpcParser* gsk_xmlrpc_parser_new (GskXmlrpcStream *stream); gboolean gsk_xmlrpc_parser_feed (GskXmlrpcParser *parser, const char *text, gssize len, GError **error); GskXmlrpcRequest* gsk_xmlrpc_parser_get_request (GskXmlrpcParser *parser); GskXmlrpcResponse* gsk_xmlrpc_parser_get_response (GskXmlrpcParser *parser); void gsk_xmlrpc_parser_free (GskXmlrpcParser *parser); void gsk_xmlrpc_request_to_buffer (GskXmlrpcRequest *request, GskBuffer *buffer); void gsk_xmlrpc_response_to_buffer (GskXmlrpcResponse *response, GskBuffer *buffer);
This file contains types mapping to the XMLRPC standard fundamental types, structures, arrays and faults. It contains a generic parser that has no I/O dependencies.
typedef struct { unsigned len; GskXmlrpcValue *values; } GskXmlrpcArray;
An array of XMLRPC values. Each may have a different type.
GskXmlrpcValue *values ; |
the values in the array. |
typedef struct { unsigned n_members; GskXmlrpcNamedValue *members; } GskXmlrpcStruct;
A structure, which is a set of named members.
typedef struct { GskXmlrpcType type; union { int v_int32; gboolean v_boolean; double v_double; char *v_string; gulong v_date; GByteArray *v_binary_data; GskXmlrpcStruct *v_struct; GskXmlrpcArray *v_array; } data; } GskXmlrpcValue;
A XMLRPC value that may be of any of the XMLRPC types. The type is included with the value.
typedef struct { char *name; GskXmlrpcValue value; } GskXmlrpcNamedValue;
A name/value pair, appropriate as a structure member.
char *name ; |
the string, name, label. |
GskXmlrpcValue value ; |
the typed value. |
typedef struct { unsigned magic; /* private, must be first */ char *method_name; GskXmlrpcArray *params; GskXmlrpcStream *xmlrpc_stream; } GskXmlrpcRequest;
An XMLRPC request (invocation).
typedef struct { unsigned magic; /* private, must be first */ GskXmlrpcArray *params; gboolean has_fault; GskXmlrpcValue fault; } GskXmlrpcResponse;
An XMLRPC response (return).
typedef struct _GskXmlrpcParser GskXmlrpcParser;
An object which can parse XMLRPC requests and responses, in any order. It does no interpretation of the requests or responses.
typedef enum { GSK_XMLRPC_INT32, GSK_XMLRPC_BOOLEAN, GSK_XMLRPC_DOUBLE, GSK_XMLRPC_STRING, GSK_XMLRPC_DATE, GSK_XMLRPC_BINARY_DATA, GSK_XMLRPC_STRUCT, GSK_XMLRPC_ARRAY } GskXmlrpcType;
The type of a XMLRPC value.
GskXmlrpcStruct* gsk_xmlrpc_struct_new (void);
Allocate a new structure, with no members.
Returns : | the newly allocated structure. |
void gsk_xmlrpc_struct_free (GskXmlrpcStruct *structure);
Free memory associated with an XMLRPC struct.
structure : |
the structure to free. |
void gsk_xmlrpc_struct_add_int32 (GskXmlrpcStruct *structure, const char *member_name, gint32 value);
Add a single int32 member to the given struct.
structure : |
the structure to append to. |
member_name : |
name of the new int32 member. |
value : |
value of the new int32 member. |
void gsk_xmlrpc_struct_add_boolean (GskXmlrpcStruct *structure, const char *member_name, gboolean value);
Add a single boolean member to the given struct.
structure : |
the structure to append to. |
member_name : |
name of the new boolean member. |
value : |
value of the new boolean member. |
void gsk_xmlrpc_struct_add_double (GskXmlrpcStruct *structure, const char *member_name, gdouble value);
Add a single double member to the given struct.
structure : |
the structure to append to. |
member_name : |
name of the new double member. |
value : |
value of the new double member. |
void gsk_xmlrpc_struct_add_string (GskXmlrpcStruct *structure, const char *member_name, const char *value);
Add a single string member to the given struct.
structure : |
the structure to append to. |
member_name : |
name of the new string member. |
value : |
value of the new string member. |
void gsk_xmlrpc_struct_add_date (GskXmlrpcStruct *structure, const char *member_name, gulong value);
Add a single date member to the given struct.
structure : |
the structure to append to. |
member_name : |
name of the new date member. |
value : |
value of the new date member. |
void gsk_xmlrpc_struct_add_data (GskXmlrpcStruct *structure, const char *member_name, GByteArray *data);
Add a single data member to the given struct.
structure : |
the structure to append to. |
member_name : |
name of the new date member. |
data : |
binary data to add, which will be freed by the structure when it is freed. |
void gsk_xmlrpc_struct_add_struct (GskXmlrpcStruct *structure, const char *member_name, GskXmlrpcStruct *substructure);
Add a structure as a member of another structure.
structure : |
the structure to append to. |
member_name : |
name of the new struct member. |
substructure : |
substructure to add, which will be freed by structure when
it is freed.
|
void gsk_xmlrpc_struct_add_array (GskXmlrpcStruct *structure, const char *member_name, GskXmlrpcArray *array);
Add an array as a member of a structure.
structure : |
the structure to append to. |
member_name : |
name of the new struct member. |
array : |
subarray to add, which will be freed by structure when
it is freed.
|
gboolean gsk_xmlrpc_struct_peek_date (GskXmlrpcStruct *structure, const char *member_name, gulong *out);
Lookup a named date member of a structure,
storing the result, if any, in out
.
structure : |
the structure to lookup the member of. |
member_name : |
the value to retrieve. |
out : |
place to store the result. |
Returns : | whether there was an date member named member_name .
|
gboolean gsk_xmlrpc_struct_peek_boolean (GskXmlrpcStruct *structure, const char *member_name, gboolean *out);
Lookup a named boolean member of a structure,
storing the result, if any, in out
.
structure : |
the structure to lookup the member of. |
member_name : |
the value to retrieve. |
out : |
place to store the result. |
Returns : | whether there was an boolean member named member_name .
|
gboolean gsk_xmlrpc_struct_peek_double (GskXmlrpcStruct *structure, const char *member_name, double *out);
Lookup a named double member of a structure,
storing the result, if any, in out
.
structure : |
the structure to lookup the member of. |
member_name : |
the value to retrieve. |
out : |
place to store the result. |
Returns : | whether there was an double member named member_name .
|
GskXmlrpcStruct* gsk_xmlrpc_struct_peek_struct (GskXmlrpcStruct *structure, const char *member_name);
Lookup a named substructure member of a structure, returning a reference to the GskXmlrpcStruct result, or NULL.
structure : |
the structure to lookup the member of. |
member_name : |
the value to retrieve. |
Returns : | a reference (not a copy!) to the struct, or NULL. |
const GByteArray* gsk_xmlrpc_struct_peek_data (GskXmlrpcStruct *structure, const char *member_name);
Lookup a named binary-data member of a structure, returning a reference to the GByteArray result, or NULL.
structure : |
the structure to lookup the member of. |
member_name : |
the value to retrieve. |
Returns : | a reference (not a copy!) to the binary data, or NULL. |
GskXmlrpcArray* gsk_xmlrpc_struct_peek_array (GskXmlrpcStruct *structure, const char *member_name);
Lookup a named subarray member of a structure, returning a reference to the GskXmlrpcArray result, or NULL.
structure : |
the structure to lookup the member of. |
member_name : |
the value to retrieve. |
Returns : | a reference (not a copy!) to the array, or NULL. |
const char* gsk_xmlrpc_struct_peek_string (GskXmlrpcStruct *structure, const char *member_name);
Lookup a named string member of a structure, returning the result, or NULL.
structure : |
the structure to lookup the member of. |
member_name : |
the value to retrieve. |
Returns : | the string value, or NULL. |
gboolean gsk_xmlrpc_struct_peek_int32 (GskXmlrpcStruct *structure, const char *member_name, gint32 *out);
Lookup a named int32 member of a structure,
storing the result, if any, in out
.
structure : |
the structure to lookup the member of. |
member_name : |
the value to retrieve. |
out : |
place to store the result. |
Returns : | whether there was an int32 member named member_name .
|
GskXmlrpcArray* gsk_xmlrpc_array_new (void);
Allocate a new, empty array.*
Returns : | the newly allocated arrays. |
void gsk_xmlrpc_array_free (GskXmlrpcArray *array);
Free the array and all its values.
array : |
the array to free. |
void gsk_xmlrpc_array_add_int32 (GskXmlrpcArray *array, gint32 value);
Append an integer to an XMLRPC array.
array : |
array to which to append a value. |
value : |
integer value to append. |
void gsk_xmlrpc_array_add_boolean (GskXmlrpcArray *array, gboolean value);
Append a boolean to an XMLRPC array.
array : |
array to which to append a value. |
value : |
boolean value to append. |
void gsk_xmlrpc_array_add_double (GskXmlrpcArray *array, gdouble value);
Append a double-precision floating-pointer value to an XMLRPC array.
array : |
array to which to append a value. |
value : |
double value to append. |
void gsk_xmlrpc_array_add_string (GskXmlrpcArray *array, const char *value);
Append a string to an XMLRPC array.
array : |
array to which to append a value. |
value : |
string value to append. This value is copied: we do not take ownership. |
void gsk_xmlrpc_array_add_date (GskXmlrpcArray *array, gulong value);
Append a string to an XMLRPC array.
array : |
array to which to append a value. |
value : |
date/time value to append. |
void gsk_xmlrpc_array_add_data (GskXmlrpcArray *array, GByteArray *data);
Append a binary-data element to an XMLRPC array.
This take ownership of data
.
array : |
array to which to append a value. |
data : |
a byte array containing arbitrary binary-data. The XMLRPC array takes ownership of the data. |
void gsk_xmlrpc_array_add_struct (GskXmlrpcArray *array, GskXmlrpcStruct *substructure);
Append a binary-data element to an XMLRPC array.
This take ownership of substructure
.
array : |
array to which to append a value. |
substructure : |
structure to append to array .
It will be freed by the array .
|
void gsk_xmlrpc_array_add_array (GskXmlrpcArray *array, GskXmlrpcArray *subarray);
Append a binary-data element to an XMLRPC array.
This take ownership of subarray
.
array : |
array to which to append a value. |
subarray : |
array to append to array .
It will be freed by the array .
|
GskXmlrpcRequest* gsk_xmlrpc_request_new (GskXmlrpcStream *xmlrpc_stream);
Allocate a new request.
At a very minimum, it should have a method name set with
gsk_xmlrpc_request_set_name()
.
xmlrpc_stream : |
|
Returns : | a newly allocated request. |
GskXmlrpcRequest* gsk_xmlrpc_request_ref (GskXmlrpcRequest *request);
Increase the reference count on request
.
request : |
the request to reference. |
Returns : | the request , for convenience.
|
void gsk_xmlrpc_request_unref (GskXmlrpcRequest *request);
Decrease the reference count on request
,
and free it if the count reached 0.
request : |
the request to stop referencing. |
void gsk_xmlrpc_request_set_name (GskXmlrpcRequest *request, const char *name);
Set the method name for this request.
request : |
the request whose method-name should be set. |
name : |
the name of the method to invoke. |
void gsk_xmlrpc_request_add_int32 (GskXmlrpcRequest *request, gint32 value);
Append an integer to an XMLRPC request.
request : |
request to whose parameters a value shall be appended. |
value : |
integer value to append. |
void gsk_xmlrpc_request_add_boolean (GskXmlrpcRequest *request, gboolean value);
Append a boolean to an XMLRPC request.
request : |
request to whose parameters a value shall be appended. |
value : |
integer value to append. |
void gsk_xmlrpc_request_add_double (GskXmlrpcRequest *request, gdouble value);
Append a double to an XMLRPC request.
request : |
request to whose parameters a value shall be appended. |
value : |
double value to append. |
void gsk_xmlrpc_request_add_string (GskXmlrpcRequest *request, const char *value);
Append a string to an XMLRPC request.
request : |
request to whose parameters a value shall be appended. |
value : |
string value to append. |
void gsk_xmlrpc_request_add_date (GskXmlrpcRequest *request, gulong value);
Append a date to an XMLRPC request.
request : |
request to whose parameters a value shall be appended. |
value : |
date value to append. |
void gsk_xmlrpc_request_add_data (GskXmlrpcRequest *request, GByteArray *data);
Append binary data to an XMLRPC request (it will be base64 encoded transparently).
request : |
request to whose parameters a value shall be appended. |
data : |
GByteArray to append: it shall be freed by the request, that is, there is a transfer of ownership. |
void gsk_xmlrpc_request_add_struct (GskXmlrpcRequest *request, GskXmlrpcStruct *substructure);
Add a structure as a parameter to the request.
request : |
request to whose parameters a value shall be appended. |
substructure : |
structure to append to array .
This will be freed by the request automatically: a transfer of ownership
occurs in this function.
|
void gsk_xmlrpc_request_add_array (GskXmlrpcRequest *request, GskXmlrpcArray *array);
Add a structure as a parameter to the request.
request : |
request to whose parameters a value shall be appended. |
array : |
array to append to request 's parmeter list.
This will be freed by the request automatically: a transfer of ownership
occurs in this function.
|
GskXmlrpcResponse* gsk_xmlrpc_response_new (void);
Allocate a new response.
Returns : | the newly allocated response which has no parameters and no fault. |
GskXmlrpcResponse* gsk_xmlrpc_response_ref (GskXmlrpcResponse *response);
Increase the reference count on response
.
response : |
the response to reference. |
Returns : | the response , for convenience.
|
void gsk_xmlrpc_response_unref (GskXmlrpcResponse *response);
Decrease the reference count on response
,
and free it if the count reached 0.
response : |
the response to stop referencing. |
void gsk_xmlrpc_response_add_int32 (GskXmlrpcResponse *response, gint32 value);
Append an integer to an XMLRPC response.
response : |
response to whose parameters a value shall be appended. |
value : |
integer value to append. |
void gsk_xmlrpc_response_add_boolean (GskXmlrpcResponse *response, gboolean value);
Append a boolean to an XMLRPC response.
response : |
response to whose parameters a value shall be appended. |
value : |
integer value to append. |
void gsk_xmlrpc_response_add_double (GskXmlrpcResponse *response, gdouble value);
Append a double to an XMLRPC response.
response : |
response to whose parameters a value shall be appended. |
value : |
double value to append. |
void gsk_xmlrpc_response_add_string (GskXmlrpcResponse *response, const char *value);
Append a string to an XMLRPC response.
response : |
response to whose parameters a value shall be appended. |
value : |
string value to append. |
void gsk_xmlrpc_response_add_date (GskXmlrpcResponse *response, gulong value);
Append a date to an XMLRPC response.
response : |
response to whose parameters a value shall be appended. |
value : |
date value to append. |
void gsk_xmlrpc_response_add_data (GskXmlrpcResponse *response, GByteArray *data);
Append binary data to an XMLRPC response (it will be base64 encoded transparently).
response : |
response to whose parameters a value shall be appended. |
data : |
GByteArray to append: it shall be freed by the response, that is, there is a transfer of ownership. |
void gsk_xmlrpc_response_add_struct (GskXmlrpcResponse *response, GskXmlrpcStruct *substructure);
Add a structure as a parameter to the response.
response : |
response to whose parameters a value shall be appended. |
substructure : |
structure to append to array .
This will be freed by the response automatically: a transfer of ownership
occurs in this function.
|
void gsk_xmlrpc_response_add_array (GskXmlrpcResponse *response, GskXmlrpcArray *array);
Add a structure as a parameter to the response.
response : |
response to whose parameters a value shall be appended. |
array : |
array to append to response 's parmeter list.
This will be freed by the response automatically: a transfer of ownership
occurs in this function.
|
void gsk_xmlrpc_response_fault (GskXmlrpcResponse *response, GskXmlrpcStruct *structure);
Indicate that an error occurred trying to process the XMLRPC request.
response : |
the response to affect. |
structure : |
the fault information. This should be a struct with at most an integer 'faultCode' and a string 'faultString'. |
GskXmlrpcParser* gsk_xmlrpc_parser_new (GskXmlrpcStream *stream);
Allocate a new XMLRPC parser. A parser can parse both requests and responses.
stream : |
|
Returns : | the newly allocated parser. |
gboolean gsk_xmlrpc_parser_feed (GskXmlrpcParser *parser, const char *text, gssize len, GError **error);
Pass data into the XMLRPC parser.
If this works, gsk_xmlrpc_parser_get_request()
and/or
gsk_xmlrpc_parser_get_response()
should be called as appropriate
until there are no more messages to dequeue.
parser : |
the parser to give data. |
text : |
the data to parse (it may just be a partial request). |
len : |
the length of text , or -1 to use NUL-termination.
|
error : |
place to put the error object if the parsing has a problem. |
Returns : | TRUE if processing did not encounter an error. |
GskXmlrpcRequest* gsk_xmlrpc_parser_get_request (GskXmlrpcParser *parser);
Get a parsed request from the list maintained by the parser.
parser : |
parser to try and get a parsed request from. |
Returns : | a reference to the request; the caller
must call gsk_xmlrpc_request_unref() eventually.
|
GskXmlrpcResponse* gsk_xmlrpc_parser_get_response (GskXmlrpcParser *parser);
Get a parsed response from the list maintained by the parser.
parser : |
parser to try and get a parsed response from. |
Returns : | a reference to the response; the caller
must call gsk_xmlrpc_response_unref() eventually.
|
void gsk_xmlrpc_parser_free (GskXmlrpcParser *parser);
Free the memory associated with the parser.
parser : |
the parser to free. |
void gsk_xmlrpc_request_to_buffer (GskXmlrpcRequest *request, GskBuffer *buffer);
request : |
|
buffer : |
void gsk_xmlrpc_response_to_buffer (GskXmlrpcResponse *response, GskBuffer *buffer);
Write the XML corresponding to this response to the buffer.
response : |
the XMLRPC response to serialize. |
buffer : |
the buffer to append to. |