/* Copyright 1998 DJ Delorie Distributed under the terms of the GNU GPL http://www.delorie.com/store/hcalc/ Revisions copyright 2007, Theodore Kilgore More revisions copyright 2023, B. Watson */ #include #include #include "hcalc.h" char *self; void version(void) { printf("%s %s\n", SELF, VERSION); exit(0); } void usage(const char *self, const char *msg) { if(msg) fprintf(stderr, "%s: %s\n", self, msg); printf ("%s %s\nUsage: %s [-default] [-small|-medium|-large] [-dec|-hex|-oct|-bin] [-quiet] [--version] [--help]\n", SELF, VERSION, self); exit(msg != NULL); } int main(int argc, char **argv) { self = argv[0]; setbuf(stdout, 0); if(argc >= 2 && strcmp(argv[1], "-default") == 0) { /* don't load the config file */ } else { load_config(); } atexit(save_config); while(argv++, --argc) { if(strcmp(*argv, "-small") == 0) winsize = 0; else if(strcmp(*argv, "-medium") == 0) winsize = 1; else if(strcmp(*argv, "-large") == 0) winsize = 2; else if(strcmp(*argv, "-dec") == 0) base = 10; else if(strcmp(*argv, "-hex") == 0) base = 16; else if(strcmp(*argv, "-oct") == 0) base = 8; else if(strcmp(*argv, "-bin") == 0) base = 2; else if(strcmp(*argv, "-quiet") == 0) quiet = 1; else if(strcmp(*argv, "--help") == 0) usage(self, NULL); else if(strcmp(*argv, "--version") == 0) version(); else if(strcmp(*argv, "-default") == 0) { /* do nothing */ } else usage(self, "Invalid command-line option %s"); } setup_x(); load_pixmaps(); process_input(); }