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:
Mark Spencer
2005-01-03 00:51:57 +00:00
parent 7b968f6151
commit 0c3cea35f0
4 changed files with 69 additions and 43 deletions

26
utils.c
View File

@@ -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);
}