#include "asterisk.h"
#include <ctype.h>
#include <iconv.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
Go to the source code of this file.
Defines | |
#define | AST_ICONV_CAST void * |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | iconv_read (struct ast_channel *chan, const char *cmd, char *arguments, char *buf, size_t len) |
static int | load_module (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Charset conversions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_custom_function | iconv_function |
Definition in file func_iconv.c.
#define AST_ICONV_CAST void * |
Some systems define the second arg to iconv() as (const char *), while others define it as (char *). Cast it to a (void *) to suppress compiler warnings about it.
Definition at line 49 of file func_iconv.c.
Referenced by iconv_read().
static void __reg_module | ( | void | ) | [static] |
Definition at line 124 of file func_iconv.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 124 of file func_iconv.c.
static int iconv_read | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | arguments, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 51 of file func_iconv.c.
References AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, AST_ICONV_CAST, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), errno, LOG_ERROR, LOG_WARNING, parse(), and text.
00052 { 00053 AST_DECLARE_APP_ARGS(args, 00054 AST_APP_ARG(in_charset); 00055 AST_APP_ARG(out_charset); 00056 AST_APP_ARG(text); 00057 ); 00058 iconv_t cd; 00059 size_t incount, outcount = len; 00060 char *parse; 00061 00062 if (ast_strlen_zero(arguments)) { 00063 ast_log(LOG_WARNING, "Syntax: ICONV(<in-charset>,<out-charset>,<text>) - missing arguments!\n"); 00064 return -1; 00065 } 00066 00067 parse = ast_strdupa(arguments); 00068 AST_STANDARD_APP_ARGS(args, parse); 00069 00070 if (args.argc < 3) { 00071 ast_log(LOG_WARNING, "Syntax: ICONV(<in-charset>,<out-charset>,<text>) %d\n", args.argc); 00072 return -1; 00073 } 00074 00075 incount = strlen(args.text); 00076 00077 ast_debug(1, "Iconv: \"%s\" %s -> %s\n", args.text, args.in_charset, args.out_charset); 00078 00079 cd = iconv_open(args.out_charset, args.in_charset); 00080 00081 if (cd == (iconv_t) -1) { 00082 ast_log(LOG_ERROR, "conversion from '%s' to '%s' not available. type 'iconv -l' in a shell to list the supported charsets.\n", args.in_charset, args.out_charset); 00083 return -1; 00084 } 00085 00086 if (iconv(cd, (AST_ICONV_CAST) &args.text, &incount, &buf, &outcount) == (size_t) -1) { 00087 if (errno == E2BIG) 00088 ast_log(LOG_WARNING, "Iconv: output buffer too small.\n"); 00089 else if (errno == EILSEQ) 00090 ast_log(LOG_WARNING, "Iconv: illegal character.\n"); 00091 else if (errno == EINVAL) 00092 ast_log(LOG_WARNING, "Iconv: incomplete character sequence.\n"); 00093 else 00094 ast_log(LOG_WARNING, "Iconv: error %d: %s.\n", errno, strerror(errno)); 00095 } 00096 iconv_close(cd); 00097 00098 return 0; 00099 }
static int load_module | ( | void | ) | [static] |
Definition at line 119 of file func_iconv.c.
References ast_custom_function_register, and iconv_function.
00120 { 00121 return ast_custom_function_register(&iconv_function); 00122 }
static int unload_module | ( | void | ) | [static] |
Definition at line 114 of file func_iconv.c.
References ast_custom_function_unregister(), and iconv_function.
00115 { 00116 return ast_custom_function_unregister(&iconv_function); 00117 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Charset conversions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 124 of file func_iconv.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 124 of file func_iconv.c.
struct ast_custom_function iconv_function [static] |