Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

csv.h

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: csv.h,v 1.13 2005/04/18 19:30:57 bostic Exp $
00008  */
00009 
00010 #include <sys/types.h>
00011 #include <sys/stat.h>
00012 
00013 #include <ctype.h>
00014 #include <errno.h>
00015 #include <stdio.h>
00016 #include <stdlib.h>
00017 #include <string.h>
00018 
00019 #ifdef _WIN32
00020 #define WIN32_LEAN_AND_MEAN     1
00021 
00022 #include <direct.h>
00023 #include <db.h>
00024 
00025 extern int getopt(int, char * const *, const char *);
00026 extern char *optarg;
00027 extern int optind;
00028 #else
00029 #define HAVE_WILDCARD_SUPPORT   1
00030 
00031 #include <regex.h>
00032 #include <unistd.h>
00033 #endif
00034 
00035 #include "db.h"
00036 
00037 /*
00038  * MAP_VERSION
00039  * This code has hooks for versioning, but does not directly support it.
00040  * See the README file for details.
00041  */
00042 #define MAP_VERSION     1
00043 
00044 /*
00045  * Supported formats.
00046  *
00047  * FORMAT_NL:           <nl> separated
00048  * FORMAT_EXCEL:        Excel dumped flat text.
00049  */
00050 typedef enum { FORMAT_EXCEL, FORMAT_NL } input_fmt;
00051 
00052 /*
00053  * OFFSET_LEN
00054  *      The length of any item can be calculated from the two offset fields.
00055  * OFFSET_OOB
00056  *      An offset that's illegal, used to detect unavailable fields.
00057  */
00058 #define OFFSET_LEN(offset, indx)                                        \
00059         (((offset)[(indx) + 1] - (offset)[(indx)]) - 1)
00060 
00061 #define OFFSET_OOB      0
00062 
00063 /*
00064  * Field comparison operators.
00065  */
00066 typedef enum { EQ=1, NEQ, GT, GTEQ, LT, LTEQ, WC, NWC } OPERATOR;
00067 
00068 /*
00069  * Supported data types.
00070  */
00071 typedef enum { NOTSET=1, DOUBLE, STRING, ULONG } datatype;
00072 
00073 /*
00074  * C structure that describes the csv fields.
00075  */
00076 typedef struct {
00077         char     *name;                         /* Field name */
00078         u_int32_t fieldno;                      /* Field index */
00079         datatype  type;                         /* Data type */
00080 
00081         int       indx;                         /* Indexed */
00082         DB       *secondary;                    /* Secondary index handle */
00083 
00084 #define FIELD_OFFSET(field)     ((size_t)(&(((DbRecord *)0)->field)))
00085         size_t    offset;                       /* DbRecord field offset */
00086 } DbField;
00087 
00088 /*
00089  * Globals
00090  */
00091 extern DB        *db;                           /* Primary database */
00092 extern DbField    fieldlist[];                  /* Field list */
00093 extern DB_ENV    *dbenv;                        /* Database environment */
00094 extern char      *progname;                     /* Program name */
00095 extern int        verbose;                      /* Program verbosity */
00096 #ifdef _WIN32
00097 #undef strcasecmp
00098 #define strcasecmp _stricmp
00099 #undef strncasecmp
00100 #define strncasecmp _strnicmp
00101 #define mkdir(d, perm) _mkdir(d)
00102 #endif

Generated on Sun Dec 25 12:14:25 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2