* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <cinttypes>
-#include <cstdlib>
#include <cstring>
#include "args.hh"
-int
-parse_int_args(Args *args, uint64_t ints[], int len)
-{
- if (args->argc > len)
- return 0;
-
-// On 32 bit platforms we need to use strtoull to do the conversion
-#ifdef __LP64__
-#define strto64 strtoul
-#else
-#define strto64 strtoull
-#endif
- for (int i = 0; i < len; ++i) {
- const char *arg = pop_arg(args);
- ints[i] = arg ? strto64(arg, NULL, 0) : 0;
- }
-
-#undef strto64
- return 1;
-}
-
-int
-pack_arg_into_regs(Args *args, uint64_t regs[], int num_regs)
+bool
+Args::pack(const std::string &str, uint64_t regs[], int num_regs)
{
const size_t RegSize = sizeof(regs[0]);
const size_t MaxLen = num_regs * RegSize;
- const char *arg = pop_arg(args);
+ const char *arg = str.c_str();
memset(regs, 0, MaxLen);
- size_t len = arg ? strlen(arg) : 0;
+ size_t len = str.size();
if (len > MaxLen)
- return 0;
+ return false;
while (len) {
for (int offset = 0; offset < RegSize && len; offset++, len--) {
}
regs++;
}
- return 1;
+ return true;
}