summaryrefslogtreecommitdiff
path: root/dpid/dpid_common.c
diff options
context:
space:
mode:
authorjcid <devnull@localhost>2007-10-07 00:36:34 +0200
committerjcid <devnull@localhost>2007-10-07 00:36:34 +0200
commit93715c46a99c96d6c866968312691ec9ab0f6a03 (patch)
tree573f19ec6aa740844f53a7c0eb7114f04096bf64 /dpid/dpid_common.c
Initial revision
Diffstat (limited to 'dpid/dpid_common.c')
-rw-r--r--dpid/dpid_common.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/dpid/dpid_common.c b/dpid/dpid_common.c
new file mode 100644
index 00000000..a04d9c4f
--- /dev/null
+++ b/dpid/dpid_common.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include "dpid_common.h"
+
+/*
+ * Send a verbose error message.
+ */
+void errmsg(char *caller, char *called, int errornum, char *file, int line)
+{
+ MSG_ERR("%s:%d: %s: %s\n", file, line, caller, called);
+ if (errornum > 0)
+ MSG_ERR("%s\n", dStrerror(errornum));
+}
+
+/*! Selector function for scandir
+ * Do not scan files starting with '.'
+ */
+int no_dotfiles(const struct dirent *filedat)
+{
+ if (filedat->d_name[0] == '.')
+ return 0;
+ else
+ return 1;
+}
+
+/*!
+ * Provides an error checked write command.
+ * Call this via the CKD_WRITE macro
+ * \return write return value
+ */
+ssize_t ckd_write(int fd, char *msg, char *file, int line)
+{
+ ssize_t ret;
+
+ do {
+ ret = write(fd, msg, strlen(msg));
+ } while (ret == -1 && errno == EINTR);
+ if (ret == -1) {
+ MSG_ERR("%s:%d: write: %s\n", file, line, dStrerror(errno));
+ }
+ return (ret);
+}