[asterisk-commits] branch kpfleming/chanfunc r9672 - in
/team/kpfleming/chanfunc: formats/ funcs/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sat Feb 11 21:20:45 MST 2006
Author: kpfleming
Date: Sat Feb 11 22:20:43 2006
New Revision: 9672
URL: http://svn.digium.com/view/asterisk?rev=9672&view=rev
Log:
repair formatting in files that were formatted using spaces
remove emacs formatting tags (especially broken ones)
Modified:
team/kpfleming/chanfunc/formats/format_ogg_vorbis.c
team/kpfleming/chanfunc/funcs/func_base64.c
team/kpfleming/chanfunc/funcs/func_callerid.c
team/kpfleming/chanfunc/funcs/func_cdr.c
team/kpfleming/chanfunc/funcs/func_db.c
team/kpfleming/chanfunc/funcs/func_enum.c
team/kpfleming/chanfunc/funcs/func_env.c
team/kpfleming/chanfunc/funcs/func_groupcount.c
team/kpfleming/chanfunc/funcs/func_language.c
team/kpfleming/chanfunc/funcs/func_logic.c
team/kpfleming/chanfunc/funcs/func_math.c
team/kpfleming/chanfunc/funcs/func_md5.c
team/kpfleming/chanfunc/funcs/func_moh.c
team/kpfleming/chanfunc/funcs/func_rand.c
team/kpfleming/chanfunc/funcs/func_sha1.c
team/kpfleming/chanfunc/funcs/func_strings.c
team/kpfleming/chanfunc/funcs/func_timeout.c
team/kpfleming/chanfunc/funcs/func_uri.c
Modified: team/kpfleming/chanfunc/formats/format_ogg_vorbis.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/formats/format_ogg_vorbis.c?rev=9672&r1=9671&r2=9672&view=diff
==============================================================================
--- team/kpfleming/chanfunc/formats/format_ogg_vorbis.c (original)
+++ team/kpfleming/chanfunc/formats/format_ogg_vorbis.c Sat Feb 11 22:20:43 2006
@@ -20,7 +20,7 @@
* \arg File name extension: ogg
* \ingroup formats
*/
-
+
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -48,37 +48,35 @@
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
-
#define SAMPLES_MAX 160
#define BLOCK_SIZE 4096
-
struct ast_filestream {
void *reserved[AST_RESERVED_POINTERS];
-
+
FILE *f;
-
+
/* structures for handling the Ogg container */
- ogg_sync_state oy;
+ ogg_sync_state oy;
ogg_stream_state os;
- ogg_page og;
- ogg_packet op;
+ ogg_page og;
+ ogg_packet op;
/* structures for handling Vorbis audio data */
- vorbis_info vi;
- vorbis_comment vc;
+ vorbis_info vi;
+ vorbis_comment vc;
vorbis_dsp_state vd;
- vorbis_block vb;
+ vorbis_block vb;
/*! \brief Indicates whether this filestream is set up for reading or writing. */
int writing;
-
+
/*! \brief Indicates whether an End of Stream condition has been detected. */
int eos;
-
+
/*! \brief Buffer to hold audio data. */
short buffer[SAMPLES_MAX];
-
+
/*! \brief Asterisk frame object. */
struct ast_frame fr;
char waste[AST_FRIENDLY_OFFSET];
@@ -86,6 +84,7 @@
};
AST_MUTEX_DEFINE_STATIC(ogg_vorbis_lock);
+
static int glistcnt = 0;
static char *name = "ogg_vorbis";
@@ -97,7 +96,7 @@
* \param f File that points to on disk storage of the OGG/Vorbis data.
* \return The new filestream.
*/
-static struct ast_filestream *ogg_vorbis_open(FILE *f)
+static struct ast_filestream *ogg_vorbis_open(FILE * f)
{
int i;
int bytes;
@@ -107,7 +106,7 @@
struct ast_filestream *tmp;
- if((tmp = malloc(sizeof(struct ast_filestream)))) {
+ if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
tmp->writing = 0;
@@ -120,24 +119,26 @@
ogg_sync_wrote(&tmp->oy, bytes);
result = ogg_sync_pageout(&tmp->oy, &tmp->og);
- if(result != 1) {
- if(bytes < BLOCK_SIZE) {
+ if (result != 1) {
+ if (bytes < BLOCK_SIZE) {
ast_log(LOG_ERROR, "Run out of data...\n");
} else {
- ast_log(LOG_ERROR, "Input does not appear to be an Ogg bitstream.\n");
+ ast_log(LOG_ERROR,
+ "Input does not appear to be an Ogg bitstream.\n");
}
fclose(f);
ogg_sync_clear(&tmp->oy);
free(tmp);
return NULL;
}
-
+
ogg_stream_init(&tmp->os, ogg_page_serialno(&tmp->og));
vorbis_info_init(&tmp->vi);
vorbis_comment_init(&tmp->vc);
- if(ogg_stream_pagein(&tmp->os, &tmp->og) < 0) {
- ast_log(LOG_ERROR, "Error reading first page of Ogg bitstream data.\n");
+ if (ogg_stream_pagein(&tmp->os, &tmp->og) < 0) {
+ ast_log(LOG_ERROR,
+ "Error reading first page of Ogg bitstream data.\n");
fclose(f);
ogg_stream_clear(&tmp->os);
vorbis_comment_clear(&tmp->vc);
@@ -146,8 +147,8 @@
free(tmp);
return NULL;
}
-
- if(ogg_stream_packetout(&tmp->os, &tmp->op) != 1) {
+
+ if (ogg_stream_packetout(&tmp->os, &tmp->op) != 1) {
ast_log(LOG_ERROR, "Error reading initial header packet.\n");
fclose(f);
ogg_stream_clear(&tmp->os);
@@ -157,8 +158,8 @@
free(tmp);
return NULL;
}
-
- if(vorbis_synthesis_headerin(&tmp->vi, &tmp->vc, &tmp->op) < 0) {
+
+ if (vorbis_synthesis_headerin(&tmp->vi, &tmp->vc, &tmp->op) < 0) {
ast_log(LOG_ERROR, "This Ogg bitstream does not contain Vorbis audio data.\n");
fclose(f);
ogg_stream_clear(&tmp->os);
@@ -168,20 +169,20 @@
free(tmp);
return NULL;
}
-
+
i = 0;
- while(i < 2) {
- while(i < 2){
+ while (i < 2) {
+ while (i < 2) {
result = ogg_sync_pageout(&tmp->oy, &tmp->og);
- if(result == 0)
+ if (result == 0)
break;
- if(result == 1) {
+ if (result == 1) {
ogg_stream_pagein(&tmp->os, &tmp->og);
- while(i < 2) {
- result = ogg_stream_packetout(&tmp->os,&tmp->op);
- if(result == 0)
+ while (i < 2) {
+ result = ogg_stream_packetout(&tmp->os, &tmp->op);
+ if (result == 0)
break;
- if(result < 0) {
+ if (result < 0) {
ast_log(LOG_ERROR, "Corrupt secondary header. Exiting.\n");
fclose(f);
ogg_stream_clear(&tmp->os);
@@ -199,7 +200,7 @@
buffer = ogg_sync_buffer(&tmp->oy, BLOCK_SIZE);
bytes = fread(buffer, 1, BLOCK_SIZE, f);
- if(bytes == 0 && i < 2) {
+ if (bytes == 0 && i < 2) {
ast_log(LOG_ERROR, "End of file before finding all Vorbis headers!\n");
fclose(f);
ogg_stream_clear(&tmp->os);
@@ -211,16 +212,18 @@
}
ogg_sync_wrote(&tmp->oy, bytes);
}
-
+
ptr = tmp->vc.user_comments;
- while(*ptr){
+ while (*ptr) {
ast_log(LOG_DEBUG, "OGG/Vorbis comment: %s\n", *ptr);
++ptr;
}
- ast_log(LOG_DEBUG, "OGG/Vorbis bitstream is %d channel, %ldHz\n", tmp->vi.channels, tmp->vi.rate);
- ast_log(LOG_DEBUG, "OGG/Vorbis file encoded by: %s\n", tmp->vc.vendor);
-
- if(tmp->vi.channels != 1) {
+ ast_log(LOG_DEBUG, "OGG/Vorbis bitstream is %d channel, %ldHz\n",
+ tmp->vi.channels, tmp->vi.rate);
+ ast_log(LOG_DEBUG, "OGG/Vorbis file encoded by: %s\n",
+ tmp->vc.vendor);
+
+ if (tmp->vi.channels != 1) {
ast_log(LOG_ERROR, "Only monophonic OGG/Vorbis files are currently supported!\n");
ogg_stream_clear(&tmp->os);
vorbis_comment_clear(&tmp->vc);
@@ -229,9 +232,8 @@
free(tmp);
return NULL;
}
-
-
- if(tmp->vi.rate != 8000) {
+
+ if (tmp->vi.rate != 8000) {
ast_log(LOG_ERROR, "Only 8000Hz OGG/Vorbis files are currently supported!\n");
fclose(f);
ogg_stream_clear(&tmp->os);
@@ -243,11 +245,11 @@
free(tmp);
return NULL;
}
-
+
vorbis_synthesis_init(&tmp->vd, &tmp->vi);
vorbis_block_init(&tmp->vd, &tmp->vb);
- if(ast_mutex_lock(&ogg_vorbis_lock)) {
+ if (ast_mutex_lock(&ogg_vorbis_lock)) {
ast_log(LOG_WARNING, "Unable to lock ogg_vorbis list\n");
fclose(f);
ogg_stream_clear(&tmp->os);
@@ -272,7 +274,8 @@
* \param comment Comment that should be embedded in the OGG/Vorbis file.
* \return A new filestream.
*/
-static struct ast_filestream *ogg_vorbis_rewrite(FILE *f, const char *comment)
+static struct ast_filestream *ogg_vorbis_rewrite(FILE * f,
+ const char *comment)
{
ogg_packet header;
ogg_packet header_comm;
@@ -280,7 +283,7 @@
struct ast_filestream *tmp;
- if((tmp = malloc(sizeof(struct ast_filestream)))) {
+ if ((tmp = malloc(sizeof(struct ast_filestream)))) {
memset(tmp, 0, sizeof(struct ast_filestream));
tmp->writing = 1;
@@ -288,7 +291,7 @@
vorbis_info_init(&tmp->vi);
- if(vorbis_encode_init_vbr(&tmp->vi, 1, 8000, 0.4)) {
+ if (vorbis_encode_init_vbr(&tmp->vi, 1, 8000, 0.4)) {
ast_log(LOG_ERROR, "Unable to initialize Vorbis encoder!\n");
free(tmp);
return NULL;
@@ -296,7 +299,7 @@
vorbis_comment_init(&tmp->vc);
vorbis_comment_add_tag(&tmp->vc, "ENCODER", "Asterisk PBX");
- if(comment)
+ if (comment)
vorbis_comment_add_tag(&tmp->vc, "COMMENT", (char *) comment);
vorbis_analysis_init(&tmp->vd, &tmp->vi);
@@ -304,21 +307,22 @@
ogg_stream_init(&tmp->os, rand());
- vorbis_analysis_headerout(&tmp->vd, &tmp->vc, &header, &header_comm, &header_code);
- ogg_stream_packetin(&tmp->os, &header);
+ vorbis_analysis_headerout(&tmp->vd, &tmp->vc, &header, &header_comm,
+ &header_code);
+ ogg_stream_packetin(&tmp->os, &header);
ogg_stream_packetin(&tmp->os, &header_comm);
ogg_stream_packetin(&tmp->os, &header_code);
- while(!tmp->eos) {
- if(ogg_stream_flush(&tmp->os, &tmp->og) == 0)
+ while (!tmp->eos) {
+ if (ogg_stream_flush(&tmp->os, &tmp->og) == 0)
break;
fwrite(tmp->og.header, 1, tmp->og.header_len, tmp->f);
fwrite(tmp->og.body, 1, tmp->og.body_len, tmp->f);
- if(ogg_page_eos(&tmp->og))
+ if (ogg_page_eos(&tmp->og))
tmp->eos = 1;
}
- if(ast_mutex_lock(&ogg_vorbis_lock)) {
+ if (ast_mutex_lock(&ogg_vorbis_lock)) {
ast_log(LOG_WARNING, "Unable to lock ogg_vorbis list\n");
fclose(f);
ogg_stream_clear(&tmp->os);
@@ -345,16 +349,16 @@
while (vorbis_analysis_blockout(&s->vd, &s->vb) == 1) {
vorbis_analysis(&s->vb, NULL);
vorbis_bitrate_addblock(&s->vb);
-
+
while (vorbis_bitrate_flushpacket(&s->vd, &s->op)) {
ogg_stream_packetin(&s->os, &s->op);
while (!s->eos) {
- if(ogg_stream_pageout(&s->os, &s->og) == 0) {
+ if (ogg_stream_pageout(&s->os, &s->og) == 0) {
break;
}
fwrite(s->og.header, 1, s->og.header_len, s->f);
fwrite(s->og.body, 1, s->og.body_len, s->f);
- if(ogg_page_eos(&s->og)) {
+ if (ogg_page_eos(&s->og)) {
s->eos = 1;
}
}
@@ -374,20 +378,21 @@
float **buffer;
short *data;
- if(!s->writing) {
+ if (!s->writing) {
ast_log(LOG_ERROR, "This stream is not set up for writing!\n");
return -1;
}
- if(f->frametype != AST_FRAME_VOICE) {
+ if (f->frametype != AST_FRAME_VOICE) {
ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
return -1;
}
- if(f->subclass != AST_FORMAT_SLINEAR) {
- ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%d)!\n", f->subclass);
+ if (f->subclass != AST_FORMAT_SLINEAR) {
+ ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%d)!\n",
+ f->subclass);
return -1;
}
- if(!f->datalen)
+ if (!f->datalen)
return -1;
data = (short *) f->data;
@@ -395,7 +400,7 @@
buffer = vorbis_analysis_buffer(&s->vd, f->samples);
for (i = 0; i < f->samples; i++) {
- buffer[0][i] = data[i]/32768.f;
+ buffer[0][i] = data[i] / 32768.f;
}
vorbis_analysis_wrote(&s->vd, f->samples);
@@ -411,7 +416,7 @@
*/
static void ogg_vorbis_close(struct ast_filestream *s)
{
- if(ast_mutex_lock(&ogg_vorbis_lock)) {
+ if (ast_mutex_lock(&ogg_vorbis_lock)) {
ast_log(LOG_WARNING, "Unable to lock ogg_vorbis list\n");
return;
}
@@ -419,7 +424,7 @@
ast_mutex_unlock(&ogg_vorbis_lock);
ast_update_use_count();
- if(s->writing) {
+ if (s->writing) {
/* Tell the Vorbis encoder that the stream is finished
* and write out the rest of the data */
vorbis_analysis_wrote(&s->vd, 0);
@@ -432,10 +437,10 @@
vorbis_comment_clear(&s->vc);
vorbis_info_clear(&s->vi);
- if(s->writing) {
+ if (s->writing) {
ogg_sync_clear(&s->oy);
}
-
+
fclose(s->f);
free(s);
}
@@ -455,28 +460,29 @@
while (1) {
samples_in = vorbis_synthesis_pcmout(&s->vd, pcm);
- if(samples_in > 0) {
+ if (samples_in > 0) {
return samples_in;
}
-
+
/* The Vorbis decoder needs more data... */
/* See ifOGG has any packets in the current page for the Vorbis decoder. */
result = ogg_stream_packetout(&s->os, &s->op);
- if(result > 0) {
+ if (result > 0) {
/* Yes OGG had some more packets for the Vorbis decoder. */
- if(vorbis_synthesis(&s->vb, &s->op) == 0) {
+ if (vorbis_synthesis(&s->vb, &s->op) == 0) {
vorbis_synthesis_blockin(&s->vd, &s->vb);
}
-
+
continue;
}
- if(result < 0)
- ast_log(LOG_WARNING, "Corrupt or missing data at this page position; continuing...\n");
-
+ if (result < 0)
+ ast_log(LOG_WARNING,
+ "Corrupt or missing data at this page position; continuing...\n");
+
/* No more packets left in the current page... */
- if(s->eos) {
+ if (s->eos) {
/* No more pages left in the stream */
return -1;
}
@@ -484,22 +490,24 @@
while (!s->eos) {
/* See ifOGG has any pages in it's internal buffers */
result = ogg_sync_pageout(&s->oy, &s->og);
- if(result > 0) {
+ if (result > 0) {
/* Yes, OGG has more pages in it's internal buffers,
add the page to the stream state */
result = ogg_stream_pagein(&s->os, &s->og);
- if(result == 0) {
+ if (result == 0) {
/* Yes, got a new,valid page */
- if(ogg_page_eos(&s->og)) {
+ if (ogg_page_eos(&s->og)) {
s->eos = 1;
}
break;
}
- ast_log(LOG_WARNING, "Invalid page in the bitstream; continuing...\n");
- }
-
- if(result < 0)
- ast_log(LOG_WARNING, "Corrupt or missing data in bitstream; continuing...\n");
+ ast_log(LOG_WARNING,
+ "Invalid page in the bitstream; continuing...\n");
+ }
+
+ if (result < 0)
+ ast_log(LOG_WARNING,
+ "Corrupt or missing data in bitstream; continuing...\n");
/* No, we need to read more data from the file descrptor */
/* get a buffer from OGG to read the data into */
@@ -508,7 +516,7 @@
bytes = fread(buffer, 1, BLOCK_SIZE, s->f);
/* Tell OGG how many bytes we actually read into the buffer */
ogg_sync_wrote(&s->oy, bytes);
- if(bytes == 0) {
+ if (bytes == 0) {
s->eos = 1;
}
}
@@ -521,7 +529,8 @@
* \param whennext Number of sample times to schedule the next call.
* \return A pointer to a frame containing audio data or NULL ifthere is no more audio data.
*/
-static struct ast_frame *ogg_vorbis_read(struct ast_filestream *s, int *whennext)
+static struct ast_frame *ogg_vorbis_read(struct ast_filestream *s,
+ int *whennext)
{
int clipflag = 0;
int i;
@@ -535,25 +544,25 @@
while (1) {
/* See ifwe have filled up an audio frame yet */
- if(samples_out == SAMPLES_MAX)
+ if (samples_out == SAMPLES_MAX)
break;
/* See ifVorbis decoder has some audio data for us ... */
samples_in = read_samples(s, &pcm);
- if(samples_in <= 0)
+ if (samples_in <= 0)
break;
/* Got some audio data from Vorbis... */
/* Convert the float audio data to 16-bit signed linear */
-
+
clipflag = 0;
samples_in = samples_in < (SAMPLES_MAX - samples_out) ? samples_in : (SAMPLES_MAX - samples_out);
-
- for(j = 0; j < samples_in; j++)
+
+ for (j = 0; j < samples_in; j++)
accumulator[j] = 0.0;
- for(i = 0; i < s->vi.channels; i++) {
+ for (i = 0; i < s->vi.channels; i++) {
mono = pcm[i];
for (j = 0; j < samples_in; j++) {
accumulator[j] += mono[j];
@@ -561,27 +570,26 @@
}
for (j = 0; j < samples_in; j++) {
- val = accumulator[j] * 32767.0 / s->vi.channels;
- if(val > 32767) {
+ val = accumulator[j] * 32767.0 / s->vi.channels;
+ if (val > 32767) {
val = 32767;
clipflag = 1;
}
- if(val < -32768) {
+ if (val < -32768) {
val = -32768;
clipflag = 1;
}
s->buffer[samples_out + j] = val;
}
-
- if(clipflag)
- ast_log(LOG_WARNING, "Clipping in frame %ld\n", (long)(s->vd.sequence));
-
+
+ if (clipflag)
+ ast_log(LOG_WARNING, "Clipping in frame %ld\n", (long) (s->vd.sequence));
/* Tell the Vorbis decoder how many samples we actually used. */
vorbis_synthesis_read(&s->vd, samples_in);
samples_out += samples_in;
}
- if(samples_out > 0) {
+ if (samples_out > 0) {
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_SLINEAR;
s->fr.offset = AST_FRIENDLY_OFFSET;
@@ -591,7 +599,7 @@
s->fr.mallocd = 0;
s->fr.samples = samples_out;
*whennext = samples_out;
-
+
return &s->fr;
} else {
return NULL;
@@ -618,17 +626,21 @@
* \return 0 on success, -1 on failure.
*/
-static int ogg_vorbis_seek(struct ast_filestream *s, long sample_offset, int whence) {
+static int ogg_vorbis_seek(struct ast_filestream *s, long sample_offset,
+ int whence)
+{
ast_log(LOG_WARNING, "Seeking is not supported on OGG/Vorbis streams!\n");
return -1;
}
-static long ogg_vorbis_tell(struct ast_filestream *s) {
+static long ogg_vorbis_tell(struct ast_filestream *s)
+{
ast_log(LOG_WARNING, "Telling is not supported on OGG/Vorbis streams!\n");
return -1;
}
-static char *ogg_vorbis_getcomment(struct ast_filestream *s) {
+static char *ogg_vorbis_getcomment(struct ast_filestream *s)
+{
ast_log(LOG_WARNING, "Getting comments is not supported on OGG/Vorbis streams!\n");
return NULL;
}
@@ -650,7 +662,7 @@
int unload_module()
{
return ast_format_unregister(name);
-}
+}
int usecount()
{
@@ -667,11 +679,3 @@
{
return ASTERISK_GPL_KEY;
}
-
-/*
-Local Variables:
-mode: C
-c-file-style: "linux"
-indent-tabs-mode: t
-End:
-*/
Modified: team/kpfleming/chanfunc/funcs/func_base64.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_base64.c?rev=9672&r1=9671&r2=9672&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_base64.c (original)
+++ team/kpfleming/chanfunc/funcs/func_base64.c Sat Feb 11 22:20:43 2006
@@ -36,21 +36,23 @@
#include "asterisk/utils.h"
#include "asterisk/app.h"
-static int base64_encode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int base64_encode(struct ast_channel *chan, char *cmd, char *data,
+ char *buf, size_t len)
{
- if (ast_strlen_zero(data) ) {
+ if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Syntax: BASE64_ENCODE(<data>) - missing argument!\n");
return -1;
}
- ast_base64encode(buf, (unsigned char *)data, strlen(data), len);
+ ast_base64encode(buf, (unsigned char *) data, strlen(data), len);
return 0;
}
-static int base64_decode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int base64_decode(struct ast_channel *chan, char *cmd, char *data,
+ char *buf, size_t len)
{
- if (ast_strlen_zero(data) ) {
+ if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Syntax: BASE64_DECODE(<base_64 string>) - missing argument!\n");
return -1;
}
@@ -80,13 +82,13 @@
int unload_module(void)
{
- return ast_custom_function_unregister(&base64_encode_function) ||
+ return ast_custom_function_unregister(&base64_encode_function) |
ast_custom_function_unregister(&base64_decode_function);
}
int load_module(void)
{
- return ast_custom_function_register(&base64_encode_function) ||
+ return ast_custom_function_register(&base64_encode_function) |
ast_custom_function_register(&base64_decode_function);
}
@@ -104,11 +106,3 @@
{
return ASTERISK_GPL_KEY;
}
-
-/*
-Local Variables:
-mode: C
-c-file-style: "linux"
-indent-tabs-mode: nil
-End:
-*/
Modified: team/kpfleming/chanfunc/funcs/func_callerid.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_callerid.c?rev=9672&r1=9671&r2=9672&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_callerid.c (original)
+++ team/kpfleming/chanfunc/funcs/func_callerid.c Sat Feb 11 22:20:43 2006
@@ -28,7 +28,6 @@
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
@@ -38,7 +37,8 @@
#include "asterisk/options.h"
#include "asterisk/callerid.h"
-static int callerid_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int callerid_read(struct ast_channel *chan, char *cmd, char *data,
+ char *buf, size_t len)
{
char *opt = data;
@@ -49,22 +49,27 @@
ast_callerid_split(opt, name, sizeof(name), num, sizeof(num));
if (!strncasecmp("all", data, 3)) {
- snprintf(buf, len, "\"%s\" <%s>", name, num);
+ snprintf(buf, len, "\"%s\" <%s>", name, num);
} else if (!strncasecmp("name", data, 4)) {
ast_copy_string(buf, name, len);
- } else if (!strncasecmp("num", data, 3) || !strncasecmp("number", data, 6)) {
+ } else if (!strncasecmp("num", data, 3) ||
+ !strncasecmp("number", data, 6)) {
+
ast_copy_string(buf, num, len);
} else {
ast_log(LOG_ERROR, "Unknown callerid data type.\n");
}
} else {
if (!strncasecmp("all", data, 3)) {
- snprintf(buf, len, "\"%s\" <%s>", chan->cid.cid_name ? chan->cid.cid_name : "", chan->cid.cid_num ? chan->cid.cid_num : "");
+ snprintf(buf, len, "\"%s\" <%s>",
+ chan->cid.cid_name ? chan->cid.cid_name : "",
+ chan->cid.cid_num ? chan->cid.cid_num : "");
} else if (!strncasecmp("name", data, 4)) {
if (chan->cid.cid_name) {
ast_copy_string(buf, chan->cid.cid_name, len);
}
- } else if (!strncasecmp("num", data, 3) || !strncasecmp("number", data, 6)) {
+ } else if (!strncasecmp("num", data, 3)
+ || !strncasecmp("number", data, 6)) {
if (chan->cid.cid_num) {
ast_copy_string(buf, chan->cid.cid_num, len);
}
@@ -88,47 +93,50 @@
return 0;
}
-static int callerid_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
+static int callerid_write(struct ast_channel *chan, char *cmd, char *data,
+ const char *value)
{
if (!value)
- return -1;
-
+ return -1;
+
if (!strncasecmp("all", data, 3)) {
char name[256];
char num[256];
if (!ast_callerid_split(value, name, sizeof(name), num, sizeof(num)))
- ast_set_callerid(chan, num, name, num);
- } else if (!strncasecmp("name", data, 4)) {
- ast_set_callerid(chan, NULL, value, NULL);
- } else if (!strncasecmp("num", data, 3) || !strncasecmp("number", data, 6)) {
- ast_set_callerid(chan, value, NULL, NULL);
- } else if (!strncasecmp("ani", data, 3)) {
- ast_set_callerid(chan, NULL, NULL, value);
- } else if (!strncasecmp("dnid", data, 4)) {
- /* do we need to lock chan here? */
- if (chan->cid.cid_dnid)
- free(chan->cid.cid_dnid);
- chan->cid.cid_dnid = ast_strlen_zero(value) ? NULL : strdup(value);
- } else if (!strncasecmp("rdnis", data, 5)) {
- /* do we need to lock chan here? */
- if (chan->cid.cid_rdnis)
- free(chan->cid.cid_rdnis);
- chan->cid.cid_rdnis = ast_strlen_zero(value) ? NULL : strdup(value);
- } else {
- ast_log(LOG_ERROR, "Unknown callerid data type.\n");
- }
+ ast_set_callerid(chan, num, name, num);
+ } else if (!strncasecmp("name", data, 4)) {
+ ast_set_callerid(chan, NULL, value, NULL);
+ } else if (!strncasecmp("num", data, 3) ||
+ !strncasecmp("number", data, 6)) {
+ ast_set_callerid(chan, value, NULL, NULL);
+ } else if (!strncasecmp("ani", data, 3)) {
+ ast_set_callerid(chan, NULL, NULL, value);
+ } else if (!strncasecmp("dnid", data, 4)) {
+ /* do we need to lock chan here? */
+ if (chan->cid.cid_dnid)
+ free(chan->cid.cid_dnid);
+ chan->cid.cid_dnid = ast_strlen_zero(value) ? NULL : strdup(value);
+ } else if (!strncasecmp("rdnis", data, 5)) {
+ /* do we need to lock chan here? */
+ if (chan->cid.cid_rdnis)
+ free(chan->cid.cid_rdnis);
+ chan->cid.cid_rdnis = ast_strlen_zero(value) ? NULL : strdup(value);
+ } else {
+ ast_log(LOG_ERROR, "Unknown callerid data type.\n");
+ }
- return 0;
+ return 0;
}
static struct ast_custom_function callerid_function = {
.name = "CALLERID",
.synopsis = "Gets or sets Caller*ID data on the channel.",
.syntax = "CALLERID(datatype[,<optional-CID>])",
- .desc = "Gets or sets Caller*ID data on the channel. The allowable datatypes\n"
- "are \"all\", \"name\", \"num\", \"ANI\", \"DNID\", \"RDNIS\".\n"
- "Uses channel callerid by default or optional callerid, if specified.\n",
+ .desc =
+ "Gets or sets Caller*ID data on the channel. The allowable datatypes\n"
+ "are \"all\", \"name\", \"num\", \"ANI\", \"DNID\", \"RDNIS\".\n"
+ "Uses channel callerid by default or optional callerid, if specified.\n",
.read = callerid_read,
.write = callerid_write,
};
@@ -137,12 +145,12 @@
int unload_module(void)
{
- return ast_custom_function_unregister(&callerid_function);
+ return ast_custom_function_unregister(&callerid_function);
}
int load_module(void)
{
- return ast_custom_function_register(&callerid_function);
+ return ast_custom_function_register(&callerid_function);
}
char *description(void)
@@ -159,11 +167,3 @@
{
return ASTERISK_GPL_KEY;
}
-
-/*
-Local Variables:
-mode: C
-c-file-style: "linux"
-indent-tabs-mode: nil
-End:
-*/
Modified: team/kpfleming/chanfunc/funcs/func_cdr.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_cdr.c?rev=9672&r1=9671&r2=9672&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_cdr.c (original)
+++ team/kpfleming/chanfunc/funcs/func_cdr.c Sat Feb 11 22:20:43 2006
@@ -47,42 +47,45 @@
AST_APP_OPTION('r', OPT_RECURSIVE),
});
-static int cdr_read(struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len)
+static int cdr_read(struct ast_channel *chan, char *cmd, char *parse,
+ char *buf, size_t len)
{
- char *ret;
- struct ast_flags flags = {0};
+ char *ret;
+ struct ast_flags flags = { 0 };
AST_DECLARE_APP_ARGS(args,
- AST_APP_ARG(variable);
- AST_APP_ARG(options);
+ AST_APP_ARG(variable);
+ AST_APP_ARG(options);
);
if (ast_strlen_zero(parse))
return -1;
-
+
if (!chan->cdr)
return -1;
AST_STANDARD_APP_ARGS(args, parse);
-
+
if (!ast_strlen_zero(args.options))
ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
- ast_cdr_getvar(chan->cdr, args.variable, &ret, buf, len, ast_test_flag(&flags, OPT_RECURSIVE));
+ ast_cdr_getvar(chan->cdr, args.variable, &ret, buf, len,
+ ast_test_flag(&flags, OPT_RECURSIVE));
return 0;
}
-static int cdr_write(struct ast_channel *chan, char *cmd, char *parse, const char *value)
+static int cdr_write(struct ast_channel *chan, char *cmd, char *parse,
+ const char *value)
{
- struct ast_flags flags = {0};
- AST_DECLARE_APP_ARGS(args,
- AST_APP_ARG(variable);
- AST_APP_ARG(options);
- );
+ struct ast_flags flags = { 0 };
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(variable);
+ AST_APP_ARG(options);
+ );
if (ast_strlen_zero(parse) || !value)
return -1;
-
+
AST_STANDARD_APP_ARGS(args, parse);
if (!ast_strlen_zero(args.options))
@@ -93,15 +96,16 @@
else if (!strcasecmp(args.variable, "userfield"))
ast_cdr_setuserfield(chan, value);
else if (chan->cdr)
- ast_cdr_setvar(chan->cdr, args.variable, value, ast_test_flag(&flags, OPT_RECURSIVE));
+ ast_cdr_setvar(chan->cdr, args.variable, value,
+ ast_test_flag(&flags, OPT_RECURSIVE));
- return 0;
+ return 0;
}
static struct ast_custom_function cdr_function = {
.name = "CDR",
.synopsis = "Gets or sets a CDR variable",
- .desc= "Option 'r' searches the entire stack of CDRs on the channel\n",
+ .desc = "Option 'r' searches the entire stack of CDRs on the channel\n",
.syntax = "CDR(<name>[|options])",
.read = cdr_read,
.write = cdr_write,
@@ -111,12 +115,12 @@
int unload_module(void)
{
- return ast_custom_function_unregister(&cdr_function);
+ return ast_custom_function_unregister(&cdr_function);
}
int load_module(void)
{
- return ast_custom_function_register(&cdr_function);
+ return ast_custom_function_register(&cdr_function);
}
char *description(void)
@@ -133,11 +137,3 @@
{
return ASTERISK_GPL_KEY;
}
-
-/*
-Local Variables:
-mode: C
-c-file-style: "linux"
-indent-tabs-mode: nil
-End:
-*/
Modified: team/kpfleming/chanfunc/funcs/func_db.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_db.c?rev=9672&r1=9671&r2=9672&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_db.c (original)
+++ team/kpfleming/chanfunc/funcs/func_db.c Sat Feb 11 22:20:43 2006
@@ -43,11 +43,12 @@
#include "asterisk/app.h"
#include "asterisk/astdb.h"
-static int function_db_read(struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len)
+static int function_db_read(struct ast_channel *chan, char *cmd,
+ char *parse, char *buf, size_t len)
{
AST_DECLARE_APP_ARGS(args,
- AST_APP_ARG(family);
- AST_APP_ARG(key);
+ AST_APP_ARG(family);
+ AST_APP_ARG(key);
);
buf[0] = '\0';
@@ -58,25 +59,27 @@
}
AST_NONSTANDARD_APP_ARGS(args, parse, '/');
-
+
if (args.argc < 2) {
ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)\n");
return -1;
}
- if (ast_db_get(args.family, args.key, buf, len-1)) {
- ast_log(LOG_DEBUG, "DB: %s/%s not found in database.\n", args.family, args.key);
+ if (ast_db_get(args.family, args.key, buf, len - 1)) {
+ ast_log(LOG_DEBUG, "DB: %s/%s not found in database.\n", args.family,
+ args.key);
} else
pbx_builtin_setvar_helper(chan, "DB_RESULT", buf);
return 0;
}
-static int function_db_write(struct ast_channel *chan, char *cmd, char *parse, const char *value)
+static int function_db_write(struct ast_channel *chan, char *cmd, char *parse,
+ const char *value)
{
AST_DECLARE_APP_ARGS(args,
- AST_APP_ARG(family);
- AST_APP_ARG(key);
+ AST_APP_ARG(family);
+ AST_APP_ARG(key);
);
if (ast_strlen_zero(parse)) {
@@ -91,7 +94,7 @@
return -1;
}
- if (ast_db_put(args.family, args.key, (char*)value))
+ if (ast_db_put(args.family, args.key, (char *) value))
ast_log(LOG_WARNING, "DB: Error writing value to database.\n");
return 0;
@@ -101,7 +104,8 @@
.name = "DB",
.synopsis = "Read or Write from/to the Asterisk database",
.syntax = "DB(<family>/<key>)",
- .desc = "This function will read or write a value from/to the Asterisk database.\n"
+ .desc =
+ "This function will read or write a value from/to the Asterisk database.\n"
"DB(...) will read a value from the database, while DB(...)=value\n"
"will write a value to the database. On a read, this function\n"
"returns the value from the datase, or NULL if it does not exist.\n"
@@ -111,11 +115,12 @@
.write = function_db_write,
};
-static int function_db_exists(struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len)
+static int function_db_exists(struct ast_channel *chan, char *cmd,
+ char *parse, char *buf, size_t len)
{
AST_DECLARE_APP_ARGS(args,
- AST_APP_ARG(family);
- AST_APP_ARG(key);
+ AST_APP_ARG(family);
+ AST_APP_ARG(key);
);
buf[0] = '\0';
@@ -126,19 +131,19 @@
}
AST_NONSTANDARD_APP_ARGS(args, parse, '/');
-
+
if (args.argc < 2) {
ast_log(LOG_WARNING, "DB_EXISTS requires an argument, DB(<family>/<key>)\n");
return -1;
}
- if (ast_db_get(args.family, args.key, buf, len-1))
+ if (ast_db_get(args.family, args.key, buf, len - 1))
strcpy(buf, "0");
else {
pbx_builtin_setvar_helper(chan, "DB_RESULT", buf);
strcpy(buf, "1");
}
-
+
return 0;
}
@@ -146,7 +151,8 @@
.name = "DB_EXISTS",
.synopsis = "Check to see if a key exists in the Asterisk database",
.syntax = "DB_EXISTS(<family>/<key>)",
- .desc = "This function will check to see if a key exists in the Asterisk\n"
+ .desc =
+ "This function will check to see if a key exists in the Asterisk\n"
"database. If it exists, the function will return \"1\". If not,\n"
"it will return \"0\". Checking for existence of a database key will\n"
"also set the variable DB_RESULT to the key's value if it exists.\n",
@@ -158,7 +164,7 @@
int unload_module(void)
{
int res = 0;
-
+
res |= ast_custom_function_unregister(&db_function);
res |= ast_custom_function_unregister(&db_exists_function);
@@ -168,7 +174,7 @@
int load_module(void)
{
int res = 0;
-
+
res |= ast_custom_function_register(&db_function);
res |= ast_custom_function_register(&db_exists_function);
@@ -177,7 +183,7 @@
char *description(void)
{
- return tdesc;
+ return tdesc;
}
int usecount(void)
@@ -187,6 +193,5 @@
char *key()
{
- return ASTERISK_GPL_KEY;
+ return ASTERISK_GPL_KEY;
}
-
Modified: team/kpfleming/chanfunc/funcs/func_enum.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_enum.c?rev=9672&r1=9671&r2=9672&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_enum.c (original)
+++ team/kpfleming/chanfunc/funcs/func_enum.c Sat Feb 11 22:20:43 2006
@@ -48,13 +48,14 @@
#include "asterisk/enum.h"
#include "asterisk/app.h"
-static char* synopsis = "Syntax: ENUMLOOKUP(number[|Method-type[|options[|record#[|zone-suffix]]]])\n";
+ static char *synopsis = "Syntax: ENUMLOOKUP(number[|Method-type[|options[|record#[|zone-suffix]]]])\n";
STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
-static int function_enum(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int function_enum(struct ast_channel *chan, char *cmd, char *data,
+ char *buf, size_t len)
{
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(number);
@@ -79,7 +80,7 @@
}
AST_STANDARD_APP_ARGS(args, data);
-
+
if (args.argc < 1) {
ast_log(LOG_WARNING, synopsis);
return -1;
@@ -102,13 +103,14 @@
LOCAL_USER_ACF_ADD(u);
- res = ast_get_enum(chan, p, dest, sizeof(dest), tech, sizeof(tech), zone, options);
+ res = ast_get_enum(chan, p, dest, sizeof(dest), tech, sizeof(tech), zone,
+ options);
LOCAL_USER_REMOVE(u);
p = strchr(dest, ':');
if (p && strcasecmp(tech, "ALL"))
- ast_copy_string(buf, p+1, len);
+ ast_copy_string(buf, p + 1, len);
else
ast_copy_string(buf, dest, len);
@@ -116,18 +118,22 @@
}
static struct ast_custom_function enum_function = {
- .name = "ENUMLOOKUP",
- .synopsis = "ENUMLOOKUP allows for general or specific querying of NAPTR records"
- " or counts of NAPTR types for ENUM or ENUM-like DNS pointers",
- .syntax = "ENUMLOOKUP(number[|Method-type[|options[|record#[|zone-suffix]]]])",
- .desc = "Option 'c' returns an integer count of the number of NAPTRs of a certain RR type.\n"
- "Combination of 'c' and Method-type of 'ALL' will return a count of all NAPTRs for the record.\n"
- "Defaults are: Method-type=sip, no options, record=1, zone-suffix=e164.arpa\n\n"
- "For more information, see README.enum",
- .read = function_enum,
+ .name = "ENUMLOOKUP",
+ .synopsis =
+ "ENUMLOOKUP allows for general or specific querying of NAPTR records"
+ " or counts of NAPTR types for ENUM or ENUM-like DNS pointers",
+ .syntax =
+ "ENUMLOOKUP(number[|Method-type[|options[|record#[|zone-suffix]]]])",
+ .desc =
+ "Option 'c' returns an integer count of the number of NAPTRs of a certain RR type.\n"
+ "Combination of 'c' and Method-type of 'ALL' will return a count of all NAPTRs for the record.\n"
+ "Defaults are: Method-type=sip, no options, record=1, zone-suffix=e164.arpa\n\n"
+ "For more information, see README.enum",
+ .read = function_enum,
};
-static int function_txtcidname(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int function_txtcidname(struct ast_channel *chan, char *cmd,
+ char *data, char *buf, size_t len)
{
int res;
char tech[80];
@@ -145,24 +151,26 @@
return -1;
}
- res = ast_get_txt(chan, data, dest, sizeof(dest), tech, sizeof(tech), txt, sizeof(txt));
-
+ res = ast_get_txt(chan, data, dest, sizeof(dest), tech, sizeof(tech), txt,
+ sizeof(txt));
+
if (!ast_strlen_zero(txt))
ast_copy_string(buf, txt, len);
-
+
LOCAL_USER_REMOVE(u);
return 0;
}
static struct ast_custom_function txtcidname_function = {
- .name = "TXTCIDNAME",
- .synopsis = "TXTCIDNAME looks up a caller name via DNS",
- .syntax = "TXTCIDNAME(<number>)",
- .desc = "This function looks up the given phone number in DNS to retrieve\n"
- "the caller id name. The result will either be blank or be the value\n"
- "found in the TXT record in DNS.\n",
- .read = function_txtcidname,
+ .name = "TXTCIDNAME",
+ .synopsis = "TXTCIDNAME looks up a caller name via DNS",
+ .syntax = "TXTCIDNAME(<number>)",
+ .desc =
+ "This function looks up the given phone number in DNS to retrieve\n"
+ "the caller id name. The result will either be blank or be the value\n"
+ "found in the TXT record in DNS.\n",
+ .read = function_txtcidname,
};
static char *tdesc = "ENUM related dialplan functions";
@@ -170,19 +178,19 @@
int unload_module(void)
{
int res = 0;
-
+
res |= ast_custom_function_unregister(&enum_function);
res |= ast_custom_function_unregister(&txtcidname_function);
STANDARD_HANGUP_LOCALUSERS;
-
+
return res;
}
int load_module(void)
{
int res = 0;
-
+
res |= ast_custom_function_register(&enum_function);
res |= ast_custom_function_register(&txtcidname_function);
@@ -191,13 +199,13 @@
char *description(void)
{
- return tdesc;
+ return tdesc;
}
int usecount(void)
{
int res;
-
+
STANDARD_USECOUNT(res);
return res;
@@ -205,6 +213,5 @@
char *key()
{
- return ASTERISK_GPL_KEY;
-}
-
+ return ASTERISK_GPL_KEY;
+}
Modified: team/kpfleming/chanfunc/funcs/func_env.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_env.c?rev=9672&r1=9671&r2=9672&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_env.c (original)
+++ team/kpfleming/chanfunc/funcs/func_env.c Sat Feb 11 22:20:43 2006
@@ -37,22 +37,24 @@
#include "asterisk/utils.h"
#include "asterisk/app.h"
-static int env_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int env_read(struct ast_channel *chan, char *cmd, char *data,
+ char *buf, size_t len)
{
char *ret = NULL;
- *buf = '\0';
+ *buf = '\0';
- if (data)
+ if (data)
ret = getenv(data);
- if (ret)
- ast_copy_string(buf, ret, len);
+ if (ret)
+ ast_copy_string(buf, ret, len);
return 0;
}
-static int env_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
+static int env_write(struct ast_channel *chan, char *cmd, char *data,
+ const char *value)
{
if (!ast_strlen_zero(data)) {
if (!ast_strlen_zero(value)) {
@@ -62,15 +64,16 @@
}
}
- return 0;
+ return 0;
}
-static int stat_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int stat_read(struct ast_channel *chan, char *cmd, char *data,
+ char *buf, size_t len)
{
char *action;
struct stat s;
- *buf = '\0';
+ *buf = '\0';
action = strsep(&data, "|");
if (stat(data, &s)) {
@@ -78,7 +81,7 @@
} else {
switch (*action) {
case 'e':
- strcpy(buf, "1");
+ strcpy(buf, "1");
break;
case 's':
snprintf(buf, len, "%d", (unsigned int) s.st_size);
@@ -121,15 +124,15 @@
.syntax = "STAT(<flag>,<filename>)",
.read = stat_read,
.desc =
-"flag may be one of the following:\n"
-" d - Checks if the file is a directory\n"
-" e - Checks if the file exists\n"
-" f - Checks if the file is a regular file\n"
-" m - Returns the file mode (in octal)\n"
[... 1477 lines stripped ...]
More information about the asterisk-commits
mailing list