if (status == 0)
free((char *)typestr);
}
+
+long parse_pos_long(const char *s, std::ostream *pss)
+{
+ if (*s == '-' || *s == '+') {
+ if (pss)
+ *pss << "expected numerical value, got: " << s;
+ return -EINVAL;
+ }
+
+ string err;
+ long r = strict_strtol(s, 10, &err);
+ if ((r == 0) && !err.empty()) {
+ if (pss)
+ *pss << err;
+ return -1;
+ }
+ if (r < 0) {
+ if (pss)
+ *pss << "unable to parse positive integer '" << s << "'";
+ return -1;
+ }
+ return r;
+}
+
+int parse_osd_id(const char *s, std::ostream *pss)
+{
+ // osd.NNN?
+ if (strncmp(s, "osd.", 4) == 0) {
+ s += 4;
+ }
+
+ // NNN?
+ ostringstream ss;
+ long id = parse_pos_long(s, &ss);
+ if (id < 0) {
+ *pss << ss.str();
+ return id;
+ }
+ if (id > 0xffff) {
+ *pss << "osd id " << id << " is too large";
+ return -ERANGE;
+ }
+ return id;
+}
#define CEPH_COMMON_CMDPARSE_H
#include <boost/variant.hpp>
-
+#include <vector>
+#include <stdexcept>
+#include <ostream>
#include "common/Formatter.h"
#include "common/BackTrace.h"
{
cmdmap[k] = val;
}
+
+extern int parse_osd_id(const char *s, std::ostream *pss);
+extern long parse_pos_long(const char *s, std::ostream *pss = NULL);
+
#endif
};
-long parse_pos_long(const char *s, ostream *pss)
-{
- if (*s == '-' || *s == '+') {
- if (pss)
- *pss << "expected numerical value, got: " << s;
- return -EINVAL;
- }
-
- string err;
- long r = strict_strtol(s, 10, &err);
- if ((r == 0) && !err.empty()) {
- if (pss)
- *pss << err;
- return -1;
- }
- if (r < 0) {
- if (pss)
- *pss << "unable to parse positive integer '" << s << "'";
- return -1;
- }
- return r;
-}
-
void C_MonContext::finish(int r) {
if (mon->is_shutdown())
return;
#define CEPH_MON_FEATURE_INCOMPAT_KRAKEN CompatSet::Feature(8, "support monmap features")
// make sure you add your feature to Monitor::get_supported_features
-long parse_pos_long(const char *s, ostream *pss = NULL);
-
struct MonCommand {
string cmdstring;
string helpstring;
return true;
}
-int OSDMonitor::parse_osd_id(const char *s, stringstream *pss)
-{
- // osd.NNN?
- if (strncmp(s, "osd.", 4) == 0) {
- s += 4;
- }
-
- // NNN?
- ostringstream ss;
- long id = parse_pos_long(s, &ss);
- if (id < 0) {
- *pss << ss.str();
- return id;
- }
- if (id > 0xffff) {
- *pss << "osd id " << id << " is too large";
- return -ERANGE;
- }
- return id;
-}
-
-
int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
stringstream& ss)
{
void tick() override; // check state, take actions
- int parse_osd_id(const char *s, stringstream *pss);
-
void get_health(list<pair<health_status_t,string> >& summary,
list<pair<health_status_t,string> > *detail,
CephContext *cct) const override;