From 96503a02c165eb39956234c43bcb274b65977541 Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Sat, 15 Jan 2005 21:51:38 +0000 Subject: Make groups be 64-bits (bug #3351, with mods) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4803 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channel.c | 34 ++++++++++++++++++++++++++++++---- channels/chan_agent.c | 8 ++++---- channels/chan_mgcp.c | 8 ++++---- channels/chan_modem.c | 10 +++++----- channels/chan_sip.c | 12 ++++++------ channels/chan_skinny.c | 8 ++++---- channels/chan_zap.c | 10 +++++----- include/asterisk/channel.h | 7 ++++++- include/asterisk/utils.h | 3 --- include/asterisk/vmodem.h | 2 +- utils.c | 27 --------------------------- 11 files changed, 65 insertions(+), 64 deletions(-) diff --git a/channel.c b/channel.c index 0d1c5da06..1fb729553 100755 --- a/channel.c +++ b/channel.c @@ -3033,13 +3033,13 @@ int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, i return 0; } -unsigned int ast_get_group(char *s) +ast_group_t ast_get_group(char *s) { char *copy; char *piece; char *c=NULL; int start=0, finish=0,x; - unsigned int group = 0; + ast_group_t group = 0; copy = ast_strdupa(s); if (!copy) { ast_log(LOG_ERROR, "Out of memory\n"); @@ -3058,8 +3058,8 @@ unsigned int ast_get_group(char *s) continue; } for (x=start;x<=finish;x++) { - if ((x > 31) || (x < 0)) { - ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 31)\n", x); + if ((x > 63) || (x < 0)) { + ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x); } else group |= (1 << x); } @@ -3118,3 +3118,29 @@ void ast_channels_init(void) { ast_cli_register(&cli_show_channeltypes); } + +/*--- ast_print_group: Print call group and pickup group ---*/ +char *ast_print_group(char *buf, int buflen, ast_group_t group) +{ + unsigned int i; + int first=1; + char num[3]; + + buf[0] = '\0'; + + if (!group) /* Return empty string if no group */ + return(buf); + + for (i=0; i<=63; i++) { /* Max group is 63 */ + if (group & (1 << i)) { + if (!first) { + strncat(buf, ", ", buflen); + } else { + first=0; + } + snprintf(num, sizeof(num), "%u", i); + strncat(buf, num, buflen); + } + } + return(buf); +} diff --git a/channels/chan_agent.c b/channels/chan_agent.c index 860898730..87046c771 100755 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -115,7 +115,7 @@ static void dump_agents(void); static int capability = -1; -static unsigned int group; +static ast_group_t group; static int autologoff; static int wrapuptime; static int ackcall; @@ -151,7 +151,7 @@ static struct agent_pvt { time_t start; /* When call started */ struct timeval lastdisc; /* When last disconnected */ int wrapuptime; /* Wrapup time in ms */ - unsigned int group; /* Group memberships */ + ast_group_t group; /* Group memberships */ int acknowledged; /* Acknowledged */ char moh[80]; /* Which music on hold */ char agent[AST_MAX_AGENT]; /* Agent ID */ @@ -1110,7 +1110,7 @@ static struct ast_channel *agent_request(const char *type, int format, void *dat struct agent_pvt *p; struct ast_channel *chan = NULL; char *s; - unsigned int groupmatch; + ast_group_t groupmatch; int waitforagent=0; int hasagent = 0; struct timeval tv; @@ -1957,7 +1957,7 @@ static int agent_devicestate(void *data) { struct agent_pvt *p; char *s; - unsigned int groupmatch; + ast_group_t groupmatch; int waitforagent=0; int res = AST_DEVICE_INVALID; diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 7065a2dae..26ee4afd4 100755 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -172,8 +172,8 @@ static int nat = 0; /*static int cur_signalling = -1;*/ /*static unsigned int cur_group = 0;*/ -static unsigned int cur_callergroup = 0; -static unsigned int cur_pickupgroup = 0; +static ast_group_t cur_callergroup = 0; +static ast_group_t cur_pickupgroup = 0; /* XXX Is this needed? */ /* Doesn't look like the dsp stuff for */ @@ -373,8 +373,8 @@ struct mgcp_endpoint { char mailbox[AST_MAX_EXTENSION]; char musicclass[MAX_LANGUAGE]; char curtone[80]; /* Current tone */ - unsigned int callgroup; - unsigned int pickupgroup; + ast_group_t callgroup; + ast_group_t pickupgroup; int callwaiting; int transfer; int threewaycalling; diff --git a/channels/chan_modem.c b/channels/chan_modem.c index 9a1e2074d..6bd5c6cd3 100755 --- a/channels/chan_modem.c +++ b/channels/chan_modem.c @@ -74,7 +74,7 @@ struct ast_dsp *dsp = NULL; static char outgoingmsn[AST_MAX_EXTENSION]=""; /* Default group */ -static unsigned int cur_group = 0; +static ast_group_t cur_group = 0; static int usecnt =0; @@ -790,7 +790,7 @@ static struct ast_channel *modem_request(const char *type, int format, void *dat struct ast_modem_pvt *p; struct ast_channel *tmp = NULL; char dev[80]; - unsigned int group = 0; + ast_group_t group = 0; char *stringp=NULL; strncpy(dev, (char *)data, sizeof(dev)-1); stringp=dev; @@ -848,11 +848,11 @@ static struct ast_channel *modem_request(const char *type, int format, void *dat return tmp; } -static unsigned int get_group(char *s) +static ast_group_t get_group(char *s) { char *piece; int start, finish,x; - unsigned int group = 0; + ast_group_t group = 0; char *copy = ast_strdupa(s); char *stringp=NULL; if (!copy) { @@ -874,7 +874,7 @@ static unsigned int get_group(char *s) piece = strsep(&stringp, ","); for (x=start;x<=finish;x++) { - if ((x > 31) || (x < 0)) { + if ((x > 63) || (x < 0)) { ast_log(LOG_WARNING, "Ignoring invalid group %d\n", x); break; } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index af185bfab..57d4cc930 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -312,8 +312,8 @@ static struct sip_pvt { struct ast_codec_pref prefs; /* codec prefs */ unsigned int ocseq; /* Current outgoing seqno */ unsigned int icseq; /* Current incoming seqno */ - unsigned int callgroup; /* Call group */ - unsigned int pickupgroup; /* Pickup group */ + ast_group_t callgroup; /* Call group */ + ast_group_t pickupgroup; /* Pickup group */ int lastinvite; /* Last Cseq of invite */ unsigned int flags; /* SIP_ flags */ int capability; /* Special capability (codec) */ @@ -433,8 +433,8 @@ struct sip_user { char musicclass[MAX_LANGUAGE]; /* Music on Hold class */ char useragent[256]; /* User agent in SIP request */ struct ast_codec_pref prefs; /* codec prefs */ - unsigned int callgroup; /* Call group */ - unsigned int pickupgroup; /* Pickup Group */ + ast_group_t callgroup; /* Call group */ + ast_group_t pickupgroup; /* Pickup Group */ unsigned int flags; /* SIP_ flags */ int amaflags; /* AMA flags for billing */ int callingpres; /* Calling id presentation */ @@ -475,8 +475,8 @@ struct sip_peer { int rtptimeout; int rtpholdtimeout; int rtpkeepalive; /* Send RTP packets for keepalive */ - unsigned int callgroup; /* Call group */ - unsigned int pickupgroup; /* Pickup group */ + ast_group_t callgroup; /* Call group */ + ast_group_t pickupgroup; /* Pickup group */ struct sockaddr_in addr; /* IP address of peer */ struct in_addr mask; diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 9a3fa486a..cb2319c3f 100755 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -492,8 +492,8 @@ static char cid_num[AST_MAX_EXTENSION] = ""; static char cid_name[AST_MAX_EXTENSION] = ""; static char linelabel[AST_MAX_EXTENSION] =""; static int nat = 0; -static unsigned int cur_callergroup = 0; -static unsigned int cur_pickupgroup = 0; +static ast_group_t cur_callergroup = 0; +static ast_group_t cur_pickupgroup = 0; static int immediate = 0; static int callwaiting = 0; static int callreturn = 0; @@ -642,8 +642,8 @@ struct skinny_line { char mailbox[AST_MAX_EXTENSION]; char musicclass[MAX_LANGUAGE]; int curtone; /* Current tone being played */ - unsigned int callgroup; - unsigned int pickupgroup; + ast_group_t callgroup; + ast_group_t pickupgroup; int callwaiting; int transfer; int threewaycalling; diff --git a/channels/chan_zap.c b/channels/chan_zap.c index 3d8741dbd..292dfc191 100755 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -172,9 +172,9 @@ static int cid_start = CID_START_RING; static int zaptrcallerid = 0; static int cur_signalling = -1; -static unsigned int cur_group = 0; -static unsigned int cur_callergroup = 0; -static unsigned int cur_pickupgroup = 0; +static ast_group_t cur_group = 0; +static ast_group_t cur_callergroup = 0; +static ast_group_t cur_pickupgroup = 0; static int relaxdtmf = 0; static int immediate = 0; @@ -489,8 +489,8 @@ static struct zt_pvt { int confno; /* Our conference */ int confusers; /* Who is using our conference */ int propconfno; /* Propagated conference number */ - unsigned int callgroup; - unsigned int pickupgroup; + ast_group_t callgroup; + ast_group_t pickupgroup; int immediate; /* Answer before getting digits? */ int channel; /* Channel Number or CRV */ int span; /* Span number */ diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 4d24150db..ddff8a390 100755 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -46,6 +46,8 @@ extern "C" { #define AST_MAX_FDS 8 +typedef unsigned long long ast_group_t; + struct ast_generator { void *(*alloc)(struct ast_channel *chan, void *params); void (*release)(struct ast_channel *chan, void *data); @@ -887,7 +889,10 @@ static inline int ast_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, ast_set_flag(c, AST_FLAG_BLOCKING); \ } } -extern unsigned int ast_get_group(char *s); +extern ast_group_t ast_get_group(char *s); +/* print call- and pickup groups into buffer */ +extern char *ast_print_group(char *buf, int buflen, ast_group_t group); + #if defined(__cplusplus) || defined(c_plusplus) } diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index ff0c2cb7e..dd1141985 100755 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -153,6 +153,3 @@ extern int ast_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*s extern char *ast_strcasestr(const char *, const char *); #endif - -/* print call- and pickup groups into buffer */ -char *ast_print_group(char *buf, int buflen, unsigned int group); diff --git a/include/asterisk/vmodem.h b/include/asterisk/vmodem.h index c4f271d33..61e031113 100755 --- a/include/asterisk/vmodem.h +++ b/include/asterisk/vmodem.h @@ -116,7 +116,7 @@ struct ast_modem_pvt { /*! Multiple Subscriber Number we accept for outgoing calls (; seperated list) */ char outgoingmsn[AST_MAX_EXTENSION]; /*! Group(s) we belong to if available */ - unsigned int group; + ast_group_t group; /*! Caller ID if available */ char cid_name[AST_MAX_EXTENSION]; /*! Caller ID if available */ diff --git a/utils.c b/utils.c index 55d915406..b11ef27dc 100755 --- a/utils.c +++ b/utils.c @@ -430,30 +430,3 @@ char *ast_strcasestr(const char *haystack, const char *needle) } } #endif - - -/*--- ast_print_group: Print call group and pickup group ---*/ -char *ast_print_group(char *buf, int buflen, unsigned int group) -{ - unsigned int i; - int first=1; - char num[3]; - - buf[0] = '\0'; - - if (!group) /* Return empty string if no group */ - return(buf); - - for (i=0; i<=31; i++) { /* Max group is 31 */ - if (group & (1 << i)) { - if (!first) { - strncat(buf, ", ", buflen); - } else { - first=0; - } - snprintf(num, sizeof(num), "%u", i); - strncat(buf, num, buflen); - } - } - return(buf); -} -- cgit v1.2.3