aboutsummaryrefslogtreecommitdiffstats
path: root/epan/strutil.h
diff options
context:
space:
mode:
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2004-06-06 14:29:07 +0000
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>2004-06-06 14:29:07 +0000
commitdef10129a14bcae28172eee56133156882b9f855 (patch)
treed8dd0933717ff6071c0baa6c4cbdd3b8479af42c /epan/strutil.h
parent3f03cb994988c84cf203cf8d1e1099473bbb72d4 (diff)
Add a "force_separators" parameter to hex_str_to_bytes so that it's
possible to paste in WEP keys without any separators. Add doxygen comments to strutil.h. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@11123 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/strutil.h')
-rw-r--r--epan/strutil.h89
1 files changed, 85 insertions, 4 deletions
diff --git a/epan/strutil.h b/epan/strutil.h
index f78b5a7c0e..4f4e8bcca9 100644
--- a/epan/strutil.h
+++ b/epan/strutil.h
@@ -1,7 +1,7 @@
/* strutil.h
* String utility definitions
*
- * $Id: strutil.h,v 1.15 2004/05/01 20:46:24 obiot Exp $
+ * $Id: strutil.h,v 1.16 2004/06/06 14:29:07 gerald Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -27,16 +27,97 @@
/* ... thus, config.h needs to be #included */
+/** @file
+ * String handling and conversion utilities.
+ */
+
+/** Given a pointer into a data buffer, and to the end of the buffer,
+ * find the end of the (putative) line at that position in the data
+ * buffer.
+ *
+ * @param data A pointer to the beginning of the data
+ * @param dataend A pointer to the end of the data
+ * @param eol A pointer that will receive the EOL location
+ * @return A pointer to the EOL character(s) in "*eol".
+ */
const guchar *find_line_end(const guchar *data, const guchar *dataend,
const guchar **eol);
+
+/** Get the length of the next token in a line, and the beginning of the
+ * next token after that (if any).
+ * @param linep A pointer to the beginning of the line
+ * @param lineend A pointer to the end of the line
+ * @param next_token Receives the location of the next token
+ * @return 0 if there is no next token.
+ */
int get_token_len(const guchar *linep, const guchar *lineend,
const guchar **next_token);
+
+/** Given a string, generate a string from it that shows non-printable
+ * characters as C-style escapes, and return a pointer to it.
+ *
+ * @param line A pointer to the input string
+ * @param len The length of the input string
+ * @return A pointer to the formatted string
+ *
+ * @see tvb_format_text()
+ */
gchar* format_text(const guchar *line, int len);
-gchar* bytes_to_str(const guint8 *, int);
-gchar* bytes_to_str_punct(const guint8 *, int, gchar punct);
-gboolean hex_str_to_bytes(const char *hex_str, GByteArray *bytes);
+
+/** Turn an array of bytes into a string showing the bytes in hex.
+ *
+ * @param bd A pointer to the byte array
+ * @param bd_len The length of the byte array
+ * @return A pointer to the formatted string
+ *
+ * @see bytes_to_str_punct()
+ */
+gchar* bytes_to_str(const guint8 *bd, int bd_len);
+
+/** Turn an array of bytes into a string showing the bytes in hex,
+ * separated by a punctuation character.
+ *
+ * @param bd A pointer to the byte array
+ * @param bd_len The length of the byte array
+ * @param punct The punctuation character
+ * @return A pointer to the formatted string
+ *
+ * @see bytes_to_str()
+ */
+gchar* bytes_to_str_punct(const guint8 *bd, int bd_len, gchar punct);
+
+/** Turn a string of hex digits with optional separators (defined by
+ * is_byte_sep() into a byte array.
+ *
+ * @param hex_str The string of hex digits.
+ * @param bytes The GByteArray that will receive the bytes. This
+ * must be initialized by the caller.
+ * @param force_separators If set to TRUE, separators MUST exist between
+ * bytes.
+ * @return True if the string was converted successfully
+ */
+gboolean hex_str_to_bytes(const char *hex_str, GByteArray *bytes,
+ gboolean force_separators);
+
+/** Return a XML escaped representation of the unescaped string.
+ * The returned string must be freed when no longer in use.
+ *
+ * @param unescaped The unescaped string
+ * @return An XML-escaped representation of the input string
+ */
gchar* xml_escape(const gchar *unescaped);
+/* Return the first occurrence of needle in haystack.
+ * Algorithm copied from GNU's glibc 2.3.2 memcmp()
+ *
+ * @param haystack The data to search
+ * @param haystack_len The length of the search data
+ * @param needle The string to look for
+ * @param needle_len The length of the search string
+ * @return A pointer to the first occurrence of "needle" in
+ * "haystack". If "needle" isn't found or is NULL, or if
+ * "needle_len" is 0, NULL is returned.
+ */
const guint8 * epan_memmem(const guint8 *haystack, guint haystack_len,
const guint8 *needle, guint needle_len);