X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/6d81055d46da8559155869c7c2762c814bb02d23..b27841d687ec9e84983340b5581376dfb24010ea:/projects/stargazer/plugins/other/smux/types.cpp diff --git a/projects/stargazer/plugins/other/smux/types.cpp b/projects/stargazer/plugins/other/smux/types.cpp index eb09a73c..8132bca0 100644 --- a/projects/stargazer/plugins/other/smux/types.cpp +++ b/projects/stargazer/plugins/other/smux/types.cpp @@ -1,9 +1,16 @@ +#include "types.h" + #include #include #include #include -#include "types.h" +namespace +{ + +bool ParseArcs(const char * str, ptrdiff_t length, unsigned * a, size_t * pos); +bool StringToArcs(const char * str, size_t length, std::vector & arcs); +bool AppendToArcs(const char * str, size_t length, std::vector & arcs); bool ParseArcs(const char * str, ptrdiff_t length, unsigned * a, size_t * pos) { @@ -15,14 +22,14 @@ if (*left == '.') size_t arcPos = 0; while ((left - str) < length) { - char * pos = NULL; - unsigned arc = strtoul(left, &pos, 10); - if (pos == left) + char * p = NULL; + unsigned arc = static_cast(strtoul(left, &p, 10)); + if (p == left) return false; a[arcPos++] = arc; if (arcPos >= 1024) return false; - left = pos + 1; + left = p + 1; } *pos = arcPos; return true; @@ -52,6 +59,8 @@ std::copy(&a[0], &a[pos], std::back_inserter(arcs)); return true; } +} + OID::OID(const std::string & str) : arcs() { @@ -182,7 +191,7 @@ return stream.str(); void OID::ToOID(OBJECT_IDENTIFIER_t * oid) const { -OBJECT_IDENTIFIER_set_arcs(oid, &arcs.front(), sizeof(unsigned), arcs.size()); +OBJECT_IDENTIFIER_set_arcs(oid, &arcs.front(), sizeof(unsigned), static_cast(arcs.size())); } OID & OID::operator=(const OID & rvalue)