util  pqp.h at [e15188634a]

File wgsync/src/pqp.h artifact 6f4d74622e part of check-in e15188634a


#include "def.h"
#define pq_null  ((uint32_t)0xFFFFffff)
#include <sys/socket.h>
#include <netinet/in.h>

typedef enum pq_array_type {
	pq_array_bool = 0x10,
	pq_array_int  = 0x17,
	pq_array_text = 0x19,
	pq_array_inet = 0x365,
} pq_array_type;

typedef struct pqp_array_elt {
	uint32_t sz;
	const char* data;
} pqp_array_elt;

typedef struct pqp_array {
	size_t sz;
	bool nullable;
	pq_array_type ty;
	pqp_array_elt elts [];
} pqp_array;

/* for receiving values from pqp_inet_read */
typedef union pqp_sockstore {
	struct sockaddr sock;
	struct sockaddr_in sock_in;
	struct sockaddr_in6 sock_in6;
} pqp_sockstore;

struct pqp_array* pqp_array_read(const void* pqary);
bool pqp_inet_read(const void* pqinet, struct sockaddr* d);