Index: asterisk/channels/chan_zap.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v
retrieving revision 1.361
diff -u -r1.361 chan_zap.c
--- asterisk/channels/chan_zap.c	23 Oct 2004 12:19:47 -0000	1.361
+++ asterisk/channels/chan_zap.c	23 Oct 2004 22:25:41 -0000
@@ -7118,9 +7118,12 @@
 	return NULL;
 }
 
-static void zt_pri_message(char *s)
+static void zt_pri_message(int fd,char *s)
 {
-	ast_verbose(s);
+  if(fd)
+    ast_cli(fd,s);
+  else
+    ast_verbose(s);
 }
 
 static void zt_pri_error(char *s)
@@ -7394,7 +7397,7 @@
 
 		if (e) {
 			if (pri->debug)
-				pri_dump_event(pri->dchans[which], e);
+			  pri_dump_event(0,pri->dchans[which], e);
 			switch(e->e) {
 			case PRI_EVENT_DCHAN_UP:
 				if (option_verbose > 1) 
@@ -8264,7 +8267,7 @@
 			ast_cli(fd, "%s D-channel: %d\n", pri_order(x), pris[span-1].dchannels[x]);
 			build_status(status, sizeof(status), pris[span-1].dchanavail[x], pris[span-1].dchans[x] == pris[span-1].pri);
 			ast_cli(fd, "Status: %s\n", status);
-			pri_dump_info(pris[span-1].pri);
+			pri_dump_info(fd,pris[span-1].pri);
 			ast_cli(fd, "\n");
 		}
 	}
Index: libpri/libpri.h
===================================================================
RCS file: /usr/cvsroot/libpri/libpri.h,v
retrieving revision 1.31
diff -u -r1.31 libpri.h
--- libpri/libpri.h	26 Jun 2004 04:37:09 -0000	1.31
+++ libpri/libpri.h	23 Oct 2004 22:25:41 -0000
@@ -370,7 +370,7 @@
 extern char *pri_switch2str(int id);
 
 /* Print an event */
-extern void pri_dump_event(struct pri *pri, pri_event *e);
+extern void pri_dump_event(int fd, struct pri *pri, pri_event *e);
 
 /* Turn an event ID into a string */
 extern char *pri_event2str(int e);
@@ -451,7 +451,7 @@
 extern int pri_setup(struct pri *pri, q931_call *call, struct pri_sr *req);
 	 
 /* Override message and error stuff */
-extern void pri_set_message(void (*__pri_error)(char *));
+extern void pri_set_message(void (*func)(int fd, char *stuff));
 extern void pri_set_error(void (*__pri_error)(char *));
 
 /* Set overlap mode */
@@ -459,7 +459,7 @@
 extern void pri_set_overlapdial(struct pri *pri,int state);
 
 #define PRI_DUMP_INFO
-extern void pri_dump_info(struct pri *pri);
+extern void pri_dump_info(int fd, struct pri *pri);
 
 /* Get file descriptor */
 extern int pri_fd(struct pri *pri);
Index: libpri/pri.c
===================================================================
RCS file: /usr/cvsroot/libpri/pri.c,v
retrieving revision 1.24
diff -u -r1.24 pri.c
--- libpri/pri.c	29 Jun 2004 17:57:18 -0000	1.24
+++ libpri/pri.c	23 Oct 2004 22:25:41 -0000
@@ -332,30 +332,30 @@
 	return q931_new_call(pri);
 }
 
-void pri_dump_event(struct pri *pri, pri_event *e)
+void pri_dump_event(int fd, struct pri *pri, pri_event *e)
 {
 	if (!pri || !e)
 		return;
-	pri_message("Event type: %s (%d)\n", pri_event2str(e->gen.e), e->gen.e);
+	pri_message(fd,"Event type: %s (%d)\n", pri_event2str(e->gen.e), e->gen.e);
 	switch(e->gen.e) {
 	case PRI_EVENT_DCHAN_UP:
 	case PRI_EVENT_DCHAN_DOWN:
 		break;
 	case PRI_EVENT_CONFIG_ERR:
-		pri_message("Error: %s", e->err.err);
+		pri_message(fd,"Error: %s", e->err.err);
 		break;
 	case PRI_EVENT_RESTART:
-		pri_message("Restart on channel %d\n", e->restart.channel);
+		pri_message(fd,"Restart on channel %d\n", e->restart.channel);
 	case PRI_EVENT_RING:
-		pri_message("Calling number: %s (%s, %s)\n", e->ring.callingnum, pri_plan2str(e->ring.callingplan), pri_pres2str(e->ring.callingpres));
-		pri_message("Called number: %s (%s)\n", e->ring.callednum, pri_plan2str(e->ring.calledplan));
-		pri_message("Channel: %d (%s) Reference number: %d\n", e->ring.channel, e->ring.flexible ? "Flexible" : "Not Flexible", e->ring.cref);
+		pri_message(fd,"Calling number: %s (%s, %s)\n", e->ring.callingnum, pri_plan2str(e->ring.callingplan), pri_pres2str(e->ring.callingpres));
+		pri_message(fd,"Called number: %s (%s)\n", e->ring.callednum, pri_plan2str(e->ring.calledplan));
+		pri_message(fd,"Channel: %d (%s) Reference number: %d\n", e->ring.channel, e->ring.flexible ? "Flexible" : "Not Flexible", e->ring.cref);
 		break;
 	case PRI_EVENT_HANGUP:
-		pri_message("Hangup, reference number: %d, reason: %s\n", e->hangup.cref, pri_cause2str(e->hangup.cause));
+		pri_message(fd,"Hangup, reference number: %d, reason: %s\n", e->hangup.cref, pri_cause2str(e->hangup.cause));
 		break;
 	default:
-		pri_message("Don't know how to dump events of type %d\n", e->gen.e);
+		pri_message(fd,"Don't know how to dump events of type %d\n", e->gen.e);
 	}
 }
 
@@ -395,9 +395,9 @@
 }	
 
 static void (*__pri_error)(char *stuff);
-static void (*__pri_message)(char *stuff);
+static void (*__pri_message)(int fd, char *stuff);
 
-void pri_set_message(void (*func)(char *stuff))
+void pri_set_message(void (*func)(int fd, char *stuff))
 {
 	__pri_message = func;
 }
@@ -407,7 +407,7 @@
 	__pri_error = func;
 }
 
-void pri_message(char *fmt, ...)
+void pri_message(int fd, char *fmt, ...)
 {
 	char tmp[1024];
 	va_list ap;
@@ -415,9 +415,11 @@
 	vsnprintf(tmp, sizeof(tmp), fmt, ap);
 	va_end(ap);
 	if (__pri_message)
-		__pri_message(tmp);
+	  __pri_message(fd,tmp);
+	else if (fd)
+	  write(fd,tmp,sizeof(tmp));
 	else
-		fprintf(stdout, tmp);
+	  fprintf(stdout, tmp);
 }
 
 void pri_error(char *fmt, ...)
@@ -443,7 +445,7 @@
 	return pri->fd;
 }
 
