~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/archive_reader.c

  • Committer: Jim Winstead
  • Date: 2008-07-19 02:56:45 UTC
  • mto: (202.1.8 codestyle)
  • mto: This revision was merged to the branch mainline in revision 207.
  • Revision ID: jimw@mysql.com-20080719025645-w2pwytebgzusjzjb
Various fixes to enable compilation on Mac OS X, and remove the glib dependency.
Temporarily disables tab-completion in the drizzle client until an appropriate
autoconf check can be added/enabled.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#include <assert.h>
4
4
#include <stdio.h>
5
5
#include <stdarg.h>
6
 
#include <mystrings/m_ctype.h>
7
 
#include <mystrings/m_string.h>
8
 
#include <mysys/my_getopt.h>
 
6
#include <m_ctype.h>
 
7
#include <m_string.h>
 
8
#include <my_getopt.h>
 
9
#include <drizzle_version.h>
9
10
 
10
11
#define BUFFER_LEN 1024
11
12
#define ARCHIVE_ROW_HEADER_SIZE 4
38
39
    return 0;
39
40
  }
40
41
 
41
 
  if (!(ret= azopen(&reader_handle, argv[0], O_RDONLY, AZ_METHOD_BLOCK)))
 
42
  if (!(ret= azopen(&reader_handle, argv[0], O_RDONLY|O_BINARY, AZ_METHOD_BLOCK)))
42
43
  {
43
44
    printf("Could not open Archive file\n");
44
45
    return 0;
61
62
      new_auto_increment_value= reader_handle.auto_increment + 1;
62
63
    }
63
64
 
64
 
    if (!(ret= azopen(&writer_handle, argv[0], O_CREAT|O_RDWR, 
 
65
    if (!(ret= azopen(&writer_handle, argv[0], O_CREAT|O_RDWR|O_BINARY, 
65
66
                      AZ_METHOD_BLOCK)))
66
67
    {
67
68
      printf("Could not open file for update: %s\n", argv[0]);
152
153
    }
153
154
 
154
155
 
155
 
    if (!(ret= azopen(&writer_handle, argv[1], O_CREAT|O_RDWR,
 
156
    if (!(ret= azopen(&writer_handle, argv[1], O_CREAT|O_RDWR|O_BINARY,
156
157
                      AZ_METHOD_BLOCK)))
157
158
    {
158
159
      printf("Could not open file for backup: %s\n", argv[1]);
166
167
      ptr= (char *)my_malloc(sizeof(char) * reader_handle.frm_length, MYF(0));
167
168
      azread_frm(&reader_handle, ptr);
168
169
      azwrite_frm(&writer_handle, ptr, reader_handle.frm_length);
169
 
      free(ptr);
 
170
      my_free(ptr, MYF(0));
170
171
    }
171
172
 
172
173
    if (reader_handle.comment_length)
175
176
      ptr= (char *)my_malloc(sizeof(char) * reader_handle.comment_length, MYF(0));
176
177
      azread_comment(&reader_handle, ptr);
177
178
      azwrite_comment(&writer_handle, ptr, reader_handle.comment_length);
178
 
      free(ptr);
 
179
      my_free(ptr, MYF(0));
179
180
    }
180
181
 
181
182
    while ((read= azread_row(&reader_handle, &error)))
207
208
  {
208
209
    File frm_file;
209
210
    char *ptr;
210
 
    frm_file= my_open(argv[1], O_CREAT|O_RDWR, MYF(0));
 
211
    frm_file= my_open(argv[1], O_CREAT|O_RDWR|O_BINARY, MYF(0));
211
212
    ptr= (char *)my_malloc(sizeof(char) * reader_handle.frm_length, MYF(0));
212
213
    azread_frm(&reader_handle, ptr);
213
 
    my_write(frm_file, (unsigned char*) ptr, reader_handle.frm_length, MYF(0));
 
214
    my_write(frm_file, (uchar*) ptr, reader_handle.frm_length, MYF(0));
214
215
    my_close(frm_file, MYF(0));
215
 
    free(ptr);
 
216
    my_free(ptr, MYF(0));
216
217
  }
217
218
 
218
219
end:
319
320
 
320
321
static void print_version(void)
321
322
{
322
 
  printf("%s  Ver %s, for %s (%s)\n", my_progname, SHOW_VERSION,
323
 
         SYSTEM_TYPE, MACHINE_TYPE);
 
323
  printf("%s  Ver %s Distrib %s, for %s (%s)\n", my_progname, SHOW_VERSION,
 
324
         MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
324
325
}
325
326
 
326
327
static void get_options(int *argc, char ***argv)