aboutsummaryrefslogtreecommitdiffstats
path: root/sisinstall/sismain.cpp
diff options
context:
space:
mode:
authorDaniel Brahneborg <basic@chello.se>2002-03-02 23:27:47 +0000
committerDaniel Brahneborg <basic@chello.se>2002-03-02 23:27:47 +0000
commit6f49fd782b8935b8caf7cea7bcb6e10644851b13 (patch)
tree3ad7ed335500fbec9ffe59299079760b810c0ce2 /sisinstall/sismain.cpp
parent4f497127917554c3a7249658feee9f5bbae84b88 (diff)
downloadplptools-6f49fd782b8935b8caf7cea7bcb6e10644851b13.tar.gz
plptools-6f49fd782b8935b8caf7cea7bcb6e10644851b13.tar.bz2
plptools-6f49fd782b8935b8caf7cea7bcb6e10644851b13.zip
Actually copy stuff to the psion, and lots of other updates.
Diffstat (limited to 'sisinstall/sismain.cpp')
-rw-r--r--sisinstall/sismain.cpp51
1 files changed, 35 insertions, 16 deletions
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 <errno.h>
#include <fcntl.h>
@@ -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);
}