|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T d
Length: 8661 (0x21d5) Types: TextFile Names: »drive.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« └─⟦e5a54fb17⟧ └─⟦this⟧ »pp-5.0/Src/MTAconsole/drive.c«
/* drive.c: driving routines */ # ifndef lint static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Src/MTAconsole/RCS/drive.c,v 5.0 90/09/20 16:19:53 pp Exp Locker: pp $"; # endif /* * $Header: /cs/research/pp/hubris/pp-beta/Src/MTAconsole/RCS/drive.c,v 5.0 90/09/20 16:19:53 pp Exp Locker: pp $ * * $Log: drive.c,v $ * Revision 5.0 90/09/20 16:19:53 pp * rcsforce : 5.0 public release * */ #include "console.h" #ifdef notdef #include "IntrinsicP.h" #include "TranslateI.h" #include "ConvertI.h" #include "InitialI.h" #endif #include <sys/stat.h> #include <pwd.h> struct stat statbuf; #define MAXMTAS 10 /* shouldn't get anything longer than that ? */ #define DEFAULT_NORMALFONT "*-medium-r-normal--14-*" #define DEFAULT_ACTIVEFONT "*-bold-r-normal--14-*" #define DEFAULT_DISABLEDFONT "*-medium-i-normal--14-*" typedef struct _cmdLineResources { int percentage; int lowerbound; int totalnumber; int totalvolume; int maxvert; Boolean confirm; int ncolours; char *connectHost; Boolean hack; char *heuristic; XFontStruct *defaultFont; char *refresh; } CmdLineResources; static CmdLineResources cmdLine_resources; static XtResource resources[] = { {"xtDefaultFont", "XtDefaultFont", XtRFontStruct, sizeof(XFontStruct *), XtOffset(struct _cmdLineResources *, defaultFont), XtRImmediate, (caddr_t) 0}, {"percentage", "Percentage", XtRInt, sizeof(int), XtOffset(struct _cmdLineResources *, percentage), XtRImmediate, (caddr_t) 0}, {"lowerbound", "Lowerbound", XtRInt, sizeof(int), XtOffset(struct _cmdLineResources *, lowerbound), XtRImmediate, (caddr_t) 0}, {"totalnumber", "Totalnumber", XtRInt, sizeof(int), XtOffset(struct _cmdLineResources *, totalnumber), XtRImmediate, (caddr_t) 0}, {"totalvolume", "Totalvolume", XtRInt, sizeof(int), XtOffset(struct _cmdLineResources *, totalvolume), XtRImmediate, (caddr_t) 0}, {"maxvert", "Maxvert", XtRInt, sizeof(int), XtOffset(struct _cmdLineResources *, maxvert), XtRImmediate, (caddr_t) 0}, {"confirm", "Confirm", XtRBoolean, sizeof(Boolean), XtOffset(struct _cmdLineResources *, confirm), XtRImmediate, (caddr_t) TRUE}, {"ncolours", "Ncolours", XtRInt, sizeof(int), XtOffset(struct _cmdLineResources *, ncolours), XtRImmediate, (caddr_t) 0}, {"connectHost", "ConnectHost", XtRString, sizeof(String), XtOffset(struct _cmdLineResources *, connectHost), XtRImmediate, (caddr_t) NULLCP}, {"hack", "Hack", XtRBoolean, sizeof(Boolean), XtOffset(struct _cmdLineResources *, hack), XtRImmediate, (caddr_t) FALSE}, {"heuristic", "Heuristic", XtRString, sizeof(String), XtOffset(struct _cmdLineResources *, heuristic), XtRImmediate, (caddr_t) NULLCP}, {"refresh", "Refresh", XtRString, sizeof(String), XtOffset(struct _cmdLineResources *, refresh), XtRImmediate, (caddr_t) NULLCP}, }; static XrmOptionDescRec options[] = { {"-percentage", "percentage", XrmoptionSepArg, 0}, {"-lowerbound", "lowerbound", XrmoptionSepArg, 0}, {"-number", "totalnumber", XrmoptionSepArg, 0}, {"-volume", "totalvolume", XrmoptionSepArg, 0}, {"-downLines", "maxvert", XrmoptionSepArg, 0}, {"-NoConfirm", "confirm", XrmoptionNoArg, "False"}, {"-colours", "ncolours", XrmoptionSepArg, 0}, {"-Queue", "connectHost", XrmoptionSepArg, NULLCP}, {"-hack", "hack", XrmoptionNoArg, "True"}, {"-heuristic", "heuristic", XrmoptionSepArg, NULLCP}, {"-refresh", "refresh", XrmoptionSepArg, NULLCP}, }; XtAppContext appContext; Display *disp; char *hostname, tailorfile[FILNSIZE]; int confirm = TRUE, doConnect = FALSE, userConnected = FALSE, autoRefresh = TRUE, hack = FALSE, autoReconnect = TRUE, auth = FALSE, lower_bound_mtas, percent; Heuristic heuristic; State connectState = notconnected; Authentication authentication = limited; char *Qinformation = NULLCP, *Qversion = NULLCP; extern unsigned long timeoutFor; time_t currentTime; XFontStruct *disabledFont = NULL, *activeFont = NULL, *normalFont = NULL, *defaultFont = NULL; static void general_initialise(); extern Widget header, error, top; #define WAIT_CONNECTION "Please wait for connection to the queue manager" char *myname; char password[100], username[100]; extern double ub_total_number, ub_total_volume; extern ConnectRetry(); main(argc, argv) int argc; char **argv; { int uid; struct passwd *pwd; uid = getuid(); pwd = getpwuid(uid); strcpy(username, pwd->pw_name); strcpy(password, "dummy"); strcpy(tailorfile,".MTAconsole"); if (myname = rindex (argv[0], '/')) myname++; if (myname == NULL || *myname == NULL) myname = argv[0]; fillin_passwdpep(username, NULLCP, 0); general_initialise(argc, argv); initiate_assoc(argc, argv); create_widgets(disp, appContext); SetColours(disp, XtWindow(top)); if (doConnect == TRUE) { WidgetSet(header, XtNlabel, WAIT_CONNECTION, NULL); InitConnectTimeOut(); } XtAppMainLoop(appContext); } #define DEFAULT_MAX_BORDER 5 #define DEFAULT_NUM_COLORS 10 #define DEFAULT_UL_MAX_LINES 4 int max_chan_border = DEFAULT_MAX_BORDER, max_mta_border = DEFAULT_MAX_BORDER, max_msg_border = DEFAULT_MAX_BORDER; int num_colors = DEFAULT_NUM_COLORS; int max_horiz_mtas, max_vert_lines; extern time_t parsetime(); extern void advise(); static void general_initialise(argc, argv) int argc; char **argv; { char buf[BUFSIZ]; Arg arg[1]; extern int optind; extern char *optarg; extern Widget top; gethostname(buf,BUFSIZ); hostname = strdup(buf); XtToolkitInitialize(); appContext = XtCreateApplicationContext(); disp = XtOpenDisplay(appContext, (String) NULL, (String) myname, (String) APPLICATION_CLASS, options, XtNumber(options), &argc, argv); if (disp == NULL) { printf("%s\n", "unable to open display"); exit(1); } #ifdef R4 /* to get round bug in XtRemoveInput */ XtRemoveInput(XtAppAddInput(appContext, 0, XtInputReadMask, ConnectRetry, NULL)); #endif XtSetArg(arg[0], XtNinput, True); /* create top level */ top = XtAppCreateShell(myname, APPLICATION_CLASS, applicationShellWidgetClass, disp, arg, 0); if (DisplayCells (disp, DefaultScreen(disp)) <= 2) num_colors = 1; else max_chan_border = max_mta_border = 2; max_horiz_mtas = MAXMTAS; max_vert_lines = DEFAULT_UL_MAX_LINES; heuristic = line; lower_bound_mtas = 20; percent = 50; XtGetApplicationResources (top, &cmdLine_resources, resources, XtNumber(resources), NULL, 0); if (cmdLine_resources.defaultFont) { defaultFont = cmdLine_resources.defaultFont; } if (cmdLine_resources.percentage) { percent = cmdLine_resources.percentage; } if (cmdLine_resources.lowerbound) { lower_bound_mtas = cmdLine_resources.lowerbound; } if (cmdLine_resources.totalnumber) ub_total_number = cmdLine_resources.totalnumber; if (cmdLine_resources.totalvolume) ub_total_volume = cmdLine_resources.totalvolume; if (cmdLine_resources.maxvert) max_vert_lines = cmdLine_resources.maxvert; confirm = cmdLine_resources.confirm; if (cmdLine_resources.ncolours) num_colors = cmdLine_resources.ncolours; if (cmdLine_resources.connectHost) { doConnect = TRUE; hostname = strdup(cmdLine_resources.connectHost); } hack = cmdLine_resources.hack; if (cmdLine_resources.heuristic != NULLCP) { if (lexequ(cmdLine_resources.heuristic, "all") == 0) heuristic = all; else if (lexnequ(cmdLine_resources.heuristic, "percent", strlen("percent")) == 0) heuristic = percentage; else if (lexequ(cmdLine_resources.heuristic, "line") == 0) heuristic = line; } if (cmdLine_resources.refresh != NULLCP) settimeoutFor(cmdLine_resources.refresh); setfonts(); } XFontStruct *get_three_choice_font(font, one, two, three) char *font, *one, *two, *three; { char *retstr; XFontStruct *retfont; if ((retstr = XGetDefault(disp, one, font)) != NULLCP && (retfont = XLoadQueryFont(disp, retstr)) != NULL) return retfont; if ((retstr = XGetDefault(disp, two, font)) != NULLCP && (retfont = XLoadQueryFont(disp, retstr)) != NULL) return retfont; if ((retfont = XLoadQueryFont(disp, three)) != NULL) return retfont; if (defaultFont == NULL) { printf("Unable to load font '%s'\n", font); exit(0); } return defaultFont; } setfonts () { normalFont = get_three_choice_font("normalfont", myname, APPLICATION_CLASS, DEFAULT_NORMALFONT); activeFont = get_three_choice_font("activefont", myname, APPLICATION_CLASS, DEFAULT_NORMALFONT); disabledFont = get_three_choice_font("disabledfont", myname, APPLICATION_CLASS, DEFAULT_NORMALFONT); }