Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:48:57 2009

## Asterisk developer's documentation

# func_env.c File Reference

Environment related dialplan functions. More...

`#include <stdlib.h>`
`#include <string.h>`
`#include <sys/types.h>`
`#include "asterisk.h"`
`#include "asterisk/channel.h"`
`#include "asterisk/pbx.h"`
`#include "asterisk/logger.h"`
`#include "asterisk/utils.h"`
`#include "asterisk/app.h"`

Include dependency graph for func_env.c:

Go to the source code of this file.

## Functions

static char * | builtin_function_env_read (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
static void | builtin_function_env_write (struct ast_channel *chan, char *cmd, char *data, const char *value)

## Variables

static struct ast_custom_function | env_function

## Detailed Description

Environment related dialplan functions.

Definition in file func_env.c.

## Function Documentation

static char* builtin_function_env_read | ( | struct ast_channel * | chan,
|  | char * | cmd,
|  | char * | data,
|  | char * | buf,
|  | size_t | len |
| ) |  |  | `[static]`

Definition at line 37 of file func_env.c.

    00038 {
    00039    char *ret = "";
    00040
    00041    if (data) {
    00042       ret = getenv(data);
    00043       if (!ret)
    00044          ret = "";
    00045    }
    00046    ast_copy_string(buf, ret, len);
    00047
    00048    return buf;
    00049 }

static void builtin_function_env_write | ( | struct ast_channel * | chan,
|  | char * | cmd,
|  | char * | data,
|  | const char * | value |
| ) |  |  | `[static]`

Definition at line 51 of file func_env.c.

References ast_strlen_zero(), setenv(), and unsetenv().

    00052 {
    00053    if (!ast_strlen_zero(data)) {
    00054       if (!ast_strlen_zero(value)) {
    00055          setenv(data, value, 1);
    00056       } else {
    00057          unsetenv(data);
    00058       }
    00059    }
    00060 }

## Variable Documentation

struct ast_custom_function env_function`[static]`

Definition at line 65 of file func_env.c.