Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

aqbanking / src / libs / aqbanking / backendsupport / swiftdescr.xml @ eb50ded7

History | View | Annotate | Download (18.1 KB)

1
<?xml?>
2

    
3
<tm2>
4
  <type id="AB_SWIFT_DESCR" type="pointer">
5
    <descr>
6
      This class holds a SWIFT document descriptor like "pain.001.002.03".
7
      Such a descriptor can be parsed into an object of this class via AB_SwiftDescr_FromString(). The element of the
8
      string given above will go into the following fields:
9
      pain -&gt; family
10
      001 -&gt; version1
11
      002 -&gt; version2
12
      03 -&gt; version3
13
    </descr>
14

    
15
    <lang id="c">
16
      <identifier>AB_SWIFT_DESCR</identifier>
17
      <prefix>AB_SwiftDescr</prefix>
18
      
19
      <baseFileName>swiftdescr</baseFileName>
20
      
21
      <flags>
22
        with_db
23
        with_xml
24
        with_refcount
25
        with_list1
26
      </flags>
27
      
28
      <headers>
29
        <header type="sys" loc="pre">aqbanking/error.h</header>
30
        <header type="sys" loc="pre">gwenhywfar/types.h</header>
31
        <header type="sys" loc="pre">gwenhywfar/text.h</header>
32
        <header type="sys" loc="pre">gwenhywfar/stringlist.h</header>
33
        <header type="sys" loc="pre">ctype.h</header>
34
      </headers>
35

    
36

    
37

    
38
      <inlines>
39

    
40
        <inline loc="end" access="public">
41
          <typeFlagsMask>with_list2</typeFlagsMask>
42
          <typeFlagsValue>with_list2</typeFlagsValue>
43
          <content>
44
             $(api) int $(struct_prefix)_List2_freeAll($(struct_type)_LIST2 *tl);
45
          </content>
46
        </inline>
47

    
48
        <inline loc="code">
49
          <typeFlagsMask>with_list2</typeFlagsMask>
50
          <typeFlagsValue>with_list2</typeFlagsValue>
51
          <content>
52
             static $(struct_type) *$(struct_prefix)_List2__freeAll_cb($(struct_type) *t, void *user_data) {
53
               $(struct_prefix)_free(t);
54
               return NULL;
55
             }
56

    
57

    
58
             int $(struct_prefix)_List2_freeAll($(struct_type)_LIST2 *tl) {
59
               if (tl) {
60
                 $(struct_prefix)_List2_ForEach(tl, $(struct_prefix)_List2__freeAll_cb, NULL);
61
                 $(struct_prefix)_List2_free(tl); 
62
               }
63
               else {
64
                 DBG_ERROR(AQBANKING_LOGDOMAIN, "List missing");
65
                 return GWEN_ERROR_INVALID;
66
               }
67
               return 0;
68
             }
69
          </content>
70
        </inline>
71

    
72

    
73

    
74
        <inline loc="end" access="public">
75
          <typeFlagsMask></typeFlagsMask>
76
          <typeFlagsValue></typeFlagsValue>
77
          <content>
78
             /** \n
79
              * Check whether a given SWIFT descriptor matches the given criteria.                          \n
80
              * @param a descriptor to match against                                                        \n
81
              * @param wantedFamily descriptor family, e.g. "pain" or "camt" (wildcards and jokers allowed) \n
82
              * @param wantedVersion1 first part of the version to match (0 matches all)                    \n
83
              * @param wantedVersion2 second part of the version to match (0 matches all)                   \n
84
              * @param wantedVersion3 third part of the version to match (0 matches all)                    \n
85
              */                                                                                            \n
86
             $(api) int $(struct_prefix)_Matches(const $(struct_type) *a,
87
                                                 const char *wantedFamily,
88
                                                 int wantedVersion1,
89
                                                 int wantedVersion2,
90
                                                 int wantedVersion3);
91
          </content>
92
        </inline>
93

    
94
        <inline loc="code">
95
          <typeFlagsMask></typeFlagsMask>
96
          <typeFlagsValue></typeFlagsValue>
97
          <content>
