home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume21 / pan / part03 < prev    next >
Encoding:
Text File  |  1993-11-08  |  42.2 KB  |  1,374 lines

  1. Newsgroups: comp.sources.x
  2. From: jeff@tasslehoff.interlan.com (Jeff Bailey)
  3. Subject: v21i039:  pan - A post a note program, Part03/06
  4. Message-ID: <1993Nov9.000711.10838@sparky.sterling.com>
  5. X-Md4-Signature: d738080ee283dab4ed83b9b13a36e2b8
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Tue, 9 Nov 1993 00:07:11 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: jeff@tasslehoff.interlan.com (Jeff Bailey)
  12. Posting-number: Volume 21, Issue 39
  13. Archive-name: pan/part03
  14. Environment: X11, OpenLook, XView
  15. Supersedes: pan: Volume 16, Issue 137-142
  16.  
  17. ---- Cut Here and feed the following to sh ----
  18. #!/bin/sh
  19. # This is part 03 of a multipart archive
  20. # ============= pan3.0/hidexp.c ==============
  21. if test ! -d 'pan3.0'; then
  22.     echo 'x - creating directory pan3.0'
  23.     mkdir 'pan3.0'
  24. fi
  25. if test -f 'pan3.0/hidexp.c' -a X"$1" != X"-c"; then
  26.     echo 'x - skipping pan3.0/hidexp.c (File already exists)'
  27. else
  28. echo 'x - extracting pan3.0/hidexp.c (Text)'
  29. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/hidexp.c' &&
  30. X/*
  31. XPost A Note V3.0
  32. XCopyright (c) 1993, Jeffrey W. Bailey
  33. XAll rights reserved.
  34. X
  35. XPermission is granted to distribute this program in exact, complete
  36. Xsource form, which includes this copyright notice, as long as no fee
  37. Xother than media and distribution cost is charged.
  38. X
  39. XThis program may not be used in whole, or in part, in any other manner
  40. Xwithout prior written permission from the author.
  41. X
  42. XThis program may not be distributed in modified form without prior
  43. Xwritten permission from the author.  In other words, patches may be
  44. Xdistributed, but modified source may not be distributed.
  45. X
  46. XIf there are any questions, comments or suggestions, the author may be
  47. Xcontacted at:
  48. X
  49. X    jeff@rd1.interlan.com
  50. X
  51. X    or
  52. X
  53. X    Jeffrey Bailey
  54. X    Racal-Datacom, Inc.
  55. X    Mail Stop E-110
  56. X    1601 N. Harrison Parkway
  57. X    Sunrise, FL  33323-2899
  58. X*/
  59. X
  60. X#include "pan.h"
  61. X
  62. Xextern int errno;
  63. Xextern char *sys_errlist[];
  64. X
  65. X/*
  66. X    Routine called when hide notes button is selected.  Hides ALL notes.
  67. X*/
  68. Xhideall()
  69. X    {
  70. X    struct SubDir *sp;
  71. X    struct Note *np;
  72. X
  73. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  74. X    while(sp != NULL)
  75. X        {
  76. X        np = (struct Note *) LLM_first(&sp->note_rt);
  77. X        while(np != NULL)
  78. X            {
  79. X            if(np->mapped && np->state != Hidden)
  80. X                {
  81. X                w_hidenote(np);
  82. X                }
  83. X            np = (struct Note *) LLM_next(&sp->note_rt);
  84. X            }
  85. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  86. X        }
  87. X    refresh_popups();
  88. X    }
  89. X
  90. X/*
  91. X    Routine called when expose notes button menu selection All is selected.
  92. X    Exposes ALL notes.
  93. X*/
  94. Xexposeall()
  95. X    {
  96. X    int  count;
  97. X    struct SubDir *sp;
  98. X    struct Note *np;
  99. X
  100. X    /* Count how many will be exposed */
  101. X    count = 0;
  102. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  103. X    while(sp != NULL)
  104. X        {
  105. X        np = (struct Note *) LLM_first(&sp->note_rt);
  106. X        while(np != NULL)
  107. X            {
  108. X            if(np->state != Visible)
  109. X                {
  110. X                if(!np->mapped)
  111. X                    {
  112. X                    count++;
  113. X                    }
  114. X                }
  115. X            np = (struct Note *) LLM_next(&sp->note_rt);
  116. X            }
  117. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  118. X        }
  119. X    if(windowmax != -1 && count >= windowmax)
  120. X        {
  121. X        char buf[1024];
  122. X
  123. X        sprintf(buf, "This action will expose %d notes!", count);
  124. X        if(notice_prompt(main_frame, NULL,
  125. X                     NOTICE_MESSAGE_STRINGS, 
  126. X                         buf,
  127. X                         "Proceed?",
  128. X                         NULL,
  129. X                     NOTICE_BUTTON_YES, "Yes",
  130. X                     NOTICE_BUTTON_NO, "No",
  131. X                     NOTICE_NO_BEEPING, noticenobeep,
  132. X                     NULL) == NOTICE_NO)
  133. X            {
  134. X            return;
  135. X            }
  136. X        }
  137. X
  138. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  139. X    while(sp != NULL)
  140. X        {
  141. X        np = (struct Note *) LLM_first(&sp->note_rt);
  142. X        while(np != NULL)
  143. X            {
  144. X            if(np->state != Visible)
  145. X                {
  146. X                if(!np->mapped)
  147. X                    {
  148. X                    w_exposenote(np, ERRONDISPLAY);
  149. X                    }
  150. X                }
  151. X            np = (struct Note *) LLM_next(&sp->note_rt);
  152. X            }
  153. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  154. X        }
  155. X    refresh_popups();
  156. X    }
  157. X
  158. X/*
  159. X    Routine called when expose notes button menu selection All is selected
  160. X    from within a folder.  Exposes ALL notes in the folder.
  161. X*/
  162. Xexposefolder(sp)
  163. X    struct SubDir *sp;
  164. X    {
  165. X    int  count;
  166. X    struct Note *np;
  167. X
  168. X    /* Count how many will be exposed */
  169. X    count = 0;
  170. X    np = (struct Note *) LLM_first(&sp->note_rt);
  171. X    while(np != NULL)
  172. X        {
  173. X        if(np->state != Visible)
  174. X            {
  175. X            if(!np->mapped)
  176. X                {
  177. X                count++;
  178. X                }
  179. X            }
  180. X        np = (struct Note *) LLM_next(&sp->note_rt);
  181. X        }
  182. X    if(windowmax != -1 && count >= windowmax)
  183. X        {
  184. X        char buf[1024];
  185. X        sprintf(buf, "This action will expose %d notes!", count);
  186. X        if(notice_prompt(main_frame, NULL,
  187. X                     NOTICE_MESSAGE_STRINGS,
  188. X                         buf,
  189. X                         "Proceed?",
  190. X                         NULL,
  191. X                     NOTICE_BUTTON_YES, "Yes",
  192. X                     NOTICE_BUTTON_NO, "No",
  193. X                     NOTICE_NO_BEEPING, noticenobeep,
  194. X                     NULL) == NOTICE_NO)
  195. X            {
  196. X            return;
  197. X            }
  198. X        }
  199. X
  200. X    np = (struct Note *) LLM_first(&sp->note_rt);
  201. X    while(np != NULL)
  202. X        {
  203. X        if(np->state != Visible)
  204. X            {
  205. X            if(!np->mapped)
  206. X                {
  207. X                w_exposenote(np, ERRONDISPLAY);
  208. X                }
  209. X            }
  210. X        np = (struct Note *) LLM_next(&sp->note_rt);
  211. X        }
  212. X    refresh_popups();
  213. X    }
  214. X
  215. X/*
  216. X    Routine called when the hide button on a note is selected.  Hides the
  217. X    selected note.
  218. X*/
  219. Xhidenote(item, event)
  220. X    Panel_item item;
  221. X    Event *event;
  222. X    {
  223. X    struct Note *np;
  224. X
  225. X    np = (struct Note *) xv_get(item, PANEL_CLIENT_DATA);
  226. X
  227. X    w_hidenote(np);
  228. X
  229. X    refresh_popups();
  230. X    }
  231. X
  232. X/*
  233. X    Called when the window border menu Quit item is selected on a note.
  234. X    Veils the note.
  235. X*/
  236. Xdismissed(frame)
  237. X    Frame frame;
  238. X    {
  239. X    int  found = 0;
  240. X    struct SubDir *sp;
  241. X    struct Note *np;
  242. X
  243. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  244. X    while(sp != NULL && !found)
  245. X        {
  246. X        np = (struct Note *) LLM_first(&sp->note_rt);
  247. X        while(np != NULL && !found)
  248. X            {
  249. X            if(np->mapped && np->frame == frame)
  250. X                {
  251. X                w_veilnote(np);
  252. X                found = 1;
  253. X                }
  254. X            np = (struct Note *) LLM_next(&sp->note_rt);
  255. X            }
  256. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  257. X        }
  258. X    refresh_popups();
  259. X    }
  260. X
  261. X/*
  262. X    Called when an expose menu item is chosen.  Figures out which note
  263. X    to expose, then does it.
  264. X*/
  265. Xexposemenu(menu, mitem)
  266. X    Menu menu;
  267. X    Menu_item mitem;
  268. X    {
  269. X    struct SubDir *sp;
  270. X    struct Note *np;
  271. X    char *ptext;
  272. X    Menu_item pullright;
  273. X
  274. X    np = (struct Note *)xv_get(mitem, MENU_CLIENT_DATA);
  275. X    if(np == NULL &&
  276. X       strcmp((char *)xv_get(mitem, MENU_STRING), CHOICE_ALL) == 0)
  277. X        {
  278. X        exposeall();
  279. X        }
  280. X    else if((long) np == 0xFFFFFFFF &&
  281. X       strcmp((char *)xv_get(mitem, MENU_STRING), CHOICE_ALL) == 0)
  282. X        {
  283. X        pullright = (Menu_item) xv_get(menu, MENU_PARENT);
  284. X        ptext = (char *)xv_get(pullright, MENU_STRING);
  285. X        sp = (struct SubDir *) LLM_first(&subdir_rt);
  286. X        while(sp != NULL)
  287. X            {
  288. X            if(strcmp(sp->subdir, ptext) == 0)
  289. X                exposefolder(sp);
  290. X            sp = (struct SubDir *) LLM_next(&subdir_rt);
  291. X            }
  292. X        }
  293. X    else
  294. X        {
  295. X        if(np == NULL)
  296. X            {
  297. X            notice_prompt(main_frame, NULL,
  298. X                NOTICE_MESSAGE_STRINGS,
  299. X                    "No notes to expose",
  300. X                    NULL,
  301. X                NOTICE_BUTTON_YES, "Acknowledge",
  302. X                NOTICE_NO_BEEPING, noticenobeep,
  303. X                NULL);
  304. X            return;
  305. X            }
  306. X        if(!np->mapped)
  307. X            {
  308. X            w_exposenote(np, ERRONDISPLAY);
  309. X            }
  310. X        refresh_popups();
  311. X        }
  312. X    }
  313. X
  314. X/* refresh any pop up windows as necessary */
  315. Xrefresh_popups()
  316. X    {
  317. X    refresh_move();
  318. X    refresh_destroy();
  319. X    refresh_search();
  320. X    }
  321. SHAR_EOF
  322. chmod 0644 pan3.0/hidexp.c ||
  323. echo 'restore of pan3.0/hidexp.c failed'
  324. Wc_c="`wc -c < 'pan3.0/hidexp.c'`"
  325. test 7422 -eq "$Wc_c" ||
  326.     echo 'pan3.0/hidexp.c: original size 7422, current size' "$Wc_c"
  327. fi
  328. # ============= pan3.0/pan.man ==============
  329. if test -f 'pan3.0/pan.man' -a X"$1" != X"-c"; then
  330.     echo 'x - skipping pan3.0/pan.man (File already exists)'
  331. else
  332. echo 'x - extracting pan3.0/pan.man (Text)'
  333. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/pan.man' &&
  334. X.TH pan l "July 2, 1991"
  335. X.SH NAME
  336. Xpan \- Post A Note Open Look program
  337. X.SH SYNTAX
  338. X\fBpan\fP [args...]
  339. X.SH DESCRIPTION
  340. XThe \fBpan\fP program keeps track of multiple text notes.  Each note
  341. Xhas its own window and associated attributes.  The position, size, and
  342. Xvisibility of each note is maintained across invocations along with the
  343. Xnote text.
  344. X.LP
  345. XA note may be in one of three states: Visible, Hidden, or Veiled.
  346. XA visible note has a window mapped to the display.  A hidden note is not
  347. Xmapped to the display.  A veiled note is a note which has been dismissed
  348. Xvia the window manager's window menu.  It is not mapped, but the permanent
  349. Xstate is still "Visible".  This feature allows a note to be unmapped, but
  350. Xmade visible automatically upon the next invocation of \fBpan\fP.  A veiled
  351. Xnote may be exposed just like a hidden note.
  352. X.LP
  353. XThe \fBpan\fP program accepts all standard Open Look command line arguments.
  354. X.LP
  355. XIn addition, \fBpan\fP accepts the following command line arguments:
  356. X.LP
  357. X\fB-d<directory>\fP
  358. X.RS
  359. XSet the initial pan directory.  This overrides the X resource
  360. X\fBinitialDirectory\fP.
  361. X.RE
  362. X.LP
  363. XAll notes are automatically saved to disk when the pointer moves outside
  364. Xof the note window, or upon loss of the keyboard focus.  Note that saving
  365. Xto disk is only done if changes have been made.
  366. X.LP
  367. XThe \fBpan\fP program has one base window from which many functions may be
  368. Xaccessed.  Each note consists of a separate window which may or may not be
  369. Xmapped to the display.  The base window has the following buttons:
  370. X.LP
  371. X\fBNew Note\fP
  372. X.RS
  373. XClicking on this button with mouse button 1 causes a new blank note to
  374. Xbe created and made visible.  This new note is created in the default folder.
  375. X.LP
  376. XClicking on this button and holding with mouse button 3 will bring up a menu
  377. Xof folders in which a new note may be created.
  378. X.RE
  379. X.LP
  380. X\fBHide Notes\fP
  381. X.RS
  382. XClicking on this button causes all visible notes to be unmapped from the 
  383. Xdisplay.
  384. X.RE
  385. X.LP
  386. X\fBExpose Notes\fP
  387. X.RS
  388. XThis button has a menu attached to it.  Clicking with mouse button 1
  389. Xselects the default action.  Pressing mouse button 3 brings up
  390. Xa menu.  The menu items are:
  391. X.LP
  392. X\fBAll\fP
  393. X.RS
  394. XExpose (make visible) all notes.  This option can be limited in scope via the
  395. X\fBwindowMax\fP X resource.  This is the default action.
  396. X.RE
  397. X.LP
  398. X\fB<Folders>\fP
  399. X.RS
  400. XAn additional entry for each folder is displayed.  By moving the pointer right,
  401. Xa menu of all hidden notes in that folder is displayed.  The first entry is
  402. Xthe item "All".  Selecting this will expose all notes in the folder.  This
  403. Xaction is also limited by the \fBwindowMax\fP X resource. The
  404. Xremaining items are individual notes within the folder.
  405. X.RE
  406. X.RE
  407. X.LP
  408. X\fBAction\fP
  409. X.RS
  410. XThis button has a menu attached to it.  Clicking with mouse button 1
  411. Xselects the default action.  Pressing mouse button 3 brings up
  412. Xa menu.  The menu items are:
  413. X.LP
  414. X\fBCreate Folder...\fP
  415. X.RS
  416. XSelecting this menu item brings up another window that allows a folder
  417. Xname to be entered.  When this is done, \fBpan\fP will create a new
  418. Xfolder.  This is the default menu item.  This may be changed with the
  419. X\fBactionDefault\fP X resource.
  420. X.RE
  421. X.LP
  422. X\fBMove Note...\fP
  423. X.RS
  424. XThis menu item will bring up a window with 3 lists.  The first list is the
  425. Xfolder \fBfrom\fP which to move notes.  The second list is the folder
  426. X\fBto\fP which notes will be moved.  The third list is the list of notes
  427. Xin the source folder.  Select the appropriate source and destination folders,
  428. Xthen select the note or notes to be moved and click on the "Apply" button.  The
  429. Xselected notes will be moved to the destination folder.
  430. X.RE
  431. X.LP
  432. X\fBPrint Note\fP
  433. X.RS
  434. XThis menu item will bring up a menu of all folders, similar to the \fBExpose\fP
  435. Xmenu.  
  436. XSliding the pointer to the right while holding
  437. Xmouse button 3 down reveals a list of all notes in the selected folder.
  438. XHighlight the one
  439. Xto be printed and release the mouse button to cause the note to be printed.
  440. X.RE
  441. X.LP
  442. X\fBDestroy Folder...\fP
  443. X.RS
  444. XThis menu item will pop up a window with a list of all available folders.
  445. XSelecting a folder and then clicking the "Apply" button will cause all
  446. Xnotes in that folder to be destroyed.  The folder itself will then be
  447. Xdestroyed.  \fIThis is an extremely destructive function and should be
  448. Xused with great care.\fP
  449. X.RE
  450. X.LP
  451. X\fBQuit\fB
  452. X.RS
  453. XCause \fBpan\fP to exit.
  454. X.RE
  455. X.RE
  456. X.LP
  457. X\fBSearch:\fP
  458. X.RS
  459. XThis is a text entry field.  It can be used to enter a regular expression.
  460. XUpon pressing the \fIreturn\fP key, \fBpan\fP will search for a note with
  461. Xa title matching the RE and expose it if there is a single match.  If more
  462. Xthan one note matches, a list window will be displayed allowing multiple
  463. Xselections of notes to expose.
  464. X.RE
  465. X.LP
  466. XIn addition, there is an abbreviated menu button to the right of the
  467. X\fBSearch:\fP text entry field.  Using the X resource \fBsearchMenu\fP,
  468. Xa list of regular expressions may be specified from which to build a
  469. Xmenu.  This allows shortcut exposures without typing in the text entry
  470. Xfield.  Using this menu does not destroy the contents of the text entry
  471. Xfield.  The default menu has only 1 regular expression: '.'.
  472. X.SH NOTE WINDOWS
  473. XEach note window contains the following items:
  474. X.LP
  475. X\fBTitle\fP
  476. X.RS
  477. XThis is a scrolling text entry item.  A note title may be entered here.  \fBThe
  478. Xtitle does not become active until the return key is pressed.\fP
  479. X.RE
  480. X.LP
  481. X\fBHide\fP
  482. X.RS
  483. XClicking on this button will cause this note to be hidden.
  484. X.RE
  485. X.LP
  486. X\fBAction\fP
  487. X.RS
  488. XThis is a menu button.  Clicking on it with mouse button 1 will cause the
  489. Xdefault menu item to be selected.  Clicking on it with mouse button 3 will
  490. Xdisplay a menu with the following items:
  491. X.LP
  492. X\fBPrint\fP
  493. X.RS
  494. XThis item will cause the note to be printed.
  495. X.RE
  496. X.LP
  497. X\fBWidth <n>\fP
  498. X.RS
  499. XThis item will cause the note's width to expand so the text subwindow can
  500. Xaccommodate at least \fB<n>\fP characters before wrapping.  See the X
  501. Xresource \fBsetWidth\fP for a more detailed explanation.
  502. X.RE
  503. X.LP
  504. X\fBDestroy\fP
  505. X.RS
  506. XThis menu item will cause this note to be destroyed.  There is
  507. Xno way to recover a note after this action is taken.
  508. X.RE
  509. X.RE
  510. X.SH RESOURCES
  511. XThe \fBpan\fP program will query the X server for resource information.
  512. XThe following items of information are examined by \fBpan\fP:
  513. X.LP
  514. X\fBpan.initialDirectory (string)\fP
  515. X.RS
  516. XThis resource may be defined with a directory name.  \fBPan\fP will read
  517. Xthis directory for notes upon startup instead of reading the default directory.
  518. XNote that the \fB-d\fP command line argument can override this.
  519. X.LP
  520. XThe current default directory is "$HOME/.pan".  It will be created 
  521. Xautomatically by \fBpan\fP if necessary.  Note that a directory other than the
  522. Xdefault will \fBnot\fP be automatically created.
  523. X.RE
  524. X.LP
  525. X\fBpan.printCommand (string)\fP
  526. X.RS
  527. XThis resource may be defined to be a command that will cause a note to
  528. Xbe printed.
  529. X.LP
  530. XThe current default command is "/usr/ucb/lpr $FILE".  Another command, including
  531. Xflags may be substituted.  Two special variables are available:  $FILE, and 
  532. X$NOTETITLE.  The first will contain the full path and file name of the note
  533. Xselected to be printed.  The second will contain the full title of the note
  534. Xselected to be printed.  If a postscript printer is available, a nicely
  535. Xformatted printout may be obtained by using 'mp -o -s "$NOTETITLE" $FILE | lpr'.
  536. XDon't include the single quotes in the .Xdefaults file.  I use them for
  537. Xemphasis only.
  538. X.RE
  539. X.LP
  540. X\fBpan.confirmDestroy (boolean)\fP
  541. X.RS
  542. XThis resource controls whether \fBpan\fP will display a confirmation notice
  543. Xwhen the destroy button on a note is selected.
  544. X.LP
  545. XThe default value is False.
  546. X.RE
  547. X.LP
  548. X\fBpan.noticeBeep (boolean)\fP
  549. X.RS
  550. XThis resource controls whether notices displayed by \fBpan\fP will be 
  551. Xaccompanied by an audible beep.
  552. X.LP
  553. XThe current default is True.
  554. X.RE
  555. X.LP
  556. X\fBpan.iconTransparent (boolean)\fP
  557. X.RS
  558. XThis resource controls whether or not the icons used by \fBpan\fP have
  559. Xa transparent background.  It is retained for backwards compatibility.
  560. XIcon masks are now used, so this attribute currently has no effect.
  561. X.LP
  562. XThe default value is False.
  563. X.RE
  564. X.LP
  565. X\fBpan.folderOrder (string)\fP
  566. X.RS
  567. XThis is a string resource.  It consists of a comma separated list of folder
  568. Xnames.  This resource allows the order in which folders appear in the menus
  569. Xto be specified.  Any folders not explicitly mentioned are added to the
  570. Xend of the list in the order in which they are encountered when reading
  571. Xthe directory.
  572. X.LP
  573. XThe default value is "Miscellaneous".
  574. X.RE
  575. X.LP
  576. X\fBpan.defaultSearch (string)\fP
  577. X.RS
  578. XThis resource allows the specification of a default search string to appear
  579. Xin the "Search:" field in the base window.
  580. X.LP
  581. XThe default value is "".
  582. X.RE
  583. X.LP
  584. X\fBpan.folderInTitle (boolean)\fP
  585. X.RS
  586. XThis resource specifies whether or not to display a note's folder name along
  587. Xwith the note title in the window manager's title bar.
  588. X.LP
  589. XThe default is False.
  590. X.RE
  591. X.LP
  592. X\fBpan.textFont (string)\fP
  593. X.RS
  594. XThis resource allows the specification of an alternate font to be used in
  595. Xthe text subwindow.  I highly recommend using a fixed with font in this
  596. Xresource if the \fBWidth\fP menu item on a note is to be used.  I have found
  597. Xthat a good font is "8x13".  (Quotes for emphasis only.)
  598. X.LP
  599. XThe default font if this resource is not set is chosen by the XView toolkit,
  600. Xand depends upon the -scale option.
  601. X.RE
  602. X.LP
  603. X\fBpan.windowMax (integer)\fP
  604. X.RS
  605. XThis resource limits the number of windows that may be exposed as the result
  606. Xof a single expose action.  If the number would be exceeded, and the expose
  607. Xaction is interactive, a confirmation notice is posted before \fBpan\fP
  608. Xwill continue the operation.  If the operation is from the pan control
  609. Xlanguage, \fBwindowMax\fP notes are exposed, then the action is halted
  610. Xsilently.
  611. X.LP
  612. XUse a value of -1 to disable this feature.  A value of 0 will cause
  613. Xconfirmation to occur for every expose action.  Any other value will allow
  614. Xthat many notes to be exposed before confirmation is requested.
  615. X.LP
  616. XThe default value is 20.
  617. X.RE
  618. X.LP
  619. X\fBpan.actionDefault (string)\fP
  620. X.RS
  621. XThis resource allows the default menu item on the \fBAction\fP menu button
  622. Xon the main \fBpan\fP window to be chosen.  This option is case sensitive
  623. Xand the value must be spelled exactly as seen in the menu including the
  624. Xperiods.
  625. X.LP
  626. XThe default value is "Create Folder...". (Quotes for emphasis only.)
  627. X.RE
  628. X.LP
  629. X\fBpan.menuTextLength (integer)\fP
  630. X.RS
  631. XThis option specifies the maximum number of characters of the note titles that
  632. Xwill appear in the \fBExpose Notes\fP and \fBPrint Note\fP menus.  This allows
  633. Xfor more or less of a title to be displayed in a menu.  Note that by default
  634. Xthe font used in menus is proportional.  Because of this, \fBpan\fP will 
  635. Xcalculate the pixel width of a string of \fBmenuTextLength\fP characters from
  636. Xthe average character width, then build a specific menu item adding or
  637. Xsubtracting characters to get as close to the calculated value as possible.
  638. XThis allows some titles to squeeze in a few extra characters, and generally
  639. Xmakes the menu items line up better.
  640. X.LP
  641. XThe default value is 20.
  642. X.RE
  643. X.LP
  644. X\fBpan.setWidth (integer)\fP
  645. X.RS
  646. XThis resource specifies the character width that a note window will be set
  647. Xto when the note's \fBWidth <n>\fP menu item is chosen.  Note that this
  648. Xworks best if a fixed width font has been specified with \fBtextFont\fP.  The
  649. Xdefault text subwindow font size is reported inaccurately by XView, 
  650. X(especially when -scale is used), making it difficult to accurately calculate
  651. Xa proper window size.  Even with a fixed width font, the window size is only
  652. Xapproximate because XView provides no way that I can find to determine the
  653. Xscrollbar width, or the window border widths.  See \fBtopMargin\fP for a
  654. Xmore detailed explanation of window border settings.
  655. X.RE
  656. X.LP
  657. X\fBpan.logging (boolean)\fP
  658. X.RS
  659. XThis resource is used to prevent \fBpan\fP from creating a log file during
  660. Xcommand execution.  See the section on \fBControl Language\fP for more
  661. Xinformation.
  662. X.LP
  663. XThe default is True.
  664. X.RE
  665. X.LP
  666. X\fBpan.topMargin (integer)\fP
  667. X.br
  668. X\fBpan.bottomMargin (integer)\fP
  669. X.br
  670. X\fBpan.leftMargin (integer)\fP
  671. X.br
  672. X\fBpan.rightMargin (integer)\fP
  673. X.RS
  674. XThese resources are used to indicate the pixel widths of the window manager's
  675. Xframe that is placed around pan windows.  The defaults are set to reasonable
  676. Xvalues for \fBolwm\fP and \fBolvwm\fP.  If another window manager is used,
  677. Xset these resources to appropriate values.  Failure to do this can cause
  678. X\fBpan\fP to incorrectly calculate window sizes and widget positions.
  679. X.RE
  680. X.LP
  681. X\fBpan.checkInterval (integer)\fP
  682. X.RS
  683. XThis resource is used to control how often the control language file is
  684. Xchecked for new commands.  The value should be specified in seconds.
  685. X.LP
  686. XThe default value is 60 seconds.
  687. X.RE
  688. X.LP
  689. X\fBpan.searchMenu (string)\fP
  690. X.RS
  691. XThis resource may be used to specify a list of note titles that will be
  692. Xused to build the shortcut search menu.  The items must be space or comma
  693. Xseparated, and both single and double quotes are supported in case a title
  694. Xcontains whitespace.
  695. X.LP
  696. XThe default value is ".".
  697. X.RE
  698. X.LP
  699. X\fBpan.noteWidth (integer)\fP
  700. X.br
  701. X\fBpan.noteHeight (integer)\fP
  702. X.br
  703. X.RS
  704. XThese resources are used to indicate a preferred width and height for a newly
  705. Xcreated note.  By default, \fBpan\fP tries to create a note as small as
  706. Xpossible, while making sure that all buttons and text items are visible.  This
  707. Xmay be overridden by specifying \fBboth\fP resources.  If only one is 
  708. Xspecified, it is ignored.  The values for both are specified in terms of
  709. Xpixels.  Note that if these resources are used, \fBpan\fP will not be
  710. Xable to adjust automatically to the use of the -scale option.
  711. X.LP
  712. XThe default value for both is -1 which means \fBpan\fP will determine the
  713. Xappropriate size based on the scale and the fonts requested.
  714. X.RE
  715. X.LP
  716. X.SH CONTROL LANGUAGE
  717. XNew to \fBPan V3.0\fP is a command line interface and general control
  718. Xlanguage.  Most of the features available in \fBpan\fP through the
  719. Xwindowing interface can now be used from the command line via a
  720. Xprogram called \fBpancmd\fP.  See the manual entry for \fBpancmd\fP
  721. Xfor more information on how to use the command.  This section describes
  722. Xthe actual control language since it is part of the \fBpan\fP program.
  723. X.LP
  724. XThe following actions are supported by the control language:
  725. X.LP
  726. X.RS
  727. Xo Note Creation
  728. X.br
  729. Xo Note Exposure
  730. X.br
  731. Xo Note Hiding
  732. X.br
  733. Xo Note Veiling
  734. X.br
  735. Xo Note Printing
  736. X.br
  737. Xo Note Movement Between Folders
  738. X.br
  739. Xo Folder Creation
  740. X.br
  741. Xo Pan Process Exit
  742. X.LP
  743. X.RE
  744. XNote that no destructive commands have been implemented.  The following is
  745. Xa list of the commands and their syntax.  The convention I use in describing
  746. Xthe syntax is to surround optional arguments with "[]", and to indicate
  747. Xuser required parameters with "<>".
  748. X.LP
  749. XWhen specifying a parameter for a command, if whitespace must be embedded,
  750. Xsingle or double quote marks may be used around the parameter.
  751. X.LP
  752. X\fBNote Creation\fP
  753. X.RS
  754. Xnewnote [folder <folder>] [title <title>] [size <width> <height>]
  755. X.br
  756. X    [location <x> <y>] [hidden|visible|veiled] [file <name>]
  757. X.LP
  758. XThis command causes \fBpan\fP to create a new note.  All parameters are
  759. Xoptional.  If no parameters are specified, the default action is to create
  760. Xa note as if the "New Note" button had bee clicked on with mouse button 1.
  761. X.LP
  762. XThe folder and title options may be used to specify the note's folder and
  763. Xtitle respectively.  The size and location options will control the note's
  764. Xsize and location respectively.  The parameters for these options are to
  765. Xbe specified in pixels.  By default, a new note is visible, but any of the
  766. Xthree states may be specified for the note.  The optional file parameter
  767. Xspecifies a full path name of a file from which the contents of the note
  768. Xare to be loaded.
  769. X.LP
  770. XExample:
  771. X.LP
  772. X.RS
  773. Xnewnote title Termcap size 500 200 location 10 10 visible
  774. X.br
  775. X    file /etc/termcap
  776. X.RE
  777. X.RE
  778. X.LP
  779. X\fBNote Exposure\fP
  780. X.RS
  781. Xexpose title <title RE> [windowmax <max # to expose>]
  782. X.LP
  783. XThis command causes \fBpan\fP to expose all notes (up to the X resource
  784. X\fBpan.windowMax\fP) with titles that match the given regular expression.
  785. XIf the windowmax parameter is given, it temporarily overrides the maximum
  786. Xset in the X resource database.
  787. X.LP
  788. XExample:
  789. X.LP
  790. X.RS
  791. Xexpose title "Phone Numbers"
  792. X.RE
  793. X.RE
  794. X.LP
  795. X\fBNote Hiding\fP
  796. X.RS
  797. Xhide title <title RE>
  798. X.LP
  799. XThis command will cause all notes with titles matching the given regular
  800. Xexpression to be hidden.
  801. X.LP
  802. XExample:
  803. X.LP
  804. X.RS
  805. Xhide title "To Do List"
  806. X.RE
  807. X.RE
  808. X.LP
  809. X\fBNote Veiling\fP
  810. X.RS
  811. Xveil title <title RE>
  812. X.LP
  813. XThis command will cause all notes with titles matching the given regular
  814. Xexpression to be veiled.
  815. X.LP
  816. XExample:
  817. X.LP
  818. X.RS
  819. Xveil title "Meeting Tomorrow"
  820. X.RE
  821. X.RE
  822. X.LP
  823. X\fBNote Printing\fP
  824. X.RS
  825. Xprint folder <folder> title <title RE>
  826. X.LP
  827. XThis command will cause all notes within the specified folder that have
  828. Xtitles matching the given regular expression to be queued for printing.
  829. XIn order to not overload the computer, \fBpan\fP will start only one
  830. Xprint command (specified by the X resource \fBpan.printCommand\fP) at a time.
  831. XWhen the print process exits, the next matching note will be queued.  This
  832. Xqueuing process is done asynchronously in the background so that the \fBpan\fP
  833. Xprocess can still respond to other commands and user interaction.
  834. X.LP
  835. XExample:
  836. X.LP
  837. X.RS
  838. Xprint folder Reference title .
  839. X.RE
  840. X.RE
  841. X.LP
  842. X\fBNote Movement Between Folders\fP
  843. X.RS
  844. Xmove source <folder> title <title RE> destination <folder>
  845. X.LP
  846. XThis command will move notes between folders.  All notes with titles matching
  847. Xthe given regular expression in the source folder are moved to the destination
  848. Xfolder.
  849. X.LP
  850. XExample:
  851. X.LP
  852. X.RS
  853. Xmove source Miscellaneous title "[Xx] [Ww]indow" destination X_Notes
  854. X.RE
  855. X.RE
  856. X.LP
  857. X\fBFolder Creation\fP
  858. X.RS
  859. Xnewfolder folder <name>
  860. X.LP
  861. XThis command will create a new folder.  The folder name may not contain
  862. Xwhitespace or slash characters.
  863. X.LP
  864. XExample:
  865. X.LP
  866. X.RS
  867. Xnewfolder folder X_Notes
  868. X.RE
  869. X.RE
  870. X.LP
  871. X\fBPan Process Exit\fP
  872. X.RS
  873. Xquit
  874. X.LP
  875. XThis command causes the currently running \fBpan\fP command to exit.
  876. X.RE
  877. X.LP
  878. X.SH NOTES
  879. XThe \fBpan\fP program will accept drag and drop files from the Open Look
  880. Xfile manager.
  881. XFor this feature to work, the file icon must be dropped directly into the text
  882. Xsubwindow of the note.  Dropping the icon anywhere else will not have
  883. Xany effect.
  884. X.LP
  885. XA late addition to this version of \fBpan\fP is the ability to drag a note
  886. Xto another application.  The drag and drop target (the small square in the
  887. Xupper, right-hand corner of the note windows) may be used for this purpose.
  888. X.LP
  889. XIf the note file directories are examined, occasionally files with names
  890. Xending in a "%" character will be seen.  These files are created automatically
  891. Xby the Open Look text subwindow package, and are simply old versions of the
  892. Xnote files being edited.
  893. X.SH WINDOW CLASS
  894. X\fBPan\fP supports three different window classes for use with window manager
  895. Xproperties such as minimal decor.  The first is "PanMain".  This is the class
  896. Xfor the main window.  The second is "PanNote".  This is the class for all
  897. Xnotes.  The third is "Pan" (assuming the executable name is not changed).
  898. XThis is used for all pop up windows, such as the create folder window.
  899. X.SH FILES
  900. XDefault note directory:
  901. X.RS
  902. X$HOME/.pan
  903. X.RE
  904. X.LP
  905. XNote files:
  906. X.RS
  907. XNote_%d_%d
  908. X.br
  909. XNote_%d_%d.info
  910. X.LP
  911. Xwhere the "%d" instances are replaced by unique id numbers.
  912. X.RE
  913. X.SH FILE FORMAT
  914. XThe "Note_%d_%d" file is a plain ASCII file containing the note text.  Lines
  915. Xare delimited by the newline character.
  916. X.LP
  917. XThe "Note_%d_%d.info" file is a plain ASCII file currently containing 3 lines.
  918. X.LP
  919. XThe first line contains 4 whitespace separated numbers followed by a
  920. Xtext word.  The 4 numbers describe the note window's start x, start y,
  921. Xwidth, and height.  The text word is either "VISIBLE" or "HIDDEN" describing
  922. Xwhether the note is mapped to the display by default or not.
  923. X.LP
  924. XThe second line of the file contains the note title.
  925. X.LP
  926. XThe third line is an ASCII representation of the decimal number returned 
  927. Xby time(3) describing the note's creation date and time.
  928. X.LP
  929. XAn example might be:
  930. X.nf
  931. X
  932. X4    424    349    206    HIDDEN
  933. XNote title
  934. X664129826
  935. X
  936. X.fi
  937. X.SH BUGS
  938. XOccasionally, when a new note is created, the focus is initially in the text
  939. Xsub-window instead of in the title panel item.  This appears to be a problem
  940. Xwith XView.
  941. X.LP
  942. XUnder OW3.0, if PgUp/PgDn is pressed when at the top/bottom of the file,
  943. Xthe window beeps as many times as
  944. Xthere are lines visible.  This also appears to be a problem with XView.
  945. XI have been told that there might be a patch from Sun for this problem,
  946. Xbut I haven't tried to verify it.
  947. X.LP
  948. XThe text sub-window package in xview creates files ending with a "%" character
  949. Xand doesn't delete them.  Periodically it is a good idea to remove them by
  950. Xhand to recover disk space.  If you accidentally destroy a note that had
  951. Xtext in it, you \fImight\fP be able to recover the text by looking through the
  952. Xfiles ending with a "%" character.
  953. X.SH ACKNOWLEDGEMENTS
  954. XMy thanks to the many people who submitted bug reports and requests for
  955. Xenhancements.  I have tried to incorporate as many of the ideas I received
  956. Xas possible into version 3.0 of \fBPan\fP.  I'm not listing specific names
  957. Xhere because I didn't keep track of the people, just the requests.  Sorry.
  958. XNext time I'll keep the names too.
  959. X.LP
  960. XIf you don't find your enhancement request in this release, don't despair!
  961. XI was unable to include everything I wanted to because of the demands of
  962. Xmy real job.  If you don't see it, and you still want it, feel free to
  963. Xrequest the feature again.
  964. X.SH AUTHOR
  965. XJeffrey Bailey
  966. SHAR_EOF
  967. chmod 0644 pan3.0/pan.man ||
  968. echo 'restore of pan3.0/pan.man failed'
  969. Wc_c="`wc -c < 'pan3.0/pan.man'`"
  970. test 21398 -eq "$Wc_c" ||
  971.     echo 'pan3.0/pan.man: original size 21398, current size' "$Wc_c"
  972. fi
  973. # ============= pan3.0/misc.c ==============
  974. if test -f 'pan3.0/misc.c' -a X"$1" != X"-c"; then
  975.     echo 'x - skipping pan3.0/misc.c (File already exists)'
  976. else
  977. echo 'x - extracting pan3.0/misc.c (Text)'
  978. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/misc.c' &&
  979. X/*
  980. XPost A Note V3.0
  981. XCopyright (c) 1993, Jeffrey W. Bailey
  982. XAll rights reserved.
  983. X
  984. XPermission is granted to distribute this program in exact, complete
  985. Xsource form, which includes this copyright notice, as long as no fee
  986. Xother than media and distribution cost is charged.
  987. X
  988. XThis program may not be used in whole, or in part, in any other manner
  989. Xwithout prior written permission from the author.
  990. X
  991. XThis program may not be distributed in modified form without prior
  992. Xwritten permission from the author.  In other words, patches may be
  993. Xdistributed, but modified source may not be distributed.
  994. X
  995. XIf there are any questions, comments or suggestions, the author may be
  996. Xcontacted at:
  997. X
  998. X    jeff@rd1.interlan.com
  999. X
  1000. X    or
  1001. X
  1002. X    Jeffrey Bailey
  1003. X    Racal-Datacom, Inc.
  1004. X    Mail Stop E-110
  1005. X    1601 N. Harrison Parkway
  1006. X    Sunrise, FL  33323-2899
  1007. X*/
  1008. X
  1009. X#include "pan.h"
  1010. X
  1011. Xextern int errno;
  1012. Xextern char *sys_errlist[];
  1013. X
  1014. Xchar *add_sorted(nr, title)
  1015. X    struct LLM_root *nr;
  1016. X    char *title;
  1017. X    {
  1018. X    struct Note *np;
  1019. X
  1020. X    np = (struct Note *)LLM_first(nr);
  1021. X    if(np == NULL)
  1022. X        {
  1023. X        return(LLM_add(nr));
  1024. X        }
  1025. X    while(np != NULL && strcmp(title, np->ntitle) >= 0)
  1026. X        {
  1027. X        np = (struct Note *)LLM_next(nr);
  1028. X        }
  1029. X    if(np == NULL)
  1030. X        {
  1031. X        return(LLM_add(nr));
  1032. X        }
  1033. X    return(LLM_insert(nr, (char *)np));
  1034. X    }
  1035. X
  1036. X/* adjust nodes position in list since the title may have changed */
  1037. Xadjust_sorted(np)
  1038. X    struct Note *np;
  1039. X    {
  1040. X    struct LLM_root *nr;
  1041. X    struct Note *tp;
  1042. X
  1043. X    nr = &np->sp->note_rt;
  1044. X    LLM_unlink(nr, (char *)np);
  1045. X    tp = (struct Note *)LLM_first(nr);
  1046. X    while(tp != NULL && strcmp(np->ntitle, tp->ntitle) >= 0)
  1047. X        {
  1048. X        tp = (struct Note *)LLM_next(nr);
  1049. X        }
  1050. X    LLM_link(nr, (char *)tp, (char *)np);
  1051. X    }
  1052. SHAR_EOF
  1053. chmod 0644 pan3.0/misc.c ||
  1054. echo 'restore of pan3.0/misc.c failed'
  1055. Wc_c="`wc -c < 'pan3.0/misc.c'`"
  1056. test 1762 -eq "$Wc_c" ||
  1057.     echo 'pan3.0/misc.c: original size 1762, current size' "$Wc_c"
  1058. fi
  1059. # ============= pan3.0/parser.c ==============
  1060. if test -f 'pan3.0/parser.c' -a X"$1" != X"-c"; then
  1061.     echo 'x - skipping pan3.0/parser.c (File already exists)'
  1062. else
  1063. echo 'x - extracting pan3.0/parser.c (Text)'
  1064. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/parser.c' &&
  1065. X/*
  1066. XPost A Note V3.0
  1067. XCopyright (c) 1993, Jeffrey W. Bailey
  1068. XAll rights reserved.
  1069. X
  1070. XPermission is granted to distribute this program in exact, complete
  1071. Xsource form, which includes this copyright notice, as long as no fee
  1072. Xother than media and distribution cost is charged.
  1073. X
  1074. XThis program may not be used in whole, or in part, in any other manner
  1075. Xwithout prior written permission from the author.
  1076. X
  1077. XThis program may not be distributed in modified form without prior
  1078. Xwritten permission from the author.  In other words, patches may be
  1079. Xdistributed, but modified source may not be distributed.
  1080. X
  1081. XIf there are any questions, comments or suggestions, the author may be
  1082. Xcontacted at:
  1083. X
  1084. X    jeff@rd1.interlan.com
  1085. X
  1086. X    or
  1087. X
  1088. X    Jeffrey Bailey
  1089. X    Racal-Datacom, Inc.
  1090. X    Mail Stop E-110
  1091. X    1601 N. Harrison Parkway
  1092. X    Sunrise, FL  33323-2899
  1093. X*/
  1094. X
  1095. X#include <stdio.h>
  1096. X#include <ctype.h>
  1097. X
  1098. X#ifdef HAS_STDLIB
  1099. X#include <stdlib.h>
  1100. X#else
  1101. Xextern char *malloc();
  1102. Xextern char *getenv();
  1103. X#endif /* HAS_STDLIB */
  1104. X
  1105. X/*
  1106. X    Component structure for each token on the linked list.
  1107. X*/
  1108. Xstruct ps_component
  1109. X    {
  1110. X    struct ps_component *ps_prev; /* Pointer to previous node */
  1111. X    struct ps_component *ps_next; /* Pointer to next node */
  1112. X    char *ps_text;          /* Pointer to token text */
  1113. X    char ps_start_delim;      /* Character delimiter for start of token */
  1114. X    char ps_end_delim;          /* Character delimiter for end of token */
  1115. X    };
  1116. X
  1117. Xstatic struct ps_component *ps_add_node();
  1118. X
  1119. X/*
  1120. X
  1121. X    Name:  parse_string()
  1122. X
  1123. X    Calling sequence is:
  1124. X
  1125. X        string  - pointer to string to be parsed
  1126. X        delim   - pointer to string of delimiters
  1127. X        d_quote - 1 or 0 allowing/disallowing double quoting
  1128. X        s_quote - 1 or 0 allowing/disallowing single quoting
  1129. X        esc     - 1 or 0 allowing/disallowing escaping
  1130. X
  1131. X    Returns:  A pointer to the first node in the linked list; NULL on failure
  1132. X              *OR* if the string contains no tokens.
  1133. X
  1134. X    Note that this routine is implemented as a somewhat complex state machine.
  1135. X*/
  1136. X
  1137. Xstruct ps_component *parse_string(string, delim, d_quote, s_quote, esc)
  1138. X    char *string, *delim;
  1139. X    int  d_quote, s_quote, esc;
  1140. X    {
  1141. X    struct ps_component *start, *ps_add_node();
  1142. X    char *point1, *point2, *t_string, *t_component;
  1143. X    int  beg_escape = 0;
  1144. X    int  in_escape = 0;
  1145. X    int  in_d_quote = 0;
  1146. X    int  in_s_quote = 0;
  1147. X    int  in_component = 0;
  1148. X    int  is_delim = 0;
  1149. X    int  is_quote = 0;
  1150. X    int  beg_component = 1;
  1151. X    char temp [2];
  1152. X    char t_start_delim;
  1153. X
  1154. X    t_start_delim = NULL;
  1155. X    temp [1] = 0;
  1156. X    start = NULL;
  1157. X
  1158. X    /* Skip leading delimiters */
  1159. X    point1 = string;
  1160. X    temp [0] = *point1;
  1161. X    while(*point1 != NULL && instr(delim, temp) != NULL)
  1162. X        {
  1163. X        t_start_delim = *point1;
  1164. X        temp [0] = *++point1;
  1165. X        }
  1166. X
  1167. X    /* quick check for null string */
  1168. X    if(!strlen(point1)) return(NULL);
  1169. X
  1170. X    /* allocate temp storage */
  1171. X    t_string = malloc(strlen(point1) + 1);
  1172. X    if(t_string == NULL) return(NULL);
  1173. X    strcpy(t_string, point1);
  1174. X    t_component = malloc(strlen(t_string) + 1);
  1175. X    if(t_component == NULL)
  1176. X        {
  1177. X        free(t_string);
  1178. X        return(NULL);
  1179. X        }
  1180. X    *t_component = 0;
  1181. X    point1 = t_string;
  1182. X    point2 = t_component;
  1183. X
  1184. X    /* parse the string */
  1185. X    while(*point1 != NULL)
  1186. X        {
  1187. X        /* handle the escape character logic */
  1188. X        in_escape = 0;
  1189. X        if(beg_escape) in_escape = 1;
  1190. X        beg_escape = 0;
  1191. X        is_quote = 0;
  1192. X
  1193. X        /* is the next char a delimiter? */
  1194. X        temp [0] = *point1;
  1195. X        if(instr(delim, temp) != NULL) is_delim = 1;
  1196. X            else is_delim = 0;
  1197. X
  1198. X        /* if an escape char and not already escaped */
  1199. X        if(*point1 == '\\' && !in_escape && esc) beg_escape = 1;
  1200. X
  1201. X        /* if a double quote, not in single quote, and not escaped */
  1202. X        if(*point1 == '"' && !in_s_quote && !in_escape)
  1203. X            {
  1204. X            /* if not escaped, in double quote, and it is a double quote */
  1205. X            if(d_quote && in_d_quote && !beg_escape)
  1206. X                {
  1207. X                is_quote = 1;
  1208. X                in_d_quote = 0;
  1209. X                *point2 = 0;
  1210. X                start = ps_add_node(start, t_component,
  1211. X                                                '"', *point1);
  1212. X                point2 = t_component;
  1213. X                }
  1214. X            else
  1215. X                if(d_quote && !in_d_quote) /* beginning double quote */
  1216. X                    {
  1217. X                    is_quote = 1;
  1218. X                    in_d_quote = 1;
  1219. X                    beg_component = 1;
  1220. X                    }
  1221. X            }
  1222. X        /* if a single quote, not in double quote, and not escaped */
  1223. X        if(*point1 == '\'' && !in_d_quote && !in_escape)
  1224. X            {
  1225. X            /* if not escaped, in single quote, and it is a single quote */
  1226. X            if(s_quote && in_s_quote && !beg_escape)
  1227. X                {
  1228. X                is_quote = 1;
  1229. X                in_s_quote = 0;
  1230. X                *point2 = 0;
  1231. X                start = ps_add_node(start, t_component,
  1232. X                                                '\'', *point1);
  1233. X                point2 = t_component;
  1234. X                }
  1235. X            else
  1236. X                if(s_quote && !in_s_quote) /* beginning single quote */
  1237. X                    {
  1238. X                    is_quote = 1;
  1239. X                    in_s_quote = 1;
  1240. X                    beg_component = 1;
  1241. X                    }
  1242. X            }
  1243. X        /* if delimiter, not in quotes and not escaped, or is a quote */
  1244. X        if( (is_delim && !in_d_quote && !in_s_quote && !in_escape) || is_quote)
  1245. X            {
  1246. X            /* at the beginning of a component */
  1247. X            beg_component = 1;
  1248. X            in_component = 0;
  1249. X            *point2 = 0;
  1250. X            if(strlen(t_component)) start = ps_add_node(start, t_component,
  1251. X                                            t_start_delim, *point1);
  1252. X            /* store the start delimiter */
  1253. X            t_start_delim = *point1;
  1254. X            point2 = t_component;
  1255. X            }
  1256. X        else
  1257. X            {
  1258. X            if(beg_component) /* if start of component, mark as in comp. */
  1259. X                {
  1260. X                in_component = 1;
  1261. X                beg_component = 0;
  1262. X                }
  1263. X            /* copy while in component */
  1264. X            if(in_component && !beg_escape)
  1265. X                {
  1266. X                *point2 = *point1;
  1267. X                point2++;
  1268. X                }
  1269. X            }
  1270. X        point1++;
  1271. X        }
  1272. X    /* if still in component, terminate and add it to the list */
  1273. X    if(in_component)
  1274. X        {
  1275. X        *point2 = 0;
  1276. X        if(strlen(t_component)) start = ps_add_node(start, t_component,
  1277. X                                        t_start_delim, *point1);
  1278. X        }
  1279. X    /* free temp storage */
  1280. X    free(t_string);
  1281. X    free(t_component);
  1282. X    return(start);
  1283. X    }
  1284. X
  1285. X/*
  1286. X    Name: ps_add_node()
  1287. X
  1288. X    Description:  private routine called to build list
  1289. X*/
  1290. X
  1291. Xstatic struct ps_component *ps_add_node(start, text, start_delim, end_delim)
  1292. X    struct ps_component *start;
  1293. X    char *text;
  1294. X    char start_delim, end_delim;
  1295. X    {
  1296. X    struct ps_component *hold, *current, *prev;
  1297. X
  1298. X    hold = (struct ps_component *) malloc(sizeof(struct ps_component));
  1299. X    if(hold == NULL) return(NULL);
  1300. X    hold->ps_text = malloc(strlen(text) + 1);
  1301. X    if(hold->ps_text == NULL) return(NULL);
  1302. X    strcpy(hold->ps_text, text);
  1303. X    hold->ps_start_delim = start_delim;
  1304. X    hold->ps_end_delim = end_delim;
  1305. X    current = start;
  1306. X    prev = current;
  1307. X    while(current != NULL)
  1308. X        {
  1309. X        prev = current;
  1310. X        current = current->ps_next;
  1311. X        }
  1312. X    if(prev == NULL)
  1313. X        {
  1314. X        start = hold;
  1315. X        hold->ps_prev = NULL;
  1316. X        hold->ps_next = NULL;
  1317. X        }
  1318. X    else
  1319. X        {
  1320. X        prev->ps_next = hold;
  1321. X        hold->ps_prev = prev;
  1322. X        hold->ps_next = NULL;
  1323. X        }
  1324. X    return(start);
  1325. X    }
  1326. X
  1327. X/*
  1328. X    Name:  free_ps_list()
  1329. X
  1330. X    Description:  Routine to free a list built by parse_string.  Pass the
  1331. X                  address of the first node in the list.
  1332. X*/
  1333. X
  1334. Xfree_ps_list(start)
  1335. X    struct ps_component *start;
  1336. X    {
  1337. X    struct ps_component *current, *hold;
  1338. X
  1339. X    current = start;
  1340. X    while(current != NULL)
  1341. X        {
  1342. X        hold = current->ps_next;
  1343. X        if(current->ps_text != NULL) free(current->ps_text);
  1344. X        free(current);
  1345. X        current = hold;
  1346. X        }
  1347. X    return(1);
  1348. X    }
  1349. SHAR_EOF
  1350. chmod 0644 pan3.0/parser.c ||
  1351. echo 'restore of pan3.0/parser.c failed'
  1352. Wc_c="`wc -c < 'pan3.0/parser.c'`"
  1353. test 8168 -eq "$Wc_c" ||
  1354.     echo 'pan3.0/parser.c: original size 8168, current size' "$Wc_c"
  1355. fi
  1356. true || echo 'restore of pan3.0/rmfolder.c failed'
  1357. echo End of part 3, continue with part 4
  1358. exit 0
  1359.  
  1360. --
  1361. Jeffrey Bailey
  1362. Racal-Datacom, Inc.
  1363. Mail Stop E-110
  1364. 1601 N. Harrison Parkway                  INET : jeff@rd1.interlan.com
  1365. Sunrise, FL 33323-2899                    UUCP : ...uflorida!novavax!rd1!jeff
  1366.  
  1367. exit 0 # Just in case...
  1368. -- 
  1369.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1370. \X/  Amiga - The only way to fly! |    sources-x@sterling.com
  1371.  "It's intuitively obvious to the |
  1372.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1373.