From 6f49fd782b8935b8caf7cea7bcb6e10644851b13 Mon Sep 17 00:00:00 2001 From: Daniel Brahneborg Date: Sat, 2 Mar 2002 23:27:47 +0000 Subject: Actually copy stuff to the psion, and lots of other updates. --- sisinstall/sismain.cpp | 51 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'sisinstall/sismain.cpp') diff --git a/sisinstall/sismain.cpp b/sisinstall/sismain.cpp index 1b9f714..8516b0f 100644 --- a/sisinstall/sismain.cpp +++ b/sisinstall/sismain.cpp @@ -2,6 +2,7 @@ #include "sisfile.h" #include "sisinstaller.h" #include "psion.h" +#include "fakepsion.h" #include #include @@ -14,18 +15,33 @@ static void error(int line) { - fprintf(stderr, "Got errno = %d (%s) on line %d\n", - errno, strerror(errno), line); + fprintf(stderr, "Got errno = %d on line %d\n", errno, line); exit(1); } void main(int argc, char* argv[]) { char* filename = 0; - if (argc > 1) - filename = argv[1]; - else - return 0; + char option; + bool dryrun = false; + while ((option = getopt(argc, argv, "nl:")) != -1) + { + switch (option) + { + case 'l': + logLevel = atoi(optarg); + break; + case 'n': + dryrun = true; + break; + } + } + if (optind < argc) + { + filename = argv[optind]; + printf("Installing sis file %s%s\n", filename, + dryrun ? ", not really" : ""); + } struct stat st; if (-1 == stat(filename, &st)) error(__LINE__); @@ -39,23 +55,26 @@ void main(int argc, char* argv[]) if (-1 == read(fd, buf, len)) error(__LINE__); close(fd); - Psion psion; -#if 0 - if (!psion.connect()) + Psion* psion; + if (dryrun) + psion = new FakePsion(); + else + psion = new Psion(); + if (!psion->connect()) { printf("Couldn't connect with the Psion\n"); exit(1); } -#endif createCRCTable(); SISFile sisFile; sisFile.fillFrom(buf); - SISInstaller installer; - installer.setPsion(&psion); - installer.run(&sisFile, buf); -#if 0 - psion.disconnect(); -#endif + if (!dryrun) + { + SISInstaller installer; + installer.setPsion(psion); + installer.run(&sisFile, buf); + } + psion->disconnect(); exit(0); } -- cgit v1.2.3