LCR now runs as a user.
[lcr.git] / lcradmin.c
index 188d718..042a4b0 100644 (file)
@@ -23,6 +23,7 @@
 #include <errno.h>
 #include <curses.h>
 #include "macro.h"
+#include "options.h"
 #include "join.h"
 #include "joinpbx.h"
 #include "extension.h"
@@ -76,7 +77,7 @@ char  red = 1,
 
 #define LOGLINES 128
 char logline[LOGLINES][512];
-unsigned long logcur = 0;
+unsigned int logcur = 0;
 int logfh = -1;
 char logfile[128];
 
@@ -209,7 +210,7 @@ int debug_port(struct admin_message *msg, struct admin_message *m, int line, int
 }
 int debug_epoint(struct admin_message *msg, struct admin_message *m, int line, int i, int vline)
 {
-       unsigned long epoint = m[i].u.e.serial;
+       unsigned int epoint = m[i].u.e.serial;
        char buffer[256];
        unsigned char c;
        int j, jj;
@@ -392,7 +393,7 @@ int debug_epoint(struct admin_message *msg, struct admin_message *m, int line, i
 }
 int debug_join(struct admin_message *msg, struct admin_message *m, int line, int i)
 {
-       unsigned long   join = m[i].u.j.serial;
+       unsigned int    join = m[i].u.j.serial;
        char            buffer[256];
        int             j, jj;
 
@@ -457,7 +458,7 @@ char *admin_state(int sock, char *argv[])
                                *p;
        int                     line, offset = 0, hoffset = 0;
        int                     i, ii, j, jj, k;
-       unsigned long           l, ll;
+       unsigned int            l, ll;
        int                     num;
        int                     len;
        int                     off;
@@ -679,8 +680,11 @@ char *admin_state(int sock, char *argv[])
                                        color((m[i].u.i.l2link)?green:red);
                                        addstr((m[i].u.i.l2link)?"  L2 UP":"  L2 down");
                                }
-                               color((m[i].u.i.l1link)?green:blue);
-                               addstr((m[i].u.i.l1link)?"  L1 ACTIVE":"  L1 inactive");
+                               color((m[i].u.i.l1link > 0)?green:blue);
+                               if (m[i].u.i.l1link < 0)
+                                       addstr("  L1 unknown");
+                               else
+                                       addstr((m[i].u.i.l1link)?"  L1 ACTIVE":"  L1 inactive");
                                if (m[i].u.i.los)
                                {
                                        color(red);
@@ -736,6 +740,8 @@ char *admin_state(int sock, char *argv[])
                                                                SPRINT(buffer,"S%2d: ", j+1+(j>=15));
                                                        else
                                                                SPRINT(buffer,"B%2d: ", j+1);
+                                                       if (m[i].u.i.mode[j] == B_MODE_HDLC)
+                                                               SCAT(buffer,"HDLC ");
                                                        addstr(buffer);
                                                        switch(m[i].u.i.busy[j])
                                                        {
@@ -1346,7 +1352,7 @@ char *admin_testcall(int sock, int argc, char *argv[])
        int stimeout = 0, ptimeout = 0, atimeout = 0, ctimeout = 0;
        int l;
        double timer = 0, now_d;
-       unsigned long on = 1;
+       unsigned int on = 1;
        struct timeval now_tv;
        struct timezone now_tz;
 
@@ -1625,7 +1631,6 @@ next:
 int main(int argc, char *argv[])
 {
        int mode;
-       char *socket_name = SOCKET_NAME;
        int sock, conn;
        struct sockaddr_un sock_address;
        char *ret;
@@ -1712,6 +1717,10 @@ int main(int argc, char *argv[])
                goto usage;
        }
 
+       if (read_options() == 0) {
+               exit(EXIT_FAILURE);
+       }
+
 //pipeagain:
        /* open socket */
        if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
@@ -1720,8 +1729,8 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
        memset(&sock_address, 0, sizeof(sock_address));
+       SPRINT(sock_address.sun_path, SOCKET_NAME, options.lock);
        sock_address.sun_family = PF_UNIX;
-       UCPY(sock_address.sun_path, socket_name);
        if ((conn = connect(sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0)
        {
                close(sock);