/usr/share/systemtap/tapset/tokenize.stp is in systemtap-common 1.6-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | // Tokenize tapset
// Copyright (C) 2010 Red Hat, Inc.
//
// This file is part of systemtap, and is free software. You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.
%{
#define STAP_NEED_CONTEXT_TOKENIZE 1
%}
/**
* sfunction tokenize - Return the next non-empty token in a string
*
* @input: string to tokenize. If NULL, returns the next non-empty token
* in the string passed in the previous call to tokenize().
* @delim: set of characters that delimit the tokens
*
* Description: This function returns the next non-empty token in the
* given input string, where the tokens are delimited by characters in
* the delim string. If the input string is non-NULL, it returns the
* first token. If the input string is NULL, it returns the next
* token in the string passed in the previous call to tokenize.
* If no delimiter is found, the entire remaining input string is
* returned. It returns NULL when no more tokens are available.
*/
function tokenize:string(input:string, delim:string)
%{ /* unprivileged */
char *token = NULL;
char *token_end = NULL;
if (THIS->input[0]) {
strncpy(CONTEXT->tok_str, THIS->input, MAXSTRINGLEN);
CONTEXT->tok_start = &CONTEXT->tok_str[0];
CONTEXT->tok_end = &CONTEXT->tok_str[0] + strlen(CONTEXT->tok_str);
}
do {
token = strsep(& CONTEXT->tok_start, THIS->delim);
} while (token && !token[0]);
if (token) {
token_end = (CONTEXT->tok_start ? CONTEXT->tok_start - 1 : CONTEXT->tok_end);
memcpy(THIS->__retvalue, token, token_end - token + 1);
}
%}
|