7 A Linux/Unix toolset and driver for Nokia mobile phones.
9 Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml.
11 Released under the terms of the GNU GPL, see file COPYING for more details.
13 Mainline code for gnokiid daemon. Handles command line parsing and
14 various daemon functions.
17 Revision 1.1.1.4 2002/04/03 01:44:15 short
18 Implemented connection type "tcp" (GCT_TCP), use <hostname>:<port> as "port"
20 Revision 1.1.1.3 2002/04/03 00:08:17 short
21 Found in "gnokii-working" directory, some November-patches version
23 Revision 1.19 2001/06/28 00:28:45 pkot
24 Small docs updates (Pawel Kot)
26 Revision 1.18 2001/02/21 19:57:09 chris
27 More fiddling with the directory layout
29 Revision 1.17 2000/12/19 16:18:18 pkot
30 configure script updates and added shared function for configfile reading
41 #include <sys/types.h>
46 #include "cfgreader.h"
47 #include "gsm-common.h"
49 #include "data/virtmodem.h"
52 /* Global variables */
53 bool DebugMode; /* When true, run in debug mode */
54 char *Model; /* Model from .gnokiirc file. */
55 char *Port; /* Serial port from .gnokiirc file */
56 char *Initlength; /* Init length from .gnokiirc file */
57 char *Connection; /* Connection type from .gnokiirc file */
58 char *BinDir; /* Directory of the mgnokiidev command */
62 char *DefaultConnection = "serial";
63 char *DefaultBinDir = "/usr/local/sbin";
68 fprintf(stdout, _("gnokiid Version %s\n"
69 "Copyright (C) Hugh Blemings <hugh@blemings.org>, 1999\n"
70 "Copyright (C) Pavel Janík ml. <Pavel.Janik@suse.cz>, 1999\n"
71 "Built %s %s for %s on %s \n"), VERSION, __TIME__, __DATE__, Model, Port);
74 /* The function usage is only informative - it prints this program's usage and
75 command-line options.*/
80 fprintf(stdout, _(" usage: gnokiid {--help|--version}\n"
81 " --help display usage information."
82 " --version displays version and copyright information."
83 " --debug uses stdin/stdout for virtual modem comms.\n"));
86 /* Main function - handles command line arguments, passes them to separate
87 functions accordingly. */
89 int main(int argc, char *argv[])
92 GSM_ConnectionType connection = GCT_Serial;
100 if (readconfig(&Model, &Port, &Initlength, &Connection, &BinDir) < 0) {
105 /* Handle command line arguments. */
107 if (argc >= 2 && strcmp(argv[1], "--help") == 0) {
112 /* Display version, copyright and build information. */
114 if (argc >= 2 && strcmp(argv[1], "--version") == 0) {
119 if (argc >= 2 && strcmp(argv[1], "--debug") == 0) {
125 if (!strcmp(Connection, "infrared")) {
126 connection=GCT_Infrared;
129 if (!strcmp(Connection, "tcp")) {
133 TerminateThread=false;
135 if (VM_Initialise(Model, Port, Initlength, connection, BinDir, DebugMode, true) == false) {
140 if (TerminateThread==true) {