Changeset 21059 for trunk/Ohana/src/libfits/header/F_H_field.c
- Timestamp:
- Dec 30, 2008, 10:01:42 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libfits/header/F_H_field.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/header/F_H_field.c
r16995 r21059 60 60 } 61 61 62 // find the given field among the HIERARCH keywords 63 // these have the form: HIERARCH KEYWORD = value 64 // returns a pointer to the start of the field 65 char *gfits_header_hierarch_field (Header *header, char *field, int N) { 66 67 char *buf, *ptr; 68 int i, Nwant, Nfound, Nfield; 69 70 Nfield = strlen (field); 71 if (Nfield >= 71) return NULL; 72 73 buf = header[0].buffer; 74 75 /* find the Nth entry */ 76 if (N > 0) { 77 Nfound = 0; 78 for (i = 0; i < header[0].size; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) { 79 // have we found a HIERARCH entry? 80 if (strncmp ("HIERARCH", buf, 8)) continue; 81 ptr = buf + 9; // start of following keyword 82 if (strncmp (field, ptr, Nfield)) continue; 83 Nfound ++; 84 if (Nfound == N) return (ptr); 85 } 86 } 87 88 /* find the Ntotal - Nth entry */ 89 if (N < 0) { 90 /* count the entries */ 91 Nfound = 0; 92 for (i = 0; i < header[0].size; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) { 93 if (strncmp ("HIERARCH", buf, 8)) continue; 94 ptr = buf + 9; // start of following keyword 95 if (strncmp (field, ptr, Nfield)) continue; 96 Nfound ++; 97 } 98 99 Nwant = Nfound + N + 1; 100 buf = header[0].buffer; 101 102 /* find the Nwant entry */ 103 Nfound = 0; 104 for (i = 0; i < header[0].size; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) { 105 if (strncmp ("HIERARCH", buf, 8)) continue; 106 ptr = buf + 9; // start of following keyword 107 if (strncmp (field, ptr, Nfield)) continue; 108 Nfound ++; 109 if (Nwant == Nfound) return (ptr); 110 } 111 } 112 113 return ((char *) NULL); 114 115 /* 116 117 find the Nth entry of this keyword. 118 if N < 0, find the last - N - 1 word (ie, -1 = last) 119 120 */ 121 } 122 62 123 /*********************** fits header field ****************************/ 63 124 char *gfits_header_lineno (Header *header, int N) {
Note:
See TracChangeset
for help on using the changeset viewer.