98
             int $(struct_prefix)_Matches(const $(struct_type) *d,
99
                                          const char *wantedFamily,
100
                                          int wantedVersion1,
101
                                          int wantedVersion2,
102
                                          int wantedVersion3) {
103
               const char *family;
104
               int version1;
105
               int version2;
106
               int version3;
107
  
108
               if (!wantedFamily)
109
                 wantedFamily="*";
110

    
111
               family=$(struct_prefix)_GetFamily(d);
112
               version1=$(struct_prefix)_GetVersion1(d);
113
               version2=$(struct_prefix)_GetVersion2(d);
114
               version3=$(struct_prefix)_GetVersion3(d);
115

    
116
               if (family==NULL)
117
                 family="";
118

    
119
               if ((-1!=GWEN_Text_ComparePattern(family, wantedFamily, 0)) &amp;&amp;
120
                   (wantedVersion1==0 || version1==wantedVersion1) &amp;&amp;
121
                   (wantedVersion2==0 || version2==wantedVersion2) &amp;&amp;
122
                   (wantedVersion3==0 || version3==wantedVersion3))
123
                 return 1;
124
               return 0;
125
             }
126
          </content>
127
        </inline>
128

    
129

    
130

    
131
        <inline loc="end" access="private">
132
          <typeFlagsMask>with_list1</typeFlagsMask>
133
          <typeFlagsValue>with_list1</typeFlagsValue>
134
          <content>
135
             /** \n
136
              * Find a SWIFT descriptor in a list by given criteria.                                        \n
137
              * @param a descriptor object with which to start searching                                    \n
138
              * @param wantedFamily descriptor family, e.g. "pain" or "camt" (wildcards and jokers allowed) \n
139
              * @param wantedVersion1 first part of the version to match (0 matches all)                    \n
140
              * @param wantedVersion2 second part of the version to match (0 matches all)                   \n
141
              * @param wantedVersion3 third part of the version to match (0 matches all)                    \n
142
              */                                                                                            \n
143
             $(struct_type) *$(struct_prefix)_List__FindInternal($(struct_type) *d,
144
                                                                 const char *wantedFamily,
145
                                                                 int wantedVersion1,
146
                                                                 int wantedVersion2,
147
                                                                 int wantedVersion3);
148
          </content>
149
        </inline>
150

    
151

    
152

    
153
        <inline loc="code">
154
          <typeFlagsMask>with_list1</typeFlagsMask>
155
          <typeFlagsValue>with_list1</typeFlagsValue>
156
          <content>
157
             $(struct_type) *$(struct_prefix)_List__FindInternal($(struct_type) *d,
158
                                                                 const char *wantedFamily,
159
                                                                 int wantedVersion1,
160
                                                                 int wantedVersion2,
161
                                                                 int wantedVersion3){
162
               if (!wantedFamily)
163
                 wantedFamily="*";
164
             
165
               while(d) {
166
                 if (1==$(struct_prefix)_Matches(d, wantedFamily, wantedVersion1, wantedVersion2, wantedVersion3))
167
                   break;
168
                 d=$(struct_prefix)_List_Next(d);
169
               } /* while */
170
             
171
               return d;
172
             }
173
          </content>
174
        </inline>
175

    
176

    
177

    
178
        <inline loc="end" access="public">
179
          <typeFlagsMask>with_list1</typeFlagsMask>
180
          <typeFlagsValue>with_list1</typeFlagsValue>
181
          <content>
182
             /** \n
183
              * Find first SWIFT descriptor in a list by given criteria.                                    \n
184
              * @param dl list of descriptors to search in                                                  \n
185
              * @param wantedFamily descriptor family, e.g. "pain" or "camt" (wildcards and jokers allowed) \n
186
              * @param wantedVersion1 first part of the version to match (0 matches all)                    \n
187
              * @param wantedVersion2 second part of the version to match (0 matches all)                   \n
188
              * @param wantedVersion3 third part of the version to match (0 matches all)                    \n
189
              */                                                                                            \n
190
             $(api) $(struct_type) *$(struct_prefix)_List_FindFirst(const $(struct_type)_LIST *dl, 
191
                                                                    const char *wantedFamily,
192
                                                                    int wantedVersion1, int wantedVersion2, int wantedVersion3);
193
          </content>
194
        </inline>
195

    
196
        <inline loc="code">
197
          <typeFlagsMask>with_list1</typeFlagsMask>
198
          <typeFlagsValue>with_list1</typeFlagsValue>
199
          <content>
200
             $(struct_type) *$(struct_prefix)_List_FindFirst(const $(struct_type)_LIST *dl, 
201
                                                             const char *wantedFamily,
202
                                                             int wantedVersion1, int wantedVersion2, int wantedVersion3) {
203
               $(struct_type) *d;
204
             
205
               if ($(struct_prefix)_List_GetCount(dl)==0) {
206
                 DBG_INFO(AQBANKING_LOGDOMAIN, "empty list");
207
                 return NULL;
208
               }
209
               d=$(struct_prefix)_List_First(dl);
210
               assert(d);
211

    
212
               return $(struct_prefix)_List__FindInternal(d, wantedFamily, wantedVersion1, wantedVersion2, wantedVersion3);
213
             }
