# include "basic.h"
# include "scheduler.h"

int task_host (int argc, char **argv) {

  Task *task;
  char *taskname;

  if (argc != 2) {
    fprintf (stderr, "USAGE: host <name>\n");
    fprintf (stderr, "  (define host machine for this task (or 'none'))\n");
    return (FALSE);
  }

  taskname = GetCurrentTask ();
  if (taskname == NULL) {
    fprintf (stderr, "ERROR: not defining or running a task\n");
    return (FALSE);
  }
  task = FindTask (taskname);
  if (task == NULL) {
    fprintf (stderr, "ERROR: current task not found??\n");
    return (FALSE);
  }

  if (task[0].host != NULL) free (task[0].host);
  task[0].host = NULL;

  if (!strcasecmp (argv[1], "NONE")) return (TRUE);

  task[0].host = strcreate (argv[1]);
  return (TRUE);
}
