updates.
[silc.git] / apps / irssi / src / silc / core / clientconfig.h
1 /*
2
3   clientconfig.h
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 1997 - 2000 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13   
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18
19 */
20
21 #ifndef CLIENTCONFIG_H
22 #define CLIENTCONFIG_H
23
24 /* Holds information of configured algorithms */
25 typedef struct SilcClientConfigSectionAlgStruct {
26   char *alg_name;
27   char *sim_name;
28   uint32 block_len;
29   uint32 key_len;
30   struct SilcClientConfigSectionAlgStruct *next;
31   struct SilcClientConfigSectionAlgStruct *prev;
32 #define SILC_CLIENT_CONFIG_MODNAME "builtin"
33 } SilcClientConfigSectionAlg;
34
35 /* Holds all server connections from config file */
36 typedef struct SilcClientConfigSectionConnectionStruct {
37   char *host;
38   int auth_meth;
39   char *auth_data;
40   uint16 port;
41   struct SilcClientConfigSectionConnectionStruct *next;
42   struct SilcClientConfigSectionConnectionStruct *prev;
43 #define SILC_CLIENT_CONFIG_AUTH_METH_PASSWD "passwd"
44 #define SILC_CLIENT_CONFIG_AUTH_METH_PUBKEY "pubkey"
45 } SilcClientConfigSectionConnection;
46
47 /* 
48    SILC Client Config object.
49
50    This object holds all the data parsed from the SILC client configuration
51    file. This is mainly used at the initialization of the client.
52
53 */
54 typedef struct {
55   /* Pointer back to the client */
56   void *client;
57
58   /* Filename of the configuration file */
59   char *filename;
60
61   /* Configuration sections */
62   SilcClientConfigSectionAlg *cipher;
63   SilcClientConfigSectionAlg *pkcs;
64   SilcClientConfigSectionAlg *hash_func;
65   SilcClientConfigSectionAlg *hmac;
66   SilcClientConfigSectionConnection *conns;
67 } SilcClientConfigObject;
68
69 typedef SilcClientConfigObject *SilcClientConfig;
70
71 /* Configuration section type enumerations. */
72 typedef enum {
73   SILC_CLIENT_CONFIG_SECTION_TYPE_NONE = 0,
74   SILC_CLIENT_CONFIG_SECTION_TYPE_CIPHER,
75   SILC_CLIENT_CONFIG_SECTION_TYPE_PKCS,
76   SILC_CLIENT_CONFIG_SECTION_TYPE_HASH_FUNCTION,
77   SILC_CLIENT_CONFIG_SECTION_TYPE_HMAC,
78   SILC_CLIENT_CONFIG_SECTION_TYPE_CONNECTION,
79 } SilcClientConfigSectionType;
80
81 /* SILC Configuration Section structure. */
82 typedef struct {
83   const char *section;
84   SilcClientConfigSectionType type;
85   int maxfields;
86 } SilcClientConfigSection;
87
88 /* List of all possible config sections in SILC client */
89 extern SilcClientConfigSection silc_client_config_sections[];
90
91 /* Structure used in parsing the configuration lines. The line is read
92    from a file to this structure before parsing it further. */
93 typedef struct SilcClientConfigParseStruct {
94   SilcBuffer line;
95   int linenum;
96   SilcClientConfigSection *section;
97   struct SilcClientConfigParseStruct *next;
98   struct SilcClientConfigParseStruct *prev;
99 } *SilcClientConfigParse;
100
101 /* Prototypes */
102 SilcClientConfig silc_client_config_alloc(char *filename);
103 void silc_client_config_free(SilcClientConfig config);
104 int silc_client_config_parse(SilcClientConfig config, SilcBuffer buffer,
105                              SilcClientConfigParse *return_config);
106 int silc_client_config_parse_lines(SilcClientConfig config, 
107                                    SilcClientConfigParse parse_config);
108 int silc_client_config_check_sections(uint32 checkmask);
109 void silc_client_config_setlogfiles(SilcClientConfig config);
110 bool silc_client_config_register_ciphers(SilcClientConfig config);
111 bool silc_client_config_register_pkcs(SilcClientConfig config);
112 bool silc_client_config_register_hashfuncs(SilcClientConfig config);
113 bool silc_client_config_register_hmacs(SilcClientConfig config);
114 SilcClientConfigSectionConnection *
115 silc_client_config_find_connection(SilcClientConfig config, 
116                                    char *host, int port);
117
118 #endif