Re: [Vala] Genie xmlrpc-c bindings test
- From: Phil Daintree <phil logicworks co nz>
- To: vala-list gnome org
- Subject: Re: [Vala] Genie xmlrpc-c bindings test
- Date: Tue, 14 Sep 2010 07:22:30 +1200
Thanks for your help Jamie - see below
On 14/09/10 02:46, Jamie McCracken wrote:
can you post xmlrpc-c_test.vala.c so i can see which line is causing the
problem
jamie
/* xmlrpc-c_test.c generated by valac, the Vala compiler
* generated from xmlrpc-c_test.gs, do not modify */
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <xmlrpc-c/base.h>
#include <xmlrpc-c/client.h>
#define _xmlrpc_client_destroy0(var) ((var == NULL) ? NULL : (var =
(xmlrpc_client_destroy (var), NULL)))
#define _xmlrpc_DECREF0(var) ((var == NULL) ? NULL : (var =
(xmlrpc_DECREF (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _xmlrpc_server_info_free0(var) ((var == NULL) ? NULL : (var =
(xmlrpc_server_info_free (var), NULL)))
void print_value (xmlrpc_env* XEnv, xmlrpc_value* XValue);
void _vala_main (char** args, int args_length1);
void _vala_main (char** args, int args_length1) {
char* ProgramName;
char* ProgramVersion;
xmlrpc_client* XClient;
xmlrpc_env XEnv = {0};
xmlrpc_value* XReturnValue;
xmlrpc_client* _tmp1_;
xmlrpc_client* _tmp0_ = NULL;
char* Server;
xmlrpc_server_info* XServer;
xmlrpc_value* XQuery;
xmlrpc_value* _tmp2_;
xmlrpc_value* _tmp3_;
xmlrpc_value* _tmp4_;
xmlrpc_value* _tmp6_;
xmlrpc_value* _tmp5_ = NULL;
ProgramName = g_strdup ("Genie XML-RPC Test Program");
ProgramVersion = g_strdup ("0.00001");
XClient = NULL;
xmlrpc_env_init (&XEnv);
XReturnValue = NULL;
g_print ("Genie xmlrpc test program\n\n");
xmlrpc_client_init (0, ProgramName, ProgramVersion);
xmlrpc_client_create (&XEnv, 0, ProgramName, ProgramVersion, NULL, 0,
&_tmp0_);
XClient = (_tmp1_ = _tmp0_, _xmlrpc_client_destroy0 (XClient), _tmp1_);
Server = g_strdup ("http://localhost/webERP/api/api_xmlrpc.php");
XServer = xmlrpc_server_info_new (&XEnv, Server);
if (XEnv.fault_occurred) {
g_print ("Setting the properties of the xml-rpc server failed with the
message: " \
"%s fault code: %d\n", XEnv.fault_string, XEnv.fault_code);
g_thread_exit (NULL);
}
XQuery = xmlrpc_array_new (&XEnv);
xmlrpc_array_append_item (&XEnv, XQuery, _tmp2_ = xmlrpc_string_new
(&XEnv, "DVD-TOPGUN"));
_xmlrpc_DECREF0 (_tmp2_);
xmlrpc_array_append_item (&XEnv, XQuery, _tmp3_ = xmlrpc_string_new
(&XEnv, "admin"));
_xmlrpc_DECREF0 (_tmp3_);
xmlrpc_array_append_item (&XEnv, XQuery, _tmp4_ = xmlrpc_string_new
(&XEnv, "weberp"));
_xmlrpc_DECREF0 (_tmp4_);
xmlrpc_client_call2 (&XEnv, XClient, XServer,
"weberp.xmlrpc_GetStockBalance", XQuery, &_tmp5_);
XReturnValue = (_tmp6_ = _tmp5_, _xmlrpc_DECREF0 (XReturnValue), _tmp6_);
if (XEnv.fault_occurred) {
g_print ("Oops.. fault happened (%s)\n\n", XEnv.fault_string);
} else {
g_print ("type = %d (struct = %d)\n\n", (gint) xmlrpc_value_type
(XReturnValue), (gint) XMLRPC_TYPE_STRUCT);
print_value (&XEnv, XReturnValue);
}
_g_free0 (ProgramName);
_g_free0 (ProgramVersion);
_xmlrpc_client_destroy0 (XClient);
xmlrpc_env_clean (&XEnv);
_xmlrpc_DECREF0 (XReturnValue);
_g_free0 (Server);
_xmlrpc_server_info_free0 (XServer);
_xmlrpc_DECREF0 (XQuery);
}
int main (int argc, char ** argv) {
g_type_init ();
_vala_main (argv, argc);
return 0;
}
static gpointer _xmlrpc_INCREF0 (gpointer self) {
return self ? xmlrpc_INCREF (self) : NULL;
}
void print_value (xmlrpc_env* XEnv, xmlrpc_value* XValue) {
gint i;
xmlrpc_value* XItem;
xmlrpc_value* XKey;
xmlrpc_value* XKeyValue;
xmlrpc_value* XArray;
gint ArraySize = 0;
xmlrpc_value* XStruct;
char* ReturnedString;
gint ReturnedNumber = 0;
char* Key;
char* KeyValue;
xmlrpc_type DataType;
g_return_if_fail (XValue != NULL);
i = 0;
XItem = NULL;
XKey = NULL;
XKeyValue = NULL;
XArray = NULL;
XStruct = NULL;
ReturnedString = NULL;
Key = NULL;
KeyValue = NULL;
DataType = xmlrpc_value_type (XValue);
switch (DataType) {
case XMLRPC_TYPE_ARRAY:
{
{
xmlrpc_value* _tmp0_;
XArray = (_tmp0_ = _xmlrpc_INCREF0 ((xmlrpc_value*) XValue),
_xmlrpc_DECREF0 (XArray), _tmp0_);
ArraySize = xmlrpc_array_size (XEnv, XArray);
g_print ("Array [%d] = {\n\n", ArraySize);
while (TRUE) {
xmlrpc_value* _tmp1_;
if (!(i < ArraySize)) {
break;
}
XItem = (_tmp1_ = xmlrpc_array_get_item (XEnv, XArray, i),
_xmlrpc_DECREF0 (XItem), _tmp1_);
g_print (" array[%d] = \n", i);
print_value (XEnv, XItem);
i++;
}
g_print ("}\n\n");
}
break;
}
case XMLRPC_TYPE_INT:
{
{
xmlrpc_read_int (XEnv, XValue, &ReturnedNumber);
g_print ("The value returned is an integer: (%d)\n\n", ReturnedNumber);
}
break;
}
case XMLRPC_TYPE_STRING:
{
{
char* _tmp3_;
const char* _tmp2_ = NULL;
xmlrpc_read_string (XEnv, XValue, &_tmp2_);
ReturnedString = (_tmp3_ = g_strdup (_tmp2_), _g_free0
(ReturnedString), _tmp3_);
g_print ("The value returned is a string: (%s)\n\n", ReturnedString);
}
break;
}
case XMLRPC_TYPE_STRUCT:
{
{
xmlrpc_value* _tmp4_;
XStruct = (_tmp4_ = _xmlrpc_INCREF0 ((xmlrpc_value*) XValue),
_xmlrpc_DECREF0 (XStruct), _tmp4_);
g_print ("Struct size: %d\n\n", xmlrpc_struct_size (XEnv, XStruct));
while (TRUE) {
xmlrpc_value* _tmp8_;
xmlrpc_value* _tmp7_ = NULL;
xmlrpc_value* _tmp6_;
xmlrpc_value* _tmp5_ = NULL;
char* _tmp10_;
const char* _tmp9_ = NULL;
char* _tmp12_;
const char* _tmp11_ = NULL;
if (!(i < xmlrpc_struct_size (XEnv, XStruct))) {
break;
}
(xmlrpc_env_struct_get_key_and_value (XEnv, XValue, i, &_tmp5_,
&_tmp7_), XKey = (_tmp6_ = _tmp5_, _xmlrpc_DECREF0 (XKey), _tmp6_));
XKeyValue = (_tmp8_ = _tmp7_, _xmlrpc_DECREF0 (XKeyValue), _tmp8_);
xmlrpc_read_string (XEnv, XKey, &_tmp9_);
Key = (_tmp10_ = g_strdup (_tmp9_), _g_free0 (Key), _tmp10_);
xmlrpc_read_string (XEnv, XKeyValue, &_tmp11_);
KeyValue = (_tmp12_ = g_strdup (_tmp11_), _g_free0 (KeyValue),
_tmp12_);
g_print (" Struct %s -> %s \n", Key, KeyValue);
i++;
}
}
break;
}
default:
{
{
g_print ("Unknown data type %d\n\n", (gint) DataType);
}
break;
}
}
_xmlrpc_DECREF0 (XItem);
_xmlrpc_DECREF0 (XKey);
_xmlrpc_DECREF0 (XKeyValue);
_xmlrpc_DECREF0 (XArray);
_xmlrpc_DECREF0 (XStruct);
_g_free0 (ReturnedString);
_g_free0 (Key);
_g_free0 (KeyValue);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]