Untested patch for Ir (NOT IrDA!) connections
[gnokii.git] / gnokii / gnokii.c
index 25f66ec..ca1a7ea 100644 (file)
@@ -731,7 +731,15 @@ static int usage(void)
 
   fprintf(stdout, _("   usage: gnokii [--help] [--version]\n"
   ));
+
+#ifdef UCLINUX
+  fprintf(stdout, _(
+"          gnokii --ir <command> [<command args>...]\n"
+  ));
+#endif /* UCLINUX */
+
 #ifndef UCLINUX
+  fprintf(stdout, _(
 "          gnokii --monitor [-noloop|-nl]\n"
   ));
 #endif /* UCLINUX */
@@ -1038,7 +1046,7 @@ int main(int argc, char *argv[])
 {
 
   int c, i, rc = -1;
-  int nargc = argc-2;
+  int nargc;
   char **nargv;
 
   /* Every option should be in this array. */
@@ -1264,6 +1272,12 @@ int main(int argc, char *argv[])
     if (CFG_ReadConfig(&model, &Port, &Initlength, &Connection, &BinDir, false) < 0) {
        exit(-1);
     }
+    if (argc>1 && !strcmp(argv[1],"--ir")) {
+       argc--;
+       argv[1]=argv[0];
+       argv++;
+       Connection="infrared";
+    }
 
   /* Handle command line arguments. */
 
@@ -1284,6 +1298,7 @@ int main(int argc, char *argv[])
 
   if((nargv = malloc(sizeof(char *) * argc)) != NULL) {
 
+         nargc = argc-2;
     for(i = 2; i < argc; i++)
       nargv[i-2] = argv[i];
                nargv[argc-2] = NULL;   /* required by gnokiid() for execv(3) */
@@ -4254,11 +4269,6 @@ static void gnokiid_SIGCHLD(int signo)
 static int gnokiid(int argc, char *argv[])
 {
        bool    DebugMode;  /* When true, run in debug mode */
-       char    *Model;   /* Model from .gnokiirc file. */
-       char    *Port;    /* Port from .gnokiirc file */
-       char    *Initlength;  /* Init length from .gnokiirc file */
-       char    *Connection;  /* Connection type from .gnokiirc file */
-       char    *BinDir;  /* Directory of the mgnokiidev command */
 
        /* evaluate for presence of "--debug" argument in parameter */
        DebugMode = false;
@@ -4276,10 +4286,7 @@ static int gnokiid(int argc, char *argv[])
   fprintf (stderr, _("Initializing gnokiid mode...\n"));
 #endif
 
-       if (CFG_ReadConfig(&Model, &Port, &Initlength, &Connection, &BinDir, true) < 0)
-               return(-1);
-
-  if (VM_Initialise(Model, Port, Initlength, GCT_FBUS, BinDir, DebugMode, true, ""/*SynchronizeTime*/) == false)
+  if (VM_Initialise(model, Port, Initlength, GetConnectionTypeFromString(Connection), BinDir, DebugMode, true, ""/*SynchronizeTime*/) == false)
                return (-1);
 
        if (argc>0) {