Geo-Location-TimeZoneFinder

 view release on metacpan or  search on metacpan

shapereader/dbf.h  view on Meta::CPAN

    /** Integer (4 bytes) */
    DBF_TYPE_INTEGER = 'I',
    /** Logical (1 byte) */
    DBF_TYPE_LOGICAL = 'L',
    /** Memo (integer stored as a string) */
    DBF_TYPE_MEMO = 'M',
    /** _NullFlags (bytes) */
    DBF_TYPE_NULLFLAGS = '0',
    /** Number (stored as a string) */
    DBF_TYPE_NUMBER = 'N',
    /** Picture (integer stored as a string) */
    DBF_TYPE_PICTURE = 'P',
    /** Timestamp (8 bytes) */
    DBF_TYPE_TIMESTAMP = '@',
    /** Varbinary */
    DBF_TYPE_VARBINARY = 'Q',
    /** Varchar */
    DBF_TYPE_VARCHAR = 'V'
} dbf_type_t;

/**
 * Field
 */
typedef struct dbf_field_t {
    struct dbf_field_t *next;   /**< Next field or NULL */
    char name[32];              /**< Name */
    dbf_type_t type;            /**< Type */
    size_t length;              /**< Number of bytes */
    size_t decimal_places;      /**< Number of decimal places in a number */
    unsigned char reserved[14]; /**< Reserved bytes */
    size_t size;                /* Size in bytes */
    size_t offset;              /* Position in the record buffer */
} dbf_field_t;

/**
 * File header
 */
typedef struct dbf_header_t {
    dbf_version_t version;      /**< Table version */
    int year;                   /**< Year since 1900 */
    int month;                  /**< Month */
    int day;                    /**< Day */
    size_t num_records;         /**< Number of records */
    size_t header_size;         /**< Number of bytes in the header */
    size_t record_size;         /**< Number of bytes in a record */
    unsigned char reserved[20]; /**< Reserved bytes */
    int num_fields;             /**< Number of fields in each record */
    dbf_field_t *fields;        /**< The fields in each record */
} dbf_header_t;

/**
 * Record
 */
typedef struct dbf_record_t {
    char *bytes; /* Raw data of length record_size */
} dbf_record_t;

/**
 * Convert a Julian date into a tm structure
 *
 * Calculates the calendar date from a Julian date and the time since
 * midnight.
 *
 * The tm_isdst member of the tm structure is always set to -1.
 *
 * @param jd days since 1 January -4712.
 * @param jt milliseconds since midnight.
 * @param[out] tm the converted date.
 *
 * @see "Astronomical Algorithms" @cite Astronomical_Algorithms, p. 63 for a
 *      description of the algorithm.
 */
extern void dbf_jd_to_tm(int32_t jd, int32_t jt, struct tm *tm);

/**
 * Converts a date string in the format "YYYYMMDD" into a tm structure
 *
 * Fills a tm structure with the day, month and year from a date string.
 *
 * The tm_wday member is only valid after 15 October 1582 in the Gregorian
 * calendar.
 *
 * The tm_isdst member is always set to -1.
 *
 * @param ymd a date string in the format "YYYYMMDD".
 * @param n the string length
 * @param[out] tm the converted date.
 * @return true on success, otherwise false.
 */
extern int dbf_yyyymmdd_to_tm(const char *ymd, size_t n, struct tm *tm);

/**
 * Get bytes
 *
 * Gets the bytes and the number of bytes from a field in a record.
 *
 * @memberof dbf_record_t
 * @param record a record.
 * @param field a field in the record.
 * @param[out] pbytes a pointer to the bytes.
 * @param[out] len the number of bytes.
 */
extern void dbf_record_bytes(const dbf_record_t *record,
                             const dbf_field_t *field, const char **pbytes,
                             size_t *len);

/**
 * Get a date
 *
 * Fills a tm structure with the day, month and year from a date in the
 * format "YYYYMMDD".
 *
 * The tm_wday member is only valid after 15 October 1582 in the Gregorian
 * calendar.
 *
 * The tm_isdst member is always set to -1.
 *
 * @memberof dbf_record_t
 * @param record a record.
 * @param field a field in the record.
 * @param[out] tm a tm structure.
 * @return true on success, otherwise false.
 */
extern int dbf_record_date(const dbf_record_t *record,
                           const dbf_field_t *field, struct tm *tm);

/**
 * Get a date and a time
 *
 * Fills a tm structure with a date and time from a date and time field.
 *
 * The tm_isdst member is always set to -1.
 *
 * @memberof dbf_record_t
 * @param record a record.
 * @param field a field in the record.
 * @param[out] tm a tm structure.
 * @return true on success, otherwise false.
 */
extern int dbf_record_datetime(const dbf_record_t *record,
                               const dbf_field_t *field, struct tm *tm);

/**
 * Get a double value
 *
 * Gets a floating-point number from a double field.
 *
 * @memberof dbf_record_t
 * @param record a record.
 * @param field a field in the record.
 * @param[out] value the double value.
 * @return true on success, otherwise false.
 */
extern int dbf_record_double(const dbf_record_t *record,
                             const dbf_field_t *field, double *value);

/**
 * Get a 32-bit integer value
 *
 * Gets an integer from an auto-increment or integer field.
 *
 * @memberof dbf_record_t
 * @param record a record.
 * @param field a field in the record.
 * @param[out] value the unscaled value.
 * @return true on success, otherwise false.
 */
extern int dbf_record_int32(const dbf_record_t *record,
                            const dbf_field_t *field, int32_t *value);

/**
 * Get a 64-bit integer value
 *
 * Gets an unscaled integer from a currency field.  The scale is stored in



( run in 0.458 second using v1.01-cache-2.11-cpan-39bf76dae61 )