- ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_1);
- ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_2);
- ODR_MASK_SET(req->protocolVersion, Z_ProtocolVersion_3);
+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;
+}