|
|
1.1 ! root 1: #ifndef lint ! 2: static char rcs_id[] = "$Header: init.c,v 1.21 87/09/12 08:04:03 swick Exp $"; ! 3: #endif lint ! 4: /* ! 5: * COPYRIGHT 1987 ! 6: * DIGITAL EQUIPMENT CORPORATION ! 7: * MAYNARD, MASSACHUSETTS ! 8: * ALL RIGHTS RESERVED. ! 9: * ! 10: * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND ! 11: * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION. ! 12: * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ! 13: * ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ! 14: * ! 15: * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT RIGHTS, ! 16: * APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN ADDITION TO THAT ! 17: * SET FORTH ABOVE. ! 18: * ! 19: * ! 20: * Permission to use, copy, modify, and distribute this software and its ! 21: * documentation for any purpose and without fee is hereby granted, provided ! 22: * that the above copyright notice appear in all copies and that both that ! 23: * copyright notice and this permission notice appear in supporting documentation, ! 24: * and that the name of Digital Equipment Corporation not be used in advertising ! 25: * or publicity pertaining to distribution of the software without specific, ! 26: * written prior permission. ! 27: */ ! 28: ! 29: /* Init.c - Handle start-up initialization. */ ! 30: ! 31: #include "xmh.h" ! 32: ! 33: /* Xmh-specific resources. */ ! 34: ! 35: static Resource resourcelist[] = { ! 36: {"debug", "Debug", XrmRBoolean, sizeof(int), ! 37: (XtArgVal)&debug, NULL}, ! 38: {"tempdir", "tempDir", XrmRString, sizeof(char *), ! 39: (XtArgVal)&tempDir, NULL}, ! 40: {"mhpath", "MhPath", XrmRString, sizeof(char *), ! 41: (XtArgVal)&defMhPath, NULL}, ! 42: {"initialfolder", "InitialFolder", XrmRString, sizeof(char *), ! 43: (XtArgVal)&initialFolderName, NULL}, ! 44: {"initialincfile", "InitialIncFile", XrmRString, sizeof(char *), ! 45: (XtArgVal)&initialIncFile, NULL}, ! 46: {"draftsfolder", "DraftsFolder", XrmRString, sizeof(char *), ! 47: (XtArgVal)&draftsFolderName, NULL}, ! 48: {"sendwidth", "SendWidth", XrmRInt, sizeof(int), ! 49: (XtArgVal)&defSendLineWidth, NULL}, ! 50: {"sendbreakwidth", "SendBreakWidth", XrmRInt, sizeof(int), ! 51: (XtArgVal)&defBreakSendLineWidth, NULL}, ! 52: {"printcommand", "PrintCommand", XrmRString, sizeof(char *), ! 53: (XtArgVal)&defPrintCommand, NULL}, ! 54: {"tocwidth", "TocWidth", XrmRInt, sizeof(int), ! 55: (XtArgVal)&defTocWidth, NULL}, ! 56: {"skipdeleted", "SkipDeleted", XrmRString, sizeof(char *), ! 57: (XtArgVal)&SkipDeleted, NULL}, ! 58: {"skipmoved", "SkipMoved", XrmRString, sizeof(char *), ! 59: (XtArgVal)&SkipMoved, NULL}, ! 60: {"skipCopied", "SkipCopied", XrmRString, sizeof(char *), ! 61: (XtArgVal)&SkipCopied, NULL}, ! 62: {"hideboringheaders", "HideBoringHeaders", XrmRBoolean, sizeof(int), ! 63: (XtArgVal)&defHideBoringHeaders, NULL}, ! 64: {"hidenullseqboxes", "HideNullSeqBoxes", XrmRBoolean, sizeof(int), ! 65: (XtArgVal)&defHideNullSeqBoxes, NULL}, ! 66: {"geometry", "Geometry", XrmRString, sizeof(char *), ! 67: (XtArgVal)&defGeometry, NULL}, ! 68: {"tocgeometry", "TocGeometry", XrmRString, sizeof(char *), ! 69: (XtArgVal)&defTocGeometry, NULL}, ! 70: {"viewgeometry", "ViewGeometry", XrmRString, sizeof(char *), ! 71: (XtArgVal)&defViewGeometry, NULL}, ! 72: {"compgeometry", "CompGeometry", XrmRString, sizeof(char *), ! 73: (XtArgVal)&defCompGeometry, NULL}, ! 74: {"pickgeometry", "PickGeometry", XrmRString, sizeof(char *), ! 75: (XtArgVal)&defPickGeometry, NULL}, ! 76: {"tocpercentage", "TocPercentage", XrmRInt, sizeof(int), ! 77: (XtArgVal)&defTocPercentage, NULL}, ! 78: {"checknewmail", "CheckNewMail", XrmRBoolean, sizeof(int), ! 79: (XtArgVal)&defNewMailCheck, NULL}, ! 80: {"makecheckpoints", "MakeCheckPoints", XrmRBoolean, sizeof(int), ! 81: (XtArgVal)&defMakeCheckpoints, NULL}, ! 82: {"grabFocus", "GrabFocus", XrmRBoolean, sizeof(int), ! 83: (XtArgVal)&defGrabFocus, NULL}, ! 84: {"doubleClick", "DoubleClick", XrmRBoolean, sizeof(int), ! 85: (XtArgVal)&defDoubleClick, NULL} ! 86: }; ! 87: ! 88: ! 89: /* Tell the user how to use this program. */ ! 90: Syntax() ! 91: { ! 92: extern void exit(); ! 93: (void)fprintf(stderr, "usage: xmh [display] [=geometry] \n"); ! 94: exit(2); ! 95: } ! 96: ! 97: ! 98: ProcessCommandLine(argc, argv) ! 99: int argc; ! 100: char **argv; ! 101: { ! 102: int i; ! 103: char *ptr; ! 104: ptr = rindex(argv[0], '/'); ! 105: if (ptr) progName = ptr + 1; ! 106: else progName = argv[0]; ! 107: if (strcmp(progName, "xmh_d") == 0) progName = "xmh"; ! 108: displayName = ""; ! 109: defTocGeometry = NULL; ! 110: for (i=1 ; i<argc ; i++) { ! 111: if (argv[i][0] == '=') defTocGeometry = argv[i]; ! 112: else if (index(argv[i], ':')) displayName = argv[i]; ! 113: else Syntax(); ! 114: } ! 115: } ! 116: ! 117: static char *defaultFile[] = { "%s/xmh.Xdefaults", /* LIBDIR */ ! 118: "%s/xmh.X11defaults", /* LIBDIR */ ! 119: "%s/.Xdefaults", /* homeDir */ ! 120: "%s/.X11defaults" /* homeDir */ ! 121: }; ! 122: ! 123: /* All the start-up initialization goes here. */ ! 124: ! 125: InitializeWorld(argc, argv) ! 126: int argc; ! 127: char **argv; ! 128: { ! 129: int gbits, l; ! 130: Position x, y; ! 131: Dimension width, height; ! 132: FILEPTR fid; ! 133: XrmResourceDataBase db = NULL, db2; ! 134: char str[500], str2[500], *ptr; ! 135: XrmNameList names; ! 136: XrmClassList classes; ! 137: Scrn scrn; ! 138: int defaultIndex; ! 139: ! 140: XtInitialize(); ! 141: ProcessCommandLine(argc, argv); ! 142: theDisplay = XOpenDisplay(displayName); ! 143: ! 144: theScreen = 0; ! 145: if (theDisplay == NULL) ! 146: Punt("Couldn't open display!"); ! 147: ! 148: homeDir = MallocACopy(getenv("HOME")); ! 149: ! 150: (void) XrmInitialize(); ! 151: ! 152: for (defaultIndex=0; defaultIndex<XtNumber(defaultFile); defaultIndex++) { ! 153: (void) sprintf( str, defaultFile[defaultIndex], ! 154: (defaultIndex<2 ? LIBDIR : homeDir) ); ! 155: fid = myfopen(str, "r"); ! 156: if (fid) { ! 157: XrmGetDataBase(fid, &db2); ! 158: (void)myfclose(fid); ! 159: if (db) XrmMergeDataBases(db2, &db); ! 160: else db = db2; ! 161: } ! 162: } ! 163: ! 164: if (db) XrmSetCurrentDataBase(db); ! 165: ! 166: (void) sprintf(str, "%s/.mh_profile", homeDir); ! 167: fid = myfopen(str, "r"); ! 168: if (fid) { ! 169: while (ptr = ReadLine(fid)) { ! 170: if (strncmp(ptr, "Path:", 5) == 0) { ! 171: ptr += 5; ! 172: while (*ptr == ' ' || *ptr == '\t') ! 173: ptr++; ! 174: (void) strcpy(str, ptr); ! 175: } ! 176: } ! 177: (void) myfclose(fid); ! 178: } else { ! 179: fid = myfopen(str, "w"); ! 180: if (fid) { ! 181: (void) fprintf(fid, "Path: Mail\n"); ! 182: (void) myfclose(fid); ! 183: } else Punt("Can't read or create .mh_profile!"); ! 184: (void) strcpy(str, "Mail"); ! 185: } ! 186: for (l = strlen(str) - 1; l >= 0 && (str[l] == ' ' || str[l] == '\t'); l--) ! 187: str[l] = 0; ! 188: if (str[0] == '/') ! 189: (void) strcpy(str2, str); ! 190: else ! 191: (void) sprintf(str2, "%s/%s", homeDir, str); ! 192: mailDir = MallocACopy(str2); ! 193: (void) sprintf(str, "%s/draft", mailDir); ! 194: draftFile = MallocACopy(str); ! 195: (void) sprintf(str, "%s/xmhdraft", mailDir); ! 196: xmhDraftFile = MallocACopy(str); ! 197: ! 198: debug = FALSE; ! 199: tempDir = "/tmp"; ! 200: defMhPath = "/usr/local/mh6"; ! 201: initialFolderName = "inbox"; ! 202: draftsFolderName = "drafts"; ! 203: ! 204: defSendLineWidth = 72; ! 205: defBreakSendLineWidth = 85; ! 206: defPrintCommand = "enscript >/dev/null 2>/dev/null"; ! 207: ! 208: defTocWidth = 300; ! 209: ! 210: SkipDeleted = TRUE; ! 211: SkipMoved = TRUE; ! 212: SkipCopied = FALSE; ! 213: ! 214: defHideBoringHeaders = TRUE; ! 215: defHideNullSeqBoxes = FALSE; ! 216: ! 217: defGeometry = ""; ! 218: defViewGeometry = NULL; ! 219: defCompGeometry = NULL; ! 220: defPickGeometry = NULL; ! 221: ! 222: defTocPercentage = 33; ! 223: defNewMailCheck = TRUE; ! 224: defMakeCheckpoints = FALSE; ! 225: defGrabFocus = FALSE; ! 226: defDoubleClick = FALSE; ! 227: ! 228: ptr = defTocGeometry; ! 229: XtGetResources(DISPLAY ! 230: resourcelist, XtNumber(resourcelist), (ArgList)NULL, 0, ! 231: QDefaultRootWindow(theDisplay), ! 232: progName, "Xmh", &names, &classes); ! 233: if (ptr) defTocGeometry = ptr; ! 234: XrmFreeNameList(names); ! 235: XrmFreeClassList(classes); ! 236: ! 237: NullSource = XtCreateEDiskSource("/dev/null", XttextRead); ! 238: ! 239: x = strlen(defMhPath) - 1; ! 240: if (x > 0 && defMhPath[x] == '/') ! 241: defMhPath[x] = 0; ! 242: ! 243: if (defTocGeometry == NULL) ! 244: defTocGeometry = defGeometry; ! 245: if (defViewGeometry == NULL) ! 246: defViewGeometry = defGeometry; ! 247: if (defCompGeometry == NULL) ! 248: defCompGeometry = defGeometry; ! 249: if (defPickGeometry == NULL) ! 250: defPickGeometry = defGeometry; ! 251: ! 252: #ifdef X11 ! 253: rootwidth = DisplayWidth(theDisplay, theScreen); ! 254: rootheight = DisplayHeight(theDisplay, theScreen); ! 255: #endif X11 ! 256: #ifdef X10 ! 257: { ! 258: WindowInfo info; ! 259: XQueryWindow(RootWindow, &info); ! 260: rootwidth = info.width; ! 261: rootheight = info.height; ! 262: } ! 263: #endif X10 ! 264: ! 265: gbits = XParseGeometry(defTocGeometry, &x, &y, &width, &height); ! 266: if (!(gbits & HeightValue)) { ! 267: height = 3 * rootheight / 4; ! 268: gbits |= HeightValue; ! 269: } ! 270: if (!(gbits & WidthValue)) { ! 271: width = rootwidth / 2; ! 272: gbits |= WidthValue; ! 273: } ! 274: defTocGeometry = CreateGeometry(gbits, x, y, width, height); ! 275: ! 276: gbits = XParseGeometry(defViewGeometry, &x, &y, &width, &height); ! 277: if (!(gbits & HeightValue)) { ! 278: height = rootheight / 2; ! 279: gbits |= HeightValue; ! 280: } ! 281: if (!(gbits & WidthValue)) { ! 282: width = rootwidth / 2; ! 283: gbits |= WidthValue; ! 284: } ! 285: defViewGeometry = CreateGeometry(gbits, x, y, width, height); ! 286: ! 287: gbits = XParseGeometry(defCompGeometry, &x, &y, &width, &height); ! 288: if (!(gbits & HeightValue)) { ! 289: height = rootheight / 2; ! 290: gbits |= HeightValue; ! 291: } ! 292: if (!(gbits & WidthValue)) { ! 293: width = rootwidth / 2; ! 294: gbits |= WidthValue; ! 295: } ! 296: defCompGeometry = CreateGeometry(gbits, x, y, width, height); ! 297: ! 298: gbits = XParseGeometry(defPickGeometry, &x, &y, &width, &height); ! 299: if (!(gbits & HeightValue)) { ! 300: height = rootheight / 2; ! 301: gbits |= HeightValue; ! 302: } ! 303: if (!(gbits & WidthValue)) { ! 304: width = rootwidth / 2; ! 305: gbits |= WidthValue; ! 306: } ! 307: defPickGeometry = CreateGeometry(gbits, x, y, width, height); ! 308: ! 309: numScrns = 0; ! 310: scrnList = (Scrn *) XtMalloc(1); ! 311: LastButtonPressed = NULL; ! 312: ! 313: windowarglist[0].name = XtNwindow; ! 314: labelarglist[0].name = XtNlabel; ! 315: TocInit(); ! 316: InitPick(); ! 317: IconInit(); ! 318: ! 319: if (debug) {(void)fprintf(stderr, "Making screen ... "); (void)fflush(stderr);} ! 320: ! 321: scrn = CreateNewScrn(STtocAndView); ! 322: ! 323: if (debug) {(void)fprintf(stderr, " setting toc ... "); (void)fflush(stderr);} ! 324: ! 325: TocSetScrn(TocGetNamed(initialFolderName), scrn); ! 326: ! 327: if (debug) (void)fprintf(stderr, "done\n"); ! 328: ! 329: /* if (debug) {(void)fprintf(stderr, "Syncing ... "); (void)fflush(stderr); QXSync(theDisplay, 0); (void)fprintf(stderr, "done\n");} */ ! 330: ! 331: MapScrn(scrn); ! 332: DoubleClickProc = NULL; ! 333: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.