]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rgw/rgw_op.h
update source to 12.2.11
[ceph.git] / ceph / src / rgw / rgw_op.h
index e4d8cd4a980bc9d952ef3b6b82635adcc2c75572..23d97994723f09ad1c690dce03b8eaf7e365303f 100644 (file)
@@ -2214,6 +2214,36 @@ public:
   virtual const string name() { return "get_cluster_stat"; }
 };
 
+static inline int parse_value_and_bound(
+    const string &input,
+    int &output,
+    const long lower_bound,
+    const long upper_bound,
+    const long default_val)
+{
+  if (!input.empty()) {
+    char *endptr;
+    output = strtol(input.c_str(), &endptr, 10);
+    if (endptr) {
+      if (endptr == input.c_str()) return -EINVAL;
+      while (*endptr && isspace(*endptr)) // ignore white space
+        endptr++;
+      if (*endptr) {
+        return -EINVAL;
+      }
+    }
+    if(output > upper_bound) {
+      output = upper_bound;
+    }
+    if(output < lower_bound) {
+      output = lower_bound;
+    }
+  } else {
+    output = default_val;
+  }
+
+  return 0;
+}
 
 
 #endif /* CEPH_RGW_OP_H */