Exemplo n.º 1
0
static PyObject *
h_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
    long val;
    short field;
    if (get_long(value, &val) < 0)
        return NULL;
    memcpy(&field, ptr, sizeof(field));
    field = SWAP_2(field);
    field = SET(short, field, val, size);
    field = SWAP_2(field);
    memcpy(ptr, &field, sizeof(field));
    _RET(value);
}
Exemplo n.º 2
0
static PyObject *
H_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
    unsigned long val;
    unsigned short field;
    if (get_ulong(value, &val) < 0)
        return NULL;
    memcpy(&field, ptr, sizeof(field));
    field = SWAP_2(field);
    field = SET(field, (unsigned short)val, size);
    field = SWAP_2(field);
    memcpy(ptr, &field, sizeof(field));
    _RET(value);
}
Exemplo n.º 3
0
static PyObject *
H_get_sw(void *ptr, Py_ssize_t size)
{
    unsigned short val;
    memcpy(&val, ptr, sizeof(val));
    val = SWAP_2(val);
    GET_BITFIELD(val, size);
    return PyLong_FromLong(val);
}
Exemplo n.º 4
0
static void
sSwapDYN (
  register MQ_BIN ist
)
{
  MQ_INT numItems = 0, len = 0;
  MQ_BINB type;

  // BDY_NumItems_S
  SWAP_4 (ist);
  memcpy(&numItems, ist, sizeof(MQ_INT));

  // for all Element's
  ist += (HDR_INT_LEN + 1);
  while (numItems) {

    // type
    type = *ist;
    ist += 2;

    // len
    len = (type & MQ_TYPE_IS_NATIVE);
    if (len == 0) {
      SWAP_4 (ist);
      memcpy(&len, ist, sizeof(MQ_INT));
      ist += (HDR_INT_LEN + 1);
    }

    // val
    switch ((enum MqTypeE)type) {
      case MQ_SRTT: SWAP_2  (ist);  break;
      case MQ_INTT: SWAP_4  (ist);  break;
      case MQ_FLTT: SWAP_4  (ist);  break;
      case MQ_WIDT: SWAP_8  (ist);  break;
      case MQ_DBLT: SWAP_8  (ist);  break;
      case MQ_STRT: case MQ_BINT: case MQ_BYTT: case MQ_BOLT: case MQ_TRAT: break;
      case MQ_LSTT: sSwapDYN (ist); break;
    }
    ist += (len + 1);
    numItems--;
  }
}