Change pri_dump_info to generate string instead of using pri_message (bug 2703)

git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@147 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
James Golovich 2004-10-26 04:27:29 +00:00
parent a3101da9fe
commit 542a5ffe0c
2 changed files with 28 additions and 23 deletions

View File

@ -459,8 +459,8 @@ extern void pri_set_error(void (*__pri_error)(char *));
#define PRI_SET_OVERLAPDIAL
extern void pri_set_overlapdial(struct pri *pri,int state);
#define PRI_DUMP_INFO
extern void pri_dump_info(struct pri *pri);
#define PRI_DUMP_INFO_STR
extern char *pri_dump_info_str(struct pri *pri);
/* Get file descriptor */
extern int pri_fd(struct pri *pri);

47
pri.c
View File

@ -520,6 +520,7 @@ void pri_error(char *fmt, ...)
else
fprintf(stderr, tmp);
}
/* Set overlap mode */
void pri_set_overlapdial(struct pri *pri,int state)
{
@ -531,43 +532,47 @@ int pri_fd(struct pri *pri)
return pri->fd;
}
void pri_dump_info(struct pri *pri)
char *pri_dump_info_str(struct pri *pri)
{
char buf[4096];
int len = 0;
#ifdef LIBPRI_COUNTERS
struct q921_frame *f;
int q921outstanding = 0;
#endif
if (!pri)
return;
return NULL;
/* Might be nice to format these a little better */
pri_message("Switchtype: %s\n", pri_switch2str(pri->switchtype));
pri_message("Type: %s\n", pri_node2str(pri->localtype));
len += sprintf(buf + len, "Switchtype: %s\n", pri_switch2str(pri->switchtype));
len += sprintf(buf + len, "Type: %s\n", pri_node2str(pri->localtype));
#ifdef LIBPRI_COUNTERS
/* Remember that Q921 Counters include Q931 packets (and any retransmissions) */
pri_message("Q931 RX: %d\n", pri->q931_rxcount);
pri_message("Q931 TX: %d\n", pri->q931_txcount);
pri_message("Q921 RX: %d\n", pri->q921_rxcount);
pri_message("Q921 TX: %d\n", pri->q921_txcount);
len += sprintf(buf + len, "Q931 RX: %d\n", pri->q931_rxcount);
len += sprintf(buf + len, "Q931 TX: %d\n", pri->q931_txcount);
len += sprintf(buf + len, "Q921 RX: %d\n", pri->q921_rxcount);
len += sprintf(buf + len, "Q921 TX: %d\n", pri->q921_txcount);
f = pri->txqueue;
while (f) {
q921outstanding++;
f = f->next;
}
pri_message("Q921 Outstanding: %d\n", q921outstanding);
len += sprintf(buf + len, "Q921 Outstanding: %d\n", q921outstanding);
#endif
pri_message("Window Length: %d/%d\n", pri->windowlen, pri->window);
pri_message("Sentrej: %d\n", pri->sentrej);
pri_message("SolicitFbit: %d\n", pri->solicitfbit);
pri_message("Retrans: %d\n", pri->retrans);
pri_message("Busy: %d\n", pri->busy);
pri_message("Overlap Dial: %d\n", pri->overlapdial);
pri_message("T200 Timer: %d\n", pri->timers[PRI_TIMER_T200]);
pri_message("T203 Timer: %d\n", pri->timers[PRI_TIMER_T203]);
pri_message("T305 Timer: %d\n", pri->timers[PRI_TIMER_T305]);
pri_message("T308 Timer: %d\n", pri->timers[PRI_TIMER_T308]);
pri_message("T313 Timer: %d\n", pri->timers[PRI_TIMER_T313]);
pri_message("N200 Counter: %d\n", pri->timers[PRI_TIMER_N200]);
len += sprintf(buf + len, "Window Length: %d/%d\n", pri->windowlen, pri->window);
len += sprintf(buf + len, "Sentrej: %d\n", pri->sentrej);
len += sprintf(buf + len, "SolicitFbit: %d\n", pri->solicitfbit);
len += sprintf(buf + len, "Retrans: %d\n", pri->retrans);
len += sprintf(buf + len, "Busy: %d\n", pri->busy);
len += sprintf(buf + len, "Overlap Dial: %d\n", pri->overlapdial);
len += sprintf(buf + len, "T200 Timer: %d\n", pri->timers[PRI_TIMER_T200]);
len += sprintf(buf + len, "T203 Timer: %d\n", pri->timers[PRI_TIMER_T203]);
len += sprintf(buf + len, "T305 Timer: %d\n", pri->timers[PRI_TIMER_T305]);
len += sprintf(buf + len, "T308 Timer: %d\n", pri->timers[PRI_TIMER_T308]);
len += sprintf(buf + len, "T313 Timer: %d\n", pri->timers[PRI_TIMER_T313]);
len += sprintf(buf + len, "N200 Counter: %d\n", pri->timers[PRI_TIMER_N200]);
return strdup(buf);
}
int pri_get_crv(struct pri *pri, q931_call *call, int *callmode)