libohana API reference

ohana memory management functions

 ALLOCATE (void *ptr, type, int Nalloc); 
 REALLOCATE (void *ptr, type, int Nalloc); 
 CHECK_REALLOCATE (void *ptr, type, int Nalloc, int Nused, int Ndelta); 
 free (void *ptr); 
 void  ohana_memregister (void *ptr); 
 void  ohana_memdump (int mode); 
 void  ohana_memcheck (int mode); 

string manipulation functions (string.c)

 int   get_argument (int argc, char **argv, char *arg); 
 int   remove_argument (int Narg, int *argc, char **argv); 
 char *strcreate (char *string); 
 char *strncreate (char *string, int Nbytes); 
 int   strnumcmp (char *str1, char *str2); 
 int   stripwhite (char *string); 
 int   scan_line (FILE *f, char *line); 
 int   dparse (double *value, int Nentry, char *line); 
 int   fparse (double *value, int Nentry, char *line); 
 char *_parse_nextword (char *string); 
 int get_argument (int argc, char **argv, char *arg); 
search argv, argc list (starting at argv[1]) for desired argument. returns entry number if found, 0 otherwise.
 int remove_argument (int Narg, int *argc, char **argv); 
remove the given entry Narg from the argv list, adjusting argc appropriately.
 int stripwhite (char *string); 
strip whitespace (space or tab) from start and end of string.
 int strnumcmp (char *str1, char *str2); 
compare str1 and str2 as strings, or as numbers if both are pure numeric values (base 10 only). returns TRUE / FALSE.

file system functions (findexec.c)

 char *pathname (char *file); 
 char *filerootname (char *file); 
 char *fileextname (char *file); 
 char *filebasename (char *file); 
 char *findexec (int argc, char **argv); 
 int   mkdirhier (char *path); 
 char *getcwd_cfht (char *path, int size); 
 void  make_backup (char *filename); 
 int Fseek (FILE *f, long offset, int whence); 

lockfile functions (glockfile.c)

 FILE *fsetlockfile (char *filename, double timeout, int type, int *state); 
 int   fclearlockfile (char *filename, FILE *f, int type, int *state); 

read/write (Fread.c)

 int Fread (char ptr, int size, int nitems, FILE *f, char *type); 
 int Fwrite (char ptr, int size, int nitems, FILE *f, char *type); 
 int ByteSwap (char *ptr, int size, int nitems, char *type); 
 int ConvertStruct (char *buffer, int size, int nitems, char *type); 
Several of these functions are used to perform byte-swapping for structures in the pre-autocode days. They should be deprecated and dropped, but the autocoding must superceed the hard-wired structure first.

miscellaneous functions

 char *ohana_version (); 

