IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 18, 2008, 2:52:14 PM (19 years ago)
Author:
eugene
Message:

return NULL if output var requested and entry not found

Location:
trunk/Ohana/src/libfits
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libfits/matrix/F_load_M.c

    r15751 r16139  
    1414
    1515  int i, nbytes, Nbytes;
    16   unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, tmp;
    17   int perpix;
    1816
    1917  matrix[0].bitpix = header[0].bitpix;
     
    4038
    4139# ifdef BYTE_SWAP 
     40 {
     41  int perpix;
     42  unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, tmp;
     43
    4244  perpix = abs(header[0].bitpix) / 8;
    4345  if (perpix > 1) {
     
    8486    }
    8587  }
     88 }
    8689# endif
    8790
  • trunk/Ohana/src/libfits/matrix/F_read_portion.c

    r15743 r16139  
    1313  FILE *f;
    1414  Header header;
    15   int status, i, nbytes, Nbytes, Nrec;
    16   unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, ctmp;
    17   int perpix;
     15  int status, nbytes, Nbytes, Nrec;
    1816
    1917  status = gfits_read_header (filename, &header);
     
    5452
    5553# ifdef BYTE_SWAP 
     54 {
     55  int i, perpix;
     56  unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, ctmp;
     57
    5658  perpix = abs(header.bitpix) / 8;
    5759  if (perpix > 1) {
     
    98100    }
    99101  }
     102 }
    100103# endif
    101104
  • trunk/Ohana/src/libfits/matrix/F_read_segment.c

    r15743 r16139  
    3838  int status, i, nbytes, Nbytes, Nskip, NbytesData;
    3939  int wantaxis[FT_MAX_NAXES][2];
    40   unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, ctmp;
    4140  double tmp;
    42   int perpix;
    4341
    4442  for (i = 0; i < FT_MAX_NAXES; i++) {
     
    9795
    9896# ifdef BYTE_SWAP 
     97 {
     98  unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, ctmp;
     99  int perpix;
     100
    99101  perpix = abs(header[0].bitpix) / 8;
    100102  if (perpix > 1) {
     
    141143    }
    142144  }
     145 }
    143146# endif
    144147
  • trunk/Ohana/src/libfits/matrix/F_write_M.c

    r7054 r16139  
    2121int gfits_fwrite_matrix (FILE *f, Matrix *matrix) {
    2222
    23   int i, status, nbytes, Nbytes;
    24   unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, tmp;
    25   int perpix;
     23  int status, nbytes, Nbytes;
    2624
    2725  status = TRUE;
     
    3028     if the size is wrong, it probably should simply pad the fwrite statement.
    3129     better policy should be defined (ie, matrix.size always correct blocking?)
    32  */
     30  */
    3331
    3432  if (matrix[0].size % FT_RECORD_SIZE)
     
    3937  /* this is a bit cumbersome: swap all words, write out file, then swap back... */
    4038# ifdef BYTE_SWAP 
    41   perpix = abs(matrix[0].bitpix) / 8;
    42   if (perpix > 1) {
    43     byte0 = (unsigned char *) matrix[0].buffer;
    44     byte1 = (unsigned char *) matrix[0].buffer + 1;
    45     byte2 = (unsigned char *) matrix[0].buffer + 2;
    46     byte3 = (unsigned char *) matrix[0].buffer + 3;
    47     byte4 = (unsigned char *) matrix[0].buffer + 4;
    48     byte5 = (unsigned char *) matrix[0].buffer + 5;
    49     byte6 = (unsigned char *) matrix[0].buffer + 6;
    50     byte7 = (unsigned char *) matrix[0].buffer + 7;
    51     if (perpix == 2) {
    52       for (i = 0; i < nbytes; i+=2, byte0 += 2, byte1 += 2) {
    53         tmp = *byte0;
    54         *byte0 = *byte1;
    55         *byte1 = tmp;
     39  {
     40    int i;
     41    unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, tmp;
     42    int perpix;
     43
     44    perpix = abs(matrix[0].bitpix) / 8;
     45    if (perpix > 1) {
     46      byte0 = (unsigned char *) matrix[0].buffer;
     47      byte1 = (unsigned char *) matrix[0].buffer + 1;
     48      byte2 = (unsigned char *) matrix[0].buffer + 2;
     49      byte3 = (unsigned char *) matrix[0].buffer + 3;
     50      byte4 = (unsigned char *) matrix[0].buffer + 4;
     51      byte5 = (unsigned char *) matrix[0].buffer + 5;
     52      byte6 = (unsigned char *) matrix[0].buffer + 6;
     53      byte7 = (unsigned char *) matrix[0].buffer + 7;
     54      if (perpix == 2) {
     55        for (i = 0; i < nbytes; i+=2, byte0 += 2, byte1 += 2) {
     56          tmp = *byte0;
     57          *byte0 = *byte1;
     58          *byte1 = tmp;
     59        }
    5660      }
    57     }
    58     if (perpix == 4) {
    59       for (i = 0; i < nbytes; i+=4, byte0 += 4, byte1 += 4, byte2 += 4, byte3 += 4) {
    60         tmp = *byte0;
    61         *byte0 = *byte3;
    62         *byte3 = tmp;
    63         tmp = *byte1;
    64         *byte1 = *byte2;
    65         *byte2 = tmp;
     61      if (perpix == 4) {
     62        for (i = 0; i < nbytes; i+=4, byte0 += 4, byte1 += 4, byte2 += 4, byte3 += 4) {
     63          tmp = *byte0;
     64          *byte0 = *byte3;
     65          *byte3 = tmp;
     66          tmp = *byte1;
     67          *byte1 = *byte2;
     68          *byte2 = tmp;
     69        }
    6670      }
    67     }
    68     if (perpix == 8) {
    69       for (i = 0; i < nbytes; i+=8, byte0 += 8, byte1 += 8, byte2 += 8, byte3 += 8, byte4 += 8, byte5 += 8, byte6 += 8, byte7 += 8) {
    70         tmp = *byte0;
    71         *byte0 = *byte7;
    72         *byte7 = tmp;
    73         tmp = *byte1;
    74         *byte1 = *byte6;
    75         *byte6 = tmp;
    76         tmp = *byte1;
    77         *byte2 = *byte5;
    78         *byte5 = tmp;
    79         tmp = *byte1;
    80         *byte3 = *byte4;
    81         *byte4 = tmp;
     71      if (perpix == 8) {
     72        for (i = 0; i < nbytes; i+=8, byte0 += 8, byte1 += 8, byte2 += 8, byte3 += 8, byte4 += 8, byte5 += 8, byte6 += 8, byte7 += 8) {
     73          tmp = *byte0;
     74          *byte0 = *byte7;
     75          *byte7 = tmp;
     76          tmp = *byte1;
     77          *byte1 = *byte6;
     78          *byte6 = tmp;
     79          tmp = *byte1;
     80          *byte2 = *byte5;
     81          *byte5 = tmp;
     82          tmp = *byte1;
     83          *byte3 = *byte4;
     84          *byte4 = tmp;
     85        }
    8286      }
    8387    }
     
    9094  }
    9195
    92 # ifdef BYTE_SWAP 
    93   perpix = abs(matrix[0].bitpix) / 8;
    94   if (perpix > 1) {
    95     byte0 = (unsigned char *) matrix[0].buffer;
    96     byte1 = (unsigned char *) matrix[0].buffer + 1;
    97     byte2 = (unsigned char *) matrix[0].buffer + 2;
    98     byte3 = (unsigned char *) matrix[0].buffer + 3;
    99     byte4 = (unsigned char *) matrix[0].buffer + 4;
    100     byte5 = (unsigned char *) matrix[0].buffer + 5;
    101     byte6 = (unsigned char *) matrix[0].buffer + 6;
    102     byte7 = (unsigned char *) matrix[0].buffer + 7;
    103     if (perpix == 2) {
    104       for (i = 0; i < nbytes; i+=2, byte0 += 2, byte1 += 2) {
    105         tmp = *byte0;
    106         *byte0 = *byte1;
    107         *byte1 = tmp;
     96# ifdef BYTE_SWAP
     97  {
     98    int i;
     99    unsigned char *byte0, *byte1, *byte2, *byte3, *byte4, *byte5, *byte6, *byte7, tmp;
     100    int perpix;
     101
     102    perpix = abs(matrix[0].bitpix) / 8;
     103    if (perpix > 1) {
     104      byte0 = (unsigned char *) matrix[0].buffer;
     105      byte1 = (unsigned char *) matrix[0].buffer + 1;
     106      byte2 = (unsigned char *) matrix[0].buffer + 2;
     107      byte3 = (unsigned char *) matrix[0].buffer + 3;
     108      byte4 = (unsigned char *) matrix[0].buffer + 4;
     109      byte5 = (unsigned char *) matrix[0].buffer + 5;
     110      byte6 = (unsigned char *) matrix[0].buffer + 6;
     111      byte7 = (unsigned char *) matrix[0].buffer + 7;
     112      if (perpix == 2) {
     113        for (i = 0; i < nbytes; i+=2, byte0 += 2, byte1 += 2) {
     114          tmp = *byte0;
     115          *byte0 = *byte1;
     116          *byte1 = tmp;
     117        }
    108118      }
    109     }
    110     if (perpix == 4) {
    111       for (i = 0; i < nbytes; i+=4, byte0 += 4, byte1 += 4, byte2 += 4, byte3 += 4) {
    112         tmp = *byte0;
    113         *byte0 = *byte3;
    114         *byte3 = tmp;
    115         tmp = *byte1;
    116         *byte1 = *byte2;
    117         *byte2 = tmp;
     119      if (perpix == 4) {
     120        for (i = 0; i < nbytes; i+=4, byte0 += 4, byte1 += 4, byte2 += 4, byte3 += 4) {
     121          tmp = *byte0;
     122          *byte0 = *byte3;
     123          *byte3 = tmp;
     124          tmp = *byte1;
     125          *byte1 = *byte2;
     126          *byte2 = tmp;
     127        }
    118128      }
    119     }
    120     if (perpix == 8) {
    121       for (i = 0; i < nbytes; i+=8, byte0 += 8, byte1 += 8, byte2 += 8, byte3 += 8, byte4 += 8, byte5 += 8, byte6 += 8, byte7 += 8) {
    122         tmp = *byte0;
    123         *byte0 = *byte7;
    124         *byte7 = tmp;
    125         tmp = *byte1;
    126         *byte1 = *byte6;
    127         *byte6 = tmp;
    128         tmp = *byte1;
    129         *byte2 = *byte5;
    130         *byte5 = tmp;
    131         tmp = *byte1;
    132         *byte3 = *byte4;
    133         *byte4 = tmp;
     129      if (perpix == 8) {
     130        for (i = 0; i < nbytes; i+=8, byte0 += 8, byte1 += 8, byte2 += 8, byte3 += 8, byte4 += 8, byte5 += 8, byte6 += 8, byte7 += 8) {
     131          tmp = *byte0;
     132          *byte0 = *byte7;
     133          *byte7 = tmp;
     134          tmp = *byte1;
     135          *byte1 = *byte6;
     136          *byte6 = tmp;
     137          tmp = *byte1;
     138          *byte2 = *byte5;
     139          *byte5 = tmp;
     140          tmp = *byte1;
     141          *byte3 = *byte4;
     142          *byte4 = tmp;
     143        }
    134144      }
    135145    }
  • trunk/Ohana/src/libfits/table/F_get_column.c

    r12399 r16139  
    11# include <ohana.h>
    22# include <gfitsio.h>
    3 # define SWAP_BYTE \
    4   tmp = Pin[0]; Pin[0] = Pin[1]; Pin[1] = tmp;
    5 # define SWAP_WORD \
     3# define SWAP_BYTE { \
     4  char tmp; \
     5  tmp = Pin[0]; Pin[0] = Pin[1]; Pin[1] = tmp; }
     6# define SWAP_WORD { \
     7  char tmp; \
    68  tmp = Pin[0]; Pin[0] = Pin[3]; Pin[3] = tmp; \
    7   tmp = Pin[1]; Pin[1] = Pin[2]; Pin[2] = tmp;
    8 # define SWAP_DBLE \
     9  tmp = Pin[1]; Pin[1] = Pin[2]; Pin[2] = tmp; }
     10# define SWAP_DBLE { \
     11  char tmp; \
    912  tmp = Pin[0]; Pin[0] = Pin[7]; Pin[7] = tmp; \
    1013  tmp = Pin[1]; Pin[1] = Pin[6]; Pin[6] = tmp; \
    1114  tmp = Pin[2]; Pin[2] = Pin[5]; Pin[5] = tmp; \
    12   tmp = Pin[3]; Pin[3] = Pin[4]; Pin[4] = tmp;
     15  tmp = Pin[3]; Pin[3] = Pin[4]; Pin[4] = tmp; }
    1316
    1417/***********************/
     
    4346  int i, N, Nfields, Nval, Nbytes, Nx, Ny, Nstart, Nv, Nb;
    4447  char tlabel[80], field[80], format[80], type[16], tmpline[16];
    45   char *Pin, *Pout, *array, tmp;
     48  char *Pin, *Pout, *array;
    4649  double Bscale, Bzero;
    47   int I;
    4850
    4951  if (label == (char *) NULL) return (FALSE);
     
    105107    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    106108# ifdef BYTE_SWAP
    107       I = i*Nbytes;
    108109      SWAP_BYTE;
    109110# endif
     
    114115    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    115116# ifdef BYTE_SWAP
    116       I = i*Nbytes;
    117117      SWAP_WORD;
    118118# endif
     
    123123    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    124124# ifdef BYTE_SWAP
    125       I = i*Nbytes;
    126125      SWAP_WORD;
    127126# endif
     
    132131    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    133132# ifdef BYTE_SWAP
    134       I = i*Nbytes;
    135133      SWAP_DBLE;
    136134# endif
  • trunk/Ohana/src/libfits/table/F_set_column.c

    r15487 r16139  
    11# include <ohana.h>
    22# include <gfitsio.h>
    3 # define SWAP_BYTE \
    4   tmp = Pout[0]; Pout[0] = Pout[1]; Pout[1] = tmp;
    5 # define SWAP_WORD \
     3# define SWAP_BYTE { \
     4  char tmp; \
     5  tmp = Pout[0]; Pout[0] = Pout[1]; Pout[1] = tmp; }
     6# define SWAP_WORD { \
     7  char tmp; \
    68  tmp = Pout[0]; Pout[0] = Pout[3]; Pout[3] = tmp; \
    7   tmp = Pout[1]; Pout[1] = Pout[2]; Pout[2] = tmp;
    8 # define SWAP_DBLE \
     9  tmp = Pout[1]; Pout[1] = Pout[2]; Pout[2] = tmp; }
     10# define SWAP_DBLE { \
     11  char tmp; \
    912  tmp = Pout[0]; Pout[0] = Pout[7]; Pout[7] = tmp; \
    1013  tmp = Pout[1]; Pout[1] = Pout[6]; Pout[6] = tmp; \
    1114  tmp = Pout[2]; Pout[2] = Pout[5]; Pout[5] = tmp; \
    12   tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp;
     15  tmp = Pout[3]; Pout[3] = Pout[4]; Pout[4] = tmp; }
    1316
    1417/***********************/
     
    1720  int i, N, Nfields, Nval, Nbytes, Nx, Ny, nbytes, Nstart, Nv, Nb;
    1821  char tlabel[80], field[80], format[80], type[16], tmpline[16];
    19   char *Pin, *Pout, *array, tmp;
     22  char *Pin, *Pout, *array;
    2023  double Bscale, Bzero;
    21   int I;
    2224
    2325  if (label == (char *) NULL) return (FALSE);
     
    8284      *(short *)Pout = (*(short *)Pin - Bzero) / Bscale;
    8385# ifdef BYTE_SWAP
    84       I = i*Nbytes;
    8586      SWAP_BYTE;
    8687# endif
     
    9192      *(int *)Pout = (*(int *)Pin - Bzero) / Bscale;
    9293# ifdef BYTE_SWAP
    93       I = i*Nbytes;
    9494      SWAP_WORD;
    9595# endif
     
    100100      *(float *)Pout = (*(float *)Pin - Bzero) / Bscale;
    101101# ifdef BYTE_SWAP
    102       I = i*Nbytes;
    103102      SWAP_WORD;
    104103# endif
     
    109108      *(double *)Pout = (*(double *)Pin - Bzero) / Bscale;
    110109# ifdef BYTE_SWAP
    111       I = i*Nbytes;
    112110      SWAP_DBLE;
    113111# endif
Note: See TracChangeset for help on using the changeset viewer.