-void pri_dump_info(struct pri *pri)
+void pri_dump_info(int fd, struct pri *pri)
 {
 #ifdef LIBPRI_COUNTERS
 	struct q921_frame *f;
@@ -453,27 +455,27 @@
 		return;
 
 	/* 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));
+	pri_message(fd,"Switchtype: %s\n", pri_switch2str(pri->switchtype));
+	pri_message(fd,"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);
+	pri_message(fd,"Q931 RX: %d\n", pri->q931_rxcount);
+	pri_message(fd,"Q931 TX: %d\n", pri->q931_txcount);
+	pri_message(fd,"Q921 RX: %d\n", pri->q921_rxcount);
+	pri_message(fd,"Q921 TX: %d\n", pri->q921_txcount);
 	f = pri->txqueue;
 	while (f) {
 		q921outstanding++;
 		f = f->next;
 	}
-	pri_message("Q921 Outstanding: %d\n", q921outstanding);
+	pri_message(fd,"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(fd,"Window Length: %d/%d\n", pri->windowlen, pri->window);
+	pri_message(fd,"Sentrej: %d\n", pri->sentrej);
+	pri_message(fd,"SolicitFbit: %d\n", pri->solicitfbit);
+	pri_message(fd,"Retrans: %d\n", pri->retrans);
+	pri_message(fd,"Busy: %d\n", pri->busy);
+	pri_message(fd,"Overlap Dial: %d\n", pri->overlapdial);
 }
 
 int pri_get_crv(struct pri *pri, q931_call *call, int *callmode)
Index: libpri/pri_internal.h
===================================================================
RCS file: /usr/cvsroot/libpri/pri_internal.h,v
retrieving revision 1.11
diff -u -r1.11 pri_internal.h
--- libpri/pri_internal.h	26 Jun 2004 04:37:09 -0000	1.11
+++ libpri/pri_internal.h	23 Oct 2004 22:25:41 -0000
@@ -128,7 +128,7 @@
 
 extern pri_event *pri_mkerror(struct pri *pri, char *errstr);
 
-extern void pri_message(char *fmt, ...);
+extern void pri_message(int fd, char *fmt, ...);
 
 extern void pri_error(char *fmt, ...);
 
Index: libpri/q921.c
===================================================================
RCS file: /usr/cvsroot/libpri/q921.c,v
retrieving revision 1.17
diff -u -r1.17 q921.c
--- libpri/q921.c	23 Jul 2004 16:04:01 -0000	1.17
+++ libpri/q921.c	23 Oct 2004 22:25:41 -0000
@@ -71,7 +71,7 @@
 		return q921_transmit(pri->master, h, len);
 #ifdef RANDOM_DROPS
    if (!(random() % 3)) {
-         pri_message(" === Dropping Packet ===\n");
+         pri_message(0," === Dropping Packet ===\n");
          return 0;
    }
 #endif   
@@ -111,7 +111,7 @@
 		return;
 	}
 	if (pri->debug & PRI_DEBUG_Q921_STATE)
-		pri_message("Sending Unnumbered Acknowledgement\n");
+		pri_message(0,"Sending Unnumbered Acknowledgement\n");
 	q921_transmit(pri, &h, 3);
 }
 
@@ -143,7 +143,7 @@
 		return;
 	}
 	if (pri->debug & PRI_DEBUG_Q921_STATE)
-		pri_message("Sending Set Asynchronous Balanced Mode Extended\n");
+		pri_message(0,"Sending Set Asynchronous Balanced Mode Extended\n");
 	q921_transmit(pri, &h, 3);
 	pri->q921_state = Q921_AWAITING_ESTABLISH;
 }
@@ -166,7 +166,7 @@
 			else
 				pri->txqueue = f->next;
 			if (pri->debug & PRI_DEBUG_Q921_STATE)
-				pri_message("-- ACKing packet %d, new txqueue is %d (-1 means empty)\n", f->h.n_s, pri->txqueue ? pri->txqueue->h.n_s : -1);
+				pri_message(0,"-- ACKing packet %d, new txqueue is %d (-1 means empty)\n", f->h.n_s, pri->txqueue ? pri->txqueue->h.n_s : -1);
 			/* Update v_a */
 			pri->v_a = num;
 			free(f);
@@ -180,7 +180,7 @@
 				if (!f->transmitted) {
 					/* Send it now... */
 					if (pri->debug & PRI_DEBUG_Q921_STATE)
-						pri_message("-- Finally transmitting %d, since window opened up\n", f->h.n_s);
+						pri_message(0,"-- Finally transmitting %d, since window opened up\n", f->h.n_s);
 					f->transmitted++;
 					pri->windowlen++;
 					f->h.n_r = pri->v_r;
@@ -206,7 +206,7 @@
 	if (pri->t203_timer) {
 		pri_schedule_del(pri, pri->t203_timer);
 		if (pri->debug &  PRI_DEBUG_Q921_STATE)
-			pri_message("-- Restarting T203 counter\n");
+			pri_message(0,"-- Restarting T203 counter\n");
 		/* Nothing to transmit, start the T203 counter instead */
 		pri->t203_timer = pri_schedule_event(pri, T_203, t203_expire, pri);
 	}
@@ -229,31 +229,31 @@
 	}
 	/* Cancel each packet as necessary */
 	if (pri->debug & PRI_DEBUG_Q921_STATE)
-		pri_message("-- ACKing all packets from %d to (but not including) %d\n", pri->v_a, ack);
+		pri_message(0,"-- ACKing all packets from %d to (but not including) %d\n", pri->v_a, ack);
 	for (x=pri->v_a; x != ack; Q921_INC(x)) 
 		cnt += q921_ack_packet(pri, x);	
 	if (!pri->txqueue) {
 		if (pri->debug &  PRI_DEBUG_Q921_STATE)
-			pri_message("-- Since there was nothing left, stopping T200 counter\n");
+			pri_message(0,"-- Since there was nothing left, stopping T200 counter\n");
 		/* Something was ACK'd.  Stop T200 counter */
 		pri_schedule_del(pri, pri->t200_timer);
 		pri->t200_timer = 0;
 	}
 	if (pri->t203_timer) {
 		if (pri->debug &  PRI_DEBUG_Q921_STATE)
-			pri_message("-- Stopping T203 counter since we got an ACK\n");
+			pri_message(0,"-- Stopping T203 counter since we got an ACK\n");
 		pri_schedule_del(pri, pri->t203_timer);
 		pri->t203_timer = 0;
 	}
 	if (pri->txqueue) {
 		/* Something left to transmit, Start the T200 counter again if we stopped it */
 		if (pri->debug &  PRI_DEBUG_Q921_STATE)
-			pri_message("-- Something left to transmit (%d), restarting T200 counter\n", pri->txqueue->h.n_s);
+			pri_message(0,"-- Something left to transmit (%d), restarting T200 counter\n", pri->txqueue->h.n_s);
 		if (!pri->t200_timer)
 			pri->t200_timer = pri_schedule_event(pri, T_200, t200_expire, pri);
 	} else {
 		if (pri->debug &  PRI_DEBUG_Q921_STATE)
-			pri_message("-- Nothing left, starting T203 counter\n");
+			pri_message(0,"-- Nothing left, starting T203 counter\n");
 		/* Nothing to transmit, start the T203 counter instead */
 		pri->t203_timer = pri_schedule_event(pri, T_203, t203_expire, pri);
 	}
@@ -281,7 +281,7 @@
 		return;
 	}
 	if (pri->debug & PRI_DEBUG_Q921_STATE)
