home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume16 / pan / part04 < prev    next >
Encoding:
Text File  |  1992-03-06  |  26.7 KB  |  945 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!think.com!mips!msi!dcmartin
  3. From: jeff@rd1.interlan.com (Jeff Bailey)
  4. Subject: v16i140: pan - Post A Note (for Open Windows), Part04/06
  5. Message-ID: <1992Mar6.200354.8290@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-16i137-pan@uunet.UU.NET>
  10. Date: Fri, 6 Mar 1992 20:03:54 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: jeff@rd1.interlan.com (Jeff Bailey)
  14. Posting-number: Volume 16, Issue 140
  15. Archive-name: pan/part04
  16.  
  17.  
  18. ---- Cut Here and feed the following to sh ----
  19. #!/bin/sh
  20. # This is part 04 of a multipart archive
  21. # ============= pan.c ==============
  22. if test -f 'pan.c' -a X"$1" != X"-c"; then
  23.     echo 'x - skipping pan.c (File already exists)'
  24. else
  25. echo 'x - extracting pan.c (Text)'
  26. sed 's/^X//' << 'SHAR_EOF' > 'pan.c' &&
  27. /*
  28. Post A Note V2.4
  29. Copyright (c) 1992, Jeffrey W. Bailey
  30. All rights reserved.
  31. X
  32. Permission is granted to distribute this program in exact, complete
  33. source form, which includes this copyright notice, as long as no fee
  34. other than media and distribution cost is charged.
  35. X
  36. This program may not be used in whole, or in part, in any other manner
  37. without prior written permission from the author.
  38. X
  39. This program may not be distributed in modified form without prior
  40. written permission from the author.  In other words, patches may be
  41. distributed, but modified source may not be distributed.
  42. X
  43. If there are any questions, comments or suggestions, the author may be
  44. contacted at:
  45. X
  46. X    jeff@rd1.interlan.com
  47. X
  48. X    or
  49. X
  50. X    Jeffrey Bailey
  51. X    Racal-Datacom, Inc.
  52. X    Mail Stop E-110
  53. X    1601 N. Harrison Parkway
  54. X    Sunrise, FL  33323-2899
  55. */
  56. X
  57. #define public
  58. X
  59. #include "pan.h"
  60. #include <signal.h>
  61. X
  62. #include <X11/X.h>
  63. #include <X11/Xutil.h>
  64. X
  65. extern char *malloc();
  66. extern char *getenv();
  67. X
  68. extern int errno;
  69. extern char *sys_errlist[];
  70. X
  71. int  xverror(), xerror();
  72. X
  73. extern char *optarg;
  74. X
  75. static char init_search_val[MAXSEARCHLEN];
  76. X
  77. Notify_value aborted();
  78. X
  79. main(argc, argv)
  80. X    int  argc;
  81. X    char *argv[];
  82. X    {
  83. X    char *cp;
  84. X    int  opt;
  85. X
  86. X    debug_on = 0;
  87. X    move_up = 0;
  88. X    destroy_up = 0;
  89. X    search_up = 0;
  90. X    notecount = 0;
  91. X    *init_search_val = 0;
  92. X
  93. X    LLM_init(&subdir_rt, sizeof(struct SubDir));
  94. X    LLM_init(&freewin_rt, sizeof(struct FreeWin));
  95. X
  96. X    strcpy(myname, argv[0]);
  97. X    cp = getenv("HOME");
  98. X    if(cp == NULL)
  99. X        {
  100. X        fprintf(stderr, "%s:  Can't determine value of HOME\n", myname);
  101. X        exit(1);
  102. X        }
  103. X
  104. X    /* If first time run, set up default dirs */
  105. X    sprintf(note_dir, "%s/%s", cp, NOTEDIR);
  106. X    (void) mkdir(note_dir, 0700);
  107. X    sprintf(note_dir, "%s/%s/Miscellaneous", cp, NOTEDIR);
  108. X    (void) mkdir(note_dir, 0700);
  109. X
  110. X    sprintf(note_dir, "%s/%s", cp, NOTEDIR);
  111. X
  112. X    xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv,
  113. X        XV_ERROR_PROC, xverror,
  114. X        XV_X_ERROR_PROC, xerror,
  115. X        NULL);
  116. X
  117. X    defaults_load_db(NULL);
  118. X
  119. X    cp = defaults_get_string(resources[RES_IDIR].a, resources[RES_IDIR].b,
  120. X         note_dir);
  121. X    if(cp != note_dir)
  122. X        {
  123. X        strcpy(note_dir, cp);
  124. X        }
  125. X
  126. X    while((opt = getopt(argc, argv, "d:x")) != -1)
  127. X        {
  128. X        switch(opt)
  129. X            {
  130. X            case 'd' : /* Initial directory */
  131. X                strcpy(note_dir, optarg);
  132. X                break;
  133. X            case 'x' : /* Turn on debugs.  Undocumented flag */
  134. X                debug_on = 1;
  135. X                break;
  136. X            }
  137. X        }
  138. X
  139. X    if(chdir(note_dir) < 0)
  140. X        {
  141. X        fprintf(stderr, "%s:  Couldn't chdir to %s\n", myname, note_dir);
  142. X        exit(1);
  143. X        }
  144. X
  145. X    confirmdestroy = (defaults_get_boolean(resources[RES_CDESTROY].a,
  146. X        resources[RES_CDESTROY].b, RESDEF_CDESTROY) == TRUE);
  147. X
  148. X    /* Reverse boolean */
  149. X    noticenobeep = (defaults_get_boolean(resources[RES_NBEEP].a,
  150. X        resources[RES_NBEEP].b, RESDEF_NBEEP) == FALSE);
  151. X
  152. X    icontransparent = (defaults_get_boolean(resources[RES_ITRANSPARENT].a,
  153. X        resources[RES_ITRANSPARENT].b, RESDEF_ITRANSPARENT) == TRUE);
  154. X
  155. X    cp = defaults_get_string(resources[RES_FORDER].a, resources[RES_FORDER].b,
  156. X         RESDEF_FORDER);
  157. X    strcpy(folderorder, cp);
  158. X
  159. X    cp = defaults_get_string(resources[RES_DSEARCH].a, resources[RES_DSEARCH].b,
  160. X         RESDEF_DSEARCH);
  161. X    strcpy(init_search_val, cp);
  162. X
  163. X    setup_display();
  164. X    restorenotes();
  165. X    xv_main_loop(main_frame);
  166. X    exit(0);
  167. X    /* NOTREACHED */
  168. X    }
  169. X
  170. /*
  171. X    Routine to set up main frame and buttons.
  172. */
  173. setup_display()
  174. X    {
  175. X    Menu menu;
  176. X    Server_image image;
  177. X    Icon icon;
  178. X    static XClassHint chint;
  179. X
  180. X    main_frame = xv_create(NULL, FRAME,
  181. X                           XV_LABEL, "Post A Note V2.4",
  182. X                           XV_WIDTH, MAINWIDTH,
  183. X                           XV_HEIGHT, MAINHEIGHT,
  184. X                           FRAME_NO_CONFIRM, TRUE,
  185. X                           NULL);
  186. X    if(main_frame == NULL)
  187. X        {
  188. X        fprintf(stderr, "%s:  Couldn't create base frame.\n", myname);
  189. X        exit(1);
  190. X        }
  191. X
  192. X    /* Set up the X class since xview doesn't */
  193. X    chint.res_name = "panmain";
  194. X    chint.res_class = "PanMain";
  195. X    XSetClassHint(xv_get(main_frame, XV_DISPLAY), xv_get(main_frame, XV_XID),
  196. X        &chint);
  197. X
  198. X    notify_interpose_destroy_func(main_frame, aborted);
  199. X
  200. X    main_panel = (Panel) xv_create(main_frame, PANEL, 
  201. X                     WIN_RETAINED, FALSE, 
  202. X                     NULL);
  203. X
  204. X    main_newnote = xv_create(NULL, MENU,
  205. X                     MENU_NOTIFY_PROC, newnote,
  206. X                     NULL);
  207. X    (void) xv_create(main_panel, PANEL_BUTTON,
  208. X                     PANEL_LABEL_STRING, "New Note", 
  209. X                     PANEL_ITEM_MENU, main_newnote,
  210. X                     NULL);
  211. X    (void) xv_create(main_panel, PANEL_BUTTON, PANEL_LABEL_STRING, 
  212. X                     "Hide Notes", PANEL_NOTIFY_PROC, hideall, NULL);
  213. X    main_expose = xv_create(NULL, MENU,
  214. X                     MENU_NOTIFY_PROC, exposemenu,
  215. X                     MENU_STRINGS, CHOICE_ALL, NULL,
  216. X                     NULL);
  217. X    (void) xv_create(main_panel, PANEL_BUTTON,
  218. X                     PANEL_LABEL_STRING, "Expose Notes", 
  219. X                     PANEL_ITEM_MENU, main_expose,
  220. X                     NULL);
  221. X    main_print = xv_create(NULL, MENU,
  222. X                     MENU_NOTIFY_PROC, actionmenu,
  223. X                     NULL);
  224. X    menu = xv_create(NULL, MENU,
  225. X                     MENU_NOTIFY_PROC, actionmenu,
  226. X                     MENU_STRINGS, CHOICE_QUIT, CHOICE_FOLDER, 
  227. X                         NULL,
  228. X                     MENU_ITEM,
  229. X                         MENU_STRING, CHOICE_MOVE,
  230. X                         MENU_NOTIFY_PROC, movenote,
  231. X                         NULL,
  232. X                     MENU_ITEM,
  233. X                         MENU_STRING, CHOICE_PRINT,
  234. X                         MENU_PULLRIGHT, main_print,
  235. X                         NULL,
  236. X                     MENU_ITEM,
  237. X                         MENU_STRING, CHOICE_DESTROY,
  238. X                         MENU_NOTIFY_PROC, destroyfolder,
  239. X                         NULL,
  240. X                     NULL);
  241. X    folder_mitem = xv_find(menu, MENUITEM, MENU_STRING, CHOICE_FOLDER, NULL);
  242. X    (void) xv_create(main_panel, PANEL_BUTTON, PANEL_LABEL_STRING, 
  243. X                     "Action", PANEL_ITEM_MENU, menu, NULL);
  244. X
  245. X    search_item = xv_create(main_panel, PANEL_TEXT,
  246. X                     PANEL_LABEL_STRING, "Search:",
  247. X                     PANEL_VALUE, init_search_val,
  248. X                     PANEL_VALUE_DISPLAY_LENGTH, MAXSEARCHDISLEN + 1,
  249. X                     PANEL_VALUE_STORED_LENGTH, MAXSEARCHLEN,
  250. X                     PANEL_NOTIFY_PROC, notesearch,
  251. X                     NULL);
  252. X
  253. X    image = xv_create(NULL, SERVER_IMAGE, XV_WIDTH, 64, XV_HEIGHT, 64,
  254. X                      SERVER_IMAGE_BITS, myicon, NULL);
  255. X    icon = xv_create(main_frame, ICON,
  256. X                     ICON_IMAGE, image,
  257. X                     ICON_LABEL, "Notes",
  258. X                     ICON_TRANSPARENT, icontransparent,
  259. X                     NULL);
  260. X    xv_set(main_frame, FRAME_ICON, icon, NULL);
  261. X    }
  262. X
  263. Notify_value aborted(client, status)
  264. X    Notify_client client;
  265. X    Destroy_status status;
  266. X    {
  267. X    struct SubDir *sp;
  268. X    struct Note *np;
  269. X    if(status == DESTROY_CHECKING) return(NOTIFY_DONE);
  270. X
  271. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  272. X    while(sp != NULL)
  273. X        {
  274. X        np = (struct Note *) LLM_first(&sp->note_rt);
  275. X        while(np != NULL)
  276. X            {
  277. X            update(np);
  278. X            np = (struct Note *) LLM_next(&sp->note_rt);
  279. X            }
  280. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  281. X        }
  282. X
  283. X    if(status == DESTROY_CLEANUP)
  284. X        return(notify_next_destroy_func(client, status));
  285. X
  286. X    return(NOTIFY_DONE);
  287. X    }
  288. X
  289. /*
  290. X    Routine called to safely cleanup and exit pan.  Called by Action Quit menu
  291. X    item.
  292. */
  293. cleanup(errnum)
  294. X    int  errnum;
  295. X    {
  296. X    struct SubDir *sp;
  297. X    struct Note *np;
  298. X
  299. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  300. X    while(sp != NULL)
  301. X        {
  302. X        np = (struct Note *) LLM_first(&sp->note_rt);
  303. X        while(np != NULL)
  304. X            {
  305. X            update(np);
  306. X            updateinfo(np, NOFORCE);
  307. X            np = (struct Note *) LLM_next(&sp->note_rt);
  308. X            }
  309. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  310. X        }
  311. X    xv_destroy_safe(main_frame);
  312. X    exit(errnum);
  313. X    }
  314. X
  315. /*
  316. X    Scan the notes directory and locate all notes.  Create frames of the
  317. X    appropriate attributes for any notes found.  Called on startup or
  318. X    folder change.
  319. */
  320. restorenotes()
  321. X    {
  322. X    int  found;
  323. X    char *cp;
  324. X    DIR *dp;
  325. X    struct dirent *ent;
  326. X    struct stat st;
  327. X    struct Note *np;
  328. X    struct SubDir *sp;
  329. X    struct ps_component *list, *tok;
  330. X    Menu_item mi;
  331. X    char buf[MAXBUFLEN];
  332. X
  333. X    /* parse requested order */
  334. X    list = parse_string(folderorder, ", \t", 0, 0, 0);
  335. X    if(list != NULL)
  336. X        {
  337. X        tok = list;
  338. X        while(tok != NULL)
  339. X            {
  340. X            if(stat(tok->ps_text, &st) == 0 && (S_IFMT & st.st_mode) == S_IFDIR)
  341. X                {
  342. X                sp = (struct SubDir *)LLM_add(&subdir_rt);
  343. X                if(sp == NULL)
  344. X                    {
  345. X                    notice_prompt(main_frame, NULL,
  346. X                        NOTICE_MESSAGE_STRINGS,
  347. X                            "Insufficient memory - Exiting",
  348. X                            sys_errlist[errno],
  349. X                            NULL,
  350. X                        NOTICE_BUTTON_YES, "Acknowledge",
  351. X                        NOTICE_NO_BEEPING, noticenobeep,
  352. X                        NULL);
  353. X                    cleanup(1);
  354. X                    }
  355. X                strcpy(sp->subdir, tok->ps_text);
  356. X                LLM_init(&sp->note_rt, sizeof(struct Note));
  357. X                mi = xv_create(NULL, MENUITEM,
  358. X                    MENU_STRING, sp->subdir,
  359. X                    MENU_NOTIFY_PROC, newnote,
  360. X                    NULL);
  361. X                xv_set(main_newnote, MENU_APPEND_ITEM, mi, NULL);
  362. X                mi = xv_create(NULL, MENUITEM,
  363. X                    MENU_STRING, sp->subdir,
  364. X                    MENU_GEN_PULLRIGHT, gen_exposemenu,
  365. X                    NULL);
  366. X                xv_set(main_expose, MENU_APPEND_ITEM, mi, NULL);
  367. X                mi = xv_create(NULL, MENUITEM,
  368. X                    MENU_STRING, sp->subdir,
  369. X                    MENU_GEN_PULLRIGHT, gen_prtmenu,
  370. X                    NULL);
  371. X                xv_set(main_print, MENU_APPEND_ITEM, mi, NULL);
  372. X                }
  373. X            tok = tok->ps_next;
  374. X            }
  375. X        free_ps_list(list);
  376. X        }
  377. X
  378. X    dp = opendir(note_dir);
  379. X    if(dp == NULL)
  380. X        {
  381. X        notice_prompt(main_frame, NULL,
  382. X            NOTICE_MESSAGE_STRINGS,
  383. X                "Couldn't read directory",
  384. X                note_dir,
  385. X                sys_errlist[errno],
  386. X                NULL,
  387. X            NOTICE_BUTTON_YES, "Acknowledge",
  388. X            NOTICE_NO_BEEPING, noticenobeep,
  389. X            NULL);
  390. X        return;
  391. X        }
  392. X    (void) re_comp("Note_[0-9][0-9]*.*\\.info$");
  393. X    while((ent = readdir(dp)) != NULL)
  394. X        {
  395. X        if(*ent->d_name != '.' && stat(ent->d_name, &st) == 0 &&
  396. X           (S_IFMT & st.st_mode) == S_IFDIR)
  397. X            {
  398. X            found = 0;
  399. X            sp = (struct SubDir *)LLM_first(&subdir_rt);
  400. X            while(sp != NULL)
  401. X                {
  402. X                if(strcmp(ent->d_name, sp->subdir) == 0)/* already processed */
  403. X                    {
  404. X                    found = 1;
  405. X                    break;
  406. X                    }
  407. X                sp = (struct SubDir *)LLM_next(&subdir_rt);
  408. X                }
  409. X            if(found) continue;
  410. X            sp = (struct SubDir *)LLM_add(&subdir_rt);
  411. X            if(sp == NULL)
  412. X                {
  413. X                notice_prompt(main_frame, NULL,
  414. X                    NOTICE_MESSAGE_STRINGS,
  415. X                        "Insufficient memory - Exiting",
  416. X                        sys_errlist[errno],
  417. X                        NULL,
  418. X                    NOTICE_BUTTON_YES, "Acknowledge",
  419. X                    NOTICE_NO_BEEPING, noticenobeep,
  420. X                    NULL);
  421. X                cleanup(1);
  422. X                }
  423. X            strcpy(sp->subdir, ent->d_name);
  424. X            LLM_init(&sp->note_rt, sizeof(struct Note));
  425. X            mi = xv_create(NULL, MENUITEM,
  426. X                MENU_STRING, sp->subdir,
  427. X                MENU_NOTIFY_PROC, newnote,
  428. X                NULL);
  429. X            xv_set(main_newnote, MENU_APPEND_ITEM, mi, NULL);
  430. X            mi = xv_create(NULL, MENUITEM,
  431. X                MENU_STRING, sp->subdir,
  432. X                MENU_GEN_PULLRIGHT, gen_exposemenu,
  433. X                NULL);
  434. X            xv_set(main_expose, MENU_APPEND_ITEM, mi, NULL);
  435. X            mi = xv_create(NULL, MENUITEM,
  436. X                MENU_STRING, sp->subdir,
  437. X                MENU_GEN_PULLRIGHT, gen_prtmenu,
  438. X                NULL);
  439. X            xv_set(main_print, MENU_APPEND_ITEM, mi, NULL);
  440. X            }
  441. X        }
  442. X    closedir(dp);
  443. X    sp = (struct SubDir *)LLM_first(&subdir_rt);
  444. X    while(sp != NULL)
  445. X        {
  446. X        sprintf(buf, "%s/%s", note_dir, sp->subdir);
  447. X        dp = opendir(buf);
  448. X        if(dp == NULL)
  449. X            {
  450. X            notice_prompt(main_frame, NULL,
  451. X                NOTICE_MESSAGE_STRINGS,
  452. X                    "Couldn't read directory",
  453. X                    note_dir,
  454. X                    sys_errlist[errno],
  455. X                    NULL,
  456. X                NOTICE_BUTTON_YES, "Acknowledge",
  457. X                NOTICE_NO_BEEPING, noticenobeep,
  458. X                NULL);
  459. X            }
  460. X        else
  461. X            {
  462. X            while((ent = readdir(dp)) != NULL)
  463. X                {
  464. X                if(re_exec(ent->d_name) == 1)
  465. X                    {
  466. X                    np = (struct Note *)LLM_add(&sp->note_rt);
  467. X                    if(np == NULL)
  468. X                        {
  469. X                        notice_prompt(main_frame, NULL,
  470. X                            NOTICE_MESSAGE_STRINGS,
  471. X                                "Insufficient memory - Exiting",
  472. X                                note_dir,
  473. X                                sys_errlist[errno],
  474. X                                NULL,
  475. X                            NOTICE_BUTTON_YES, "Acknowledge",
  476. X                            NOTICE_NO_BEEPING, noticenobeep,
  477. X                            NULL);
  478. X                        cleanup(1);
  479. X                        }
  480. X                    memset((char *)np, 0, sizeof(struct Note));
  481. X                    np->sp = sp;
  482. X                    strcpy(np->basename, ent->d_name);
  483. X                    cp = np->basename;
  484. X                    while(*cp)
  485. X                        {
  486. X                        if(*cp == '.') *cp = 0;
  487. X                        cp++;
  488. X                        }
  489. X                    setnote(np);
  490. X                    adjust_sorted(np);
  491. X                    }
  492. X                }
  493. X            closedir(dp);
  494. X            }
  495. X        sp = (struct SubDir *)LLM_next(&subdir_rt);
  496. X        }
  497. X    }
  498. X
  499. /*
  500. X   Trims trailing blanks, tabs, newlines, and carriage returns from a string 
  501. */
  502. X
  503. trim(start)
  504. X    register char *start;
  505. X    {
  506. X    register int  slen;
  507. X    register char *end;
  508. X
  509. X    slen = strlen(start);
  510. X    if(slen == 0) return;
  511. X    end = start + slen - 1;
  512. X    while( (*end == ' ' || *end == '\t' || *end == '\n' || *end == '\r')
  513. X           && end >= start) end--;
  514. X    end++;
  515. X    *end = '\0';
  516. X    }
  517. X
  518. /* Searches for first occurrence of spattern in string */
  519. X
  520. char *instr(string, spattern)
  521. X    char *string;
  522. X    char *spattern;
  523. X    {
  524. X    register char *pos1, *pos2;
  525. X
  526. X    while(*string != '\0')
  527. X        {
  528. X        pos1 = string;
  529. X        pos2 = spattern;
  530. X        while(*pos1 == *pos2)
  531. X            {
  532. X            pos1++;
  533. X            pos2++;
  534. X            if(*pos2 == '\0') return(string);
  535. X            }
  536. X        string++;
  537. X        }
  538. X    return(NULL);
  539. X    }
  540. X
  541. xverror(obj, list)
  542. X    Xv_object obj;
  543. X    Attr_avlist list;
  544. X    {
  545. X    fprintf(stderr, "XView error:  %s\n", xv_error_format(obj, list));
  546. X    kill(getpid(), SIGBUS);
  547. X    }
  548. X
  549. xerror()
  550. X    {
  551. X    if(fork() == 0)
  552. X        kill(getpid(), SIGBUS);
  553. X    return(XV_ERROR);
  554. X    }
  555. SHAR_EOF
  556. chmod 0644 pan.c ||
  557. echo 'restore of pan.c failed'
  558. Wc_c="`wc -c < 'pan.c'`"
  559. test 15901 -eq "$Wc_c" ||
  560.     echo 'pan.c: original size 15901, current size' "$Wc_c"
  561. fi
  562. # ============= pan.h ==============
  563. if test -f 'pan.h' -a X"$1" != X"-c"; then
  564.     echo 'x - skipping pan.h (File already exists)'
  565. else
  566. echo 'x - extracting pan.h (Text)'
  567. sed 's/^X//' << 'SHAR_EOF' > 'pan.h' &&
  568. /*
  569. Post A Note V2.4
  570. Copyright (c) 1992, Jeffrey W. Bailey
  571. All rights reserved.
  572. X
  573. Permission is granted to distribute this program in exact, complete
  574. source form, which includes this copyright notice, as long as no fee
  575. other than media and distribution cost is charged.
  576. X
  577. This program may not be used in whole, or in part, in any other manner
  578. without prior written permission from the author.
  579. X
  580. This program may not be distributed in modified form without prior
  581. written permission from the author.  In other words, patches may be
  582. distributed, but modified source may not be distributed.
  583. X
  584. If there are any questions, comments or suggestions, the author may be
  585. contacted at:
  586. X
  587. X    jeff@rd1.interlan.com
  588. X
  589. X    or
  590. X
  591. X    Jeffrey Bailey
  592. X    Racal-Datacom, Inc.
  593. X    Mail Stop E-110
  594. X    1601 N. Harrison Parkway
  595. X    Sunrise, FL  33323-2899
  596. */
  597. X
  598. #ifndef  PAN
  599. X
  600. #include <stdio.h>
  601. #include <time.h>
  602. #include <dirent.h>
  603. #include <sys/types.h>
  604. #include <sys/wait.h>
  605. #include <sys/time.h>
  606. #include <sys/resource.h>
  607. #include <sys/stat.h>
  608. #include <xview/xview.h>
  609. #include <xview/panel.h>
  610. #include <xview/openmenu.h>
  611. #include <xview/textsw.h>
  612. #include <xview/svrimage.h>
  613. #include <xview/icon.h>
  614. #include <xview/notice.h>
  615. #include <xview/defaults.h>
  616. #include <xview/seln.h>
  617. X
  618. #define  PAN
  619. X
  620. /* parser stuff */
  621. struct ps_component
  622. X    {
  623. X    struct ps_component *ps_prev; /* Pointer to previous node */
  624. X    struct ps_component *ps_next; /* Pointer to next node */
  625. X    char *ps_text;                /* Pointer to token text */
  626. X    char ps_start_delim;          /* Character delimiter for start of token */
  627. X    char ps_end_delim;            /* Character delimiter for end of token */
  628. X    };
  629. extern struct ps_component *parse_string();
  630. X
  631. X
  632. /* Linked List stuff */
  633. X
  634. struct LLM_node   {
  635. X                  struct LLM_node *Next;
  636. X                  struct LLM_node *Prev;
  637. X                  };
  638. X
  639. struct LLM_root   {
  640. X                  int              Init;
  641. X                  struct LLM_node *First;
  642. X                  struct LLM_node *Last;
  643. X                  struct LLM_node *Current;
  644. X                  unsigned int     Size;
  645. X                  };
  646. X
  647. typedef struct LLM_root LLM_root;
  648. X
  649. extern char *LLM_add();
  650. extern char *LLM_first();
  651. extern char *LLM_insert();
  652. extern char *LLM_last();
  653. extern char *LLM_next();
  654. extern char *LLM_previous();
  655. extern char *LLM_current();
  656. X
  657. /* Pan stuff */
  658. struct resource {
  659. X    char *a;
  660. X    char *b;
  661. };
  662. X
  663. #ifdef public
  664. struct resource resources [] = {
  665. X    {"pan.initialDirectory",    "pan.initialdirectory"},
  666. X    {"pan.noticeBeep",        "pan.noticebeep"},
  667. X    {"pan.confirmDestroy",    "pan.confirmdestroy"},
  668. X    {"pan.printCommand",    "pan.printcommand"},
  669. X    {"pan.iconTransparent",    "pan.icontransparent"},
  670. X    {"pan.folderOrder",            "pan.folderorder"},
  671. X    {"pan.defaultSearch",    "pan.defaultsearch"}
  672. };
  673. X
  674. short myicon [] = {
  675. #include "pan.icon"
  676. };
  677. X
  678. #else /* ifdef public */
  679. X
  680. extern struct resource resources [];
  681. extern short myicon [];
  682. X
  683. #endif /* ifdef public */
  684. X
  685. /* Index number into resources array */
  686. #define RES_IDIR         0
  687. #define RES_NBEEP        1
  688. #define RES_CDESTROY     2
  689. #define RES_PCOMMAND     3
  690. #define RES_ITRANSPARENT 4
  691. #define RES_FORDER       5
  692. #define RES_DSEARCH      6
  693. X
  694. /* Resource default values (IDIR default is built dynamically) */
  695. #define RESDEF_NBEEP        TRUE
  696. #define RESDEF_CDESTROY        FALSE
  697. #define RESDEF_PCOMMAND        "/usr/ucb/lpr $FILE"
  698. #define RESDEF_ITRANSPARENT    FALSE
  699. #define RESDEF_FORDER          "Miscellaneous"
  700. #define RESDEF_DSEARCH          ""
  701. X
  702. #ifndef public
  703. #define public extern
  704. #endif
  705. X
  706. #define NOTEDIR ".pan"
  707. #define NOTENAM "Note_%d_%d"
  708. X
  709. #define DEFWIDTH  260
  710. #define DEFHEIGHT 200
  711. #define DEFSPACING 30
  712. X
  713. #define MAINWIDTH  200
  714. #define MAINHEIGHT 90
  715. X
  716. #define FLDRWIDTH  350
  717. #define FLDRHEIGHT 60
  718. #define FLDRSPACING 30
  719. X
  720. #define DESTROYWIDTH  160
  721. #define DESTROYHEIGHT 230
  722. #define DESTROYSPACING 30
  723. X
  724. #define SEARCHWIDTH  160
  725. #define SEARCHHEIGHT 230
  726. #define SEARCHSPACING 30
  727. X
  728. #define MOVEWIDTH  550
  729. #define MOVEHEIGHT 250
  730. #define MOVESPACING 30
  731. X
  732. #define FORCE   1
  733. #define NOFORCE 0
  734. X
  735. #define NOTITLE "Untitled"
  736. X
  737. #define MAXTITLELEN     100
  738. #define MAXTITLEDISLEN  8
  739. #define MAXSEARCHLEN    MAXTITLELEN
  740. #define MAXSEARCHDISLEN 15
  741. #define MAXBUFLEN       1024
  742. X
  743. #define MAXINCORE      20  /* Max. note windows created */
  744. #define MAXSUBDIR      20  /* Max. len of sub dir name */
  745. #define MAXNAME        256 /* Max. note file name len */
  746. X
  747. #define COL_ROLLOVER 10
  748. #define COL_MAXCOL    6
  749. X
  750. #define CHOICE_ALL       "All"
  751. #define CHOICE_FROM_LIST "From List"
  752. X
  753. #define CHOICE_QUIT    "Quit"
  754. #define CHOICE_MOVE    "Move Note"
  755. #define CHOICE_FOLDER  "Create Folder"
  756. #define CHOICE_DESTROY "Destroy Folder"
  757. #define CHOICE_PRINT   "Print Note"
  758. X
  759. public Frame  main_frame;
  760. public Panel  main_panel;
  761. public Menu   main_newnote;
  762. public Menu   main_expose;
  763. public Menu   main_print;
  764. X
  765. public Frame      folder_frame;
  766. public Panel_item folder_item;
  767. public Menu_item  folder_mitem;
  768. X
  769. public Frame      move_frame;
  770. public Panel      move_panel;
  771. public Menu_item  move_mitem;
  772. X
  773. public Frame      destroy_frame;
  774. public Panel_item destroy_item;
  775. public Menu_item  destroy_mitem;
  776. X
  777. public Frame      search_frame;
  778. public Panel_item search_item;
  779. X
  780. public int move_up, destroy_up, search_up;
  781. X
  782. enum NoteState {
  783. X    Visible = 0,
  784. X    Hidden  = 1,
  785. X    Veiled  = 2
  786. };
  787. typedef enum NoteState NoteState;
  788. X
  789. struct Note {
  790. X    Rect       rect;
  791. X    NoteState  state;
  792. X    char       ntitle[MAXTITLELEN + 1];
  793. X    int        mapped;
  794. X    Frame      frame;
  795. X    Panel      panel;
  796. X    Textsw     textsw;
  797. X    Panel_item title;
  798. X    Panel_item hide;
  799. X    Panel_item destroy;
  800. X    Panel_item cdate;
  801. X    Panel_item ctime;
  802. X    Icon       icon;
  803. X    long       crttime;
  804. X    long       touched;
  805. X    char       basename[MAXNAME];
  806. X    struct SubDir *sp;
  807. };
  808. X
  809. struct SubDir {
  810. X    char           subdir[MAXSUBDIR];
  811. X   struct LLM_root note_rt;
  812. };
  813. X
  814. struct FreeWin {
  815. X    Frame      frame;
  816. X    Panel      panel;
  817. X    Textsw     textsw;
  818. X    Panel_item title;
  819. X    Panel_item hide;
  820. X    Panel_item destroy;
  821. X    Panel_item cdate;
  822. X    Panel_item ctime;
  823. X    Icon       icon;
  824. };
  825. X
  826. public int  confirmdestroy;
  827. public int  noticenobeep;
  828. public int  icontransparent;
  829. public char folderorder[2048];
  830. X
  831. public int  notecount;
  832. X
  833. public int  debug_on;
  834. X
  835. public char note_dir [MAXBUFLEN];
  836. public char myname [MAXBUFLEN];
  837. X
  838. extern int  cleanup(), hideall(), exposeall(), hidenote(), removenote();
  839. extern int  dismissed(), frameexit(), dragdrop(), reseticon(), newtitle();
  840. extern int  newnote(), exposemenu(), actionmenu(), newfolder(), folderdone();
  841. extern int  notesearch(), movenote(), destroyfolder();
  842. extern Menu gen_exposemenu(), gen_prtmenu();
  843. extern Notify_value child_death();
  844. extern char *add_sorted();
  845. X
  846. public struct LLM_root subdir_rt;
  847. public struct LLM_root freewin_rt;
  848. X
  849. #endif /* PAN */
  850. SHAR_EOF
  851. chmod 0644 pan.h ||
  852. echo 'restore of pan.h failed'
  853. Wc_c="`wc -c < 'pan.h'`"
  854. test 6718 -eq "$Wc_c" ||
  855.     echo 'pan.h: original size 6718, current size' "$Wc_c"
  856. fi
  857. # ============= pan.icon ==============
  858. if test -f 'pan.icon' -a X"$1" != X"-c"; then
  859.     echo 'x - skipping pan.icon (File already exists)'
  860. else
  861. echo 'x - extracting pan.icon (Text)'
  862. sed 's/^X//' << 'SHAR_EOF' > 'pan.icon' &&
  863. /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  864. X */
  865. X    0x0000,0x0000,0x0000,0x0800,
  866. X    0x0000,0x0000,0x0000,0x1600,
  867. X    0x0000,0x0000,0x0000,0x1100,
  868. X    0x0000,0x0000,0x0000,0x2200,
  869. X    0x0000,0x0000,0x0000,0x4200,
  870. X    0x0000,0x0000,0x0000,0x6400,
  871. X    0x07FF,0xFFFF,0xFFFF,0x9FE0,
  872. X    0x0400,0x0000,0x0001,0x0820,
  873. X    0x0400,0x0000,0x0001,0x1020,
  874. X    0x0400,0x0020,0x0002,0x2020,
  875. X    0x0424,0x0022,0x0004,0x2020,
  876. X    0x045E,0x61FE,0x0004,0x4020,
  877. X    0x0401,0xB600,0x0008,0x8020,
  878. X    0x0400,0x0000,0x0010,0x8020,
  879. X    0x0400,0x0000,0x0011,0x0020,
  880. X    0x0400,0x0000,0x01A2,0x0020,
  881. X    0x0404,0x0100,0x0142,0x0020,
  882. X    0x04EB,0x5531,0xAE45,0xB920,
  883. X    0x0400,0x8983,0xF089,0x8320,
  884. X    0x0400,0x0118,0x0108,0x0020,
  885. X    0x0400,0x0008,0x0110,0x0020,
  886. X    0x0400,0x0000,0x0220,0x0020,
  887. X    0x0400,0x0000,0x2420,0x0020,
  888. X    0x046E,0x340F,0x4446,0x8220,
  889. X    0x0400,0x83A8,0x0888,0x7DA0,
  890. X    0x0400,0x0000,0x1080,0x0020,
  891. X    0x0400,0x0000,0x1100,0x0020,
  892. X    0x0400,0x0000,0x2E00,0x0020,
  893. X    0x0400,0x0000,0x2200,0x0020,
  894. X    0x0421,0x8800,0x4C00,0x0020,
  895. X    0x0442,0xA800,0x7000,0x0020,
  896. X    0x0418,0x457D,0xC000,0x0020,
  897. X    0x0400,0x0248,0x0000,0x0020,
  898. X    0x0400,0x0000,0x0000,0x0020,
  899. X    0x0400,0x0000,0x0000,0x0020,
  900. X    0x0400,0x0000,0x0000,0x0020,
  901. X    0x0400,0x0000,0x0000,0x0020,
  902. X    0x0400,0x0000,0x0000,0x0020,
  903. X    0x0400,0x0000,0x0000,0x0020,
  904. X    0x0400,0x0000,0x0000,0x0020,
  905. X    0x0400,0x0000,0x0000,0x0020,
  906. X    0x0400,0x0000,0x0000,0x0020,
  907. X    0x0400,0x0000,0x0000,0x0020,
  908. X    0x0400,0x0000,0x0000,0x0020,
  909. X    0x0400,0x0000,0x0000,0x0020,
  910. X    0x0400,0x0000,0x0000,0x0020,
  911. X    0x07FF,0xFFFF,0xFFFF,0xFFE0,
  912. X    0x0000,0x0000,0x0000,0x0000,
  913. X    0x0000,0x0000,0x0000,0x0000,
  914. X    0x0000,0x0000,0x0000,0x0000,
  915. X    0x0000,0x0000,0x0000,0x0000,
  916. X    0x0000,0x0000,0x0000,0x0000,
  917. X    0x0000,0x0000,0x0000,0x0000,
  918. X    0x0000,0x0000,0x0000,0x0000,
  919. X    0x0000,0x0000,0x0000,0x0000,
  920. X    0x0000,0x0000,0x0000,0x0000,
  921. X    0x0000,0x0000,0x0000,0x0000,
  922. X    0x0000,0x0000,0x0000,0x0000,
  923. X    0x0000,0x0000,0x0000,0x0000,
  924. X    0x0000,0x0000,0x0000,0x0000,
  925. X    0x0000,0x0000,0x0000,0x0000,
  926. X    0x0000,0x0000,0x0000,0x0000,
  927. X    0x0000,0x0000,0x0000,0x0000,
  928. X    0x0000,0x0000,0x0000,0x0000
  929. SHAR_EOF
  930. chmod 0644 pan.icon ||
  931. echo 'restore of pan.icon failed'
  932. Wc_c="`wc -c < 'pan.icon'`"
  933. test 1997 -eq "$Wc_c" ||
  934.     echo 'pan.icon: original size 1997, current size' "$Wc_c"
  935. fi
  936. true || echo 'restore of pan.man failed'
  937. echo End of part 4, continue with part 5
  938. exit 0
  939. -- 
  940. --
  941. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  942. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  943. Sunnyvale, California 94086            at&t: 408/522-9236
  944.