~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/archive/azio.h

Reverted 1103

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
34
34
*/
35
35
 
36
 
#ifndef PLUGIN_ARCHIVE_AZIO_H
37
 
#define PLUGIN_ARCHIVE_AZIO_H
 
36
#ifndef __AZIO_H__
 
37
#define __AZIO_H__
38
38
 
39
39
/* We currently allow this on all platforms */
40
40
#define AZIO_AIO
41
41
 
 
42
#include <drizzled/global.h>
42
43
#include <drizzled/common.h>
43
 
#include "drizzled/internal/my_sys.h"
44
 
#include <string.h>
 
44
#include <mysys/my_sys.h>
 
45
 
45
46
#include <zlib.h>
46
47
 
47
48
#ifdef  __cplusplus
224
225
  AZ_METHOD_MAX
225
226
} az_method;
226
227
 
227
 
typedef class azio_container azio_container;
 
228
typedef struct azio_container_st azio_container_st;
228
229
 
229
 
class azio_container {
230
 
public:
 
230
struct azio_container_st {
231
231
  int fd;
232
232
  az_thread_type ready;
233
233
  size_t offset;
236
236
  pthread_mutex_t thresh_mutex;
237
237
  pthread_cond_t threshhold;
238
238
  pthread_t mainthread;            /* Thread descriptor */
239
 
 
240
 
  azio_container():
241
 
    fd(0),
242
 
    offset(0),
243
 
    read_size(0),
244
 
    buffer(NULL),
245
 
    mainthread(0)
246
 
  {}
247
 
 
248
239
};
249
240
 
250
241
 
251
 
typedef class azio_stream {
252
 
public:
 
242
typedef struct azio_stream {
253
243
  z_stream stream;
254
 
  int z_err;    /* error code for last stream operation */
255
 
  int z_eof;    /* set if end of input file */
256
 
  int file;     /* .gz file */
257
 
  Byte *inbuf;  /* input buffer */
258
 
  Byte buffer1[AZ_BUFSIZE_READ];  /* input buffer */
259
 
  Byte buffer2[AZ_BUFSIZE_READ];  /* input buffer */
260
 
  Byte outbuf[AZ_BUFSIZE_WRITE]; /* output buffer */
261
 
  int aio_inited; /* Are we good to go */
262
 
  uLong crc;      /* crc32 of uncompressed data */
263
 
  char *msg;      /* error message */
264
 
  char mode;      /* 'w' or 'r' */
265
 
  size_t start;   /* start of compressed data in file (header skipped) */
266
 
  size_t in;      /* bytes into deflate or inflate */
267
 
  size_t out;     /* bytes out of deflate or inflate */
268
 
  size_t pos;     /* bytes out of deflate or inflate */
269
 
  int back;    /* one character push-back */
270
 
  int last;    /* true if push-back is last character */
 
244
  int      z_err;   /* error code for last stream operation */
 
245
  int      z_eof;   /* set if end of input file */
 
246
  File     file;   /* .gz file */
 
247
  Byte     *inbuf;  /* input buffer */
 
248
  Byte     buffer1[AZ_BUFSIZE_READ];  /* input buffer */
 
249
  Byte     buffer2[AZ_BUFSIZE_READ];  /* input buffer */
 
250
  Byte     outbuf[AZ_BUFSIZE_WRITE]; /* output buffer */
 
251
  int      aio_inited; /* Are we good to go */
 
252
  uLong    crc;     /* crc32 of uncompressed data */
 
253
  char     *msg;    /* error message */
 
254
  char     mode;    /* 'w' or 'r' */
 
255
  size_t  start;   /* start of compressed data in file (header skipped) */
 
256
  size_t  in;      /* bytes into deflate or inflate */
 
257
  size_t  out;     /* bytes out of deflate or inflate */
 
258
  size_t  pos;     /* bytes out of deflate or inflate */
 
259
  int      back;    /* one character push-back */
 
260
  int      last;    /* true if push-back is last character */
271
261
  unsigned char version;   /* Version */
272
262
  unsigned char minor_version;   /* Version */
273
263
  unsigned int block_size;   /* Block Size */
282
272
  unsigned int frm_length;   /* Position for start of FRM */
283
273
  unsigned int comment_start_pos;   /* Position for start of comment */
284
274
  unsigned int comment_length;   /* Position for start of comment */
285
 
 
286
275
#ifdef AZIO_AIO
287
 
  azio_container container;
 
276
  azio_container_st container;
288
277
#endif
289
278
  az_method method;
290
279
  char *row_ptr;
291
 
 
292
 
  azio_stream():
293
 
    z_err(0),
294
 
    z_eof(0),
295
 
    file(0),
296
 
    inbuf(NULL),
297
 
    aio_inited(0),
298
 
    crc(0),
299
 
    msg(NULL),
300
 
    mode(0),
301
 
    start(0),
302
 
    in(0),
303
 
    out(0),
304
 
    pos(0),
305
 
    back(0),
306
 
    last(0),
307
 
    version(0),
308
 
    minor_version(0),
309
 
    block_size(0),
310
 
    check_point(0),
311
 
    forced_flushes(0),
312
 
    rows(0),
313
 
    auto_increment(0),
314
 
    longest_row(0),
315
 
    shortest_row(0),
316
 
    dirty(0),
317
 
    frm_start_pos(0),
318
 
    frm_length(0),
319
 
    comment_start_pos(0),
320
 
    comment_length(0),
321
 
    row_ptr(NULL)
322
 
 {
323
 
    memset(buffer1, 0, AZ_BUFSIZE_READ);
324
 
    memset(buffer2, 0, AZ_BUFSIZE_READ);
325
 
    memset(outbuf, 0, AZ_BUFSIZE_WRITE);
326
 
 }
327
 
 
328
280
} azio_stream;
329
281
 
330
282
                        /* basic functions */
346
298
   can be checked to distinguish the two cases (if errno is zero, the
347
299
   zlib error is Z_MEM_ERROR).  */
348
300
 
349
 
int azdopen(azio_stream *s,int fd, int Flags);
 
301
int azdopen(azio_stream *s,File fd, int Flags);
350
302
/*
351
303
     azdopen() associates a azio_stream with the file descriptor fd.  File
352
304
   descriptors are obtained from calls like open, dup, creat, pipe or
359
311
   the (de)compression state.
360
312
*/
361
313
 
 
314
 
 
315
unsigned int azread_internal( azio_stream *s, voidp buf, unsigned int len, int *error);
 
316
/*
 
317
   This function is legacy, do not use.
 
318
 
 
319
     Reads the given number of uncompressed bytes from the compressed file.
 
320
   If the input file was not in gzip format, gzread copies the given number
 
321
   of bytes into the buffer.
 
322
     gzread returns the number of uncompressed bytes actually read (0 for
 
323
   end of file, -1 for error). */
 
324
 
362
325
extern int azflush(azio_stream *file, int flush);
363
326
/*
364
327
     Flushes all pending output into the compressed file. The parameter
409
372
 
410
373
extern int azwrite_frm (azio_stream *s, const char *blob, unsigned int length);
411
374
extern int azread_frm (azio_stream *s, char *blob);
412
 
extern int azwrite_comment (azio_stream *s, const char *blob, unsigned int length);
 
375
extern int azwrite_comment (azio_stream *s, char *blob, unsigned int length);
413
376
extern int azread_comment (azio_stream *s, char *blob);
414
377
 
415
378
#ifdef  __cplusplus
416
379
}
417
380
#endif
418
381
 
419
 
#endif /* PLUGIN_ARCHIVE_AZIO_H */
 
382
#endif /* AZIO_H */