LRN: add function GNUNET_STRINGS_get_short_name to get basename
[oweals/gnunet.git] / src / include / gnunet_strings_lib.h
index 4efecc8639418a6ff34e24b3975f1d87d9505cd2..8101a8113d262e1b4a88366ea7d737ca78877c63 100644 (file)
@@ -85,6 +85,18 @@ char *
 GNUNET_STRINGS_byte_size_fancy (unsigned long long size);
 
 
+/**
+ * Convert the len characters long character sequence
+ * given in input that is in the given input charset
+ * to a string in given output charset.
+ * @return the converted string (0-terminated),
+ *  if conversion fails, a copy of the orignal
+ *  string is returned.
+ */
+char *
+GNUNET_STRINGS_conv (const char *input, size_t len,
+    const char *input_charset, const char *output_charset);
+
 /**
  * Convert the len characters long character sequence
  * given in input that is in the given charset
@@ -98,6 +110,17 @@ GNUNET_STRINGS_byte_size_fancy (unsigned long long size);
 char *
 GNUNET_STRINGS_to_utf8 (const char *input, size_t len, const char *charset);
 
+/**
+ * Convert the len bytes-long UTF-8 string
+ * given in input to the given charset.
+
+ * @return the converted string (0-terminated),
+ *  if conversion fails, a copy of the orignal
+ *  string is returned.
+ */
+char *
+GNUNET_STRINGS_from_utf8 (const char *input, size_t len, const char *charset);
+
 
 /**
  * Complete filename (a la shell) from abbrevition.
@@ -176,6 +199,20 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t);
 char *
 GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta);
 
+/**
+ * "man basename"
+ * Returns a pointer to a part of filename (allocates nothing)!
+ *
+ * @param filename filename to extract basename from
+ * @return short (base) name of the file (that is, everything following the
+ *         last directory separator in filename. If filename ends with a
+ *         directory separator, the result will be a zero-length string.
+ *         If filename has no directory separators, the result is filename
+ *         itself.
+ */
+const char *
+GNUNET_STRINGS_get_short_name (const char *filename);
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif