
FITS I/O APIs

  - I/O to a binary FITS table
  - one extension per file?
  - no locking
  - always read/write to/from matched structure
  - user needs to supply idiosyncratic conversions

  - basic APIs:
    - fits_read_datatable_NAME
    - fits_write_datatable_NAME
    - fits_IO_convert_NAME
    - fits_fread_datatable_NAME
    - fits_fwrite_datatable_NAME

  

FITS db APIs

Basic Rules:

  - All db files are Binary FITS tables
  - There is only one extension per file
  - The PHU contains basic information like status & date
  - There is no data array for the PHU (NAXIS = 0)

typedef struct {
  FILE *f;
  char *filename;
  Header header;
  FTable ftable;
  int Nrows;
  int Ncols;
  int Nbyte;
  int lockstate;
  int lockreq;
  NAME *data;
} NAME_DB;

NAME_DB *NAME_DB_Init (NAME_DB *db);

  - 

NAME_DB *NAME_DB_Load (char *filename, int lockreq);

  - lock the database file
  - load PHU
  - load the header
  - validate the EXTNAME
  - validate the header
  - load the data into ftable
  - convert to memory format

  * if SOFT & database file does not exist (file is empty), 
    - return structure w/ 0 entries

  * if HARD & database file does not exist (file is empty), 
    - open, lock, return structure w/ 0 entries

  * if database file cannot be locked
    - return an error (NULL)

  * if header does not validate: 
    - unlock file
    - return an error (NULL)

NAME_DB *NAME_DB_Loadset (char *filename, int lockreq, int start, int Nrows);

  - lock the database file
  - load PHU
  - load the header
  - validate the EXTNAME
  - validate the header
  - load the data into vtable
  - convert to memory format

  * if database file does not exist (file is empty), 
    - open, lock, return structure w/ 0 entries
  * if requested entries don't exist
    - unlock file
    - return an error (NULL)

NAME_DB *NAME_DB_Save ();

  - if Nrows = 0, delete the file

  - write PHU
  - write header
  - write ftable

  - if vtable: 
    - update 
  - if ftable: 
    - update 

NAME_DB *NAME_DB_Saveset ();

  - if Nrows = 0, delete the file

  - write PHU
  - write header
  - write ftable

  - if vtable: 
    - update 
  - if ftable: 
    - update 

NAME_DB *NAME_DB_Free ();

  - unlock file