photcode manipulations (LoadPhotcodes.c)

 int   	LoadPhotcodes (char *filename, PhotCodeData *photcodes); 
 int   	FreePhotcodes (PhotCodeData *photcodes); 
 PhotCode *GetPhotcodebyName (char *name); 
 PhotCode *GetPhotcodeEquivbyName (char *name); 
 PhotCode *GetPhotcodebyCode (int code); 
 PhotCode *GetPhotcodeEquivbyCode (int code); 
 PhotCode *GetPhotcodebyNsec (int Nsec); 
 char     *GetPhotcodeNamebyCode (int code); 
 int 	GetPhotcodeCodebyName (char *name); 
 int 	GetPhotcodeEquivCodebyName (char *name); 
 int 	GetPhotcodeEquivCodebyCode (int code); 
 int 	GetPhotcodeNsec (int code); 
 int 	GetPhotcodeNsecfilt (); 
 int      *GetPhotcodeEquivList (int code, int *nlist); 
 void 	SetZeroPoint (double ZP); 
 void 	ParseColorTerms (char *terms, float *X, int *N); 
 int       PhotColor (Average *average, SecFilt *secfilt, Measure *measure, int c1, int c2, double *color); 
 short 	iPhotColor (Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 
 double 	PhotInst (Measure *measure); 
 double 	PhotCat (Measure *measure); 
 double 	PhotSys (Measure *measure, Average *average, SecFilt *secfilt); 
 double 	PhotRel (Measure *measure, Average *average, SecFilt *secfilt); 
 double 	PhotCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 
 double 	PhotAve (PhotCode *code, Average *average, SecFilt *secfilt); 
 double 	PhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 
 double 	PhotdM (PhotCode *code, Average *average, SecFilt *secfilt); 
 double 	PhotXm (PhotCode *code, Average *average, SecFilt *secfilt); 
 short 	iPhotInst (Measure *measure); 
 short 	iPhotCat (Measure *measure); 
 short 	iPhotSys (Measure *measure, Average *average, SecFilt *secfilt); 
 short 	iPhotRel (Measure *measure, Average *average, SecFilt *secfilt); 
 short 	iPhotCal (Measure *thisone, Average *average, SecFilt *secfilt, Measure *measure, PhotCode *code); 
 short 	iPhotAve (PhotCode *code, Average *average, SecFilt *secfilt); 
 short 	iPhotRef (PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure); 
 short 	iPhotdM (PhotCode *code, Average *average, SecFilt *secfilt); 
 short 	iPhotXm (PhotCode *code, Average *average, SecFilt *secfilt); 

functions in config.c

 char *SelectConfigFile (int *argc, char **argv, char *progname); 
 char *LoadConfigFile (char *filename); 
 char *ScanConfig (char *config, char *field, char *mode, int Nentry, ...); 
 char *expandline (char *line, char *config); 
 char *LoadRawConfigFile (char *filename, int options); 

functions in coordops.c

 int XY_to_RD (double *ra, double *dec, double x,  double y,   Coords *coords); 
 int RD_to_XY (double *x,  double *y,   double ra, double dec, Coords *coords); 
 int fXY_to_RD (float *ra, float *dec, float x,  float y,   Coords *coords); 
 int fRD_to_XY (float *x,  float *y,   float ra, float dec, Coords *coords); 
 int GetCoords (Coords *coords, Header *header); 
 int coords_precess (double *ra, double *dec, double in_epoch, double out_epoch); 

functions in phot_catalog.c

 int lock_catalog (Catalog *catalog, int lockmode); 
 int unlock_catalog (Catalog *catalog); 
 int load_catalog (Catalog *catalog, char mode, int VERBOSE); 
 int save_catalog (Catalog *catalog, char VERBOSE); 
 Measure *FixOldMeasure (OldMeasure *in, int Nvalues); 
 Average *FixOldAverage (OldAverage *in, int Nvalues); 
 SecFilt *FixOldSecFilt (OldSecFilt *in, int Nvalues); 

functions in photfits.c

 short int putMi (double value); 
 double getMi (short int value); 
 void returnMcal (Image *image, double *c); 
 void assignMcal (Image *image, double *c, int order); 
 double applyMcal (Image *image, double x, double y); 
 double findscatter (double *X, double *Y, double *M, double *dM, int N, double *c, int order); 

defined macros

the ohana library includes the following macros:

SIGN(X)  
ROUND(X) 
SQR(X)   
SQ(X)    
MIN(X,Y) 
MAX(X,Y) 
SWAP(X,Y) 

whitespace (char c)

defined constants

TRUE
FALSE

LCK_SOFT - block writing
LCK_XCLD - block reading and writing
LCK_HARD - block reading and writing, persistent

LCK_UNLOCK   - file is unlocked 
LCK_ACCESS   - can't get access to file 
LCK_TIMEOUT  - timeout setting lock 
LCK_HARDLCK  - error setting hard lockfile 
LCK_HUNLOCK  - error clearing hard lockfile 
	    
LCK_EMPTY    - locked file is empty 
LCK_FULL     - locked file is not empty 
LCK_UNKNOWN  - can't stat file to get size