Index: unk/Ohana/src/imregister/src/imphotset.c
===================================================================
--- /trunk/Ohana/src/imregister/src/imphotset.c	(revision 4846)
+++ 	(revision )
@@ -1,211 +1,0 @@
-# include "imregister.h"
-
-static char PhotError[] = "unknown";
-static char *version = "imphotset $Revision: 1.2 $";
-
-Image *LoadImageTable (FILE *f, Header *header, int *nimage);
-
-int main (int argc, char **argv) {
- 
-  Header header;
-  Image *image;
-  FILE *f;
-  int i, j, status, N;
-  char *dBFile;
-  int Nimage, *index, Ntimes;
-  unsigned long *tstart, *tstop;
-  int VERBOSE, dbstate;
-  int PhotCodeSelect, Nin;
-  char *NameSelect;
-  int NameSelectLength;
-  int ModifyFlag;
-  char *ModifyEntry, *ModifyValue;
-  char *timestr, *photstr;
-  PhotCode *photcode;
-
-  get_version (argc, argv, version);
-  ConfigInit (&argc, argv);
-
-  /* load photcode data */
-  if (!LoadPhotcodes (PhotCodeFile)) {
-    fprintf (stderr, "error loading photcodes from %s\n", PhotCodeFile);
-    exit (1);
-  }
-
-  /* interpret command-line arguments */
-  /* select by image time */
-  if (!get_trange_arguments (&argc, argv, &tstart, &tstop, &Ntimes)) {
-    fprintf (stderr, "ERROR: syntax error\n");
-    exit (1);
-  }
-
-  /* select by image photcode */
-  PhotCodeSelect = FALSE;
-  photcode = NULL;
-  if ((N = get_argument (argc, argv, "-photcode"))) {
-    remove_argument (N, &argc, argv);
-    if ((photcode = GetPhotcodebyName (argv[N])) == NULL) {
-      fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", argv[N]);
-      exit (1);
-    }
-    remove_argument (N, &argc, argv);
-    PhotCodeSelect = TRUE;
-  }
-
-  /* select by image name */
-  NameSelect = (char *) NULL;
-  NameSelectLength = 0;
-  if ((N = get_argument (argc, argv, "-name"))) {
-    remove_argument (N, &argc, argv);
-    NameSelect = strcreate (argv[N]);
-    remove_argument (N, &argc, argv);
-    NameSelectLength = strlen (NameSelect);
-  }
-
-  /* desired action */
-  ModifyFlag = FALSE;
-  ModifyValue = ModifyEntry = NULL;
-  if ((N = get_argument (argc, argv, "-flag"))) {
-    remove_argument (N, &argc, argv);
-    ModifyEntry = strcreate (argv[N]);
-    remove_argument (N, &argc, argv);
-    ModifyValue = strcreate (argv[N]);
-    remove_argument (N, &argc, argv);
-    ModifyFlag = TRUE;
-  }
-
-  VERBOSE = FALSE;
-  if ((N = get_argument (argc, argv, "-v"))) {
-    remove_argument (N, &argc, argv);
-    VERBOSE = TRUE;
-  }
-
-  if (argc != 1) {
-    fprintf (stderr, "USAGE: imphotset [config ops] [-trange start stop/delta] [-photcode code] [-name name] [cmds]\n");
-    exit (1);
-  }
- 
-  /* load image database - still a non-FITS file */
-  dBFile = ImPhotDB;
-
-  f = fsetlockfile (dBFile, 120.0, LCK_HARD, &dbstate);
-  if (f == (FILE *) NULL) {
-    fprintf (stderr, "ERROR: can't set lock on %s, state is %d\n", dBFile, dbstate);
-    exit (1);
-  }
-  image = LoadImageTable (f, &header, &Nimage);
-
-  /* allocate space for reference lists */
-  Nin = 0;
-  ALLOCATE (index, int, Nimage);
-  
-  /* select images based on filters */
-  for (i = 0; i < Nimage; i++) {
-    for (j = 0, status = FALSE; !status && (j < Ntimes); j++) {
-      status = (image[i].tzero >= tstart[j]) && (image[i].tzero <= tstop[j]);
-    }
-    if (!status && Ntimes) continue;
-    if (PhotCodeSelect && (image[i].source != photcode[0].code)) continue;
-    if ((NameSelect != (char *) NULL) && (strncasecmp (image[i].name, NameSelect, NameSelectLength))) continue;
-
-    index[Nin] = i;
-    Nin ++;
-  }
-
-  /* list or modify selected images */
-  for (j = 0; j < Nin; j++) {
-    i = index[j];
-    
-    if (ModifyFlag) {
-      if (!strcasecmp (ModifyEntry, "and")) {
-	image[i].code &= atoi (ModifyValue);
-      }
-      if (!strcasecmp (ModifyEntry, "or")) {
-	image[i].code |= atoi (ModifyValue);
-      }
-      if (!strcasecmp (ModifyEntry, "xor")) {
-	image[i].code ^= atoi (ModifyValue);
-      }
-      if (!strcasecmp (ModifyEntry, "=")) {
-	image[i].code = atoi (ModifyValue);
-      }
-    }
-
-    if (!ModifyFlag) {
-      /* convert UNIX time to Elixir-style date string */
-      timestr = sec_to_date (image[i].tzero);
-    
-      /* convert photcode to filter name */
-      photstr = GetPhotcodeNamebyCode (image[i].source);
-      if (photstr == (char *) NULL) photstr = PhotError;
-    
-      fprintf (stdout, "%s %s %s  %7.4f %7.4f  %7.4f %5d %02x\n", image[i].name, photstr, timestr, 
-	       0.001*image[i].Mcal, 0.001*image[i].dMcal, 0.001*image[i].secz, image[i].nstar, image[i].code); 
-      free (timestr);
-    }
-  }
-
-  if (ModifyFlag) {
-    /* position to begining of file to write header */
-    fseek (f, 0, SEEK_SET);
-    status = Fwrite (header.buffer, 1, header.size, f, "char");
-    if (status != header.size) {
-      fprintf (stderr, "ERROR: failed writing data to image header\n");
-      exit (0);
-    }
-    
-    /* position to end of file for new image data */
-    fseek (f, header.size, SEEK_SET);
-    status = Fwrite (image, sizeof(Image), Nimage, f, "image");
-    if (status != Nimage) {
-      fprintf (stderr, "ERROR: failed writing data to image catalog\n");
-      exit (0);
-    }
-  }
-
-  fclearlockfile (dBFile, f, LCK_HARD, &dbstate);
-
-  if (VERBOSE) fprintf (stderr, "SUCCESS\n");
-  exit (0);
-
-}
-
-Image *LoadImageTable (FILE *f, Header *header, int *nimage) {
-
-  int Nimage, Ndata, Nread, size;
-  struct stat filestatus;
-  Image *image;
-
-  /* read header */
-  if (!fits_fread_header (f, header)) {
-    fprintf (stderr, "ERROR: can't read image catalog\n");
-    exit (1);
-  }
-
-  /* check that file size makes sense */
-  Nimage = 0;
-  fits_scan (header, "NIMAGES", "%d", 1, &Nimage);
-  if (fstat (fileno(f), &filestatus) == -1) {
-    fprintf (stderr, "ERROR: failed to get status of image catalog\n");
-    exit (1);
-  }
-  size = Nimage*sizeof(Image) + header[0].size;
-  if (size != filestatus.st_size) {
-    Ndata = (filestatus.st_size - header[0].size) / sizeof (Image);
-    fprintf (stderr, "ERROR: image catalog has inconsistent size\n");
-    fprintf (stderr, "header: %d, data: %d\n", Nimage, Ndata);
-    Nimage = Ndata;
-  } 
-
-  /* alloc, read images */
-  ALLOCATE (image, Image, MAX (Nimage, 1));
-  Nread = Fread (image, sizeof(Image), Nimage, f, "image");
-  if (Nread != Nimage) {
-    fprintf (stderr, "ERROR: problem loading image catalog\n");
-    exit (1);
-  } 
-
-  *nimage = Nimage;
-  return (image);
-}
-
