chiark / gitweb /
*** empty log message ***
[sympathy.git] / apps / sympathy.c
index e93c9302398df284a2cbbcee273c7abe6ac5678d..89cc552d0fdd07d81978833a1999ffd9d4a38958 100644 (file)
@@ -11,6 +11,18 @@ static char rcsid[] =
 
 /*
  * $Log$
+ * Revision 1.21  2008/02/27 16:01:24  james
+ * *** empty log message ***
+ *
+ * Revision 1.20  2008/02/27 10:00:34  james
+ * *** empty log message ***
+ *
+ * Revision 1.19  2008/02/27 09:47:05  james
+ * *** empty log message ***
+ *
+ * Revision 1.18  2008/02/27 09:42:53  james
+ * *** empty log message ***
+ *
  * Revision 1.17  2008/02/27 09:42:21  james
  * *** empty log message ***
  *
@@ -248,7 +260,7 @@ main (int argc, char *argv[])
   int c;
   extern char *optarg;
   extern int optind, opterr, optopt;
-  CRT_Pos size={VT102_COLS_80,VT102_ROWS};
+  CRT_Pos size = { VT102_COLS_80, VT102_ROWS };
 
   int oflags[128];
   char *oargs[128];
@@ -298,15 +310,6 @@ main (int argc, char *argv[])
     oflags['s'] = 0;
 
 
-  if (!oflags['s'] && !oflags['c'] && !oflags['t'] && !oflags['r']
-      && !oflags['l'])
-    {
-      /*If no mode is specified behave like screen */
-      oflags['s']++;
-      oflags['c']++;
-    }
-
-
   {
     int sum = 0;
     sum += oflags['t'];
@@ -315,14 +318,24 @@ main (int argc, char *argv[])
     sum += oflags['l'];
     sum += oflags['v'];
 
+    if (!sum) {
+      /*If no mode is specified behave like screen */
+      oflags['s']++;
+      oflags['c']++;
+      sum++;
+    }
+       
     if (sum != 1)
-      fatal_moan ("specifiy exactly one of ( -c and or -s ), -t, -r, -l and -v");
+      fatal_moan
+        ("specifiy exactly one of ( -c and or -s ), -t, -r, -l and -v");
   }
 
-  if (oflags['v']) {
-       fprintf("Version: %s\n",libsympathy_version());
-       return 0;
-  }
+  if (oflags['v'])
+    {
+      fprintf (stderr, "Version: %s\n", libsympathy_version ());
+      fprintf (stderr, "Version: %s\n", rcsid);
+      return 0;
+    }
 
   if (oflags['l'])
     return list_sockets ();
@@ -345,12 +358,16 @@ main (int argc, char *argv[])
   /*Fold -r into -c */
   if (oflags['r'])
     {
-      int id = safe_atoi (oargs['r']);
+      char *id = oargs['r'];
       if (id < 0)
         fatal_moan ("cannot parse -r %s as an integer", oargs['r']);
 
       oflags['k']++;
-      oargs['k'] = mome ("/.sympathy/%s%d", hostname, id);
+      if (safe_atoi(id)>0) {
+       oargs['k'] = mome ("/.sympathy/%s%d", hostname, safe_atoi(id));
+      } else {
+       oargs['k'] = mome ("/.sympathy/%s", id);
+      }
       oflags['r'] = 0;
       oflags['c']++;
     }
@@ -428,22 +445,24 @@ main (int argc, char *argv[])
 
   if (oflags['w'])
     {
-       char buf[128],*ptr;
-       strcpy(buf,oargs['w']);
-       ptr=index(buf,'x');
-       if (ptr) {
-               *ptr=0;
-               ptr++;
-               size.y=safe_atoi(ptr);
-       }
-       size.x=safe_atoi(buf);  
+      char buf[128], *ptr;
+      strcpy (buf, oargs['w']);
+      ptr = index (buf, 'x');
+      if (ptr)
+        {
+          *ptr = 0;
+          ptr++;
+          size.y = safe_atoi (ptr);
+        }
+      size.x = safe_atoi (buf);
 
       if ((size.x > VT102_MAX_COLS) || (size.x < 1))
         fatal_moan ("-w requires a width between 1 and %d\n", VT102_MAX_COLS);
 
       if ((size.y > VT102_ROWS) || (size.y < 1))
-        fatal_moan ("-w requires a height between 1 and %d\n", VT102_MAX_COLS);
-       
+        fatal_moan ("-w requires a height between 1 and %d\n",
+                    VT102_MAX_COLS);
+
     }
 
   if (oflags['s'] && !oflags['F'])