chiark / gitweb /
time-util: refuse formatting/parsing times that we can't store
[elogind.git] / src / basic / parse-util.c
index bfdf483229045c18eef1835825798cfd24a8e25a..2daa797a5025dc888f8f764d589944e905498f12 100644 (file)
@@ -567,6 +567,7 @@ int parse_percent(const char *p) {
         return v;
 }
 
+#if 0 /// UNNEEDED by elogind
 int parse_nice(const char *p, int *ret) {
         int n, r;
 
@@ -580,3 +581,20 @@ int parse_nice(const char *p, int *ret) {
         *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;
+}