- Timestamp:
- Mar 19, 2010, 5:35:25 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/largefiles.20100314/Ohana/src/libfits/header/F_print.c
r27295 r27368 2 2 # include <gfitsio.h> 3 3 4 // this only prints the regular and non-boolean fields 4 5 int gfits_print (Header *header, char *field, char *mode, int N,...) { 5 6 … … 8 9 static char blank[] = " "; 9 10 char string[82], line[80]; 10 char *p , a;11 char *p; 11 12 va_list argp; 12 13 … … 61 62 if (!strcmp (mode, "%lg")) { snprintf (string, 81, "%-8s= %20.10G / %46s ", field, va_arg (argp, double), blank); } 62 63 64 /* string value. Quotes must be at least 18 chars apart. Longer lines will this should be fixed to allow arbitrary string lengths, up to 69 chars */ 65 if (!strcmp (mode, "%s")) { 66 strcpy (line, va_arg (argp, char *)); 67 line[68] = 0; 68 snprintf (string, 81, "%-8s= '%-18s' / %46s ", field, line, blank); 69 } 70 71 strncpy (p, string, 80); 72 73 va_end (argp); 74 return (TRUE); 75 76 } 77 78 // alternate version for the special types (boolean, comments, COMMENT) 79 int gfits_print_alt (Header *header, char *field, char *mode, int N,...) { 80 81 /* this function expects one more argument, the value to be written */ 82 83 static char blank[] = " "; 84 char string[82], line[80]; 85 char *p, a; 86 va_list argp; 87 88 va_start (argp, N); 89 90 if (mode[0] != '%') { 91 fprintf (stderr, "gfits_print: weird mode: %s\n", mode); 92 return (FALSE); 93 } 94 95 /* this is supposed to create a new field, not modify an old one. */ 96 p = gfits_header_field (header, field, N); 97 if (p != NULL) return (FALSE); 98 99 /* find the END of the header */ 100 p = gfits_header_field (header, "END", 1); 101 if (p == NULL) return (FALSE); 102 103 /* is there enough space for 1 more line? */ 104 if (header[0].datasize - (p - (header[0].buffer)) < 2*FT_LINE_LENGTH) { 105 header[0].datasize += FT_RECORD_SIZE; 106 REALLOCATE (header[0].buffer, char, header[0].datasize); 107 /* re-find the "END" marker, in case new memory block is used */ 108 p = gfits_header_field (header, "END", 1); 109 if (p == NULL) return (FALSE); 110 memset (p + FT_LINE_LENGTH, ' ', FT_RECORD_SIZE); 111 } 112 113 /* push END line back 1 */ 114 memmove ((p + FT_LINE_LENGTH), p, FT_LINE_LENGTH); 115 memset (p, ' ', FT_LINE_LENGTH); 116 63 117 /* write the boolean mode */ 64 118 if (!strcmp (mode, "%t")) { … … 68 122 else 69 123 snprintf (string, 81, "%-8s= %18s F / %46s ", field, blank, blank); 70 }71 72 /* string value. Quotes must be at least 18 chars apart. Longer lines will this should be fixed to allow arbitrary string lengths, up to 69 chars */73 if (!strcmp (mode, "%s")) {74 strcpy (line, va_arg (argp, char *));75 line[68] = 0;76 snprintf (string, 81, "%-8s= '%-18s' / %46s ", field, line, blank);77 124 } 78 125
Note:
See TracChangeset
for help on using the changeset viewer.
