GnuCash 2.4.99
qif-import.h
00001 /*
00002  * qif-import.h -- a QIF Import module
00003  *
00004  * Written By:  Derek Atkins <derek@ihtfp.com>
00005  * Copyright (c) 2003 Derek Atkins <warlord@MIT.EDU>
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as
00009  * published by the Free Software Foundation; either version 2 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, contact:
00019  *
00020  * Free Software Foundation           Voice:  +1-617-542-5942
00021  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
00022  * Boston, MA  02110-1301,  USA       gnu@gnu.org
00023  */
00024 
00025 #ifndef QIF_IMPORT_H
00026 #define QIF_IMPORT_H
00027 
00028 #include <stdio.h>
00029 #include "qof.h"
00030 
00031 typedef enum
00032 {
00033     QIF_TYPE_BANK = 1,
00034     QIF_TYPE_CASH,
00035     QIF_TYPE_CCARD,
00036     QIF_TYPE_INVST,
00037     QIF_TYPE_PORT,
00038     QIF_TYPE_OTH_A,
00039     QIF_TYPE_OTH_L,
00040     QIF_TYPE_CLASS,
00041     QIF_TYPE_CAT,
00042     QIF_TYPE_SECURITY,
00043     QIF_ACCOUNT,
00044     QIF_AUTOSWITCH,
00045     QIF_CLEAR_AUTOSWITCH
00046 } QifType;
00047 
00048 /* Make sure this patches */
00049 #define QIF_TYPE_MAX QIF_CLEAR_AUTOSWITCH
00050 
00051 typedef struct _QifHandler *QifHandler;
00052 typedef struct _QifContext *QifContext;
00053 typedef struct _QifLine *QifLine;
00054 
00055 /* Qif Flags */
00056 #define QIF_F_IGNORE_ACCOUNTS   (1 << 0)
00057 #define QIF_F_TXN_NEEDS_ACCT    (1 << 1)
00058 #define QIF_F_ITXN_NEEDS_ACCT   (1 << 2)
00059 
00060 /* Qif Reconciled Flag */
00061 typedef enum
00062 {
00063     QIF_R_NO = 0,
00064     QIF_R_CLEARED,
00065     QIF_R_RECONCILED,
00066     QIF_R_BUDGETED,
00067 } QifRecnFlag;
00068 
00069 /* Qif Errors */
00070 
00071 typedef enum
00072 {
00073     QIF_E_OK = 0,
00074     QIF_E_INTERNAL,
00075     QIF_E_BADSTATE,
00076     QIF_E_BADARGS,
00077     QIF_E_NOFILE,
00078 } QifError;
00079 
00080 
00081 /* Qif (investment?) Actions */
00082 typedef enum
00083 {
00084     QIF_A_NONE = 0,
00085     QIF_A_BUY,
00086     QIF_A_BUYX,
00087     QIF_A_CGLONG,
00088     QIF_A_CGLONGX,
00089     QIF_A_CGMID,
00090     QIF_A_CGMIDX,
00091     QIF_A_CGSHORT,
00092     QIF_A_CGSHORTX,
00093     QIF_A_DIV,
00094     QIF_A_DIVX,
00095     QIF_A_EXERCISE,
00096     QIF_A_EXERCISEX,
00097     QIF_A_EXPIRE,
00098     QIF_A_GRANT,
00099     QIF_A_INTINC,
00100     QIF_A_INTINCX,
00101     QIF_A_MARGINT,
00102     QIF_A_MARGINTX,
00103     QIF_A_MISCEXP,
00104     QIF_A_MISCEXPX,
00105     QIF_A_MISCINC,
00106     QIF_A_MISCINCX,
00107     QIF_A_REINVDIV,
00108     QIF_A_REINVINT,
00109     QIF_A_REINVLG,
00110     QIF_A_REINVMD,
00111     QIF_A_REINVSG,
00112     QIF_A_REINVSH,
00113     QIF_A_REMINDER,
00114     QIF_A_RTRNCAP,
00115     QIF_A_RTRNCAPX,
00116     QIF_A_SELL,
00117     QIF_A_SELLX,
00118     QIF_A_SHRSIN,
00119     QIF_A_SHRSOUT,
00120     QIF_A_STKSPLIT,
00121     QIF_A_VEST,
00122     QIF_A_XIN,
00123     QIF_A_XOUT,
00124 } QifAction;
00125 
00126 /* Public API Functions */
00127 
00128 /* Create a QIF Import Context */
00129 QifContext qif_context_new(void);
00130 void qif_context_destroy(QifContext ctx);
00131 
00132 /* Open and read a QIF File.  You must pass in the parent
00133  * context; it will return the child (file) context
00134  */
00135 QifContext qif_file_new(QifContext ctx, const char* filename);
00136 
00137 /* Does a qif-file need a default QIF account? */
00138 gboolean qif_file_needs_account(QifContext ctx);
00139 
00140 /* Return the filename of the QIF file */
00141 const char * qif_file_filename(QifContext ctx);
00142 
00143 /* Provide a default QIF Account for the QIF File */
00144 void qif_file_set_default_account(QifContext ctx, const char *acct_name);
00145 
00146 /* Parse the QIF File */
00147 QifError qif_file_parse(QifContext ctx, gpointer ui_arg);
00148 
00149 /* Merge all the qif-files from the children and into the context */
00150 void qif_parse_merge_files(QifContext ctx);
00151 
00152 /* Obtain the list of USED QifAccounts and QifCategories.  Finds all
00153  * references from the transactions in the QifContext.  The returned
00154  * GList must be freed by the caller.
00155  */
00156 GList *qif_context_get_accounts(QifContext ctx);
00157 GList *qif_context_get_categories(QifContext ctx);
00158 
00159 #endif /* QIF_IMPORT_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines