Lines 191-197
Link Here
|
191 |
|
191 |
|
192 |
count=0; |
192 |
count=0; |
193 |
bp=buff; |
193 |
bp=buff; |
194 |
while (1) { |
194 |
while (count<MAX_SIZE) { |
195 |
c=fgetc(f); |
195 |
c=fgetc(f); |
196 |
switch (c) { |
196 |
switch (c) { |
197 |
|
197 |
|
Lines 210-215
Link Here
|
210 |
default: count++; *bp++ = c; |
210 |
default: count++; *bp++ = c; |
211 |
} |
211 |
} |
212 |
} |
212 |
} |
|
|
213 |
return (count); |
213 |
} |
214 |
} |
214 |
|
215 |
|
215 |
|
216 |
|
Lines 397-403
Link Here
|
397 |
|
398 |
|
398 |
if (strcmp(scanbuff,"END") == 0) { |
399 |
if (strcmp(scanbuff,"END") == 0) { |
399 |
break; |
400 |
break; |
400 |
} else if (sscanf(scanbuff," RECORD_TYPE = %s",rtbuff) == 1) { |
401 |
} else if (sscanf(scanbuff," RECORD_TYPE = %62s",rtbuff) == 1) { |
401 |
if (strncmp(rtbuff,"VARIABLE_LENGTH", (size_t) 15) == 0) { |
402 |
if (strncmp(rtbuff,"VARIABLE_LENGTH", (size_t) 15) == 0) { |
402 |
/* itype=PDSVARIABLE; */ |
403 |
/* itype=PDSVARIABLE; */ |
403 |
} else if (strncmp(rtbuff,"FIXED_LENGTH", (size_t) 12) == 0) { |
404 |
} else if (strncmp(rtbuff,"FIXED_LENGTH", (size_t) 12) == 0) { |
Lines 416-422
Link Here
|
416 |
if (irecsize == 0) irecsize=recsize; |
417 |
if (irecsize == 0) irecsize=recsize; |
417 |
lastwasinote=FALSE; |
418 |
lastwasinote=FALSE; |
418 |
continue; |
419 |
continue; |
419 |
} else if (sscanf(scanbuff," FILE_TYPE = %s", rtbuff) != 0) { |
420 |
} else if (sscanf(scanbuff," FILE_TYPE = %62s", rtbuff) != 0) { |
420 |
lastwasinote=FALSE; |
421 |
lastwasinote=FALSE; |
421 |
if (strncmp(rtbuff,"IMAGE", (size_t) 5) == 0) { |
422 |
if (strncmp(rtbuff,"IMAGE", (size_t) 5) == 0) { |
422 |
isimage=TRUE; |
423 |
isimage=TRUE; |
Lines 445-529
Link Here
|
445 |
lastwasinote=FALSE; continue; |
446 |
lastwasinote=FALSE; continue; |
446 |
} else if (sscanf(scanbuff," SAMPLE_BITS = %d", &samplesize) == 1) { |
447 |
} else if (sscanf(scanbuff," SAMPLE_BITS = %d", &samplesize) == 1) { |
447 |
lastwasinote=FALSE; continue; |
448 |
lastwasinote=FALSE; continue; |
448 |
} else if (sscanf(scanbuff," SAMPLE_TYPE = %s", sampletype) == 1) { |
449 |
} else if (sscanf(scanbuff," SAMPLE_TYPE = %50s", sampletype) == 1) { |
449 |
lastwasinote=FALSE; continue; |
450 |
lastwasinote=FALSE; continue; |
450 |
} else if (sscanf(scanbuff," SPACECRAFT_NAME = %s %s", |
451 |
} else if (sscanf(scanbuff," SPACECRAFT_NAME = %50s %1020s", |
451 |
spacecraft,garbage) == 2 ) { |
452 |
spacecraft,garbage) == 2 ) { |
452 |
strcat(spacecraft,xv_strstr(scanbuff, spacecraft)+strlen(spacecraft)); |
453 |
if (strlen (spacecraft) + strlen (xv_strstr(scanbuff, spacecraft)+strlen(spacecraft)) < COMMENTSIZE-2) |
|
|
454 |
strcat(spacecraft,xv_strstr(scanbuff, spacecraft)+strlen(spacecraft)); |
453 |
lastwasinote=FALSE; continue; |
455 |
lastwasinote=FALSE; continue; |
454 |
} else if (sscanf(scanbuff," SPACECRAFT_NAME = %s", spacecraft) == 1) { |
456 |
} else if (sscanf(scanbuff," SPACECRAFT_NAME = %50s", spacecraft) == 1) { |
455 |
lastwasinote=FALSE; continue; |
457 |
lastwasinote=FALSE; continue; |
456 |
|
458 |
|
457 |
} else if (sscanf(scanbuff," TARGET_NAME = %s", target) == 1) { |
459 |
} else if (sscanf(scanbuff," TARGET_NAME = %50s", target) == 1) { |
458 |
lastwasinote=FALSE; continue; |
460 |
lastwasinote=FALSE; continue; |
459 |
} else if (sscanf(scanbuff," TARGET_BODY = %s", target) == 1) { |
461 |
} else if (sscanf(scanbuff," TARGET_BODY = %50s", target) == 1) { |
460 |
lastwasinote=FALSE; continue; |
462 |
lastwasinote=FALSE; continue; |
461 |
|
463 |
|
462 |
} else if (sscanf(scanbuff," MISSION_PHASE_NAME = %s", mphase) == 1) { |
464 |
} else if (sscanf(scanbuff," MISSION_PHASE_NAME = %50s", mphase) == 1) { |
463 |
lastwasinote=FALSE; continue; |
465 |
lastwasinote=FALSE; continue; |
464 |
} else if (sscanf(scanbuff," MISSION_PHASE = %s", mphase) == 1) { |
466 |
} else if (sscanf(scanbuff," MISSION_PHASE = %50s", mphase) == 1) { |
465 |
lastwasinote=FALSE; continue; |
467 |
lastwasinote=FALSE; continue; |
466 |
|
468 |
|
467 |
} else if (sscanf(scanbuff," INSTRUMENT_NAME = %s", iname) == 1) { |
469 |
} else if (sscanf(scanbuff," INSTRUMENT_NAME = %50s", iname) == 1) { |
468 |
lastwasinote=FALSE; continue; |
470 |
lastwasinote=FALSE; continue; |
469 |
|
471 |
|
470 |
} else if (sscanf(scanbuff," GAIN_MODE_ID = %s", gainmode) == 1) { |
472 |
} else if (sscanf(scanbuff," GAIN_MODE_ID = %50s", gainmode) == 1) { |
471 |
lastwasinote=FALSE; continue; |
473 |
lastwasinote=FALSE; continue; |
472 |
|
474 |
|
473 |
} else if (sscanf(scanbuff," INSTRUMENT_GAIN_STATE = %s",gainmode)==1) { |
475 |
} else if (sscanf(scanbuff," INSTRUMENT_GAIN_STATE = %50s", gainmode)==1) { |
474 |
lastwasinote=FALSE; continue; |
476 |
lastwasinote=FALSE; continue; |
475 |
|
477 |
|
476 |
} else if (sscanf(scanbuff," EDIT_MODE_ID = %s", editmode) == 1) { |
478 |
} else if (sscanf(scanbuff," EDIT_MODE_ID = %50s", editmode) == 1) { |
477 |
lastwasinote=FALSE; continue; |
479 |
lastwasinote=FALSE; continue; |
478 |
|
480 |
|
479 |
} else if (sscanf(scanbuff," INSTRUMENT_EDIT_MODE = %s", editmode)==1) { |
481 |
} else if (sscanf(scanbuff," INSTRUMENT_EDIT_MODE = %50s", editmode)==1) { |
480 |
lastwasinote=FALSE; continue; |
482 |
lastwasinote=FALSE; continue; |
481 |
|
483 |
|
482 |
} else if (sscanf(scanbuff," SCAN_MODE_ID = %s", scanmode) == 1) { |
484 |
} else if (sscanf(scanbuff," SCAN_MODE_ID = %50s", scanmode) == 1) { |
483 |
lastwasinote=FALSE; continue; |
485 |
lastwasinote=FALSE; continue; |
484 |
|
486 |
|
485 |
} else if (sscanf(scanbuff," INSTRUMENT_SCAN_RATE = %s", scanmode)==1) { |
487 |
} else if (sscanf(scanbuff," INSTRUMENT_SCAN_RATE = %50s", scanmode)==1) { |
486 |
lastwasinote=FALSE; continue; |
488 |
lastwasinote=FALSE; continue; |
487 |
|
489 |
|
488 |
} else if (sscanf(scanbuff," SHUTTER_MODE_ID = %s", shuttermode) == 1) { |
490 |
} else if (sscanf(scanbuff," SHUTTER_MODE_ID = %50s", shuttermode) == 1) { |
489 |
lastwasinote=FALSE; continue; |
491 |
lastwasinote=FALSE; continue; |
490 |
|
492 |
|
491 |
} else if (sscanf(scanbuff," INSTRUMENT_SHUTTER_MODE = %s", |
493 |
} else if (sscanf(scanbuff," INSTRUMENT_SHUTTER_MODE = %50s", shuttermode) == 1) { |
492 |
shuttermode) == 1) { |
|
|
493 |
lastwasinote=FALSE; continue; |
494 |
lastwasinote=FALSE; continue; |
494 |
|
495 |
|
495 |
} else if (sscanf(scanbuff," SCAN_MODE_ID = %s", scanmode) == 1) { |
496 |
} else if (sscanf(scanbuff," SCAN_MODE_ID = %50s", scanmode) == 1) { |
496 |
lastwasinote=FALSE; continue; |
497 |
lastwasinote=FALSE; continue; |
497 |
|
498 |
|
498 |
} else if (sscanf(scanbuff," INSTRUMENT_SCAN_RATE = %s", scanmode)==1) { |
499 |
} else if (sscanf(scanbuff," INSTRUMENT_SCAN_RATE = %50s", scanmode)==1) { |
499 |
lastwasinote=FALSE; continue; |
500 |
lastwasinote=FALSE; continue; |
500 |
|
501 |
|
501 |
} else if (sscanf(scanbuff," SPACECRAFT_EVENT_TIME = %s", itime) == 1) { |
502 |
} else if (sscanf(scanbuff," SPACECRAFT_EVENT_TIME = %50s", itime) == 1) { |
502 |
lastwasinote=FALSE; continue; |
503 |
lastwasinote=FALSE; continue; |
503 |
|
504 |
|
504 |
} else if (sscanf(scanbuff," IMAGE_TIME = %s", itime) == 1) { |
505 |
} else if (sscanf(scanbuff," IMAGE_TIME = %50s", itime) == 1) { |
505 |
lastwasinote=FALSE; continue; |
506 |
lastwasinote=FALSE; continue; |
506 |
|
507 |
|
507 |
} else if (sscanf(scanbuff," FILTER_NAME = %s", filtname) == 1) { |
508 |
} else if (sscanf(scanbuff," FILTER_NAME = %50s", filtname) == 1) { |
508 |
lastwasinote=FALSE; continue; |
509 |
lastwasinote=FALSE; continue; |
509 |
|
510 |
|
510 |
} else if (sscanf(scanbuff," INSTRUMENT_FILTER_NAME = %s",filtname)==1) { |
511 |
} else if (sscanf(scanbuff," INSTRUMENT_FILTER_NAME = %50s", filtname)==1) { |
511 |
lastwasinote=FALSE; continue; |
512 |
lastwasinote=FALSE; continue; |
512 |
|
513 |
|
513 |
} else if ((sscanf(scanbuff," EXPOSURE_DURATION = %s", exposure) == 1) |
514 |
} else if ((sscanf(scanbuff," EXPOSURE_DURATION = %50s", exposure) == 1) |
514 |
|| (sscanf(scanbuff," INSTRUMENT_EXPOSURE_DURATION = %s", |
515 |
|| (sscanf(scanbuff," INSTRUMENT_EXPOSURE_DURATION = %50s", |
515 |
exposure) == 1)) { |
516 |
exposure) == 1)) { |
516 |
tmptmp = (char *) index(scanbuff,'='); |
517 |
tmptmp = (char *) index(scanbuff,'='); |
517 |
tmptmp++; |
518 |
tmptmp++; |
518 |
while((*tmptmp) == ' ') |
519 |
while((*tmptmp) == ' ') |
519 |
tmptmp++; |
520 |
tmptmp++; |
520 |
strcpy(exposure,tmptmp); |
521 |
strncpy(exposure,tmptmp,COMMENTSIZE); |
521 |
lastwasinote=FALSE; continue; |
522 |
lastwasinote=FALSE; continue; |
522 |
|
523 |
|
523 |
} else if (sscanf(scanbuff, "NOTE = %s", inote) == 1) { |
524 |
} else if (sscanf(scanbuff, "NOTE = %1000s", inote) == 1) { |
524 |
tmptmp = (char *) index(scanbuff,'='); tmptmp++; |
525 |
tmptmp = (char *) index(scanbuff,'='); tmptmp++; |
525 |
while (((*tmptmp) == ' ') || ((*tmptmp) == '"')) tmptmp++; |
526 |
while (((*tmptmp) == ' ') || ((*tmptmp) == '"')) tmptmp++; |
526 |
strcpy(inote,tmptmp); |
527 |
strncpy(inote,tmptmp,sizeof(inote)-2); |
527 |
strcat(inote," "); |
528 |
strcat(inote," "); |
528 |
|
529 |
|
529 |
/* evil and somewhat risky: A "note" (really, any textual |
530 |
/* evil and somewhat risky: A "note" (really, any textual |
Lines 548-554
Link Here
|
548 |
} else if (lastwasinote) { |
549 |
} else if (lastwasinote) { |
549 |
tmptmp=scanbuff; |
550 |
tmptmp=scanbuff; |
550 |
while (((*tmptmp) == ' ') || ((*tmptmp) == '"')) tmptmp++; |
551 |
while (((*tmptmp) == ' ') || ((*tmptmp) == '"')) tmptmp++; |
551 |
strcat(inote,tmptmp); |
552 |
strncat(inote,tmptmp,sizeof(inote)-strlen(inote)-2); |
552 |
strcat(inote," "); |
553 |
strcat(inote," "); |
553 |
if (index(tmptmp,'"') != NULL) |
554 |
if (index(tmptmp,'"') != NULL) |
554 |
lastwasinote=FALSE; |
555 |
lastwasinote=FALSE; |
Lines 650-673
Link Here
|
650 |
strcat(infobuff,spacecraft); |
651 |
strcat(infobuff,spacecraft); |
651 |
} |
652 |
} |
652 |
|
653 |
|
653 |
if (*target) { |
654 |
if (*target && (strlen(infobuff)+strlen(target)+2 < sizeof (infobuff))) { |
654 |
strcat(infobuff,", "); |
655 |
strcat(infobuff,", "); |
655 |
strcat(infobuff,target); |
656 |
strcat(infobuff,target); |
656 |
} |
657 |
} |
657 |
|
658 |
|
658 |
if (*filtname) { |
659 |
if (*filtname && (strlen(infobuff)+strlen(filtname)+2 < sizeof (infobuff))) { |
659 |
strcat(infobuff,", "); |
660 |
strcat(infobuff,", "); |
660 |
strcat(infobuff,filtname); |
661 |
strcat(infobuff,filtname); |
661 |
} |
662 |
} |
662 |
|
663 |
|
663 |
if (*itime) { |
664 |
if (*itime && (strlen(infobuff)+strlen(itime)+2 < sizeof (infobuff))) { |
664 |
strcat(infobuff,", "); |
665 |
strcat(infobuff,", "); |
665 |
strcat(infobuff,itime); |
666 |
strcat(infobuff,itime); |
666 |
} |
667 |
} |
667 |
|
668 |
|
668 |
SetISTR(ISTR_WARNING,infobuff); |
669 |
/* OUCH! */ |
|
|
670 |
SetISTR(ISTR_WARNING,"%s",infobuff); |
669 |
|
671 |
|
670 |
strcpy(pdsuncompfname,fname); |
672 |
strncpy(pdsuncompfname,fname, sizeof(pdsuncompfname)); |
671 |
ftypstr = ""; |
673 |
ftypstr = ""; |
672 |
|
674 |
|
673 |
switch (itype) { |
675 |
switch (itype) { |
Lines 823-847
Link Here
|
823 |
char tmp[256]; |
825 |
char tmp[256]; |
824 |
*(pinfo->comment) = '\0'; |
826 |
*(pinfo->comment) = '\0'; |
825 |
|
827 |
|
826 |
sprintf(tmp, "Spacecraft: %-28sTarget: %-32s\n", spacecraft, target); |
828 |
snprintf(tmp, sizeof (tmp), "Spacecraft: %-28sTarget: %-32s\n", spacecraft, target); |
827 |
strcat(pinfo->comment, tmp); |
829 |
strcat(pinfo->comment, tmp); |
828 |
|
830 |
|
829 |
sprintf(tmp, "Filter: %-32sMission phase: %-24s\n", filtname, mphase); |
831 |
snprintf(tmp, sizeof (tmp), "Filter: %-32sMission phase: %-24s\n", filtname, mphase); |
830 |
strcat(pinfo->comment, tmp); |
832 |
strcat(pinfo->comment, tmp); |
831 |
|
833 |
|
832 |
sprintf(tmp, "Image time: %-28sGain mode: %-29s\n", itime, gainmode); |
834 |
snprintf(tmp, sizeof (tmp), "Image time: %-28sGain mode: %-29s\n", itime, gainmode); |
833 |
strcat(pinfo->comment, tmp); |
835 |
strcat(pinfo->comment, tmp); |
834 |
|
836 |
|
835 |
sprintf(tmp, "Edit mode: %-29sScan mode: %-29s\n", editmode, scanmode); |
837 |
snprintf(tmp, sizeof (tmp), "Edit mode: %-29sScan mode: %-29s\n", editmode, scanmode); |
836 |
strcat(pinfo->comment, tmp); |
838 |
strcat(pinfo->comment, tmp); |
837 |
|
839 |
|
838 |
sprintf(tmp, "Exposure: %-30sShutter mode: %-25s\n", exposure,shuttermode); |
840 |
snprintf(tmp, sizeof (tmp), "Exposure: %-30sShutter mode: %-25s\n", exposure,shuttermode); |
839 |
strcat(pinfo->comment, tmp); |
841 |
strcat(pinfo->comment, tmp); |
840 |
|
842 |
|
841 |
sprintf(tmp, "Instrument: %-28sImage time: %-28s\n", iname, itime); |
843 |
snprintf(tmp, sizeof (tmp), "Instrument: %-28sImage time: %-28s\n", iname, itime); |
842 |
strcat(pinfo->comment, tmp); |
844 |
strcat(pinfo->comment, tmp); |
843 |
|
845 |
|
844 |
sprintf(tmp, "Image Note: %-28s", inote); |
846 |
snprintf(tmp, sizeof (tmp), "Image Note: %-28s", inote); |
845 |
strcat(pinfo->comment, tmp); |
847 |
strcat(pinfo->comment, tmp); |
846 |
} |
848 |
} |
847 |
|
849 |
|