Index: /branches/eam_branches/ipp-20130306/Ohana/src/addstar/src/ExternImageIDs.c
===================================================================
--- /branches/eam_branches/ipp-20130306/Ohana/src/addstar/src/ExternImageIDs.c	(revision 35252)
+++ /branches/eam_branches/ipp-20130306/Ohana/src/addstar/src/ExternImageIDs.c	(revision 35252)
@@ -0,0 +1,31 @@
+# include "addstar.h"
+
+int CheckDuplicateImageIDs (Image *images, off_t Nimages) {
+
+  // load the image ID table
+  char filename[DVO_MAX_PATH];
+  snprintf (filename, DVO_MAX_PATH, "%s/ExternImageIDs.fits", CATDIR);
+  ExternImageIDs *imageIDs = ExternImageIDsLoad (filename);
+
+  for (i = 0; i < Nimages; i++) {
+    off_t extID = images[i].externID;
+    if (extID == 0) continue;
+
+    if (extID < imageIDs.minID) continue;
+    if (extID > imageIDs.maxID) continue;
+
+    extIDoff = extID - imageIDs.min;
+    if (imageIDs.value[extIDoff] == -1) continue;
+    fprintf (stderr, "duplicate external image ID "OFF_T_FMT" found, exiting\n", extID);
+    exit (1);
+  }
+  
+  // append the new ext IDs and save
+  for (i = 0; i < Nimages; i++) {
+    append();
+  }
+
+  // do this as an 'extend' operation
+  ExternImageIDsSave (filename, imageIDs);
+  return TRUE;
+}
