home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume31 / bam / part02 < prev    next >
Encoding:
Text File  |  1992-07-30  |  31.9 KB  |  1,127 lines

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