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;
}
Пример #2
0
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;
}
Пример #3
0
gboolean
my_thrift_transport_write (ThriftTransport *transport, const gpointer buf,
                           const guint32 len, GError **error)
{
  if (transport_write_count != transport_write_error_at
      && transport_write_error == 0)
  {
    transport_write_count++;
    return thrift_transport_write (transport, buf, len, error);
  }
  return FALSE;
}
int32_t
thrift_binary_protocol_write_byte (ThriftProtocol *protocol, const int8_t value,
                                   int *error)
{
  if (thrift_transport_write (protocol->transport,
                              (const void *) &value, 1, error))
  {
    return 1;
  } else {
    return -1;
  }
}
int32_t
thrift_binary_protocol_write_u32 (ThriftProtocol *protocol, const u_int32_t value,
                                  int *error)
{
  u_int32_t net = htonl (value);
  if (thrift_transport_write (protocol->transport,
                              (const void *) &net, 4, error))
  {
    return 4;
  } else {
    return -1;
  }
}
int32_t
thrift_binary_protocol_write_i16 (ThriftProtocol *protocol, const int16_t value,
                                  int *error)
{
  int16_t net = htons (value);
  if (thrift_transport_write (protocol->transport,
                              (const void *) &net, 2, error))
  {
    return 2;
  } else {
    return -1;
  }
}
Пример #7
0
gint32
thrift_binary_protocol_write_byte (ThriftProtocol *protocol, const gint8 value,
                                   GError **error)
{
  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
   
  if (thrift_transport_write (protocol->transport,
                              (const gpointer) &value, 1, error))
  {
    return 1;
  } else {
    return -1;
  }
}
int32_t
thrift_binary_protocol_write_u64 (ThriftProtocol *protocol, const uint64_t value,
                                  int *error)
{
  int64_t net;
  os_put_value64((uint8_t *)&net, value);
  if (thrift_transport_write (protocol->transport,
                              (const void *) &net, 8, error))
  {
    return 8;
  } else {
    return -1;
  }
}
Пример #9
0
gint32
thrift_binary_protocol_write_double (ThriftProtocol *protocol,
                                     const gdouble value, GError **error)
{
  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);

  guint64 bits = GUINT64_FROM_BE (thrift_bitwise_cast_guint64 (value));
  if (thrift_transport_write (protocol->transport,
                              (const gpointer) &bits, 8, error))
  {
    return 8;
  } else {
    return -1;
  }
}
Пример #10
0
gint32
thrift_binary_protocol_write_i64 (ThriftProtocol *protocol, const gint64 value,
                                  GError **error)
{
  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);

  gint64 net = GUINT64_TO_BE (value);
  if (thrift_transport_write (protocol->transport,
                              (const gpointer) &net, 8, error))
  {
    return 8;
  } else {
    return -1;
  }
}
Пример #11
0
gint32
thrift_binary_protocol_write_i32 (ThriftProtocol *protocol, const gint32 value,
                                  GError **error)
{
  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);

  gint32 net = g_htonl (value);
  if (thrift_transport_write (protocol->transport,
                              (const gpointer) &net, 4, error))
  {
    return 4;
  } else {
    return -1;
  }
}
int32_t
thrift_binary_protocol_write_double (ThriftProtocol *protocol,
                                     const double value, int *error)
{
#ifndef __KERNEL__
  // TODO
  u_int64_t bits = thrift_bitwise_cast_u_int64 (value);
  if (thrift_transport_write (protocol->transport,
                              (const void *) &bits, 8, error))
  {
    return 8;
  } else {
    return -1;
  }
#else
  return -1;
#endif
}