Changeset 41379 for trunk/Ohana/src/opihi/cmd.data/list_header.c
- Timestamp:
- Jun 22, 2020, 11:00:22 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/list_header.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/list_header.c
r34088 r41379 1 1 # include "data.h" 2 3 # define SKIP_HEADER(NAME) { if (!strncmp(line, NAME, strlen(NAME))) continue; } 2 4 3 5 int header (int argc, char **argv) { … … 16 18 LOADHEAD = TRUE; 17 19 } 20 if ((N = get_argument (argc, argv, "-file"))) { 21 remove_argument (N, &argc, argv); 22 strcpy (filename, argv[N]); 23 remove_argument (N, &argc, argv); 24 LOADHEAD = TRUE; 25 } 26 27 char *COPYHEAD = NULL; 28 if ((N = get_argument (argc, argv, "-copy"))) { 29 if (LOADHEAD) { 30 gprint (GP_ERR, "-copy and -w are incompatible\n"); 31 return (FALSE); 32 } 33 remove_argument (N, &argc, argv); 34 COPYHEAD = strcreate (argv[N]); 35 remove_argument (N, &argc, argv); 36 } 18 37 19 38 if (argc != 2) { 20 gprint (GP_ERR, "USAGE: header <buffer> [-w filename]\n"); 39 gprint (GP_ERR, "USAGE: header <buffer> [-w filename] [-file filename] [-copy buffer]\n"); 40 gprint (GP_ERR, " -file / -w : replace buffer header with contents from file (PHU only)\n"); 41 gprint (GP_ERR, " -copy : replace buffer header with contents of buffer\n"); 21 42 return (FALSE); 22 43 } 23 44 24 45 if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) return (FALSE); 46 47 if (COPYHEAD) { 48 Buffer *src = NULL; 49 if ((src = SelectBuffer (COPYHEAD, OLDBUFFER, TRUE)) == NULL) return (FALSE); 50 51 // loop over all lines in the header and copy one-by-one 52 // skip the special words: 53 54 for (int i = 0; TRUE; i++) { 55 char *line = gfits_header_lineno (&src[0].header, i); 56 if (!line) break; 57 58 // skip special keywords 59 SKIP_HEADER ("SIMPLE"); 60 SKIP_HEADER ("SIMPLE"); 61 SKIP_HEADER ("BITPIX"); 62 SKIP_HEADER ("NAXIS"); 63 SKIP_HEADER ("EXTEND"); 64 SKIP_HEADER ("UNSIGN"); 65 SKIP_HEADER ("BSCALE"); 66 SKIP_HEADER ("BZERO"); 67 SKIP_HEADER ("NAXIS1"); 68 SKIP_HEADER ("NAXIS2"); 69 SKIP_HEADER ("NAXIS3"); 70 SKIP_HEADER ("NAXIS4"); 71 SKIP_HEADER ("NAXIS5"); 72 SKIP_HEADER ("NAXIS6"); 73 SKIP_HEADER ("NAXIS7"); 74 SKIP_HEADER ("NAXIS8"); 75 SKIP_HEADER ("NAXIS9"); 76 SKIP_HEADER ("NAXIS10"); 77 SKIP_HEADER ("PCOUNT"); 78 SKIP_HEADER ("GCOUNT"); 79 80 gfits_header_append_line_raw (&buf[0].header, line); 81 } 82 return TRUE; 83 84 } 25 85 26 86 if (LOADHEAD) {
Note:
See TracChangeset
for help on using the changeset viewer.
