blob: 760d7ab7af6bc58ec13d2873f876155cb7eef80f [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>
Harald Welte255539c2008-12-28 02:26:27 +000024#include <malloc.h>
Jan Luebbe7398eb92008-12-27 00:45:41 +000025
26int main() {
27
Holger Freytherbde36102008-12-28 22:51:39 +000028 if (db_init("hlr.sqlite3")) {
Jan Luebbe5c15c852008-12-27 15:59:25 +000029 printf("DB: Failed to init database. Please check the option settings.\n");
30 return 1;
31 }
32 printf("DB: Database initialized.\n");
Jan Luebbe7398eb92008-12-27 00:45:41 +000033
Jan Luebbe5c15c852008-12-27 15:59:25 +000034 if (db_prepare()) {
35 printf("DB: Failed to prepare database.\n");
36 return 1;
37 }
38 printf("DB: Database prepared.\n");
Jan Luebbe7398eb92008-12-27 00:45:41 +000039
Jan Luebbe5c15c852008-12-27 15:59:25 +000040 struct gsm_subscriber *alice = NULL;
Jan Luebbe7398eb92008-12-27 00:45:41 +000041
Jan Luebbe5c15c852008-12-27 15:59:25 +000042 alice = db_create_subscriber("3243245432345");
Jan Luebbe5c15c852008-12-27 15:59:25 +000043 db_set_subscriber(alice);
44 db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice);
45 free(alice);
Jan Luebbe7398eb92008-12-27 00:45:41 +000046
Jan Luebbe5c15c852008-12-27 15:59:25 +000047 alice = db_create_subscriber("3693245423445");
Jan Luebbe391d86e2008-12-27 22:33:34 +000048 db_subscriber_assoc_imei(alice, "1234567890");
Jan Luebbe5c15c852008-12-27 15:59:25 +000049 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);
Jan Luebbefac25fc2008-12-27 18:04:34 +000059 db_subscriber_assoc_imei(alice, "1234567890");
60 db_subscriber_assoc_imei(alice, "6543560920");
Jan Luebbe5c15c852008-12-27 15:59:25 +000061 db_get_subscriber(GSM_SUBSCRIBER_IMSI, alice);
62 free(alice);
63
64 db_fini();
65
66 return 0;
Jan Luebbe7398eb92008-12-27 00:45:41 +000067}