blob: 760d7ab7af6bc58ec13d2873f876155cb7eef80f [file] [log] [blame]
Holger Freytherc1e11922008-12-31 23:25:05 +00001/* (C) 2008 by Jan Luebbe <jluebbe@debian.org>
2 * All Rights Reserved
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19
20#include <openbsc/db.h>
21
22#include <stdio.h>
23#include <string.h>
24#include <malloc.h>
25
26int main() {
27
28 if (db_init("hlr.sqlite3")) {
29 printf("DB: Failed to init database. Please check the option settings.\n");
30 return 1;
31 }
32 printf("DB: Database initialized.\n");
33
34 if (db_prepare()) {
35 printf("DB: Failed to prepare database.\n");
36 return 1;
37 }
38 printf("DB: Database prepared.\n");
39
40 struct gsm_subscriber *alice = NULL;
41
42 alice = db_create_subscriber("3243245432345");
43 db_set_subscriber(alice);
44 db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice);
45 free(alice);
46
47 alice = db_create_subscriber("3693245423445");
48 db_subscriber_assoc_imei(alice, "1234567890");
49 db_subscriber_alloc_tmsi(alice);
50 alice->lac=42;
51 db_set_subscriber(alice);
52 db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice);
53 free(alice);
54
55 alice = db_create_subscriber("9993245423445");
56 db_subscriber_alloc_tmsi(alice);
57 alice->lac=42;
58 db_set_subscriber(alice);
59 db_subscriber_assoc_imei(alice, "1234567890");
60 db_subscriber_assoc_imei(alice, "6543560920");
61 db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice);
62 free(alice);
63
64 db_fini();
65
66 return 0;
67}