gint32
thrift_binary_protocol_write_message_begin (ThriftProtocol *protocol,
    const gchar *name, const ThriftMessageType message_type,
    const gint32 seqid, GError **error)
{
  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);

  gint32 version = (THRIFT_BINARY_PROTOCOL_VERSION_1)
                   | ((gint32) message_type);
  gint32 ret;
  gint32 xfer = 0;

  if ((ret = thrift_protocol_write_i32 (protocol, version, error)) < 0)
  {
    return -1;
  }
  xfer += ret;
  if ((ret = thrift_protocol_write_string (protocol, name, error)) < 0)
  {
    return -1;
  }
  xfer += ret;
  if ((ret = thrift_protocol_write_i32 (protocol, seqid, error)) < 0)
  {
    return -1;
  }
  xfer += ret;
  return xfer;
}
int32_t
thrift_binary_protocol_write_message_begin (ThriftProtocol *protocol,
    const char *name, const ThriftMessageType message_type,
    const int32_t seqid, int *error)
{
  int32_t version = (THRIFT_BINARY_PROTOCOL_VERSION_1)
                   | ((int32_t) message_type);
  int32_t ret;
  int32_t xfer = 0;

  if ((ret = thrift_protocol_write_i32 (protocol, version, error)) < 0)
  {
    return -1;
  }
  xfer += ret;
  if ((ret = thrift_protocol_write_string (protocol, name, error)) < 0)
  {
    return -1;
  }
  xfer += ret;
  if ((ret = thrift_protocol_write_i32 (protocol, seqid, error)) < 0)
  {
    return -1;
  }
  xfer += ret;
  return xfer;
}
Beispiel #3
0
gboolean calculator_client_send_add (CalculatorIf * iface, const gint32 num1, const gint32 num2, GError ** error)
{
  gint32 cseqid = 0;
  ThriftProtocol * protocol = SHARED_SERVICE_CLIENT (iface)->output_protocol;

  if (thrift_protocol_write_message_begin (protocol, "add", T_CALL, cseqid, error) < 0)
    return FALSE;

  {
    gint32 ret;
    gint32 xfer = 0;

    
    if ((ret = thrift_protocol_write_struct_begin (protocol, "add_args", error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_protocol_write_field_begin (protocol, "num1", T_I32, 1, error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_protocol_write_i32 (protocol, num1, error)) < 0)
      return 0;
    if ((ret = thrift_protocol_write_field_end (protocol, error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_protocol_write_field_begin (protocol, "num2", T_I32, 2, error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_protocol_write_i32 (protocol, num2, error)) < 0)
      return 0;
    if ((ret = thrift_protocol_write_field_end (protocol, error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_protocol_write_field_stop (protocol, error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_protocol_write_struct_end (protocol, error)) < 0)
      return 0;
    xfer += ret;

  }

  if (thrift_protocol_write_message_end (protocol, error) < 0)
    return FALSE;
  if (!thrift_transport_flush (protocol->transport, error))
    return FALSE;
  if (!thrift_transport_write_end (protocol->transport, error))
    return FALSE;

  return TRUE;
}
gint32
thrift_binary_protocol_write_binary (ThriftProtocol *protocol,
                                     const gpointer buf,
                                     const guint32 len, GError **error)
{
  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
  gint32 ret;
  gint32 xfer = 0;

  if ((ret = thrift_protocol_write_i32 (protocol, len, error)) < 0)
  {
    return -1;
  }
  xfer += ret;

  if (len > 0)
  {
    if (thrift_transport_write (protocol->transport,
                                (const gpointer) buf, len, error) == FALSE)
    {
      return -1;
    }
    xfer += len;
  }

  return xfer;
}
gint32
thrift_binary_protocol_write_list_begin (ThriftProtocol *protocol,
                                         const ThriftType element_type,
                                         const guint32 size, 
                                         GError **error)
{
  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1); 

  gint32 ret;
  gint32 xfer = 0;

  if ((ret = thrift_protocol_write_byte (protocol, (gint8) element_type,
                                         error)) < 0)
  {
    return -1;
  }
  xfer += ret;

  if ((ret = thrift_protocol_write_i32 (protocol, (gint32) size, error)) < 0)
  {
    return -1;
  }
  xfer += ret;

  return xfer;
}
int32_t
thrift_binary_protocol_write_binary (ThriftProtocol *protocol,
                                     const void * buf,
                                     const u_int32_t len, int *error)
{
  int32_t ret;
  int32_t xfer = 0;

  if ((ret = thrift_protocol_write_i32 (protocol, len, error)) < 0)
  {
    return -1;
  }
  xfer += ret;

  if (len > 0)
  {
    if (thrift_transport_write (protocol->transport,
                                (const void *) buf, len, error) == 0)
    {
      return -1;
    }
    xfer += len;
  }

  return xfer;
}
int32_t
thrift_binary_protocol_write_map_begin (ThriftProtocol *protocol,
                                        const ThriftType key_type,
                                        const ThriftType value_type,
                                        const u_int32_t size,
                                        int *error)
{
  int32_t ret;
  int32_t xfer = 0;

  if ((ret = thrift_protocol_write_byte (protocol, (int8_t) key_type,
                                         error)) < 0)
  {
    return -1;
  }
  xfer += ret;
  if ((ret = thrift_protocol_write_byte (protocol, (int8_t) value_type,
                                         error)) < 0)
  {
    return -1;
  }
  xfer += ret;
  if ((ret = thrift_protocol_write_i32 (protocol, (int32_t) size, error)) < 0)
  {
    return -1;
  }
  xfer += ret;
  return xfer;
}
Beispiel #8
0
gboolean calculator_client_send_calculate (CalculatorIf * iface, const gint32 logid, const Work * w, GError ** error)
{
  gint32 cseqid = 0;
  ThriftProtocol * protocol = SHARED_SERVICE_CLIENT (iface)->output_protocol;

  if (thrift_protocol_write_message_begin (protocol, "calculate", T_CALL, cseqid, error) < 0)
    return FALSE;

  {
    gint32 ret;
    gint32 xfer = 0;

    
    if ((ret = thrift_protocol_write_struct_begin (protocol, "calculate_args", error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_protocol_write_field_begin (protocol, "logid", T_I32, 1, error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_protocol_write_i32 (protocol, logid, error)) < 0)
      return 0;
    if ((ret = thrift_protocol_write_field_end (protocol, error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_protocol_write_field_begin (protocol, "w", T_STRUCT, 2, error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_struct_write (THRIFT_STRUCT (w), protocol, error)) < 0)
      return 0;
    xfer += ret;

    if ((ret = thrift_protocol_write_field_end (protocol, error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_protocol_write_field_stop (protocol, error)) < 0)
      return 0;
    xfer += ret;
    if ((ret = thrift_protocol_write_struct_end (protocol, error)) < 0)
      return 0;
    xfer += ret;

  }

  if (thrift_protocol_write_message_end (protocol, error) < 0)
    return FALSE;
  if (!thrift_transport_flush (protocol->transport, error))
    return FALSE;
  if (!thrift_transport_write_end (protocol->transport, error))
    return FALSE;

  return TRUE;
}