]> git.sur5r.net Git - i3/i3/blobdiff - include/util.h
Merge branch 'master' into next
[i3/i3] / include / util.h
index 276ea5b9e20db05eca0fcc0b5f0ba59606444188..edc51d812de74580d6387aca300a70a5e4c597df 100644 (file)
     for (Con *child = (Con*)-1; (child == (Con*)-1) && ((child = 0), true);) \
         TAILQ_FOREACH(child, &((head)->nodes_head), nodes)
 
+#define NODES_FOREACH_REVERSE(head) \
+    for (Con *child = (Con*)-1; (child == (Con*)-1) && ((child = 0), true);) \
+        TAILQ_FOREACH_REVERSE(child, &((head)->nodes_head), nodes_head, nodes)
+
 /* greps the ->nodes of the given head and returns the first node that matches the given condition */
 #define GREP_FIRST(dest, head, condition) \
     NODES_FOREACH(head) { \
@@ -164,4 +168,27 @@ char *get_process_filename(const char *prefix);
  */
 void i3_restart(bool forget_layout);
 
+#if defined(__OpenBSD__) || defined(__APPLE__)
+
+/*
+ * Taken from FreeBSD
+ * Find the first occurrence of the byte string s in byte string l.
+ *
+ */
+void *memmem(const void *l, size_t l_len, const void *s, size_t s_len);
+
+#endif
+
+#if defined(__APPLE__)
+
+/*
+ * Taken from FreeBSD
+ * Returns a pointer to a new string which is a duplicate of the
+ * string, but only copies at most n characters.
+ *
+ */
+char *strndup(const char *str, size_t n);
+
+#endif
+
 #endif