/* read_float(nds_socket_type fd, float*) * * read a float from the indicated fd and swap bytes from network * byte ordering (big-endian) to host byte ordering. */ int read_float(nds_socket_type fd, float* data) { union {uint32_t i; float f;} d; if (read_uint4(fd, &d.i)) return DAQD_ERROR; *data = d.f; return DAQD_OK; }
/* * Read an NDS2 byte-counted string from the specified fd. The string is * transferred as an integer byte-count followed by text. */ int _daq_read_string(nds_socket_type fd, size_t maxlen, char* buf) { int rc; uint4_type tmp = 0; size_t len; if (read_uint4(fd, &tmp)) return -1; len = tmp; if (len == 0) { if (maxlen && buf) *buf = 0; return (int)len; } if (len > maxlen) rc = read_bytes(fd, buf, maxlen); else rc = read_bytes(fd, buf, len); if (rc < 0) return -1; if ((size_t)rc < maxlen) buf[rc] = 0; return (int)len; }
int32_t read_sint4() { return static_cast<int32_t>(read_uint4()); }