Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

aqbanking / src / libs / plugins / imexporters / camt / camt.c @ f4a16f5b

History | View | Annotate | Download (2.98 KB)

1
/***************************************************************************
2
    begin       : Sat Dec 15 2018
3
    copyright   : (C) 2018 by Martin Preuss
4
    email       : martin@libchipcard.de
5

6
 ***************************************************************************
7
 *          Please see toplevel file COPYING for license details           *
8
 ***************************************************************************/
9

    
10
#ifdef HAVE_CONFIG_H
11
# include <config.h>
12
#endif
13

    
14

    
15
#include "camt_p.h"
16

    
17

    
18
#include "i18n_l.h"
19
#include <aqbanking/banking.h>
20
#include <gwenhywfar/debug.h>
21
#include <gwenhywfar/misc.h>
22
#include <gwenhywfar/gui.h>
23
#include <gwenhywfar/inherit.h>
24
#include <gwenhywfar/gwendate.h>
25
#include <gwenhywfar/gwentime.h>
26
#include <gwenhywfar/text.h>
27

    
28
#include <ctype.h>
29

    
30

    
31

    
32

    
33
GWEN_INHERIT(AB_IMEXPORTER, AH_IMEXPORTER_CAMT);
34

    
35

    
36

    
37
AB_IMEXPORTER *AB_ImExporterCAMT_new(AB_BANKING *ab){
38
  AB_IMEXPORTER *ie;
39
  AH_IMEXPORTER_CAMT *ieh;
40

    
41
  ie=AB_ImExporter_new(ab, "camt");
42
  GWEN_NEW_OBJECT(AH_IMEXPORTER_CAMT, ieh);
43
  GWEN_INHERIT_SETDATA(AB_IMEXPORTER, AH_IMEXPORTER_CAMT, ie, ieh, AH_ImExporterCAMT_FreeData);
44

    
45
  AB_ImExporter_SetImportFn(ie, AH_ImExporterCAMT_Import);
46
  AB_ImExporter_SetExportFn(ie, AH_ImExporterCAMT_Export);
47
  AB_ImExporter_SetCheckFileFn(ie, AH_ImExporterCAMT_CheckFile);
48
  return ie;
49
}
50

    
51

    
52

    
53
void GWENHYWFAR_CB AH_ImExporterCAMT_FreeData(void *bp, void *p){
54
  AH_IMEXPORTER_CAMT *ieh;
55

    
56
  ieh=(AH_IMEXPORTER_CAMT*)p;
57
  GWEN_FREE_OBJECT(ieh);
58
}
59

    
60

    
61

    
62
int AH_ImExporterCAMT_Import(AB_IMEXPORTER *ie,
63
                             AB_IMEXPORTER_CONTEXT *ctx,
64
                             GWEN_SYNCIO *sio,
65
                             GWEN_DB_NODE *params) {
66
  int rv;
67
  GWEN_XMLNODE *xmlRoot;
68
  GWEN_XMLNODE *n;
69
  GWEN_XML_CONTEXT *xmlCtx;
70
  const char *camVersionWanted;
71

    
72
  /* read whole document into XML tree */
73
  xmlRoot=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "camt52");
74
  xmlCtx=GWEN_XmlCtxStore_new(xmlRoot, GWEN_XML_FLAGS_DEFAULT);
75
  rv=GWEN_XMLContext_ReadFromIo(xmlCtx, sio);
76
  if (rv<0) {
77
    GWEN_XmlCtx_free(xmlCtx);
78
    GWEN_XMLNode_free(xmlRoot);
79
    return rv;
80
  }
81
  GWEN_XmlCtx_free(xmlCtx);
82

    
83
  n=GWEN_XMLNode_FindFirstTag(xmlRoot, "Document", NULL, NULL);
84
  if (n==NULL) {
85
    DBG_ERROR(AQBANKING_LOGDOMAIN, "<Document> element not found");
86
    GWEN_XMLNode_free(xmlRoot);
87
    return GWEN_ERROR_BAD_DATA;
88
  }
89

    
90
  /* debug */
91
  GWEN_XMLNode_Dump(n, 2);
92

    
93
  /* check document type */
94
  camVersionWanted=GWEN_DB_GetCharValue(params, "type", 0, "052.001.02");
95
  assert(camVersionWanted);
96

    
97
  if (strcasecmp(camVersionWanted, "052.001.02")==0)
98
    rv=AH_ImExporterCAMT_Import_052_001_02(ie, ctx, params, n);
99
  else
100
    rv=0;
101

    
102
  GWEN_XMLNode_free(xmlRoot);
103
  return rv;
104
}
105

    
106

    
107

    
108
int AH_ImExporterCAMT_Export(AB_IMEXPORTER *ie,
109
                             AB_IMEXPORTER_CONTEXT *ctx,
110
                             GWEN_SYNCIO *sio,
111
                             GWEN_DB_NODE *params) {
112
  return GWEN_ERROR_NOT_SUPPORTED;
113
}
114

    
115

    
116

    
117
int AH_ImExporterCAMT_CheckFile(AB_IMEXPORTER *ie, const char *fname) {
118
  return 0;
119
}
120

    
121

    
122

    
123

    
124
#include "camt52_001_02.c"
125

    
126

    
127

    
128