home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume21 / pan / part01 < prev    next >
Encoding:
Text File  |  1993-11-08  |  50.4 KB  |  1,821 lines

  1. Newsgroups: comp.sources.x
  2. From: jeff@tasslehoff.interlan.com (Jeff Bailey)
  3. Subject: v21i037:  pan - A post a note program, Part01/06
  4. Message-ID: <csx-v21i037=pan.180636@sparky.Sterling.COM>
  5. X-Md4-Signature: 40f9fc54f36837ee560a9f8d02c64c65
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Tue, 9 Nov 1993 00:06:52 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: jeff@tasslehoff.interlan.com (Jeff Bailey)
  12. Posting-number: Volume 21, Issue 37
  13. Archive-name: pan/part01
  14. Environment: X11, OpenLook, XView
  15. Supersedes: pan: Volume 16, Issue 137-142
  16.  
  17. Extracts from Pan 3.0 README:
  18.  
  19. About Pan:
  20.  
  21. Pan is an Open Look X Windows Post A Note program.  It is basically a note
  22. manager program.  It organizes notes into folders.  Each note may be hidden or
  23. visible.  If it is visible, it is mapped to a window on the display.  The
  24. note's state, position, and size are "remembered" across invocations of Pan.
  25.  
  26. Some of Pan's features are:
  27.  
  28.     o  Multiple folders
  29.     o  Number of notes limited only by memory (swap space).
  30.     o  Re-sizable notes with full text editing capabilities.
  31.     o  Note text size limited only by machine resources.
  32.     o  Command line control language.
  33.     o  Flexible note searching features.
  34.     o  Flexible note printing features.
  35.  
  36. Version 3.0:
  37.  
  38. I have only built and tested Pan 3.0 under Open Windows V3 on a sun4 platform.
  39. I have tried to remain compatible with OW2.0, but I may have accidentally
  40. used a new feature, or attribute.  If Pan 3.0 won't compile or work correctly
  41. under OW2.0, get Pan 2.4 and use it.
  42.  
  43. ---- Cut Here and feed the following to sh ----
  44. #!/bin/sh
  45. # This is a shell archive (produced by shar 3.49)
  46. # To extract the files from this archive, save it to a file, remove
  47. # everything above the "!/bin/sh" line above, and type "sh file_name".
  48. #
  49. # made 10/04/1993 15:31 UTC by jeff@ss1
  50. # Source directory /tmp_mnt/usr4/jeff/c/pan
  51. #
  52. # existing files will NOT be overwritten unless -c is specified
  53. #
  54. # This shar contains:
  55. # length  mode       name
  56. # ------ ---------- ------------------------------------------
  57. #  24544 -rw-r--r-- pan3.0/control.c
  58. #   7221 -rw-r--r-- pan3.0/event.c
  59. #   4329 -rw-r--r-- pan3.0/dnd.c
  60. #   8148 -rw-r--r-- pan3.0/llm.c
  61. #   7450 -rw-r--r-- pan3.0/README
  62. #  10131 -rw-r--r-- pan3.0/pan.h
  63. #   9172 -rw-r--r-- pan3.0/menu.c
  64. #  12055 -rw-r--r-- pan3.0/move.c
  65. #   1997 -rw-r--r-- pan3.0/pan.icon
  66. #   7422 -rw-r--r-- pan3.0/hidexp.c
  67. #  21398 -rw-r--r-- pan3.0/pan.man
  68. #   1762 -rw-r--r-- pan3.0/misc.c
  69. #   8168 -rw-r--r-- pan3.0/parser.c
  70. #   9620 -rw-r--r-- pan3.0/rmfolder.c
  71. #    823 -rw-r--r-- pan3.0/COPYRIGHT
  72. #   2190 -rw-r--r-- pan3.0/panmain.icon
  73. #    286 -rw-r--r-- pan3.0/MANIFEST
  74. #  15182 -rw-r--r-- pan3.0/note.c
  75. #  21826 -rw-r--r-- pan3.0/pan.c
  76. #   3543 -rw-r--r-- pan3.0/update.c
  77. #   9168 -rw-r--r-- pan3.0/search.c
  78. #   2517 -rw-r--r-- pan3.0/win.c
  79. #  19226 -rw-r--r-- pan3.0/work.c
  80. #   4846 -rw-r--r-- pan3.0/folder.c
  81. #     39 -rw-r--r-- pan3.0/patchlevel.h
  82. #   2705 -rw-r--r-- pan3.0/noteaction.c
  83. #    958 -rw-r--r-- pan3.0/Makefile.std
  84. #   3137 -rwxr-xr-x pan3.0/pancmd
  85. #   1791 -rwxr-xr-x pan3.0/panlog
  86. #    792 -rw-r--r-- pan3.0/Imakefile
  87. #   2190 -rw-r--r-- pan3.0/panmain.mask.icon
  88. #   2190 -rw-r--r-- pan3.0/pan.mask.icon
  89. #
  90. # ============= pan3.0/control.c ==============
  91. if test ! -d 'pan3.0'; then
  92.     echo 'x - creating directory pan3.0'
  93.     mkdir 'pan3.0'
  94. fi
  95. if test -f 'pan3.0/control.c' -a X"$1" != X"-c"; then
  96.     echo 'x - skipping pan3.0/control.c (File already exists)'
  97. else
  98. echo 'x - extracting pan3.0/control.c (Text)'
  99. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/control.c' &&
  100. X/*
  101. XPost A Note V3.0
  102. XCopyright (c) 1993, Jeffrey W. Bailey
  103. XAll rights reserved.
  104. X
  105. XPermission is granted to distribute this program in exact, complete
  106. Xsource form, which includes this copyright notice, as long as no fee
  107. Xother than media and distribution cost is charged.
  108. X
  109. XThis program may not be used in whole, or in part, in any other manner
  110. Xwithout prior written permission from the author.
  111. X
  112. XThis program may not be distributed in modified form without prior
  113. Xwritten permission from the author.  In other words, patches may be
  114. Xdistributed, but modified source may not be distributed.
  115. X
  116. XIf there are any questions, comments or suggestions, the author may be
  117. Xcontacted at:
  118. X
  119. X    jeff@rd1.interlan.com
  120. X
  121. X    or
  122. X
  123. X    Jeffrey Bailey
  124. X    Racal-Datacom, Inc.
  125. X    Mail Stop E-110
  126. X    1601 N. Harrison Parkway
  127. X    Sunrise, FL  33323-2899
  128. X*/
  129. X
  130. X#include "pan.h"
  131. X
  132. Xextern int errno;
  133. Xextern char *sys_errlist[];
  134. X
  135. Xstruct Commands
  136. X    {
  137. X    char *Name;
  138. X    int  (*Routine)();
  139. X    };
  140. X
  141. Xint cmd_debug(), cmd_expose(), cmd_hide(), cmd_movenote(), cmd_newfolder();
  142. Xint cmd_newnote(), cmd_printnote(), cmd_quit(), cmd_rename(), cmd_veil();
  143. X
  144. Xstatic struct Commands cmds[] = {
  145. X    {"debug",     cmd_debug},
  146. X    {"expose",    cmd_expose},
  147. X    {"hide",      cmd_hide},
  148. X    {"move",      cmd_movenote},
  149. X    {"newfolder", cmd_newfolder},
  150. X    {"newnote",   cmd_newnote},
  151. X    {"print",     cmd_printnote},
  152. X    {"quit",      cmd_quit},
  153. X    {"rename",    cmd_rename},
  154. X    {"veil",      cmd_veil},
  155. X    {NULL,        NULL}
  156. X};
  157. X
  158. XFILE *errfp;
  159. X
  160. Xstatic char ctrllck[MAXBUFLEN];
  161. Xstatic char ctrlnam[MAXBUFLEN];
  162. Xstatic char errlnam[MAXBUFLEN];
  163. X
  164. XNotify_value check_ctl_file(client, which)
  165. X    Notify_client client;
  166. X    int  which;
  167. X    {
  168. X    int  fd;
  169. X    struct stat mystat;
  170. X
  171. X    sprintf(ctrllck, "%s/%s", note_dir, CTRLLCK);
  172. X    if(stat(ctrllck, &mystat) == 0)
  173. X        return(NOTIFY_DONE); /* control file is locked */
  174. X
  175. X    sprintf(ctrlnam, "%s/%s", note_dir, CTRLNAM);
  176. X    if(stat(ctrlnam, &mystat) < 0)
  177. X        return(NOTIFY_DONE); /* control file doesn't exit */
  178. X
  179. X    if((fd = open(ctrllck, O_CREAT|O_RDWR|O_EXCL, 0644) < 0))
  180. X        return(NOTIFY_DONE); /* Couldn't acquire lock */
  181. X    (void)close(fd);
  182. X
  183. X    if(logging)
  184. X        sprintf(errlnam, "%s/%s", note_dir, ERRLNAM);
  185. X    else
  186. X        strcpy(errlnam, "/dev/null");
  187. X
  188. X    if((errfp = fopen(errlnam, "a")) == NULL)
  189. X        {
  190. X        (void) unlink(ctrllck);
  191. X        fprintf(stderr, "%s:  Couldn't open %s for append\n", myname, errlnam);
  192. X        return(NOTIFY_DONE);
  193. X        }
  194. X
  195. X    dispatch(ctrlnam);
  196. X
  197. X    (void) fclose(errfp);
  198. X    (void) unlink(ctrlnam);
  199. X    (void) unlink(ctrllck);
  200. X    return(NOTIFY_DONE);
  201. X    }
  202. X
  203. Xdispatch(name)
  204. X    char *name;
  205. X    {
  206. X    FILE *fp;
  207. X    struct ps_component *lp;
  208. X    int  i, found;
  209. X    char buf[MAXBUFLEN];
  210. X
  211. X    fp = fopen(name, "r");
  212. X    if(fp == NULL)
  213. X        {
  214. X        fprintf(errfp, "%s:  Couldn't open %s:  %s\n", myname, name,
  215. X                sys_errlist[errno]);
  216. X        return;
  217. X        }
  218. X
  219. X    while(fgets(buf, sizeof(buf), fp) != NULL)
  220. X        {
  221. X        trim(buf); /* skip comments & blank lines */
  222. X        if(*buf == '#' || *buf == 0) continue;
  223. X
  224. X        lp = parse_string(buf, " \t\n", 1, 1, 1);
  225. X        if(lp == NULL) continue;
  226. X
  227. X        for(i = 0, found = 0; cmds[i].Name != NULL; i++)
  228. X            {
  229. X            if(strcmp(lp->ps_text, cmds[i].Name) == 0)
  230. X                {
  231. X                fprintf(errfp, "%s:  **** executing {%s}\n", myname, buf);
  232. X                found = 1;
  233. X                (*cmds[i].Routine)(lp->ps_next);
  234. X                break;
  235. X                }
  236. X            }
  237. X        free_ps_list(lp);
  238. X        if(!found)
  239. X            {
  240. X            fprintf(errfp, "%s:  Unrecognized command:  %s\n", myname, buf);
  241. X            }
  242. X        }
  243. X
  244. X    (void) fclose(fp);
  245. X    }
  246. X
  247. Xcmd_debug(lp)
  248. X    struct ps_component *lp;
  249. X    {
  250. X    if(debug_on) fprintf(stderr, "cmd_debug\n");
  251. X    if(lp == NULL ||
  252. X       (strcmp(lp->ps_text, "on") != 0 && strcmp(lp->ps_text, "off") != 0))
  253. X        {
  254. X        fprintf(errfp, "%s:  debug command requires \"on|off\" parameter\n",
  255. X            myname);
  256. X        return;
  257. X        }
  258. X    if(strcmp(lp->ps_text, "on") == 0)
  259. X        {
  260. X        debug_on = 1;
  261. X        }
  262. X    else
  263. X        {
  264. X        debug_on = 0;
  265. X        }
  266. X    }
  267. X
  268. Xcmd_expose(lp)
  269. X    struct ps_component *lp;
  270. X    {
  271. X    int  count;
  272. X    int  res;
  273. X    struct Note **npp;
  274. X    struct LLM_root root;
  275. X    char title[MAXBUFLEN];
  276. X    int  gottitle;
  277. X    int  lwindowmax;
  278. X
  279. X    if(debug_on) fprintf(stderr, "cmd_expose\n");
  280. X    lwindowmax = windowmax;
  281. X    gottitle = 0;
  282. X    while(lp != NULL)
  283. X        {
  284. X        if(lp->ps_next == NULL) /* go by two's, so we need another param */
  285. X            {
  286. X            fprintf(errfp, "%s:  Incorrect parameters for expose\n",
  287. X                myname);
  288. X            return;
  289. X            }
  290. X        if(strcmp(lp->ps_text, "title") == 0)
  291. X            {
  292. X            lp = lp->ps_next;
  293. X            strcpy(title, lp->ps_text);
  294. X            gottitle = 1;
  295. X            lp = lp->ps_next;
  296. X            }
  297. X        else if(strcmp(lp->ps_text, "windowmax") == 0)
  298. X            {
  299. X            lp = lp->ps_next;
  300. X            lwindowmax = atoi(lp->ps_text);
  301. X            lp = lp->ps_next;
  302. X            }
  303. X        else
  304. X            {
  305. X            fprintf(errfp, "%s:  Incorrect parameter {%s} for expose\n",
  306. X                myname, lp->ps_text);
  307. X            return;
  308. X            }
  309. X        }
  310. X    if(!gottitle)
  311. X        {
  312. X        fprintf(errfp, "%s:  Missing title for expose\n",
  313. X            myname);
  314. X        return;
  315. X        }
  316. X    res = w_matchingnotes(&root, title, 1);
  317. X    switch(res)
  318. X        {
  319. X        case  -1 :
  320. X            fprintf(errfp, "%s:  Invalid RE for expose command {%s}\n",
  321. X                myname, title);
  322. X            return;
  323. X            break;
  324. X        case  -2 :
  325. X            fprintf(errfp, "%s:  Memory allocation failure during expose\n",
  326. X                myname);
  327. X            LLM_free(&root);
  328. X            return;
  329. X            break;
  330. X        }
  331. X    count = 0;
  332. X    npp = (struct Note **) LLM_first(&root);
  333. X    if(npp == NULL)
  334. X        {
  335. X        fprintf(errfp, "%s:  No matches found to expose for RE {%s}\n",
  336. X            myname, title);
  337. X        }
  338. X    while(npp != NULL && (lwindowmax == -1 || count < lwindowmax))
  339. X        {
  340. X        count++;
  341. X        w_exposenote(*npp, ERRINLOG);
  342. X        npp = (struct Note **) LLM_next(&root);
  343. X        }
  344. X    LLM_free(&root);
  345. X
  346. X    if(npp != NULL && count == lwindowmax)
  347. X        fprintf(errfp, "%s:  expose halted at windowmax setting of %d\n",
  348. X                  myname, count);
  349. X    if(count)
  350. X        fprintf(errfp, "%s:  exposed %d notes for RE {%s}\n",
  351. X                  myname, count, title);
  352. X    }
  353. X
  354. Xcmd_hide(lp)
  355. X    struct ps_component *lp;
  356. X    {
  357. X    int  count;
  358. X    int  res;
  359. X    struct Note **npp;
  360. X    struct LLM_root root;
  361. X
  362. X    if(debug_on) fprintf(stderr, "cmd_hide\n");
  363. X    if(lp == NULL || lp->ps_next == NULL)
  364. X        {
  365. X        fprintf(errfp, "%s:  hide command requires title RE parameter\n",
  366. X            myname);
  367. X        return;
  368. X        }
  369. X    if(debug_on)
  370. X        fprintf(stderr, "hide {%s} {%s}\n", lp->ps_text,
  371. X            lp->ps_next->ps_text);
  372. X    if(strcmp(lp->ps_text, "title") != 0)
  373. X        {
  374. X        fprintf(errfp, "%s:  hide command requires title keyword\n",
  375. X            myname);
  376. X        return;
  377. X        }
  378. X    lp = lp->ps_next;
  379. X    /*
  380. X        This is slightly different than for expose - we will probably get
  381. X        matches for notes that are already hidden because of the way
  382. X        w_matchingnotes works.  It knows how to a) find all non-visible notes,
  383. X        and b) all notes.
  384. X    */
  385. X    res = w_matchingnotes(&root, lp->ps_text, 0);
  386. X    switch(res)
  387. X        {
  388. X        case  -1 :
  389. X            fprintf(errfp, "%s:  Invalid RE for hide command {%s}\n",
  390. X                myname, lp->ps_text);
  391. X            return;
  392. X            break;
  393. X        case  -2 :
  394. X            fprintf(errfp, "%s:  Memory allocation failure during hide\n",
  395. X                myname);
  396. X            LLM_free(&root);
  397. X            return;
  398. X            break;
  399. X        }
  400. X    count = 0;
  401. X    npp = (struct Note **) LLM_first(&root);
  402. X    if(npp == NULL)
  403. X        {
  404. X        fprintf(errfp, "%s:  No matches found to hide for RE {%s}\n",
  405. X            myname, lp->ps_text);
  406. X        }
  407. X    while(npp != NULL)
  408. X        {
  409. X        /*
  410. X            Make sure the note is really visible; note that we do not hide
  411. X            veiled notes.
  412. X        */
  413. X        if((*npp)->state == Visible && (*npp)->mapped)
  414. X            {
  415. X            count++;
  416. X            w_hidenote(*npp);
  417. X            }
  418. X        npp = (struct Note **) LLM_next(&root);
  419. X        }
  420. X    LLM_free(&root);
  421. X    fprintf(errfp, "%s:  hid %d notes for RE {%s}\n",
  422. X            myname, count, lp->ps_text);
  423. X    }
  424. X
  425. Xcmd_movenote(lp)
  426. X    struct ps_component *lp;
  427. X    {
  428. X    int  gotsrc, gotdst, gottitle, res, count;
  429. X    struct SubDir *src_sp, *dst_sp, *sp;
  430. X    struct Note **npp;
  431. X    struct LLM_root root;
  432. X    char src[MAXBUFLEN];
  433. X    char dst[MAXBUFLEN];
  434. X    char title[MAXBUFLEN];
  435. X
  436. X    if(debug_on) fprintf(stderr, "cmd_movenote\n");
  437. X    gotsrc = gotdst = gottitle = 0;
  438. X    while(lp != NULL)
  439. X        {
  440. X        if(lp->ps_next == NULL) /* go by two's, so we need another param */
  441. X            {
  442. X            fprintf(errfp, "%s:  Incorrect parameters for move\n",
  443. X                myname);
  444. X            return;
  445. X            }
  446. X        if(strcmp(lp->ps_text, "source") == 0)
  447. X            {
  448. X            lp = lp->ps_next;
  449. X            strcpy(src, lp->ps_text);
  450. X            gotsrc = 1;
  451. X            lp = lp->ps_next;
  452. X            }
  453. X        else if(strcmp(lp->ps_text, "title") == 0)
  454. X            {
  455. X            lp = lp->ps_next;
  456. X            strcpy(title, lp->ps_text);
  457. X            gottitle = 1;
  458. X            lp = lp->ps_next;
  459. X            }
  460. X        else if(strcmp(lp->ps_text, "destination") == 0)
  461. X            {
  462. X            lp = lp->ps_next;
  463. X            strcpy(dst, lp->ps_text);
  464. X            gotdst = 1;
  465. X            lp = lp->ps_next;
  466. X            }
  467. X        else
  468. X            {
  469. X            fprintf(errfp, "%s:  Incorrect parameter {%s} for move\n",
  470. X                myname, lp->ps_text);
  471. X            return;
  472. X            }
  473. X        }
  474. X    if(!gotsrc)
  475. X        {
  476. X        fprintf(errfp, "%s:  Missing source folder for move\n",
  477. X            myname);
  478. X        return;
  479. X        }
  480. X    if(!gotdst)
  481. X        {
  482. X        fprintf(errfp, "%s:  Missing destination folder for move\n",
  483. X            myname);
  484. X        return;
  485. X        }
  486. X    if(!gottitle)
  487. X        {
  488. X        fprintf(errfp, "%s:  Missing title for move\n",
  489. X            myname);
  490. X        return;
  491. X        }
  492. X    src_sp = dst_sp = NULL;
  493. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  494. X    while(sp != NULL)
  495. X        {
  496. X        if(strcmp(src, sp->subdir) == 0) src_sp = sp;
  497. X        if(strcmp(dst, sp->subdir) == 0) dst_sp = sp;
  498. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  499. X        }
  500. X    if(src_sp == NULL)
  501. X        {
  502. X        fprintf(errfp, "%s:  Bad source folder {%s} for move\n",
  503. X            myname, src);
  504. X        return;
  505. X        }
  506. X    if(dst_sp == NULL)
  507. X        {
  508. X        fprintf(errfp, "%s:  Bad destination folder {%s} for move\n",
  509. X            myname, dst);
  510. X        return;
  511. X        }
  512. X    res = w_matchingnotes(&root, title, 0);
  513. X    switch(res)
  514. X        {
  515. X        case  -1 :
  516. X            fprintf(errfp, "%s:  Invalid RE for move command {%s}\n",
  517. X                myname, title);
  518. X            return;
  519. X            break;
  520. X        case  -2 :
  521. X            fprintf(errfp, "%s:  Memory allocation failure during move\n",
  522. X                myname);
  523. X            LLM_free(&root);
  524. X            return;
  525. X            break;
  526. X        }
  527. X    count = 0;
  528. X    npp = (struct Note **) LLM_first(&root);
  529. X    while(npp != NULL)
  530. X        {
  531. X        if((*npp)->sp == src_sp) /* Make sure it's in the src folder */
  532. X            {
  533. X            if(debug_on)
  534. X                fprintf(stderr, "Moving {%s} from {%s} to {%s}...\n",
  535. X                    (*npp)->ntitle, src, dst);
  536. X            res = w_movenote(src_sp, dst_sp, *npp, ERRINLOG);
  537. X            if(res == 0)
  538. X                {
  539. X                if(debug_on) fprintf(stderr, "    ...succeeded\n");
  540. X                count++;
  541. X                }
  542. X            else if(debug_on) fprintf(stderr, "    ...failed\n");
  543. X            }
  544. X        npp = (struct Note **) LLM_next(&root);
  545. X        }
  546. X    fprintf(errfp, "%s:  %d notes moved successfully\n", myname, count);
  547. X    }
  548. X
  549. Xcmd_newfolder(lp)
  550. X    struct ps_component *lp;
  551. X    {
  552. X    if(debug_on) fprintf(stderr, "cmd_newfolder\n");
  553. X    if(lp == NULL || lp->ps_next == NULL || strcmp(lp->ps_text, "folder") != 0)
  554. X        {
  555. X        fprintf(errfp,
  556. X            "%s:  newfolder command requires folder name parameter\n", myname);
  557. X        return;
  558. X        }
  559. X    lp = lp->ps_next;
  560. X    w_newfolder(lp->ps_text, ERRINLOG);
  561. X    }
  562. X
  563. Xcmd_newnote(lp)
  564. X    struct ps_component *lp;
  565. X    {
  566. X    int  x, y;
  567. X    int  gotrect, gottitle, gotfile, gotfolder;
  568. X    struct SubDir *sp;
  569. X    NoteState state;
  570. X    Rect rect;
  571. X    char folder[MAXBUFLEN];
  572. X    char title[MAXBUFLEN];
  573. X    char file[MAXBUFLEN];
  574. X
  575. X    if(debug_on) fprintf(stderr, "cmd_newnote\n");
  576. X    gotrect = gottitle = gotfile = gotfolder = 0;
  577. X
  578. X    /* set up good defaults in case only half is specified */
  579. X    w_popupxy(&x, &y, DEFWIDTH, DEFHEIGHT, DEFSPACING);
  580. X    rect.r_left = x;
  581. X    rect.r_top = y;
  582. X    rect.r_width = DEFWIDTH;
  583. X    rect.r_height = DEFHEIGHT;
  584. X
  585. X    state = Visible;
  586. X    while(lp != NULL)
  587. X        {
  588. X        if(strcmp(lp->ps_text, "folder") == 0)
  589. X            {
  590. X            if(lp->ps_next == NULL)
  591. X                {
  592. X                fprintf(errfp, "%s:  Missing folder name\n", myname);
  593. X                return;
  594. X                }
  595. X            lp = lp->ps_next;
  596. X            strcpy(folder, lp->ps_text);
  597. X            gotfolder = 1;
  598. X            lp = lp->ps_next;
  599. X            }
  600. X        else if(strcmp(lp->ps_text, "title") == 0)
  601. X            {
  602. X            if(lp->ps_next == NULL)
  603. X                {
  604. X                fprintf(errfp, "%s:  Missing title\n", myname);
  605. X                return;
  606. X                }
  607. X            lp = lp->ps_next;
  608. X            strcpy(title, lp->ps_text);
  609. X            gottitle = 1;
  610. X            lp = lp->ps_next;
  611. X            }
  612. X        else if(strcmp(lp->ps_text, "size") == 0)
  613. X            {
  614. X            if(lp->ps_next == NULL || lp->ps_next->ps_next == NULL)
  615. X                {
  616. X                fprintf(errfp, "%s:  Missing width or height\n", myname);
  617. X                return;
  618. X                }
  619. X            gotrect = 1;
  620. X            lp = lp->ps_next;
  621. X            rect.r_width = atoi(lp->ps_text);
  622. X            lp = lp->ps_next;
  623. X            rect.r_height = atoi(lp->ps_text);
  624. X            lp = lp->ps_next;
  625. X            }
  626. X        else if(strcmp(lp->ps_text, "location") == 0)
  627. X            {
  628. X            if(lp->ps_next == NULL || lp->ps_next->ps_next == NULL)
  629. X                {
  630. X                fprintf(errfp, "%s:  Missing x or y location\n", myname);
  631. X                return;
  632. X                }
  633. X            gotrect = 1;
  634. X            lp = lp->ps_next;
  635. X            rect.r_left = atoi(lp->ps_text);
  636. X            lp = lp->ps_next;
  637. X            rect.r_top = atoi(lp->ps_text);
  638. X            lp = lp->ps_next;
  639. X            }
  640. X        else if(strcmp(lp->ps_text, "hidden") == 0)
  641. X            {
  642. X            state = Hidden;
  643. X            lp = lp->ps_next;
  644. X            }
  645. X        else if(strcmp(lp->ps_text, "visible") == 0)
  646. X            {
  647. X            state = Visible;
  648. X            lp = lp->ps_next;
  649. X            }
  650. X        else if(strcmp(lp->ps_text, "veiled") == 0)
  651. X            {
  652. X            state = Veiled;
  653. X            lp = lp->ps_next;
  654. X            }
  655. X        else if(strcmp(lp->ps_text, "file") == 0)
  656. X            {
  657. X            if(lp->ps_next == NULL)
  658. X                {
  659. X                fprintf(errfp, "%s:  Missing file name\n", myname);
  660. X                return;
  661. X                }
  662. X            lp = lp->ps_next;
  663. X            strcpy(file, lp->ps_text);
  664. X            gotfile = 1;
  665. X            lp = lp->ps_next;
  666. X            }
  667. X        else
  668. X            {
  669. X            fprintf(errfp, "%s:  Invalid parameter {%s}\n",
  670. X                myname, lp->ps_text);
  671. X            return;
  672. X            }
  673. X        }
  674. X    if(!gotfolder) strcpy(folder, "Miscellaneous");
  675. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  676. X    while(sp != NULL)
  677. X        {
  678. X        if(strcmp(folder, sp->subdir) == 0) break;
  679. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  680. X        }
  681. X    if(sp == NULL)
  682. X        {
  683. X        fprintf(errfp, "%s:  Invalid folder {%s}\n",
  684. X            myname, folder);
  685. X        return;
  686. X        }
  687. X    w_newnote(sp, state, gotrect ? &rect : NULL, gottitle ? title : NULL,
  688. X        gotfile ? file : NULL, ERRINLOG);
  689. X    }
  690. X
  691. X/*
  692. X    This guy is a half baked state machine for printing notes.
  693. X
  694. X    State 1 = Doing nothing.  Process command and get list of notes to print.
  695. X              Start queuing of first note.
  696. X    State 2 = Printing and called by child_death.  Kick off next queue command.
  697. X    State 3 = Printing and got a real print command.  Add notes to list to
  698. X              be printed.
  699. X    State 4 = Not printing, called on child death, do nothing.
  700. X
  701. X    The state machine is controlled by the variables:  printing, lp, adding
  702. X*/
  703. X
  704. Xcmd_printnote(lp)
  705. X    struct ps_component *lp;
  706. X    {
  707. X    int  adding = 0;
  708. X    struct Note **tnpp1, **tnpp2;
  709. X    struct LLM_root addroot;
  710. X    static int printing = 0;
  711. X    static int  gotfldr, gottitle, res, count;
  712. X    static struct SubDir *fldr_sp, *sp;
  713. X    static struct Note **npp;
  714. X    static struct LLM_root root;
  715. X    static char fldr[MAXBUFLEN];
  716. X    static char title[MAXBUFLEN];
  717. X
  718. X    if(debug_on) fprintf(stderr, "cmd_printnote\n");
  719. X    if(!printing && lp == NULL) return;
  720. X    if(printing && lp != NULL)
  721. X        {
  722. X        /* need to add to list! */
  723. X        adding = 1;
  724. X        }
  725. X    if(printing && lp == NULL)
  726. X        {
  727. X        npp = (struct Note **) LLM_next(&root);
  728. X        if(npp == NULL)
  729. X            {
  730. X            printing = 0;
  731. X            LLM_free(&root);
  732. X            if(debug_on)
  733. X                fprintf(stderr, "Printed %d notes\n", count);
  734. X            }
  735. X        else
  736. X            {
  737. X            if(debug_on)
  738. X                fprintf(stderr, "Printing {%s} ...\n", (*npp)->ntitle);
  739. X            w_printnote(*npp, ERRINLOG);
  740. X            count++;
  741. X            }
  742. X        return;
  743. X        }
  744. X    gotfldr = gottitle = 0;
  745. X    while(lp != NULL)
  746. X        {
  747. X        if(lp->ps_next == NULL) /* go by two's, so we need another param */
  748. X            {
  749. X            fprintf(errfp, "%s:  Incorrect parameters for print\n",
  750. X                myname);
  751. X            return;
  752. X            }
  753. X        if(strcmp(lp->ps_text, "folder") == 0)
  754. X            {
  755. X            lp = lp->ps_next;
  756. X            strcpy(fldr, lp->ps_text);
  757. X            gotfldr = 1;
  758. X            lp = lp->ps_next;
  759. X            }
  760. X        else if(strcmp(lp->ps_text, "title") == 0)
  761. X            {
  762. X            lp = lp->ps_next;
  763. X            strcpy(title, lp->ps_text);
  764. X            gottitle = 1;
  765. X            lp = lp->ps_next;
  766. X            }
  767. X        else
  768. X            {
  769. X            fprintf(errfp, "%s:  Incorrect parameter {%s} for print\n",
  770. X                myname, lp->ps_text);
  771. X            return;
  772. X            }
  773. X        }
  774. X    if(!gotfldr)
  775. X        {
  776. X        fprintf(errfp, "%s:  Missing source folder for print\n",
  777. X            myname);
  778. X        return;
  779. X        }
  780. X    if(!gottitle)
  781. X        {
  782. X        fprintf(errfp, "%s:  Missing title for print\n",
  783. X            myname);
  784. X        return;
  785. X        }
  786. X    fldr_sp = NULL;
  787. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  788. X    while(sp != NULL)
  789. X        {
  790. X        if(strcmp(fldr, sp->subdir) == 0) fldr_sp = sp;
  791. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  792. X        }
  793. X    if(fldr_sp == NULL)
  794. X        {
  795. X        fprintf(errfp, "%s:  Bad source folder {%s} for print\n",
  796. X            myname, fldr);
  797. X        return;
  798. X        }
  799. X    if(adding)
  800. X        {
  801. X        res = w_matchingnotes(&addroot, title, 0);
  802. X        }
  803. X    else
  804. X        {
  805. X        res = w_matchingnotes(&root, title, 0);
  806. X        }
  807. X    switch(res)
  808. X        {
  809. X        case  -1 :
  810. X            fprintf(errfp, "%s:  Invalid RE for print command {%s}\n",
  811. X                myname, title);
  812. X            return;
  813. X            break;
  814. X        case  -2 :
  815. X            fprintf(errfp, "%s:  Memory allocation failure during print\n",
  816. X                myname);
  817. X            LLM_free(&root);
  818. X            return;
  819. X            break;
  820. X        }
  821. X    /* get rid of matching titles not in target folder */
  822. X    if(adding)
  823. X        {
  824. X        tnpp1 = (struct Note **) LLM_first(&addroot);
  825. X        while(tnpp1 != NULL)
  826. X            {
  827. X            if((*tnpp1)->sp != fldr_sp)
  828. X                {
  829. X                LLM_delete(&addroot, (char *)tnpp1);
  830. X                tnpp1 = (struct Note **) LLM_first(&addroot); /* restart */
  831. X                }
  832. X            else
  833. X                {
  834. X                tnpp1 = (struct Note **) LLM_next(&addroot);
  835. X                }
  836. X            }
  837. X        /* now append the new list onto the old one we are printing from */
  838. X        tnpp1 = (struct Note **) LLM_first(&addroot);
  839. X        while(tnpp1 != NULL)
  840. X            {
  841. X            tnpp2 = (struct Note **) LLM_add(&root);
  842. X            if(tnpp2 == NULL) /* Gak! */
  843. X                {
  844. X                fprintf(errfp,
  845. X                    "%s:  Memory allocation failure during print\n",
  846. X                    myname);
  847. X                LLM_free(&addroot);
  848. X                return;
  849. X                }
  850. X            *tnpp2 = *tnpp1;
  851. X            tnpp1 = (struct Note **) LLM_next(&addroot);
  852. X            }
  853. X        LLM_free(&addroot);
  854. X        /* no need to go further, printing should be in process */
  855. X        return;
  856. X        }
  857. X    else
  858. X        {
  859. X        npp = (struct Note **) LLM_first(&root);
  860. X        while(npp != NULL)
  861. X            {
  862. X            if((*npp)->sp != fldr_sp)
  863. X                {
  864. X                LLM_delete(&root, (char *)npp);
  865. X                npp = (struct Note **) LLM_first(&root); /* restart */
  866. X                }
  867. X            else
  868. X                {
  869. X                npp = (struct Note **) LLM_next(&root);
  870. X                }
  871. X            }
  872. X        }
  873. X    count = 0;
  874. X    printing = 1;
  875. X    npp = (struct Note **) LLM_first(&root);
  876. X    if(npp == NULL)
  877. X        {
  878. X        printing = 0;
  879. X        LLM_free(&root);
  880. X        if(debug_on)
  881. X            fprintf(stderr, "Printed %d notes\n", count);
  882. X        }
  883. X    else
  884. X        {
  885. X        if(debug_on)
  886. X            fprintf(stderr, "Printing {%s} ...\n", (*npp)->ntitle);
  887. X        w_printnote(*npp, ERRINLOG);
  888. X        count++;
  889. X        }
  890. X    }
  891. X
  892. Xcmd_quit(lp)
  893. X    struct ps_component *lp;
  894. X    {
  895. X    if(debug_on) fprintf(stderr, "cmd_quit\n");
  896. X    fprintf(errfp, "%s:  Exiting due to quit command\n", myname);
  897. X    (void) fclose(errfp);
  898. X    (void) unlink(ctrlnam);
  899. X    (void) unlink(ctrllck);
  900. X    cleanup(0);
  901. X    }
  902. X
  903. Xcmd_rename(lp)
  904. X    struct ps_component *lp;
  905. X    {
  906. X    if(debug_on) fprintf(stderr, "cmd_rename\n");
  907. X    fprintf(errfp, "%s:  Unimplemented command\n", myname);
  908. X    }
  909. X
  910. Xcmd_veil(lp)
  911. X    struct ps_component *lp;
  912. X    {
  913. X    int  count;
  914. X    int  res;
  915. X    struct Note **npp;
  916. X    struct LLM_root root;
  917. X
  918. X    if(debug_on) fprintf(stderr, "cmd_veil\n");
  919. X    if(lp == NULL || lp->ps_next == NULL)
  920. X        {
  921. X        fprintf(errfp, "%s:  veil command requires title RE parameter\n",
  922. X            myname);
  923. X        return;
  924. X        }
  925. X    if(debug_on)
  926. X        fprintf(stderr, "veil {%s} {%s}\n", lp->ps_text,
  927. X            lp->ps_next->ps_text);
  928. X    if(strcmp(lp->ps_text, "title") != 0)
  929. X        {
  930. X        fprintf(errfp, "%s:  veil command requires title keyword\n",
  931. X            myname);
  932. X        return;
  933. X        }
  934. X    lp = lp->ps_next;
  935. X    /*
  936. X        This is slightly different than for expose - we will probably get
  937. X        matches for notes that are already hidden because of the way
  938. X        w_matchingnotes works.  It knows how to a) find all non-visible notes,
  939. X        and b) all notes.
  940. X    */
  941. X    res = w_matchingnotes(&root, lp->ps_text, 0);
  942. X    switch(res)
  943. X        {
  944. X        case  -1 :
  945. X            fprintf(errfp, "%s:  Invalid RE for veil command {%s}\n",
  946. X                myname, lp->ps_text);
  947. X            return;
  948. X            break;
  949. X        case  -2 :
  950. X            fprintf(errfp, "%s:  Memory allocation failure during veil\n",
  951. X                myname);
  952. X            LLM_free(&root);
  953. X            return;
  954. X            break;
  955. X        }
  956. X    count = 0;
  957. X    npp = (struct Note **) LLM_first(&root);
  958. X    if(npp == NULL)
  959. X        {
  960. X        fprintf(errfp, "%s:  No matches found to veil for RE {%s}\n",
  961. X            myname, lp->ps_text);
  962. X        }
  963. X    while(npp != NULL)
  964. X        {
  965. X        /*
  966. X            Make sure the note is really visible; note that we do not veil
  967. X            hidden notes.
  968. X        */
  969. X        if((*npp)->state == Visible && (*npp)->mapped)
  970. X            {
  971. X            count++;
  972. X            w_veilnote(*npp);
  973. X            }
  974. X        npp = (struct Note **) LLM_next(&root);
  975. X        }
  976. X    LLM_free(&root);
  977. X    fprintf(errfp, "%s:  veiled %d notes for RE {%s}\n",
  978. X            myname, count, lp->ps_text);
  979. X    }
  980. SHAR_EOF
  981. chmod 0644 pan3.0/control.c ||
  982. echo 'restore of pan3.0/control.c failed'
  983. Wc_c="`wc -c < 'pan3.0/control.c'`"
  984. test 24544 -eq "$Wc_c" ||
  985.     echo 'pan3.0/control.c: original size 24544, current size' "$Wc_c"
  986. fi
  987. # ============= pan3.0/event.c ==============
  988. if test -f 'pan3.0/event.c' -a X"$1" != X"-c"; then
  989.     echo 'x - skipping pan3.0/event.c (File already exists)'
  990. else
  991. echo 'x - extracting pan3.0/event.c (Text)'
  992. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/event.c' &&
  993. X/*
  994. XPost A Note V3.0
  995. XCopyright (c) 1993, Jeffrey W. Bailey
  996. XAll rights reserved.
  997. X
  998. XPermission is granted to distribute this program in exact, complete
  999. Xsource form, which includes this copyright notice, as long as no fee
  1000. Xother than media and distribution cost is charged.
  1001. X
  1002. XThis program may not be used in whole, or in part, in any other manner
  1003. Xwithout prior written permission from the author.
  1004. X
  1005. XThis program may not be distributed in modified form without prior
  1006. Xwritten permission from the author.  In other words, patches may be
  1007. Xdistributed, but modified source may not be distributed.
  1008. X
  1009. XIf there are any questions, comments or suggestions, the author may be
  1010. Xcontacted at:
  1011. X
  1012. X    jeff@rd1.interlan.com
  1013. X
  1014. X    or
  1015. X
  1016. X    Jeffrey Bailey
  1017. X    Racal-Datacom, Inc.
  1018. X    Mail Stop E-110
  1019. X    1601 N. Harrison Parkway
  1020. X    Sunrise, FL  33323-2899
  1021. X*/
  1022. X
  1023. X#include "pan.h"
  1024. X
  1025. Xextern int errno;
  1026. Xextern char *sys_errlist[];
  1027. X
  1028. X/*
  1029. X    Handle the window exit event of the mouse pointer.  Used to do auto-saves.
  1030. X    This trick on a frame is not specifically documented, but seems to work.
  1031. X    I hope it doesn't break in the future.
  1032. X*/
  1033. Xframeexit(frame, event, arg)
  1034. X    Frame frame;
  1035. X    Event *event;
  1036. X    Notify_arg arg;
  1037. X    {
  1038. X    int  found = 0;
  1039. X    struct SubDir *sp;
  1040. X    struct Note *np;
  1041. X
  1042. X    if(event_id(event) != LOC_WINEXIT) return;
  1043. X    if(debug_on) fprintf(stderr, "Got LOC_WINEXIT\n");
  1044. X
  1045. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  1046. X    while(sp != NULL && !found)
  1047. X        {
  1048. X        np = (struct Note *) LLM_first(&sp->note_rt);
  1049. X        while(np != NULL && !found)
  1050. X            {
  1051. X            if(np->frame == frame && np->mapped)
  1052. X                {
  1053. X                update(np);
  1054. X                updateinfo(np, NOFORCE);
  1055. X                found = 1;
  1056. X                }
  1057. X            np = (struct Note *) LLM_next(&sp->note_rt);
  1058. X            }
  1059. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  1060. X        }
  1061. X
  1062. X    }
  1063. X
  1064. X/*
  1065. X    Handles a drag & drop event from the file manager into a note, retrieving
  1066. X    the path & file name and inserting it into the note text.
  1067. X*/
  1068. Xdragdrop(window, event, arg)
  1069. X    Xv_Window window;
  1070. X    Event *event;
  1071. X    Notify_arg arg;
  1072. X    {
  1073. X    int  found = 0;
  1074. X    struct SubDir *sp;
  1075. X    struct Note *np;
  1076. X    Xv_Window twin;
  1077. X    int  n;
  1078. X    int  amount;
  1079. X    char buf[SELN_BUFSIZE];
  1080. X
  1081. X    if(debug_on)
  1082. X        {
  1083. X        if(event_action(event) == ACTION_DRAG_MOVE)
  1084. X            fprintf(stderr, "Got ACTION_DRAG_MOVE event\n");
  1085. X        if(event_action(event) == ACTION_DRAG_LOAD)
  1086. X            fprintf(stderr, "Got ACTION_DRAG_LOAD event\n");
  1087. X        if(event_action(event) == ACTION_DRAG_COPY)
  1088. X            fprintf(stderr, "Got ACTION_DRAG_COPY event\n");
  1089. X        }
  1090. X    if(event_action(event) == ACTION_DRAG_LOAD)
  1091. X        {
  1092. X        sp = (struct SubDir *)LLM_first(&subdir_rt);
  1093. X        while(sp != NULL && !found)
  1094. X            {
  1095. X            np = (struct Note *) LLM_first(&sp->note_rt);
  1096. X            while(np != NULL && !found)
  1097. X                {
  1098. X                if(np->mapped)
  1099. X                    {
  1100. X                    twin = (Xv_Window) xv_get(np->textsw, OPENWIN_NTH_VIEW, 0);
  1101. X                    if(twin == window)
  1102. X                        {
  1103. X                        found = 1;
  1104. X                        n = xv_decode_drop(event, buf, sizeof(buf));
  1105. X                        buf[sizeof(buf) - 1] = 0;
  1106. X                        if(debug_on) fprintf(stderr, "buf {%s}\n", buf);
  1107. X                        if(n > 0)
  1108. X                            xv_set(np->textsw,
  1109. X                                TEXTSW_INSERT_FROM_FILE, buf, NULL);
  1110. X                        }
  1111. X                    }
  1112. X                np = (struct Note *) LLM_next(&sp->note_rt);
  1113. X                }
  1114. X            sp = (struct SubDir *)LLM_next(&subdir_rt);
  1115. X            }
  1116. X        }
  1117. X    if((event_action(event) == ACTION_GO_PAGE_FORWARD || 
  1118. X       event_action(event) == ACTION_GO_PAGE_BACKWARD) && event_is_down(event))
  1119. X        {
  1120. X        if(debug_on) fprintf(stderr, "Got PAGE event\n");
  1121. X        sp = (struct SubDir *)LLM_first(&subdir_rt);
  1122. X        while(sp != NULL && !found)
  1123. X            {
  1124. X            np = (struct Note *) LLM_first(&sp->note_rt);
  1125. X            while(np != NULL && !found)
  1126. X                {
  1127. X                if(np->mapped)
  1128. X                    {
  1129. X                    twin = (Xv_Window) xv_get(np->textsw, OPENWIN_NTH_VIEW, 0);
  1130. X                    if(twin == window)
  1131. X                        {
  1132. X                        Textsw_index t_ndx;
  1133. X                        int  top, bottom;
  1134. X                        int  len;
  1135. X
  1136. X                        found = 1;
  1137. X                        textsw_file_lines_visible(np->textsw, &top, &bottom);
  1138. X                        len = xv_get(np->textsw, TEXTSW_LENGTH);
  1139. X                        if(debug_on)
  1140. X                            fprintf(stderr, "len %d\n", len);
  1141. X                        amount = bottom - top + 1;
  1142. X                        if(event_action(event) == ACTION_GO_PAGE_BACKWARD)
  1143. X                            amount = -(amount);
  1144. X                        if(debug_on)
  1145. X                            fprintf(stderr, "top %d, bot %d\n", top, bottom);
  1146. X                        top += amount;
  1147. X                        if(top < 0) top = 0;
  1148. X                        t_ndx = textsw_index_for_file_line(np->textsw, top);
  1149. X                        if(debug_on)
  1150. X                            fprintf(stderr, "t_ndx %d\n",
  1151. X                                    t_ndx);
  1152. X                        if(t_ndx >= 0)
  1153. X                            {
  1154. X                            xv_set(np->textsw,
  1155. X                                   TEXTSW_INSERTION_POINT, t_ndx,
  1156. X                                   TEXTSW_UPPER_CONTEXT, 0,
  1157. X                                   NULL);
  1158. X                            textsw_normalize_view(np->textsw, t_ndx);
  1159. X                            }
  1160. X                        }
  1161. X                    }
  1162. X                np = (struct Note *) LLM_next(&sp->note_rt);
  1163. X                }
  1164. X            sp = (struct SubDir *)LLM_next(&subdir_rt);
  1165. X            }
  1166. X        }
  1167. X    if(event_id(event) == KBD_DONE)
  1168. X        {
  1169. X        if(debug_on) fprintf(stderr, "Got KBD_DONE event\n");
  1170. X        sp = (struct SubDir *)LLM_first(&subdir_rt);
  1171. X        while(sp != NULL && !found)
  1172. X            {
  1173. X            np = (struct Note *) LLM_first(&sp->note_rt);
  1174. X            while(np != NULL && !found)
  1175. X                {
  1176. X                if(np->mapped)
  1177. X                    {
  1178. X                    twin = (Xv_Window) xv_get(np->textsw, OPENWIN_NTH_VIEW, 0);
  1179. X                    if(twin == window)
  1180. X                        {
  1181. X                        found = 1;
  1182. X                        update(np);
  1183. X                        updateinfo(np, NOFORCE);
  1184. X                        }
  1185. X                    }
  1186. X                np = (struct Note *) LLM_next(&sp->note_rt);
  1187. X                }
  1188. X            sp = (struct SubDir *)LLM_next(&subdir_rt);
  1189. X            }
  1190. X        }
  1191. X    }
  1192. X
  1193. X/*
  1194. X    Handles child process death notification.  Used with the print note
  1195. X    action.
  1196. X*/
  1197. XNotify_value child_death(me, pid, status, rusage)
  1198. X    Notify_client me;
  1199. X    int  pid;
  1200. X    union wait *status;
  1201. X    struct rusage *rusage;
  1202. X    {
  1203. X    if(WIFEXITED(*status))
  1204. X        {
  1205. X        if(debug_on) fprintf(stderr, "Got child death\n");
  1206. X        cmd_printnote(NULL); /* allow next note to go, if any */
  1207. X        return(NOTIFY_DONE);
  1208. X        }
  1209. X    return(NOTIFY_IGNORED);
  1210. X    }
  1211. SHAR_EOF
  1212. chmod 0644 pan3.0/event.c ||
  1213. echo 'restore of pan3.0/event.c failed'
  1214. Wc_c="`wc -c < 'pan3.0/event.c'`"
  1215. test 7221 -eq "$Wc_c" ||
  1216.     echo 'pan3.0/event.c: original size 7221, current size' "$Wc_c"
  1217. fi
  1218. # ============= pan3.0/dnd.c ==============
  1219. if test -f 'pan3.0/dnd.c' -a X"$1" != X"-c"; then
  1220.     echo 'x - skipping pan3.0/dnd.c (File already exists)'
  1221. else
  1222. echo 'x - extracting pan3.0/dnd.c (Text)'
  1223. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/dnd.c' &&
  1224. X/*
  1225. XPost A Note V3.0
  1226. XCopyright (c) 1993, Jeffrey W. Bailey
  1227. XAll rights reserved.
  1228. X
  1229. XPermission is granted to distribute this program in exact, complete
  1230. Xsource form, which includes this copyright notice, as long as no fee
  1231. Xother than media and distribution cost is charged.
  1232. X
  1233. XThis program may not be used in whole, or in part, in any other manner
  1234. Xwithout prior written permission from the author.
  1235. X
  1236. XThis program may not be distributed in modified form without prior
  1237. Xwritten permission from the author.  In other words, patches may be
  1238. Xdistributed, but modified source may not be distributed.
  1239. X
  1240. XIf there are any questions, comments or suggestions, the author may be
  1241. Xcontacted at:
  1242. X
  1243. X    jeff@rd1.interlan.com
  1244. X
  1245. X    or
  1246. X
  1247. X    Jeffrey Bailey
  1248. X    Racal-Datacom, Inc.
  1249. X    Mail Stop E-110
  1250. X    1601 N. Harrison Parkway
  1251. X    Sunrise, FL  33323-2899
  1252. X*/
  1253. X
  1254. X#ifdef PAN_DND
  1255. X
  1256. X#include "pan.h"
  1257. X#include <xview/dragdrop.h>
  1258. X
  1259. Xstruct Note *drag_find();
  1260. X
  1261. Xstatic Xv_Server dnd_server;
  1262. X
  1263. Xdrag_init(server)
  1264. X    Xv_Server server;
  1265. X    {
  1266. X    dnd_server = server;
  1267. X    }
  1268. X
  1269. Xdrag_proc(item, value, event)
  1270. X    Xv_opaque item;
  1271. X    unsigned int value;
  1272. X    Event *event;
  1273. X    {
  1274. X    struct Note *np;
  1275. X    Selection_requestor sel_req;
  1276. X
  1277. X    sel_req = xv_get(item, PANEL_DROP_SEL_REQ);
  1278. X    switch(event_action(event))
  1279. X        {
  1280. X        case ACTION_DRAG_MOVE : /* Do nothing for now, textsw handles it */
  1281. X            break;
  1282. X        case ACTION_DRAG_COPY : /* Do nothing for now, textsw handles it */
  1283. X            break;
  1284. X        case LOC_DRAG :
  1285. X            np = drag_find(item);
  1286. X            if(np)
  1287. X                {
  1288. X                int txt_len;
  1289. X                char *text;
  1290. X                char fname[MAXBUFLEN];
  1291. X                Atom list[3];
  1292. X
  1293. X                /* Set up file name */
  1294. X                makename(fname, np);
  1295. X                if(!np->got_itms)
  1296. X                    {
  1297. X                    np->sel_itm1 = xv_create(np->drag_obj,SELECTION_ITEM,NULL);
  1298. X                    np->sel_itm2 = xv_create(np->drag_obj,SELECTION_ITEM,NULL);
  1299. X                    np->sel_itm3 = xv_create(np->drag_obj,SELECTION_ITEM,NULL);
  1300. X                    np->got_itms = 1;
  1301. X                    }
  1302. X                xv_set(np->sel_itm1,
  1303. X                    SEL_DATA, fname,
  1304. X                    SEL_FORMAT, 8,
  1305. X                    SEL_LENGTH, strlen(fname),
  1306. X                    SEL_TYPE_NAME, "FILE_NAME",
  1307. X                    SEL_COPY, TRUE,
  1308. X                    SEL_OWN, TRUE,
  1309. X                    NULL);
  1310. X                /* Set up for text transfer */
  1311. X                txt_len = xv_get(np->textsw, TEXTSW_LENGTH) + 1;
  1312. X                text = malloc(txt_len);
  1313. X                if(text == NULL)
  1314. X                    {
  1315. X                    fprintf(stderr, "pan:  Memory allocation failure\n");
  1316. X                    cleanup(1);
  1317. X                    }
  1318. X                xv_get(np->textsw, TEXTSW_CONTENTS, 0, text, txt_len);
  1319. X                xv_set(np->sel_itm2,
  1320. X                    SEL_DATA, text,
  1321. X                    SEL_FORMAT, 8,
  1322. X                    SEL_LENGTH, strlen(text),
  1323. X                    SEL_TYPE_NAME, "STRING",
  1324. X                    SEL_COPY, TRUE,
  1325. X                    SEL_OWN, TRUE,
  1326. X                    NULL);
  1327. X                free(text);
  1328. X                list[0] = (Atom) xv_get(dnd_server, SERVER_ATOM, "TARGETS");
  1329. X                list[1] = (Atom) xv_get(dnd_server, SERVER_ATOM, "FILE_NAME");
  1330. X                list[2] = (Atom) xv_get(dnd_server, SERVER_ATOM, "STRING");
  1331. X                xv_set(np->sel_itm3,
  1332. X                    SEL_DATA, list,
  1333. X                    SEL_FORMAT, 32,
  1334. X                    SEL_LENGTH, 3,
  1335. X                    SEL_TYPE_NAME, "TARGETS",
  1336. X                    SEL_COPY, TRUE,
  1337. X                    SEL_OWN, TRUE,
  1338. X                    NULL);
  1339. X                }
  1340. X            break;
  1341. X        default :
  1342. X            printf("unknown event %d\n", event_action(event));
  1343. X            break;
  1344. X        }
  1345. X    return(XV_OK);
  1346. X    }
  1347. X
  1348. Xstruct Note *drag_find(item)
  1349. X    Xv_opaque item;
  1350. X    {
  1351. X    struct SubDir *sp;
  1352. X    struct Note *np;
  1353. X
  1354. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  1355. X    while(sp != NULL)
  1356. X        {
  1357. X        np = (struct Note *) LLM_first(&sp->note_rt);
  1358. X        while(np != NULL)
  1359. X            {
  1360. X            if(np->drag_tgt == item) return(np);
  1361. X            np = (struct Note *) LLM_next(&sp->note_rt);
  1362. X            }
  1363. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  1364. X        }
  1365. X    return(NULL);
  1366. X    }
  1367. X#endif
  1368. SHAR_EOF
  1369. chmod 0644 pan3.0/dnd.c ||
  1370. echo 'restore of pan3.0/dnd.c failed'
  1371. Wc_c="`wc -c < 'pan3.0/dnd.c'`"
  1372. test 4329 -eq "$Wc_c" ||
  1373.     echo 'pan3.0/dnd.c: original size 4329, current size' "$Wc_c"
  1374. fi
  1375. # ============= pan3.0/llm.c ==============
  1376. if test -f 'pan3.0/llm.c' -a X"$1" != X"-c"; then
  1377.     echo 'x - skipping pan3.0/llm.c (File already exists)'
  1378. else
  1379. echo 'x - extracting pan3.0/llm.c (Text)'
  1380. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/llm.c' &&
  1381. X/*
  1382. XPost A Note V3.0
  1383. XCopyright (c) 1993, Jeffrey W. Bailey
  1384. XAll rights reserved.
  1385. X
  1386. XPermission is granted to distribute this program in exact, complete
  1387. Xsource form, which includes this copyright notice, as long as no fee
  1388. Xother than media and distribution cost is charged.
  1389. X
  1390. XThis program may not be used in whole, or in part, in any other manner
  1391. Xwithout prior written permission from the author.
  1392. X
  1393. XThis program may not be distributed in modified form without prior
  1394. Xwritten permission from the author.  In other words, patches may be
  1395. Xdistributed, but modified source may not be distributed.
  1396. X
  1397. XIf there are any questions, comments or suggestions, the author may be
  1398. Xcontacted at:
  1399. X
  1400. X    jeff@rd1.interlan.com
  1401. X
  1402. X    or
  1403. X
  1404. X    Jeffrey Bailey
  1405. X    Racal-Datacom, Inc.
  1406. X    Mail Stop E-110
  1407. X    1601 N. Harrison Parkway
  1408. X    Sunrise, FL  33323-2899
  1409. X*/
  1410. X
  1411. X#include <stdio.h>
  1412. X#include "pan.h"
  1413. X
  1414. XLLM_init(root, size)
  1415. X    struct LLM_root *root;
  1416. X    int  size;
  1417. X    {
  1418. X    if(root == NULL)
  1419. X        {
  1420. X        return(NULL);
  1421. X        }
  1422. X    root->First   = NULL;
  1423. X    root->Last    = NULL;
  1424. X    root->Current = NULL;
  1425. X    root->Size    = size + sizeof(struct LLM_node);
  1426. X    root->Init    = 1;
  1427. X    return(1);
  1428. X    }
  1429. X
  1430. Xchar *LLM_add(root)
  1431. X    struct LLM_root *root;
  1432. X    {
  1433. X    struct LLM_node *hold, *temp;
  1434. X
  1435. X    if(root == NULL)
  1436. X        {
  1437. X        return(NULL);
  1438. X        }
  1439. X    if(root->Init != 1)
  1440. X        {
  1441. X        return(NULL);
  1442. X        }
  1443. X    hold = (struct LLM_node *) malloc(root->Size);
  1444. X    if(hold == NULL)
  1445. X        {
  1446. X        return(NULL);
  1447. X        }
  1448. X    if(root->First == NULL)
  1449. X        {
  1450. X        root->First = hold;
  1451. X        root->Last = hold;
  1452. X        root->Current = hold;
  1453. X        hold->Next = NULL;
  1454. X        hold->Prev = NULL;
  1455. X        }
  1456. X    else
  1457. X        {
  1458. X        temp = root->Last;
  1459. X        temp->Next = hold;
  1460. X        hold->Next = NULL;
  1461. X        hold->Prev = temp;
  1462. X        root->Last = hold;
  1463. X        }
  1464. X    return( (char *) (hold + 1));
  1465. X    }
  1466. X
  1467. Xchar *LLM_first(root)
  1468. X    struct LLM_root *root;
  1469. X    {
  1470. X    if(root == NULL)
  1471. X        {
  1472. X        return(NULL);
  1473. X        }
  1474. X    if(root->Init != 1)
  1475. X        {
  1476. X        return(NULL);
  1477. X        }
  1478. X    if(root->First == NULL)
  1479. X        {
  1480. X        return(NULL);
  1481. X        }
  1482. X    root->Current = root->First;
  1483. X    return((char *) (root->Current + 1));
  1484. X    }
  1485. X
  1486. Xchar *LLM_last(root)
  1487. X    struct LLM_root *root;
  1488. X    {
  1489. X    if(root == NULL)
  1490. X        {
  1491. X        return(NULL);
  1492. X        }
  1493. X    if(root->Init != 1)
  1494. X        {
  1495. X        return(NULL);
  1496. X        }
  1497. X    if(root->Last == NULL)
  1498. X        {
  1499. X        return(NULL);
  1500. X        }
  1501. X    root->Current = root->Last;
  1502. X    return((char *) (root->Current + 1));
  1503. X    }
  1504. X
  1505. Xchar *LLM_next(root)
  1506. X    struct LLM_root *root;
  1507. X    {
  1508. X    if(root == NULL)
  1509. X        {
  1510. X        return(NULL);
  1511. X        }
  1512. X    if(root->Init != 1)
  1513. X        {
  1514. X        return(NULL);
  1515. X        }
  1516. X    if(root->First == NULL)
  1517. X        {
  1518. X        return(NULL);
  1519. X        }
  1520. X    if(root->Current == NULL)
  1521. X        {
  1522. X        return(NULL);
  1523. X        }
  1524. X    if(root->Current == root->Last)
  1525. X        {
  1526. X        return(NULL);
  1527. X        }
  1528. X    root->Current = root->Current->Next;
  1529. X    return((char *) (root->Current + 1));
  1530. X    }
  1531. X
  1532. Xchar *LLM_previous(root)
  1533. X    struct LLM_root *root;
  1534. X    {
  1535. X    if(root == NULL)
  1536. X        {
  1537. X        return(NULL);
  1538. X        }
  1539. X    if(root->Init != 1)
  1540. X        {
  1541. X        return(NULL);
  1542. X        }
  1543. X    if(root->First == NULL)
  1544. X        {
  1545. X        return(NULL);
  1546. X        }
  1547. X    if(root->Current == NULL)
  1548. X        {
  1549. X        return(NULL);
  1550. X        }
  1551. X    if(root->Current == root->First)
  1552. X        {
  1553. X        return(NULL);
  1554. X        }
  1555. X    root->Current = root->Current->Prev;
  1556. X    return((char *) (root->Current + 1));
  1557. X    }
  1558. X
  1559. XLLM_free(root)
  1560. X    struct LLM_root *root;
  1561. X    {
  1562. X    struct LLM_node *temp, *hold;
  1563. X
  1564. X    if(root == NULL)
  1565. X        {
  1566. X        return(NULL);
  1567. X        }
  1568. X    if(root->Init != 1)
  1569. X        {
  1570. X        return(NULL);
  1571. X        }
  1572. X    temp = root->First;
  1573. X    while(temp != NULL)   /* Loop until we're at the end. */
  1574. X        {
  1575. X        hold = temp;
  1576. X        temp = temp->Next;
  1577. X        (void)free((char *)hold);       /* Free up our current node. */
  1578. X        }
  1579. X    root->First   = NULL;
  1580. X    root->Last    = NULL;
  1581. X    root->Current = NULL;
  1582. X    return(1);
  1583. X    }
  1584. X
  1585. XLLM_delete(root, node)
  1586. X    struct LLM_root *root;
  1587. X    char *node;
  1588. X    {
  1589. X    struct LLM_node *temp;
  1590. X
  1591. X    if(root == NULL)
  1592. X        {
  1593. X        return(NULL);
  1594. X        }
  1595. X    if(root->Init != 1)
  1596. X        {
  1597. X        return(NULL);
  1598. X        }
  1599. X    if(node == NULL)
  1600. X        {
  1601. X        return(NULL);
  1602. X        }
  1603. X    temp = (struct LLM_node *) node;
  1604. X    temp--;
  1605. X
  1606. X    if(temp->Prev != NULL)
  1607. X        temp->Prev->Next = temp->Next;
  1608. X    else
  1609. X        root->First = temp->Next;
  1610. X
  1611. X    if(temp->Next != NULL)
  1612. X        temp->Next->Prev = temp->Prev;
  1613. X    else
  1614. X        root->Last = temp->Prev;
  1615. X
  1616. X    if(temp == root->Current) root->Current = root->First;
  1617. X
  1618. X    (void)free((char *)temp);
  1619. X    return(1);
  1620. X    }
  1621. X
  1622. Xchar *LLM_insert(root, node)
  1623. X    struct LLM_root *root;
  1624. X    char *node;
  1625. X    {
  1626. X    struct LLM_node *temp, *hold;
  1627. X
  1628. X    if(root == NULL)
  1629. X        {
  1630. X        return(NULL);
  1631. X        }
  1632. X    if(root->Init != 1)
  1633. X        {
  1634. X        return(NULL);
  1635. X        }
  1636. X    if(node == NULL)
  1637. X        {
  1638. X        return(NULL);
  1639. X        }
  1640. X    temp = (struct LLM_node *) node;
  1641. X    temp--;
  1642. X    hold = (struct LLM_node *) malloc(root->Size);
  1643. X    if(hold == NULL)
  1644. X        {
  1645. X        return(NULL);
  1646. X        }
  1647. X    if(temp == root->First)
  1648. X        {
  1649. X        hold->Next = root->First;
  1650. X        hold->Next->Prev = hold;
  1651. X        root->First = hold;
  1652. X        hold->Prev = NULL;
  1653. X        return( (char *) (hold + 1));
  1654. X        }
  1655. X    hold->Next = temp;
  1656. X    hold->Prev = temp->Prev;
  1657. X    temp->Prev = hold;
  1658. X    hold->Prev->Next = hold;
  1659. X
  1660. X    return( (char *) (hold + 1));
  1661. X    }
  1662. X
  1663. XLLM_position(root, node)
  1664. X    struct LLM_root *root;
  1665. X    char *node;
  1666. X    {
  1667. X    struct LLM_node *temp;
  1668. X
  1669. X    if(root == NULL)
  1670. X        {
  1671. X        return(NULL);
  1672. X        }
  1673. X    if(node == NULL)
  1674. X        {
  1675. X        return(NULL);
  1676. X        }
  1677. X    if(root->Init != 1)
  1678. X        {
  1679. X        return(NULL);
  1680. X        }
  1681. X    temp = (struct LLM_node *) node;
  1682. X    temp--;
  1683. X    root->Current = temp;
  1684. X    return(1);
  1685. X    }
  1686. X
  1687. Xchar *LLM_current(root)
  1688. X    struct LLM_root *root;
  1689. X    {
  1690. X    if(root == NULL)
  1691. X        {
  1692. X        return(NULL);
  1693. X        }
  1694. X    if(root->Init != 1)
  1695. X        {
  1696. X        return(NULL);
  1697. X        }
  1698. X    if(root->Current == NULL)
  1699. X        {
  1700. X        return(NULL);
  1701. X        }
  1702. X    return((char *) (root->Current + 1));
  1703. X    }
  1704. X
  1705. XLLM_unlink(root, node)
  1706. X    struct LLM_root *root;
  1707. X    char *node;
  1708. X    {
  1709. X    struct LLM_node *temp;
  1710. X
  1711. X    if(root == NULL)
  1712. X        {
  1713. X        return(NULL);
  1714. X        }
  1715. X    if(root->Init != 1)
  1716. X        {
  1717. X        return(NULL);
  1718. X        }
  1719. X    if(node == NULL)
  1720. X        {
  1721. X        return(NULL);
  1722. X        }
  1723. X    temp = (struct LLM_node *) node;
  1724. X    temp--;
  1725. X
  1726. X    if(temp->Prev != NULL)
  1727. X        temp->Prev->Next = temp->Next;
  1728. X    else
  1729. X        root->First = temp->Next;
  1730. X
  1731. X    if(temp->Next != NULL)
  1732. X        temp->Next->Prev = temp->Prev;
  1733. X    else
  1734. X        root->Last = temp->Prev;
  1735. X
  1736. X    if(temp == root->Current) root->Current = root->First;
  1737. X
  1738. X    return(1);
  1739. X    }
  1740. X
  1741. XLLM_link(root, node, newnode)
  1742. X    struct LLM_root *root;
  1743. X    char *node;
  1744. X    char *newnode;
  1745. X    {
  1746. X    struct LLM_node *temp, *hold;
  1747. X
  1748. X    if(root == NULL)
  1749. X        {
  1750. X        return(NULL);
  1751. X        }
  1752. X    if(root->Init != 1)
  1753. X        {
  1754. X        return(NULL);
  1755. X        }
  1756. X    if(newnode == NULL)
  1757. X        {
  1758. X        return(NULL);
  1759. X        }
  1760. X    hold = (struct LLM_node *) newnode;
  1761. X    hold--;
  1762. X    if(node == NULL && root->First != NULL) /* link at end */
  1763. X        {
  1764. X        temp = root->Last;
  1765. X        temp->Next = hold;
  1766. X        hold->Next = NULL;
  1767. X        hold->Prev = temp;
  1768. X        root->Last = hold;
  1769. X        return(1);
  1770. X        }
  1771. X    if(node == NULL && root->First == NULL) /* first node */
  1772. X        {
  1773. X        root->First = hold;
  1774. X        root->Last = hold;
  1775. X        root->Current = hold;
  1776. X        hold->Next = NULL;
  1777. X        hold->Prev = NULL;
  1778. X        return(1);
  1779. X        }
  1780. X    temp = (struct LLM_node *) node;
  1781. X    temp--;
  1782. X    if(temp == root->First)
  1783. X        {
  1784. X        hold->Next = root->First;
  1785. X        hold->Next->Prev = hold;
  1786. X        root->First = hold;
  1787. X        hold->Prev = NULL;
  1788. X        return(1);
  1789. X        }
  1790. X    hold->Next = temp;
  1791. X    hold->Prev = temp->Prev;
  1792. X    temp->Prev = hold;
  1793. X    hold->Prev->Next = hold;
  1794. X
  1795. X    return(1);
  1796. X    }
  1797. SHAR_EOF
  1798. chmod 0644 pan3.0/llm.c ||
  1799. echo 'restore of pan3.0/llm.c failed'
  1800. Wc_c="`wc -c < 'pan3.0/llm.c'`"
  1801. test 8148 -eq "$Wc_c" ||
  1802.     echo 'pan3.0/llm.c: original size 8148, current size' "$Wc_c"
  1803. fi
  1804. true || echo 'restore of pan3.0/README failed'
  1805. echo End of part 1, continue with part 2
  1806. exit 0
  1807.  
  1808. --
  1809. Jeffrey Bailey
  1810. Racal-Datacom, Inc.
  1811. Mail Stop E-110
  1812. 1601 N. Harrison Parkway                  INET : jeff@rd1.interlan.com
  1813. Sunrise, FL 33323-2899                    UUCP : ...uflorida!novavax!rd1!jeff
  1814.  
  1815. exit 0 # Just in case...
  1816. -- 
  1817.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1818. \X/  Amiga - The only way to fly! |    sources-x@sterling.com
  1819.  "It's intuitively obvious to the |
  1820.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1821.