File: tutorial1.c

package info (click to toggle)
libaqbanking 2.2.3-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 14,912 kB
  • ctags: 6,430
  • sloc: ansic: 59,251; cpp: 17,347; sh: 8,930; xml: 6,189; makefile: 3,326; python: 2,806; pascal: 559; perl: 267
file content (84 lines) | stat: -rw-r--r-- 3,205 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/***************************************************************************
 $RCSfile$
 -------------------
 cvs         : $Id: tutorial1.c 1013 2006-05-12 06:59:56Z martin $
 begin       : Tue May 03 2005
 copyright   : (C) 2005 by Martin Preuss
 email       : martin@libchipcard.de

 ***************************************************************************
 *          Please see toplevel file COPYING for license details           *
 ***************************************************************************/


/***************************************************************************
 * This tutorial simply creates an instance of AqBanking, initializes and  *
 * deinitializes it.                                                       *
 *                                                                         *
 * You must either choose a frontend to be used with AqBanking or create   *
 * one yourself by implementing the user interface callbacks of AqBanking. *
 *                                                                         *
 * However, for simplicity reasons we use the console frontend CBanking    *
 * which implements these callbacks for you.                               *
 *                                                                         *
 * There are other frontends, e.g. G2Banking for GTK2/Gnome, QBanking for  *
 * QT3 or KDE3 or KBanking for KDE3.                                       *
 ***************************************************************************/


#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <cbanking/cbanking.h>



int main(int argc, char **argv) {
  AB_BANKING *ab;
  int rv;

  /* The first argument is the name of the application. This is needed for
   * AqBanking to internally store some application-specific settings.
   * This name may contain whatever characters you like, it is escaped
   * internally before creating file paths or DB groups from it.
   *
   * The second argument is the folder in which the AqBanking settings are
   * stored. You should in most cases provide NULL here which makes AqBanking
   * choose the default path ($HOME/.banking).
   * If this folder doesn't exist it will be created as soon as AqBanking has
   * something to store (in most cases when closing the application).
   */
  ab=CBanking_new("tutorial1", 0);

  /* This function initializes AqBanking. It is only after successfull return
   * from this function that any other AqBanking function may be used.
   */
  rv=AB_Banking_Init(ab);
  if (rv) {
    fprintf(stderr, "Error on init (%d)\n", rv);
    return 2;
  }

  fprintf(stderr, "AqBanking successfully initialized.\n");

  /* You must always call this function before exiting, because only then
   * AqBanking's settings are written.
   * After this function has been called no other function except
   * AB_Banking_free() or AB_Banking_Init() may be called.
   */
  rv=AB_Banking_Fini(ab);
  if (rv) {
    fprintf(stderr, "ERROR: Error on deinit (%d)\n", rv);
    return 3;
  }

  /* The AqBanking instance you created at the beginning must always be
   * destroyed using this function to avoid memory leaks.
   */
  AB_Banking_free(ab);

  return 0;
}