#include <stdio.h>
#include <string.h>
#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <sys/poll.h>
#include <sys/types.h>
#include <sys/time.h>
extern void *safe_malloc(size_t size, const char *message);
extern void *safe_malloc_ary(size_t size, size_t count, const char *message);
+void setcloexec(int fd); /* cannot fail */
+void pipe_cloexec(int fd[2]); /* pipe(), setcloexec() twice; cannot fail */
+
extern int sys_cmd(const char *file, const char *argc, ...);
extern uint64_t now_global;
comm_addr_to_string_fn *addr_to_string;
};
+static inline const char *comm_addr_to_string(const struct comm_addr *ca)
+{
+ return ca->comm->addr_to_string(ca->comm->st, ca);
+}
+
/* LOG interface */
+#define LOG_MESSAGE_BUFLEN 1023
+
typedef void log_msg_fn(void *st, int class, const char *message, ...);
typedef void log_vmsg_fn(void *st, int class, const char *message,
va_list args);
struct log_if {
void *st;
- log_msg_fn *logfn; /* Do not call these directly - you don't get */
log_vmsg_fn *vlogfn; /* printf format checking. Use [v]slilog instead */
+ char buff[LOG_MESSAGE_BUFLEN+1];
};
/* (convenience functions, defined in util.c) */
extern void slilog(struct log_if *lf, int class, const char *message, ...)
extern void vslilog(struct log_if *lf, int class, const char *message, va_list)
FORMAT(printf,3,0);
+/* Versions which take (parts of) (multiple) messages, using \n to
+ * distinguish one message from another. */
+extern void slilog_part(struct log_if *lf, int class, const char *message, ...)
+FORMAT(printf,3,4);
+extern void vslilog_part(struct log_if *lf, int class, const char *message,
+ va_list) FORMAT(printf,3,0);
+
/* SITE interface */
/* Pretty much a placeholder; allows starting and stopping of processing,
uint8_t *base;
uint8_t *start;
int32_t size; /* Size of buffer contents */
- int32_t len; /* Total length allocated at base */
+ int32_t alloclen; /* Total length allocated at base */
};
/***** LOG functions *****/