-		pri_message("Sending Reject (%d)\n", pri->v_r);
+		pri_message(0,"Sending Reject (%d)\n", pri->v_r);
 	pri->sentrej = 1;
 	q921_transmit(pri, &h, 4);
 }
@@ -313,7 +313,7 @@
 	}
 	pri->v_na = pri->v_r;	/* Make a note that we've already acked this */
 	if (pri->debug & PRI_DEBUG_Q921_STATE)
-		pri_message("Sending Receiver Ready (%d)\n", pri->v_r);
+		pri_message(0,"Sending Receiver Ready (%d)\n", pri->v_r);
 	q921_transmit(pri, &h, 4);
 }
 
@@ -323,7 +323,7 @@
 	if (pri->txqueue) {
 		/* Retransmit first packet in the queue, setting the poll bit */
 		if (pri->debug & PRI_DEBUG_Q921_STATE)
-			pri_message("-- T200 counter expired, What to do...\n");
+			pri_message(0,"-- T200 counter expired, What to do...\n");
 		/* Force Poll bit */
 		pri->txqueue->h.p_f = 1;	
 		/* Update nr */
@@ -335,7 +335,7 @@
       if (pri->retrans < N_200) {
          /* Reschedule t200_timer */
          if (pri->debug & PRI_DEBUG_Q921_STATE)
-            pri_message("-- Retransmitting %d bytes\n", pri->txqueue->len);
+            pri_message(0,"-- Retransmitting %d bytes\n", pri->txqueue->len);
 		if (pri->busy) 
 			q921_rr(pri, 1, 0);
 		else {
@@ -344,11 +344,11 @@
 			q921_transmit(pri, (q921_h *)&pri->txqueue->h, pri->txqueue->len);
 		}
          if (pri->debug & PRI_DEBUG_Q921_STATE) 
-               pri_message("-- Rescheduling retransmission (%d)\n", pri->retrans);
+               pri_message(0,"-- Rescheduling retransmission (%d)\n", pri->retrans);
          pri->t200_timer = pri_schedule_event(pri, T_200, t200_expire, pri);
       } else {
          if (pri->debug & PRI_DEBUG_Q921_STATE) 
-               pri_message("-- Timeout occured, restarting PRI\n");
+               pri_message(0,"-- Timeout occured, restarting PRI\n");
          pri->q921_state = Q921_LINK_CONNECTION_RELEASED;
       	pri->t200_timer = 0;
          q921_dchannel_down(pri);
@@ -357,7 +357,7 @@
       }
 	} else if (pri->solicitfbit) {
          if (pri->debug & PRI_DEBUG_Q921_STATE)
-            pri_message("-- Retrying poll with f-bit\n");
+            pri_message(0,"-- Retrying poll with f-bit\n");
 		pri->retrans++;
 		if (pri->retrans < N_200) {
 			pri->solicitfbit = 1;
@@ -365,7 +365,7 @@
 			pri->t200_timer = pri_schedule_event(pri, T_200, t200_expire, pri);
 		} else {
 			if (pri->debug & PRI_DEBUG_Q921_STATE) 
-				pri_message("-- Timeout occured, restarting PRI\n");
+				pri_message(0,"-- Timeout occured, restarting PRI\n");
 			pri->q921_state = Q921_LINK_CONNECTION_RELEASED;
 			pri->t200_timer = 0;
 			q921_dchannel_down(pri);
@@ -423,23 +423,23 @@
 				f->transmitted++;
 			} else {
 				if (pri->debug & PRI_DEBUG_Q921_STATE)
-					pri_message("Delaying transmission of %d, window is %d/%d long\n", 
+					pri_message(0,"Delaying transmission of %d, window is %d/%d long\n", 
 						f->h.n_s, pri->windowlen, pri->window);
 			}
 		}
 		if (pri->t203_timer) {
 			if (pri->debug & PRI_DEBUG_Q921_STATE)
-				pri_message("Stopping T_203 timer\n");
+				pri_message(0,"Stopping T_203 timer\n");
 			pri_schedule_del(pri, pri->t203_timer);
 			pri->t203_timer = 0;
 		}
 		if (!pri->t200_timer) {
 			if (pri->debug & PRI_DEBUG_Q921_STATE)
-				pri_message("Starting T_200 timer\n");
+				pri_message(0,"Starting T_200 timer\n");
 			pri->t200_timer = pri_schedule_event(pri, T_200, t200_expire, pri);
 		} else
 			if (pri->debug & PRI_DEBUG_Q921_STATE)
-				pri_message("T_200 timer already going (%d)\n", pri->t200_timer);
+				pri_message(0,"T_200 timer already going (%d)\n", pri->t200_timer);
 		
 	} else {
 		pri_error("!! Out of memory for Q.921 transmit\n");
@@ -453,7 +453,7 @@
 	struct pri *pri = vpri;
 	if (pri->q921_state == Q921_LINK_CONNECTION_ESTABLISHED) {
 		if (pri->debug &  PRI_DEBUG_Q921_STATE)
-			pri_message("T203 counter expired, sending RR and scheduling T203 again\n");
+			pri_message(0,"T203 counter expired, sending RR and scheduling T203 again\n");
 		/* Solicit an F-bit in the other's RR */
 		pri->solicitfbit = 1;
 		pri->retrans = 0;
@@ -462,7 +462,7 @@
 		pri->t203_timer = pri_schedule_event(pri, T_200, t200_expire, pri);
 	} else {
 		if (pri->debug &  PRI_DEBUG_Q921_STATE)
-			pri_message("T203 counter expired in weird state %d\n", pri->q921_state);
+			pri_message(0,"T203 counter expired in weird state %d\n", pri->q921_state);
 		pri->t203_timer = 0;
 	}
 }
@@ -520,7 +520,7 @@
 		if (buf) {
 			for (x=0;x<len;x++) 
 				buflen += sprintf(buf + buflen, "%02x ", h->raw[x]);
-			pri_message("\n%c [ %s]\n", direction_tag, buf);
+			pri_message(0,"\n%c [ %s]\n", direction_tag, buf);
 			free(buf);
 		}
 	}
@@ -528,17 +528,17 @@
 	switch (h->h.data[0] & Q921_FRAMETYPE_MASK) {
 	case 0:
 	case 2:
-		pri_message("\n%c Informational frame:\n", direction_tag);
+		pri_message(0,"\n%c Informational frame:\n", direction_tag);
 		break;
 	case 1:
-		pri_message("\n%c Supervisory frame:\n", direction_tag);
+		pri_message(0,"\n%c Supervisory frame:\n", direction_tag);
 		break;
 	case 3:
-		pri_message("\n%c Unnumbered frame:\n", direction_tag);
+		pri_message(0,"\n%c Unnumbered frame:\n", direction_tag);
 		break;
 	}
 	
