| 1 |
// context-envvar tapset |
| 2 |
// Copyright (C) 2012 Red Hat, Inc. |
| 3 |
// |
| 4 |
// This file is part of systemtap, and is free software. You can |
| 5 |
// redistribute it and/or modify it under the terms of the GNU General |
| 6 |
// Public License (GPL); either version 2, or (at your option) any |
| 7 |
// later version. |
| 8 |
|
| 9 |
// NB: functionally equivalent to linux/context-envvar.stp |
| 10 |
|
| 11 |
%{ |
| 12 |
#include <stdlib.h> |
| 13 |
%} |
| 14 |
|
| 15 |
function env_var:string(name:string) |
| 16 |
%{ /* pure */ /* unmodified-fnargs */ |
| 17 |
// XXX getenv may not be reentrant! |
| 18 |
const char* env = getenv(STAP_ARG_name); |
| 19 |
if (env) |
| 20 |
strlcpy (STAP_RETVALUE, env, MAXSTRINGLEN); |
| 21 |
else |
| 22 |
STAP_RETVALUE[0] = '\0'; |
| 23 |
|
| 24 |
%} |