+/*
+ * Send a command to the director, and read all the resulting
+ * output into a list.
+ */
+QStringList Console::get_list(char *cmd)
+{
+ QStringList list;
+ int stat;
+
+ setEnabled(false);
+ write(cmd);
+ while ((stat = read()) > 0) {
+ strip_trailing_junk(msg());
+ list << msg();
+ }
+ setEnabled(true);
+// list.sort();
+ return list;
+}
+
+/*
+ * Send a job name to the director, and read all the resulting
+ * defaults.
+ */
+bool Console::get_job_defaults(struct job_defaults &job_defs)
+{
+ QString scmd;
+ char cmd[1000];
+ int stat;
+ char *def;
+
+ setEnabled(false);
+ beginNewCommand();
+ scmd = QString(".defaults job=\"%1\"").arg(job_defs.job_name);
+ write(scmd);
+ while ((stat = read()) > 0) {
+ def = strchr(msg(), '=');
+ if (!def) {
+ continue;
+ }
+ /* Pointer to default value */
+ *def++ = 0;
+ strip_trailing_junk(def);
+
+ if (strcmp(msg(), "job") == 0) {
+ if (strcmp(def, job_defs.job_name.toUtf8().data()) != 0) {
+ goto bail_out;
+ }
+ continue;
+ }
+ if (strcmp(msg(), "pool") == 0) {
+ job_defs.pool_name = def;
+ continue;
+ }
+ if (strcmp(msg(), "messages") == 0) {
+ job_defs.messages_name = def;
+ continue;
+ }
+ if (strcmp(msg(), "client") == 0) {
+ job_defs.client_name = def;
+ continue;
+ }
+ if (strcmp(msg(), "storage") == 0) {
+ job_defs.store_name = def;
+ continue;
+ }
+ if (strcmp(msg(), "where") == 0) {
+ job_defs.where = def;
+ continue;
+ }
+ if (strcmp(msg(), "level") == 0) {
+ job_defs.level = def;
+ continue;
+ }
+ if (strcmp(msg(), "type") == 0) {
+ job_defs.type = def;
+ continue;
+ }
+ if (strcmp(msg(), "fileset") == 0) {
+ job_defs.fileset_name = def;
+ continue;
+ }
+ if (strcmp(msg(), "catalog") == 0) {
+ job_defs.catalog_name = def;
+ continue;
+ }
+ if (strcmp(msg(), "enabled") == 0) {
+ job_defs.enabled = *def == '1' ? true : false;
+ continue;
+ }
+ }
+ bsnprintf(cmd, sizeof(cmd), "job=%s pool=%s client=%s storage=%s where=%s\n"
+ "level=%s type=%s fileset=%s catalog=%s enabled=%d\n",
+ job_defs.job_name.toUtf8().data(), job_defs.pool_name.toUtf8().data(),
+ job_defs.client_name.toUtf8().data(),
+ job_defs.pool_name.toUtf8().data(), job_defs.messages_name.toUtf8().data(),
+ job_defs.store_name.toUtf8().data(),
+ job_defs.where.toUtf8().data(), job_defs.level.toUtf8().data(),
+ job_defs.type.toUtf8().data(), job_defs.fileset_name.toUtf8().data(),
+ job_defs.catalog_name.toUtf8().data(), job_defs.enabled);
+
+ setEnabled(true);