mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 04:30:28 +00:00
Merge OEJ's print groups feature (bug #3228, with changes)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4636 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
26
utils.c
26
utils.c
@@ -430,3 +430,29 @@ 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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user