~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/archive/archive_reader.c

  • Committer: Monty Taylor
  • Date: 2008-10-16 06:32:30 UTC
  • mto: (511.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016063230-4brxsra0qsmsg84q
Added -Wunused-macros.

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 <m_ctype.h>
7
 
#include <m_string.h>
8
 
#include <my_getopt.h>
9
 
#include <drizzle_version.h>
 
6
#include <mystrings/m_ctype.h>
 
7
#include <mystrings/m_string.h>
 
8
#include <mysys/my_getopt.h>
10
9
 
11
10
#define BUFFER_LEN 1024
12
11
#define ARCHIVE_ROW_HEADER_SIZE 4
39
38
    return 0;
40
39
  }
41
40
 
42
 
  if (!(ret= azopen(&reader_handle, argv[0], O_RDONLY|O_BINARY, AZ_METHOD_BLOCK)))
 
41
  if (!(ret= azopen(&reader_handle, argv[0], O_RDONLY, AZ_METHOD_BLOCK)))
43
42
  {
44
43
    printf("Could not open Archive file\n");
45
44
    return 0;
62
61
      new_auto_increment_value= reader_handle.auto_increment + 1;
63
62
    }
64
63
 
65
 
    if (!(ret= azopen(&writer_handle, argv[0], O_CREAT|O_RDWR|O_BINARY, 
 
64
    if (!(ret= azopen(&writer_handle, argv[0], O_CREAT|O_RDWR, 
66
65
                      AZ_METHOD_BLOCK)))
67
66
    {
68
67
      printf("Could not open file for update: %s\n", argv[0]);
153
152
    }
154
153
 
155
154
 
156
 
    if (!(ret= azopen(&writer_handle, argv[1], O_CREAT|O_RDWR|O_BINARY,
 
155
    if (!(ret= azopen(&writer_handle, argv[1], O_CREAT|O_RDWR,
157
156
                      AZ_METHOD_BLOCK)))
158
157
    {
159
158
      printf("Could not open file for backup: %s\n", argv[1]);
167
166
      ptr= (char *)my_malloc(sizeof(char) * reader_handle.frm_length, MYF(0));
168
167
      azread_frm(&reader_handle, ptr);
169
168
      azwrite_frm(&writer_handle, ptr, reader_handle.frm_length);
170
 
      my_free(ptr, MYF(0));
 
169
      free(ptr);
171
170
    }
172
171
 
173
172
    if (reader_handle.comment_length)
176
175
      ptr= (char *)my_malloc(sizeof(char) * reader_handle.comment_length, MYF(0));
177
176
      azread_comment(&reader_handle, ptr);
178
177
      azwrite_comment(&writer_handle, ptr, reader_handle.comment_length);
179
 
      my_free(ptr, MYF(0));
 
178
      free(ptr);
180
179
    }
181
180
 
182
181
    while ((read= azread_row(&reader_handle, &error)))
208
207
  {
209
208
    File frm_file;
210
209
    char *ptr;
211
 
    frm_file= my_open(argv[1], O_CREAT|O_RDWR|O_BINARY, MYF(0));
 
210
    frm_file= my_open(argv[1], O_CREAT|O_RDWR, MYF(0));
212
211
    ptr= (char *)my_malloc(sizeof(char) * reader_handle.frm_length, MYF(0));
213
212
    azread_frm(&reader_handle, ptr);
214
 
    my_write(frm_file, (uchar*) ptr, reader_handle.frm_length, MYF(0));
 
213
    my_write(frm_file, (unsigned char*) ptr, reader_handle.frm_length, MYF(0));
215
214
    my_close(frm_file, MYF(0));
216
 
    my_free(ptr, MYF(0));
 
215
    free(ptr);
217
216
  }
218
217
 
219
218
end:
263
262
  case '?':
264
263
    usage();
265
264
    exit(0);
266
 
  case '#':
267
 
    if (argument == disabled_my_option)
268
 
    {
269
 
      DBUG_POP();
270
 
    }
271
 
    else
272
 
    {
273
 
      DBUG_PUSH(argument ? argument : "d:t:o,/tmp/archive_reader.trace");
274
 
    }
275
 
    break;
276
265
  }
277
266
  return 0;
278
267
}
284
273
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
285
274
  {"check", 'c', "Check table for errors.",
286
275
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
287
 
#ifndef DBUG_OFF
288
 
  {"debug", '#',
289
 
   "Output debug log. Often this is 'd:t:o,filename'.",
290
 
   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
291
 
#endif
292
276
  {"extract-frm", 'e',
293
277
   "Extract the frm file.",
294
278
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
335
319
 
336
320
static void print_version(void)
337
321
{
338
 
  printf("%s  Ver %s Distrib %s, for %s (%s)\n", my_progname, SHOW_VERSION,
339
 
         MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE);
 
322
  printf("%s  Ver %s, for %s (%s)\n", my_progname, SHOW_VERSION,
 
323
         SYSTEM_TYPE, MACHINE_TYPE);
340
324
}
341
325
 
342
326
static void get_options(int *argc, char ***argv)