1 /*-
2  * Copyright (c) 1998-2008 DHIS, Dynamic Host Information System
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  */
27 
28 
29 #include <stdio.h>
30 #include <time.h>
31 
32 #define APASS           1
33 #define AQRC            2
34 
35 struct dhis_rec {
36 	int hostid;
37 	char hostname[128];
38 	char hostpass[32];
39 	char authn[4][128];
40 	int status;
41 	char oncmd[256];
42 	char offcmd[256];
43 
44 	/* DHISD specific parameters */
45 	int atype;
46 	mpz_t mauthn;
47 	int xstage;
48 	int refresh;
49 	mpz_t x;
50 
51 	struct dhis_rec *next;
52 };
53 
54 #define	DB_FILE	1		// Default database type if mysql is not enabled
55 
56 struct dhis_rec *new_rec(void);
57 void free_rec(struct dhis_rec *);
58 struct dhis_rec *get_rec(int);
59 
60 int db_reload(void);
61 void db_free(void);
62 
63 char *db_password(int);
64 int db_is_locked(int);
65 
66 int file_db_reload(void);
67 
68 #ifdef WITH_MYSQL
69 #define	DB_MYSQL 2
70 int sql_login(void);
71 void sql_logout(void);
72 int sql_log(char *);
73 int sql_update_lastlogin(int);
74 int sql_db_reload(void);
75 #endif
76 
77