blob: 74d645f2465510c648b20a50810209775fc29d79 [file] [log] [blame]
Jan Luebbefaaa49c2008-12-27 01:07:07 +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>
Jan Luebbe7398eb92008-12-27 00:45:41 +000021
22#include <stdio.h>
Jan Luebbe5c15c852008-12-27 15:59:25 +000023#include <string.h>
Jan Luebbe7398eb92008-12-27 00:45:41 +000024
25int main() {
26
Jan Luebbe5c15c852008-12-27 15:59:25 +000027 if (db_init()) {
28 printf("DB: Failed to init database. Please check the option settings.\n");
29 return 1;
30 }
31 printf("DB: Database initialized.\n");
Jan Luebbe7398eb92008-12-27 00:45:41 +000032
Jan Luebbe5c15c852008-12-27 15:59:25 +000033 if (db_prepare()) {
34 printf("DB: Failed to prepare database.\n");
35 return 1;
36 }
37 printf("DB: Database prepared.\n");
Jan Luebbe7398eb92008-12-27 00:45:41 +000038
Jan Luebbe5c15c852008-12-27 15:59:25 +000039 struct gsm_subscriber *alice = NULL;
Jan Luebbe7398eb92008-12-27 00:45:41 +000040
Jan Luebbe5c15c852008-12-27 15:59:25 +000041 alice = db_create_subscriber("3243245432345");
42 db_subscriber_alloc_tmsi(alice);
43 alice->lac=42;
44 db_set_subscriber(alice);
45 db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice);
46 free(alice);
Jan Luebbe7398eb92008-12-27 00:45:41 +000047
Jan Luebbe5c15c852008-12-27 15:59:25 +000048 alice = db_create_subscriber("3693245423445");
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);
Jan Luebbe7398eb92008-12-27 00:45:41 +000054
Jan Luebbe5c15c852008-12-27 15:59:25 +000055 alice = db_create_subscriber("9993245423445");
56 db_subscriber_alloc_tmsi(alice);
57 alice->lac=42;
58 db_set_subscriber(alice);
59 db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice);
60 free(alice);
61
62 db_fini();
63
64 return 0;
Jan Luebbe7398eb92008-12-27 00:45:41 +000065}