ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/include/conf_db.h
Revision: 1737
Committed: Mon Jan 14 17:37:55 2013 UTC (12 years, 7 months ago) by michael
Content type: text/x-chdr
File size: 3452 byte(s)
Log Message:
- Quick and dirty workaround to fix build on GNU/Hurd
  because of undefined PATH_MAX

File Contents

# User Rev Content
1 michael 1620 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     *
4 michael 1668 * Copyright (C) 1996-2009 by Andrew Church <achurch@achurch.org>
5 michael 1620 * Copyright (C) 2012 by the Hybrid Development Team.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     */
22    
23     /*! \file conf_db.h
24     * \brief Includes file utilities for database handling
25 michael 1635 * \version $Id$
26 michael 1620 */
27    
28     #ifndef DATAFILES_H
29     #define DATAFILES_H
30    
31     struct dbFILE
32     {
33 michael 1668 char mode; /**< 'r' for reading, 'w' for writing */
34     FILE *fp; /**< The file pointer itself */
35 michael 1737 char filename[HYB_PATH_MAX + 1]; /**< Name of the database file */
36     char tempname[HYB_PATH_MAX + 1]; /**< Name of the temporary file (for writing) */
37 michael 1620 };
38    
39     extern void check_file_version(struct dbFILE *);
40 michael 1621 extern uint32_t get_file_version(struct dbFILE *);
41 michael 1620 extern int write_file_version(struct dbFILE *, uint32_t);
42    
43 michael 1668 extern struct dbFILE *open_db(const char *, const char *, uint32_t);
44 michael 1620 extern void restore_db(struct dbFILE *); /* Restore to state before open_db() */
45 michael 1668 extern int close_db(struct dbFILE *);
46 michael 1620 extern void backup_databases(void);
47    
48     #define read_db(f,buf,len) (fread((buf),1,(len),(f)->fp))
49     #define write_db(f,buf,len) (fwrite((buf),1,(len),(f)->fp))
50     #define getc_db(f) (fgetc((f)->fp))
51    
52 michael 1627 extern int read_uint8(uint8_t *, struct dbFILE *);
53     extern int write_uint8(uint8_t, struct dbFILE *);
54 michael 1620 extern int read_uint16(uint16_t *, struct dbFILE *);
55     extern int write_uint16(uint16_t, struct dbFILE *);
56     extern int read_uint32(uint32_t *, struct dbFILE *);
57     extern int write_uint32(uint32_t, struct dbFILE *);
58     extern int read_uint64(uint64_t *, struct dbFILE *);
59     extern int write_uint64(uint64_t, struct dbFILE *);
60     extern int read_ptr(void **, struct dbFILE *);
61     extern int write_ptr(const void *, struct dbFILE *);
62     extern int read_string(char **, struct dbFILE *);
63     extern int write_string(const char *, struct dbFILE *);
64    
65 michael 1622 extern void load_kline_database(void);
66     extern void save_kline_database(void);
67     extern void load_dline_database(void);
68     extern void save_dline_database(void);
69     extern void load_gline_database(void);
70     extern void save_gline_database(void);
71     extern void load_xline_database(void);
72     extern void save_xline_database(void);
73     extern void load_resv_database(void);
74     extern void save_resv_database(void);
75 michael 1625 extern void save_all_databases(void *);
76 michael 1620
77     #define read_buffer(buf,f) (read_db((f),(buf),sizeof(buf)) == sizeof(buf))
78     #define write_buffer(buf,f) (write_db((f),(buf),sizeof(buf)) == sizeof(buf))
79     #define read_buflen(buf,len,f) (read_db((f),(buf),(len)) == (len))
80     #define write_buflen(buf,len,f) (write_db((f),(buf),(len)) == (len))
81     #define read_variable(var,f) (read_db((f),&(var),sizeof(var)) == sizeof(var))
82     #define write_variable(var,f) (write_db((f),&(var),sizeof(var)) == sizeof(var))
83 michael 1622
84 michael 1625 #define DATABASE_UPDATE_TIMEOUT 300
85 michael 1622 #define KLINE_DB_VERSION 1
86 michael 1620 #endif

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision