Changeset 21059 for trunk/Ohana/src/libfits/header/F_modify.c
- Timestamp:
- Dec 30, 2008, 10:01:42 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libfits/header/F_modify.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/header/F_modify.c
r10073 r21059 1 1 # include <ohana.h> 2 2 # include <gfitsio.h> 3 4 char *gfits_keyword_start (char *line);5 char *gfits_keyword_end (char *line);6 void pad_ending (char *line, char value, int Nbyte);7 3 8 4 int gfits_modify (Header *header, char *field, char *mode, int N,...) { … … 51 47 strncpy (comment, qe, p + 80 - qe); 52 48 } 53 pad_ending (comment, ' ', 82); /* comment must contain spaces to the end */49 gfits_pad_ending (comment, ' ', 82); /* comment must contain spaces to the end */ 54 50 55 51 /* write the numeric modes */ … … 96 92 strncpy (data, qs, MAX (MIN (qe - qs, 71), 0)); 97 93 strncpy (comment, va_arg (argp, char *), 80); 98 pad_ending (comment, ' ', 82); /* comment must contain spaces to the end */94 gfits_pad_ending (comment, ' ', 82); /* comment must contain spaces to the end */ 99 95 snprintf (string, 81, "%-8s= %s / %-s", field, data, comment); 100 96 /* this will keep the original line, but truncate the comment */ … … 156 152 } else { 157 153 while ((*c1 != ' ') && (c1 < line + 80)) c1++; 154 } 155 return (c1); 156 } 157 158 /* given a pointer to the FITS HIERARCH card field name, return pointer to the start of the data area */ 159 char *gfits_hierarch_keyword_start (char *line, char *field) { 160 161 char *c; 162 163 /* find the end of the existing data region */ 164 c = line + strlen(field) + 1; 165 if (*c != '=') return (c); /* non-data fields are not allowed */ 166 167 c += 2; 168 /* advance pointer over WHITESPACE */ 169 while ((*c == ' ') && (c < line + 71)) { c++; } 170 171 /* skip one quote mark */ 172 if ((*c == 0x27) && (c < line + 71)) { c++; } 173 174 return (c); 175 } 176 177 /* given a pointer to the FITS HIERARCH card field name, return pointer to the end of the data area */ 178 char *gfits_hierarch_keyword_end (char *line, char *field) { 179 180 int done; 181 char *c1, *c2; 182 183 /* find the end of the existing data region */ 184 c1 = line + strlen(field) + 1; 185 if (*c1 != '=') return (NULL); /* non-data fields are not allowed */ 186 c1 += 2; 187 188 /* advance pointer over WHITESPACE */ 189 while ((*c1 == ' ') && (c1 < line + 71)) { c1++; } 190 191 if (c1[0] == 0x27) { /* entry a string, skip over 'fred' */ 192 for (done = FALSE, c2 = c1 + 1; !done && (c2 < line + 71); c2++) { 193 if ((c2[0] == 0x27) && (c2[1] == 0x27)) { 194 c2 += 2; 195 continue; 196 } 197 if (c2[0] == 0x27) { 198 c1 = c2; 199 done = TRUE; 200 } 201 } 202 if (!done) { /* error in line: mismatched ' chars, return fixed position */ 203 c1 = line + 30; 204 } 205 } else { 206 while ((*c1 != ' ') && (c1 < line + 71)) c1++; 158 207 } 159 208 return (c1); … … 171 220 172 221 /* fill 'line' with Nbyte space from first NULL to last byte with value */ 173 void pad_ending (char *line, char value, int Nbyte) {222 void gfits_pad_ending (char *line, char value, int Nbyte) { 174 223 175 224 char *p;
Note:
See TracChangeset
for help on using the changeset viewer.
