/* Copyright (c) 1994 by Sanjay Ghemawat */ /* * Behaves like Tk main routine if display can be opened, otherwise * like the Tcl main routine. The following control whether or not * Tk is used -- * * $DISPLAY in environment Use Tk * -display Use Tk * -list Do not use Tk * -show Do not use Tk * -print Do not use Tk * -nodisplay Do not use Tk * * The "-f" flag can be used to pass in an initialization script regardless * of whether or not Tk is used. * * All .tcl files from Tcl/Tk libraries are linked into the executable * as well to avoid depending on external files being installed correctly. */ #include #include #include #include #include "ical.h" /* Include various libraries converted to strings. */ #ifdef STANDALONE static char* tcl_lib_str[] = { #include "tcl_lib.gen" 0 }; // Need to disable "source" command static char* tk_lib_str[] = { "rename source _orig_source", "proc source {args} {}", #include "tk_lib.gen" "rename source {}", "rename _orig_source source", 0 }; static char* ical_lib_str[] = { #include "ical_lib.gen" 0 }; static char* tcllib_str[] = { #include "tcllib.gen" 0 }; #endif static char* ical_startup[] = { #include "ical_start.gen" 0 }; static char* psheader_str[] = { "set ical(psheader) {%!PS-Adobe-", #include "psheader.gen" "}", 0 }; static char* ical_doc_str[] = { "set ical(doc) {", #include "icaldoc.gen" "}", 0 }; static char* tcl_doc_str[] = { "set ical(tcl_interface_doc) {", #include "tcldoc.gen" "}", 0 }; #include "bitmaps/left.xbm" #include "bitmaps/right.xbm" #include "bitmaps/todo.xbm" #include "bitmaps/done.xbm" #include "bitmaps/sleft.xbm" #include "bitmaps/dleft.xbm" #include "bitmaps/sright.xbm" #include "bitmaps/dright.xbm" #include "bitmaps/ical.xbm" // Is Tk available? static int have_tk; // Was a script specified on the command line? static int have_script; static int eval_list(Tcl_Interp*, char** list); static int app_init(Tcl_Interp*); extern int Ical_Init(Tcl_Interp*); int main(int argc, char* argv[]) { // XXX Hacky scanning of argument list to figure out whether // or not Tk is needed, and also if a script is specified on the // command line. have_script = 0; have_tk = (getenv("DISPLAY") != 0); int i; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-display") == 0) { have_tk = 1; continue; } if (strcmp(argv[i], "-list") == 0) { have_tk = 0; continue; } if (strcmp(argv[i], "-show") == 0) { have_tk = 0; continue; } if (strcmp(argv[i], "-print") == 0) { have_tk = 0; continue; } if (strcmp(argv[i], "-nodisplay") == 0) { have_tk = 0; continue; } if ((strcmp(argv[i], "-f") == 0) || (strcmp(argv[i], "-file") == 0)) { have_script = 1; continue; } } // Strip out processed "-nodisplay" arguments int j = 1; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-nodisplay") == 0) continue; argv[j++] = argv[i]; } argv[j] = 0; argc = j; if (!have_tk && have_script) { // If a "-f