rdb.h - /rdb library definitions and data structures
SYNOPSIS
DESCRIPTION
#include <stdio.h>
#include <errno.h>
extern int errno; /* error. see intro (2) */
/* sizes and limits */
#define BUFSIZE 2048 /* buffer for rows */
#define FILENAMESIZE 256 /* size of unix filename */
#define MAXCOL 512 /* maximum columns in a row */
#define MAXROW 4096 /* maximum rows for search */
/* local definitions */
#define INT 0 /* coltype value for int */
#define CHAR -1 /* coltype value for char */
#define READ "r" /* fopen read mode */
#define READWRITE "r+" /* fopen update mode */
#define WRITE "w" /* fopen write mode */
#define EOS '\\0' /* null at end of string */
#define TAB '\\t'
#define TABWIDTH 8
/* yes or no / good or bad stuff */
#define MATCH 0 /* string match */
#define NOMATCH -1 /* no string match */
#define OK 0 /* routine passed */
#define NOT_OK -1 /* exit error */
#define N_ERROR -2 /* coltype value for error */
/* index stuff */
#define OFFSETWIDTH 9
#define XHEAD " Offset\\n"
#define XDASH "---------\\n"
#define XHEADLENGTH ((long) (2 * (OFFSETWIDTH + 1)))
/* date formats */
#define COMPUTER 0
#define EUROPEAN 1
#define US 2
#define tolower(c) ((c)>='A'&&(c)<='Z'?((c)-'A'+'a'):(c))
#define toupper(c) ((c)>='a'&&(c)<='z'?((c)-'a'+'A'):(c))
#ifndef NULL
# define NULL 0 /* null */
#endif
#ifndef SEEK_SET
# define SEEK_SET 0
# define SEEK_CUR 1
# define SEEK_END 2
#endif
#ifndef TRUE
# define TRUE 1
# define FALSE 0
#endif
/* row and key structures to hold info */
struct rowstruct {
FILE *p_filein; /* file pointer for input */
FILE *p_fileout; /* file pointer for output */
char *buffer; /* points to start of buffer */
char *p_buffer; /* points to write buffer */
unsigned bufsize; /* size of buffer */
char *p_endbuffer; /* points to end of buffer */
char **p_heads; /* points to each head in list */
int heads; /* number of head columns */
long headlength; /* head line and dashes */
char **p_columns; /* points to each column found */
unsigned colsize; /* size of a char pointer */
unsigned maxcolumns; /* maximum columns array */
int columns; /* number of columns */
int *collengths; /* each column's length */
int rowlength; /* entire row length */
int fixed; /* boolean fixed or variable */
int list; /* boolean list or table */
char fs; /* field separation character */
};
/* keystruct->flags values */
#define SINGLEROW 1 /* return after 1st match */
#define NOBLANKEYS 2 /* don't report blank matches */
#define FOLDCASE 4 /* ignore case */
#define EXACTMATCH 8 /* do byte-for-byte compare */
#define NUMERIC 16 /* treat keys as numeric */
#define DELETIT 32 /* delete this key if found */
struct keystruct {
FILE *file; /* file pointer for input */
FILE *xfile; /* file pointer for index */
char *p_filename; /* file name */
char *p_xfilename; /* index file name */
int maxkeys; /* dynamic maximum keys */
int keys; /* number of keys */
char **p_keynames; /* key columns */
char **p_keyvalues; /* key values */
int *keytocolumn; /* key number to column number */
long *rowoffsets; /* offset in file of each row */
long keyoffsets; /* offset in index file key */
int rows; /* number of rows found */
int flags; /* bools for singlerow etc. */
int (*compare) (); /* comparison routine */
};
SEE ALSO