IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 22, 2008, 8:52:54 AM (18 years ago)
Author:
eugene
Message:

replaced with CFITSIO updates from 3.080; defined our own ricecomp.h to make upgrades easier

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libfits/extern/ricecomp.h

    r15487 r18269  
    1 /* @(#) buffer.h 1.1 98/07/21 12:34:27 */
    2 /* buffer.h: structure for compression to buffer rather than to a file, including
    3  *   bit I/O buffer
    4  *
    5  * R. White, 19 June 1998
    6  */
    71
    82
    9 typedef unsigned char Buffer_t;
     3// 2008.06.22 EAM : This code was taken from CFITSIO and included in Ohana for rice
     4// decompression.  In order to include this .c file (or future upgrades), we include our own
     5// version of ricecomp.h (not the one available in the CFITSIO tree) and include it instead of
     6// fitsio2.h.  This file defines our own version of ffpmsg. 
    107
    11 typedef struct {
    12         int bitbuffer;          /* bit buffer                                   */
    13         int bits_to_go;         /* bits to go in buffer                 */
    14         Buffer_t *start;        /* start of buffer                              */
    15         Buffer_t *current;      /* current position in buffer   */
    16         Buffer_t *end;          /* end of buffer                                */
    17 } Buffer;
    18 
    19 #define buffree(mf)             (free(mf->start), free(mf))
    20 #define bufused(mf)             (mf->current - mf->start)
    21 #define bufreset(mf)    (mf->current = mf->start)
    22 
    23 /*
    24  * getcbuf, putcbuf macros for character IO to buffer
    25  * putcbuf returns EOF on end of buffer, else returns 0
    26  */
    27 #define getcbuf(mf) ((mf->current >= mf->end) ? EOF : *(mf->current)++)
    28 #define putcbuf(c,mf) \
    29         ((mf->current >= mf->end) ? \
    30         EOF :\
    31         ((*(mf->current)++ = c), 0))
    32 
    33 /*
    34  * bufalloc sets up buffer of length n
    35  */
    36 
    37 /*  not needed by CFITSIO
    38 
    39 static Buffer *bufalloc(int n)
    40 {
    41 Buffer *mf;
    42 
    43         mf = (Buffer *) malloc(sizeof(Buffer));
    44         if (mf == (Buffer *)NULL) return((Buffer *)NULL);
    45 
    46         mf->start = (Buffer_t *) malloc(n*sizeof(Buffer_t));
    47         if (mf->start == (Buffer_t *)NULL) {
    48                 free(mf);
    49                 return((Buffer *)NULL);
    50         }
    51         mf->bits_to_go = 8;
    52         mf->end = mf->start + n;
    53         mf->current = mf->start;
    54         return(mf);
     8int ffpmsg (char *line) {
     9   
     10    fprintf (stderr, "%s\n", line);
     11    return 1;
    5512}
    56 */
    57 
    58 /*
    59  * bufrealloc extends buffer (or truncates it) by
    60  * reallocating memory
    61  */
    62 
    63 /* not needed by CFITSIO
    64 static int bufrealloc(Buffer *mf, int n)
    65 {
    66 int len;
    67 
    68         len = mf->current - mf->start;
    69 
    70         * silently throw away data if buffer is already longer than n *
    71         if (len>n) len = n;
    72         if (len<0) len = 0;
    73 
    74         mf->start = (Buffer_t *) realloc(mf->start, n*sizeof(Buffer_t));
    75         if (mf->start == (Buffer_t *)NULL) return(0);
    76 
    77         mf->end = mf->start + n;
    78         mf->current = mf->start + len;
    79         return(n);
    80 }
    81 */
    82 
    83 /*
    84  * bufdump dumps contents of buffer to outfile and resets
    85  * it to be empty.  Returns number of bytes written.
    86  *
    87  * Note we don't write out the bit buffer -- you must call
    88  * done_outputing_bits() first to ensure that the bit buffer
    89  * is written out.  I do it this way to allow incremental
    90  * buffer dumps while bit IO is still going on.
    91  */
    92 
    93 /*  not needed by CFITSIO
    94 
    95 static int bufdump(FILE *outfile, Buffer *buffer)
    96 {
    97 int ndump;
    98 
    99         ndump = bufused(buffer);
    100         if (fwrite(buffer->start, 1, ndump, outfile) != ndump) {
    101                 fprintf(stderr, "bufdump: error in write\n");
    102                 exit(1);
    103     }
    104         bufreset(buffer);
    105         return(ndump);
    106 }
    107 */
Note: See TracChangeset for help on using the changeset viewer.