~drizzle-pbxt/drizzle/drizzle-pbxt-2

« back to all changes in this revision

Viewing changes to plugin/archive/azio.cc

  • Committer: Paul McCullagh
  • Date: 2009-11-10 14:18:39 UTC
  • mfrom: (1038.1.7 drizzle-pbxt-pre-merge)
  • Revision ID: paul.mccullagh@primebase.org-20091110141839-2j3k43b17ag6f605
Merged Drizzle trunk and PBXT 1.0.09

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
/* @(#) $Id$ */
13
13
 
 
14
#include <drizzled/global.h>
 
15
 
14
16
#include "azio.h"
15
17
 
16
18
#include <stdio.h>
37
39
static void do_aio_cleanup(azio_stream *s);
38
40
#endif
39
41
 
40
 
extern "C"
41
 
pthread_handler_t run_task(void *p)
 
42
extern "C" pthread_handler_t run_task(void *p);
 
43
 
 
44
extern "C" pthread_handler_t run_task(void *p)
42
45
{
43
46
  int fd;
44
47
  char *buffer;
456
459
  Reads the given number of uncompressed bytes from the compressed file.
457
460
  azread returns the number of bytes actually read (0 for end of file).
458
461
*/
459
 
unsigned int azread_internal( azio_stream *s, voidp buf, unsigned int len, int *error)
 
462
/*
 
463
   This function is legacy, do not use.
 
464
 
 
465
     Reads the given number of uncompressed bytes from the compressed file.
 
466
   If the input file was not in gzip format, gzread copies the given number
 
467
   of bytes into the buffer.
 
468
     gzread returns the number of uncompressed bytes actually read (0 for
 
469
   end of file, -1 for error).
 
470
*/
 
471
static unsigned int azread_internal( azio_stream *s, voidp buf, unsigned int len, int *error)
460
472
{
461
473
  Bytef *start = (Bytef*)buf; /* starting point for crc computation */
462
474
  Byte  *next_out; /* == stream.next_out but not forced far (for MSDOS) */
889
901
  for (n = 0; n < 4; n++)
890
902
  {
891
903
    buffer[0]= (int)(x & 0xff);
892
 
    assert(pwrite(s->file, buffer, 1, s->pos)==1);
 
904
    size_t ret= pwrite(s->file, buffer, 1, s->pos);
 
905
    assert(ret == 1);
893
906
    s->pos++;
894
907
    x >>= 8;
895
908
  }
958
971
  Though this was added to support MySQL's FRM file, anything can be
959
972
  stored in this location.
960
973
*/
961
 
int azwrite_frm(azio_stream *s, char *blob, unsigned int length)
 
974
int azwrite_frm(azio_stream *s, const char *blob, unsigned int length)
962
975
{
963
976
  if (s->mode == 'r')
964
977
    return 1;
993
1006
/*
994
1007
  Simple comment field
995
1008
*/
996
 
int azwrite_comment(azio_stream *s, char *blob, unsigned int length)
 
1009
int azwrite_comment(azio_stream *s, const char *blob, unsigned int length)
997
1010
{
998
1011
  if (s->mode == 'r')
999
 
    return 1;
 
1012
    return -1;
1000
1013
 
1001
1014
  if (s->rows > 0)
1002
 
    return 1;
 
1015
    return -1;
1003
1016
 
1004
1017
  s->comment_start_pos= (uint) s->start;
1005
1018
  s->comment_length= length;
1008
1021
  ssize_t r= pwrite(s->file, (unsigned char*) blob,
1009
1022
                    s->comment_length, s->comment_start_pos);
1010
1023
  if (r != (ssize_t)s->comment_length)
1011
 
    return r;
 
1024
    return -1;
1012
1025
 
1013
1026
  write_header(s);
1014
1027
  s->pos= (size_t)lseek(s->file, 0, SEEK_END);