home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sources / misc / 3782 < prev    next >
Encoding:
Text File  |  1992-07-30  |  32.1 KB  |  1,133 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: sbo@vlsi.polymtl.ca (Stephane Boucher)
  4. Subject:  v31i058:  bam - [OpenLook|Athena] menu system for [GNU|Epoch|Lucid] Emacs, Part02/07
  5. Message-ID: <1992Jul31.042303.23317@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: a7a5d93feacbfc573dca9fb67c54cde7
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. References: <csm-v31i057=bam.232156@sparky.IMD.Sterling.COM>
  11. Date: Fri, 31 Jul 1992 04:23:03 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 1118
  14.  
  15. Submitted-by: sbo@vlsi.polymtl.ca (Stephane Boucher)
  16. Posting-number: Volume 31, Issue 58
  17. Archive-name: bam/part02
  18. Environment: Lex, Yacc, SunOS 4.x with XView or BSD Unix with Athena Widget
  19. Supersedes: bam: Volume 27, Issue 68-69
  20.  
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of archive 2 (of 7)."
  28. # Contents:  bam-2.0/FindWindow.c bam-2.0/args.c bam-2.0/bam.c
  29. #   bam-2.0/bam.h bam-2.0/filenames.c bam-2.0/icon.c
  30. #   bam-2.0/menus/emacs-base-ol.el bam-2.0/scanner.l
  31. #   bam-2.0/strstore.c
  32. # Wrapped by sbo@froh on Mon Jul 27 20:11:48 1992
  33. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  34. if test -f 'bam-2.0/FindWindow.c' -a "${1}" != "-c" ; then 
  35.   echo shar: Will not clobber existing file \"'bam-2.0/FindWindow.c'\"
  36. else
  37. echo shar: Extracting \"'bam-2.0/FindWindow.c'\" \(2108 characters\)
  38. sed "s/^X//" >'bam-2.0/FindWindow.c' <<'END_OF_FILE'
  39. X/*   bam - the Born Again Menus for GNU Emacs.
  40. X   Copyright (C) 1992 Hans Olsson.
  41. X
  42. X    This program is free software; you can redistribute it and/or modify
  43. X    it under the terms of the GNU General Public License as published by
  44. X    the Free Software Foundation; either version 1, or (at your option)
  45. X    any later version.
  46. X
  47. X    This program is distributed in the hope that it will be useful,
  48. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  49. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  50. X    GNU General Public License for more details.
  51. X
  52. X    You should have received a copy of the GNU General Public License
  53. X    along with this program; if not, write to the Free Software
  54. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  55. X
  56. X  In other words, you are welcome to use, share and improve this program.
  57. X  You are forbidden to forbid anyone else to use, share and improve
  58. X  what you give them.   Help stamp out software-hoarding!
  59. X*/
  60. X/* $Id: FindWindow.c,v 1.1 1992/07/02 00:59:41 sbo Exp $ */
  61. X
  62. X#include <X11/Xos.h>
  63. X#include <X11/Xlib.h>
  64. X#include <X11/Xutil.h>
  65. X#include <X11/cursorfont.h>
  66. X#include <X11/IntrinsicP.h>
  67. X#include <X11/StringDefs.h>
  68. X
  69. X/*
  70. X * Window_With_Name: routine to locate a window with a given name on a display.
  71. X *                   If no window with the given name is found, 0 is returned.
  72. X *                   If more than one window has the given name, the first
  73. X *                   one found will be returned.  Only top and its subwindows
  74. X *                   are looked at.  Normally, top should be the RootWindow.
  75. X */
  76. XWindow Window_With_Name(dpy,top,name)
  77. X     Display *dpy;
  78. X     Window top;
  79. X     char* name;
  80. X{
  81. X    Window *children, dummy;
  82. X    unsigned int nchildren;
  83. X    int i;
  84. X    Window w=0;
  85. X    char *window_name;
  86. X
  87. X    if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name)) {
  88. X             return(top);
  89. X    }
  90. X    if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren))
  91. X      return(0);
  92. X
  93. X    for (i=0; i<nchildren; i++) {
  94. X        w = Window_With_Name(dpy, children[i], name);
  95. X        if (w)
  96. X          break;
  97. X    }
  98. X    if (children) XFree ((char *)children);
  99. X    return(w);
  100. X}
  101. END_OF_FILE
  102. if test 2108 -ne `wc -c <'bam-2.0/FindWindow.c'`; then
  103.     echo shar: \"'bam-2.0/FindWindow.c'\" unpacked with wrong size!
  104. fi
  105. # end of 'bam-2.0/FindWindow.c'
  106. fi
  107. if test -f 'bam-2.0/args.c' -a "${1}" != "-c" ; then 
  108.   echo shar: Will not clobber existing file \"'bam-2.0/args.c'\"
  109. else
  110. echo shar: Extracting \"'bam-2.0/args.c'\" \(2270 characters\)
  111. sed "s/^X//" >'bam-2.0/args.c' <<'END_OF_FILE'
  112. X/*   bam - the Born Again Menus for GNU Emacs.
  113. X   Copyright (C) 1992 Stephane Boucher.
  114. X
  115. X    This program is free software; you can redistribute it and/or modify
  116. X    it under the terms of the GNU General Public License as published by
  117. X    the Free Software Foundation; either version 1, or (at your option)
  118. X    any later version.
  119. X
  120. X    This program is distributed in the hope that it will be useful,
  121. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  122. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  123. X    GNU General Public License for more details.
  124. X
  125. X    You should have received a copy of the GNU General Public License
  126. X    along with this program; if not, write to the Free Software
  127. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  128. X
  129. X  In other words, you are welcome to use, share and improve this program.
  130. X  You are forbidden to forbid anyone else to use, share and improve
  131. X  what you give them.   Help stamp out software-hoarding!
  132. X*/
  133. X/* $Id: args.c,v 1.7 1992/07/02 00:57:44 sbo Exp $ */
  134. X
  135. X#include "bam.h"
  136. X
  137. Xextern char *optarg;
  138. Xextern int optind, opterr;
  139. X
  140. XprocessArgs(argc, argv)
  141. X     int argc;
  142. X     char **argv;
  143. X{
  144. X  char c;
  145. X  int errflg=0;
  146. X
  147. X  while ((c = getopt(argc, argv, "e:g:B:nw:")) != -1)
  148. X    switch (c) {
  149. X    case 'e':
  150. X      /* -e <error_format> 
  151. X     Specify the error format where <error_format>
  152. X     is a format string like printf format with
  153. X     one %s */
  154. X
  155. X      errorFormat=optarg;
  156. X      break;
  157. X
  158. X    case 'w':
  159. X#ifdef ATHENA
  160. X      windowName = optarg;
  161. X#endif
  162. X      break;
  163. X
  164. X    case 'g':
  165. X      /* -g <debug_level>
  166. X     specify the debug level. Used only for debugging bam. */
  167. X
  168. X      menuDebug=atoi(optarg);
  169. X      break;
  170. X      
  171. X    case 'B':
  172. X      /* -B <bitmap_path>
  173. X     Specify a search path for the bitmaps. <bitmap_path>
  174. X     is a list of paths seperated by ':', just like the
  175. X     shell variable PATH. */
  176. X      
  177. X      bitmapsPath=optarg;
  178. X      
  179. X    case 'n':
  180. X      /* -n
  181. X     specify not to display the author frame when the menu
  182. X     is openned */
  183. X      noAuthorFrame=TRUE;
  184. X      break;
  185. X
  186. X    case '?':
  187. X    default:
  188. X      errflg++;
  189. X      break;
  190. X    }
  191. X
  192. X  if (errflg || optind+1!=argc) {
  193. X    sendErrorToEmacs("usage: \n\
  194. X\t%s [-e <error_format>] [-B <bitmap_path>] menu_file\n", argv[0]);
  195. X    exit (2);
  196. X  }
  197. X
  198. X  menuFile=argv[optind];
  199. X}
  200. END_OF_FILE
  201. if test 2270 -ne `wc -c <'bam-2.0/args.c'`; then
  202.     echo shar: \"'bam-2.0/args.c'\" unpacked with wrong size!
  203. fi
  204. # end of 'bam-2.0/args.c'
  205. fi
  206. if test -f 'bam-2.0/bam.c' -a "${1}" != "-c" ; then 
  207.   echo shar: Will not clobber existing file \"'bam-2.0/bam.c'\"
  208. else
  209. echo shar: Extracting \"'bam-2.0/bam.c'\" \(2632 characters\)
  210. sed "s/^X//" >'bam-2.0/bam.c' <<'END_OF_FILE'
  211. X/*   bam - the Born Again Menus for GNU Emacs.
  212. X   Copyright (C) 1992 Stephane Boucher.
  213. X
  214. X    This program is free software; you can redistribute it and/or modify
  215. X    it under the terms of the GNU General Public License as published by
  216. X    the Free Software Foundation; either version 1, or (at your option)
  217. X    any later version.
  218. X
  219. X    This program is distributed in the hope that it will be useful,
  220. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  221. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  222. X    GNU General Public License for more details.
  223. X
  224. X    You should have received a copy of the GNU General Public License
  225. X    along with this program; if not, write to the Free Software
  226. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  227. X
  228. X  In other words, you are welcome to use, share and improve this program.
  229. X  You are forbidden to forbid anyone else to use, share and improve
  230. X  what you give them.   Help stamp out software-hoarding!
  231. X*/
  232. X/* $Id: bam.c,v 1.8 1992/07/02 00:57:44 sbo Exp $ */
  233. X
  234. X#define _BAM_MAIN_
  235. X
  236. X#include <unistd.h>
  237. X
  238. X#include "bam.h"
  239. X
  240. X#ifdef ATHENA
  241. X#include "athena.h"
  242. X#endif
  243. X
  244. Xchar *menuFile=NULL;
  245. Xchar *errorFormat="(command-process-error \"%s\")";
  246. Xchar *bitmapsPath=NULL;
  247. X
  248. XFrame baseFrame=NULL;
  249. Xint menuDebug=0; /* Contains the level of debugging. 0 is no debug level */
  250. Xint finalExit=0;
  251. Xint noAuthorFrame=FALSE;
  252. X
  253. XFILE *debugFp=stdout;
  254. X
  255. Xmain(argc, argv)
  256. X     int argc;
  257. X     char **argv; 
  258. X{
  259. X  int exitVal=0;
  260. X
  261. X#ifdef ATHENA
  262. X  do_init(&argc,argv);
  263. X#else
  264. X  xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
  265. X#endif
  266. X
  267. X  strStoreOpen();
  268. X  
  269. X  processArgs(argc, argv);
  270. X  
  271. X  if (access(menuFile, R_OK) == 0 ) {
  272. X    /* Menu File accessible */
  273. X    
  274. X    while (1) {
  275. X      /* The next exit of the window_main_loop will
  276. X     be the final one, unless specified otherwise  
  277. X     in panelMenuNotifyProc */
  278. X      finalExit=1;
  279. X
  280. X      yyin=fopen(menuFile, "r");
  281. X
  282. X      if (!yyparse()) {
  283. X    window_main_loop(baseFrame);
  284. X    strStoreFree();
  285. X      }
  286. X      else {
  287. X    /* A parse error has occured */
  288. X    exitVal=1;
  289. X    fclose(yyin);
  290. X    break;
  291. X      }
  292. X      fclose(yyin);
  293. X
  294. X      if (finalExit)
  295. X    break;
  296. X    }
  297. X    
  298. X  }
  299. X  else {
  300. X    /* Menu File not accessible */
  301. X    sendErrorToEmacs("Unaccessable File: %s\n", menuFile);
  302. X    exitVal=1;
  303. X  }
  304. X  
  305. X  strStoreClose();
  306. X  
  307. X  return(exitVal);
  308. X} 
  309. X
  310. X
  311. X#ifdef XVIEW
  312. Xvoid
  313. XmenuProc (menu, menuItem)
  314. X     Menu menu;
  315. X     Menu_item menuItem;
  316. X{
  317. X  sendToEmacs( (int)xv_get(menuItem, 
  318. X               XV_KEY_DATA, M_COMMAND_STRING));
  319. X}
  320. X
  321. Xint
  322. X  selected(item, event)
  323. XPanel_item item;
  324. XEvent *event;
  325. X{
  326. X  sendToEmacs((char *)xv_get(item, 
  327. X                 XV_KEY_DATA, M_COMMAND_STRING));
  328. X  return XV_OK;
  329. X}
  330. X
  331. X#endif
  332. END_OF_FILE
  333. if test 2632 -ne `wc -c <'bam-2.0/bam.c'`; then
  334.     echo shar: \"'bam-2.0/bam.c'\" unpacked with wrong size!
  335. fi
  336. # end of 'bam-2.0/bam.c'
  337. fi
  338. if test -f 'bam-2.0/bam.h' -a "${1}" != "-c" ; then 
  339.   echo shar: Will not clobber existing file \"'bam-2.0/bam.h'\"
  340. else
  341. echo shar: Extracting \"'bam-2.0/bam.h'\" \(3811 characters\)
  342. sed "s/^X//" >'bam-2.0/bam.h' <<'END_OF_FILE'
  343. X/*   bam - the Born Again Menus for GNU Emacs.
  344. X   Copyright (C) 1992 Stephane Boucher, Hans Olsson.
  345. X
  346. X    This program is free software; you can redistribute it and/or modify
  347. X    it under the terms of the GNU General Public License as published by
  348. X    the Free Software Foundation; either version 1, or (at your option)
  349. X    any later version.
  350. X
  351. X    This program is distributed in the hope that it will be useful,
  352. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  353. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  354. X    GNU General Public License for more details.
  355. X
  356. X    You should have received a copy of the GNU General Public License
  357. X    along with this program; if not, write to the Free Software
  358. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  359. X
  360. X  In other words, you are welcome to use, share and improve this program.
  361. X  You are forbidden to forbid anyone else to use, share and improve
  362. X  what you give them.   Help stamp out software-hoarding!
  363. X*/
  364. X/* $Id: bam.h,v 1.8 1992/07/02 00:57:44 sbo Exp $ */
  365. X
  366. X#ifndef _BAM_H_
  367. X#define _BAM_H_
  368. X
  369. X/*#include <stdlib.h>*/
  370. X/*#include <unistd.h>*/
  371. X
  372. X#include <stdio.h>
  373. X
  374. X#ifdef XVIEW
  375. X
  376. X#include <xview/xview.h>
  377. X#include <xview/screen.h>
  378. X#include <xview/frame.h>
  379. X#include <xview/panel.h>
  380. X#include <xview/openmenu.h>
  381. X
  382. X#else
  383. X
  384. X#include <X11/Intrinsic.h>
  385. X#include <X11/StringDefs.h>
  386. X#include <X11/Xatom.h>
  387. X#include <X11/Xaw/MenuButton.h>
  388. X#include <X11/Xaw/SimpleMenu.h>
  389. X#include <X11/Xaw/Sme.h>
  390. X#include <X11/Xaw/SmeBSB.h>
  391. X#include <X11/Xaw/Form.h>
  392. X#include <X11/Xaw/Box.h>
  393. X#include "GrabAndManage.h"
  394. X#include <X11/Xaw/Paned.h>
  395. X
  396. X#include <X11/Xaw/Cardinals.h>
  397. Xtypedef Widget Frame;
  398. Xtypedef Widget Panel;
  399. Xtypedef Widget Panel_item;
  400. Xtypedef Widget Menu;
  401. Xtypedef Widget Menu_item;
  402. Xextern Widget baseFrame;
  403. Xextern Widget gam;
  404. Xextern int grab;
  405. Xextern char*windowName;
  406. Xextern XtTranslations button_xt;
  407. Xextern Widget mainFrame;
  408. Xextern Widget pops[200]; /* Sorry no more than 200 submenus */
  409. Xextern int pops_nr;
  410. X
  411. X#endif
  412. X
  413. X
  414. X
  415. X#include "config.h"
  416. X#include "paths.h"
  417. X
  418. X/*define temporaire */
  419. X#define SCROLLBAR_KEY 1000
  420. X#define MENU_KEY      1001
  421. X#define PANEL_KEY     1002
  422. X/* ---------------------------------- */
  423. X
  424. X#define TRUE             1
  425. X#define FALSE             0
  426. X
  427. X#define M_COMMAND_STRING     100
  428. X
  429. X/* ---------------------------------- */
  430. X
  431. Xtypedef struct {
  432. X  Frame frame;
  433. X  Panel panel;
  434. X  int buttonNameIndex;
  435. X  int buttonActionIndex;
  436. X  Panel_item button;
  437. X} ButtonData;
  438. X
  439. Xtypedef struct {
  440. X  struct {
  441. X    int pushpin;
  442. X    char *title;
  443. X  } attr;
  444. X  int defaultChoice;
  445. X  int curItem;
  446. X  Menu id;
  447. X  Menu prevCur; /* Previous current menu */
  448. X  Panel_item button;  /* athena only */
  449. X} MenuData;
  450. X#define DEFAULT_MENU_DATA_VALUE {{TRUE, ""}, 1, 1, NULL, NULL, NULL}
  451. X#ifdef _BAM_MAIN_
  452. XMenuData defaultMenuDataValue=DEFAULT_MENU_DATA_VALUE;
  453. X#else
  454. Xextern MenuData defaultMenuDataValue;
  455. X#endif
  456. X
  457. X
  458. Xtypedef struct {
  459. X  struct {
  460. X    int showResizeCorner;
  461. X    char *iconFileName;
  462. X    char *iconLabel;
  463. X    char *title;
  464. X  } attr;
  465. X  Frame id;
  466. X  Frame prevCur; /* Previous current frame @@Unused */
  467. X}FrameData;
  468. X#define DEFAULT_FRAME_DATA_VALUE {{FALSE, NULL, NULL, ""}, NULL, NULL}
  469. X#ifdef _BAM_MAIN_
  470. XFrameData defaultFrameDataValue=DEFAULT_FRAME_DATA_VALUE;
  471. X#else
  472. Xextern FrameData defaultFrameDataValue;
  473. X#endif
  474. X
  475. X/* ---------------------------------- */
  476. X/* Fonction Prototypes              */
  477. X
  478. Xvoid sendToEmacs();
  479. Xvoid sendErrorToEmacs();
  480. X
  481. Xvoid menuProc();
  482. Xint selected();
  483. X
  484. Xint processArgs();
  485. X
  486. Xvoid printMenuDataStruct();
  487. Xvoid initMenuData();
  488. Xint setMenu();
  489. Xvoid menuUp();
  490. X
  491. Xchar *getFileName();
  492. X
  493. X/* ---------------------------------- */
  494. X/* Global variables                   */
  495. X
  496. Xextern Frame baseFrame;
  497. Xextern FILE *yyin;
  498. Xextern char *menuFile;
  499. Xextern char *errorFormat;
  500. Xextern int menuDebug;
  501. Xextern char *bitmapsPath;
  502. Xextern FILE *debugFp;
  503. Xextern int finalExit;
  504. Xextern int noAuthorFrame;
  505. X
  506. X#endif
  507. X
  508. END_OF_FILE
  509. if test 3811 -ne `wc -c <'bam-2.0/bam.h'`; then
  510.     echo shar: \"'bam-2.0/bam.h'\" unpacked with wrong size!
  511. fi
  512. # end of 'bam-2.0/bam.h'
  513. fi
  514. if test -f 'bam-2.0/filenames.c' -a "${1}" != "-c" ; then 
  515.   echo shar: Will not clobber existing file \"'bam-2.0/filenames.c'\"
  516. else
  517. echo shar: Extracting \"'bam-2.0/filenames.c'\" \(4128 characters\)
  518. sed "s/^X//" >'bam-2.0/filenames.c' <<'END_OF_FILE'
  519. X/*   bam - the Born Again Menus for GNU Emacs.
  520. X   Copyright (C) 1992 Stephane Boucher.
  521. X
  522. X    This program is free software; you can redistribute it and/or modify
  523. X    it under the terms of the GNU General Public License as published by
  524. X    the Free Software Foundation; either version 1, or (at your option)
  525. X    any later version.
  526. X
  527. X    This program is distributed in the hope that it will be useful,
  528. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  529. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  530. X    GNU General Public License for more details.
  531. X
  532. X    You should have received a copy of the GNU General Public License
  533. X    along with this program; if not, write to the Free Software
  534. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  535. X
  536. X  In other words, you are welcome to use, share and improve this program.
  537. X  You are forbidden to forbid anyone else to use, share and improve
  538. X  what you give them.   Help stamp out software-hoarding!
  539. X*/
  540. X/* $Id: filenames.c,v 1.4 1992/07/27 23:06:26 sbo Exp $ */
  541. X
  542. X#include <string.h>
  543. X
  544. X#include "bam.h"
  545. X
  546. X/* Search for a file that exist and have the permission specified. The
  547. X   search is done by concatenating the filename with each path in the
  548. X   primary list of paths seperated by ':', and then the alternate list of
  549. X   paths until a file that satisfies the the specified permission is
  550. X   found. If the filename given is absolute (starting with '/'), then the
  551. X   path lists are not used 
  552. X   
  553. X   A return Value of NULL means an error occured.
  554. X   
  555. X   A return Value of "" means no file was found. 
  556. X   
  557. X   The string returned is newly allocated (including ""). It must
  558. X   therefore be freed.
  559. X   */
  560. X
  561. Xchar *getFileName(filename, perm, primaryPathList, secondaryPathList)
  562. X     char *filename;
  563. X     int perm;
  564. X     char *primaryPathList;
  565. X     char *secondaryPathList;
  566. X{
  567. X  char tmpFileName[MAX_FILE_NAME_LEN+1];
  568. X  char *startOfPath;
  569. X  char *endOfPath;
  570. X  char savedChar;
  571. X  char *returnValue=NULL;
  572. X  int step=0;
  573. X  int loopFinished=0;
  574. X  
  575. X  if (filename[0]=='/') {
  576. X    /* Filename is absolute. There's no need to check against
  577. X       path lists */
  578. X    if (access(filename, perm)==0)
  579. X      returnValue=strdup(filename);
  580. X    else
  581. X      returnValue=strdup("");
  582. X  }
  583. X
  584. X  else {
  585. X    step=0;
  586. X    
  587. X    /* Do the various steps.
  588. X
  589. X       Step 0 is to use primaryPathList
  590. X
  591. X       Step 1 is to use secondaryPathList
  592. X
  593. X       Step 2 is to use the filename as is (the filename is relative
  594. X       since it would have been treated in the first if above for the case of
  595. X       absolute filename */
  596. X
  597. X    loopFinished=0;
  598. X    while (1) {
  599. X      switch(step) {
  600. X    /* Step 0 */
  601. X      case 0:
  602. X    if (primaryPathList!=NULL) {
  603. X      startOfPath=primaryPathList;
  604. X      step++;
  605. X      break;
  606. X    }
  607. X    /* No break was put here So that if primaryPathList is NULL
  608. X       the function will proceed with the next step */
  609. X
  610. X    /* Step 1 */
  611. X      case 1:
  612. X    if (secondaryPathList!=NULL) {
  613. X      startOfPath=secondaryPathList;
  614. X      step++;
  615. X      break;
  616. X    }
  617. X    /* No break was put here So that if secondaryPathList is NULL
  618. X       the function will proceed with the next step */
  619. X
  620. X    /* Step 2 */
  621. X      case 2:
  622. X    if (access(filename, perm)==0)
  623. X      returnValue=strdup(filename);
  624. X    else
  625. X      returnValue=strdup("");
  626. X    loopFinished=1;
  627. X    break;
  628. X      }
  629. X
  630. X      if (loopFinished)
  631. X    break;
  632. X
  633. X      while (1) {
  634. X    if (startOfPath[0]=='\0')
  635. X        break;
  636. X
  637. X    endOfPath=strchr(startOfPath, ':');
  638. X    savedChar='\0';
  639. X    if (endOfPath!=NULL) {
  640. X      savedChar=*endOfPath;
  641. X      *endOfPath='\0';
  642. X    }
  643. X    if (strlen(startOfPath)+strlen(filename)+1 <= MAX_FILE_NAME_LEN) {
  644. X      sprintf(&(tmpFileName[0]), "%s/%s", startOfPath, filename);
  645. X    }
  646. X    else
  647. X      tmpFileName[0]='\0';
  648. X
  649. X    if (savedChar!='\0') {
  650. X      *endOfPath=savedChar;
  651. X      startOfPath=endOfPath+1;
  652. X    }
  653. X    else
  654. X      startOfPath=strchr(startOfPath, '\0');
  655. X
  656. X    if (tmpFileName[0]!='\0' && access(tmpFileName, perm)==0) {
  657. X      returnValue=strdup(tmpFileName);
  658. X      break;
  659. X    }
  660. X    else {
  661. X      /* No need to check the filename. It can't exist since
  662. X         it is longer than the allowed maximum length for a filename */
  663. X    }
  664. X      }
  665. X
  666. X      /* If something was found than exit the main loop */
  667. X      if (returnValue!=NULL)
  668. X    break;
  669. X    }
  670. X  }
  671. X  
  672. X  return(returnValue);
  673. X}
  674. END_OF_FILE
  675. if test 4128 -ne `wc -c <'bam-2.0/filenames.c'`; then
  676.     echo shar: \"'bam-2.0/filenames.c'\" unpacked with wrong size!
  677. fi
  678. # end of 'bam-2.0/filenames.c'
  679. fi
  680. if test -f 'bam-2.0/icon.c' -a "${1}" != "-c" ; then 
  681.   echo shar: Will not clobber existing file \"'bam-2.0/icon.c'\"
  682. else
  683. echo shar: Extracting \"'bam-2.0/icon.c'\" \(2106 characters\)
  684. sed "s/^X//" >'bam-2.0/icon.c' <<'END_OF_FILE'
  685. X/*   bam - the Born Again Menus for GNU Emacs.
  686. X   Copyright (C) 1992 Stephane Boucher.
  687. X
  688. X    This program is free software; you can redistribute it and/or modify
  689. X    it under the terms of the GNU General Public License as published by
  690. X    the Free Software Foundation; either version 1, or (at your option)
  691. X    any later version.
  692. X
  693. X    This program is distributed in the hope that it will be useful,
  694. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  695. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  696. X    GNU General Public License for more details.
  697. X
  698. X    You should have received a copy of the GNU General Public License
  699. X    along with this program; if not, write to the Free Software
  700. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  701. X
  702. X  In other words, you are welcome to use, share and improve this program.
  703. X  You are forbidden to forbid anyone else to use, share and improve
  704. X  what you give them.   Help stamp out software-hoarding!
  705. X*/
  706. X/* $Id: icon.c,v 1.3 1992/03/30 20:50:23 sbo Exp $ */
  707. X
  708. X#include <unistd.h>
  709. X#include "bam.h"
  710. X
  711. XIcon makeIcon(iconFileName, iconLabel)
  712. X     char *iconFileName;
  713. X     char *iconLabel;
  714. X{
  715. X  Server_image serverImage;
  716. X  Icon icon=NULL;       /* By default there's an error */
  717. X  char *bitmapFileName;
  718. X  
  719. X  if (iconFileName==NULL) {
  720. X    icon=xv_create(NULL, ICON,
  721. X           XV_LABEL, iconLabel,
  722. X           NULL);
  723. X  }
  724. X  else {
  725. X    strStorePut(bitmapFileName=
  726. X        getFileName(iconFileName, 
  727. X                R_OK, 
  728. X                bitmapsPath, 
  729. X                DEFAULT_BITMAPS_PATH));
  730. X
  731. X    if (bitmapFileName==NULL) {
  732. X     /* Internal error */
  733. X      sendErrorToEmacs("Internal Error While Trying to Find the File: %s", 
  734. X               iconFileName);
  735. X    }
  736. X    else if (strcmp(bitmapFileName, "")==0) {
  737. X      /* No file was found */
  738. X      sendErrorToEmacs("Unaccessible File: %s", iconFileName);
  739. X    }
  740. X    else {
  741. X      serverImage=(Server_image)
  742. X    xv_create(NULL, SERVER_IMAGE,
  743. X          SERVER_IMAGE_BITMAP_FILE, bitmapFileName,
  744. X          NULL);
  745. X      icon=
  746. X    xv_create(NULL, ICON,
  747. X          XV_LABEL, iconLabel,
  748. X          ICON_IMAGE, serverImage,
  749. X          MENU_RELEASE_IMAGE,
  750. X          NULL);
  751. X    }
  752. X  }
  753. X  return(icon);
  754. X}
  755. END_OF_FILE
  756. if test 2106 -ne `wc -c <'bam-2.0/icon.c'`; then
  757.     echo shar: \"'bam-2.0/icon.c'\" unpacked with wrong size!
  758. fi
  759. # end of 'bam-2.0/icon.c'
  760. fi
  761. if test -f 'bam-2.0/menus/emacs-base-ol.el' -a "${1}" != "-c" ; then 
  762.   echo shar: Will not clobber existing file \"'bam-2.0/menus/emacs-base-ol.el'\"
  763. else
  764. echo shar: Extracting \"'bam-2.0/menus/emacs-base-ol.el'\" \(2907 characters\)
  765. sed "s/^X//" >'bam-2.0/menus/emacs-base-ol.el' <<'END_OF_FILE'
  766. X;   bam - the Born Again Menus for GNU Emacs.
  767. X;   Copyright (C) 1992 Marc Paquette.
  768. X;
  769. X;    This program is free software; you can redistribute it and/or modify
  770. X;    it under the terms of the GNU General Public License as published by
  771. X;    the Free Software Foundation; either version 1, or (at your option)
  772. X;    any later version.
  773. X;
  774. X;    This program is distributed in the hope that it will be useful,
  775. X;    but WITHOUT ANY WARRANTY; without even the implied warranty of
  776. X;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  777. X;    GNU General Public License for more details.
  778. X;
  779. X;    You should have received a copy of the GNU General Public License
  780. X;    along with this program; if not, write to the Free Software
  781. X;    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  782. X;
  783. X;  In other words, you are welcome to use, share and improve this program.
  784. X;  You are forbidden to forbid anyone else to use, share and improve
  785. X;  what you give them.   Help stamp out software-hoarding!
  786. X
  787. X; $Id: emacs-base-ol.el,v 1.9 1992/07/27 22:55:57 sbo Exp $
  788. X; @(#)emacs-base-ol.el    1.8 92/04/01
  789. X
  790. X(bam-set-menu-args "emacs-base-ol" 
  791. X           (append (bam-font-option "7x14") 
  792. X               (bam-geometry-option 0 0 1000 300 't)))
  793. X
  794. X(defun bam-emacs-base-ol:find-file ()
  795. X  "Do an equivalent of a find-file but from a BAM menu and with no arguments.
  796. XIt checks for special actions to take depending of the current
  797. Xmode."
  798. X  (cond ((and (eq major-mode 'dired-mode)
  799. X          (dired-get-filename nil 'no-error-if-not-filep))
  800. X     (call-interactively 'dired-find-file))
  801. X    ((eq major-mode 'Electric-buffer-menu-mode)
  802. X     (call-interactively 'Electric-buffer-menu-select))
  803. X    (t (call-interactively 'find-file))))
  804. X
  805. X(defun bam-emacs-base-ol:dired ()
  806. X  "Do an equivalent of a dired but from a BAM menu.
  807. XCheck for special actions to do depending of the current mode."
  808. X  (cond ((eq major-mode 'dired-mode)
  809. X     (let ((entry (dired-get-filename 'no-dir t)))
  810. X       (cond ((null entry)
  811. X          (call-interactively 'dired))
  812. X         ((not (file-directory-p entry))
  813. X          (call-interactively 'dired-view-file))
  814. X         ((file-directory-p entry)
  815. X          (call-interactively 'dired-find-file))
  816. X         (t (call-interactively 'dired)))))
  817. X    (t (call-interactively 'dired))))
  818. X
  819. X(defun bam-emacs-base-ol:save-buffer ()
  820. X  "Do an equivalent of a save-buffer but from a BAM menu."
  821. X  (call-interactively 'save-buffer))
  822. X
  823. X(defun bam-emacs-base-ol:write-file ()
  824. X  "Do an equivalent of a write-file but from a BAM menu.
  825. XCheck for special actions to do depending of the current mode."
  826. X  (cond ((eq major-mode 'dired-mode)
  827. X     (message "Current buffer is a dired buffer."))
  828. X    (t (call-interactively write-file))))
  829. X
  830. X(defun bam-emacs-base-ol:insert-file ()
  831. X  "Do an equivalent of a insert-file but from a BAM menu.
  832. XCheck for special actions to do depending of the current mode."
  833. X  (cond ((eq major-mode 'dired-mode)
  834. X     (message "Current buffer is a dired buffer."))
  835. X    (t (call-interactively insert-file))))
  836. X
  837. X     
  838. END_OF_FILE
  839. if test 2907 -ne `wc -c <'bam-2.0/menus/emacs-base-ol.el'`; then
  840.     echo shar: \"'bam-2.0/menus/emacs-base-ol.el'\" unpacked with wrong size!
  841. fi
  842. # end of 'bam-2.0/menus/emacs-base-ol.el'
  843. fi
  844. if test -f 'bam-2.0/scanner.l' -a "${1}" != "-c" ; then 
  845.   echo shar: Will not clobber existing file \"'bam-2.0/scanner.l'\"
  846. else
  847. echo shar: Extracting \"'bam-2.0/scanner.l'\" \(2816 characters\)
  848. sed "s/^X//" >'bam-2.0/scanner.l' <<'END_OF_FILE'
  849. X%{
  850. X/*   bam - the Born Again Menus for GNU Emacs.
  851. X   Copyright (C) 1992 Stephane Boucher.
  852. X
  853. X    This program is free software; you can redistribute it and/or modify
  854. X    it under the terms of the GNU General Public License as published by
  855. X    the Free Software Foundation; either version 1, or (at your option)
  856. X    any later version.
  857. X
  858. X    This program is distributed in the hope that it will be useful,
  859. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  860. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  861. X    GNU General Public License for more details.
  862. X
  863. X    You should have received a copy of the GNU General Public License
  864. X    along with this program; if not, write to the Free Software
  865. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  866. X
  867. X  In other words, you are welcome to use, share and improve this program.
  868. X  You are forbidden to forbid anyone else to use, share and improve
  869. X  what you give them.   Help stamp out software-hoarding!
  870. X%}
  871. X%{ -*-c-*-
  872. X/* $Id: scanner.l,v 1.11 1992/07/27 23:04:06 sbo Exp $ */
  873. X
  874. X/* 
  875. X  Please note that sun's cc,lex and X11/Xutil.h doesn't get along at all 
  876. X  You will have to change one of them (or replace input()
  877. X  in scanner.c with some other name.
  878. X*/
  879. X
  880. X#include <string.h>
  881. X
  882. X#include "bam.h"
  883. X#include "parser.h"
  884. X
  885. X%}
  886. X
  887. X%%
  888. X
  889. X"BUTTON"    {return(BUTTON_TOK);}
  890. X"FRAME"         {return(FRAME_TOK);}
  891. X"TITLE"         {return(TITLE_TOK);}
  892. X"LABEL"         {return(LABEL_TOK);}
  893. X"PANEL"            {return(PANEL_TOK);}
  894. X"MENU"            {return(MENU_TOK);}
  895. X"END"        {return(END_TOK);}
  896. X"TEXT"         {return(TEXT_TOK);}
  897. X"BITMAP"        {return(BITMAP_TOK);} 
  898. X"PUSHPIN"    {return(PUSHPIN_TOK);}
  899. X%{
  900. X/*"RESIZE_CORNER" {return(RESIZE_CORNER_TOK);}*/
  901. X%}
  902. X"ICON_FILE_NAME" {return(ICON_FILE_NAME);}
  903. X"ICON_LABEL"    {return(ICON_LABEL_TOK);}
  904. X"TRUE"          {return(TRUE_TOK);}
  905. X"FALSE"         {return(FALSE_TOK);}
  906. X"DEFAULT"       {return(DEFAULT_TOK);}
  907. X
  908. X"\""(([\\]"\"")|([\\][\\])|[^"])*"\"" { 
  909. X        char *ptRead, *ptWrite;
  910. X
  911. X    /* Enlever le " de la fin */
  912. X    yytext[strlen(yytext)-1]='\0';
  913. X
  914. X    /*    voir p 261 pour allocation */
  915. X    yylval.str=strdup(&yytext[1]);
  916. X
  917. X    /* substitute \" by " and \\ by \ */
  918. X        for (ptRead=yylval.str, ptWrite=yylval.str;
  919. X             *ptRead!='\0';
  920. X             ptRead++, ptWrite++) {
  921. X          if (*ptRead=='\\') {
  922. X            switch(*(ptRead+1)) {
  923. X        case '\\':
  924. X        case '"':
  925. X          ptRead++;
  926. X          *ptWrite=*ptRead;
  927. X              break;
  928. X
  929. X        default:
  930. X          *ptWrite=*ptRead;
  931. X            }
  932. X          }
  933. X          else {
  934. X            *ptWrite=*ptRead;
  935. X          }
  936. X        }
  937. X    *ptWrite='\0';
  938. X
  939. X    return(STRING);
  940. X} 
  941. X
  942. X%{
  943. X/*[ ]    {return((int)(yytext[0]));}*/
  944. X%}
  945. X
  946. X"#".*$  {/*Commentaire*/}
  947. X[ \t\n] {/*Inhiber les caracteres blancs*/}
  948. X
  949. X. {return(ERROR_TOK);}
  950. X
  951. X%%
  952. X
  953. Xyyerror(str)
  954. X     char *str;
  955. X{
  956. X  sendErrorToEmacs("%d:%s\n", yylineno, str);
  957. X  return(0);
  958. X}
  959. END_OF_FILE
  960. if test 2816 -ne `wc -c <'bam-2.0/scanner.l'`; then
  961.     echo shar: \"'bam-2.0/scanner.l'\" unpacked with wrong size!
  962. fi
  963. # end of 'bam-2.0/scanner.l'
  964. fi
  965. if test -f 'bam-2.0/strstore.c' -a "${1}" != "-c" ; then 
  966.   echo shar: Will not clobber existing file \"'bam-2.0/strstore.c'\"
  967. else
  968. echo shar: Extracting \"'bam-2.0/strstore.c'\" \(3471 characters\)
  969. sed "s/^X//" >'bam-2.0/strstore.c' <<'END_OF_FILE'
  970. X/*   bam - the Born Again Menus for GNU Emacs.
  971. X   Copyright (C) 1992 Stephane Boucher.
  972. X
  973. X    This program is free software; you can redistribute it and/or modify
  974. X    it under the terms of the GNU General Public License as published by
  975. X    the Free Software Foundation; either version 1, or (at your option)
  976. X    any later version.
  977. X
  978. X    This program is distributed in the hope that it will be useful,
  979. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  980. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  981. X    GNU General Public License for more details.
  982. X
  983. X    You should have received a copy of the GNU General Public License
  984. X    along with this program; if not, write to the Free Software
  985. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  986. X
  987. X  In other words, you are welcome to use, share and improve this program.
  988. X  You are forbidden to forbid anyone else to use, share and improve
  989. X  what you give them.   Help stamp out software-hoarding!
  990. X*/
  991. X/* $Id: strstore.c,v 1.3 1992/03/30 20:50:11 sbo Exp $ */
  992. X
  993. X#include "strstore.h"
  994. X
  995. X
  996. Xint strStoreInitialized=FALSE;
  997. Xint strStoreNextAvail=0;
  998. Xchar **strStoreVector=NULL;
  999. Xint strStoreVectorSize=0;
  1000. X
  1001. Xint strStorePut(str)
  1002. X     char *str;
  1003. X{
  1004. X  int returnValue=STR_STORE_OK;
  1005. X  char **newVector;
  1006. X
  1007. X  if (strStoreNextAvail>=strStoreVectorSize) {
  1008. X    /* Not enough Vector Space left */
  1009. X    
  1010. X    strStoreVectorSize+=INITIAL_STR_STORE_VECTOR_SIZE;
  1011. X    newVector=(char **)realloc(strStoreVector, 
  1012. X                   sizeof(char*)*strStoreVectorSize);
  1013. X      
  1014. X    if (newVector==NULL) {
  1015. X      strStoreVectorSize-=INITIAL_STR_STORE_VECTOR_SIZE;
  1016. X      returnValue=STR_STORE_ERR;
  1017. X    }
  1018. X    else {
  1019. X      strStoreVector=newVector;
  1020. X    }
  1021. X  }
  1022. X  
  1023. X  if (returnValue!=STR_STORE_ERR) {
  1024. X    strStoreVector[strStoreNextAvail]=str;
  1025. X    returnValue=strStoreNextAvail;
  1026. X    strStoreNextAvail++;
  1027. X  }
  1028. X  
  1029. X  return(returnValue);
  1030. X}
  1031. X
  1032. Xchar *strStoreGet(strIndex)
  1033. X     int strIndex;
  1034. X{
  1035. X  /* Bogus. Peu utile puisque les utilisateurs de la librairie ne connaissent
  1036. X     jamais l'index de la chaine de car. */
  1037. X  char *returnValue=NULL;
  1038. X  
  1039. X  if (strIndex<strStoreNextAvail)
  1040. X    returnValue=strStoreVector[strIndex];
  1041. X  
  1042. X  return(returnValue);
  1043. X}
  1044. X
  1045. Xint strStoreFree()
  1046. X{
  1047. X  int index;
  1048. X  
  1049. X  index=strStoreNextAvail-1;
  1050. X  while (index>=0) {
  1051. X    if (strStoreVector[index]!=NULL) {
  1052. X      free(strStoreVector[index]);
  1053. X      strStoreVector[index]=NULL;
  1054. X    }
  1055. X    index--;
  1056. X  }
  1057. X  strStoreNextAvail=0;
  1058. X}
  1059. X
  1060. Xint strStoreOpen()
  1061. X{
  1062. X  int returnValue=STR_STORE_OK;
  1063. X  
  1064. X  if (strStoreInitialized) {
  1065. X    fprintf(stderr, "String Storing facilities Already Initialized\n");
  1066. X    returnValue=STR_STORE_ERR;
  1067. X  }
  1068. X  else {
  1069. X    if (strStoreVector==NULL) {
  1070. X      strStoreVector=(char **)malloc(sizeof(char*)*
  1071. X                     (INITIAL_STR_STORE_VECTOR_SIZE));
  1072. X      if (strStoreVector==NULL) {
  1073. X    fprintf(stderr, "Memory Allocation Error\n");
  1074. X    returnValue=STR_STORE_ERR;
  1075. X      }
  1076. X      else {
  1077. X    strStoreVectorSize=INITIAL_STR_STORE_VECTOR_SIZE;
  1078. X    strStoreVector[0]=NULL;
  1079. X    strStoreNextAvail=0;
  1080. X    strStoreInitialized=TRUE;
  1081. X      }
  1082. X    }
  1083. X    else {
  1084. X      fprintf(stderr, "strStore module already initialized\n");
  1085. X      returnValue=STR_STORE_ERR;
  1086. X    }
  1087. X  }
  1088. X  return(returnValue);
  1089. X}
  1090. X
  1091. X
  1092. Xint strStoreClose()
  1093. X{
  1094. X  int returnValue=STR_STORE_OK;
  1095. X  
  1096. X  if (strStoreInitialized) {
  1097. X    strStoreFree();
  1098. X    free(strStoreVector);
  1099. X    strStoreVector=NULL;
  1100. X    strStoreVectorSize=0;
  1101. X    strStoreNextAvail=0;
  1102. X    strStoreInitialized=FALSE;
  1103. X  }
  1104. X  else {
  1105. X    fprintf(stderr, "StrStore Module not initialized\n");
  1106. X  }
  1107. X}
  1108. END_OF_FILE
  1109. if test 3471 -ne `wc -c <'bam-2.0/strstore.c'`; then
  1110.     echo shar: \"'bam-2.0/strstore.c'\" unpacked with wrong size!
  1111. fi
  1112. # end of 'bam-2.0/strstore.c'
  1113. fi
  1114. echo shar: End of archive 2 \(of 7\).
  1115. cp /dev/null ark2isdone
  1116. MISSING=""
  1117. for I in 1 2 3 4 5 6 7 ; do
  1118.     if test ! -f ark${I}isdone ; then
  1119.     MISSING="${MISSING} ${I}"
  1120.     fi
  1121. done
  1122. if test "${MISSING}" = "" ; then
  1123.     echo You have unpacked all 7 archives.
  1124.     rm -f ark[1-9]isdone
  1125. else
  1126.     echo You still need to unpack the following archives:
  1127.     echo "        " ${MISSING}
  1128. fi
  1129. ##  End of shell archive.
  1130. exit 0
  1131.  
  1132. exit 0 # Just in case...
  1133.