do better callsign checking
[spider.git] / src / client.c
index b50514fa618f47bb0895bbdb61977ac1c43d0402..5258e39d8163860543b8c1d6a0fef5ae14e48da1 100644 (file)
@@ -44,7 +44,9 @@
 #define MAXPATHLEN 256
 #endif
 
+#define DEFPACLEN 128
 #define MAXPACLEN 236
+
 #define DBUF 1
 #define DMSG 2
 
@@ -84,15 +86,27 @@ char echo = 1;                                      /* echo characters on stdout from stdin */
 char int_tabs = 0;                             /* interpret tabs -> spaces */
 char *root = "/spider";         /* root of data tree, can be overridden by DXSPIDER_ROOT  */
 int timeout = 60;                              /* default timeout for logins and things */
-int paclen = 128;                              /* default buffer size for outgoing packets */
+int paclen = DEFPACLEN;                        /* default buffer size for outgoing packets */
 int tabsize = 8;                               /* default tabsize for text messages */
 
 myregex_t iscallreg[] = {              /* regexes to determine whether this is a reasonable callsign */
        {
-               "^[A-Z]+[0-9]+[A-Z]+", 0
+               "^[A-Z]+[0-9]+[A-Z]+[1-9]?$", 0
+       },
+       {
+               "^[0-9]+[A-Z]+[0-9]+[A-Z]+[1-9]?$", 0
+       },
+       {
+               "^[A-Z]+[0-9]+[A-Z]+[1-9]?-[1-9]$", 0
+       },
+       {
+               "^[0-9]+[A-Z]+[0-9]+[A-Z]+[1-9]?-[1-9]$", 0
        },
        {
-               "^[0-9]+[A-Z]+[0-9]+[A-Z]+", 0
+               "^[A-Z]+[0-9]+[A-Z]+[1-9]?-1[0-5]$", 0
+       },
+       {
+               "^[0-9]+[A-Z]+[0-9]+[A-Z]+[1-9]?-1[0-5]$", 0
        },
        {
                0, 0
@@ -488,6 +502,11 @@ lerr:
                nl = '\n';
                echo = 1;
        }
+
+       /* this is kludgy, but hey so is the rest of this! */
+       if (!eq(connsort, "ax25") && paclen == DEFPACLEN) {
+               paclen = MAXPACLEN;
+       }
 }
 
 void connect_to_node()
@@ -707,9 +726,11 @@ main(int argc, char *argv[])
                }
                buf[r] = 0;
                call = strupper(buf);
-               if (!iscallsign(call)) {
-                       die("Sorry, %s isn't a valid callsign", buf);
-               }
+       }
+
+       /* check the callsign */
+       if (!iscallsign(call)) {
+               die("Sorry, %s isn't a valid callsign", call);
        }
        
        /* connect up stdin */