More contributed BSD enhancements

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@919 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.0
Mark Spencer 23 years ago
parent 493cba1f80
commit f6764f4722

@ -914,7 +914,7 @@ static char usage_noop[] =
" Usage: NOOP\n" " Usage: NOOP\n"
" Does nothing.\n"; " Does nothing.\n";
agi_command commands[] = { static agi_command commands[] = {
{ { "answer", NULL }, handle_answer, "Asserts answer", usage_answer }, { { "answer", NULL }, handle_answer, "Asserts answer", usage_answer },
{ { "wait", "for", "digit", NULL }, handle_waitfordigit, "Waits for a digit to be pressed", usage_waitfordigit }, { { "wait", "for", "digit", NULL }, handle_waitfordigit, "Waits for a digit to be pressed", usage_waitfordigit },
{ { "send", "text", NULL }, handle_sendtext, "Sends text to channels supporting it", usage_sendtext }, { { "send", "text", NULL }, handle_sendtext, "Sends text to channels supporting it", usage_sendtext },
@ -1343,10 +1343,10 @@ static char dumpagihtml_help[] =
"Usage: dump agihtml <filename>\n" "Usage: dump agihtml <filename>\n"
" Dumps the agi command list in html format to given filename\n"; " Dumps the agi command list in html format to given filename\n";
struct ast_cli_entry showagi = static struct ast_cli_entry showagi =
{ { "show", "agi", NULL }, handle_showagi, "Show AGI commands or specific help", showagi_help }; { { "show", "agi", NULL }, handle_showagi, "Show AGI commands or specific help", showagi_help };
struct ast_cli_entry dumpagihtml = static struct ast_cli_entry dumpagihtml =
{ { "dump", "agihtml", NULL }, handle_dumpagihtml, "Dumps a list of agi command in html format", dumpagihtml_help }; { { "dump", "agihtml", NULL }, handle_dumpagihtml, "Dumps a list of agi command in html format", dumpagihtml_help };
int unload_module(void) int unload_module(void)

@ -83,8 +83,8 @@ LOCAL_USER_DECL;
static float loudness=4096.0; static float loudness=4096.0;
int firstdigittimeout = 20000; /* 20 seconds first digit timeout */ static int firstdigittimeout = 20000; /* 20 seconds first digit timeout */
int digittimeout = 10000; /* 10 seconds subsequent digit timeout */ static int digittimeout = 10000; /* 10 seconds subsequent digit timeout */
static void make_tone_block(unsigned char *data, float f1, float f2, int len, int *x) static void make_tone_block(unsigned char *data, float f1, float f2, int len, int *x)
{ {

@ -73,7 +73,7 @@
#include <sys/file.h> #include <sys/file.h>
#include "../astconf.h" #include "../astconf.h"
char qdir[255]; static char qdir[255];
static char *tdesc = "Call from Queue"; static char *tdesc = "Call from Queue";
static pthread_t qcall_thread; static pthread_t qcall_thread;
static int debug = 0; static int debug = 0;

@ -64,11 +64,11 @@
#define BASELINELEN 72 #define BASELINELEN 72
#define eol "\r\n" #define eol "\r\n"
int iocp; static int iocp;
int iolen; static int iolen;
int linelength; static int linelength;
int ateof; static int ateof;
unsigned char iobuf[BASEMAXINLINE]; static unsigned char iobuf[BASEMAXINLINE];
static char *tdesc = "Comedian Mail (Voicemail System)"; static char *tdesc = "Comedian Mail (Voicemail System)";

@ -23,7 +23,7 @@
// table to convert unsigned a-law bytes to signed linear integers // table to convert unsigned a-law bytes to signed linear integers
const int alaw2int[256] = { static const int alaw2int[256] = {
-5504,5504,-344,344,-22016,22016,-1376,1376,-2752,2752,-88,88,-11008,11008, -5504,5504,-344,344,-22016,22016,-1376,1376,-2752,2752,-88,88,-11008,11008,
-688,688,-7552,7552,-472,472,-30208,30208,-1888,1888,-3776,3776,-216,216, -688,688,-7552,7552,-472,472,-30208,30208,-1888,1888,-3776,3776,-216,216,
-15104,15104,-944,944,-4480,4480,-280,280,-17920,17920,-1120,1120,-2240,2240, -15104,15104,-944,944,-4480,4480,-280,280,-17920,17920,-1120,1120,-2240,2240,
@ -50,7 +50,7 @@ const int alaw2int[256] = {
// shift the integer to be 12+1 bit first, then add 4096 to get // shift the integer to be 12+1 bit first, then add 4096 to get
// the right index // the right index
const unsigned char int2alaw[8192] = { static const unsigned char int2alaw[8192] = {
84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84, 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84, 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84, 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,

@ -93,7 +93,7 @@ static int expirey = AST_DEFAULT_REG_EXPIRE;
static int usecnt; static int usecnt;
static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER; static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
int (*regfunk)(char *username, int onoff) = NULL; int (*iax_regfunk)(char *username, int onoff) = NULL;
/* Ethernet, etc */ /* Ethernet, etc */
#define IAX_CAPABILITY_FULLBANDWIDTH 0xFFFF #define IAX_CAPABILITY_FULLBANDWIDTH 0xFFFF
@ -218,7 +218,7 @@ struct iax_registry {
struct iax_registry *next; struct iax_registry *next;
}; };
struct iax_registry *registrations; static struct iax_registry *registrations;
/* Don't retry more frequently than every 10 ms, or less frequently than every 5 seconds */ /* Don't retry more frequently than every 10 ms, or less frequently than every 5 seconds */
#define MIN_RETRY_TIME 10 #define MIN_RETRY_TIME 10
@ -426,10 +426,10 @@ static struct iax_dpcache {
struct iax_dpcache *peer; /* For linking in peers */ struct iax_dpcache *peer; /* For linking in peers */
} *dpcache; } *dpcache;
pthread_mutex_t dpcache_lock; static pthread_mutex_t dpcache_lock;
#ifdef DEBUG_SUPPORT #ifdef DEBUG_SUPPORT
void showframe(struct ast_iax_frame *f, struct ast_iax_full_hdr *fhi, int rx, struct sockaddr_in *sin) static void showframe(struct ast_iax_frame *f, struct ast_iax_full_hdr *fhi, int rx, struct sockaddr_in *sin)
{ {
char *frames[] = { char *frames[] = {
"(0?)", "(0?)",
@ -4501,7 +4501,7 @@ static struct iax_user *build_user(char *name, struct ast_variable *v)
} }
void delete_users(void){ static void delete_users(void){
struct iax_user *user, *userlast; struct iax_user *user, *userlast;
struct iax_peer *peer; struct iax_peer *peer;
struct iax_registry *reg, *regl; struct iax_registry *reg, *regl;
@ -4535,7 +4535,7 @@ void delete_users(void){
ast_pthread_mutex_unlock(&peerl.lock); ast_pthread_mutex_unlock(&peerl.lock);
} }
void prune_peers(void){ static void prune_peers(void){
/* Prune peers who still are supposed to be deleted */ /* Prune peers who still are supposed to be deleted */
struct iax_peer *peer, *peerlast, *peernext; struct iax_peer *peer, *peerlast, *peernext;
int x; int x;

@ -109,7 +109,7 @@ static int timingfd = -1; /* Timing file descriptor */
static int usecnt; static int usecnt;
static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER; static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
int (*regfunk)(char *username, int onoff) = NULL; int (*iax2_regfunk)(char *username, int onoff) = NULL;
/* Ethernet, etc */ /* Ethernet, etc */
#define IAX_CAPABILITY_FULLBANDWIDTH 0xFFFF #define IAX_CAPABILITY_FULLBANDWIDTH 0xFFFF
@ -244,7 +244,7 @@ struct iax2_registry {
struct iax2_registry *next; struct iax2_registry *next;
}; };
struct iax2_registry *registrations; static struct iax2_registry *registrations;
/* Don't retry more frequently than every 10 ms, or less frequently than every 5 seconds */ /* Don't retry more frequently than every 10 ms, or less frequently than every 5 seconds */
#define MIN_RETRY_TIME 10 #define MIN_RETRY_TIME 10
@ -429,7 +429,7 @@ static struct iax2_dpcache {
struct iax2_dpcache *peer; /* For linking in peers */ struct iax2_dpcache *peer; /* For linking in peers */
} *dpcache; } *dpcache;
pthread_mutex_t dpcache_lock; static pthread_mutex_t dpcache_lock;
static void iax_debug_output(const char *data) static void iax_debug_output(const char *data)
{ {
@ -4808,7 +4808,7 @@ static struct iax2_user *build_user(char *name, struct ast_variable *v)
} }
void delete_users(void){ static void delete_users(void){
struct iax2_user *user, *userlast; struct iax2_user *user, *userlast;
struct iax2_peer *peer; struct iax2_peer *peer;
struct iax2_registry *reg, *regl; struct iax2_registry *reg, *regl;
@ -4842,7 +4842,7 @@ void delete_users(void){
ast_pthread_mutex_unlock(&peerl.lock); ast_pthread_mutex_unlock(&peerl.lock);
} }
void prune_peers(void){ static void prune_peers(void){
/* Prune peers who still are supposed to be deleted */ /* Prune peers who still are supposed to be deleted */
struct iax2_peer *peer, *peerlast, *peernext; struct iax2_peer *peer, *peerlast, *peernext;
int x; int x;

@ -155,7 +155,7 @@ struct mgcp_endpoint {
struct mgcp_gateway *parent; struct mgcp_gateway *parent;
}; };
struct mgcp_gateway { static struct mgcp_gateway {
/* A gateway containing one or more endpoints */ /* A gateway containing one or more endpoints */
char name[80]; char name[80];
struct sockaddr_in addr; struct sockaddr_in addr;
@ -293,7 +293,7 @@ struct my_ifreq {
} ifr_ifru; } ifr_ifru;
}; };
struct in_addr *lookup_iface(char *iface) { static struct in_addr *lookup_iface(char *iface) {
int mysock; int mysock;
int res; int res;
static struct my_ifreq ifreq; static struct my_ifreq ifreq;
@ -1694,7 +1694,7 @@ static struct ast_channel *mgcp_request(char *type, int format, void *data)
return tmpc; return tmpc;
} }
struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v) static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
{ {
struct mgcp_gateway *gw; struct mgcp_gateway *gw;
struct mgcp_endpoint *e; struct mgcp_endpoint *e;

@ -808,7 +808,7 @@ static unsigned int get_group(char *s)
char *piece; char *piece;
int start, finish,x; int start, finish,x;
unsigned int group = 0; unsigned int group = 0;
char *copy = strdupa(s); char *copy = ast_strdupa(s);
char *stringp=NULL; char *stringp=NULL;
if (!copy) { if (!copy) {
ast_log(LOG_ERROR, "Out of memory\n"); ast_log(LOG_ERROR, "Out of memory\n");

@ -33,8 +33,8 @@ static char *breakcmd = "\0x10\0x03";
static char *desc = "A/Open (Rockwell Chipset) ITU-2 VoiceModem Driver"; static char *desc = "A/Open (Rockwell Chipset) ITU-2 VoiceModem Driver";
int usecnt; static int usecnt;
pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER; static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
static char *aopen_idents[] = { static char *aopen_idents[] = {
/* Identify A/Open Modem */ /* Identify A/Open Modem */

@ -38,8 +38,8 @@ static char *breakcmd = "\020!";
static char *desc = "BestData (Conexant V.90 Chipset) VoiceModem Driver"; static char *desc = "BestData (Conexant V.90 Chipset) VoiceModem Driver";
int usecnt; static int usecnt;
pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER; static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
static char *bestdata_idents[] = { static char *bestdata_idents[] = {
/* Identify BestData Modem */ /* Identify BestData Modem */

@ -33,8 +33,8 @@ static char *breakcmd = "\0x10\0x14\0x10\0x3";
static char *desc = "ISDN4Linux Emulated Modem Driver"; static char *desc = "ISDN4Linux Emulated Modem Driver";
int usecnt; static int usecnt;
pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER; static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
static char *i4l_idents[] = { static char *i4l_idents[] = {
/* Identify ISDN4Linux Driver */ /* Identify ISDN4Linux Driver */

@ -75,7 +75,7 @@ static char context[AST_MAX_EXTENSION] = "default";
static char language[MAX_LANGUAGE] = ""; static char language[MAX_LANGUAGE] = "";
static char exten[AST_MAX_EXTENSION] = "s"; static char exten[AST_MAX_EXTENSION] = "s";
int hookstate=0; static int hookstate=0;
static short silence[FRAME_SIZE] = {0, }; static short silence[FRAME_SIZE] = {0, };
@ -123,7 +123,7 @@ static int time_has_passed(void)
with 160 sample frames, and a buffer size of 3, we have a 60ms buffer, with 160 sample frames, and a buffer size of 3, we have a 60ms buffer,
usually plenty. */ usually plenty. */
pthread_t sthread; static pthread_t sthread;
#define MAX_BUFFER_SIZE 100 #define MAX_BUFFER_SIZE 100
static int buffersize = 3; static int buffersize = 3;

@ -343,7 +343,7 @@ struct sip_registry {
#define REINVITE_UPDATE 2 #define REINVITE_UPDATE 2
static int sip_do_register(struct sip_registry *r); static int sip_do_register(struct sip_registry *r);
struct sip_registry *registrations; static struct sip_registry *registrations;
static int sipsock = -1; static int sipsock = -1;
static int globalnat = 0; static int globalnat = 0;
@ -361,7 +361,7 @@ static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp);
static int transmit_info_with_digit(struct sip_pvt *p, char digit); static int transmit_info_with_digit(struct sip_pvt *p, char digit);
static int transmit_message_with_text(struct sip_pvt *p, char *text); static int transmit_message_with_text(struct sip_pvt *p, char *text);
static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req); static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req);
char *getsipuri(char *header); static char *getsipuri(char *header);
static void free_old_route(struct sip_route *route); static void free_old_route(struct sip_route *route);
static int build_reply_digest(struct sip_pvt *p, char *orig_header, char *digest, int digest_len); static int build_reply_digest(struct sip_pvt *p, char *orig_header, char *digest, int digest_len);
@ -848,7 +848,7 @@ struct my_ifreq {
struct sockaddr_in ifru_addr; struct sockaddr_in ifru_addr;
}; };
struct in_addr *lookup_iface(char *iface) { static struct in_addr *lookup_iface(char *iface) {
int mysock; int mysock;
int res; int res;
static struct my_ifreq ifreq; static struct my_ifreq ifreq;
@ -5350,7 +5350,7 @@ int load_module()
return res; return res;
} }
void delete_users(void) static void delete_users(void)
{ {
struct sip_user *user, *userlast; struct sip_user *user, *userlast;
struct sip_peer *peer; struct sip_peer *peer;
@ -5384,7 +5384,7 @@ void delete_users(void)
ast_pthread_mutex_unlock(&peerl.lock); ast_pthread_mutex_unlock(&peerl.lock);
} }
void prune_peers(void) static void prune_peers(void)
{ {
/* Prune peers who still are supposed to be deleted */ /* Prune peers who still are supposed to be deleted */
struct sip_peer *peer, *peerlast, *peernext; struct sip_peer *peer, *peerlast, *peernext;
@ -5502,7 +5502,7 @@ char *description()
return desc; return desc;
} }
char *getsipuri(char *header) static char *getsipuri(char *header)
{ {
char *c, *d, *retval; char *c, *d, *retval;
int n; int n;

@ -708,6 +708,17 @@ static inline int ast_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds,
#endif #endif
} }
#if !defined(ast_strdupa) && defined(__GNUC__)
# define ast_strdupa(s) \
(__extension__ \
({ \
__const char *__old = (s); \
size_t __len = strlen (__old) + 1; \
char *__new = (char *) __builtin_alloca (__len); \
(char *) memcpy (__new, __old, __len); \
}))
#endif
#ifdef DO_CRASH #ifdef DO_CRASH
#define CRASH do { fprintf(stderr, "!! Forcing immediate crash a-la abort !!\n"); *((int *)0) = 0; } while(0) #define CRASH do { fprintf(stderr, "!! Forcing immediate crash a-la abort !!\n"); *((int *)0) = 0; } while(0)
#else #else

@ -29,10 +29,17 @@
// #define AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE_NP // #define AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE_NP
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
#define AST_MUTEX_INITIALIZER PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP #define AST_MUTEX_INITIALIZER PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
#define AST_MUTEX_KIND PTHREAD_MUTEX_ERRORCHECK_NP
#else #else
#ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
#define AST_MUTEX_INITIALIZER PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #define AST_MUTEX_INITIALIZER PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
#define AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE_NP #else
#define AST_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#endif
#endif
#ifdef PTHREAD_MUTEX_ERRORCHECK_NP
#define AST_MUTEX_KIND PTHREAD_MUTEX_ERRORCHECK_NP
#else
#define AST_MUTEX_KIND PTHREAD_MUTEX_ERRORCHECK
#endif #endif
struct mutex_info { struct mutex_info {
@ -96,7 +103,11 @@ static inline int __ast_pthread_mutex_unlock(char *filename, int lineno, char *f
#else #else
#define AST_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER #define AST_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#ifdef PTHREAD_MUTEX_FAST_NP
#define AST_MUTEX_KIND PTHREAD_MUTEX_FAST_NP #define AST_MUTEX_KIND PTHREAD_MUTEX_FAST_NP
#else
#define AST_MUTEX_KIND PTHREAD_NORMAL
#endif
#define ast_pthread_mutex_init(mutex) pthread_mutex_init(mutex, NULL) #define ast_pthread_mutex_init(mutex) pthread_mutex_init(mutex, NULL)
#define ast_pthread_mutex_lock pthread_mutex_lock #define ast_pthread_mutex_lock pthread_mutex_lock

@ -140,7 +140,7 @@ static struct ast_generator playtones = {
int ast_playtones_start(struct ast_channel *chan, int vol, const char *playlst, int interruptible) int ast_playtones_start(struct ast_channel *chan, int vol, const char *playlst, int interruptible)
{ {
char *s, *data = strdupa(playlst); /* cute */ char *s, *data = ast_strdupa(playlst); /* cute */
struct playtones_def d = { vol, -1, 0, 1, NULL}; struct playtones_def d = { vol, -1, 0, 1, NULL};
char *stringp=NULL; char *stringp=NULL;
if (!data) if (!data)

@ -248,7 +248,7 @@ static int ind_load_module(void)
if (!strcasecmp(v->name, "description")) { if (!strcasecmp(v->name, "description")) {
strncpy(tones->description, v->value, sizeof(tones->description)-1); strncpy(tones->description, v->value, sizeof(tones->description)-1);
} else if (!strcasecmp(v->name,"ringcadance")) { } else if (!strcasecmp(v->name,"ringcadance")) {
char *ring,*rings = strdupa(v->value); char *ring,*rings = ast_strdupa(v->value);
c = rings; c = rings;
ring = strsep(&c,","); ring = strsep(&c,",");
while (ring) { while (ring) {
@ -270,7 +270,7 @@ static int ind_load_module(void)
ring = strsep(&c,","); ring = strsep(&c,",");
} }
} else if (!strcasecmp(v->name,"alias")) { } else if (!strcasecmp(v->name,"alias")) {
char *countries = strdupa(v->value); char *countries = ast_strdupa(v->value);
c = countries; c = countries;
country = strsep(&c,","); country = strsep(&c,",");
while (country) { while (country) {

@ -611,7 +611,7 @@ unsigned int ast_get_group(char *s)
char *c=NULL; char *c=NULL;
int start=0, finish=0,x; int start=0, finish=0,x;
unsigned int group = 0; unsigned int group = 0;
copy = strdupa(s); copy = ast_strdupa(s);
if (!copy) { if (!copy) {
ast_log(LOG_ERROR, "Out of memory\n"); ast_log(LOG_ERROR, "Out of memory\n");
return 0; return 0;

Loading…
Cancel
Save