Changeset 34388 for branches/eam_branches/ipp-20120805/Ohana
- Timestamp:
- Sep 5, 2012, 3:28:10 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120805/Ohana/src/libdvo
- Files:
-
- 2 edited
-
include/dvo.h (modified) (1 diff)
-
src/dvo_image.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120805/Ohana/src/libdvo/include/dvo.h
r34291 r34388 623 623 int dvo_image_save_raw (FITS_DB *db, int VERBOSE); 624 624 int dvo_image_addrows (FITS_DB *db, Image *new, off_t Nnew); 625 int dvo_image_createID (Header *header); 625 626 void dvo_image_create (FITS_DB *db, double ZeroPoint); 626 627 -
branches/eam_branches/ipp-20120805/Ohana/src/libdvo/src/dvo_image.c
r34260 r34388 200 200 gfits_modify (&db[0].header, "NIMAGES", "%d", 1, 0); 201 201 gfits_modify (&db[0].header, "ZERO_PT", "%lf", 1, ZeroPoint); 202 203 dvo_image_createID (&db[0].header); 202 204 203 205 if (db[0].format == DVO_FORMAT_INTERNAL) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "INTERNAL"); … … 217 219 return; 218 220 } 221 222 // given a dvo image db, add an ID to the header 223 int dvo_image_createID (Header *header) { 224 225 char dbID[33]; 226 227 if (!header->buffer) return FALSE; 228 229 int status = gfits_scan (header, "DVO_DBID", "%s", 1, dbID); 230 if (status) { 231 // do not add a DVO_DBID to a table which already has one 232 return TRUE; 233 } 234 235 // I have a header, I want to add ONE line. double check there is enough space 236 char *p = gfits_header_field (header, "END", 1); 237 if (p == NULL) { 238 fprintf (stderr, "header is missing END\n"); 239 return FALSE; 240 } 241 if (p - header->buffer + 80 == header->datasize) { 242 fprintf (stderr, "no free space in block, can't insert keyword\n"); 243 return FALSE; 244 } 245 246 int start_size = header->datasize; 247 248 long A = time(NULL); 249 srand48(A); 250 251 int i; 252 for (i = 0; i < 32; i++) { 253 sprintf (&dbID[i], "%1x", (int)(16.0*drand48())); 254 } 255 256 gfits_modify (header, "DVO_DBID", "%s", 1, dbID); 257 if (start_size != header->datasize) { 258 fprintf (stderr, "error: header buffer grew? (%d to %d bytes)\n", (int) start_size, (int) header->datasize); 259 return FALSE; 260 } 261 return TRUE; 262 } 263
Note:
See TracChangeset
for help on using the changeset viewer.
