Changeset 38545
- Timestamp:
- Jun 25, 2015, 2:09:11 PM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150616/Ohana/src/libdvo
- Files:
-
- 12 edited
-
include/convert.h (modified) (1 diff)
-
src/HostTable.c (modified) (1 diff)
-
src/LoadImages.c (modified) (1 diff)
-
src/RegionHostTable.c (modified) (1 diff)
-
src/convert.c (modified) (9 diffs)
-
src/coordops.c (modified) (2 diffs)
-
src/dvo_catalog_create.c (modified) (2 diffs)
-
src/dvo_image.c (modified) (2 diffs)
-
src/dvo_util.c (modified) (2 diffs)
-
src/skydb.c (modified) (4 diffs)
-
src/skyregion_gsc.c (modified) (5 diffs)
-
src/skyregion_io.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/include/convert.h
r31635 r38545 13 13 int hh_hms PROTO((double hh, int *hr, int *mn, double *sc)); 14 14 int dd_dms PROTO((double dd, int *dg, int *mn, double *sc)); 15 int hms_format PROTO((char *line, double value));16 int dms_format PROTO((char *line, double value));15 int hms_format PROTO((char *line, int length, double value)); 16 int dms_format PROTO((char *line, int length, double value)); 17 17 int hh_hm PROTO((double hh, int *hr, double *mn)); 18 18 int day_to_sec PROTO((char *string, time_t *second)); -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/HostTable.c
r38441 r38545 62 62 char *filename = NULL; 63 63 64 ALLOCATE (filename, char, strlen(catdir) + strlen(rootname) + 2); // one slash and one EOL 65 sprintf (filename, "%s/%s", catdir, rootname); 64 int Nchar = strlen(catdir) + strlen(rootname) + 16; 65 ALLOCATE (filename, char, Nchar); // one slash and one EOL 66 snprintf (filename, Nchar, "%s/%s", catdir, rootname); 66 67 67 68 FILE *f = fopen (filename, "r"); -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/LoadImages.c
r38441 r38545 23 23 24 24 catdir = dvo_get_catdir (); 25 s printf (filename, "%s/Images.dat", catdir);25 snprintf (filename, 256, "%s/Images.dat", catdir); 26 26 27 27 if (lastFilename) { -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/RegionHostTable.c
r37807 r38545 64 64 char *filename = NULL; 65 65 66 ALLOCATE (filename, char, strlen(catdir) + strlen(rootname) + 2); // one slash and one EOL 67 sprintf (filename, "%s/%s", catdir, rootname); 66 int Nchar = strlen(catdir) + strlen(rootname) + 16; 67 68 ALLOCATE (filename, char, Nchar); // one slash and one EOL 69 snprintf (filename, Nchar, "%s/%s", catdir, rootname); 68 70 69 71 FILE *f = fopen (filename, "r"); -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/convert.c
r31635 r38545 46 46 } 47 47 48 int hms_format (char *line, double value) {48 int hms_format (char *line, int length, double value) { 49 49 50 50 int hr, mn; … … 54 54 hr = (int) value; 55 55 if (isnan (value)) 56 s printf (line, "xx:xx:xx.xx");56 snprintf (line, length, "xx:xx:xx.xx"); 57 57 else { 58 58 if (value < 0) { 59 s printf (line, "-%02d:%02d:%05.2f", abs(hr), mn, sc);59 snprintf (line, length, "-%02d:%02d:%05.2f", abs(hr), mn, sc); 60 60 } else { 61 s printf (line, "+%02d:%02d:%05.2f", hr, mn, sc);61 snprintf (line, length, "+%02d:%02d:%05.2f", hr, mn, sc); 62 62 } 63 63 } … … 65 65 } 66 66 67 int dms_format (char *line, double value) {67 int dms_format (char *line, int length, double value) { 68 68 69 69 int dg, mn; … … 72 72 dd_dms (value, &dg, &mn, &sc); 73 73 if (value < 0) { 74 s printf (line, "-%02d:%02d:%05.2f", abs(dg), mn, sc);74 snprintf (line, length, "-%02d:%02d:%05.2f", abs(dg), mn, sc); 75 75 } else { 76 s printf (line, "+%02d:%02d:%05.2f", dg, mn, sc);76 snprintf (line, length, "+%02d:%02d:%05.2f", dg, mn, sc); 77 77 } 78 78 return (TRUE); … … 134 134 ALLOCATE (line, char, 64); 135 135 gmt = gmtime (&second); 136 s printf (line, "%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);136 snprintf (line, 64, "%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 137 137 return (line); 138 138 } … … 148 148 switch (gmt[0].tm_wday) { 149 149 case 0: 150 s printf (line, "Sun@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);150 snprintf (line, 64, "Sun@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 151 151 break; 152 152 case 1: 153 s printf (line, "Mon@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);153 snprintf (line, 64, "Mon@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 154 154 break; 155 155 case 2: 156 s printf (line, "Tue@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);156 snprintf (line, 64, "Tue@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 157 157 break; 158 158 case 3: 159 s printf (line, "Wed@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);159 snprintf (line, 64, "Wed@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 160 160 break; 161 161 case 4: 162 s printf (line, "Thu@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);162 snprintf (line, 64, "Thu@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 163 163 break; 164 164 case 5: 165 s printf (line, "Fri@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);165 snprintf (line, 64, "Fri@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 166 166 break; 167 167 case 6: 168 s printf (line, "Sat@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec);168 snprintf (line, 64, "Sat@%02d:%02d:%02d", gmt[0].tm_hour, gmt[0].tm_min, gmt[0].tm_sec); 169 169 break; 170 170 } … … 195 195 hh_hm (deg, &hr, &mn); 196 196 197 s printf (line, "%03d:%04.1f", abs(hr), mn);197 snprintf (line, 16, "%03d:%04.1f", abs(hr), mn); 198 198 return (line); 199 199 } … … 209 209 hh_hm (deg/15.0, &hr, &mn); 210 210 211 s printf (line, "%02d:%04.1f", abs(hr), mn);211 snprintf (line, 16, "%02d:%04.1f", abs(hr), mn); 212 212 return (line); 213 213 } … … 224 224 225 225 if (deg < 0) { 226 s printf (line, "-%02d:%04.1f", abs(hr), mn);226 snprintf (line, 16, "-%02d:%04.1f", abs(hr), mn); 227 227 } else { 228 s printf (line, "+%02d:%04.1f", hr, mn);228 snprintf (line, 16, "+%02d:%04.1f", hr, mn); 229 229 } 230 230 return (line); -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/coordops.c
r38462 r38545 740 740 for (i = 0; i < 14; i++) { 741 741 char name[64]; 742 s printf (name, "PV2_%d", i);742 snprintf (name, 64, "PV2_%d", i); 743 743 if (i < 7) { 744 744 found = gfits_scan (header, name, "%f", 1, &coords[0].polyterms[0][i]); … … 834 834 if (!strncmp (coords[0].ctype, "SLAT", 4)) strcpy (csys, "SLON"); 835 835 if (!strcmp (csys, "NONE")) return (FALSE); 836 s printf (ctype, "%s-%s", csys, &coords[0].ctype[5]);836 snprintf (ctype, 16, "%s-%s", csys, &coords[0].ctype[5]); 837 837 gfits_modify (header, "CTYPE1", "%s", 1, ctype); 838 838 } -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_catalog_create.c
r38441 r38545 105 105 char *path = pathname (catalog[0].filename); 106 106 char *root = filerootname (catalog[0].filename); 107 int length = strlen(path) + strlen(root) + 6; 107 108 int length = strlen(path) + strlen(root) + 16; 108 109 109 110 Catalog *subcat; … … 120 121 ALLOCATE (subcat->filename, char, length); 121 122 122 s printf (subcat->filename, "%s/%s.%s", path, root, ext);123 snprintf (subcat->filename, length, "%s/%s.%s", path, root, ext); 123 124 124 125 char *file = filebasename (subcat->filename); -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_image.c
r38441 r38545 231 231 int dvo_image_createID (Header *header) { 232 232 233 char dbID[ 33];233 char dbID[64]; 234 234 235 235 if (!header->buffer) return FALSE; … … 259 259 int i; 260 260 for (i = 0; i < 32; i++) { 261 sprintf (&dbID[i], "%1x", (int)(16.0*drand48()));261 myAssert (snprintf (&dbID[i], 2, "%1x", (int)(16.0*drand48())) < 2, "overflow"); 262 262 } 263 263 -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/dvo_util.c
r38471 r38545 63 63 } 64 64 65 s printf (dvoConfig->photcodeFile, "%s/Photcodes.dat", dvoConfig->catdir);65 snprintf (dvoConfig->photcodeFile, 256, "%s/Photcodes.dat", dvoConfig->catdir); 66 66 if (!LoadPhotcodes (dvoConfig->photcodeFile, MasterPhotcodeFile, FALSE)) { 67 67 fprintf (stderr, "error loading photcode table %s or master file %s\n", … … 101 101 char filename[256]; 102 102 103 s printf (filename, "%s/Images.dat", dvoConfig->catdir);103 snprintf (filename, 256, "%s/Images.dat", dvoConfig->catdir); 104 104 105 105 gfits_db_init (&dvoConfig->imageDB); -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/skydb.c
r19823 r38545 224 224 /* north dec bands */ 225 225 for (dec = 0; dec < 90; dec += 7.5) { 226 sprintf (db[N].name, "n%04d.cpt", (int) 100*dec);226 myAssert (snprintf (db[N].name, 18, "n%04d.cpt", (int) 100*dec) < 18, "overflow"); 227 227 db[N].Rmin = 0; db[N].Rmax = 360; 228 228 db[N].Dmin = dec; db[N].Dmax = dec + 7.5; … … 233 233 /* south dec bands */ 234 234 for (dec = 0; dec > -90; dec -= 7.5) { 235 sprintf (db[N].name, "s%04d.cpt", (int) 100*dec);235 myAssert (snprintf (db[N].name, 18, "s%04d.cpt", (int) 100*dec) < 18, "overflow"); 236 236 db[N].Rmin = 0; db[N].Rmax = 360; 237 237 db[N].Dmin = dec - 7.5; db[N].Dmax = dec; … … 276 276 new[Nnew].child = FALSE; 277 277 strncpy (root, db[i].name, 5); root[5] = 0; 278 sprintf (new[Nnew].name, "%s/r%04d.cpt", root, Rnumber);278 myAssert (snprintf (new[Nnew].name, 18, "%s/r%04d.cpt", root, Rnumber) < 18, "overflow"); 279 279 Rnumber ++; 280 280 Nnew ++; … … 365 365 db[N].child = FALSE; 366 366 strncpy (root, db[i].name, 10); root[10] = 0; 367 sprintf (db[N].name, "%s.%02d.cpt", root, Rnumber);367 myAssert (snprintf (db[N].name, 18, "%s.%02d.cpt", root, Rnumber) < 18, "overflow"); 368 368 Rnumber ++; 369 369 N ++; -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/skyregion_gsc.c
r38500 r38545 225 225 226 226 temp[5] = 0; 227 s printf (name, "%s/%s", DecName, &temp[1]);227 snprintf (name, 80, "%s/%s", DecName, &temp[1]); 228 228 strcpy (regions[i].name, name); 229 229 } … … 366 366 band[0].regions[Nregions + i].Dmax = -86.250; 367 367 } 368 sprintf (band[0].regions[Nregions + i].name, "%s.%d", basename, i);368 myAssert (snprintf (band[0].regions[Nregions + i].name, 18, "%s.%d", basename, i) < 18, "overflow"); 369 369 } 370 370 band[0].regions[Nregions + i].Rmin = 0.0; … … 377 377 band[0].regions[Nregions + i].Dmax = -88.125; 378 378 } 379 sprintf (band[0].regions[Nregions + i].name, "%s.%d", basename, i);379 myAssert (snprintf (band[0].regions[Nregions + i].name, 18, "%s.%d", basename, i) < 18, "overflow"); 380 380 381 381 zones[0].Nset = 6; … … 436 436 } 437 437 *p = 0; 438 sprintf (name, "%s/z%03d", band[0].regions[Ns].name, Nr);438 myAssert (snprintf (name, 80, "%s/z%03d", band[0].regions[Ns].name, Nr) < 80, "overflow"); 439 439 *p = '/'; 440 440 strcpy (L2[0].regions[Nr].name, name); … … 532 532 L4[0].regions[Nr].backupID = 0; 533 533 534 sprintf (name, "%s.%02d", L3[0].name, Nbox);534 myAssert (snprintf (name, 80, "%s.%02d", L3[0].name, Nbox) < 80, "overflow"); 535 535 strcpy (L4[0].regions[Nr].name, name); 536 536 if (DEBUG >= 4) SkyRegionPrint (&L4[0].regions[Nr]); -
branches/eam_branches/ipp-20150616/Ohana/src/libdvo/src/skyregion_io.c
r38500 r38545 201 201 // this generates the names, be sure to free when not needed 202 202 for (i = 0; i < list[0].Nregions; i++) { 203 s printf (line, "%s/%s.%s", path, list[0].regions[i][0].name, ext);203 snprintf (line, 256, "%s/%s.%s", path, list[0].regions[i][0].name, ext); 204 204 list[0].filename[i] = strcreate (line); 205 205 } … … 215 215 // this generates the names, be sure to free when not needed 216 216 for (i = 0; i < sky[0].Nregions; i++) { 217 s printf (line, "%s/%s.%s", path, sky[0].regions[i].name, ext);217 snprintf (line, 256, "%s/%s.%s", path, sky[0].regions[i].name, ext); 218 218 sky[0].filename[i] = strcreate (line); 219 219 } … … 228 228 229 229 char *skyfile; 230 ALLOCATE (skyfile, char, strlen(catdir) + strlen("/SkyTable.fits") + 1); 231 sprintf (skyfile, "%s/SkyTable.fits", catdir); 230 231 int Nchar = strlen(catdir) + strlen("/SkyTable.fits") + 16; 232 ALLOCATE (skyfile, char, Nchar); 233 snprintf (skyfile, Nchar, "%s/SkyTable.fits", catdir); 232 234 233 235 return skyfile;
Note:
See TracChangeset
for help on using the changeset viewer.
