1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
/*
* pdbfile.h
*
* (c) 2002,2009 by Jeremy Bowman <jmbowman@alum.mit.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
/** @file pdbfile.h
* Header file for PDBFile
*/
#ifndef PDBFILE_H
#define PDBFILE_H
#include <QString>
#include <sys/types.h>
class QFile;
/**
* Parser for .pdb files (Palm OS application data). Can be subclassed to
* support specific Palm OS applications' data.
*/
class PDBFile
{
public:
PDBFile(const QString &f);
virtual ~PDBFile();
virtual bool read();
protected:
/**
* Information about one record in a .pdb file.
*/
struct RecordInfo {
unsigned int record_data_offset; /**< The location in the file at which the record starts */
unsigned char record_attributes; /**< A bitmap of record attributes */
unsigned int unique_id; /**< The unique ID of the record */
unsigned int record_size; /**< The length of the record in bytes */
};
bool readHeader();
bool readRecordList();
unsigned short toshort(unsigned char *v) const;
unsigned int toint(unsigned char *v) const;
time_t palm2unix_time(unsigned int p) const;
protected:
QFile *fd; /**< The file being parsed */
QString filename; /**< The path of the file being parsed */
unsigned char pdb_name[33]; /**< Name field of the file header */
unsigned short file_attributes; /**< File attributes field of the file header */
unsigned short version; /**< Version field of the file header */
unsigned int create_date; /**< Creation date field of the file header */
unsigned int modification_date; /**< Modification date field of the file header */
unsigned int backup_date; /**< Backup date field of the file header */
unsigned int modification_number; /**< Modification number field of the file header */
unsigned int appinfo_offset; /**< Appinfo offset field of the file header */
unsigned int sortinfo_offset; /**< Sortinfo offset field of the file header */
unsigned char db_type[5]; /**< Database type field of the file header */
unsigned char create_id[5]; /**< Creator ID field of the file header */
unsigned int unique_seed; /**< Unique seed field of the file header */
unsigned int next_record_list_id; /**< Next record list field of the file header */
unsigned short number_records; /**< Number of records in the file */
struct RecordInfo *record_list; /**< Array of RecordInfo structs for the file's records */
};
#endif
|