# include "pcontrol.h"

// XXX deprecated

int ResetJob (Job *job) {
  
  int       status;
  Host     *host;

  /** must have a valid host : if not, move to pending? **/
  ASSERT (job != NULL, "job missing");

  host = (Host *) job[0].host;
  ASSERT (job != NULL, "host missing");

  /* we have tried to reset the job; may not get status */
  job[0].Reset = TRUE;

  status = PclientCommand (host, "reset");

  /* check on success of pclient command */
  switch (status) {
    case PCLIENT_DOWN:
      if (VerboseMode()) gprint (GP_ERR, "host %s is down\n", host[0].hostname);
      HarvestHost (host[0].pid);
      PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
      return (FALSE);

    case PCLIENT_GOOD:
      host[0].response_state = PCONTROL_RESP_RESET_JOB;
      host[0].response = PCLIENT_PROMPT;
      FlushIOBuffer (&host[0].comms_buffer, 0x100);
      PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM);
      return (TRUE);

    default:
      ABORT ("unknown status for pclient command");  
  }
  ABORT ("should not reach here (ResetJob)"); 
}

int ResetJobResponse (Host *host) {
  
  int       status;
  IOBuffer *buffer;

  /* job must have assigned host */
  ASSERT (host, "missing host");
  ASSERT (host[0].job, "missing job");
  buffer = host[0].comms_buffer;

  gprint (GP_ERR, "message received (ResetJob)\n");  
  return (TRUE);
}

/* if machine is down, return FALSE
   this will place job back in BUSY state,
   next check of job will catch state and
   put machine down correctly

*/
