Integer type name change.
[silc.git] / apps / silc / 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   SilcUInt32 block_len;
29   SilcUInt32 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   SilcUInt16 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 /* Holds all given commands from config file */
48 typedef struct SilcClientConfigSectionCommandStruct {
49   char *command;
50   struct SilcClientConfigSectionCommandStruct *next;
51   struct SilcClientConfigSectionCommandStruct *prev;
52 } SilcClientConfigSectionCommand;
53
54 /* 
55    SILC Client Config object.
56
57    This object holds all the data parsed from the SILC client configuration
58    file. This is mainly used at the initialization of the client.
59
60 */
61 typedef struct {
62   /* Pointer back to the client */
63   void *client;
64
65   /* Filename of the configuration file */
66   char *filename;
67
68   /* Configuration sections */
69   SilcClientConfigSectionAlg *cipher;
70   SilcClientConfigSectionAlg *pkcs;
71   SilcClientConfigSectionAlg *hash_func;
72   SilcClientConfigSectionAlg *hmac;
73   SilcClientConfigSectionConnection *conns;
74   SilcClientConfigSectionCommand *commands;
75 } SilcClientConfigObject;
76
77 typedef SilcClientConfigObject *SilcClientConfig;
78
79 /* Configuration section type enumerations. */
80 typedef enum {
81   SILC_CLIENT_CONFIG_SECTION_TYPE_NONE = 0,
82   SILC_CLIENT_CONFIG_SECTION_TYPE_CIPHER,
83   SILC_CLIENT_CONFIG_SECTION_TYPE_PKCS,
84   SILC_CLIENT_CONFIG_SECTION_TYPE_HASH_FUNCTION,
85   SILC_CLIENT_CONFIG_SECTION_TYPE_HMAC,
86   SILC_CLIENT_CONFIG_SECTION_TYPE_CONNECTION,
87   SILC_CLIENT_CONFIG_SECTION_TYPE_COMMAND = 253, /* Special section */
88 } SilcClientConfigSectionType;
89
90 /* SILC Configuration Section structure. */
91 typedef struct {
92   const char *section;
93   SilcClientConfigSectionType type;
94   int maxfields;
95 } SilcClientConfigSection;
96
97 /* List of all possible config sections in SILC client */
98 extern SilcClientConfigSection silc_client_config_sections[];
99
100 /* Structure used in parsing the configuration lines. The line is read
101    from a file to this structure before parsing it further. */
102 typedef struct SilcClientConfigParseStruct {
103   SilcBuffer line;
104   int linenum;
105   SilcClientConfigSection *section;
106   struct SilcClientConfigParseStruct *next;
107   struct SilcClientConfigParseStruct *prev;
108 } *SilcClientConfigParse;
109
110 /* Prototypes */
111 SilcClientConfig silc_client_config_alloc(char *filename);
112 void silc_client_config_free(SilcClientConfig config);
113 int silc_client_config_parse(SilcClientConfig config, SilcBuffer buffer,
114                              SilcClientConfigParse *return_config);
115 int silc_client_config_parse_lines(SilcClientConfig config, 
116                                    SilcClientConfigParse parse_config);
117 int silc_client_config_check_sections(SilcUInt32 checkmask);
118 void silc_client_config_setlogfiles(SilcClientConfig config);
119 bool silc_client_config_register_ciphers(SilcClientConfig config);
120 bool silc_client_config_register_pkcs(SilcClientConfig config);
121 bool silc_client_config_register_hashfuncs(SilcClientConfig config);
122 bool silc_client_config_register_hmacs(SilcClientConfig config);
123 SilcClientConfigSectionConnection *
124 silc_client_config_find_connection(SilcClientConfig config, 
125                                    char *host, int port);
126
127 #endif