+/*
+ * Get a positive integer
+ * Returns: false if failure
+ * true if success => value in ua->pint32_val
+ */
+bool get_pint(UAContext *ua, const char *prompt)
+{
+ double dval;
+ ua->pint32_val = 0;
+ ua->int64_val = 0;
+ for (;;) {
+ ua->cmd[0] = 0;
+ if (!get_cmd(ua, prompt)) {
+ return false;
+ }
+ /* Kludge for slots blank line => 0 */
+ if (ua->cmd[0] == 0 && strncmp(prompt, _("Enter slot"), strlen(_("Enter slot"))) == 0) {
+ return true;
+ }
+ if (!is_a_number(ua->cmd)) {
+ ua->warning_msg(_("Expected a positive integer, got: %s\n"), ua->cmd);
+ continue;
+ }
+ errno = 0;
+ dval = strtod(ua->cmd, NULL);
+ if (errno != 0 || dval < 0) {
+ ua->warning_msg(_("Expected a positive integer, got: %s\n"), ua->cmd);
+ continue;
+ }
+ ua->pint32_val = (uint32_t)dval;
+ ua->int64_val = (int64_t)dval;
+ return true;
+ }
+}
+
+/*
+ * Test a yes or no response
+ * Returns: false if failure
+ * true if success => ret == 1 for yes
+ * ret == 0 for no