214
          </content>
215
        </inline>
216

    
217

    
218
        <inline loc="end" access="public">
219
          <typeFlagsMask>with_list1</typeFlagsMask>
220
          <typeFlagsValue>with_list1</typeFlagsValue>
221
          <content>
222
             /** \n
223
              * Find next SWIFT descriptor in a list by given criteria.                                     \n
224
              * @param d last descriptor checked (i.e. search in the following descriptors)                 \n
225
              * @param wantedFamily descriptor family, e.g. "pain" or "camt" (wildcards and jokers allowed) \n
226
              * @param wantedVersion1 first part of the version to match (0 matches all)                    \n
227
              * @param wantedVersion2 second part of the version to match (0 matches all)                   \n
228
              * @param wantedVersion3 third part of the version to match (0 matches all)                    \n
229
              */                                                                                            \n
230
             $(api) $(struct_type) *$(struct_prefix)_List_FindNext($(struct_type) *d, 
231
                                                                   const char *wantedFamily,
232
                                                                   int wantedVersion1, int wantedVersion2, int wantedVersion3);
233
          </content>
234
        </inline>
235

    
236
        <inline loc="code">
237
          <typeFlagsMask>with_list1</typeFlagsMask>
238
          <typeFlagsValue>with_list1</typeFlagsValue>
239
          <content>
240
             $(struct_type) *$(struct_prefix)_List_FindNext($(struct_type) *d, 
241
                                                            const char *wantedFamily,
242
                                                            int wantedVersion1, int wantedVersion2, int wantedVersion3){
243
               assert(d);
244
               d=$(struct_prefix)_List_Next(d);
245
               if (d==NULL) {
246
                 DBG_INFO(AQBANKING_LOGDOMAIN, "No more entries in list");
247
                 return NULL;
248
               }
249
               return $(struct_prefix)_List__FindInternal(d, wantedFamily, wantedVersion1, wantedVersion2, wantedVersion3);
250
             }
251
          </content>
252
        </inline>
253

    
254

    
255
        <inline loc="end" access="public">
256
          <content>
257
             /** \n
258
             * Create a SWIFT descriptor from a given string. \n
259
             *
260
             * Example strings are "pain.001.002.03" or "camt_054_001_02". \n
261
             * @return created descriptor (NULL for invalid string) \n
262
             */ \n
263
             $(api) $(struct_type) *$(struct_prefix)_FromString(const char *s);
264
          </content>
265
        </inline>
266

    
267

    
268
        <inline loc="code" access="public">
269
          <content>
270
             $(struct_type) *$(struct_prefix)_FromString(const char *inputName) {
271
               GWEN_STRINGLIST *slist;
272
               int count;
273
             
274
               /* add delimiters here if needed */
275
               slist=GWEN_StringList_fromString(inputName, ":._- \\t", 0);
276
               if (slist==NULL) {
277
                 DBG_ERROR(AQBANKING_LOGDOMAIN, "Could not parse string [%s] into list", inputName);
278
                 return NULL;
279
               }
280

    
281
               count=GWEN_StringList_Count(slist);
282
               if (count&gt;2) {
283
                 int i;
284
                 
285
                 for (i=count-1; i&gt;=0; i--) {
286
                   const char *s;
287
                   
288
                   s=GWEN_StringList_StringAt(slist, i);
289
                   DBG_DEBUG(AQBANKING_LOGDOMAIN, "Handling string[%d of %d]: \"%s\"", i, count, s?s:"&lt;empty&gt;");
290
                   if (s &amp;&amp; (strcasecmp(s, "camt")==0 || strcasecmp(s, "pain")==0)) {
291
                     if ((count-i)&lt;4) {
292
                       DBG_INFO(AQBANKING_LOGDOMAIN, "Too few entries left in string list (source: [%s])", inputName);
293
                       break;
294
                     }
295
                     else {
296
                       const char *family;
297
                       int version1;
298
                       int version2;
299
                       int version3;
300
                       $(struct_type) *d;
301
                       
302
                       family=s;
303
                       i++;
304
                       
305
                       s=GWEN_StringList_StringAt(slist, i);
306
                       if (!(s &amp;&amp; *s &amp;&amp; 1==sscanf(s, "%d", &amp;version1))) {
307
                         DBG_ERROR(AQBANKING_LOGDOMAIN, "No valid string for version1 [%s] ", s?s:"&lt;empty&gt;");
308
                         GWEN_StringList_free(slist);
309
                         return NULL;
310
                       }
311
                       i++;
312

    
313
                       s=GWEN_StringList_StringAt(slist, i);
314
                       if (!(s &amp;&amp; *s &amp;&amp; 1==sscanf(s, "%d", &amp;version2))) {
315
                         DBG_ERROR(AQBANKING_LOGDOMAIN, "No valid string for version2 [%s] ", s?s:"&lt;empty&gt;");
316
                         GWEN_StringList_free(slist);
317
                         return NULL;
318
                       }
319
                       i++;
320

    
321
                       s=GWEN_StringList_StringAt(slist, i);
322
                       if (!(s &amp;&amp; *s &amp;&amp; 1==sscanf(s, "%d", &amp;version3))) {
323
                         DBG_ERROR(AQBANKING_LOGDOMAIN, "No valid string for version3 [%s] ", s?s:"&lt;empty&gt;");
324
                         GWEN_StringList_free(slist);
325
                         return NULL;
326
                       }
327
                       i++;
328

    
329
                       DBG_INFO(AQBANKING_LOGDOMAIN, "Creating descriptor %s.%03d.%03d.%02d",
330
                                family?family:"&lt;empty&gt;", version1, version2, version3);
331
                       d=$(struct_prefix)_new();
332
                       $(struct_prefix)_SetFamily(d, family);
333
                       $(struct_prefix)_SetVersion1(d, version1);
334
                       $(struct_prefix)_SetVersion2(d, version2);
335
                       $(struct_prefix)_SetVersion3(d, version3);
336
                       GWEN_StringList_free(slist);
337
                       return d;
338
                     }
339
                   } /* if camt or pain */
340
                 } /* for */  
341
                 
342
               } /* if enough entries in string list to be a valid descriptor */
343
               else {
344
                 DBG_INFO(AQBANKING_LOGDOMAIN, "Too few entries in string list (source: [%s])", inputName);
345
               }
346
               
347
               GWEN_StringList_free(slist);
348
               return NULL;
349
             }
