IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 16, 2006, 10:58:49 PM (20 years ago)
Author:
eugene
Message:

major updates to use gprint for buffered / threaded printing

Location:
trunk/Ohana/src/opihi/pantasks
Files:
39 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pantasks/CheckController.c

    r6687 r7917  
    1919  // TimerMark ();
    2020  // status = ControllerCommand ("stop", CONTROLLER_PROMPT, &buffer);
    21   // if (VerboseMode()) fprintf (stderr, "stop controller %f\n", TimerElapsed(TRUE));
     21  // if (VerboseMode()) gprint (GP_ERR, "stop controller %f\n", TimerElapsed(TRUE));
    2222
    2323  TimerMark ();
    2424  FlushIOBuffer (&buffer);
    2525  status = ControllerCommand ("jobstack exit", CONTROLLER_PROMPT, &buffer);
    26   if (VerboseMode()) fprintf (stderr, "check exit stack %f\n", TimerElapsed(TRUE));
     26  if (VerboseMode()) gprint (GP_ERR, "check exit stack %f\n", TimerElapsed(TRUE));
    2727  if (!status) goto escape;
    2828
     
    3434  status = sscanf (buffer.buffer, "%*s %d", &Njobs);
    3535  if (status != 1) goto escape;
    36   if (VerboseMode()) fprintf (stderr, "parse %d jobs on stack %f\n", Njobs, TimerElapsed(TRUE));
     36  if (VerboseMode()) gprint (GP_ERR, "parse %d jobs on stack %f\n", Njobs, TimerElapsed(TRUE));
    3737
    3838  p = buffer.buffer;
     
    4040    q = strchr (p, '\n');
    4141    if (q == NULL) {
    42       fprintf (stderr, "controller message error: incomplete job list\n");
     42      gprint (GP_ERR, "controller message error: incomplete job list\n");
    4343      break;
    4444    }
     
    4848    job = FindControllerJob (JobID);
    4949    if (job == NULL) {
    50       fprintf (stderr, "misplaced job? %d not in EXIT job list\n", JobID);
     50      gprint (GP_ERR, "misplaced job? %d not in EXIT job list\n", JobID);
    5151      continue;
    5252    }
     
    5454    CheckControllerJob (job);
    5555  }
    56   if (VerboseMode()) fprintf (stderr, "clear %d exit jobs %f\n", i, TimerElapsed(TRUE));
     56  if (VerboseMode()) gprint (GP_ERR, "clear %d exit jobs %f\n", i, TimerElapsed(TRUE));
    5757
    5858  if (TestElapsedCheck()) goto finish;
     
    7070  status = sscanf (buffer.buffer, "%*s %d", &Njobs);
    7171  if (status != 1) goto escape;
    72   if (VerboseMode()) fprintf (stderr, "check crash stack %f\n", TimerElapsed(TRUE));
     72  if (VerboseMode()) gprint (GP_ERR, "check crash stack %f\n", TimerElapsed(TRUE));
    7373
    7474  p = buffer.buffer;
     
    7676    q = strchr (p, '\n');
    7777    if (q == NULL) {
    78       fprintf (stderr, "controller message error: incomplete job list\n");
     78      gprint (GP_ERR, "controller message error: incomplete job list\n");
    7979      break;
    8080    }
     
    8484    job = FindControllerJob (JobID);
    8585    if (job == NULL) {
    86       fprintf (stderr, "misplaced job? %d not in CRASH job list\n", JobID);
     86      gprint (GP_ERR, "misplaced job? %d not in CRASH job list\n", JobID);
    8787      continue;
    8888    }
     
    9090    CheckControllerJob (job);
    9191  }
    92   if (VerboseMode()) fprintf (stderr, "clear %d crash jobs %f\n", i, TimerElapsed(TRUE));
     92  if (VerboseMode()) gprint (GP_ERR, "clear %d crash jobs %f\n", i, TimerElapsed(TRUE));
    9393
    9494 finish:
  • trunk/Ohana/src/opihi/pantasks/CheckJobs.c

    r6687 r7917  
    1818    switch (status) {
    1919      case JOB_PENDING:
    20         /* if (VerboseMode()) fprintf (stderr, "job %s (%d) pending\n", job[0].task[0].name, job[0].JobID); */
     20        /* if (VerboseMode()) gprint (GP_LOG, "job %s (%d) pending\n", job[0].task[0].name, job[0].JobID); */
    2121        break;
    2222
    2323      case JOB_BUSY:
    24         /* if (VerboseMode()) fprintf (stderr, "job %s (%d) busy\n", job[0].task[0].name, job[0].JobID); */
     24        /* if (VerboseMode()) gprint (GP_LOG, "job %s (%d) busy\n", job[0].task[0].name, job[0].JobID); */
    2525        break;
    2626
     
    2828        /* run task[0].crash macro, if it exists */
    2929        /* push output buffer data to the stdout and stderr queues */
    30         if (VerboseMode()) fprintf (stderr, "job %s (%d) crash\n", job[0].task[0].name, job[0].JobID);
     30        if (VerboseMode()) gprint (GP_LOG, "job %s (%d) crash\n", job[0].task[0].name, job[0].JobID);
    3131        PushNamedQueue ("stdout", job[0].stdout.buffer);
    3232        PushNamedQueue ("stderr", job[0].stderr.buffer);
     
    4848
    4949      case JOB_EXIT:
    50         if (VerboseMode()) fprintf (stderr, "job %s (%d) exit\n", job[0].task[0].name, job[0].JobID);
     50        if (VerboseMode()) gprint (GP_LOG, "job %s (%d) exit\n", job[0].task[0].name, job[0].JobID);
    5151        PushNamedQueue ("stdout", job[0].stdout.buffer);
    5252        PushNamedQueue ("stderr", job[0].stderr.buffer);
     
    7979
    8080      default:
    81         if (VerboseMode()) fprintf (stderr, "unknown exit status: %d\n", status);
     81        if (VerboseMode()) gprint (GP_LOG, "unknown exit status: %d\n", status);
    8282        /** do something more useful here ?? **/
    8383        break;
     
    8989    if (job[0].mode == JOB_LOCAL) {
    9090      if (GetTaskTimer(job[0].start) < job[0].task[0].timeout_period) continue;
    91       if (VerboseMode()) fprintf (stderr, "timeout on %s\n", job[0].task[0].name);
     91      if (VerboseMode()) gprint (GP_LOG, "timeout on %s\n", job[0].task[0].name);
    9292
    9393      /* update the timeout counter */
     
    9696      if (!KillLocalJob (job)) {
    9797        job[0].state = JOB_HUNG;
    98         if (VerboseMode()) fprintf (stderr, "child process %d is hung, cannot kill\n", job[0].pid);
     98        if (VerboseMode()) gprint (GP_LOG, "child process %d is hung, cannot kill\n", job[0].pid);
    9999        continue;
    100100      }
  • trunk/Ohana/src/opihi/pantasks/CheckPassword.c

    r7892 r7917  
    1515  int status;
    1616
    17   if (DEBUG) fprintf (stderr, "waiting for password %s\n", PASSWORD);
     17  if (DEBUG) gprint (GP_ERR, "waiting for password %s\n", PASSWORD);
    1818
    1919  status = ExpectCommand (BindSocket, strlen(PASSWORD), 0.1, &message);
    2020  if (status != 0) {
    21     if (DEBUG) fprintf (stderr, "failed connection\n");
     21    if (DEBUG) gprint (GP_ERR, "failed connection\n");
    2222    FreeIOBuffer (&message);
    2323    close (BindSocket);
     
    2525  }
    2626  if (strncmp (message.buffer, PASSWORD, strlen(PASSWORD))) {
    27     if (DEBUG) fprintf (stderr, "invalid password\n");
     27    if (DEBUG) gprint (GP_ERR, "invalid password\n");
    2828    close (BindSocket);
    2929    return (FALSE);
    3030  }
    31   if (DEBUG) fprintf (stderr, "accepted password (%s)\n", message.buffer);
     31  if (DEBUG) gprint (GP_ERR, "accepted password (%s)\n", message.buffer);
    3232 
    3333  return (TRUE);
  • trunk/Ohana/src/opihi/pantasks/ControllerOps.c

    r6687 r7917  
    2525  gettimeofday (&stop, (void *) NULL);
    2626  dtime = DTIME (stop, start);
    27   /* if (VerboseMode()) fprintf (stderr, "check job status %f\n", dtime); */
     27  /* if (VerboseMode()) gprint (GP_ERR, "check job status %f\n", dtime); */
    2828
    2929  if ((job[0].state == JOB_EXIT) || (job[0].state == JOB_CRASH)) {
     
    3232    gettimeofday (&stop, (void *) NULL);
    3333    dtime = DTIME (stop, start);
    34     /* if (VerboseMode()) fprintf (stderr, "get stdout %f\n", dtime); */
     34    /* if (VerboseMode()) gprint (GP_ERR, "get stdout %f\n", dtime); */
    3535
    3636    gettimeofday (&start, (void *) NULL);
     
    3838    gettimeofday (&stop, (void *) NULL);
    3939    dtime = DTIME (stop, start);
    40     /* if (VerboseMode()) fprintf (stderr, "get stderr %f\n", dtime); */
     40    /* if (VerboseMode()) gprint (GP_ERR, "get stderr %f\n", dtime); */
    4141
    4242    gettimeofday (&start, (void *) NULL);
     
    4444    gettimeofday (&stop, (void *) NULL);
    4545    dtime = DTIME (stop, start);
    46     /* if (VerboseMode()) fprintf (stderr, "delete job %f\n", dtime); */
     46    /* if (VerboseMode()) gprint (GP_ERR, "delete job %f\n", dtime); */
    4747  } 
    4848  return (TRUE);
     
    8181  p = memstr (buffer.buffer, "job not found", buffer.Nbuffer);
    8282  if (p != NULL) {
    83     fprintf (stderr, "unknown job %d\n", job[0].pid);
     83    gprint (GP_ERR, "unknown job %d\n", job[0].pid);
    8484    FreeIOBuffer (&buffer);
    8585    return (FALSE);
     
    105105  if (!strcmp(status_string, "CRASH"))   outstate = JOB_CRASH;
    106106  if (outstate == -1) {
    107     fprintf (stderr, "programming error?\n");
     107    gprint (GP_ERR, "programming error?\n");
    108108    exit (1);
    109109  }
     
    147147  if (status == -1) return (CONTROLLER_HUNG);
    148148
    149   /* if (VerboseMode()) fprintf (stderr, "message received (GetJobOutput : %s)\n", cmd);   */
     149  /* if (VerboseMode()) gprint (GP_ERR, "message received (GetJobOutput : %s)\n", cmd);   */
    150150  /* drop extra bytes from pcontrol (not pclient:job) */
    151151  buffer[0].Nbuffer = Nstart + Nbytes;
     
    205205  p = memstr (buffer.buffer, "JobID", buffer.Nbuffer);
    206206  if (p == NULL) {
    207     fprintf (stderr, "missing PID in pcontrol message : programming error\n");
     207    gprint (GP_ERR, "missing PID in pcontrol message : programming error\n");
    208208    exit (1);
    209209  }
     
    240240  pid = fork ();
    241241  if (!pid) { /* must be child process */
    242     fprintf (stderr, "starting controller connection\n");
     242    gprint (GP_LOG, "starting controller connection\n");
    243243
    244244    /* close the other ends of the pipes */
     
    303303  ControllerPID = pid;
    304304  ControllerStatus = TRUE;
    305   fprintf (stderr, "Connected\n");
     305  gprint (GP_LOG, "Connected\n");
    306306  return (TRUE);
    307307
     
    311311
    312312io_error:
    313   fprintf (stderr, "timeout while connecting\n");
     313  gprint (GP_ERR, "timeout while connecting\n");
    314314  goto close_pipes;
    315315
     
    341341  if ((status == -1) && (errno == EPIPE)) {
    342342    StopController ();
    343     if (VerboseMode()) fprintf (stderr, "controller is down\n");
     343    if (VerboseMode()) gprint (GP_ERR, "controller is down\n");
    344344    return (FALSE);
    345345  }
     
    355355  if (status ==  0) {
    356356    StopController ();
    357     if (VerboseMode()) fprintf (stderr, "controller is down\n");
     357    if (VerboseMode()) gprint (GP_ERR, "controller is down\n");
    358358    return (FALSE);
    359359  }
    360360  if (status == -1) {
    361     if (VerboseMode()) fprintf (stderr, "controller is not responding\n");
     361    if (VerboseMode()) gprint (GP_ERR, "controller is not responding\n");
    362362    return (FALSE);
    363363  }
     
    369369    bzero (buffer[0].buffer + buffer[0].Nbuffer, buffer[0].Nalloc - buffer[0].Nbuffer);
    370370  }
    371   /* if (VerboseMode()) fprintf (stderr, "message received, %d cycles\n", i); */
     371  /* if (VerboseMode()) gprint (GP_ERR, "message received, %d cycles\n", i); */
    372372  return (TRUE);
    373373}
     
    383383  switch (Nread) {
    384384    case -2:  /* error in read (programming error?  system level error?) */
    385       fprintf (stderr, "serious IO error\n");
     385      gprint (GP_ERR, "serious IO error\n");
    386386      exit (2);
    387387    case -1:  /* no data in pipe */
     
    395395  switch (Nread) {
    396396    case -2:  /* error in read (programming error?  system level error?) */
    397       fprintf (stderr, "serious IO error\n");
     397      gprint (GP_ERR, "serious IO error\n");
    398398      exit (2);
    399399    case -1:  /* no data in pipe */
     
    407407int PrintControllerOutput () {
    408408
    409   fprintf (stderr, "--- stdout ---\n");
    410   fwrite (stdout_buffer.buffer, 1, stdout_buffer.Nbuffer, stderr);
    411   fprintf (stderr, "--- stdout ---\n");
    412   fwrite (stderr_buffer.buffer, 1, stderr_buffer.Nbuffer, stderr);
    413   fprintf (stderr, "---  done  ---\n");
     409  gprint (GP_LOG, "--- stdout ---\n");
     410  gwrite (stdout_buffer.buffer, 1, stdout_buffer.Nbuffer, GP_LOG);
     411  gprint (GP_LOG, "--- stderr ---\n");
     412  gwrite (stderr_buffer.buffer, 1, stderr_buffer.Nbuffer, GP_LOG);
     413  gprint (GP_LOG, "---  done  ---\n");
    414414  return (TRUE);
    415415}
  • trunk/Ohana/src/opihi/pantasks/JobOps.c

    r6687 r7917  
    6565  int i;
    6666
    67   fprintf (stderr, "\n");
     67  gprint (GP_LOG, "\n");
    6868  if (Njobs == 0) {
    69     fprintf (stderr, " no defined jobs\n");
     69    gprint (GP_LOG, " no defined jobs\n");
    7070    return;
    7171  }
    7272
    73   fprintf (stderr, " Jobs\n");
    74   for (i = 0; i < Njobs; i++) {
    75     fprintf (stderr, " %d: %-15s %5d %20s (%lx)\n", Njobs, jobs[i][0].task[0].name, jobs[i][0].JobID, jobs[i][0].argv[0], (long) jobs[i][0].argv);
     73  gprint (GP_LOG, " Jobs\n");
     74  for (i = 0; i < Njobs; i++) {
     75    gprint (GP_LOG, " %d: %-15s %5d %20s (%lx)\n", Njobs, jobs[i][0].task[0].name, jobs[i][0].JobID, jobs[i][0].argv[0], (long) jobs[i][0].argv);
    7676  }
    7777  return;
     
    155155  }
    156156  if (Nm == -1) {
    157     fprintf (stderr, "programming error: job not found\n");
     157    gprint (GP_ERR, "programming error: job not found\n");
    158158    return (FALSE);
    159159  }
  • trunk/Ohana/src/opihi/pantasks/ListenClients.c

    r7892 r7917  
    2525  */
    2626
    27   if (DEBUG) fprintf (stderr, "adding a new client (%d)\n", client);
     27  if (DEBUG) gprint (GP_LOG, "adding a new client (%d)\n", client);
    2828  clients[Nclients] = client;
    2929  InitIOBuffer(&buffers[Nclients], 256);
     
    4242  fd_set fdSet;
    4343  struct timeval timeout;
     44  IOBuffer *outbuffer;
    4445
    4546  InitClients ();
     
    5051    for (i = 0; i < Ncurrent; i++) {
    5152      ExpectMessage (clients[i], 0.25, &buffers[i]);
    52       if (DEBUG) fprintf (stderr, "read %d from client %d\n", buffers[i].Nbuffer, i);
     53      if (DEBUG) gprint (GP_ERR, "read %d from client %d\n", buffers[i].Nbuffer, i);
    5354      if (buffers[i].Nbuffer) {
    54         if (DEBUG) fprintf (stderr, "%s\n", buffers[i].buffer);
     55        if (DEBUG) gprint (GP_ERR, "%s\n", buffers[i].buffer);
    5556      }
    5657    }
     
    7374      FD_SET (clients[i], &fdSet);
    7475      if (FD_ISSET(clients[i], &fdSet)) {
    75         if (DEBUG) fprintf (stderr, "fd %d is set\n", clients[i]);
     76        if (DEBUG) gprint (GP_ERR, "fd %d is set\n", clients[i]);
    7677      } else {
    77         if (DEBUG) fprintf (stderr, "fd %d is not set\n", clients[i]);
     78        if (DEBUG) gprint (GP_ERR, "fd %d is not set\n", clients[i]);
    7879      }
    7980    }   
     
    8182
    8283    /* block until we have some data on the pipes (or timeout) */
    83     if (DEBUG) fprintf (stderr, "listening to %d clients\n", Ncurrent);
     84    if (DEBUG) gprint (GP_ERR, "listening to %d clients\n", Ncurrent);
    8485    status = select (Nmax, &fdSet, NULL, NULL, &timeout);
    8586
    86     if (DEBUG) fprintf (stderr, "messages from %d clients\n", status);
     87    if (DEBUG) gprint (GP_ERR, "messages from %d clients\n", status);
    8788
    8889    if (status == -1) {
     
    99100
    100101      /* this client has data, handle it */
    101       if (DEBUG) fprintf (stderr, "data from client %d\n", clients[i]);
    102 
    103       if (DEBUG) fprintf (stderr, "start: ", buffers[i].buffer);
    104       fwrite (buffers[i].buffer, 1, buffers[i].Nbuffer, stderr);
    105       if (DEBUG) fprintf (stderr, "...\n");
     102      if (DEBUG) {
     103        gprint (GP_ERR, "data from client %d\n", clients[i]);
     104        gprint (GP_ERR, "start: ", buffers[i].buffer);
     105        gwrite (buffers[i].buffer, 1, buffers[i].Nbuffer, GP_ERR);
     106        gprint (GP_ERR, "...\n");
     107      }
    106108       
    107109      /* read until the pipe is empty: -1 is empty, -2 is error */
     
    109111      while (Nread >= 0) {
    110112        Nread = ReadtoIOBuffer (&buffers[i], clients[i]);       
    111         if (DEBUG) fprintf (stderr, "read %d bytes from socket\n", Nread);
     113        if (DEBUG) gprint (GP_ERR, "read %d bytes from socket\n", Nread);
    112114
    113115        if (Nread == -2) {
    114116          /* error: do something */
    115           if (1) fprintf (stderr, "error reading from socket\n");
     117          if (1) gprint (GP_ERR, "error reading from socket\n");
    116118        }
    117119      }
    118       if (DEBUG) fprintf (stderr, "read %d total bytes\n", buffers[i].Nbuffer);
     120      if (DEBUG) gprint (GP_ERR, "read %d total bytes\n", buffers[i].Nbuffer);
    119121
    120122      if (DEBUG) {
    121         fprintf (stderr, "end: ", buffers[i].buffer);
    122         fwrite (buffers[i].buffer, 1, buffers[i].Nbuffer, stderr);
    123         fprintf (stderr, "...\n");
     123        gprint (GP_ERR, "end: ", buffers[i].buffer);
     124        gwrite (buffers[i].buffer, 1, buffers[i].Nbuffer, GP_ERR);
     125        gprint (GP_ERR, "...\n");
    124126      }
    125127       
     
    129131
    130132      /* we now have a possible command from the client: run it */
     133      /* XXX : we need to handle ; in the client-parsing of commands */
    131134      stripwhite (line);
    132135      if (*line) {
    133         if (1) fprintf (stderr, "got command: %s\n", line);
     136        if (1) gprint (GP_ERR, "got command: %s\n", line);
     137        SetOutBuffer ();
    134138        status = multicommand (line);
     139        outbuffer = GetOutBuffer ();
     140
     141        gprint (GP_ERR, "send message: %d bytes\n", outbuffer[0].Nbuffer);
     142        gwrite (outbuffer[0].buffer, 1, outbuffer[0].Nbuffer, GP_ERR);
     143        gprint (GP_ERR, "end message\n");
     144       
     145        SendMessage (clients[i], outbuffer[0].buffer);
     146        SetOutfile ("stdout");
    135147      }
    136148      free (line);
    137149
     150     
    138151      /* this function should return the output buffer
    139152         to the currently selected client */
  • trunk/Ohana/src/opihi/pantasks/LocalJob.c

    r6687 r7917  
    2424    switch (Nread) {
    2525      case -2:  /* error in read (programming error?  system level error?) */
    26         fprintf (stderr, "serious IO error\n");
     26        gprint (GP_ERR, "serious IO error\n");
    2727        exit (2);
    2828      case -1:  /* no data in pipe */
     
    3636    switch (Nread) {
    3737      case -2:  /* error in read (programming error?  system level error?) */
    38         fprintf (stderr, "serious IO error\n");
     38        gprint (GP_ERR, "serious IO error\n");
    3939        exit (2);
    4040      case -1:  /* no data in pipe */
     
    5757      switch (errno) {
    5858        case ECHILD:
    59           fprintf (stderr, "unknown PID, not a child proc\n");
    60           fprintf (stderr, "did process already exit?  programming error?\n");
     59          gprint (GP_ERR, "unknown PID, not a child proc\n");
     60          gprint (GP_ERR, "did process already exit?  programming error?\n");
    6161          job[0].state = JOB_NONE;
    6262          job[0].exit_status = 0;
    6363          return (FALSE);
    6464        case EINVAL:
    65           fprintf (stderr, "error EINVAL (waitpid): programming error\n");
     65          gprint (GP_ERR, "error EINVAL (waitpid): programming error\n");
    6666          exit (1);
    6767        case EINTR:
    68           fprintf (stderr, "error EINTR (waitpid): programming error\n");
     68          gprint (GP_ERR, "error EINTR (waitpid): programming error\n");
    6969          exit (1);
    7070        default:
    71           fprintf (stderr, "unknown error for waitpid (%d): programming error\n", errno);
     71          gprint (GP_ERR, "unknown error for waitpid (%d): programming error\n", errno);
    7272          exit (1);
    7373      }
     
    8181    default:
    8282      if (result != job[0].pid) {
    83         fprintf (stderr, "waitpid error: mis-matched PID (%d vs %d).  programming error\n", result, job[0].pid);
     83        gprint (GP_ERR, "waitpid error: mis-matched PID (%d vs %d).  programming error\n", result, job[0].pid);
    8484        exit (1);
    8585      }
     
    9393      }
    9494      if (WIFSTOPPED(waitstatus)) {
    95         fprintf (stderr, "waitpid returns 'stopped': programming error\n");
     95        gprint (GP_ERR, "waitpid returns 'stopped': programming error\n");
    9696        exit (1);
    9797      }
     
    114114  pid = fork ();
    115115  if (!pid) { /* must be child process */
    116     if (VerboseMode()) fprintf (stderr, "starting local job\n");
     116    if (VerboseMode()) gprint (GP_ERR, "starting local job\n");
    117117
    118118    /* close the other ends of the pipes */
  • trunk/Ohana/src/opihi/pantasks/Makefile

    r7892 r7917  
    1919# link flags
    2020LIBS    =       -L$(LIB) -L$(LLIB) -L$(XLIB)
    21 LIBS1   =       -lsocket -lnsl -lreadline $(TLIB) -ldvo -lkapa -lFITS -lohana -lX11 -lm
     21LIBS1   =       -lsocket -lnsl -lreadline $(TLIB) -ldvo -lkapa -lFITS -lohana -lX11 -lpthread -lm
    2222LIBS2   =       -lbasiccmd -ldatacmd -lastrocmd -lshell -ldata
    2323LFLAGS  =       $(LIBS) $(LIBS2) $(LIBS1)
     
    9494$(BIN)/pantasks_server.$(ARCH) : $(server) $(funcs) $(cmds) $(libs)
    9595        @if [ ! -d $(BIN) ]; then mkdir -p $(BIN); fi
    96         $(CC) -o $@ $^ $(LFLAGS) -lpthread
     96        $(CC) -o $@ $^ $(LFLAGS)
    9797
    9898pantasks_client.install: $(DESTBIN)/pantasks_client
  • trunk/Ohana/src/opihi/pantasks/SocketOps.c

    r7892 r7917  
    3333  status = inet_aton (hostip, &Address[0].sin_addr);
    3434  if (!status) {
    35     fprintf (stderr, "invalid address\n");
     35    gprint (GP_ERR, "invalid address\n");
    3636    exit (2);
    3737  }
     
    4646  }
    4747
    48   if (DEBUG) fprintf (stderr, "init sock: %d, len: %d\n", InitSocket, length);
     48  if (DEBUG) gprint (GP_ERR, "init sock: %d, len: %d\n", InitSocket, length);
    4949  status = bind (InitSocket, (struct sockaddr *) Address, length);
    5050  if (status == -1) {
     
    7474  fcntl (InitSocket, F_SETFL, !O_NONBLOCK);
    7575
    76   if (DEBUG) fprintf (stderr, "init sock: %d, len: %d\n", InitSocket, length);
     76  if (DEBUG) gprint (GP_ERR, "init sock: %d, len: %d\n", InitSocket, length);
    7777  BindSocket = accept (InitSocket, (struct sockaddr *) &Address_in, &length);
    78   if (DEBUG) fprintf (stderr, "bind sock: %d\n", BindSocket);
     78  if (DEBUG) gprint (GP_ERR, "bind sock: %d\n", BindSocket);
    7979  if (BindSocket == -1) {
    8080    perror ("accept: ");
     
    8484  addr = Address_in.sin_addr.s_addr;
    8585  if (DEBUG) {
    86     fprintf (stderr, "incoming connection from: ");
    87     fprintf (stderr, " %u", (0xff & (addr >>  0)));
    88     fprintf (stderr, ".%u", (0xff & (addr >>  8)));
    89     fprintf (stderr, ".%u", (0xff & (addr >> 16)));
    90     fprintf (stderr, ".%u", (0xff & (addr >> 24)));
    91     fprintf (stderr, "\n");
     86    gprint (GP_ERR, "incoming connection from: ");
     87    gprint (GP_ERR, " %u", (0xff & (addr >>  0)));
     88    gprint (GP_ERR, ".%u", (0xff & (addr >>  8)));
     89    gprint (GP_ERR, ".%u", (0xff & (addr >> 16)));
     90    gprint (GP_ERR, ".%u", (0xff & (addr >> 24)));
     91    gprint (GP_ERR, "\n");
    9292  }
    9393
     
    109109  }
    110110
    111   if (DEBUG) fprintf (stderr, "connection rejected\n");
     111  if (DEBUG) gprint (GP_ERR, "connection rejected\n");
    112112  close (BindSocket);
    113113  return (-1);
    114114
    115115accepted:
    116   if (DEBUG) fprintf (stderr, "connection accepted\n");
     116  if (DEBUG) gprint (GP_ERR, "connection accepted\n");
    117117  fcntl (BindSocket, F_SETFL, O_NONBLOCK);
    118118  return (BindSocket);
     
    135135
    136136  if (DEBUG) {
    137     fprintf (stderr, "trying %s (%s:%d)...", host[0].h_name, hostip, MY_PORT);
     137    gprint (GP_ERR, "trying %s (%s:%d)...", host[0].h_name, hostip, MY_PORT);
    138138  }
    139139
     
    142142  status = inet_aton (hostip, &Address.sin_addr);
    143143  if (!status) {
    144     fprintf (stderr, "invalid address\n");
     144    gprint (GP_ERR, "invalid address\n");
    145145    exit (2);
    146146  }
     
    160160  }
    161161
    162   if (DEBUG) fprintf (stderr, "connected\n");
     162  if (DEBUG) gprint (GP_ERR, "connected\n");
    163163  fcntl (InitSocket, F_SETFL, O_NONBLOCK);
    164164  return (InitSocket);
     
    183183  status = inet_aton (hostip, &Address[0].sin_addr);
    184184  if (!status) {
    185     fprintf (stderr, "invalid address\n");
     185    gprint (GP_ERR, "invalid address\n");
    186186    exit (2);
    187187  }
     
    195195  }
    196196
    197   if (DEBUG) fprintf (stderr, "init sock: %d, len: %d\n", InitSocket, length);
     197  if (DEBUG) gprint (GP_ERR, "init sock: %d, len: %d\n", InitSocket, length);
    198198  status = bind (InitSocket, (struct sockaddr *) Address, length);
    199199  if (status == -1) {
     
    208208  }
    209209
    210   if (DEBUG) fprintf (stderr, "socket listening on %s (%s:%d)\n", host[0].h_name, hostip, MY_PORT);
     210  if (DEBUG) gprint (GP_ERR, "socket listening on %s (%s:%d)\n", host[0].h_name, hostip, MY_PORT);
    211211  return (InitSocket);
    212212}
     
    230230    test &= ((ip4 >=0) && (ip4 < 256));
    231231    if (!test) {
    232       fprintf (stderr, "invalid IP address %s\n", string);
     232      gprint (GP_ERR, "invalid IP address %s\n", string);
    233233      exit (2);
    234234    }
  • trunk/Ohana/src/opihi/pantasks/TaskOps.c

    r6687 r7917  
    5454  int i, valid;
    5555
    56   fprintf (stderr, "\n");
     56  gprint (GP_LOG, "\n");
    5757  if (Ntasks == 0) {
    58     fprintf (stderr, " no defined tasks\n");
     58    gprint (GP_LOG, " no defined tasks\n");
    5959    return;
    6060  }
    6161
    62   fprintf (stderr, " Task Status\n");
    63   fprintf (stderr, "  * Name            Njobs  Command\n");
     62  gprint (GP_LOG, " Task Status\n");
     63  gprint (GP_LOG, "  * Name            Njobs  Command\n");
    6464  for (i = 0; i < Ntasks; i++) {
    6565    valid = CheckTimeRanges (tasks[i][0].ranges, tasks[i][0].Nranges);
    66     if (verbose) fprintf (stderr, "\n");
     66    if (verbose) gprint (GP_LOG, "\n");
    6767    if (valid) {
    68       fprintf (stderr, "  + ");
     68      gprint (GP_LOG, "  + ");
    6969    } else {
    70       fprintf (stderr, "  - ");
     70      gprint (GP_LOG, "  - ");
    7171    }
    7272    if (tasks[i][0].argv == NULL) {
    73       fprintf (stderr, "%-15s %5d  %-20s\n", tasks[i][0].name, tasks[i][0].Njobs, "(dynamic)");
     73      gprint (GP_LOG, "%-15s %5d  %-20s\n", tasks[i][0].name, tasks[i][0].Njobs, "(dynamic)");
    7474    } else {
    75       fprintf (stderr, "%-15s %5d  %-20s\n", tasks[i][0].name, tasks[i][0].Njobs, tasks[i][0].argv[0]);
     75      gprint (GP_LOG, "%-15s %5d  %-20s\n", tasks[i][0].name, tasks[i][0].Njobs, tasks[i][0].argv[0]);
    7676    }
    7777    if (verbose) {
    78       fprintf (stderr, "    spawn period: %f, polling period: %f, timeout period: %f\n",
     78      gprint (GP_LOG, "    spawn period: %f, polling period: %f, timeout period: %f\n",
    7979               tasks[i][0].exec_period, tasks[i][0].poll_period, tasks[i][0].timeout_period);
    8080      if (tasks[i][0].host == NULL) {
    81         fprintf (stderr, "    task runs locally\n");
     81        gprint (GP_LOG, "    task runs locally\n");
    8282        continue;
    8383      }
    8484      if (!strcasecmp(tasks[i][0].host, "ANYHOST")) {
    85         fprintf (stderr, "    task host selected by controller\n");
     85        gprint (GP_LOG, "    task host selected by controller\n");
    8686        continue;
    8787      }
    8888      if (tasks[i][0].host_required) {
    89         fprintf (stderr, "    host %s (required)\n", tasks[i][0].host);
     89        gprint (GP_LOG, "    host %s (required)\n", tasks[i][0].host);
    9090      } else {
    91         fprintf (stderr, "    host %s (desired)\n", tasks[i][0].host);
     91        gprint (GP_LOG, "    host %s (desired)\n", tasks[i][0].host);
    9292      }
    9393    }
     
    104104  task = FindTask (name);
    105105  if (task == NULL) {
    106     fprintf (stderr, "task %s not found\n", name);
     106    gprint (GP_LOG, "task %s not found\n", name);
    107107    return (FALSE);
    108108  }
    109109
    110   fprintf (stderr, "\n macro %s\n", task[0].name);
    111 
    112   fprintf (stderr, "\n command: ");
     110  gprint (GP_LOG, "\n macro %s\n", task[0].name);
     111
     112  gprint (GP_LOG, "\n command: ");
    113113  for (i = 0; i < task[0].argc; i++) {
    114     fprintf (stderr, "%s ", task[0].argv[i]);
    115   }
    116   fprintf (stderr, "\n\n");
     114    gprint (GP_LOG, "%s ", task[0].argv[i]);
     115  }
     116  gprint (GP_LOG, "\n\n");
    117117
    118118  if (task[0].host == NULL) {
    119     fprintf (stderr, " task runs locally\n");
     119    gprint (GP_LOG, " task runs locally\n");
    120120    goto periods;
    121121  }
    122122  if (!strcasecmp(task[0].host, "ANYHOST")) {
    123     fprintf (stderr, " task host selected by controller\n");
     123    gprint (GP_LOG, " task host selected by controller\n");
    124124    goto periods;
    125125  }
    126126  if (task[0].host_required) {
    127     fprintf (stderr, " host %s (required)\n", task[0].host);
     127    gprint (GP_LOG, " host %s (required)\n", task[0].host);
    128128  } else {
    129     fprintf (stderr, " host %s (desired)\n", task[0].host);
     129    gprint (GP_LOG, " host %s (desired)\n", task[0].host);
    130130  }
    131131
    132132periods:
    133   fprintf (stderr, " time periods: exec: %f  poll: %f  timeout: %f\n",
     133  gprint (GP_LOG, " time periods: exec: %f  poll: %f  timeout: %f\n",
    134134           task[0].exec_period, task[0].poll_period, task[0].timeout_period);
    135135
    136   fprintf (stderr, "\n pre-execute macro\n");
     136  gprint (GP_LOG, "\n pre-execute macro\n");
    137137  ListMacro (task[0].exec);
    138138
    139   fprintf (stderr, "\n timeout macro\n");
     139  gprint (GP_LOG, "\n timeout macro\n");
    140140  ListMacro (task[0].timeout);
    141141
    142   fprintf (stderr, "\n crash macro\n");
     142  gprint (GP_LOG, "\n crash macro\n");
    143143  ListMacro (task[0].crash);
    144144
    145   fprintf (stderr, "\n default exit macro\n");
     145  gprint (GP_LOG, "\n default exit macro\n");
    146146  ListMacro (task[0].defexit);
    147147
    148148  for (i = 0; i < task[0].Nexit; i++) {
    149     fprintf (stderr, "\n exit macro (status == %d)\n", atoi(task[0].exit[i][0].name));
     149    gprint (GP_LOG, "\n exit macro (status == %d)\n", atoi(task[0].exit[i][0].name));
    150150    ListMacro (task[0].exit[i]);
    151151  }
     
    252252  }
    253253  if (Nt == -1) {
    254     fprintf (stderr, "programming error: task not found\n");
     254    gprint (GP_ERR, "programming error: task not found\n");
    255255    return (FALSE);
    256256  }
     
    269269  if (task[0].argc != 0) {
    270270    if (task[0].argv == NULL) {
    271       fprintf (stderr, "task command arguments not defined (programming error)\n");
     271      gprint (GP_ERR, "task command arguments not defined (programming error)\n");
    272272      return (FALSE);
    273273    }
     
    275275  }
    276276  if (RequireStatic) {
    277     fprintf (stderr, "task command not defined\n");
     277    gprint (GP_ERR, "task command not defined\n");
    278278    return (FALSE);
    279279  }
     
    286286    }
    287287  }
    288   fprintf (stderr, "task command not defined\n");
     288  gprint (GP_ERR, "task command not defined\n");
    289289  return (FALSE);
    290290}
  • trunk/Ohana/src/opihi/pantasks/client_shell.c

    r7892 r7917  
    1919  /* connect to the server */
    2020  if (VarConfig ("PANTASKS_SERVER", "%s", hostname) == NULL) {
    21     fprintf (stderr, "pantasks server host undefined\n");
     21    gprint (GP_ERR, "pantasks server host undefined\n");
    2222    exit (2);
    2323  }
     
    3838      ppid = getppid();
    3939      if (ppid == 1) {
    40         fprintf (stderr, "caught parent shutdown\n");
     40        gprint (GP_ERR, "caught parent shutdown\n");
    4141        exit (2);
    4242      }
    4343      if (!isatty (STDIN_FILENO)) exit (2);
    44       fprintf (stdout, "Use \"quit\" to exit\n");
     44      gprint (GP_ERR, "Use \"quit\" to exit\n");
    4545      Nbad ++;
    4646      continue;
     
    5757    status = command (line, &outline);
    5858    if (outline == NULL) {
    59       fprintf (stderr, "programming error: command_client returned NULL\n");
     59      gprint (GP_ERR, "programming error: command_client returned NULL\n");
    6060      exit (2);
    6161    }
     
    6363    /* command was not caught by client, send to server */
    6464    if (*outline && !status ) {
    65       fprintf (stderr, "sending message to %d: %s\n", server, outline);
     65      gprint (GP_ERR, "sending message to %d: %s\n", server, outline);
    6666      SendMessage (server, outline);
    6767      add_history (outline);
     
    6969
    7070      // XXX add this in and print to stdout
    71       // status = ExpectMessage (server, 2.0, &message);
     71      status = ExpectMessage (server, 2.0, &message);
     72      gprint (GP_ERR, "got message: %d bytes\n", message.Nbuffer);
     73      gwrite (message.buffer, 1, message.Nbuffer, GP_ERR);
     74      gprint (GP_ERR, "end message\n");
    7275    }
    7376    free (outline);
  • trunk/Ohana/src/opihi/pantasks/controller.c

    r6687 r7917  
    2323
    2424  if (argc < 2) {
    25     fprintf (stderr, "USAGE: controller (command) ... \n");
     25    gprint (GP_ERR, "USAGE: controller (command) ... \n");
    2626    return (FALSE);
    2727  }
     
    2929  func = FindControllerCommand (argv[1]);
    3030  if (func == NULL) {
    31     fprintf (stderr, "invalid controller command\n");
     31    gprint (GP_ERR, "invalid controller command\n");
    3232    return (FALSE);
    3333  }
  • trunk/Ohana/src/opihi/pantasks/controller_check.c

    r6687 r7917  
    1414  status = CheckControllerStatus ();
    1515  if (!status) {
    16     fprintf (stderr, "controller is not running\n");
     16    gprint (GP_LOG, "controller is not running\n");
    1717    return (TRUE);
    1818  }
     
    2222  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
    2323  if (VerboseMode()) {
    24     fprintf (stderr, "controller command sent\n"); 
    25     fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
    26     fprintf (stderr, "\n Nbytes received: %d\n", buffer.Nbuffer); 
     24    gprint (GP_LOG, "controller command sent\n"); 
     25    gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG);
     26    gprint (GP_LOG, "\n Nbytes received: %d\n", buffer.Nbuffer); 
    2727  }
    2828  FreeIOBuffer (&buffer);
     
    3030
    3131usage:
    32   fprintf (stderr, "USAGE: controller check job (jobID)\n");
    33   fprintf (stderr, "USAGE: controller check host (hostID)\n");
     32  gprint (GP_ERR, "USAGE: controller check job (jobID)\n");
     33  gprint (GP_ERR, "USAGE: controller check host (hostID)\n");
    3434  return (FALSE);
    3535}
  • trunk/Ohana/src/opihi/pantasks/controller_exit.c

    r6687 r7917  
    44
    55  if (argc != 2) {
    6     fprintf (stderr, "USAGE: controller exit TRUE\n");
     6    gprint (GP_ERR, "USAGE: controller exit TRUE\n");
    77    return (FALSE);
    88  }
  • trunk/Ohana/src/opihi/pantasks/controller_host.c

    r6687 r7917  
    88
    99  if (argc != 3) {
    10     fprintf (stderr, "USAGE: controller host (command) (hostname)\n");
     10    gprint (GP_ERR, "USAGE: controller host (command) (hostname)\n");
    1111    return (FALSE);
    1212  }
     
    1818  InitIOBuffer (&buffer, 0x100);
    1919  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
    20   if (status) fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
     20  if (status) gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG);
    2121  FreeIOBuffer (&buffer);
    2222  return (TRUE);
  • trunk/Ohana/src/opihi/pantasks/controller_output.c

    r6687 r7917  
    44
    55  if (argc != 1) {
    6     fprintf (stderr, "USAGE: controller status\n");
     6    gprint (GP_ERR, "USAGE: controller status\n");
    77    return (FALSE);
    88  }
  • trunk/Ohana/src/opihi/pantasks/controller_pulse.c

    r6687 r7917  
    88
    99  if (argc != 2) {
    10     fprintf (stderr, "USAGE: controller pulse (usec)\n");
     10    gprint (GP_ERR, "USAGE: controller pulse (usec)\n");
    1111    return (FALSE);
    1212  }
     
    1818  InitIOBuffer (&buffer, 0x100);
    1919  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
    20   if (status) fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
     20  if (status) gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG);
    2121  FreeIOBuffer (&buffer);
    2222  return (TRUE);
  • trunk/Ohana/src/opihi/pantasks/controller_status.c

    r6687 r7917  
    88
    99  if (argc != 1) {
    10     fprintf (stderr, "USAGE: controller status\n");
     10    gprint (GP_ERR, "USAGE: controller status\n");
    1111    return (FALSE);
    1212  }
     
    1515  status = CheckControllerStatus ();
    1616  if (!status) {
    17     fprintf (stderr, "controller is not running\n");
     17    gprint (GP_LOG, "controller is not running\n");
    1818    return (TRUE);
    1919  }
     
    2323  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
    2424  if (status) {
    25     fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
     25    gwrite (buffer.buffer, 1, buffer.Nbuffer, GP_LOG);
    2626  } else {
    27     fprintf (stderr, "controller is down\n");
     27    gprint (GP_LOG, "controller is down\n");
    2828  }
    2929  FreeIOBuffer (&buffer);
  • trunk/Ohana/src/opihi/pantasks/delete.c

    r6687 r7917  
    66
    77  if (argc < 2) {
    8     fprintf (stderr, "USAGE: delete (JobID)\n");
     8    gprint (GP_ERR, "USAGE: delete (JobID)\n");
    99    return (FALSE);
    1010  }
     
    1212  /* use a string interp to convert JobIDs to ints ? */
    1313
    14   fprintf (stderr, "this function is not yet implemented\n");
     14  gprint (GP_ERR, "this function is not yet implemented\n");
    1515  return (TRUE);
    1616}
  • trunk/Ohana/src/opihi/pantasks/invalid.c

    r7892 r7917  
    33int invalid (int argc, char **argv) {
    44
    5   fprintf (stderr, "%s is not valid for the pantasks client\n", argv[0]);
     5  gprint (GP_ERR, "%s is not valid for the pantasks client\n", argv[0]);
    66  return (TRUE);
    77
  • trunk/Ohana/src/opihi/pantasks/job.c

    r6687 r7917  
    3333  if ((N = get_argument (argc, argv, "+host"))) {
    3434    if (Mode == PCONTROL_JOB_WANTHOST) {
    35       fprintf (stderr, "ERROR: -host and +host are incompatible\n");
     35      gprint (GP_ERR, "ERROR: -host and +host are incompatible\n");
    3636      FREE (Host);
    3737      return (FALSE);
     
    5252
    5353  if (argc < 2) {
    54     fprintf (stderr, "USAGE: job [options] (arg0) (arg1) ... (argN)\n");
     54    gprint (GP_ERR, "USAGE: job [options] (arg0) (arg1) ... (argN)\n");
    5555    FREE (Host);
    5656    return (FALSE);
     
    6464
    6565  JobID = AddJob (Host, Mode, Timeout, targc, targv);
    66   fprintf (stdout, "JobID: %d\n", JobID);
     66  gprint (GP_LOG, "JobID: %d\n", JobID);
    6767  return (TRUE);
    6868}
  • trunk/Ohana/src/opihi/pantasks/kill.c

    r6687 r7917  
    77
    88  if (argc < 2) {
    9     fprintf (stderr, "USAGE: kill (JobID)\n");
     9    gprint (GP_ERR, "USAGE: kill (JobID)\n");
    1010    return (FALSE);
    1111  }
     
    1717    if (!KillLocalJob (job)) {
    1818      job[0].state = JOB_HUNG;
    19       if (VerboseMode()) fprintf (stderr, "child process %d is hung, cannot kill\n", job[0].pid);
     19      if (VerboseMode()) gprint (GP_LOG, "child process %d is hung, cannot kill\n", job[0].pid);
    2020      return (FALSE);
    2121    }
     
    2323    if (!KillControllerJob (job)) {
    2424      job[0].state = JOB_HUNG;
    25       if (VerboseMode()) fprintf (stderr, "child process %d is hung, cannot kill\n", job[0].pid);
     25      if (VerboseMode()) gprint (GP_LOG, "child process %d is hung, cannot kill\n", job[0].pid);
    2626      return (FALSE);
    2727    }
    2828  }   
    2929   
    30   fprintf (stderr, "this function is not yet implemented\n");
     30  gprint (GP_ERR, "this function is not yet implemented\n");
    3131  return (TRUE);
    3232}
  • trunk/Ohana/src/opihi/pantasks/pantasks.c

    r6687 r7917  
    3838/* standard welcome message */
    3939void welcome () {
    40   fprintf (stderr, "\n");
    41   fprintf (stderr, "Welcome to %s - %s\n\n", opihi_name, opihi_description);
     40  gprint (GP_LOG, "\n");
     41  gprint (GP_LOG, "Welcome to %s - %s\n\n", opihi_name, opihi_description);
    4242}
    4343
     
    5151
    5252void gotsignal (int signum) {
    53   fprintf (stderr, "got signal : %d\n", signum);
     53  gprint (GP_ERR, "got signal : %d\n", signum);
    5454  return;
    5555}
  • trunk/Ohana/src/opihi/pantasks/pantasks_client.c

    r7892 r7917  
    3838/* standard welcome message */
    3939void welcome () {
    40   fprintf (stderr, "\n");
    41   fprintf (stderr, "Welcome to %s - %s\n\n", opihi_name, opihi_description);
     40  gprint (GP_LOG, "\n");
     41  gprint (GP_LOG, "Welcome to %s - %s\n\n", opihi_name, opihi_description);
    4242}
    4343
     
    5454/* default signal handling */
    5555void gotsignal (int signum) {
    56   fprintf (stderr, "got signal : %d\n", signum);
     56  gprint (GP_ERR, "got signal : %d\n", signum);
    5757  return;
    5858}
  • trunk/Ohana/src/opihi/pantasks/pantasks_server.c

    r7892 r7917  
    3030  InitData ();
    3131  InitPantasks ();
     32 
     33  InitPrint ();
    3234
    3335  // signal (SIGPIPE, gotsignal);
     
    7779
    7880void gotsignal (int signum) {
    79   fprintf (stderr, "got signal : %d\n", signum);
     81  gprint (GP_ERR, "got signal : %d\n", signum);
    8082  return;
    8183}
  • trunk/Ohana/src/opihi/pantasks/pulse.c

    r6687 r7917  
    66
    77  if (argc != 2) {
    8     fprintf (stderr, "USAGE: pulse (microseconds)\n");
     8    gprint (GP_ERR, "USAGE: pulse (microseconds)\n");
    99    return (FALSE);
    1010  }
  • trunk/Ohana/src/opihi/pantasks/run.c

    r6687 r7917  
    44
    55  if (argc != 1) {
    6     fprintf (stderr, "USAGE: run\n");
     6    gprint (GP_ERR, "USAGE: run\n");
    77    return (FALSE);
    88  }
  • trunk/Ohana/src/opihi/pantasks/scheduler.c

    r4689 r7917  
    5252    f = fopen (opihi_history, "a");
    5353    if (f == NULL) /* no current history file here */
    54       fprintf (stderr, "can't save history.\n");
     54      gprint (GP_ERR, "can't save history.\n");
    5555    else
    5656      fclose (f);
     
    6565/* standard welcome message */
    6666void welcome () {
    67   fprintf (stderr, "\n");
    68   fprintf (stderr, "Welcome to %s - %s\n\n", opihi_name, opihi_description);
     67  gprint (GP_LOG, "\n");
     68  gprint (GP_LOG, "Welcome to %s - %s\n\n", opihi_name, opihi_description);
    6969}
    7070
  • trunk/Ohana/src/opihi/pantasks/status.c

    r6687 r7917  
    33int status_sys (int argc, char **argv) {
    44
    5   fprintf (stderr, "\n");
     5  gprint (GP_LOG, "\n");
    66  if (rl_event_hook == NULL) {
    7     fprintf (stderr, " Scheduler is stopped\n");
     7    gprint (GP_LOG, " Scheduler is stopped\n");
    88  } else {
    9     fprintf (stderr, " Scheduler is running\n");
     9    gprint (GP_LOG, " Scheduler is running\n");
    1010  }
    1111  if (CheckControllerStatus ()) {
    12     fprintf (stderr, " Controller is running\n");
     12    gprint (GP_LOG, " Controller is running\n");
    1313  } else {
    14     fprintf (stderr, " Controller is stopped\n");
     14    gprint (GP_LOG, " Controller is stopped\n");
    1515  }
    1616  ListTasks (FALSE);
  • trunk/Ohana/src/opihi/pantasks/stop.c

    r6687 r7917  
    44
    55  if (argc != 1) {
    6     fprintf (stderr, "USAGE: stop\n");
     6    gprint (GP_ERR, "USAGE: stop\n");
    77    return (FALSE);
    88  }
  • trunk/Ohana/src/opihi/pantasks/task.c

    r6687 r7917  
    2828
    2929  if (argc != 2) {
    30     fprintf (stderr, "USAGE: task <name>\n");
    31     fprintf (stderr, "  (enter commands & task functions; end with the word 'END')\n");
     30    gprint (GP_ERR, "USAGE: task <name>\n");
     31    gprint (GP_ERR, "  (enter commands & task functions; end with the word 'END')\n");
    3232    return (FALSE);
    3333  }
     
    5858
    5959    if ((ThisList == 0) && (input == (char *) NULL)) {
    60       fprintf (stderr, "end task with 'END'\n");
     60      gprint (GP_ERR, "end task with 'END'\n");
    6161      continue;
    6262    }
    6363    if ((ThisList > 0) && (input == (char *) NULL)) {
    64       fprintf (stderr, "missing 'END' in task definition\n");
     64      gprint (GP_ERR, "missing 'END' in task definition\n");
    6565      input = strcreate ("end");
    6666    }
     
    103103
    104104      case TASK_NONE:
    105         fprintf (stderr, "unknown task command %s\n", input);
     105        gprint (GP_ERR, "unknown task command %s\n", input);
    106106        break;
    107107    }
  • trunk/Ohana/src/opihi/pantasks/task_command.c

    r6687 r7917  
    77
    88  if (argc < 2) {
    9     fprintf (stderr, "USAGE: command <command> <arg>. ..\n");
    10     fprintf (stderr, "  (define command for this task)\n");
     9    gprint (GP_ERR, "USAGE: command <command> <arg>. ..\n");
     10    gprint (GP_ERR, "  (define command for this task)\n");
    1111    return (FALSE);
    1212  }
     
    1616    task = GetActiveTask ();
    1717    if (task == NULL) {
    18       fprintf (stderr, "ERROR: not defining or running a task\n");
     18      gprint (GP_ERR, "ERROR: not defining or running a task\n");
    1919      return (FALSE);
    2020    }
  • trunk/Ohana/src/opihi/pantasks/task_host.c

    r6687 r7917  
    1313
    1414  if (argc != 2) {
    15     fprintf (stderr, "USAGE: host <name> [-required]\n");
    16     fprintf (stderr, "  define host machine for this task\n");
    17     fprintf (stderr, "  -required flags indicates controller must use this host\n");
    18     fprintf (stderr, "  value of 'local' for host indicates process not using controller\n");
    19     fprintf (stderr, "  value of 'anyhost' for host indicates controller may assign at will\n");
     15    gprint (GP_ERR, "USAGE: host <name> [-required]\n");
     16    gprint (GP_ERR, "  define host machine for this task\n");
     17    gprint (GP_ERR, "  -required flags indicates controller must use this host\n");
     18    gprint (GP_ERR, "  value of 'local' for host indicates process not using controller\n");
     19    gprint (GP_ERR, "  value of 'anyhost' for host indicates controller may assign at will\n");
    2020    return (FALSE);
    2121  }
     
    2525    task = GetActiveTask ();
    2626    if (task == NULL) {
    27       fprintf (stderr, "ERROR: not defining or running a task\n");
     27      gprint (GP_ERR, "ERROR: not defining or running a task\n");
    2828      return (FALSE);
    2929    }
  • trunk/Ohana/src/opihi/pantasks/task_macros.c

    r6687 r7917  
    1111
    1212  if (!strcmp (argv[0], "task.exec") && (argc != 1)) {
    13     fprintf (stderr, "USAGE: task.exec\n");
    14     fprintf (stderr, "  (define pre-exec macro for this task)\n");
     13    gprint (GP_ERR, "USAGE: task.exec\n");
     14    gprint (GP_ERR, "  (define pre-exec macro for this task)\n");
    1515    return (FALSE);
    1616  }
    1717
    1818  if (!strcmp (argv[0], "task.exit") && (argc != 2)) {
    19     fprintf (stderr, "USAGE: task.exit (state)\n");
    20     fprintf (stderr, "  (define exit state macro for this task)\n");
     19    gprint (GP_ERR, "USAGE: task.exit (state)\n");
     20    gprint (GP_ERR, "  (define exit state macro for this task)\n");
    2121    return (FALSE);
    2222  }
     
    2424  task = GetNewTask ();
    2525  if (task == NULL) {
    26     fprintf (stderr, "ERROR: not defining or running a task\n");
     26    gprint (GP_ERR, "ERROR: not defining or running a task\n");
    2727    return (FALSE);
    2828  }
     
    115115
    116116    if ((ThisList == 0) && (input == (char *) NULL)) {
    117       fprintf (stderr, "end macro with 'END'\n");
     117      gprint (GP_ERR, "end macro with 'END'\n");
    118118      continue;
    119119    }
    120120    if ((ThisList > 0) && (input == (char *) NULL)) {
    121       fprintf (stderr, "missing 'END' in macro definition\n");
     121      gprint (GP_ERR, "missing 'END' in macro definition\n");
    122122      input = strcreate ("end");
    123123    }
  • trunk/Ohana/src/opihi/pantasks/task_nmax.c

    r6687 r7917  
    99  task = GetNewTask ();
    1010  if (task == NULL) {
    11     fprintf (stderr, "ERROR: not defining or running a task\n");
     11    gprint (GP_ERR, "ERROR: not defining or running a task\n");
    1212    return (FALSE);
    1313  }
     
    1717
    1818usage:
    19   fprintf (stderr, "USAGE: nmax N\n");
     19  gprint (GP_ERR, "USAGE: nmax N\n");
    2020  return (FALSE);
    2121}
  • trunk/Ohana/src/opihi/pantasks/task_periods.c

    r6687 r7917  
    3535
    3636  if (argc != 1) {
    37     fprintf (stderr, "USAGE: periods [-poll value] [-exec value] [-timeout value]\n");
    38     fprintf (stderr, "  define time periods for this task\n");
     37    gprint (GP_ERR, "USAGE: periods [-poll value] [-exec value] [-timeout value]\n");
     38    gprint (GP_ERR, "  define time periods for this task\n");
    3939    return (FALSE);
    4040  }
     
    4444    task = GetActiveTask ();
    4545    if (task == NULL) {
    46       fprintf (stderr, "ERROR: not defining or running a task\n");
     46      gprint (GP_ERR, "ERROR: not defining or running a task\n");
    4747      return (FALSE);
    4848    }
  • trunk/Ohana/src/opihi/pantasks/task_trange.c

    r6687 r7917  
    2525  task = GetNewTask ();
    2626  if (task == NULL) {
    27     fprintf (stderr, "ERROR: not defining or running a task\n");
     27    gprint (GP_ERR, "ERROR: not defining or running a task\n");
    2828    return (FALSE);
    2929  }
     
    6161
    6262usage:
    63   fprintf (stderr, "USAGE: trange start end\n");
     63  gprint (GP_ERR, "USAGE: trange start end\n");
    6464  return (FALSE);
    6565}
  • trunk/Ohana/src/opihi/pantasks/verbose.c

    r6687 r7917  
    77  if (argc == 1) {
    88    if (VERBOSE) {
    9       fprintf (stderr, "verbose mode ON\n");
     9      gprint (GP_LOG, "verbose mode ON\n");
    1010    } else {
    11       fprintf (stderr, "verbose mode OFF\n");
     11      gprint (GP_LOG, "verbose mode OFF\n");
    1212    }
    1313    return (TRUE);
     
    2929  }
    3030
    31   fprintf (stderr, "USAGE: verbose (on/off/toggle)\n");
     31  gprint (GP_ERR, "USAGE: verbose (on/off/toggle)\n");
    3232  return (FALSE);
    3333}
  • trunk/Ohana/src/opihi/pantasks/version.c

    r7080 r7917  
    44int version (int argc, char **argv) {
    55
    6   fprintf (stderr, "%s\n", name);
     6  gprint (GP_LOG, "%s\n", name);
    77
    8   fprintf (stderr, "%s\n", opihi_version());
    9   fprintf (stderr, "%s\n", ohana_version());
    10   fprintf (stderr, "%s\n", gfits_version());
     8  gprint (GP_LOG, "%s\n", opihi_version());
     9  gprint (GP_LOG, "%s\n", ohana_version());
     10  gprint (GP_LOG, "%s\n", gfits_version());
    1111
    12   fprintf (stderr, "compiled on %s %s\n", __DATE__, __TIME__);
     12  gprint (GP_LOG, "compiled on %s %s\n", __DATE__, __TIME__);
    1313  return (TRUE);
    1414}
Note: See TracChangeset for help on using the changeset viewer.