5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 1997 - 2002 Pekka Riikonen
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; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
20 /****h* silcutil/SILC Utilities
31 /****f* silcutil/SilcUtilAPI/silc_gets
35 * int silc_gets(char *dest, int destlen, const char *src, int srclen,
40 * Gets line from a buffer. Stops reading when a newline or EOF occurs.
41 * This doesn't remove the newline sign from the destination buffer. The
42 * argument begin is returned and should be passed again for the function.
45 int silc_gets(char *dest, int destlen, const char *src, int srclen, int begin);
47 /****f* silcutil/SilcUtilAPI/silc_check_line
51 * int silc_check_line(char *buf);
55 * Checks line for illegal characters. Return -1 when illegal character
56 * were found. This is used to check for bad lines when reading data from
57 * for example a configuration file.
60 int silc_check_line(char *buf);
62 /****f* silcutil/SilcUtilAPI/silc_get_time
66 * char *silc_get_time();
70 * Returns current time as string.
73 char *silc_get_time();
75 /****f* silcutil/SilcUtilAPI/silc_to_upper
79 * char *silc_to_upper(char *string);
83 * Converts string to capital characters.
86 char *silc_to_upper(char *string);
88 /****f* silcutil/SilcUtilAPI/silc_parse_userfqdn
92 * bool silc_parse_userfqdn(const char *string, char **left, char **right);
96 * Parse userfqdn string which is in user@fqdn format.
99 bool silc_parse_userfqdn(const char *string, char **left, char **right);
101 /****f* silcutil/SilcUtilAPI/silc_parse_command_line
105 * void silc_parse_command_line(unsigned char *buffer,
106 * unsigned char ***parsed,
107 * SilcUInt32 **parsed_lens,
108 * SilcUInt32 **parsed_types,
109 * SilcUInt32 *parsed_num,
110 * SilcUInt32 max_args);
114 * Parses command line. At most `max_args' is taken. Rest of the line
115 * will be allocated as the last argument if there are more than `max_args'
116 * arguments in the line. Note that the command name is counted as one
117 * argument and is saved.
120 void silc_parse_command_line(unsigned char *buffer,
121 unsigned char ***parsed,
122 SilcUInt32 **parsed_lens,
123 SilcUInt32 **parsed_types,
124 SilcUInt32 *parsed_num,
125 SilcUInt32 max_args);
127 /****f* silcutil/SilcUtilAPI/silc_format
131 * char *silc_format(char *fmt, ...);
135 * Formats arguments to a string and returns it after allocating memory
136 * for it. It must be remembered to free it later.
139 char *silc_format(char *fmt, ...);
141 /****f* silcutil/SilcUtilAPI/silc_id_render
145 * char *silc_id_render(void *id, SilcUInt16 type);
149 * Renders ID to suitable to print for example to log file.
152 char *silc_id_render(void *id, SilcUInt16 type);
154 /****f* silcutil/SilcUtilAPI/silc_string_compare
158 * int silc_string_compare(char *string1, char *string2);
162 * Compares two strings. Strings may include wildcards '*' and '?'.
163 * Returns TRUE if strings match.
166 int silc_string_compare(char *string1, char *string2);
168 /****f* silcutil/SilcUtilAPI/silc_hash_string
172 * SilcUInt32 silc_hash_string(void *key, void *user_context);
176 * Basic has function to hash strings. May be used with the SilcHashTable.
177 * Note that this lowers the characters of the string (with tolower()) so
178 * this is used usually with nicknames, channel and server names to provide
179 * case insensitive keys.
182 SilcUInt32 silc_hash_string(void *key, void *user_context);
184 /****f* silcutil/SilcUtilAPI/silc_hash_uint
188 * SilcUInt32 silc_hash_uint(void *key, void *user_context);
192 * Basic hash function to hash integers. May be used with the SilcHashTable.
195 SilcUInt32 silc_hash_uint(void *key, void *user_context);
197 /****f* silcutil/SilcUtilAPI/silc_hash_ptr
201 * SilcUInt32 silc_hash_ptr(void *key, void *user_context);
205 * Basic hash funtion to hash pointers. May be used with the SilcHashTable.
208 SilcUInt32 silc_hash_ptr(void *key, void *user_context);
210 /****f* silcutil/SilcUtilAPI/silc_hash_id
214 * SilcUInt32 silc_hash_id(void *key, void *user_context);
218 * Hash a ID. The `user_context' is the ID type.
221 SilcUInt32 silc_hash_id(void *key, void *user_context);
223 /****f* silcutil/SilcUtilAPI/silc_hash_data
227 * SilcUInt32 silc_hash_data(void *key, void *user_context);
231 * Hash binary data. The `user_context' is the data length.
234 SilcUInt32 silc_hash_data(void *key, void *user_context);
236 /****f* silcutil/SilcUtilAPI/silc_hash_public_key
240 * SilcUInt32 silc_hash_public_key(void *key, void *user_context);
244 * Hashed SILC Public key.
247 SilcUInt32 silc_hash_public_key(void *key, void *user_context);
249 /****f* silcutil/SilcUtilAPI/silc_hash_string_compare
253 * bool silc_hash_string_compare(void *key1, void *key2,
254 * void *user_context);
258 * Compares two strings. It may be used as SilcHashTable comparison
262 bool silc_hash_string_compare(void *key1, void *key2, void *user_context);
264 /****f* silcutil/SilcUtilAPI/silc_hash_id_compare
268 * bool silc_hash_id_compare(void *key1, void *key2, void *user_context);
272 * Compares two ID's. May be used as SilcHashTable comparison function.
273 * The Client ID's compares only the hash of the Client ID not any other
274 * part of the Client ID. Other ID's are fully compared.
277 bool silc_hash_id_compare(void *key1, void *key2, void *user_context);
279 /****f* silcutil/SilcUtilAPI/silc_hash_client_id_compare
283 * bool silc_hash_client_id_compare(void *key1, void *key2, void *user_context);
287 * Compare two Client ID's entirely and not just the hash from the ID.
290 bool silc_hash_client_id_compare(void *key1, void *key2, void *user_context);
292 /****f* silcutil/SilcUtilAPI/silc_hash_data_compare
296 * bool silc_hash_data_compare(void *key1, void *key2, void *user_context);
300 * Compares binary data. May be used as SilcHashTable comparison function.
303 bool silc_hash_data_compare(void *key1, void *key2, void *user_context);
305 /****f* silcutil/SilcUtilAPI/silc_hash_public_key_compare
309 * bool silc_hash_public_key_compare(void *key1, void *key2, void *user_context);
313 * Compares two SILC Public keys. It may be used as SilcHashTable
314 * comparison function.
317 bool silc_hash_public_key_compare(void *key1, void *key2, void *user_context);
319 /****f* silcutil/SilcUtilAPI/silc_client_chmode
323 * char *silc_client_chmode(SilcUInt32 mode, const char *cipher,
328 * Parses mode mask and returns the mode as string.
331 char *silc_client_chmode(SilcUInt32 mode, const char *cipher,
334 /****f* silcutil/SilcUtilAPI/silc_client_chumode
338 * char *silc_client_chumode(SilcUInt32 mode);
342 * Parses channel user mode mask and returns te mode as string.
345 char *silc_client_chumode(SilcUInt32 mode);
347 /****f* silcutil/SilcUtilAPI/silc_client_chumode_char
351 * char *silc_client_chumode_char(SilcUInt32 mode);
355 * Parses channel user mode and returns it as special mode character.
358 char *silc_client_chumode_char(SilcUInt32 mode);
360 /****f* silcutil/SilcUtilAPI/silc_fingerprint
364 * char *silc_fingerprint(const unsigned char *data, SilcUInt32 data_len);
368 * Creates fingerprint from data, usually used with SHA1 digests.
371 char *silc_fingerprint(const unsigned char *data, SilcUInt32 data_len);
373 /****f* silcutil/SilcUtilAPI/silc_string_is_ascii
377 * bool silc_string_is_ascii(const unsigned char *data,
378 * SilcUInt32 data_len);
382 * Return TRUE if the `data' is ASCII string.
385 bool silc_string_is_ascii(const unsigned char *data, SilcUInt32 data_len);
387 /****f* silcutil/SilcUtilAPI/silc_parse_version_string
391 * bool silc_parse_version_string(const char *version,
392 * SilcUInt32 *protocol_version,
393 * char **protocol_version_string,
394 * SilcUInt32 *software_version,
395 * char **software_version_string,
396 * char **vendor_version);
400 * Parses SILC protocol style version string.
403 bool silc_parse_version_string(const char *version,
404 SilcUInt32 *protocol_version,
405 char **protocol_version_string,
406 SilcUInt32 *software_version,
407 char **software_version_string,
408 char **vendor_version);
410 /****f* silcutil/SilcUtilAPI/silc_version_to_num
414 * SilcUInt32 silc_version_to_num(const char *version);
418 * Converts version string x.x into number representation.
421 SilcUInt32 silc_version_to_num(const char *version);
423 /****f* silcutil/SilcUtilAPI/silc_get_input
427 * char *silc_get_input(const char *prompt, bool echo_off);
431 * Displays input prompt on command line and takes input data from user.
434 char *silc_get_input(const char *prompt, bool echo_off);
436 /* XXX - System dependant prototypes */
438 int silc_gettimeofday(struct timeval *p);
439 char *silc_string_regexify(const char *string);
440 int silc_string_regex_match(const char *regex, const char *string);
441 int silc_string_match(const char *string1, const char *string2);
442 char *silc_get_username();
443 char *silc_get_real_name();
445 #endif /* !SILCUTIL_H */