-	pri_message(
+	pri_message(0,
 "%c SAPI: %02d  C/R: %d EA: %d\n"
 "%c  TEI: %03d        EA: %d\n", 
     	direction_tag,
@@ -552,7 +552,7 @@
 	case 0:
 	case 2:
 		/* Informational frame */
-		pri_message(
+		pri_message(0,
 "%c N(S): %03d   0: %d\n"
 "%c N(R): %03d   P: %d\n"
 "%c %d bytes of data\n",
@@ -579,7 +579,7 @@
 			type = "REJ (reject)";
 			break;
 		}
-		pri_message(
+		pri_message(0,
 "%c Zero: %d     S: %d 01: %d  [ %s ]\n"
 "%c N(R): %03d P/F: %d\n"
 "%c %d bytes of data\n",
@@ -625,7 +625,7 @@
 				break;
 			}
 		}
-		pri_message(
+		pri_message(0,
 "%c   M3: %d   P/F: %d M2: %d 11: %d  [ %s ]\n"
 "%c %d bytes of data\n",
 	direction_tag,
@@ -739,10 +739,10 @@
 				/* If it's a p/f one then send back a RR in return with the p/f bit set */
 				if (pri->solicitfbit) {
 					if (pri->debug & PRI_DEBUG_Q921_STATE) 
-						pri_message("-- Got RR response to our frame\n");
+						pri_message(0,"-- Got RR response to our frame\n");
 				} else {
 					if (pri->debug & PRI_DEBUG_Q921_STATE) 
-						pri_message("-- Unsolicited RR with P/F bit, responding\n");
+						pri_message(0,"-- Unsolicited RR with P/F bit, responding\n");
 						q921_rr(pri, 1, 0);
 				}
 				pri->solicitfbit = 0;
@@ -751,7 +751,7 @@
       case 1:
          /* Receiver not ready */
          if (pri->debug & PRI_DEBUG_Q921_STATE)
-            pri_message("-- Got receiver not ready\n");
+            pri_message(0,"-- Got receiver not ready\n");
 	 if(h->s.p_f) {
 		/* Send RR if poll bit set */
 		q921_rr(pri, h->s.p_f, 0);
@@ -761,7 +761,7 @@
       case 2:
          /* Just retransmit */
          if (pri->debug & PRI_DEBUG_Q921_STATE)
-            pri_message("-- Got reject requesting packet %d...  Retransmitting.\n", h->s.n_r);
+            pri_message(0,"-- Got reject requesting packet %d...  Retransmitting.\n", h->s.n_r);
          if (h->s.p_f) {
             /* If it has the poll bit set, send an appropriate supervisory response */
             q921_rr(pri, 1, 0);
@@ -818,7 +818,7 @@
 					/* Section 5.7.1 says we should restart on receiving a DM response with the f-bit set to
 					   one, but we wait T200 first */
 					if (pri->debug & PRI_DEBUG_Q921_STATE)
-						pri_message("-- Got DM Mode from peer.\n");
+						pri_message(0,"-- Got DM Mode from peer.\n");
 					/* Disconnected mode, try again after T200 */
 					ev = q921_dchannel_down(pri);
 					q921_start(pri, 0);
@@ -826,7 +826,7 @@
 						
 				} else {
 					if (pri->debug & PRI_DEBUG_Q921_STATE)
-						pri_message("-- Ignoring unsolicited DM with p/f set to 0\n");
+						pri_message(0,"-- Ignoring unsolicited DM with p/f set to 0\n");
 #if 0
 					/* Requesting that we start */
 					q921_start(pri, 0);
@@ -834,12 +834,12 @@
 				}
 				break;
 			} else if (!h->u.m2) {
-				pri_message("XXX Unnumbered Information not implemented XXX\n");
+				pri_message(0,"XXX Unnumbered Information not implemented XXX\n");
 			}
 			break;
 		case 2:
 			if (pri->debug &  PRI_DEBUG_Q921_STATE)
-				pri_message("-- Got Disconnect from peer.\n");
+				pri_message(0,"-- Got Disconnect from peer.\n");
 			/* Acknowledge */
 			q921_send_ua(pri, h->u.p_f);
 			ev = q921_dchannel_down(pri);
@@ -849,7 +849,7 @@
 			if (h->u.m2 == 3) {
 				/* SABME */
 				if (pri->debug & PRI_DEBUG_Q921_STATE) {
-					pri_message("-- Got SABME from %s peer.\n", h->h.c_r ? "network" : "cpe");
+					pri_message(0,"-- Got SABME from %s peer.\n", h->h.c_r ? "network" : "cpe");
 				}
 				if (h->h.c_r) {
 					pri->remotetype = PRI_NETWORK;
@@ -871,7 +871,7 @@
 					/* It's a UA */
 				if (pri->q921_state == Q921_AWAITING_ESTABLISH) {
 					if (pri->debug & PRI_DEBUG_Q921_STATE) {
-						pri_message("-- Got UA from %s peer  Link up.\n", h->h.c_r ? "cpe" : "network");
+						pri_message(0,"-- Got UA from %s peer  Link up.\n", h->h.c_r ? "cpe" : "network");
 					}
 					return q921_dchannel_up(pri);
 				} else 
Index: libpri/q931.c
===================================================================
RCS file: /usr/cvsroot/libpri/q931.c,v
retrieving revision 1.84
diff -u -r1.84 q931.c
--- libpri/q931.c	25 Aug 2004 06:20:50 -0000	1.84
+++ libpri/q931.c	23 Oct 2004 22:25:41 -0000
@@ -442,30 +442,30 @@
 		"No channel selected", "As indicated in following octets", "Reserved","Any channel selected"
 	};
 
-	pri_message("%c Channel ID (len=%2d) [ Ext: %d  IntID: %s, %s Spare: %d, %s Dchan: %d\n",
+	pri_message(0,"%c Channel ID (len=%2d) [ Ext: %d  IntID: %s, %s Spare: %d, %s Dchan: %d\n",
 		prefix, len, (ie->data[0] & 0x80) ? 1 : 0, (ie->data[0] & 0x40) ? "Explicit" : "Implicit",
 		(ie->data[0] & 0x20) ? "PRI" : "Other", (ie->data[0] & 0x10) ? 1 : 0,
 		(ie->data[0] & 0x08) ? "Exclusive" : "Preferred",  (ie->data[0] & 0x04) ? 1 : 0);
-	pri_message("%c                        ChanSel: %s\n",
+	pri_message(0,"%c                        ChanSel: %s\n",
 		prefix, msg_chan_sel[(ie->data[0] & 0x3) + ((ie->data[0]>>3) & 0x4)]);
 	pos++;
 	len--;
 	if (ie->data[0] &  0x40) {
 		/* Explicitly defined DS1 */
-		pri_message("%c                       Ext: %d  DS1 Identifier: %d  \n", prefix, (ie->data[pos] & 0x80) >> 7, ie->data[pos] & 0x7f);
+		pri_message(0,"%c                       Ext: %d  DS1 Identifier: %d  \n", prefix, (ie->data[pos] & 0x80) >> 7, ie->data[pos] & 0x7f);
 		pos++;
 	} else {
 		/* Implicitly defined DS1 */
 	}
 	if (pos+2 < len) {
 		/* Still more information here */
-		pri_message("%c                       Ext: %d  Coding: %d   %s Specified   Channel Type: %d\n",
+		pri_message(0,"%c                       Ext: %d  Coding: %d   %s Specified   Channel Type: %d\n",
 				prefix, (ie->data[pos] & 0x80) >> 7, (ie->data[pos] & 60) >> 5, 
 				(ie->data[pos] & 0x10) ? "Slot Map" : "Number", ie->data[pos] & 0x0f);
 		if (!(ie->data[pos] & 0x10)) {
 			/* Number specified */
 			pos++;
-			pri_message("%c                       Ext: %d  Channel: %d ]\n", prefix, (ie->data[pos] & 0x80) >> 7, 
+			pri_message(0,"%c                       Ext: %d  Channel: %d ]\n", prefix, (ie->data[pos] & 0x80) >> 7, 
 				(ie->data[pos]) & 0x7f);
 		} else {
 			pos++;
@@ -474,9 +474,9 @@
 				res <<= 8;
 				res |= ie->data[pos++];
 			}
-			pri_message("%c                       Map: %s ]\n", prefix, binary(res, 24));
+			pri_message(0,"%c                       Map: %s ]\n", prefix, binary(res, 24));
 		}
-	} else pri_message("                         ]\n");				
+	} else pri_message(0,"                         ]\n");				
 }
 
 static char *ri2str(int ri)
@@ -491,7 +491,7 @@
 
 static FUNC_DUMP(dump_restart_indicator)
 {
-	pri_message("%c Restart Indentifier (len=%2d) [ Ext: %d  Spare: %d  Resetting %s (%d) ]\n", 
+	pri_message(0,"%c Restart Indentifier (len=%2d) [ Ext: %d  Spare: %d  Resetting %s (%d) ]\n", 
 		prefix, len, (ie->data[0] & 0x80) >> 7, (ie->data[0] & 0x78) >> 3, ri2str(ie->data[0] & 0x7), ie->data[0] & 0x7);
 }
 
@@ -607,11 +607,11 @@
 static FUNC_DUMP(dump_bearer_capability)
 {
 	int pos=2;
-	pri_message("%c Bearer Capability (len=%2d) [ Ext: %d  Q.931 Std: %d  Info transfer capability: %s (%d)\n",
+	pri_message(0,"%c Bearer Capability (len=%2d) [ Ext: %d  Q.931 Std: %d  Info transfer capability: %s (%d)\n",
 		prefix, len, (ie->data[0] & 0x80 ) >> 7, (ie->data[0] & 0x60) >> 5, cap2str(ie->data[0] & 0x1f), (ie->data[0] & 0x1f));
-	pri_message("%c                              Ext: %d  Trans mode/rate: %s (%d)\n", prefix, (ie->data[1] & 0x80) >> 7, mode2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
+	pri_message(0,"%c                              Ext: %d  Trans mode/rate: %s (%d)\n", prefix, (ie->data[1] & 0x80) >> 7, mode2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
 	if ((ie->data[1] & 0x7f) == 0x18) {
-	    pri_message("%c                              Ext: %d  Transfer rate multiplier: %d x 64\n", prefix, (ie->data[2] & 0x80) >> 7, ie->data[2] & 0x7f);
+	    pri_message(0,"%c                              Ext: %d  Transfer rate multiplier: %d x 64\n", prefix, (ie->data[2] & 0x80) >> 7, ie->data[2] & 0x7f);
 		pos++;
 	}
 	/* Stop here if no more */
@@ -619,15 +619,15 @@
 		return;
 	if ((ie->data[1] & 0x7f) != TRANS_MODE_PACKET) {
 		/* Look for octets 5 and 5.a if present */
-		pri_message("%c                              Ext: %d  User information layer 1: %s (%d)\n", prefix, (ie->data[pos] >> 7), l12str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
+		pri_message(0,"%c                              Ext: %d  User information layer 1: %s (%d)\n", prefix, (ie->data[pos] >> 7), l12str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
 		if ((ie->data[pos] & 0x7f) == PRI_LAYER_1_ITU_RATE_ADAPT)
-			pri_message("%c                                Ext: %d  Rate adaptatation: %s (%d)\n", prefix, ie->data[pos] >> 7, ra2str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
+			pri_message(0,"%c                                Ext: %d  Rate adaptatation: %s (%d)\n", prefix, ie->data[pos] >> 7, ra2str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
 		pos++;
 	} else {
 		/* Look for octets 6 and 7 but not 5 and 5.a */
-		pri_message("%c                              Ext: %d  User information layer 2: %s (%d)\n", prefix, ie->data[pos] >> 7, l22str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
+		pri_message(0,"%c                              Ext: %d  User information layer 2: %s (%d)\n", prefix, ie->data[pos] >> 7, l22str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
 		pos++;
-		pri_message("%c                              Ext: %d  User information layer 3: %s (%d)\n", prefix, ie->data[pos] >> 7, l32str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
+		pri_message(0,"%c                              Ext: %d  User information layer 3: %s (%d)\n", prefix, ie->data[pos] >> 7, l32str(ie->data[pos] & 0x7f), ie->data[pos] & 0x7f);
 		pos++;
 	}
 }
@@ -775,7 +775,7 @@
 	char cnum[256];
 
 	q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
-	pri_message("%c Called Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d) '%s' ]\n",
+	pri_message(0,"%c Called Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d) '%s' ]\n",
 		prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f, cnum);
 }
 
@@ -783,7 +783,7 @@
 {
 	char cnum[256];
 	q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
-	pri_message("%c Called Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d) O: %d '%s' ]\n",
+	pri_message(0,"%c Called Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d) O: %d '%s' ]\n",
 		prefix, len, ie->data[0] >> 7,
 		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
 		(ie->data[0] & 0x08) >> 3, cnum);
@@ -796,18 +796,18 @@
 		q931_get_number(cnum, sizeof(cnum), ie->data + 1, len - 3);
 	else
 		q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
-	pri_message("%c Calling Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n", prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
+	pri_message(0,"%c Calling Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)\n", prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
 	if (ie->data[0] & 0x80)
-		pri_message("%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(0), 0, cnum);
+		pri_message(0,"%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(0), 0, cnum);
 	else
-		pri_message("%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
+		pri_message(0,"%c                           Presentation: %s (%d) '%s' ]\n", prefix, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, cnum);
 }
 
 static FUNC_DUMP(dump_calling_party_subaddr)
 {
 	char cnum[256];
 	q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
-	pri_message("%c Calling Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d) O: %d '%s' ]\n",
+	pri_message(0,"%c Calling Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d) O: %d '%s' ]\n",
 		prefix, len, ie->data[0] >> 7,
 		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
 		(ie->data[0] & 0x08) >> 3, cnum);
@@ -822,22 +822,22 @@
 	do {
 		switch(i) {
 		case 0:	/* Octet 3 */
-			pri_message("%c Redirecting Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)",
+			pri_message(0,"%c Redirecting Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)",
 				prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
 			break;
 		case 1: /* Octet 3a */
-			pri_message("\n%c                               Ext: %d Presentation: %s (%d)",
+			pri_message(0,"\n%c                               Ext: %d Presentation: %s (%d)",
 				prefix, ie->data[1] >> 7, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
 			break;
 		case 2: /* Octet 3b */
-			pri_message("\n%c                               Ext: %d Reason: %s (%d)",
+			pri_message(0,"\n%c                               Ext: %d Reason: %s (%d)",
 				prefix, ie->data[2] >> 7, redirection_reason2str(ie->data[2] & 0x7f), ie->data[2] & 0x7f);
 			break;
 		}
 	}
 	while(!(ie->data[i++]& 0x80));
 	q931_get_number(cnum, sizeof(cnum), ie->data + i, ie->len - i);
-	pri_message(" '%s' ]\n", cnum);
+	pri_message(0," '%s' ]\n", cnum);
 }
 
 static FUNC_DUMP(dump_connected_number)
@@ -849,18 +849,18 @@
 	do {
 		switch(i) {
 		case 0:	/* Octet 3 */
-			pri_message("%c Connected Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)",
+			pri_message(0,"%c Connected Number (len=%2d) [ Ext: %d  TON: %s (%d)  NPI: %s (%d)",
 				prefix, len, ie->data[0] >> 7, ton2str((ie->data[0] >> 4) & 0x07), (ie->data[0] >> 4) & 0x07, npi2str(ie->data[0] & 0x0f), ie->data[0] & 0x0f);
 			break;
 		case 1: /* Octet 3a */
-			pri_message("\n%c                             Ext: %d Presentation: %s (%d)",
+			pri_message(0,"\n%c                             Ext: %d Presentation: %s (%d)",
 				prefix, ie->data[1] >> 7, pri_pres2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
 			break;
 		}
 	}
 	while(!(ie->data[i++]& 0x80));
 	q931_get_number(cnum, sizeof(cnum), ie->data + i, ie->len - i);
-	pri_message(" '%s' ]\n", cnum);
+	pri_message(0," '%s' ]\n", cnum);
 }
 
 
@@ -893,7 +893,7 @@
 {
 	char cnum[256];
 	q931_get_number(cnum, sizeof(cnum), ie->data + 2, len - 4);
-	pri_message("%c Redirecting Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d) O: %d '%s' ]\n",
+	pri_message(0,"%c Redirecting Sub-Address (len=%2d) [ Ext: %d  Type: %s (%d) O: %d '%s' ]\n",
 		prefix, len, ie->data[0] >> 7,
 		subaddrtype2str((ie->data[0] & 0x70) >> 4), (ie->data[0] & 0x70) >> 4,
 		(ie->data[0] & 0x08) >> 3, cnum);
@@ -952,10 +952,10 @@
 static FUNC_DUMP(dump_user_user)
 {
 	int x;
-	pri_message("%c User-User Information (len=%2d) [", prefix, len);
+	pri_message(0,"%c User-User Information (len=%2d) [", prefix, len);
 	for (x=0;x<ie->len;x++)
-		pri_message(" %02x", ie->data[x] & 0x7f);
-	pri_message(" ]\n");
+		pri_message(0," %02x", ie->data[x] & 0x7f);
+	pri_message(0," ]\n");
 }
 
 
@@ -1011,10 +1011,10 @@
 
 static FUNC_DUMP(dump_progress_indicator)
 {
-	pri_message("%c Progress Indicator (len=%2d) [ Ext: %d  Coding: %s (%d) 0: %d   Location: %s (%d)\n",
+	pri_message(0,"%c Progress Indicator (len=%2d) [ Ext: %d  Coding: %s (%d) 0: %d   Location: %s (%d)\n",
 		prefix, len, ie->data[0] >> 7, coding2str((ie->data[0] & 0x60) >> 5), (ie->data[0] & 0x60) >> 5,
 		(ie->data[0] & 0x10) >> 4, loc2str(ie->data[0] & 0xf), ie->data[0] & 0xf);
-	pri_message("%c                               Ext: %d  Progress Description: %s (%d) ]\n",
+	pri_message(0,"%c                               Ext: %d  Progress Description: %s (%d) ]\n",
 		prefix, ie->data[1] >> 7, prog2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f);
 }
 
@@ -1121,7 +1121,7 @@
 
 static FUNC_DUMP(dump_call_state)
 {
-	pri_message("%c Call State (len=%2d) [ Ext: %d  Coding: %s (%d) Call state: %s (%d)\n",
+	pri_message(0,"%c Call State (len=%2d) [ Ext: %d  Coding: %s (%d) Call state: %s (%d)\n",
 		prefix, len, ie->data[0] >> 7, coding2str((ie->data[0] & 0xC0) >> 6), (ie->data[0] & 0xC0) >> 6,
 		callstate2str(ie->data[0] & 0x3f), ie->data[0] & 0x3f);
 }
@@ -1129,28 +1129,28 @@
 static FUNC_DUMP(dump_call_identity)
 {
 	int x;
-	pri_message("%c Call Identity (len=%2d) [ ", prefix, len);
+	pri_message(0,"%c Call Identity (len=%2d) [ ", prefix, len);
 	for (x=0;x<ie->len;x++) 
-		pri_message("0x%02X ", ie->data[x]);
-	pri_message(" ]\n");
+		pri_message(0,"0x%02X ", ie->data[x]);
+	pri_message(0," ]\n");
 }
 
 static FUNC_DUMP(dump_time_date)
 {
-	pri_message("%c Time Date (len=%2d) [ ", prefix, len);
+	pri_message(0,"%c Time Date (len=%2d) [ ", prefix, len);
 	if (ie->len > 0)
-		pri_message("%02d", ie->data[0]);
+		pri_message(0,"%02d", ie->data[0]);
 	if (ie->len > 1)
-		pri_message("-%02d", ie->data[1]);
+		pri_message(0,"-%02d", ie->data[1]);
 	if (ie->len > 2)
-		pri_message("-%02d", ie->data[2]);
+		pri_message(0,"-%02d", ie->data[2]);
 	if (ie->len > 3)
-		pri_message(" %02d", ie->data[3]);
+		pri_message(0," %02d", ie->data[3]);
 	if (ie->len > 4)
-		pri_message(":%02d", ie->data[4]);
+		pri_message(0,":%02d", ie->data[4]);
 	if (ie->len > 5)
-		pri_message(":%02d", ie->data[5]);
-	pri_message(" ]\n");
+		pri_message(0,":%02d", ie->data[5]);
+	pri_message(0," ]\n");
 }
 
 static FUNC_DUMP(dump_display)
@@ -1167,7 +1167,7 @@
 		for (y=x; x<ie->len; x++) 
 			buf[x] = ie->data[x] & 0x7f;
 		buf[x] = '\0';
-		pri_message("%c Display (len=%2d) %s[ %s ]\n", prefix, ie->len, tmp, &buf[y]);
+		pri_message(0,"%c Display (len=%2d) %s[ %s ]\n", prefix, ie->len, tmp, &buf[y]);
 		free(buf);
 	}
 }
@@ -1207,25 +1207,25 @@
 	}
 	if (lastascii)
 		tmp[x++] = '\'';
-	pri_message(tmp);
+	pri_message(0,tmp);
 }
 
 static FUNC_DUMP(dump_facility)
 {
-	pri_message("%c Facility (len=%2d, codeset=%d) [ ", prefix, len, Q931_IE_CODESET(full_ie));
+	pri_message(0,"%c Facility (len=%2d, codeset=%d) [ ", prefix, len, Q931_IE_CODESET(full_ie));
 	dump_ie_data(ie->data, ie->len);
-	pri_message(" ]\n");
+	pri_message(0," ]\n");
 }
 
 static FUNC_DUMP(dump_network_spec_fac)
 {
-       pri_message("%c Network-Specific Facilities (len=%2d) [ ", prefix, ie->len);
+       pri_message(0,"%c Network-Specific Facilities (len=%2d) [ ", prefix, ie->len);
        if (ie->data[0] == 0x00) {
-               pri_message (code2str(ie->data[1], facilities, sizeof(facilities) / sizeof(facilities[0])));
+               pri_message(0,code2str(ie->data[1], facilities, sizeof(facilities) / sizeof(facilities[0])));
        }
        else
                dump_ie_data(ie->data, ie->len);
-       pri_message(" ]\n");
+       pri_message(0," ]\n");
 }
 
 static FUNC_RECV(receive_network_spec_fac)
@@ -1268,14 +1268,14 @@
 static FUNC_DUMP(dump_cause)
 {
 	int x;
-	pri_message("%c Cause (len=%2d) [ Ext: %d  Coding: %s (%d) 0: %d   Location: %s (%d)\n",
+	pri_message(0,"%c Cause (len=%2d) [ Ext: %d  Coding: %s (%d) 0: %d   Location: %s (%d)\n",
 		prefix, len, ie->data[0] >> 7, coding2str((ie->data[0] & 0x60) >> 5), (ie->data[0] & 0x60) >> 5,
 		(ie->data[0] & 0x10) >> 4, loc2str(ie->data[0] & 0xf), ie->data[0] & 0xf);
-	pri_message("%c                  Ext: %d  Cause: %s (%d), class = %s (%d) ]\n",
+	pri_message(0,"%c                  Ext: %d  Cause: %s (%d), class = %s (%d) ]\n",
 		prefix, (ie->data[1] >> 7), pri_cause2str(ie->data[1] & 0x7f), ie->data[1] & 0x7f, 
 			pri_causeclass2str((ie->data[1] & 0x7f) >> 4), (ie->data[1] & 0x7f) >> 4);
 	for (x=2;x<ie->len;x++) 
-		pri_message("%c              Cause data %d: %02x (%d)\n", prefix, x-1, ie->data[x], ie->data[x]);
+		pri_message(0,"%c              Cause data %d: %02x (%d)\n", prefix, x-1, ie->data[x], ie->data[x]);
 }
 
 static FUNC_RECV(receive_cause)
@@ -1300,7 +1300,7 @@
 
 static FUNC_DUMP(dump_sending_complete)
 {
-	pri_message("%c Sending Complete (len=%2d)\n", prefix, len);
+	pri_message(0,"%c Sending Complete (len=%2d)\n", prefix, len);
 }
 
 static FUNC_RECV(receive_sending_complete)
@@ -1353,7 +1353,7 @@
 
 static FUNC_DUMP(dump_notify)
 {
-	pri_message("%c Notification indicator (len=%2d): Ext: %d  %s (%d)\n", prefix, len, ie->data[0] >> 7, notify2str(ie->data[0] & 0x7f), ie->data[0] & 0x7f);
+	pri_message(0,"%c Notification indicator (len=%2d): Ext: %d  %s (%d)\n", prefix, len, ie->data[0] >> 7, notify2str(ie->data[0] & 0x7f), ie->data[0] & 0x7f);
 }
 
 static FUNC_RECV(receive_notify)
@@ -1373,7 +1373,7 @@
 
 static FUNC_DUMP(dump_shift)
 {
-	pri_message("%c %sLocking Shift (len=%02d): Requested codeset %d\n", prefix, (full_ie & 8) ? "Non-" : "", len, full_ie & 7);
+	pri_message(0,"%c %sLocking Shift (len=%02d): Requested codeset %d\n", prefix, (full_ie & 8) ? "Non-" : "", len, full_ie & 7);
 }
 
 static char *lineinfo2str(int info)
@@ -1410,7 +1410,7 @@
 
 static FUNC_DUMP(dump_line_information)
 {
-	pri_message("%c Originating Line Information (len=%02d): %s (%d)\n", prefix, len, lineinfo2str(ie->data[0]), ie->data[0]);
+	pri_message(0,"%c Originating Line Information (len=%02d): %s (%d)\n", prefix, len, lineinfo2str(ie->data[0]), ie->data[0]);
 }
 
 static FUNC_RECV(receive_line_information)
@@ -1591,14 +1591,14 @@
 	int full_ie = Q931_FULL_IE(codeset, ie->ie);
 	int base_ie;
 
-	pri_message("%c [", prefix);
-	pri_message("%02x", ie->ie);
+	pri_message(0,"%c [", prefix);
+	pri_message(0,"%02x", ie->ie);
 	if (!(ie->ie & 0x80)) {
-		pri_message(" %02x", ielen(ie)-2);
+		pri_message(0," %02x", ielen(ie)-2);
 		for (x = 0; x + 2 < ielen(ie); ++x)
-			pri_message(" %02x", ie->data[x]);
+			pri_message(0," %02x", ie->data[x]);
 	}
-	pri_message("]\n");
+	pri_message(0,"]\n");
 
 	/* Special treatment for shifts */
 	if((full_ie & 0xf0) == Q931_LOCKING_SHIFT)
@@ -1611,7 +1611,7 @@
 			if (ies[x].dump)
 				ies[x].dump(full_ie, ie, ielen(ie), prefix);
 			else
-				pri_message("%c IE: %s (len = %d)\n", prefix, ies[x].name, ielen(ie));
+				pri_message(0,"%c IE: %s (len = %d)\n", prefix, ies[x].name, ielen(ie));
 			return;
 		}
 	
@@ -1631,7 +1631,7 @@
 	}
 	/* No call exists, make a new one */
 	if (pri->debug & PRI_DEBUG_Q931_STATE)
-		pri_message("-- Making new call for cr %d\n", cr);
+		pri_message(0,"-- Making new call for cr %d\n", cr);
 	cur = malloc(sizeof(struct q931_call));
 	if (cur) {
 		call_init(cur);
@@ -1676,7 +1676,7 @@
 			else
 				*pri->callpool = cur->next;
 			if (pri->debug & PRI_DEBUG_Q931_STATE)
-				pri_message("NEW_HANGUP DEBUG: Destroying the call, ourstate %s, peerstate %s\n",callstate2str(cur->ourcallstate),callstate2str(cur->peercallstate));
+				pri_message(0,"NEW_HANGUP DEBUG: Destroying the call, ourstate %s, peerstate %s\n",callstate2str(cur->ourcallstate),callstate2str(cur->peercallstate));
 			if (cur->retranstimer)
 				pri_schedule_del(pri, cur->retranstimer);
 			free(cur);
@@ -1762,11 +1762,11 @@
 	int cur_codeset;
 	int codeset;
 	c = txrx ? '>' : '<';
-	pri_message("%c Protocol Discriminator: %s (%d)  len=%d\n", c, disc2str(h->pd), h->pd, len);
-	pri_message("%c Call Ref: len=%2d (reference %d/0x%X) (%s)\n", c, h->crlen, q931_cr(h), q931_cr(h), (h->crv[0] & 0x80) ? "Terminator" : "Originator");
+	pri_message(0,"%c Protocol Discriminator: %s (%d)  len=%d\n", c, disc2str(h->pd), h->pd, len);
+	pri_message(0,"%c Call Ref: len=%2d (reference %d/0x%X) (%s)\n", c, h->crlen, q931_cr(h), q931_cr(h), (h->crv[0] & 0x80) ? "Terminator" : "Originator");
 	/* Message header begins at the end of the call reference number */
 	mh = (q931_mh *)(h->contents + h->crlen);
-	pri_message("%c Message type: %s (%d)\n", c, msg2str(mh->msg), mh->msg);
+	pri_message(0,"%c Message type: %s (%d)\n", c, msg2str(mh->msg), mh->msg);
 	/* Drop length of header, including call reference */
 	len -= (h->crlen + 3);
 	codeset = cur_codeset = 0;
@@ -1796,7 +1796,7 @@
 	unsigned int x;
 	int full_ie = Q931_FULL_IE(codeset, ie->ie);
 	if (pri->debug & PRI_DEBUG_Q931_STATE)
-		pri_message("-- Processing IE %d (cs%d, %s)\n", ie->ie, codeset, ie2str(full_ie));
+		pri_message(0,"-- Processing IE %d (cs%d, %s)\n", ie->ie, codeset, ie2str(full_ie));
 	for (x=0;x<sizeof(ies) / sizeof(ies[0]);x++) {
 		if (full_ie == ies[x].ie) {
 			if (ies[x].receive)
@@ -1808,7 +1808,7 @@
 			}
 		}
 	}
-	pri_message("!! Unknown IE %d (cs%d, %s)\n", ie->ie, codeset, ie2str(full_ie));
+	pri_message(0,"!! Unknown IE %d (cs%d, %s)\n", ie->ie, codeset, ie2str(full_ie));
 	return -1;
 }
 
@@ -1905,7 +1905,7 @@
 		cur = cur->next;
 	}
 	if (!cur) {
-		pri_message("YYY Here we get reset YYY\n");
+		pri_message(0,"YYY Here we get reset YYY\n");
 		/* something went wrong, respond with "no such call" */
 		c->ourcallstate = Q931_CALL_STATE_NULL;
 		c->peercallstate = Q931_CALL_STATE_NULL;
@@ -2043,7 +2043,7 @@
 	struct q931_call *c = data;
 	struct pri *pri = c->pri;
 	if (pri->debug & PRI_DEBUG_Q931_STATE)
-		pri_message("Timed out looking for connect acknowledge\n");
+		pri_message(0,"Timed out looking for connect acknowledge\n");
 	q931_disconnect(pri, c, PRI_CAUSE_NORMAL_CLEARING);
 	
 }
@@ -2053,7 +2053,7 @@
 	struct q931_call *c = data;
 	struct pri *pri = c->pri;
 	if (pri->debug & PRI_DEBUG_Q931_STATE)
-		pri_message("Timed out looking for release complete\n");
+		pri_message(0,"Timed out looking for release complete\n");
 	c->t308_timedout++;
 	c->alive = 1;
 	q931_release(pri, c, PRI_CAUSE_NORMAL_CLEARING);
@@ -2065,7 +2065,7 @@
 	struct pri *pri = c->pri;
 	c->alive = 1;
 	if (pri->debug & PRI_DEBUG_Q931_STATE)
-		pri_message("Final time-out looking for release complete\n");
+		pri_message(0,"Final time-out looking for release complete\n");
 	c->t308_timedout++;
 	c->ourcallstate = Q931_CALL_STATE_NULL;
 	c->peercallstate = Q931_CALL_STATE_NULL;
@@ -2083,7 +2083,7 @@
 	struct q931_call *c = data;
 	struct pri *pri = c->pri;
 	if (pri->debug & PRI_DEBUG_Q931_STATE)
-		pri_message("Timed out looking for release\n");
+		pri_message(0,"Timed out looking for release\n");
 	c->alive = 1;
 	q931_release(pri, c, PRI_CAUSE_NORMAL_CLEARING);
 }
@@ -2297,7 +2297,7 @@
 	int disconnect = 1;
 	int release_compl = 0;
 	if (pri->debug & PRI_DEBUG_Q931_STATE)
-		pri_message("NEW_HANGUP DEBUG: Calling q931_hangup, ourstate %s, peerstate %s\n",callstate2str(c->ourcallstate),callstate2str(c->peercallstate));
+		pri_message(0,"NEW_HANGUP DEBUG: Calling q931_hangup, ourstate %s, peerstate %s\n",callstate2str(c->ourcallstate),callstate2str(c->peercallstate));
 	if (!pri || !c)
 		return -1;
 	/* If mandatory IE was missing, insist upon that cause code */
@@ -2420,7 +2420,7 @@
 	switch(mh->msg) {
 	case Q931_RESTART:
 		if (pri->debug & PRI_DEBUG_Q931_STATE)
-			pri_message("-- Processing Q.931 Restart\n");
+			pri_message(0,"-- Processing Q.931 Restart\n");
 		/* Reset information */
 		c->channelno = -1;
 		c->slotmap = -1;
@@ -2433,7 +2433,7 @@
 		break;
 	case Q931_SETUP:
 		if (pri->debug & PRI_DEBUG_Q931_STATE)
-			pri_message("-- Processing Q.931 Call Setup\n");
+			pri_message(0,"-- Processing Q.931 Call Setup\n");
 		c->channelno = -1;
 		c->slotmap = -1;
 		c->chanflags = 0;
@@ -2555,7 +2555,7 @@
 			y = ie->ie & 7;	/* Requested codeset */
 			/* Locking shifts couldn't go to lower codeset, and couldn't follows non-locking shifts - verify this */
 			if ((cur_codeset != codeset) && (pri->debug & PRI_DEBUG_Q931_ANOMALY))
-				pri_message("XXX Locking shift immediately follows non-locking shift (from %d through %d to %d) XXX\n", codeset, cur_codeset, y);
+				pri_message(0,"XXX Locking shift immediately follows non-locking shift (from %d through %d to %d) XXX\n", codeset, cur_codeset, y);
 			if (y > 0) {
 				if ((y < codeset) && (pri->debug & PRI_DEBUG_Q931_ANOMALY))
 					pri_error("!! Trying to locked downshift codeset from %d to %d !!\n", codeset, y);
@@ -2574,7 +2574,7 @@
 			if (!(ie->ie & 0x80)) {
 				if (last_ie[cur_codeset] > ie->ie) {
 					if ((pri->debug & PRI_DEBUG_Q931_ANOMALY))
-						pri_message("XXX Out-of-order IE %d at codeset %d (last was %d)\n", ie->ie, cur_codeset, last_ie[cur_codeset]);
+						pri_message(0,"XXX Out-of-order IE %d at codeset %d (last was %d)\n", ie->ie, cur_codeset, last_ie[cur_codeset]);
 				}
 				else
 					last_ie[cur_codeset] = ie->ie;
@@ -2585,7 +2585,7 @@
 			case PRI_SWITCH_ATT4ESS:
 				if (cur_codeset != codeset) {
 					if ((pri->debug & PRI_DEBUG_Q931_DUMP))
-						pri_message("XXX Ignoring IE %d for temporary codeset %d XXX\n", ie->ie, cur_codeset);
+						pri_message(0,"XXX Ignoring IE %d for temporary codeset %d XXX\n", ie->ie, cur_codeset);
 					break;
 				}
 				/* Fall through */
@@ -2705,7 +2705,7 @@
 		pri->ev.facname.cref = c->cr;
 		pri->ev.facname.call = c;
 #if 0
-		pri_message("Sending facility event (%s/%s)\n", pri->ev.facname.callingname, pri->ev.facname.callingnum);
+		pri_message(0,"Sending facility event (%s/%s)\n", pri->ev.facname.callingname, pri->ev.facname.callingnum);
 #endif
 		return Q931_RES_HAVEEVENT;
 	case Q931_PROGRESS:
