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, ...);
comm_notify_fn *fn);
typedef bool_t comm_sendmsg_fn(void *commst, struct buffer_if *buf,
const struct comm_addr *dest);
+ /* Only returns false if (we know that) the local network
+ * environment is such that this address cannot work; transient
+ * or unknown/unexpected failures return true. */
typedef const char *comm_addr_to_string_fn(void *commst,
const struct comm_addr *ca);
/* Returned string is in a static buffer. */
#define FILLZERO(obj) (memset(&(obj),0,sizeof((obj))))
+/*
+ * void COPY_OBJ( OBJECT& dst, const OBJECT& src);
+ * void COPY_ARRAY(OBJECT *dst, const OBJECT *src, INTEGER count);
+ * // Typesafe: we check that the type OBJECT is the same in both cases.
+ * // It is OK to use COPY_OBJ on an array object, provided it's
+ * // _actually_ the whole array object and not decayed into a
+ * // pointer (e.g. a formal parameter).
+ */
+#define COPY_OBJ(dst,src) \
+ (&(dst)==&(src), memcpy(&(dst),&(src),sizeof((dst))))
+#define COPY_ARRAY(dst,src,count) \
+ (&(dst)[0]==&(src)[0], memcpy((dst),(src),sizeof((dst)[0])*(count)))
+
#endif /* secnet_h */