summaryrefslogtreecommitdiffstats
path: root/tapset/string.stp
diff options
context:
space:
mode:
authormmason <mmason>2007-01-23 18:03:50 +0000
committermmason <mmason>2007-01-23 18:03:50 +0000
commitdfd8bb34d4d06033c5062ef19f2e5a2f77d5f6c9 (patch)
tree327a715cfbf385c9d91775b9881fc499f2e0637a /tapset/string.stp
parent6dd0aa5face6fc1091841a31ff86280b7e7da96d (diff)
downloadsystemtap-steved-dfd8bb34d4d06033c5062ef19f2e5a2f77d5f6c9.tar.gz
systemtap-steved-dfd8bb34d4d06033c5062ef19f2e5a2f77d5f6c9.tar.xz
systemtap-steved-dfd8bb34d4d06033c5062ef19f2e5a2f77d5f6c9.zip
Added new string functions tokenize() and strtol().
Diffstat (limited to 'tapset/string.stp')
-rw-r--r--tapset/string.stp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tapset/string.stp b/tapset/string.stp
index 77925d0d..15791134 100644
--- a/tapset/string.stp
+++ b/tapset/string.stp
@@ -58,5 +58,37 @@ function text_strn:string(input:string, len:long, quoted:long)
_stp_text_str(THIS->__retvalue, THIS->input, THIS->len, THIS->quoted, 0);
%}
+/*
+ * tokenize - Given a string and a token delimiter,
+ * return the next token in the string
+ * input String to tokenize. If NULL, returns the next token in the
+ * string passed in the previous call to tokenize().
+ * delim Token delimiter. Note this is a string, but only the first
+ * character is used as the delimiter.
+ */
+function tokenize:string(input:string, delim:string)
+%{ /* pure */
+ static char str[MAXSTRINGLEN];
+ static char *str_start;
+ char *token = NULL;
+
+ if (THIS->input[0]) {
+ strncpy(str, THIS->input, MAXSTRINGLEN);
+ str_start = &str[0];
+ }
+ token = strsep(&str_start, THIS->delim);
+ if (token)
+ strncpy (THIS->__retvalue, token, MAXSTRINGLEN);
+%}
+
+/*
+ * strtol - Convert a string to a long
+ * str String to convert
+ * base The base to use
+ */
+function strtol:long(str:string, base:long)
+%{ /* pure */
+ THIS->__retvalue = simple_strtol(THIS->str, NULL, THIS->base);
+%}
/** @} */