|
GnuCash 2.4.99
|
00001 /* qif-import-p.h -- a QIF Importer module (private headers) 00002 * 00003 * Written By: Derek Atkins <derek@ihtfp.com> 00004 * Copyright (c) 2003 Derek Atkins <warlord@MIT.EDU> 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License as 00008 * published by the Free Software Foundation; either version 2 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, contact: 00018 * 00019 * Free Software Foundation Voice: +1-617-542-5942 00020 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 00021 * Boston, MA 02110-1301, USA gnu@gnu.org 00022 */ 00023 00024 #ifndef QIF_IMPORT_P_H 00025 #define QIF_IMPORT_P_H 00026 00027 #include "qif-import.h" 00028 #include "qif-objects.h" 00029 #include "qif-parse.h" 00030 #include "qif-file.h" 00031 00032 #include <stdio.h> 00033 00034 struct _QifHandler 00035 { 00036 void (*init)(QifContext ctx); 00037 QifError (*parse_record)(QifContext ctx, GList *record); 00038 QifError (*end)(QifContext ctx); 00039 }; 00040 00041 struct _QifContext 00042 { 00043 /* The parent context */ 00044 QifContext parent; 00045 00046 /* file information */ 00047 char * filename; 00048 FILE * fp; 00049 gint lineno; 00050 00051 /* This describes what we are parsing right now */ 00052 QifType parse_type; 00053 QifHandler handler; 00054 gpointer parse_state; 00055 00056 /* A bunch of flags for the current handler */ 00057 gint parse_flags; 00058 gboolean parsed; 00059 00060 /* The current and "opening balance" account */ 00061 QifAccount current_acct; 00062 QifAccount opening_bal_acct; 00063 00064 /* HashTable of Maps of data objects */ 00065 GHashTable * object_maps; 00066 00067 /* HashTable of Lists of data objects */ 00068 GHashTable * object_lists; 00069 00070 /* List of files */ 00071 GList *files; 00072 }; 00073 00074 /* Object Maps */ 00075 gint qif_object_map_count(QifContext ctx, const char *type); 00076 void qif_object_map_foreach(QifContext ctx, const char *type, 00077 GHFunc func, gpointer arg); 00078 void qif_object_map_insert(QifContext ctx, const char *key, QifObject obj); 00079 void qif_object_map_remove(QifContext ctx, const char *type, const char *key); 00080 QifObject qif_object_map_lookup(QifContext ctx, const char *type, const char *key); 00081 void qif_object_map_destroy(QifContext ctx); 00082 /* GList _SHOULD_ be freed by the caller */ 00083 GList * qif_object_map_get(QifContext ctx, const char *type); 00084 00085 /* Object Lists */ 00086 void qif_object_list_reverse(QifContext ctx, const char *type); 00087 gint qif_object_list_count(QifContext ctx, const char *type); 00088 void qif_object_list_foreach(QifContext ctx, const char *type, 00089 GFunc func, gpointer arg); 00090 void qif_object_list_insert(QifContext ctx, QifObject obj); 00091 void qif_object_list_remove(QifContext ctx, QifObject obj); 00092 void qif_object_list_destroy(QifContext ctx); 00093 /* GList should NOT be freed by the caller */ 00094 GList *qif_object_list_get(QifContext ctx, const char *type); 00095 00096 /* Set and clear flags in bit-flags */ 00097 #define qif_set_flag(i,f) (i |= f) 00098 #define qif_clear_flag(i,f) (i &= ~f) 00099 00100 #endif /* QIF_IMPORT_P_H */
1.7.4