home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format 135
/
af135a.adf
/
AmiCheck.lzx
/
AmiCheck
/
Source
/
dataBase.h
< prev
next >
Wrap
C/C++ Source or Header
|
2012-08-17
|
12KB
|
506 lines
#ifndef DATABASE_H
#define DATABASE_H
/************************************************
* dataBase.h
*
* This header defines externals and
* prototypes, etc. for dataBase.c lib.
*
************************************************/
#include <stdio.h>
#include <libraries/guifront.h>
#include <proto/guifront.h>
#include <clib/exec_protos.h>
#define FILESIZE 100
#define MAXMACROS 10
#define FILTERNA 0
#define FILTERYES 1
#define FILTERNO 2
#define FILTERIN 1
#define FILTEROUT 2
#define DEFAULT_TEMPS 4
#define DEFAULT_CATS 1
#define STRINGSIZE 71
#define DATESIZE 12
#define TEMPNAMESIZE 31
#define CATNAMESIZE 31
#define AMNTSIZE 16
#define CHECKSIZE 7
#define CHECKTYPE 0
#define WITHDRAWALTYPE 1
#define DEPOSITTYPE 2
#define SCRIPTTYPE 3
/* flags */
#define PRINTED 0x01
#define CLEARED 0x02
#define VOIDED 0x04
#define RECONCILED 0x08
#define TAXDEDUCT 0x10
/* sort entry defines */
#define SORTENTRIES 6
#define SORTCHECK 0
#define SORTDATE 1
#define SORTAMNT 2
#define SORTNAME 3
#define SORTMEMO 4
#define SORTCATEGORY 5
#define SORTASCEND 0
#define SORTDESCEND 1
/* voucher types */
#define VT_NONE 0
#define VT_LEFTRIGHT 1
#define VT_ABOVEBELOW 2
#define VT_TWOBELOW 3
#define VT_ABOVE 4
#define VT_BELOW 5
#define NUMCHECKFORMS 10
/* date formats */
#define DATE_MMDDYY 0
#define DATE_DDMMYY 1
#define DATE_DEC_12 2
#define DATE_12_DEC 3
/* max decimal places */
#define MAXDECIMAL 4
/* macro for copylist routine */
#define STROFF(nodedef,nodefield) ((UWORD)((char *)( ((nodedef *)0)-> nodefield ) - (char *)( (nodedef *)0)))
/* amount structure */
typedef ULONG amountType;
/* balance type (not to be confused with amount! */
typedef struct {
ULONG dollar; /* not really dollar, but so I can read it clearly */
UWORD cent; /* ditto, normally.. remainder? */
UBYTE neg; /* negative or positive... */
} balanceType;
/* stateVariables */
struct stateVars {
balanceType currAmnt;
balanceType stateAmnt;
UWORD currTemplate;
UWORD currCheckNumber;
};
/* NetInformation */
struct netInfoVars {
balanceType taxdeductcurr;
balanceType taxdeductstate;
balanceType currAmnt;
balanceType stateAmnt;
UBYTE decimal;
};
/* date structure */
typedef struct {
UBYTE day;
UBYTE month;
USHORT year;
} dateType;
typedef struct {
UBYTE line1[STRINGSIZE];
UBYTE line2[STRINGSIZE];
UBYTE line3[STRINGSIZE];
UBYTE line4[STRINGSIZE];
} addressType;
/* arexx macro structure */
typedef struct {
char macroname[20+1];
char macrofile[FILESIZE+1];
} arexxNode;
/* script structure */
typedef struct {
struct Node node;
char scname[TEMPNAMESIZE];
} scriptNode;
/* networth structure */
typedef struct {
struct Node node;
char acname[100];
char actype;
struct netInfoVars balances;
} netNode;
/* a category structure */
typedef struct {
struct Node node;
char catname[CATNAMESIZE];
char color;
char linestyle;
} categoryNode;
/* A budget group structure */
typedef struct {
struct Node node;
char groupname[CATNAMESIZE];
struct List catlist;
} groupNode;
/* a budget item */
typedef struct {
struct Node node;
UBYTE catname[CATNAMESIZE];
amountType amount;
} budgetNode;
/* an item node */
typedef struct {
struct MinNode node;
WORD type;
UWORD check;
char name[STRINGSIZE];
char memo[STRINGSIZE];
dateType date;
amountType amount;
UBYTE flags;
char category[CATNAMESIZE];
#if 0
struct List budgetlist;
addressType address;
#endif
} entryNode;
/* a template structure */
typedef struct {
struct Node node;
char tempname[TEMPNAMESIZE];
entryNode template;
} templateNode;
/* a filter structure */
typedef struct {
struct MinNode node;
entryNode *entry;
long printChars[4];
balanceType runningBal;
balanceType filterBal;
} filterNode;
typedef struct {
/* types */
BOOL checks;
BOOL withdrawals;
BOOL deposits;
/* type state(s) */
UBYTE andflag; /* AND set */
UBYTE notflag; /* NOT set */
/* ranges */
UBYTE checkrange; /* flag ->0, 1=in, 2=out */
UWORD checkfrom;
UWORD checkto;
UBYTE amntrange; /* flag -> 0, 1=in, 2=out */
amountType amountFrom;
amountType amountTo;
UBYTE daterange; /* flag -> 0, 1=in, 2=out */
dateType dateFrom;
dateType dateTo;
/* budget */
UBYTE usecategory; /* flags -> 0, 1=in, 2=out */
UBYTE category[CATNAMESIZE+1];
/* storage */
UBYTE printcode, taxcode, voidcode, reconcilecode, clearcode;
/* fields */
UBYTE usepayee, usememo;
char payee[STRINGSIZE+1], memo[STRINGSIZE+1];
char payeetoken[STRINGSIZE*2 + 2], memotoken[STRINGSIZE*2+2];
} filterSetting;
/* sort structures */
typedef struct {
struct Node node;
char field[STRINGSIZE+1];
UBYTE order;
UBYTE index;
} sortNode;
typedef struct {
BOOL check;
BOOL memo;
BOOL name;
BOOL amnt;
BOOL date;
BOOL category;
} sortState;
/* account global info structure */
typedef struct {
char accnt[STRINGSIZE];
char bank[STRINGSIZE];
char holder[STRINGSIZE];
BOOL negative;
amountType beginAmount;
dateType openDate;
BOOL closed;
dateType closeDate;
UBYTE decimal;
UWORD checknumber;
} accntState;
/* search criteria structure */
typedef struct {
BOOL check;
UWORD checknum;
BOOL memo;
char memostr[STRINGSIZE];
char memostrtoken[STRINGSIZE*2 + 2];
BOOL name;
char namestr[STRINGSIZE];
char namestrtoken[STRINGSIZE*2 + 2];
BOOL amnt;
amountType amount;
BOOL date;
dateType searchdate;
BOOL category;
char catstr[CATNAMESIZE];
char catstrtoken[CATNAMESIZE*2 + 2];
LONG lastrow;
} searchState;
/* special category edit structure */
typedef struct {
categoryNode new;
BOOL oldnode;
categoryNode original;
} editCatNode;
/* report prefs */
typedef struct {
UWORD rows;
UWORD cols;
UWORD style;
BOOL tofile;
BOOL state;
BOOL summary;
BOOL padline;
} reportSetting;
/* quick-dates structure */
typedef struct {
struct Node node;
char dateStr[DATESIZE];
dateType date;
} dateNode;
/* quick-memos structure */
typedef struct {
struct Node node;
char memoStr[STRINGSIZE];
} memoNode;
/* quick-name structure */
typedef struct {
struct Node node;
char nameStr[STRINGSIZE];
} nameNode;
/* quick-amnt structure */
typedef struct {
struct Node node;
char amntStr[STRINGSIZE];
} amntNode;
/* check form structure */
typedef struct {
BOOL sheet_feed;
ULONG lines_check;
ULONG checks_page;
ULONG pay_margin;
ULONG pay_width;
ULONG pay_line;
ULONG date_margin;
ULONG date_width;
ULONG date_line;
ULONG amnt_margin;
ULONG amnt_width;
ULONG amnt_line;
ULONG memo_margin;
ULONG memo_width;
ULONG memo_line;
ULONG voucher_type;
ULONG voucher_margin;
ULONG voucher_width;
ULONG str_margin;
ULONG str_width;
ULONG str_line;
/* new stuff */
ULONG top_lines;
ULONG columns;
ULONG reserved;
} checkForm;
typedef struct {
char device[STRINGSIZE];
checkForm userForm;
checkForm forms[NUMCHECKFORMS];
} formControl;
typedef struct {
ULONG checkNumber;
BOOL autoVoid;
BOOL printVoid;
ULONG checksPage1;
ULONG printMode;
} printControl;
typedef void (*funcptr)();
extern STRPTR fptlabels[];
extern struct TagItem strCheckTags[];
extern struct TagItem strAmntTags[];
extern struct TagItem strDateTags[];
extern struct TagItem strMemoTags[];
extern struct TagItem strNameTags[];
extern struct TagItem strTempTags[];
extern struct TagItem strCatTags[];
extern struct TagItem TxtBorder[];
extern struct TagItem TxtNoBorder[];
extern struct TagItem TxtZero[];
extern struct TagItem TxtInt[];
extern struct TagItem NumBorder[];
extern struct TagItem ListView[];
extern struct TagItem MiscButton[];
extern UWORD decimalModulos[];
extern char easymonths[12][4];
extern char daysinmonth[12];
extern searchState searchControl;
extern struct MinList entries, filtered;
extern struct List templates, testtemps, memolist, datelist, namelist, amntlist;
extern struct List categories, sortfields, grouplist;
extern arexxNode arexxMacros[MAXMACROS];
extern printControl checkPrint;
extern reportSetting reportControl;
extern struct stateVars amntState;
extern balanceType filtAmnt;
extern BOOL amiChangedItems;
extern accntState usrAccount;
extern sortNode sortEntries[SORTENTRIES];
extern sortState sortStates;
extern filterSetting filterControl;
extern dateType currDate;
extern UWORD currCentury;
extern UWORD entryCount;
extern formControl checkForms;
extern UWORD dateFormat;
void DataFreeList(struct List *);
BOOL DataInit(void);
BOOL DataAddTemp(struct List *,templateNode *);
BOOL DataAddCat(struct List *, categoryNode *);
void DataFreeAll(void);
struct Node *DataOrd2Node(struct List *,LONG );
LONG DataNode2Ord(struct List *,char *);
void DataStoreAmnt(amountType *, char *);
void DataBuildAmnt(BOOL, amountType *, char *);
void DataBalConvert(balanceType *, UBYTE, UBYTE);
void DataBalToAmnt(balanceType *, UBYTE *, amountType *);
void DataBuildBal(UBYTE, balanceType *, char *);
void DataInitBal(UBYTE, amountType *, balanceType *);
void DataAddBal(UBYTE , amountType *, balanceType *);
void DataBalAddBal(UBYTE decimal,balanceType *dest,balanceType *bal1, balanceType *bal2);
int DataCmpBal(BOOL, balanceType *, balanceType *);
int DataCmpAmntBal(amountType *amnt, balanceType *bal);
void DataCopyGroupList(struct List *, struct List *);
void DataMoveList(struct List *, struct List *);
BOOL DataIsUnique(GUIFront *gui, struct List *, char *, BOOL,char *);
BOOL DataVerifyAmnt(char *, char *);
BOOL DataVerifyDate(char *, char *);
void DataStoreDate(dateType *, char *);
void DataBuildDate(dateType *, char *);
void DataAnnounce(GUIFront *gui, char *);
void DataAnnounceDate(GUIFront *gui);
void DataAnnounceAmount(GUIFront *gui);
int DataQuery(GUIFront *gui, char*, char *);
BOOL DataAddEntry(entryNode *, struct MinList *, filterNode **);
BOOL DataInsertEntry(filterNode *,entryNode *,entryNode *, struct MinList *, filterNode **, entryNode **);
BOOL DataAddFilter(filterNode **, entryNode *, struct MinList *);
BOOL DataInsertFilter(filterNode *,filterNode **, entryNode *, struct MinList *);
void DataBuildRegDate(dateType *, char *);
BOOL DataTestFilter(entryNode *, filterSetting *);
void DataListInit(void);
void DataRemoveEntry(entryNode *, filterNode *);
void DataRemoveFilter(filterNode *);
void DataRemoveEntryFilter(entryNode *);
void DataUpdateBal(UBYTE, amountType *, balanceType *, char *);
void DataRebuildFilters(void);
void DataSitNSpin(struct Gadget *, struct Window *);
void DataMoveSort(struct List *, sortNode *, struct List *, sortNode *);
balanceType DataReconcile(BOOL);
void DataSortFilter(filterNode *, filterNode *, sortNode *);
void DataCopyCatList(struct List *, struct List *);
editCatNode *DataNewEditCat(struct List *, categoryNode *);
void DataMoveCatList(struct List *);
WORD DataSearchFilter(struct MinList *, searchState *);
BOOL DataLoadFile(char *);
BOOL DataSaveFile(char *, BOOL);
WORD DataFindNode(struct List *,struct Node *);
BOOL DataGetFileName(char *,short , char *, char *);
void DataAttachIcon(char*, char *, char *);
balanceType DataRunningBals(struct MinList *, struct MinList *);
balanceType DataBalance(UBYTE, struct MinList *);
BOOL DataSummarize(char *, netNode *);
void DataFilterBalance(struct MinList *);
void DataUpdateFilters(struct MinList *);
struct Node *DataFindName(struct List *,char *);
struct Node *DataGetNext(struct List *, struct Node *);
void DataListUp(GUIFront *gui, struct Gadget *listgad, struct List *list, UWORD *listsel);
void DataListDown(GUIFront *gui, struct Gadget *listgad, struct List *list, UWORD *listsel);
void DataListBottom(GUIFront *gui, struct Gadget *listgad,
struct List *list, UWORD *listsel, UWORD entries);
void DataListTop(GUIFront *gui, struct Gadget *listgad,
struct List *list, UWORD *listsel, UWORD topmargin);
void DataListRemove(GUIFront *gui, struct Gadget *listgad,
struct List *list, UWORD *listsel);
UWORD DataCountNodes(struct List *);
groupNode *DataNewGroup(struct List *gl, groupNode *grp);
void DataFreeGroupCats(struct List *gl);
void DataReplaceGroupCats(struct List *grps, struct List *new);
void DataCopyList(struct List *src, struct List *dest, funcptr func);
void DataCopyGroupList(struct List *src, struct List *dest);
#endif