X-Git-Url: https://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=gnokiid%2Fgnokiid.c;h=26cb16fa1d6f1208ddd3e228f47701ff94f67f36;hp=0b589aead3476cbf868b6754edaca0604d681ccb;hb=refs%2Fheads%2Fats;hpb=a2dfc99dc499ea8600bf5178f8122125d7d7d557 diff --git a/gnokiid/gnokiid.c b/gnokiid/gnokiid.c index 0b589ae..26cb16f 100644 --- a/gnokiid/gnokiid.c +++ b/gnokiid/gnokiid.c @@ -1,14 +1,35 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. Mainline code for gnokiid daemon. Handles command line parsing and various daemon functions. + $Log$ + Revision 1.1.1.4 2002/04/03 01:44:15 short + Implemented connection type "tcp" (GCT_TCP), use : as "port" + + Revision 1.1.1.3 2002/04/03 00:08:17 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.19 2001/06/28 00:28:45 pkot + Small docs updates (Pawel Kot) + + Revision 1.18 2001/02/21 19:57:09 chris + More fiddling with the directory layout + + Revision 1.17 2000/12/19 16:18:18 pkot + configure script updates and added shared function for configfile reading + + */ #include @@ -22,28 +43,31 @@ #include #include "misc.h" -#include "files/cfgreader.h" +#include "cfgreader.h" #include "gsm-common.h" #include "gsm-api.h" #include "data/virtmodem.h" -/* Global variables */ -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 *SynchronizeTime; -char *BinDir; /* Directory of the mgnokiidev command */ -bool TerminateThread; +/* Global variables */ +bool DebugMode; /* When true, run in debug mode */ +char *Model; /* Model from .gnokiirc file. */ +char *Port; /* Serial 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 */ +bool TerminateThread; + +/* Local variables */ +char *DefaultConnection = "serial"; +char *DefaultBinDir = "/usr/local/sbin"; void version(void) { - fprintf(stdout, _("gnokiid Version %s\n" -"Copyright (C) Hugh Blemings , 1999\n" -"Copyright (C) Pavel Janík ml. , 1999\n" + fprintf(stdout, _("gnokiid Version %s\n" +"Copyright (C) Hugh Blemings , 1999\n" +"Copyright (C) Pavel Janík ml. , 1999\n" "Built %s %s for %s on %s \n"), VERSION, __TIME__, __DATE__, Model, Port); } @@ -53,7 +77,7 @@ void version(void) void usage(void) { - fprintf(stdout, _(" usage: gnokiid {--help|--version}\n" + fprintf(stdout, _(" usage: gnokiid {--help|--version}\n" " --help display usage information." " --version displays version and copyright information." " --debug uses stdin/stdout for virtual modem comms.\n")); @@ -65,64 +89,59 @@ void usage(void) int main(int argc, char *argv[]) { - GSM_ConnectionType connection; - - /* For GNU gettext */ + GSM_ConnectionType connection = GCT_Serial; - #ifdef USE_NLS - textdomain("gnokii"); - #endif + /* For GNU gettext */ -#ifndef WIN32 - if (strcmp(GetMygnokiiVersion(),VERSION)!=0) - fprintf(stderr,_("WARNING: version of installed libmygnokii.so (%s) is different to version of gnokiid (%s)\n"),GetMygnokiiVersion(),VERSION); +#ifdef USE_NLS + textdomain("gnokii"); #endif - if (CFG_ReadConfig(&Model, &Port, &Initlength, &Connection, &BinDir, &SynchronizeTime,true) < 0) { + if (readconfig(&Model, &Port, &Initlength, &Connection, &BinDir) < 0) { exit(-1); } - /* Handle command line arguments. */ - - if (argc >= 2 && strcmp(argv[1], "--help") == 0) { - usage(); - exit(0); - } - - /* Display version, copyright and build information. */ - - if (argc >= 2 && strcmp(argv[1], "--version") == 0) { - version(); - exit(0); - } - - if (argc >= 2 && strcmp(argv[1], "--debug") == 0) { - DebugMode = true; - } - else { - DebugMode = false; - } - - connection=GetConnectionTypeFromString(Connection); - - /* MBUS wasn't tested */ - if (connection!=GCT_FBUS && connection!=GCT_MBUS && - connection!=GCT_Infrared && connection!=GCT_Tekram) { - fprintf(stdout,_("Incorrect connection type!\n")); - exit(0); - } - - TerminateThread=false; - - if (VM_Initialise(Model, Port, Initlength, connection, BinDir, DebugMode, true, SynchronizeTime) == false) - exit (-1); - - while (1) { - if (TerminateThread==true) { - VM_Terminate(); - exit(1); - } - sleep (1); - } - exit (0); + + /* Handle command line arguments. */ + + if (argc >= 2 && strcmp(argv[1], "--help") == 0) { + usage(); + exit(0); + } + + /* Display version, copyright and build information. */ + + if (argc >= 2 && strcmp(argv[1], "--version") == 0) { + version(); + exit(0); + } + + if (argc >= 2 && strcmp(argv[1], "--debug") == 0) { + DebugMode = true; + } else { + DebugMode = false; + } + + if (!strcmp(Connection, "infrared")) { + connection=GCT_Infrared; + } + + if (!strcmp(Connection, "tcp")) { + connection=GCT_TCP; + } + + TerminateThread=false; + + if (VM_Initialise(Model, Port, Initlength, connection, BinDir, DebugMode, true) == false) { + exit (-1); + } + + while (1) { + if (TerminateThread==true) { + VM_Terminate(); + exit(1); + } + sleep (1); + } + exit (0); }