30#if defined(HAVE_LIBCFITSIO)
33#pragma GCC diagnostic ignored "-Wstrict-prototypes"
35#pragma GCC diagnostic pop
37#error CFITSIO library is not available
40int main(
int argc,
char *argv[] )
43 char keyname[FLEN_KEYWORD], colname[FLEN_VALUE], coltype[FLEN_VALUE];
45 int single = 0, hdupos = 0, hdutype = 0, bitpix = 0, naxis = 0, ncols = 0, ii = 0;
46 long naxes[10], nrows = 0;
48 int printhelp = ( argc == 2 && ( strcmp( argv[1],
"-h" ) == 0 || strcmp( argv[1],
"--help" ) == 0 ) );
50 if ( printhelp || argc != 2 ) {
51 fprintf( stderr,
"Usage: %s filename[ext] \n", argv[0] );
53 fprintf( stderr,
"List the structure of a single extension, or, if ext is \n" );
54 fprintf( stderr,
"not given, list the structure of the entire FITS file. \n" );
56 fprintf( stderr,
"Note that it may be necessary to enclose the input file\n" );
57 fprintf( stderr,
"name in single quote characters on the Unix command line.\n" );
61#if defined(PAGER) && defined(HAVE_POPEN) && defined(HAVE_PCLOSE)
62 FILE *fout = popen( PAGER,
"w" );
64 fprintf( stderr,
"Could not execute '%s'\n", PAGER );
71 if ( !fits_open_file( &fptr, argv[1], READONLY, &
status ) ) {
72 fits_get_hdu_num( fptr, &hdupos );
75 if ( strchr( argv[1],
'[' ) || strchr( argv[1],
'+' ) ) {
79 for ( ; !
status; hdupos++ ) {
80 fits_get_hdu_type( fptr, &hdutype, &
status );
82 fprintf( fout,
"\nHDU #%d ", hdupos );
83 if ( hdutype == IMAGE_HDU ) {
84 fits_get_img_param( fptr, 10, &bitpix, &naxis, naxes, &
status );
86 fprintf( fout,
"Array: NAXIS = %d, BITPIX = %d\n", naxis, bitpix );
87 for ( ii = 0; ii < naxis; ii++ ) {
88 fprintf( fout,
" NAXIS%d = %ld\n", ii + 1, naxes[ii] );
91 fits_get_num_rows( fptr, &nrows, &
status );
92 fits_get_num_cols( fptr, &ncols, &
status );
94 if ( hdutype == ASCII_TBL ) {
95 fprintf( fout,
"ASCII Table: " );
97 fprintf( fout,
"Binary Table: " );
100 fprintf( fout,
"%d columns x %ld rows\n", ncols, nrows );
101 fprintf( fout,
" COL NAME FORMAT\n" );
103 for ( ii = 1; ii <= ncols; ii++ ) {
104 fits_make_keyn(
"TTYPE", ii, keyname, &
status );
105 fits_read_key( fptr, TSTRING, keyname, colname, NULL, &
status );
106 fits_make_keyn(
"TFORM", ii, keyname, &
status );
107 fits_read_key( fptr, TSTRING, keyname, coltype, NULL, &
status );
109 fprintf( fout,
" %3d %-16s %-16s\n", ii, colname, coltype );
117 fits_movrel_hdu( fptr, 1, NULL, &
status );
120 if (
status == END_OF_FILE ) {
123 fits_close_file( fptr, &
status );
126#if defined(PAGER) && defined(HAVE_POPEN) && defined(HAVE_PCLOSE)
131 fits_report_error( stderr,
status );
int main(int argc, char *argv[])