[zaptel-commits] tzafrir: branch 1.4 r3958 - /branches/1.4/kernel/zaptel-base.c

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Thu Mar 6 19:01:43 CST 2008


Author: tzafrir
Date: Thu Mar  6 19:01:42 2008
New Revision: 3958

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3958
Log:
Also print channel alarms in /proc/zaptel files.

Modified:
    branches/1.4/kernel/zaptel-base.c

Modified: branches/1.4/kernel/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/kernel/zaptel-base.c?view=diff&rev=3958&r1=3957&r2=3958
==============================================================================
--- branches/1.4/kernel/zaptel-base.c (original)
+++ branches/1.4/kernel/zaptel-base.c Thu Mar  6 19:01:42 2008
@@ -513,6 +513,31 @@
 
 }
 
+static inline int fill_alarm_string(char *buf, int count, int alarms)
+{
+	int	len = 0;
+
+	if (alarms > 0) {
+		if (alarms & ZT_ALARM_BLUE)
+			len += snprintf(buf + len, count - len, "BLUE ");
+		if (alarms & ZT_ALARM_YELLOW)
+			len += snprintf(buf + len, count - len, "YELLOW ");
+		if (alarms & ZT_ALARM_RED)
+			len += snprintf(buf + len, count - len, "RED ");
+		if (alarms & ZT_ALARM_LOOPBACK)
+			len += snprintf(buf + len, count - len, "LOOP ");
+		if (alarms & ZT_ALARM_RECOVER)
+			len += snprintf(buf + len, count - len, "RECOVERING ");
+		if (alarms & ZT_ALARM_NOTOPEN)
+			len += snprintf(buf + len, count - len, "NOTOPEN ");
+	}
+	if(len > 0) {
+		len--;
+		buf[len] = '\0';	/* strip last space */
+	}
+	return len;
+}
+
 static int zaptel_proc_read(char *page, char **start, off_t off, int count, int *eof, void *data)
 {
 	int x, len = 0;
@@ -558,21 +583,7 @@
 	len += sprintf(page + len, " ");
 
 	/* list alarms */
-	if (spans[span]->alarms && (spans[span]->alarms > 0)) {
-		if (spans[span]->alarms & ZT_ALARM_BLUE)
-			len += sprintf(page + len, "BLUE ");
-		if (spans[span]->alarms & ZT_ALARM_YELLOW)
-			len += sprintf(page + len, "YELLOW ");
-		if (spans[span]->alarms & ZT_ALARM_RED)
-			len += sprintf(page + len, "RED ");
-		if (spans[span]->alarms & ZT_ALARM_LOOPBACK)
-			len += sprintf(page + len, "LOOP ");
-		if (spans[span]->alarms & ZT_ALARM_RECOVER)
-			len += sprintf(page + len, "RECOVERING ");
-		if (spans[span]->alarms & ZT_ALARM_NOTOPEN)
-			len += sprintf(page + len, "NOTOPEN ");
-					
-	}
+	len += fill_alarm_string(page + len, count - len, spans[span]->alarms);
 	if (spans[span]->syncsrc && (spans[span]->syncsrc == spans[span]->spanno))
 		len += sprintf(page + len, "ClockSource ");
 	len += sprintf(page + len, "\n");
@@ -613,6 +624,7 @@
 					len += sprintf(page + len, "(no pcm) ");
 				}
 #endif
+				len += fill_alarm_string(page + len, count - len, chans[x]->chan_alarms);
 				len += sprintf(page + len, "\n");
 			}
 			if (len <= off) { /* If everything printed so far is before beginning of request */




More information about the zaptel-commits mailing list