IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8427


Ignore:
Timestamp:
Aug 20, 2006, 5:36:41 PM (20 years ago)
Author:
eugene
Message:

updated to the new DVO APIs; minor cleanups (unused variables, etc)

Location:
trunk/Ohana/src/opihi
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.astro/csystem.c

    r8130 r8427  
    55  /* USAGE: csystem [C/G/E/H] [C/G/E/H] [epoch] */
    66  int i;
    7   double Xin, Yin, X, Y, Xo, xo, phi, T;
     7  double X, Y, Xo, xo, phi, T;
    88  double sin_x, sin_y, cos_x, cos_y;
    99  float *x, *y;
  • trunk/Ohana/src/opihi/cmd.astro/drizzle.c

    r8200 r8427  
    293293  YY = (SYy*Sx2 - SYx*Sxy) / (Sx2*Sy2 - Sxy*Sxy);
    294294  YO = Y/N - YX*x/N - YY*y/N;
    295 
     295  return (TRUE);
    296296}
    297297
  • trunk/Ohana/src/opihi/cmd.data/queuedrop.c

    r8192 r8427  
    55  int N;
    66  char *Key;
    7   char *var;
    87  char *line;
    98  char *Value;
     
    1918  }
    2019
    21   if ((argc != 2) || (Key == -1)) {
     20  if ((argc != 2) || (Key == NULL)) {
    2221    gprint (GP_ERR, "USAGE: queuedrop (queue) [-key N value]\n");
    2322    return (FALSE);
  • trunk/Ohana/src/opihi/dvo/avextract.c

    r7917 r8427  
    5454  if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape;
    5555
     56  // XXX need to add interrupt test to this loop
    5657  for (i = 0; i < skylist[0].Nregions; i++) {
    5758    /* lock, load, unlock catalog */
    5859    catalog.filename = skylist[0].filename[i];
    59     switch (lock_catalog (&catalog, LCK_SOFT)) {
    60     case 2:
    61       unlock_catalog (&catalog);
    62     case 0:
    63       continue;
     60    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     61
     62    // an error exit status here is a significant error
     63    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     64      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     65      exit (2);
    6466    }
    65     catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    66     if (!load_catalog (&catalog, FALSE)) {
    67       unlock_catalog (&catalog);
    68       continue;
    69     }
    70     unlock_catalog (&catalog);
     67    dvo_catalog_unlock (&catalog);
    7168
    7269    for (j = 0; j < catalog.Naverage; j++) {
     
    7673      CHECK_REALLOCATE (vec[0].elements, float, NPTS, N, 2000);
    7774    }
    78     if (catalog.average != NULL) free (catalog.average);
    79     if (catalog.secfilt != NULL) free (catalog.secfilt);
    80     if (catalog.measure != NULL) free (catalog.measure);
    81     catalog.average = (Average *) NULL;
    82     catalog.secfilt = (SecFilt *) NULL;
    83     catalog.measure = (Measure *) NULL;
     75    dvo_catalog_free (&catalog);
    8476  }
    8577  vec[0].Nelements = N;
     
    9587escape:
    9688  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    97   if (catalog.average != NULL) free (catalog.average);
    98   if (catalog.secfilt != NULL) free (catalog.secfilt);
    99   if (catalog.measure != NULL) free (catalog.measure);
     89  dvo_catalog_free (&catalog);
    10090  if (RegionName != NULL) free (RegionName);
    10191  if (RegionList != NULL) free (RegionList);
  • trunk/Ohana/src/opihi/dvo/calextract.c

    r7917 r8427  
    6262    /* lock, load, unlock catalog */
    6363    catalog.filename = skylist[0].filename[Nr];
    64     switch (lock_catalog (&catalog, LCK_SOFT)) {
    65       case 2:
    66         unlock_catalog (&catalog);
    67       case 0:
    68         continue;
     64    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     65
     66    // an error exit status here is a significant error
     67    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     68      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     69      exit (2);
    6970    }
    70     catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    71     if (!load_catalog (&catalog, FALSE)) {
    72       unlock_catalog (&catalog);
    73       continue;
    74     }
    75     unlock_catalog (&catalog);
     71    dvo_catalog_unlock (&catalog);
    7672
    7773    /* extract values, assign to vectors */
     
    115111      }
    116112    }
    117     if (catalog.average != (Average *) NULL) free (catalog.average);
    118     if (catalog.measure != (Measure *) NULL) free (catalog.measure);
    119     if (catalog.secfilt != (SecFilt *) NULL) free (catalog.secfilt);
    120     catalog.average = (Average *) NULL;
    121     catalog.secfilt = (SecFilt *) NULL;
    122     catalog.measure = (Measure *) NULL;
     113    dvo_catalog_free (&catalog);
    123114  }
    124115
     
    134125
    135126escape:
    136  
    137127  if (RegionName != NULL) free (RegionName);
    138128  if (RegionList != NULL) free (RegionList);
  • trunk/Ohana/src/opihi/dvo/calmextract.c

    r7917 r8427  
    7575    /* lock, load, unlock catalog */
    7676    catalog.filename = skylist[0].filename[Nr];
    77     switch (lock_catalog (&catalog, LCK_SOFT)) {
    78       case 2:
    79         unlock_catalog (&catalog);
    80       case 0:
    81         continue;
     77    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     78
     79    // an error exit status here is a significant error
     80    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     81      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     82      exit (2);
    8283    }
    83     catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    84     if (!load_catalog (&catalog, FALSE)) {
    85       unlock_catalog (&catalog);
    86       continue;
    87     }
    88     unlock_catalog (&catalog);
     84    dvo_catalog_unlock (&catalog);
    8985
    9086    /* extract values, assign to vectors */
     
    141137      if (M1 != NULL) free (M1);
    142138    }
    143     if (catalog.average != (Average *) NULL) free (catalog.average);
    144     if (catalog.measure != (Measure *) NULL) free (catalog.measure);
    145     if (catalog.secfilt != (SecFilt *) NULL) free (catalog.secfilt);
    146     catalog.average = (Average *) NULL;
    147     catalog.secfilt = (SecFilt *) NULL;
    148     catalog.measure = (Measure *) NULL;
     139    dvo_catalog_free (&catalog);
    149140  }
    150141
     
    161152
    162153escape:
    163  
    164154  FreeImageSelection ();
    165155  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
  • trunk/Ohana/src/opihi/dvo/catalog.c

    r7917 r8427  
    316316      /* lock, load, unlock catalog */
    317317      catalog.filename = filename;
    318       switch (lock_catalog (&catalog, LCK_SOFT)) {
    319       case 2:
    320         unlock_catalog (&catalog);
    321       case 0:
    322         continue;
    323       }
    324318      catalog.catflags = LOAD_AVES;
    325       if (!load_catalog (&catalog, TRUE)) {
    326         unlock_catalog (&catalog);
    327         continue;
    328       }
    329       unlock_catalog (&catalog);
     319
     320      // an error exit status here is a significant error
     321      if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     322          fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     323          exit (2);
     324      }
     325      dvo_catalog_unlock (&catalog);
    330326    }
    331327   
  • trunk/Ohana/src/opihi/dvo/ccd.c

    r7917 r8427  
    5959    /* lock, load, unlock catalog */
    6060    catalog.filename = skylist[0].filename[k];
    61     switch (lock_catalog (&catalog, LCK_SOFT)) {
    62       case 2:
    63         unlock_catalog (&catalog);
    64       case 0:
    65         continue;
     61    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     62
     63    // an error exit status here is a significant error
     64    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     65      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     66      exit (2);
    6667    }
    67     catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    68     if (!load_catalog (&catalog, FALSE)) {
    69       unlock_catalog (&catalog);
    70       continue;
    71     }
    72     unlock_catalog (&catalog);
     68    dvo_catalog_unlock (&catalog);
    7369
    7470    /* get correct mags, convert to X,Y */
     
    109105      if (M2 != NULL) free (M2);
    110106    }
    111     if (catalog.average != NULL) free (catalog.average);
    112     if (catalog.secfilt != NULL) free (catalog.secfilt);
    113     if (catalog.measure != NULL) free (catalog.measure);
    114     catalog.average = (Average *) NULL;
    115     catalog.secfilt = (SecFilt *) NULL;
    116     catalog.measure = (Measure *) NULL;
     107    dvo_catalog_free (&catalog);
    117108  }
    118109  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
     
    126117escape:
    127118  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    128   if (catalog.average != NULL) free (catalog.average);
    129   if (catalog.secfilt != NULL) free (catalog.secfilt);
    130   if (catalog.measure != NULL) free (catalog.measure);
     119  dvo_catalog_free (&catalog);
    131120  if (RegionName != NULL) free (RegionName);
    132121  if (RegionList != NULL) free (RegionList);
  • trunk/Ohana/src/opihi/dvo/cmatch.c

    r7917 r8427  
    2929  /* load data from the photometry database file */
    3030  catalog1.filename = filename;
    31   switch (lock_catalog (&catalog1, LCK_SOFT)) {
    32   case 2:
    33     unlock_catalog (&catalog1);
    34   case 0:
    35     return (FALSE);
     31  catalog1.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     32
     33  // an error exit status here is a significant error
     34  if (!dvo_catalog_open (&catalog1, NULL, FALSE, "r")) {
     35      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog1.filename);
     36      exit (2);
    3637  }
    37   catalog1.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    38   if (!load_catalog (&catalog1, TRUE)) {
    39     unlock_catalog (&catalog1);
    40     return (FALSE);
    41   }
    42   unlock_catalog (&catalog1);
     38  dvo_catalog_unlock (&catalog1);
    4339  gprint (GP_ERR, "read %d stars from phot catalog file %s\n", catalog1.Naverage, filename);
    4440
     
    7874  compare (&catalog1, &catalog2, rvec, dvec, mvec, drvec, ddvec, dmvec, radius);
    7975
    80   free (catalog1.average);
     76  dvo_catalog_free (&catalog1);
    8177  free (catalog2.average);
    8278
  • trunk/Ohana/src/opihi/dvo/cmd.c

    r7917 r8427  
    5757    /* lock, load, unlock catalog */
    5858    catalog.filename = skylist[0].filename[j];
    59     switch (lock_catalog (&catalog, LCK_SOFT)) {
    60     case 2:
    61       unlock_catalog (&catalog);
    62     case 0:
    63       continue;
     59    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     60
     61    // an error exit status here is a significant error
     62    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     63      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     64      exit (2);
    6465    }
    65     catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    66     if (!load_catalog (&catalog, FALSE)) {
    67       unlock_catalog (&catalog);
    68       continue;
    69     }
    70     unlock_catalog (&catalog);
     66    dvo_catalog_unlock (&catalog);
    7167   
    7268    /* get correct mags, convert to X,Y */
     
    107103      if (M3 != NULL) free (M3);
    108104    }
    109     if (catalog.average != NULL) free (catalog.average);
    110     if (catalog.secfilt != NULL) free (catalog.secfilt);
    111     if (catalog.measure != NULL) free (catalog.measure);
    112     catalog.average = (Average *) NULL;
    113     catalog.secfilt = (SecFilt *) NULL;
    114     catalog.measure = (Measure *) NULL;
     105    dvo_catalog_free (&catalog);
    115106  }
    116107  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
     
    124115escape:
    125116  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    126   if (catalog.average != NULL) free (catalog.average);
    127   if (catalog.secfilt != NULL) free (catalog.secfilt);
    128   if (catalog.measure != NULL) free (catalog.measure);
     117  dvo_catalog_free (&catalog);
    129118  if (RegionName != NULL) free (RegionName);
    130119  if (RegionList != NULL) free (RegionList);
  • trunk/Ohana/src/opihi/dvo/ddmags.c

    r7917 r8427  
    6060    /* lock, load, unlock catalog */
    6161    catalog.filename = skylist[0].filename[k];
    62     switch (lock_catalog (&catalog, LCK_SOFT)) {
    63       case 2:
    64         unlock_catalog (&catalog);
    65       case 0:
    66         continue;
     62    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     63
     64    // an error exit status here is a significant error
     65    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     66      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     67      exit (2);
    6768    }
    68     catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    69     if (!load_catalog (&catalog, TRUE)) {
    70       unlock_catalog (&catalog);
    71       continue;
    72     }
    73     unlock_catalog (&catalog);
     69    dvo_catalog_unlock (&catalog);
     70
    7471    // gprint (GP_ERR, "seaching %s with %d stars\n", catalog.filename, catalog.Naverage);
    7572    // ListPhotSelections ();
     
    113110    }
    114111    // gprint (GP_ERR, "selected %d stars\n", Npts);
    115 
    116     if (catalog.average != NULL) free (catalog.average);
    117     if (catalog.secfilt != NULL) free (catalog.secfilt);
    118     if (catalog.measure != NULL) free (catalog.measure);
    119     catalog.average = (Average *) NULL;
    120     catalog.secfilt = (SecFilt *) NULL;
    121     catalog.measure = (Measure *) NULL;
     112    dvo_catalog_free (&catalog);
    122113  }
    123114  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
     
    130121escape:
    131122  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    132   if (catalog.average != NULL) free (catalog.average);
    133   if (catalog.secfilt != NULL) free (catalog.secfilt);
    134   if (catalog.measure != NULL) free (catalog.measure);
     123  dvo_catalog_free (&catalog);
    135124  if (RegionName != NULL) free (RegionName);
    136125  if (RegionList != NULL) free (RegionList);
  • trunk/Ohana/src/opihi/dvo/dmagaves.c

    r7917 r8427  
    5151    /* lock, load, unlock catalog */
    5252    catalog.filename = skylist[0].filename[j];
    53     switch (lock_catalog (&catalog, LCK_SOFT)) {
    54     case 2:
    55       unlock_catalog (&catalog);
    56     case 0:
    57       continue;
     53    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     54
     55    // an error exit status here is a significant error
     56    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     57      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     58      exit (2);
    5859    }
    59     catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    60     if (!load_catalog (&catalog, FALSE)) {
    61       unlock_catalog (&catalog);
    62       continue;
    63     }
    64     unlock_catalog (&catalog);
     60    dvo_catalog_unlock (&catalog);
    6561
    6662    /* get correct mags, convert to X,Y */
     
    8985      if (M1 != NULL) free (M1);
    9086    }
    91     if (catalog.average != NULL) free (catalog.average);
    92     if (catalog.secfilt != NULL) free (catalog.secfilt);
    93     if (catalog.measure != NULL) free (catalog.measure);
    94     catalog.average = (Average *) NULL;
    95     catalog.secfilt = (SecFilt *) NULL;
    96     catalog.measure = (Measure *) NULL;
     87    dvo_catalog_free (&catalog);
    9788  }
    9889  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
     
    10697escape:
    10798  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    108   if (catalog.average != NULL) free (catalog.average);
    109   if (catalog.secfilt != NULL) free (catalog.secfilt);
    110   if (catalog.measure != NULL) free (catalog.measure);
     99  dvo_catalog_free (&catalog);
    111100  if (RegionName != NULL) free (RegionName);
    112101  if (RegionList != NULL) free (RegionList);
  • trunk/Ohana/src/opihi/dvo/dmagmeas.c

    r7917 r8427  
    5959    /* lock, load, unlock catalog */
    6060    catalog.filename = skylist[0].filename[j];
    61     switch (lock_catalog (&catalog, LCK_SOFT)) {
    62       case 2:
    63         unlock_catalog (&catalog);
    64       case 0:
    65         continue;
     61    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     62
     63    // an error exit status here is a significant error
     64    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     65      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     66      exit (2);
    6667    }
    67     catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    68     if (!load_catalog (&catalog, FALSE)) {
    69       unlock_catalog (&catalog);
    70       continue;
    71     }
    72     unlock_catalog (&catalog);
     68    dvo_catalog_unlock (&catalog);
    7369
    7470    /* get correct mags, convert to X,Y */
     
    109105      if (M3 != NULL) free (M3);
    110106    }
    111     if (catalog.average != NULL) free (catalog.average);
    112     if (catalog.secfilt != NULL) free (catalog.secfilt);
    113     if (catalog.measure != NULL) free (catalog.measure);
    114     catalog.average = (Average *) NULL;
    115     catalog.secfilt = (SecFilt *) NULL;
    116     catalog.measure = (Measure *) NULL;
     107    dvo_catalog_free (&catalog);
    117108  }
    118109  FreeImageSelection ();
     
    128119  FreeImageSelection ();
    129120  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    130   if (catalog.average != NULL) free (catalog.average);
    131   if (catalog.secfilt != NULL) free (catalog.secfilt);
    132   if (catalog.measure != NULL) free (catalog.measure);
     121  dvo_catalog_free (&catalog);
    133122  if (RegionName != NULL) free (RegionName);
    134123  if (RegionList != NULL) free (RegionList);
  • trunk/Ohana/src/opihi/dvo/dmags.c

    r7917 r8427  
    5858    /* lock, load, unlock catalog */
    5959    catalog.filename = skylist[0].filename[j];
    60     switch (lock_catalog (&catalog, LCK_SOFT)) {
    61       case 2:
    62         unlock_catalog (&catalog);
    63       case 0:
    64         continue;
     60    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     61
     62    // an error exit status here is a significant error
     63    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     64      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     65      exit (2);
    6566    }
    66     catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    67     if (!load_catalog (&catalog, FALSE)) {
    68       unlock_catalog (&catalog);
    69       continue;
    70     }
    71     unlock_catalog (&catalog);
     67    dvo_catalog_unlock (&catalog);
    7268
    7369    /* get correct mags, convert to X,Y */
     
    108104      if (M3 != NULL) free (M3);
    109105    }
    110     if (catalog.average != NULL) free (catalog.average);
    111     if (catalog.secfilt != NULL) free (catalog.secfilt);
    112     if (catalog.measure != NULL) free (catalog.measure);
    113     catalog.average = (Average *) NULL;
    114     catalog.secfilt = (SecFilt *) NULL;
    115     catalog.measure = (Measure *) NULL;
     106    dvo_catalog_free (&catalog);
    116107  }
    117108
     
    131122escape:
    132123  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    133   if (catalog.average != NULL) free (catalog.average);
    134   if (catalog.secfilt != NULL) free (catalog.secfilt);
    135   if (catalog.measure != NULL) free (catalog.measure);
     124  dvo_catalog_free (&catalog);
    136125  if (RegionName != NULL) free (RegionName);
    137126  if (RegionList != NULL) free (RegionList);
  • trunk/Ohana/src/opihi/dvo/dmt.c

    r7917 r8427  
    7070    /* lock, load, unlock catalog */
    7171    catalog.filename = skylist[0].filename[k];
    72     switch (lock_catalog (&catalog, LCK_SOFT)) {
    73       case 2:
    74         unlock_catalog (&catalog);
    75       case 0:
    76         continue;
     72    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     73
     74    // an error exit status here is a significant error
     75    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     76      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     77      exit (2);
    7778    }
    78     catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    79     if (!load_catalog (&catalog, TRUE)) {
    80       unlock_catalog (&catalog);
    81       continue;
    82     }
    83     unlock_catalog (&catalog);
     79    dvo_catalog_unlock (&catalog);
    8480
    8581    for (i = 0; i < catalog.Naverage; i++) {
     
    114110      }
    115111    }
     112    dvo_catalog_free (&catalog);
    116113  }
    117114  Yvec.Nelements = Xvec.Nelements = N;
  • trunk/Ohana/src/opihi/dvo/fitcolors.c

    r7960 r8427  
    22# define NMIN_PTS 100
    33
    4 static void init_catalog (Catalog *catalog);
    54static void free_catalog (Catalog *catalog, int Ncatalog);
    65
     
    1918  char name[64], filename[64], plotname[64], label[64];
    2019  double *M1, *M2;
    21   float *out, *colorFit, *deltaFit, color, dColor, C0, C1;
     20  float *out, *colorFit, *deltaFit, dColor, C0, C1;
    2221  float minDelta, maxDelta, minColor, maxColor;
    2322  int fd, Npx, Npy, NPX, NPY, Nplot, PLOT;
     
    168167    /* lock, load, unlock catalog */
    169168    catalog[k].filename = skylist[0].filename[k];
    170     switch (lock_catalog (&catalog[k], LCK_SOFT)) {
    171       case 2:
    172         unlock_catalog (&catalog[k]);
    173       case 0:
    174         catalog[k].Naverage = 0;
    175         continue;
     169    catalog[k].catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     170
     171    // an error exit status here is a significant error
     172    if (!dvo_catalog_open (&catalog[k], NULL, FALSE, "r")) {
     173      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog[k].filename);
     174      exit (2);
    176175    }
    177     catalog[k].catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    178     if (!load_catalog (&catalog[k], TRUE)) {
    179       catalog[k].Naverage = 0;
    180       unlock_catalog (&catalog[k]);
    181       continue;
    182     }
    183     unlock_catalog (&catalog[k]);
     176    dvo_catalog_unlock (&catalog[k]);
    184177    // XXX make a subset catalog consisting of only Average and Measure values which meet
    185178    // the selection criteria
     
    400393  if (catalog == NULL) return;
    401394  for (i = 0; i < Ncatalog; i++) {
    402     if (catalog[i].average != NULL) free (catalog[i].average);
    403     if (catalog[i].secfilt != NULL) free (catalog[i].secfilt);
    404     if (catalog[i].measure != NULL) free (catalog[i].measure);
     395    dvo_catalog_free (&catalog[i]);
    405396  }
    406397  free (catalog);
    407398}
    408 
    409 static void init_catalog (Catalog *catalog) {
    410   catalog[0].average = NULL;
    411   catalog[0].secfilt = NULL;
    412   catalog[0].measure = NULL;
    413   catalog[0].Naverage = 0;
    414   catalog[0].Nsecfilt = 0;
    415   catalog[0].Nmeasure = 0;
    416 }
  • trunk/Ohana/src/opihi/dvo/fitsed.c

    r7960 r8427  
    2424 
    2525  int *hashcode;
    26   int i, j, k, m, N, done, Nfit, NP1, NP2, NP, Np, Npts, NPTS;
    27   int N1, N2, i1, i2, mode[4];
     26  int i, j, k, m, N, done, Nfit;
    2827  int Nsec, status;
    2928  void *oldsignal;
    3029  char *RegionName, *RegionList;
    31   char name[64], filename[64], plotname[64], label[64];
    32   char line[1024], key[20];
     30  char name[64], line[1024], key[20];
    3331  float *fitmags, *fiterrs, *wavecode, *vegaToAB;
    34   float minWave, maxWave, color;
     32  float color;
    3533  double X, Y;
    3634  int fd, PLOT;
     
    184182    /* lock, load, unlock catalog */
    185183    catalog.filename = skylist[0].filename[k];
    186     switch (lock_catalog (&catalog, LCK_SOFT)) {
    187       case 2:
    188         unlock_catalog (&catalog);
    189       case 0:
    190         catalog.Naverage = 0;
    191         continue;
    192     }
    193184    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    194     if (!load_catalog (&catalog, TRUE)) {
    195       catalog.Naverage = 0;
    196       unlock_catalog (&catalog);
    197       continue;
    198     }
     185
     186    // an error exit status here is a significant error
     187    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     188      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     189      exit (2);
     190    }
     191    dvo_catalog_unlock (&catalog);
    199192
    200193    // perform the fit to all sources
     
    258251      // create the vectors for the example plots
    259252      if (PLOT) {
    260         double tmp;
    261253        // find plot range
    262254        SetLimitsRaw (NULL, SEDtable[minFit.row][0].mags, Nfilter, &graphdata);
     
    326318          if (!strcasecmp (key, "ESCAPE")) {
    327319            KiiCursorOff (fd);
    328             unlock_catalog (&catalog);
    329320            goto escape;
    330321          }
    331322        }
    332323      }
    333 
    334324      // we now have the min chisq row. use this to supply the other filter values....
    335325    }
    336     unlock_catalog (&catalog);
     326    dvo_catalog_free (&catalog);
    337327  }
    338328  gprint (GP_ERR, "fitted %d stars\n", Nfit);
     
    366356finish:
    367357  if (skylist != NULL) SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    368   if (catalog.average != NULL) free (catalog.average);
    369   if (catalog.secfilt != NULL) free (catalog.secfilt);
    370   if (catalog.measure != NULL) free (catalog.measure);
    371 
    372358  if (RegionName != NULL) free (RegionName);
    373359  if (RegionList != NULL) free (RegionList);
  • trunk/Ohana/src/opihi/dvo/gstar.c

    r7960 r8427  
    7272  /* lock, load, unlock catalog */
    7373  catalog.filename = skylist[0].filename[0];
    74   switch (lock_catalog (&catalog, LCK_SOFT)) {
    75     case 2:
    76       unlock_catalog (&catalog);
    77     case 0:
    78       return (FALSE);
    79   }
    8074  catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    81   if (!load_catalog (&catalog, TRUE)) {
    82     unlock_catalog (&catalog);
    83     return (FALSE);
    84   }
    85   unlock_catalog (&catalog);
     75
     76  // an error exit status here is a significant error
     77  if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     78      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     79      exit (2);
     80  }
     81  dvo_catalog_unlock (&catalog);
    8682
    8783  Nstars = catalog.Naverage;
     
    209205  free (DEC);
    210206  free (N1);
    211   if (catalog.average != 0) free (catalog.average);
    212   if (catalog.measure != 0) free (catalog.measure);
    213   if (catalog.secfilt != 0) free (catalog.secfilt);
     207  dvo_catalog_free (&catalog);
    214208
    215209  freePhotcodeSequence ();
  • trunk/Ohana/src/opihi/dvo/imdata.c

    r7917 r8427  
    121121    /* get file name and open */
    122122    catalog.filename = skylist[0].filename[j];
    123     switch (lock_catalog (&catalog, LCK_SOFT)) {
    124       case 2:
    125         unlock_catalog (&catalog);
    126       case 0:
    127         continue;
    128     }
    129     catalog.catflags = LOAD_AVES;
    130     if (!load_catalog (&catalog, TRUE)) {
    131       unlock_catalog (&catalog);
    132       continue;
    133     }
    134     unlock_catalog (&catalog);
     123    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     124
     125    // an error exit status here is a significant error
     126    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     127      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     128      exit (2);
     129    }
     130    dvo_catalog_unlock (&catalog);
    135131
    136132    /* assign vector values */
     
    203199        break;
    204200    }
    205     if (catalog.average != 0) {
    206       free (catalog.average);
    207     }
    208     if (catalog.measure != 0) {
    209       free (catalog.measure);
    210     }
     201    dvo_catalog_free (&catalog);
    211202  }
    212203 
  • trunk/Ohana/src/opihi/dvo/lcurve.c

    r7917 r8427  
    8282  /* set filename, read in header */
    8383  catalog.filename = skylist[0].filename[0];
    84   switch (lock_catalog (&catalog, LCK_SOFT)) {
    85     case 2:
    86       unlock_catalog (&catalog);
    87     case 0:
    88       return (FALSE);
     84  catalog.catflags = LOAD_AVES | LOAD_MEAS;
     85
     86  // an error exit status here is a significant error
     87  if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     88      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     89      exit (2);
    8990  }
    90   catalog.catflags = LOAD_AVES | LOAD_MEAS;
    91   if (!load_catalog (&catalog, TRUE)) {
    92     unlock_catalog (&catalog);
    93     return (FALSE);
    94   }
    95   unlock_catalog (&catalog);
     91  dvo_catalog_unlock (&catalog);
    9692
    9793  Nstars = catalog.Naverage;
     
    195191
    196192  if (ErrorBars) free (dYvec.elements);
    197   if (catalog.average != 0) free (catalog.average);
    198   if (catalog.measure != 0) free (catalog.measure);
    199  
     193  dvo_catalog_free (&catalog);
     194
    200195  SkyListFree (skylist, FALSE);
    201196  return (TRUE);
  • trunk/Ohana/src/opihi/dvo/lightcurve.c

    r7917 r8427  
    5858  /* set filename, read in header */
    5959  catalog.filename = skylist[0].filename[0];
    60   switch (lock_catalog (&catalog, LCK_SOFT)) {
    61     case 2:
    62       unlock_catalog (&catalog);
    63     case 0:
    64       return (FALSE);
     60  catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     61
     62  // an error exit status here is a significant error
     63  if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     64      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     65      exit (2);
    6566  }
    66   catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    67   if (!load_catalog (&catalog, TRUE)) {
    68     unlock_catalog (&catalog);
    69     return (FALSE);
    70   }
    71   unlock_catalog (&catalog);
     67  dvo_catalog_unlock (&catalog);
    7268
    7369  Nstars = catalog.Naverage;
     
    143139  free (DEC);
    144140  free (N1);
    145   if (catalog.average != 0) free (catalog.average);
    146   if (catalog.measure != 0) free (catalog.measure);
    147   if (catalog.secfilt != 0) free (catalog.secfilt);
    148  
     141  dvo_catalog_free (&catalog);
    149142  SkyListFree (skylist, FALSE);
    150143  return (TRUE);
  • trunk/Ohana/src/opihi/dvo/mextract.c

    r7917 r8427  
    1414
    1515  /* defaults */
    16   catalog.average = (Average *) NULL;
    17   catalog.secfilt = (SecFilt *) NULL;
    18   catalog.measure = (Measure *) NULL;
     16  skylist = NULL;
    1917  RegionName = NULL;
    2018  RegionList = NULL;
    2119  code = NULL;
    2220  mode = MAG_REL;
     21  dvo_catalog_init (&catalog, TRUE);
    2322
    2423  /* load photcode information */
     
    5756  for (i = 0; i < skylist[0].Nregions; i++) {
    5857    catalog.filename = skylist[0].filename[i];
    59     switch (lock_catalog (&catalog, LCK_SOFT)) {
    60       case 2:
    61         unlock_catalog (&catalog);
    62       case 0:
    63         continue;
     58    catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
     59
     60    // an error exit status here is a significant error
     61    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     62      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     63      exit (2);
    6464    }
    65     catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
    66     if (!load_catalog (&catalog, FALSE)) {
    67       unlock_catalog (&catalog);
    68       continue;
    69     }
    70     unlock_catalog (&catalog);
     65    dvo_catalog_unlock (&catalog);
    7166
    7267    for (j = 0; j < catalog.Naverage; j++) {
     
    8176      if (M1 != NULL) free (M1);
    8277    }
    83     if (catalog.average != NULL) free (catalog.average);
    84     if (catalog.secfilt != NULL) free (catalog.secfilt);
    85     if (catalog.measure != NULL) free (catalog.measure);
    86     catalog.average = (Average *) NULL;
    87     catalog.secfilt = (SecFilt *) NULL;
    88     catalog.measure = (Measure *) NULL;
     78    dvo_catalog_free (&catalog);
    8979  }
    9080  vec[0].Nelements = N;
     
    10595  FreeImageSelection ();
    10696  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
    107   if (catalog.average != NULL) free (catalog.average);
    108   if (catalog.secfilt != NULL) free (catalog.secfilt);
    109   if (catalog.measure != NULL) free (catalog.measure);
     97  dvo_catalog_free (&catalog);
    11098  if (RegionName != NULL) free (RegionName);
    11199  if (RegionList != NULL) free (RegionList);
  • trunk/Ohana/src/opihi/dvo/photometry.c

    r8132 r8427  
    324324  char PhotCodeFile[256];
    325325
    326   if (VarConfig ("ZERO_PT", "%lf", &ZERO_POINT) == (char *) NULL) return (FALSE);
     326  if (VarConfig ("ZERO_PT", "%lf", &ZERO_POINT) == (char *) NULL) {
     327      gprint (GP_ERR, "ZERO_PT undefined in config\n");
     328      return (FALSE);
     329  }
    327330  SetZeroPoint (ZERO_POINT);
    328331
    329   if (VarConfig ("PHOTCODE_FILE", "%s", PhotCodeFile) == (char *) NULL) return (FALSE);
     332  if (VarConfig ("PHOTCODE_FILE", "%s", PhotCodeFile) == (char *) NULL) {
     333      gprint (GP_ERR, "PHOTCODE_FILE undefined in config\n");
     334      return (FALSE);
     335  }
    330336  if (!LoadPhotcodes (PhotCodeFile)) {
    331337    gprint (GP_ERR, "error loading photcodes\n");
     
    354360  gprint (GP_ERR, "NcodeSelect: %d, %d - %d\n",     NcodeSelect, NcodeSign, NcodeValue);
    355361  gprint (GP_ERR, "FWHMSelect: %d, %d %f %f\n",     FWHMSelect, FWHMsign, FWHMvalue, FWHMfrac);
     362  return (TRUE);
    356363}
    357364
  • trunk/Ohana/src/opihi/dvo/pmeasure.c

    r7917 r8427  
    8181    /* lock, load, unlock catalog */
    8282    catalog.filename = skylist[0].filename[j];
    83     switch (lock_catalog (&catalog, LCK_SOFT)) {
    84       case 2:
    85         unlock_catalog (&catalog);
    86       case 0:
    87         continue;
     83    catalog.catflags = LOAD_AVES | LOAD_MEAS;
     84
     85    // an error exit status here is a significant error
     86    if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     87      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     88      exit (2);
    8889    }
    89     catalog.catflags = LOAD_AVES | LOAD_MEAS;
    90     if (!load_catalog (&catalog, TRUE)) {
    91       unlock_catalog (&catalog);
    92       continue;
    93     }
    94     unlock_catalog (&catalog);
     90    dvo_catalog_unlock (&catalog);
    9591
    9692    /* data has been loaded, get ready to plot it */
     
    138134    free (Zvec.elements);
    139135
    140     if (catalog.average != 0) free (catalog.average);
    141     if (catalog.measure != 0) free (catalog.measure);
     136    dvo_catalog_free (&catalog);
    142137  }
    143138  return (TRUE);
  • trunk/Ohana/src/opihi/dvo/subpix.c

    r7917 r8427  
    4242  /* lock, load, unlock catalog */
    4343  catalog.filename = skylist[0].filename[0];
    44   switch (lock_catalog (&catalog, LCK_SOFT)) {
    45     case 2:
    46       unlock_catalog (&catalog);
    47     case 0:
    48       return (FALSE);
     44  catalog.catflags = LOAD_AVES | LOAD_MEAS;
     45
     46  // an error exit status here is a significant error
     47  if (!dvo_catalog_open (&catalog, NULL, FALSE, "r")) {
     48      fprintf (stderr, "ERROR: failure to open catalog file %s\n", catalog.filename);
     49      exit (2);
    4950  }
    50   catalog.catflags = LOAD_AVES | LOAD_MEAS;
    51   if (!load_catalog (&catalog, TRUE)) {
    52     unlock_catalog (&catalog);
    53     return (FALSE);
    54   }
    55   unlock_catalog (&catalog);
     51  dvo_catalog_unlock (&catalog);
    5652
    5753  /* quick search of star list for Ra, Dec */
     
    8884    free (entry);
    8985    free (index);
    90     if (catalog.average != 0) free (catalog.average);
    91     if (catalog.measure != 0) free (catalog.measure);
     86    dvo_catalog_free (&catalog);
    9287    SkyListFree (skylist, FALSE);
    9388    return (TRUE);
     
    152147  }
    153148
    154   if (catalog.average != 0) free (catalog.average);
    155   if (catalog.measure != 0) free (catalog.measure);
     149  dvo_catalog_free (&catalog);
    156150  free (image);
    157151  free (index);
  • trunk/Ohana/src/opihi/include/external.h

    r7917 r8427  
    1111# include <errno.h>
    1212# include <pthread.h>
     13
     14# include <netinet/ip.h>
     15# include <netdb.h>
     16# include <arpa/inet.h>
    1317
    1418# include <ohana.h>
  • trunk/Ohana/src/opihi/include/pantasks.h

    r8192 r8427  
    55# include <time.h>
    66# include <zlib.h>
    7 # include <netinet/ip.h>
    8 # include <netdb.h>
    9 # include <arpa/inet.h>
    10 
    11 typedef struct sockaddr_in SockAddress;
    127
    138typedef enum {
     
    210205void *ListenClients (void *data);
    211206
    212 int InitServerSocket (SockAddress *Address);
    213 int WaitServerSocket (int InitSocket, SockAddress *Address);
    214 int GetClientSocket (char *hostname);
    215 int InitServerSocket_Named (char *hostname, SockAddress *Address);
    216 
    217207/*
    218208void InitPrint ();
  • trunk/Ohana/src/opihi/include/shell.h

    r8424 r8427  
    1717
    1818typedef int CommandF ();
     19
     20typedef struct sockaddr_in SockAddress;
    1921
    2022/*** typedef structs used by shell functions ***/
     
    149151int           gwrite                    PROTO((char *buffer, int size, int N, gpDest dest));
    150152
     153/* socket functions */
     154int InitServerSocket (SockAddress *Address);
     155int WaitServerSocket (int InitSocket, SockAddress *Address);
     156int GetClientSocket (char *hostname);
     157int InitServerSocket_Named (char *hostname, SockAddress *Address);
     158
    151159# endif
     160
  • trunk/Ohana/src/opihi/lib.data/queues.c

    r8190 r8427  
    232232      key2 = ChooseKey (queue[0].lines[j], Key);
    233233      if (key2 == NULL) continue;
    234       if (strcmp (key1, key2)) {
    235         if (Key != -1) free (key2);
    236         continue;
    237       }
    238       found = TRUE;
    239       if (Key != -1) free (key2);
     234      found = !strcmp (key1, key2);
     235      free (key2);
    240236    }     
    241237    if (!found) PushQueue (queue, tmp.lines[i]);
    242     if (Key != -1) free (key1);
     238    free (key1);
    243239  }
    244240  for (i = 0; i < tmp.Nlines; i++) {
     
    287283      key2 = ChooseKey (queue[0].lines[j], Key);
    288284      if (key2 == NULL) continue;
    289       if (strcmp (key1, key2)) {
    290         if (Key != -1) free (key2);
    291         continue;
     285      found = !strcmp (key1, key2);
     286      if (found) {
     287        // XXX do I need to free queue[0].lines[j]??
     288        queue[0].lines[j] = strcreate (tmp.lines[i]);
    292289      }
    293       queue[0].lines[j] = strcreate (tmp.lines[i]);
    294       found = TRUE;
    295       if (Key != -1) free (key2);
     290      free (key2);
    296291    }     
    297292    if (!found) PushQueue (queue, tmp.lines[i]);
    298     if (Key != -1) free (key1);
     293    free (key1);
    299294  }
    300295  for (i = 0; i < tmp.Nlines; i++) {
  • trunk/Ohana/src/opihi/lib.shell/SocketOps.c

    r7938 r8427  
    1 # include "pantasks.h"
     1# include "shell.h"
    22
    33# define MY_PORT 2000
     
    273273    VALID = NULL;
    274274  }
    275 }
     275  return (TRUE);
     276}
  • trunk/Ohana/src/opihi/lib.shell/version.c

    r8174 r8427  
    1313  char *p, *q;
    1414
    15   p = strcasestr (input, "$NAME:");
     15  p = strstr (input, "$NAME:");
    1616  if (p == NULL) return (unknown);
    1717
Note: See TracChangeset for help on using the changeset viewer.