Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:49:20 2009

## Asterisk developer's documentation

# strcompat.c File Reference

`#include <sys/types.h>`
`#include <stdio.h>`
`#include "asterisk/compat.h"`

Include dependency graph for strcompat.c:

Go to the source code of this file.

## Functions

int | setenv (const char *name, const char *value, int overwrite)
char * | strsep (char **str, const char *delims)
int | unsetenv (const char *name)

## Function Documentation

int setenv | ( | const char * | name,
|  | const char * | value,
|  | int | overwrite |
| ) |  |  |

Definition at line 33 of file strcompat.c.

Referenced by builtin_function_env_write(), load_odbc_config(), main(), and unsetenv().

    00034 {
    00035    unsigned char *buf;
    00036    int buflen;
    00037
    00038    buflen = strlen(name) + strlen(value) + 2;
    00039    if (!(buf = alloca(buflen)))
    00040       return -1;
    00041
    00042    if (!overwrite && getenv(name))
    00043       return 0;
    00044
    00045    snprintf(buf, buflen, "%s=%s", name, value);
    00046
    00047    return putenv(buf);
    00048 }

char* strsep | ( | char ** | str,
|  | const char * | delims |
| ) |  |  |

Definition at line 8 of file strcompat.c.

Referenced by __login_exec(), _build_port_config(), _parse(), acf_curl_exec(), acf_strftime(), acf_vmcount_exec(), add_realm_authentication(), admin_exec(), adsi_load(), adsi_message(), agi_exec_full(), aPGSQL_clear(), aPGSQL_connect(), aPGSQL_disconnect(), aPGSQL_fetch(), aPGSQL_query(), aPGSQL_reset(), append_mailbox(), apply_options(), apply_outgoing(), ast_device_state(), ast_el_strtoarr(), ast_feature_interpret(), ast_fileexists(), ast_filehelper(), ast_get_group(), ast_hint_state_changed(), ast_netsock_bind(), ast_parse_allow_disallow(), ast_parseable_goto(), ast_play_and_prepend(), ast_play_and_record_full(), ast_playtones_start(), ast_read_image(), ast_remotecontrol(), astman_get_variables(), attempt_reconnect(), authenticate_verify(), background_detect_exec(), builtin_function_if(), builtin_function_iftime(), builtin_function_regex(), builtin_function_set(), chanavail_exec(), collect_function_digits(), complete_confcmd(), complete_context_add_ignorepat(), complete_context_add_include(), complete_context_dont_include(), complete_context_remove_extension(), complete_context_remove_ignorepat(), conf_exec(), console_dial(), count_exec(), curl_exec(), cut_exec(), cut_internal(), decrypt_frame(), del_exec(), deltree_exec(), dial_exec_full(), do_directory(), eval_exec(), exec_exec(), exts_compare(), find_conf(), fix_complete_args(), forward_message(), function_fieldqty(), function_ilink(), function_remote(), get_exec(), get_group(), getSearchPath(), gosubif_exec(), handle_common_options(), handle_context_add_extension(), handle_dumpagihtml(), handle_show_dialplan(), has_voicemail(), hasvoicemail_exec(), iax2_register(), ind_load_module(), ivr_dispatch(), leave_voicemail(), load_config(), macro_exec(), make_components(), math_exec(), md5_exec(), messagecount(), misdn_call(), misdn_set_opt_exec(), modem_call(), modem_request(), notify_new_message(), page_exec(), parkandannounce_exec(), parse_dial_string(), pbx_builtin_execiftime(), pbx_builtin_gotoif(), pbx_builtin_gotoiftime(), pbx_builtin_importvar(), pbx_builtin_saynumber(), pbx_builtin_setglobalvar(), pbx_load_module(), peer_set_srcaddr(), process_text_line(), put_exec(), queue_exec(), random_exec(), read_config_maps(), readfile_exec(), realtime_multi_odbc(), realtime_odbc(), record_exec(), reg_source_db(), register_peer_exten(), register_verify(), reload_agents(), reload_queue_members(), reply_digest(), rpt_exec(), rpt_tele_thread(), sayunixtime_exec(), send_tone_telemetry(), sendurl_exec(), set_config_flags(), setup_zap(), sip_getheader(), sip_register(), sip_sipredirect(), softhangup_exec(), sort_exec(), sort_internal(), spawn_ras(), ss_thread(), transmit_state_notify(), verbose_exec(), vmauthenticate(), vpb_request(), zapateller_exec(), and zt_request().

    00009 {
    00010     char* token;
    00011
    00012     if (*str==NULL) {
    00013         /* No more tokens */
    00014         return NULL;
    00015     }
    00016
    00017     token=*str;
    00018     while (**str!='\0') {
    00019         if (strchr(delims,**str)!=NULL) {
    00020             **str='\0';
    00021             (*str)++;
    00022             return token;
    00023         }
    00024         (*str)++;
    00025     }
    00026     /* There is no other token */
    00027     *str=NULL;
    00028     return token;
    00029 }

int unsetenv | ( | const char * | name | ) |

Definition at line 50 of file strcompat.c.

References setenv().

Referenced by builtin_function_env_write().

    00051 {
    00052    return setenv(name, "", 0);
    00053 }