5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2002 - 2007 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 String Utilities
24 * String manipulation utility routines. These routines provides
25 * various helper functions for encoding, decoding and otherwise
33 /****d* silcutil/SilcStrUtilAPI/SilcStringEncoding
37 * typedef enum { ... } SilcStringEncoding;
41 * String encoding definitions used with various string manipulation
42 * routines. By default, applications are suggested to use
43 * SILC_STRING_LOCALE since it encodes and decodes correctly according
44 * to local system language and character set (locale).
49 SILC_STRING_ASCII = 0, /* Any 8 bit ASCII encoding (default) */
50 SILC_STRING_ASCII_ESC = 1, /* 7 bit ASCII (>0x7f escaped) */
51 SILC_STRING_BMP = 2, /* 16 bit, UCS-2, BMP, ISO/IEC 10646 */
52 SILC_STRING_BMP_LSB = 3, /* BMP, least significant byte first */
53 SILC_STRING_UNIVERSAL = 4, /* 32 bit, UCS-4, Universal, ISO/IEC 10646 */
54 SILC_STRING_UNIVERSAL_LSB = 5, /* Universal, least significant byte first */
55 SILC_STRING_LOCALE = 6, /* A locale specific conversion on
56 those platforms that support iconv().
57 Fallback is SILC_STRING_ASCII. */
58 SILC_STRING_UTF8 = 7, /* UTF-8 encoding */
59 SILC_STRING_PRINTABLE = 8, /* Printable ASCII (no escaping) */
60 SILC_STRING_VISIBLE = 9, /* Visible ASCII string */
61 SILC_STRING_TELETEX = 10, /* Teletex ASCII string */
62 SILC_STRING_NUMERICAL = 11, /* Numerical ASCII string (digits) */
63 SILC_STRING_LDAP_DN = 12, /* Strings for LDAP DNs, RFC 2253 */
64 SILC_STRING_UTF8_ESCAPE = 12, /* Escaped UTF-8 as defined in RFC 2253 */
66 SILC_STRING_LANGUAGE = 6, /* _Deprecated_, use SILC_STRING_LOCALE. */
70 /****f* silcutil/SilcStrStrUtilAPI/silc_strncat
74 * char *silc_strncat(char *dest, SilcUInt32 dest_size,
75 * const char *src, SilcUInt32 src_len);
79 * Concatenates the `src' into `dest'. If `src_len' is more than the
80 * size of the `dest' (minus NULL at the end) the `src' will be
84 char *silc_strncat(char *dest, SilcUInt32 dest_size,
85 const char *src, SilcUInt32 src_len);
87 /****f* silcutil/SilcStrUtilAPI/silc_string_regexify
91 * char *silc_string_regexify(const char *string);
95 * Inspects the `string' for wildcards and returns regex string that can
96 * be used by the GNU regex library. A comma (`,') in the `string' means
97 * that the string is list.
100 char *silc_string_regexify(const char *string);
102 /****f* silcutil/SilcStrUtilAPI/silc_string_regex_match
106 * int silc_string_regex_match(const char *regex, const char *string);
110 * Matches the two strings and returns TRUE if the strings match.
113 int silc_string_regex_match(const char *regex, const char *string);
115 /****f* silcutil/SilcStrUtilAPI/silc_string_match
119 * int silc_string_match(const char *string1, const char *string2);
123 * Do regex match to the two strings `string1' and `string2'. If the
124 * `string2' matches the `string1' this returns TRUE.
127 int silc_string_match(const char *string1, const char *string2);
129 /****f* silcutil/SilcStrUtilAPI/silc_string_compare
133 * int silc_string_compare(char *string1, char *string2);
137 * Compares two strings. Strings may include wildcards '*' and '?'.
138 * Returns TRUE if strings match.
141 int silc_string_compare(char *string1, char *string2);
143 /****f* silcutil/SilcStrUtilAPI/silc_string_split
147 * char **silc_string_split(const char *string, char ch, int *ret_count);
151 * Splits a `string' that has a separator `ch' into an array of strings
152 * and returns the array. The `ret_count' will contain the number of
153 * strings in the array. Caller must free the strings and the array.
154 * Returns NULL on error. If the string does not have `ch' separator
155 * this returns the `string' in the array.
158 char **silc_string_split(const char *string, char ch, int *ret_count);
160 #endif /* SILCSTRUTIL_H */