aboutsummaryrefslogtreecommitdiffstats
path: root/sisinstall/sismain.cpp
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2009-03-05 21:47:24 +0000
committerReuben Thomas <rrt@sc3d.org>2009-03-05 21:47:24 +0000
commitd3ba1cf57383182257fb02164fd4bc0fa580fabb (patch)
treeb2703494a7967ac2eeb4e5ac0964bd2c30c71d09 /sisinstall/sismain.cpp
parent2296dccd2f3e1ca88cc670f10b25b8d4cc758259 (diff)
downloadplptools-d3ba1cf57383182257fb02164fd4bc0fa580fabb.tar.gz
plptools-d3ba1cf57383182257fb02164fd4bc0fa580fabb.tar.bz2
plptools-d3ba1cf57383182257fb02164fd4bc0fa580fabb.zip
Fix some compiler warnings.
Diffstat (limited to 'sisinstall/sismain.cpp')
-rw-r--r--sisinstall/sismain.cpp195
1 files changed, 94 insertions, 101 deletions
diff --git a/sisinstall/sismain.cpp b/sisinstall/sismain.cpp
index 479fbf8..c5f6e05 100644
--- a/sisinstall/sismain.cpp
+++ b/sisinstall/sismain.cpp
@@ -1,4 +1,3 @@
-
#include "sisfile.h"
#include "sisinstaller.h"
#include "psion.h"
@@ -20,122 +19,116 @@
static void error(int line)
{
- fprintf(stderr, _("Error %d on line %d: %s\n"), errno, line,
- strerror(errno));
- exit(1);
+ fprintf(stderr, _("Error %d on line %d: %s\n"), errno, line,
+ strerror(errno));
+ exit(1);
}
static struct option opts[] = {
- { "help", no_argument, 0, 'h' },
- { "version", no_argument, 0, 'V' },
- { "verbose", required_argument, 0, 'v' },
- { "dry-run", no_argument, 0, 'n' },
- { NULL, 0, 0, 0 },
+ { "help", no_argument, 0, 'h' },
+ { "version", no_argument, 0, 'V' },
+ { "verbose", required_argument, 0, 'v' },
+ { "dry-run", no_argument, 0, 'n' },
+ { NULL, 0, 0, 0 },
};
void printHelp()
{
- printf(
- _("Usage: sisinstall [OPTIONS]... SISFILE\n"
- "\n"
- "Supported options:\n"
- "\n"
- " -h, --help Display this text.\n"
- " -V, --version Print version and exit.\n"
- " -v, --verbose=LEVEL Set the verbosity level, by default 0.\n"
- " -n, --dry-run Just parse the file.\n"
- ));
+ printf("%s",
+ _("Usage: sisinstall [OPTIONS]... SISFILE\n"
+ "\n"
+ "Supported options:\n"
+ "\n"
+ " -h, --help Display this text.\n"
+ " -V, --version Print version and exit.\n"
+ " -v, --verbose=LEVEL Set the verbosity level, by default 0.\n"
+ " -n, --dry-run Just parse the file.\n"
+ ));
}
int main(int argc, char* argv[])
{
- char* filename = 0;
- char option;
- bool dryrun = false;
+ char* filename = 0;
+ char option;
+ bool dryrun = false;
#ifdef LC_ALL
- setlocale(LC_ALL, "");
+ setlocale(LC_ALL, "");
#endif
- textdomain(PACKAGE);
+ textdomain(PACKAGE);
- while (1)
- {
- option = getopt_long(argc, argv,
- "hnv:V"
- , opts, NULL);
- if (option == -1)
- break;
- switch (option)
- {
- case 'h':
- case '?':
- printHelp();
- exit(0);
- case 'v':
- logLevel = atoi(optarg);
- break;
- case 'n':
- dryrun = true;
- break;
- case 'V':
- printf(_("sisinstall version 0.1\n"));
- exit(0);
- }
- }
- if (optind < argc)
- {
- filename = argv[optind];
+ while (1)
+ {
+ option = getopt_long(argc, argv,
+ "hnv:V"
+ , opts, NULL);
+ if (option == -1)
+ break;
+ switch (option)
+ {
+ case 'h':
+ case '?':
+ printHelp();
+ exit(0);
+ case 'v':
+ logLevel = atoi(optarg);
+ break;
+ case 'n':
+ dryrun = true;
+ break;
+ case 'V':
+ printf("%s", _("sisinstall version 0.1\n"));
+ exit(0);
+ }
+ }
+ if (optind < argc)
+ {
+ filename = argv[optind];
printf(_("Installing sis file %s%s.\n"), filename,
dryrun ? _(", not really") : "");
- }
- else
- {
- fprintf(stderr, _("Missing SIS filename\n"));
- exit(1);
- }
- struct stat st;
- if (-1 == stat(filename, &st))
- error(__LINE__);
- off_t len = st.st_size;
- if (logLevel >= 2)
- printf(_("File is %d bytes long\n"), len);
- uint8_t* buf = new uint8_t[len];
- int fd = open(filename, O_RDONLY);
- if (-1 == fd)
- error(__LINE__);
- if (-1 == read(fd, buf, len))
- error(__LINE__);
- close(fd);
- Psion* psion;
- if (dryrun)
- psion = new FakePsion();
- else
- psion = new Psion();
- if (!psion->connect())
- {
- printf(_("Couldn't connect with the Psion\n"));
- }
- else
- {
- createCRCTable();
- SISFile sisFile;
- SisRC rc = sisFile.fillFrom(buf, len);
- if (rc == SIS_OK)
- {
-// if (!dryrun)
- {
- SISInstaller installer;
- installer.setPsion(psion);
- installer.run(&sisFile, buf, len);
- }
- }
- else
- {
- printf(_("Could not parse the sis file.\n"));
- }
- psion->disconnect();
- }
+ }
+ else
+ {
+ fprintf(stderr, "%s", _("Missing SIS filename\n"));
+ exit(1);
+ }
+ struct stat st;
+ if (-1 == stat(filename, &st))
+ error(__LINE__);
+ off_t len = st.st_size;
+ if (logLevel >= 2)
+ printf(_("File is %d bytes long\n"), len);
+ uint8_t* buf = new uint8_t[len];
+ int fd = open(filename, O_RDONLY);
+ if (-1 == fd)
+ error(__LINE__);
+ if (-1 == read(fd, buf, len))
+ error(__LINE__);
+ close(fd);
+ Psion* psion;
+ if (dryrun)
+ psion = new FakePsion();
+ else
+ psion = new Psion();
+ if (!psion->connect())
+ {
+ printf("%s", _("Couldn't connect with the Psion\n"));
+ }
+ else
+ {
+ createCRCTable();
+ SISFile sisFile;
+ SisRC rc = sisFile.fillFrom(buf, len);
+ if (rc == SIS_OK)
+ {
+ SISInstaller installer;
+ installer.setPsion(psion);
+ installer.run(&sisFile, buf, len);
+ }
+ else
+ printf("%s", _("Could not parse the sis file.\n"));
+ psion->disconnect();
+ }
- return 0;
+ return 0;
}
-