~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to ext/dbase/dbf.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 1991, 1992, 1993 Brad Eacker,
 
3
 *              (Music, Intuition, Software, and Computers)
 
4
 * All Rights Reserved
 
5
 */
 
6
 
 
7
/*
 
8
 * dbf header structure on disk (pc dbase III)
 
9
 *
 
10
 *  Basic info taken from:
 
11
 *      "File Formats for Popular PC Software"
 
12
 *      Jeff Walden
 
13
 *      (c) 1986 John Wiley & Sons, Inc.
 
14
 */
 
15
 
 
16
#ifndef DBF_H_
 
17
#define DBF_H_
 
18
 
 
19
#include <stdlib.h>
 
20
#include <string.h>
 
21
#ifdef WIN32
 
22
#include <io.h>
 
23
#else
 
24
#include <unistd.h>
 
25
#endif
 
26
 
 
27
/* So we can use O_BINARY on non-Win32 systems. */
 
28
#if !defined(O_BINARY) && !defined(WIN32)
 
29
#define O_BINARY (0)
 
30
#endif
 
31
 
 
32
struct dbf_dhead {
 
33
        char    dbh_dbt;                /* memo (dbt) file present */
 
34
        char    dbh_date[3];            /* last update YY, MM, DD */
 
35
        char    dbh_records[4];         /* number of records LE */
 
36
        char    dbh_hlen[2];            /* header length LE */
 
37
        char    dbh_rlen[2];            /* record length LE */
 
38
        char    dbh_res[20];            /* padding */
 
39
};
 
40
#define DBH_DATE_YEAR   0               /* byte offset for year in dbh_date */
 
41
#define DBH_DATE_MONTH  1
 
42
#define DBH_DATE_DAY    2
 
43
 
 
44
/*
 
45
 * field description on disk
 
46
 */
 
47
 
 
48
#define DBF_NAMELEN     11
 
49
 
 
50
struct dbf_dfield {
 
51
        char    dbf_name[DBF_NAMELEN];  /* name of field */
 
52
        char    dbf_type;               /* type of field */
 
53
        char    dbf_fda[4];             /* something for dbase III */
 
54
        char    dbf_flen[2];            /* field length [and decimal if N] */
 
55
        char    dbf_res[14];            /* padding */
 
56
};
 
57
 
 
58
struct db_field {
 
59
        char    db_fname[DBF_NAMELEN+1];        /* 0 terminated */
 
60
        char    db_type;                /* type of field */
 
61
        int     db_flen;                /* length of field */
 
62
        int     db_fdc;                 /* number of decimals in field */
 
63
 
 
64
        char    *db_format;             /* format for printing %s etc */
 
65
        int     db_foffset;             /* offset within record */
 
66
};
 
67
typedef struct db_field dbfield_t;
 
68
 
 
69
struct db_head {
 
70
        int     db_fd;
 
71
        unsigned char   db_dbt;                 /* dbt present */
 
72
        char    db_date[9];             /* date of last update in db format */
 
73
        long    db_records;             /* number of records */
 
74
        int     db_hlen;                /* header length */
 
75
        int     db_rlen;                /* record length */
 
76
 
 
77
        int     db_nfields;             /* number of fields */
 
78
        dbfield_t       *db_fields;     /* field info */
 
79
        char    *db_name;               /* name of dbf file */
 
80
        int     db_cur_rec;             /* current record */
 
81
};
 
82
typedef struct db_head  dbhead_t;
 
83
 
 
84
#define DBH_TYPE_NORMAL 0x03
 
85
#define DBH_TYPE_MEMO   0x83
 
86
 
 
87
#define VALID_RECORD    ' '
 
88
#define DELETED_RECORD  '*'
 
89
 
 
90
#include "dbf_head.h"
 
91
#include "dbf_misc.h"
 
92
#include "dbf_rec.h"
 
93
 
 
94
#endif  /* DBF_H_ */