chiark / gitweb /
exit-status: add missing files src/exit-status.h src/exit-status.c
[elogind.git] / src / util.c
index 0b0063ee0e6078a48cdec42f053be97c42a7742a..f1a7bbdc7124b1d977d536fcb4c83bea80213478 100644 (file)
@@ -57,6 +57,7 @@
 #include "log.h"
 #include "strv.h"
 #include "label.h"
+#include "exit-status.h"
 
 bool streq_ptr(const char *a, const char *b) {
 
@@ -2398,6 +2399,16 @@ bool is_clean_exit(int code, int status) {
         return false;
 }
 
+bool is_clean_exit_lsb(int code, int status) {
+
+        if (is_clean_exit(code, status))
+                return true;
+
+        return
+                code == CLD_EXITED &&
+                (status == EXIT_NOTINSTALLED || status == EXIT_NOTCONFIGURED);
+}
+
 bool is_device_path(const char *path) {
 
         /* Returns true on paths that refer to a device, either in
@@ -2993,6 +3004,19 @@ int touch(const char *path) {
         return 0;
 }
 
+char *unquote(const char *s, const char quote) {
+        size_t l;
+        assert(s);
+
+        if ((l = strlen(s)) < 2)
+                return strdup(s);
+
+        if (s[0] == quote && s[l-1] == quote)
+                return strndup(s+1, l-2);
+
+        return strdup(s);
+}
+
 static const char *const ioprio_class_table[] = {
         [IOPRIO_CLASS_NONE] = "none",
         [IOPRIO_CLASS_RT] = "realtime",