Added SILC errno API. Added SilcResult, generic error code and
[silc.git] / lib / silcutil / silcutil.h
index f645569f2163fcb0f4ecba46eff72d18f3907a7b..b4d9eb451063d466af2417f00b0dce1e5f7047bc 100644 (file)
  ***/
 int silc_gets(char *dest, int destlen, const char *src, int srclen, int begin);
 
-/****f* silcutil/SilcUtilAPI/silc_check_line
- *
- * SYNOPSIS
- *
- *    int silc_check_line(char *buf);
- *
- * DESCRIPTION
- *
- *    Checks line for illegal characters. Return -1 when illegal character
- *    were found. This is used to check for bad lines when reading data from
- *    for example a configuration file.
- *
- ***/
-int silc_check_line(char *buf);
-
 /****f* silcutil/SilcUtilAPI/silc_to_upper
  *
  * SYNOPSIS
@@ -156,8 +141,7 @@ char *silc_format(char *fmt, ...);
  *
  *    Basic has function to hash strings. May be used with the SilcHashTable.
  *    Note that this lowers the characters of the string (with tolower()) so
- *    this is used usually with nicknames, channel and server names to provide
- *    case insensitive keys.
+ *    this can be used to provide case-insensitive hashing.
  *
  ***/
 SilcUInt32 silc_hash_string(void *key, void *user_context);
@@ -251,8 +235,8 @@ SilcUInt32 silc_hash_data(void *key, void *user_context);
  *
  * DESCRIPTION
  *
- *    Compares two strings. It may be used as SilcHashTable comparison
- *    function.
+ *    Compares two strings. This ignores the case while comparing.  It may
+ *    be used as SilcHashTable comparison function.
  *
  ***/
 SilcBool silc_hash_string_compare(void *key1, void *key2, void *user_context);
@@ -433,4 +417,52 @@ char *silc_get_real_name();
 #define silc_va_copy(dest, src) dest = src;
 #endif
 
+/****f* silcutil/SilcUtilAPI/silc_hexdump
+ *
+ * SYNOPSIS
+ *
+ *    void silc_hexdump(const unsigned char *data, SilcUInt32 data_len,
+ *                      FILE *output);
+ *
+ * DESCRIPTION
+ *
+ *    Dumps the `data' of length of `data_len' bytes as HEX.  The `output'
+ *    file specifies the destination.
+ *
+ ***/
+void silc_hexdump(const unsigned char *data, SilcUInt32 data_len,
+                 FILE *output);
+
+/****f* silcutil/SilcUtilAPI/silc_hex2data
+ *
+ * SYNOPSIS
+ *
+ *    SilcBool silc_hex2data(const char *hex, unsigned char *data,
+ *                           SilcUInt32 data_size, SilcUInt32 *ret_data_len);
+ *
+ * DESCRIPTION
+ *
+ *    Converts HEX character string to binary data.  Each HEX numbers must
+ *    have two characters in the `hex' string.
+ *
+ ***/
+SilcBool silc_hex2data(const char *hex, unsigned char *data,
+                      SilcUInt32 data_size, SilcUInt32 *ret_data_len);
+
+/****f* silcutil/SilcUtilAPI/silc_data2hex
+ *
+ * SYNOPSIS
+ *
+ *    SilcBool silc_data2hex(const unsigned char *data, SilcUInt32 data_len,
+ *                           char *hex, SilcUInt32 hex_size);
+ *
+ * DESCRIPTION
+ *
+ *    Converts binary data to HEX string.  This NULL terminates the `hex'
+ *    buffer automatically.
+ *
+ ***/
+SilcBool silc_data2hex(const unsigned char *data, SilcUInt32 data_len,
+                      char *hex, SilcUInt32 hex_size);
+
 #endif /* !SILCUTIL_H */