- ODR_MASK_SET(req->options, Z_Options_search);
- ODR_MASK_SET(req->options, Z_Options_present);
- ODR_MASK_SET(req->options, Z_Options_namedResultSets);
- ODR_MASK_SET(req->options, Z_Options_triggerResourceCtrl);
- ODR_MASK_SET(req->options, Z_Options_scan);
- ODR_MASK_SET(req->options, Z_Options_sort);
- ODR_MASK_SET(req->options, Z_Options_extendedServices);
- ODR_MASK_SET(req->options, Z_Options_delSet);
+ int res = 1;
+ if (cmd[i].cmd) // Invoke command handler
+ res = (this->*cmd[i].fun)(cmdArgs);
+ else // Dump help screen
+ {
+ printf("Unknown command: %s.\n", cmdStr);
+ printf("Currently recognized commands:\n");
+ for (i = 0; cmd[i].cmd; i++)
+ printf(" %s %s\n", cmd[i].cmd, cmd[i].ad);
+ }
+ return res;
+}
+
+const char *MyClient::getCommand()
+{
+#if HAVE_READLINE_READLINE_H
+ // Read using GNU readline
+ char *line_in;
+ line_in=readline(C_PROMPT);
+ if (!line_in)
+ return 0;
+#if HAVE_READLINE_HISTORY_H
+ if (*line_in)
+ add_history(line_in);
+#endif
+ strncpy(m_thisCommand,line_in, 1023);
+ m_thisCommand[1023] = '\0';
+ free (line_in);
+#else
+ // Read using fgets(3)
+ printf (C_PROMPT);
+ fflush(stdout);
+ if (!fgets(m_thisCommand, 1023, stdin))
+ return 0;
+#endif
+ // Remove trailing whitespace
+ char *cp = m_thisCommand + strlen(m_thisCommand);
+ while (cp != m_thisCommand && strchr("\t \n", cp[-1]))
+ cp--;
+ *cp = '\0';
+ cp = m_thisCommand;
+ // Remove leading spaces...
+ while (strchr ("\t \n", *cp))
+ cp++;
+ // Save command if non-empty
+ if (*cp != '\0')
+ strcpy (m_lastCommand, cp);
+ return m_lastCommand;
+}
+
+int MyClient::interactive(Yaz_SocketManager *socketManager)
+{
+ const char *cmd;
+ if (!m_interactive_flag)
+ return 0;
+ while ((cmd = getCommand()))
+ {
+ if (!processCommand(cmd))
+ break;
+ }
+ return 0;
+}