00001
00004 #ifndef _das2_io_h_
00005 #define _das2_io_h_
00006
00007 #include <stdio.h>
00008 #include <zlib.h>
00009 #include <das2/stream.h>
00010 #include <das2/oob.h>
00011 #include <das2/processor.h>
00012
00013
00014 #define STREAM_MODE_STRING 0
00015
00016
00017 #define STREAM_MODE_SOCKET 1
00018
00019
00020 #define STREAM_MODE_FILE 2
00021
00022
00023 #define DAS2_MAX_PROCESSORS 10
00024
00025 #define DASIO_NAME_SZ 128
00026
00034 typedef struct das_io_struct {
00035 char rw;
00036 bool compressed;
00037
00038 int mode;
00039 char sName[DASIO_NAME_SZ];
00040
00041 int offset;
00042
00043
00044 FILE *file;
00045
00046
00047 char *sBuffer;
00048 int nLength;
00049
00050
00051 z_stream *zstrm;
00052 Byte *inbuf;
00053 Byte *outbuf;
00054 int zerr;
00055 int eof;
00056
00057
00058 StreamHandler* pProcs[DAS2_MAX_PROCESSORS+1];
00059 bool bSentHeader;
00060
00061
00062 DasBuf* pDb;
00063
00064 int logLevel;
00065
00066 int taskSize;
00067 long tmLastProgMsg;
00068
00069 OobComment cmt;
00070 } DasIO;
00071
00091 DasIO* new_DasIO_cfile(const char* sProg, FILE* file, const char* mode);
00092
00105 DasIO* new_DasIO_file(const char* sProg, const char* sFile, const char* mode);
00106
00107 DasIO* new_DasIO_str(const char* sProg, char* sbuf, size_t len, const char* mode);
00108
00118 void del_DasIO(DasIO* pThis);
00119
00120
00138 int DasIO_addProcessor(DasIO* pThis, StreamHandler* pProc);
00139
00140
00154 int DasIO_readAll(DasIO* pThis);
00155
00156
00165 ErrorCode DasIO_writeStreamDesc(DasIO* pThis, StreamDesc* pSd);
00166
00174 ErrorCode DasIO_writePktDesc(DasIO* pThis, PktDesc* pd);
00175
00186 ErrorCode DasIO_writePktData(DasIO* pThis, PktDesc* pPd);
00187
00192 ErrorCode DasIO_writeException(DasIO* pThis, OobExcept* pSe);
00193
00200 ErrorCode DasIO_writeComment(DasIO* pThis, OobComment* pSc);
00201
00202 #define LOGLVL_FINEST 0
00203 #define LOGLVL_FINER 300
00204 #define LOGLVL_FINE 400
00205 #define LOGLVL_CONFIG 500
00206 #define LOGLVL_INFO 600
00207 #define LOGLVL_WARNING 700
00208 #define LOGLVL_ERROR 800
00209
00216 ErrorCode DasIO_sendLog(DasIO* pThis, int level, char * msg, ... );
00217
00237 void DasIO_setLogLvl(DasIO* pThis, int minLevel);
00238
00244 int DasIO_getLogLvl(const DasIO* pThis);
00245
00252 const char* LogLvl_string(int logLevel);
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263 ErrorCode DasIO_setTaskSize(DasIO* pThis, int size);
00264
00277 ErrorCode DasIO_setTaskProgress( DasIO* pThis, int progress );
00278
00305 void DasIO_throwException(
00306 DasIO* pThis, StreamDesc* pSd, const char* type, char* msg
00307 );
00308
00316 void DasIO_close(DasIO* pThis);
00317
00327 int DasIO_printf(DasIO* pThis, const char* format, ...);
00328
00332 int DasIO_write(DasIO* pThis, const char* data, int length);
00333
00337 int DasIO_read(DasIO* pThis, DasBuf* pBuf, size_t nBytes);
00338
00343 int DasIO_getc(DasIO* pThis);
00344
00345
00346
00347 #endif