File indexing completed on 2025-01-05 04:11:58
0001 0002 #ifndef GETDATA_H 0003 #define GETDATA_H 0004 0005 //#include <config.h> 0006 0007 /* The following has been extracted from internal.cpp from kjs */ 0008 0009 /* 0010 ** For systems without NAN, this is a NAN in IEEE double format. 0011 */ 0012 0013 #if !defined(NAN) 0014 static double __NAN() 0015 { 0016 /* work around some strict alignment requirements 0017 for double variables on some architectures (e.g. PA-RISC) */ 0018 typedef union { unsigned char b[8]; double d; } kjs_double_t; 0019 #ifdef WORDS_BIGENDIAN 0020 static const kjs_double_t NaN_Bytes = { { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 } }; 0021 #elif defined(arm) 0022 static const kjs_double_t NaN_Bytes = { { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 } }; 0023 #else 0024 static const kjs_double_t NaN_Bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f } }; 0025 #endif 0026 0027 const double NaN = NaN_Bytes.d; 0028 return NaN; 0029 } 0030 #define NAN __NAN() 0031 #endif /* !defined(NAN) */ 0032 0033 0034 0035 extern const char *GD_ERROR_CODES[15]; 0036 0037 #define GD_E_OK 0 0038 #define GD_E_OPEN_FORMAT 1 0039 #define GD_E_FORMAT 2 0040 #define GD_E_FIELD 4 0041 #define GD_E_BAD_CODE 5 0042 #define GD_E_BAD_RETURN_TYPE 6 0043 #define GD_E_OPEN_RAWFIELD 7 0044 #define GD_E_OPEN_INCLUDE 8 0045 #define GD_E_INTERNAL_ERROR 9 0046 #define GD_E_SIZE_MISMATCH 12 0047 #define GD_E_OPEN_LINFILE 13 0048 #define GD_E_RECURSE_LEVEL 14 0049 0050 /***************************************************************************/ 0051 /* */ 0052 /* GetData: read BLAST format files. */ 0053 /* filename_in: the name of the file directory (raw files are in here) */ 0054 /* field_code: the name of the field you want to read */ 0055 /* first_frame, first_samp: the first sample read is */ 0056 /* first_samp + samples_per_frame*first_frame */ 0057 /* num_frames, num_samps: the number of samples read is */ 0058 /* num_samps + samples_per_frame*num_frames */ 0059 /* return_type: data type of *data_out. 's': 16 bit signed */ 0060 /* 'u' 16bit unsiged. 'S' 32bit signed 'U' 32bit unsigned */ 0061 /* 'c' 8 bit unsigned */ 0062 /* void *data_out: array to put the data */ 0063 /* *error_code: error code is returned here. If error_code==null, */ 0064 /* GetData prints the error message and exits */ 0065 /* */ 0066 /* return value: returns number of samples actually read into data_out */ 0067 /* */ 0068 /***************************************************************************/ 0069 #ifdef __cplusplus 0070 extern "C" 0071 #endif 0072 int GetData(const char *filename_in, const char *field_code, 0073 int first_sframe, int first_samp, 0074 int num_sframes, int num_samp, 0075 char return_type, void *data_out, 0076 int *error_code); 0077 0078 /***************************************************************************/ 0079 /* */ 0080 /* GetDataErrorString: Write a descriptive message in the supplied */ 0081 /* buffer describing the last library error. The message may be */ 0082 /* truncated but should be null terminated. */ 0083 /* */ 0084 /* buffer: memory into which to write the string */ 0085 /* buflen: length of the buffer. GetDataErrorString will not write */ 0086 /* more than buflen characters (including the trailing '\0') */ 0087 /* */ 0088 /* return value: buffer or NULL if buflen < 1 */ 0089 /* */ 0090 /***************************************************************************/ 0091 #ifdef __cplusplus 0092 extern "C" 0093 #endif 0094 char* GetDataErrorString(char* buffer, size_t buflen); 0095 0096 /***************************************************************************/ 0097 /* */ 0098 /* Get the number of samples for each frame for the given field */ 0099 /* */ 0100 /***************************************************************************/ 0101 #ifdef __cplusplus 0102 extern "C" 0103 #endif 0104 int GetSamplesPerFrame(const char *filename_in, const char *field_name, int *error_code); 0105 0106 /***************************************************************************/ 0107 /* */ 0108 /* Get the number of frames available */ 0109 /* */ 0110 /***************************************************************************/ 0111 #ifdef __cplusplus 0112 extern "C" 0113 #endif 0114 int GetNFrames(const char *filename_in, int *error_code, const char *field); 0115 0116 /***************************************************************************/ 0117 /* */ 0118 /* Get the number format structure */ 0119 /* */ 0120 /***************************************************************************/ 0121 #ifdef __cplusplus 0122 extern "C" 0123 #endif 0124 struct FormatType *GetFormat(const char *filedir, int *error_code); 0125 0126 #endif