chiark / gitweb /
cgroup: rename cg_update_unified() → cg_unified_update()
[elogind.git] / src / basic / parse-util.c
index 757e5b4127041f0de12136b0600702878eb32b35..2daa797a5025dc888f8f764d589944e905498f12 100644 (file)
@@ -558,10 +558,43 @@ int parse_percent_unbounded(const char *p) {
 }
 
 int parse_percent(const char *p) {
-        int v = parse_percent_unbounded(p);
+        int v;
 
+        v = parse_percent_unbounded(p);
         if (v > 100)
                 return -ERANGE;
 
         return v;
 }
+
+#if 0 /// UNNEEDED by elogind
+int parse_nice(const char *p, int *ret) {
+        int n, r;
+
+        r = safe_atoi(p, &n);
+        if (r < 0)
+                return r;
+
+        if (!nice_is_valid(n))
+                return -ERANGE;
+
+        *ret = n;
+        return 0;
+}
+#endif // 0
+
+int parse_ip_port(const char *s, uint16_t *ret) {
+        uint16_t l;
+        int r;
+
+        r = safe_atou16(s, &l);
+        if (r < 0)
+                return r;
+
+        if (l == 0)
+                return -EINVAL;
+
+        *ret = (uint16_t) l;
+
+        return 0;
+}