Check for validity of category/board when placing seek ad
[capablanca.git] / lasker-2.2.3 / src / seekproc.c
index 399dfbe..43ffe66 100644 (file)
@@ -78,6 +78,22 @@ int com_seek(int p, param_list param)
              return COM_OK; /* couldn't parse */
        }
 
+    if (category[0]) {
+      if (!board[0] && strcmp(category,"bughouse")) {
+        pprintf(p, "You must specify a board and a category.\n");
+        return COM_OK;
+
+      } else if (board[0]) { /* not bughouse */
+        char fname[MAX_FILENAME_SIZE];
+
+        sprintf(fname, "%s/%s/%s", BOARD_DIR, category, board);
+        if (!file_exists(fname)) {
+          pprintf(p, "No such category/board: %s/%s\n", category, board);
+          return COM_OK;
+        }
+      }
+    }
+
        seek_globals.ads[num].status = SEEKCLOSED; // params are valid; create ad
 
        if(wt < 0) wt = pp->d_time; if(bt < 0) bt = wt;