--- bottlerocket-0.04/br.c~	Thu Jul  8 03:07:03 1999
+++ bottlerocket-0.04/br.c	Sat Jul 10 02:43:03 1999
@@ -1,3 +1,21 @@
+
+/*
+ *
+ * br (BottleRocket)
+ *
+ * Control software for the X10(R) FireCracker wireless computer
+ * interface kit.
+ *
+ * (c) 1999 Ashley Clark (aclark@ghoti.org) and Tymm Twillman (tymm@acm.org)
+ *  Free Software.  LGPL applies.
+ *  No warranties expressed or implied.
+ *
+ * Have fun with it and if you do anything really cool, send an email and let me
+ * know.
+ *
+ */
+
+#include <features.h>
 #include <errno.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
@@ -40,24 +58,8 @@
                         && (fd != STDERR_FILENO))
 
 /*
-
-br (BottleRocket)
-
-Control software for the X10(R) FireCracker wireless computer
-interface kit.
-
-(c) 1999 Ashley Clark (aclark@ghoti.org) and Tymm Twillman (tymm@acm.org)
-  Free Software.  LGPL applies.
-  No warranties expressed or implied.
-
-Have fun with it and if you do anything really cool, send an email and let me
-know.
-
-*/
-
-/*
  * Could have device info/commands dynamically allocated, but that's too much
- *  trouble, and even this allows for really really obnoxious command lines.
+ * trouble, and even this allows for really really obnoxious command lines.
  */
 
 typedef struct {
@@ -121,7 +123,7 @@
     fprintf(stderr, "<housecode>\tis a letter between A and P\n");
     fprintf(stderr, "<native cmd>\tis one of ON, OFF, DIM, BRIGHT, "
       "ALL_ON, ALL_OFF,\n");
-    fprintf(stderr, "\t\tLIGHTS_ON or LIGHTS_OFF\n\n");
+    fprintf(stderr, "\t\tLAMPS_ON or LAMPS_OFF\n\n");
     fprintf(stderr, "For native commands, <list> should only be specified "
       "for ON or OFF.\n\n");
 
@@ -315,7 +317,7 @@
         return ALL_LAMPS_OFF;
 
     fprintf(stderr, "%s:  Command must be one of ON, OFF, DIM, BRIGHT, "
-      "ALLON, ALLOFF, LAMPSON or LAMPSOFF.\n", MyName);
+	    "ALL_ON, ALL_OFF, LAMPS_ON or LAMPS_OFF.\n", MyName);
     errno = EINVAL;
 
     return -1;
@@ -634,21 +636,25 @@
 #ifdef HAVE_GETOPT_LONG    
     int opt_index;
     static struct option long_options[] = {
-        {"help", 0, 0, 'h'},
-        {"port", 1, 0, 'x'},
-        {"repeat", 1, 0, 'r'},
-        {"on", 1, 0, 'n'},
-        {"off", 1, 0, 'f'},
-        {"ON", 0, 0, 'N'},
-        {"OFF", 0, 0, 'F'},
-        {"dim", 1, 0, 'd'},
-        {"lamps_on", 0, 0, 'B'},
-        {"lamps_off", 0, 0, 'D'},
-        {"inverse", 0, 0, 'i'},
-        {0, 0, 0, 0}
+        {"help",  	no_argument, 	    	0, 'h'},
+        {"port",  	required_argument, 	0, 'x'},
+        {"repeat",	required_argument, 	0, 'r'},
+        {"on", 		required_argument, 	0, 'n'},
+        {"off", 	required_argument, 	0, 'f'},
+        {"ON", 		no_argument, 		0, 'N'},
+        {"OFF", 	no_argument, 		0, 'F'},
+        {"dim", 	required_argument, 	0, 'd'},
+        {"lamps_on", 	no_argument, 		0, 'B'},
+        {"lamps_off", 	no_argument, 		0, 'D'},
+        {"inverse", 	no_argument, 		0, 'i'},
+	{"house",	required_argument,	0, 'c'},
+	{"verbose",	no_argument,		0, 'v'},
+	{0, 0, 0, 0}
     };
 #endif
 
+#define OPT_STRING	"x:hvr:ic:n:Nf:Fd:BD"
+    
     /*
      * It's possible to do an exec without even passing argv[0];
      *  this is just to make sure we don't make any bad
@@ -680,11 +686,10 @@
     }
     
 #ifdef HAVE_GETOPT_LONG
-    while ((opt = getopt_long(argc, argv, "x:hvr:ivc:n:Nf:Fd:BD",
-      long_options, &opt_index)) != -1) 
+    while ((opt = getopt_long(argc, argv, OPT_STRING, long_options, &opt_index)) != -1) 
     {
 #else
-    while ((opt = getopt(argc, argv, "x:hvr:ivc:n:Nf:Fd:BD")) != -1) {
+    while ((opt = getopt(argc, argv, OPT_STRING)) != -1) {
 #endif        
         switch (opt) {
         case 'x':
@@ -759,7 +764,7 @@
         }
     }
 
-    if (optind - argc) {
+    if (argc > optind) {
         /*
          * Must be using the native BottleRocket command line...
          */
