IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 28, 2022, 12:17:32 PM (4 years ago)
Author:
eugene
Message:

add imresample, imcollapse functions; more usage documentation; option to catch failures in command when loading from shell command into queue; better handling of errors reading FITS table

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/queueload.c

    r12332 r42082  
    33int queueload (int argc, char **argv) {
    44 
    5   char *A, *B, *val;
    6   int i, status;
    7   int Nread, Nbytes, NBYTES;
    8   FILE *f;
    9   Queue *queue;
     5  int N;
     6
     7  // variable name to save the value
     8  int TrapFailure = FALSE;
     9  if ((N = get_argument (argc, argv, "-trap-failure"))) {
     10    remove_argument (N, &argc, argv);
     11    TrapFailure = TRUE;
     12  }
     13  if ((N = get_argument (argc, argv, "-trap"))) {
     14    remove_argument (N, &argc, argv);
     15    TrapFailure = TRUE;
     16  }
    1017
    1118  if (argc != 4) goto usage;
     
    1320 
    1421  /* will create a queue if none exists */
    15   queue = CreateQueue (argv[1]);
     22  Queue *queue = CreateQueue (argv[1]);
    1623
    1724  /* val will hold the result of the command */
    18   NBYTES = 1024;
    19   ALLOCATE (val, char, NBYTES);
     25  int NBYTES = 1024;
     26  ALLOCATE_PTR (val, char, NBYTES);
    2027   
    2128  /* loop until command produces no more output,  REALLOCATE as needed. */
    22   f = popen (argv[3], "r");
    23   Nbytes = 0;
    24   Nread = 1;
     29  FILE *f = popen (argv[3], "r");
     30
     31  int Nbytes = 0;
     32  int Nread = 1;
    2533  while (Nread > 0) {
    2634    Nread = fread (&val[Nbytes], 1, 1023, f);
     
    3543  }
    3644  val[Nbytes] = 0;
    37   status = pclose (f);
     45  int status = pclose (f);
    3846   
     47  // XXX
    3948  if (status) {
    4049    gprint (GP_ERR, "warning: exit status of command %d\n", status);
     50    if (TrapFailure) { free (val); return FALSE; }
    4151  }
    4252     
    43   A = B = val;
    44   for (i = 0; B != (char *) NULL;) {
     53  char *A = val, *B = val;
     54  for (int i = 0; B != (char *) NULL;) {
    4555    while (isspace (*A) && (*A != 0)) A++;
    4656    B = strchr (A, '\n');
Note: See TracChangeset for help on using the changeset viewer.