gboolean thrift_dispatch_processor_process (ThriftProcessor *processor, ThriftProtocol *in, ThriftProtocol *out, GError **error) { gchar *fname; ThriftMessageType mtype; gint32 seqid; ThriftDispatchProcessor *dispatch_processor = THRIFT_DISPATCH_PROCESSOR (processor); /* Read the start of the message, which we expect to be a method call */ if (thrift_protocol_read_message_begin (in, &fname, &mtype, &seqid, error) < 0) { g_warning ("error reading start of message: %s", (error != NULL) ? (*error)->message : "(null)"); return FALSE; } else if (mtype != T_CALL && mtype != T_ONEWAY) { g_warning ("received invalid message type %d from client", mtype); return FALSE; } /* Dispatch the method call */ return THRIFT_DISPATCH_PROCESSOR_GET_CLASS (dispatch_processor) ->dispatch_call (dispatch_processor, in, out, fname, seqid, error); }
gboolean bucket_store_mapping_client_recv_get_mapping (BucketStoreMappingIf * iface, GHashTable ** _return, BucketStoreMappingException ** e, GError ** error) { gint32 rseqid; gchar * fname; ThriftMessageType mtype; ThriftProtocol * protocol = BUCKET_STORE_MAPPING_CLIENT (iface)->input_protocol; if (thrift_protocol_read_message_begin (protocol, &fname, &mtype, &rseqid, error) < 0) { if (fname) g_free (fname); return FALSE; } if (mtype == T_EXCEPTION) { if (fname) g_free (fname); ThriftApplicationException *xception = g_object_new (THRIFT_TYPE_APPLICATION_EXCEPTION, NULL); thrift_struct_read (THRIFT_STRUCT (xception), protocol, NULL); thrift_protocol_read_message_end (protocol, NULL); thrift_transport_read_end (protocol->transport, NULL); g_set_error (error, THRIFT_APPLICATION_EXCEPTION_ERROR, xception->type, "application error: %s", xception->message); g_object_unref (xception); return FALSE; } else if (mtype != T_REPLY) { if (fname) g_free (fname); thrift_protocol_skip (protocol, T_STRUCT, NULL); thrift_protocol_read_message_end (protocol, NULL); thrift_transport_read_end (protocol->transport, NULL); g_set_error (error, THRIFT_APPLICATION_EXCEPTION_ERROR, THRIFT_APPLICATION_EXCEPTION_ERROR_INVALID_MESSAGE_TYPE, "invalid message type %d, expected T_REPLY", mtype); return FALSE; } else if (strncmp (fname, "getMapping", 10) != 0) { thrift_protocol_skip (protocol, T_STRUCT, NULL); thrift_protocol_read_message_end (protocol, error); thrift_transport_read_end (protocol->transport, error); g_set_error (error, THRIFT_APPLICATION_EXCEPTION_ERROR, THRIFT_APPLICATION_EXCEPTION_ERROR_WRONG_METHOD_NAME, "wrong method name %s, expected getMapping", fname); if (fname) g_free (fname); return FALSE; } if (fname) g_free (fname); { gint32 ret; gint32 xfer = 0; gchar *name = NULL; ThriftType ftype; gint16 fid; guint32 len = 0; gpointer data = NULL; /* satisfy -Wall in case these aren't used */ THRIFT_UNUSED_VAR (len); THRIFT_UNUSED_VAR (data); /* read the struct begin marker */ if ((ret = thrift_protocol_read_struct_begin (protocol, &name, error)) < 0) { if (name) g_free (name); return 0; } xfer += ret; if (name) g_free (name); name = NULL; /* read the struct fields */ while (1) { /* read the beginning of a field */ if ((ret = thrift_protocol_read_field_begin (protocol, &name, &ftype, &fid, error)) < 0) { if (name) g_free (name); return 0; } xfer += ret; if (name) g_free (name); name = NULL; /* break if we get a STOP field */ if (ftype == T_STOP) { break; } switch (fid) { case 0: if (ftype == T_MAP) { { guint32 size; ThriftType key_type; ThriftType value_type; /* read the map begin marker */ if ((ret = thrift_protocol_read_map_begin (protocol, &key_type, &value_type, &size, error)) < 0) return 0; xfer += ret; /* iterate through each of the map's fields */ guint32 i; for (i = 0; i < size; i++) { gint32* key0 = g_new (gint32, 1); HostPort * val1 = NULL; if ((ret = thrift_protocol_read_i32 (protocol, &*key0, error)) < 0) return 0; xfer += ret; if ( val1 != NULL) { g_object_unref (val1); } val1 = g_object_new (TYPE_HOST_PORT, NULL); if ((ret = thrift_struct_read (THRIFT_STRUCT (val1), protocol, error)) < 0) { g_object_unref (val1); return 0; } xfer += ret; g_hash_table_insert ((GHashTable *)*_return, (gpointer) key0, (gpointer) val1); } /* read the map end marker */ if ((ret = thrift_protocol_read_map_end (protocol, error)) < 0) return 0; xfer += ret; } } else { if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0) return 0; xfer += ret; } break; case 1: if (ftype == T_STRUCT) { /* This struct is an exception */ if ( *e != NULL) { g_object_unref (*e); } *e = g_object_new (TYPE_BUCKET_STORE_MAPPING_EXCEPTION, NULL); if ((ret = thrift_struct_read (THRIFT_STRUCT (*e), protocol, error)) < 0) { g_object_unref (*e); return 0; } xfer += ret; } else { if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0) return 0; xfer += ret; } break; default: if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0) return 0; xfer += ret; break; } if ((ret = thrift_protocol_read_field_end (protocol, error)) < 0) return 0; xfer += ret; } if ((ret = thrift_protocol_read_struct_end (protocol, error)) < 0) return 0; xfer += ret; } if (thrift_protocol_read_message_end (protocol, error) < 0) return FALSE; if (!thrift_transport_read_end (protocol->transport, error)) return FALSE; if (*e != NULL) { g_set_error (error, BUCKET_STORE_MAPPING_EXCEPTION_ERROR, BUCKET_STORE_MAPPING_EXCEPTION_ERROR_CODE, "BucketStoreMappingException"); return FALSE; } return TRUE; }
gboolean t_test_second_service_client_recv_secondtest_string (TTestSecondServiceIf * iface, gchar ** _return, GError ** error) { gint32 rseqid; gchar * fname = NULL; ThriftMessageType mtype; ThriftProtocol * protocol = T_TEST_SECOND_SERVICE_CLIENT (iface)->input_protocol; if (thrift_protocol_read_message_begin (protocol, &fname, &mtype, &rseqid, error) < 0) { if (fname) g_free (fname); return FALSE; } if (mtype == T_EXCEPTION) { if (fname) g_free (fname); ThriftApplicationException *xception = g_object_new (THRIFT_TYPE_APPLICATION_EXCEPTION, NULL); thrift_struct_read (THRIFT_STRUCT (xception), protocol, NULL); thrift_protocol_read_message_end (protocol, NULL); thrift_transport_read_end (protocol->transport, NULL); g_set_error (error, THRIFT_APPLICATION_EXCEPTION_ERROR, xception->type, "application error: %s", xception->message); g_object_unref (xception); return FALSE; } else if (mtype != T_REPLY) { if (fname) g_free (fname); thrift_protocol_skip (protocol, T_STRUCT, NULL); thrift_protocol_read_message_end (protocol, NULL); thrift_transport_read_end (protocol->transport, NULL); g_set_error (error, THRIFT_APPLICATION_EXCEPTION_ERROR, THRIFT_APPLICATION_EXCEPTION_ERROR_INVALID_MESSAGE_TYPE, "invalid message type %d, expected T_REPLY", mtype); return FALSE; } else if (strncmp (fname, "secondtestString", 16) != 0) { thrift_protocol_skip (protocol, T_STRUCT, NULL); thrift_protocol_read_message_end (protocol, error); thrift_transport_read_end (protocol->transport, error); g_set_error (error, THRIFT_APPLICATION_EXCEPTION_ERROR, THRIFT_APPLICATION_EXCEPTION_ERROR_WRONG_METHOD_NAME, "wrong method name %s, expected secondtestString", fname); if (fname) g_free (fname); return FALSE; } if (fname) g_free (fname); { gint32 ret; gint32 xfer = 0; gchar *name = NULL; ThriftType ftype; gint16 fid; guint32 len = 0; gpointer data = NULL; /* satisfy -Wall in case these aren't used */ THRIFT_UNUSED_VAR (len); THRIFT_UNUSED_VAR (data); /* read the struct begin marker */ if ((ret = thrift_protocol_read_struct_begin (protocol, &name, error)) < 0) { if (name) g_free (name); return 0; } xfer += ret; if (name) g_free (name); name = NULL; /* read the struct fields */ while (1) { /* read the beginning of a field */ if ((ret = thrift_protocol_read_field_begin (protocol, &name, &ftype, &fid, error)) < 0) { if (name) g_free (name); return 0; } xfer += ret; if (name) g_free (name); name = NULL; /* break if we get a STOP field */ if (ftype == T_STOP) { break; } switch (fid) { case 0: if (ftype == T_STRING) { if (*_return != NULL) { g_free(*_return); *_return = NULL; } if ((ret = thrift_protocol_read_string (protocol, &*_return, error)) < 0) return 0; xfer += ret; } else { if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0) return 0; xfer += ret; } break; default: if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0) return 0; xfer += ret; break; } if ((ret = thrift_protocol_read_field_end (protocol, error)) < 0) return 0; xfer += ret; } if ((ret = thrift_protocol_read_struct_end (protocol, error)) < 0) return 0; xfer += ret; } if (thrift_protocol_read_message_end (protocol, error) < 0) return FALSE; if (!thrift_transport_read_end (protocol->transport, error)) return FALSE; return TRUE; }
gboolean calculator_client_recv_calculate (CalculatorIf * iface, gint32* _return, InvalidOperation ** ouch, GError ** error) { gint32 rseqid; gchar * fname = NULL; ThriftMessageType mtype; ThriftProtocol * protocol = SHARED_SERVICE_CLIENT (iface)->input_protocol; ThriftApplicationException *xception; if (thrift_protocol_read_message_begin (protocol, &fname, &mtype, &rseqid, error) < 0) { if (fname) g_free (fname); return FALSE; } if (mtype == T_EXCEPTION) { if (fname) g_free (fname); xception = g_object_new (THRIFT_TYPE_APPLICATION_EXCEPTION, NULL); thrift_struct_read (THRIFT_STRUCT (xception), protocol, NULL); thrift_protocol_read_message_end (protocol, NULL); thrift_transport_read_end (protocol->transport, NULL); g_set_error (error, THRIFT_APPLICATION_EXCEPTION_ERROR,xception->type, "application error: %s", xception->message); g_object_unref (xception); return FALSE; } else if (mtype != T_REPLY) { if (fname) g_free (fname); thrift_protocol_skip (protocol, T_STRUCT, NULL); thrift_protocol_read_message_end (protocol, NULL); thrift_transport_read_end (protocol->transport, NULL); g_set_error (error, THRIFT_APPLICATION_EXCEPTION_ERROR, THRIFT_APPLICATION_EXCEPTION_ERROR_INVALID_MESSAGE_TYPE, "invalid message type %d, expected T_REPLY", mtype); return FALSE; } else if (strncmp (fname, "calculate", 9) != 0) { thrift_protocol_skip (protocol, T_STRUCT, NULL); thrift_protocol_read_message_end (protocol,error); thrift_transport_read_end (protocol->transport, error); g_set_error (error, THRIFT_APPLICATION_EXCEPTION_ERROR, THRIFT_APPLICATION_EXCEPTION_ERROR_WRONG_METHOD_NAME, "wrong method name %s, expected calculate", fname); if (fname) g_free (fname); return FALSE; } if (fname) g_free (fname); { gint32 ret; gint32 xfer = 0; gchar *name = NULL; ThriftType ftype; gint16 fid; guint32 len = 0; gpointer data = NULL; /* satisfy -Wall in case these aren't used */ THRIFT_UNUSED_VAR (len); THRIFT_UNUSED_VAR (data); /* read the struct begin marker */ if ((ret = thrift_protocol_read_struct_begin (protocol, &name, error)) < 0) { if (name) g_free (name); return 0; } xfer += ret; if (name) g_free (name); name = NULL; /* read the struct fields */ while (1) { /* read the beginning of a field */ if ((ret = thrift_protocol_read_field_begin (protocol, &name, &ftype, &fid, error)) < 0) { if (name) g_free (name); return 0; } xfer += ret; if (name) g_free (name); name = NULL; /* break if we get a STOP field */ if (ftype == T_STOP) { break; } switch (fid) { case 0: if (ftype == T_I32) { if ((ret = thrift_protocol_read_i32 (protocol, &*_return, error)) < 0) return 0; xfer += ret; } else { if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0) return 0; xfer += ret; } break; case 1: if (ftype == T_STRUCT) { /* This struct is an exception */ if ( *ouch != NULL) { g_object_unref (*ouch); } *ouch = g_object_new (TYPE_INVALID_OPERATION, NULL); if ((ret = thrift_struct_read (THRIFT_STRUCT (*ouch), protocol, error)) < 0) { g_object_unref (*ouch); *ouch = NULL; return 0; } xfer += ret; } else { if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0) return 0; xfer += ret; } break; default: if ((ret = thrift_protocol_skip (protocol, ftype, error)) < 0) return 0; xfer += ret; break; } if ((ret = thrift_protocol_read_field_end (protocol, error)) < 0) return 0; xfer += ret; } if ((ret = thrift_protocol_read_struct_end (protocol, error)) < 0) return 0; xfer += ret; } if (thrift_protocol_read_message_end (protocol, error) < 0) return FALSE; if (!thrift_transport_read_end (protocol->transport, error)) return FALSE; if (*ouch != NULL) { g_set_error (error, INVALID_OPERATION_ERROR, INVALID_OPERATION_ERROR_CODE, "InvalidOperation"); return FALSE; } return TRUE; }