350
          </content>
351
        </inline>
352

    
353

    
354
      </inlines>
355

    
356

    
357
    </lang>
358

    
359
    <enums>
360

    
361
    </enums>
362

    
363
    <defines>
364

    
365
    </defines>
366

    
367

    
368
    <members>
369

    
370
      <member name="family" type="char_ptr" maxlen="32" >
371
        <descr>
372
          Family of descriptors (e.g. "pain" in "pain.001.001.03")
373
        </descr>
374
        <access>public</access>
375
        <flags>own with_hash</flags>
376
        <setflags>const dup</setflags>
377
        <getflags>const</getflags>
378
      </member>
379

    
380

    
381
      <member name="version1" type="int" maxlen="4">
382
        <descr>
383
          First part of the version (i.e. the "001" in "pain.001.002.03")
384
        </descr>
385
        <default>0</default>
386
        <preset>0</preset>
387
        <access>public</access>
388
        <flags>with_hash</flags>
389
      </member>
390

    
391

    
392
      <member name="version2" type="int" maxlen="4">
393
        <descr>
394
          Second part of the version (i.e. the "002" in "pain.001.002.03")
395
        </descr>
396
        <default>0</default>
397
        <preset>0</preset>
398
        <access>public</access>
399
        <flags>with_hash</flags>
400
      </member>
401

    
402

    
403
      <member name="version3" type="int" maxlen="4">
404
        <descr>
405
          Second part of the version (i.e. the "03" in "pain.001.002.03")
406
        </descr>
407
        <default>0</default>
408
        <preset>0</preset>
409
        <access>public</access>
410
        <flags>with_hash</flags>
411
      </member>
412

    
413
      <member name="alias1" type="char_ptr" maxlen="32" >
414
        <descr>
415
          Alias string for the given descriptor. This can be used to store additional names with descriptor
416
          (e.g. when searching for a special descriptor by a given name you can store the name of the originally
417
          searched name here).
418
        </descr>
419
        <access>public</access>
420
        <flags>own with_hash with_getbyname</flags>
421
        <setflags>const dup</setflags>
422
        <getflags>const</getflags>
423
      </member>
424

    
425
      <member name="alias2" type="char_ptr" maxlen="32" >
426
        <descr>
427
          Another alias string for the given descriptor. This can be used to store additional names with descriptor
428
          (e.g. when searching for a special descriptor by a given name you can store the name of the originally
429
          searched name here).
430
        </descr>
431
        <access>public</access>
432
        <flags>own with_hash with_getbyname</flags>
433
        <setflags>const dup</setflags>
434
        <getflags>const</getflags>
435
      </member>
436

    
437

    
438
    </members>
439

    
440
    
441
  </type>
442
  
443
</tm2>
444