home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume18 / bibview / part05 < prev    next >
Encoding:
Text File  |  1992-08-26  |  50.3 KB  |  1,573 lines

  1. Path: uunet!dtix!darwin.sura.net!mips!msi!dcmartin
  2. From: liebla@informatik.tu-muenchen.de (Armin Liebl)
  3. Newsgroups: comp.sources.x
  4. Subject: v18i103: bibview - BibTeX GUI, Part05/20
  5. Message-ID: <1992Aug27.161434.25344@msi.com>
  6. Date: 27 Aug 92 16:14:34 GMT
  7. References: <csx-18i099-bibview@uunet.UU.NET>
  8. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  9. Organization: Molecular Simulations, Inc.
  10. Lines: 1559
  11. Approved: dcmartin@msi.com
  12. Originator: dcmartin@fascet
  13.  
  14. Submitted-by: Armin Liebl <liebla@informatik.tu-muenchen.de>
  15. Posting-number: Volume 18, Issue 103
  16. Archive-name: bibview/part05
  17.  
  18. #!/bin/sh
  19. # this is part.05 (part 5 of a multipart archive)
  20. # do not concatenate these parts, unpack them in order with /bin/sh
  21. # file bib_flex.c continued
  22. #
  23. if test ! -r _shar_seq_.tmp; then
  24.     echo 'Please unpack part 1 first!'
  25.     exit 1
  26. fi
  27. (read Scheck
  28.  if test "$Scheck" != 5; then
  29.     echo Please unpack part "$Scheck" next!
  30.     exit 1
  31.  else
  32.     exit 0
  33.  fi
  34. ) < _shar_seq_.tmp || exit 1
  35. if test ! -f _shar_wnt_.tmp; then
  36.     echo 'x - still skipping bib_flex.c'
  37. else
  38. echo 'x - continuing file bib_flex.c'
  39. sed 's/^X//' << 'SHAR_EOF' >> 'bib_flex.c' &&
  40. X    { /* need to shift things up to make room */
  41. X    register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  42. X    register YY_CHAR *dest =
  43. X        &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
  44. X    register YY_CHAR *source =
  45. X        &yy_current_buffer->yy_ch_buf[number_to_move];
  46. X
  47. X    while ( source > yy_current_buffer->yy_ch_buf )
  48. X        *--dest = *--source;
  49. X
  50. X    yy_cp += dest - source;
  51. X    yy_bp += dest - source;
  52. X    yy_n_chars = yy_current_buffer->yy_buf_size;
  53. X
  54. X    if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  55. X        YY_FATAL_ERROR( "flex scanner push-back overflow" );
  56. X    }
  57. X
  58. X    if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  59. X    yy_cp[-2] = '\n';
  60. X
  61. X    *--yy_cp = c;
  62. X
  63. X    /* note: the formal parameter *must* be called "yy_bp" for this
  64. X     *       macro to now work correctly
  65. X     */
  66. X    YY_DO_BEFORE_ACTION; /* set up yytext again */
  67. X    }
  68. X
  69. X
  70. #ifdef __cplusplus
  71. static int yyinput()
  72. #else
  73. static int input()
  74. #endif
  75. X
  76. X    {
  77. X    int c;
  78. X    YY_CHAR *yy_cp = yy_c_buf_p;
  79. X
  80. X    *yy_cp = yy_hold_char;
  81. X
  82. X    if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  83. X    {
  84. X    /* yy_c_buf_p now points to the character we want to return.
  85. X     * If this occurs *before* the EOB characters, then it's a
  86. X     * valid NUL; if not, then we've hit the end of the buffer.
  87. X     */
  88. X    if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  89. X        /* this was really a NUL */
  90. X        *yy_c_buf_p = '\0';
  91. X
  92. X    else
  93. X        { /* need more input */
  94. X        yytext = yy_c_buf_p;
  95. X        ++yy_c_buf_p;
  96. X
  97. X        switch ( yy_get_next_buffer() )
  98. X        {
  99. X        case EOB_ACT_END_OF_FILE:
  100. X            {
  101. X            if ( yywrap() )
  102. X            {
  103. X            yy_c_buf_p = yytext + YY_MORE_ADJ;
  104. X            return ( EOF );
  105. X            }
  106. X
  107. X            YY_NEW_FILE;
  108. X
  109. #ifdef __cplusplus
  110. X            return ( yyinput() );
  111. #else
  112. X            return ( input() );
  113. #endif
  114. X            }
  115. X            break;
  116. X
  117. X        case EOB_ACT_CONTINUE_SCAN:
  118. X            yy_c_buf_p = yytext + YY_MORE_ADJ;
  119. X            break;
  120. X
  121. X        case EOB_ACT_LAST_MATCH:
  122. #ifdef __cplusplus
  123. X            YY_FATAL_ERROR( "unexpected last match in yyinput()" );
  124. #else
  125. X            YY_FATAL_ERROR( "unexpected last match in input()" );
  126. #endif
  127. X        }
  128. X        }
  129. X    }
  130. X
  131. X    c = *yy_c_buf_p;
  132. X    yy_hold_char = *++yy_c_buf_p;
  133. X
  134. X    return ( c );
  135. X    }
  136. X
  137. X
  138. #ifdef YY_USE_PROTOS
  139. void yyrestart( FILE *input_file )
  140. #else
  141. void yyrestart( input_file )
  142. FILE *input_file;
  143. #endif
  144. X
  145. X    {
  146. X    yy_init_buffer( yy_current_buffer, input_file );
  147. X    yy_load_buffer_state();
  148. X    }
  149. X
  150. X
  151. #ifdef YY_USE_PROTOS
  152. void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  153. #else
  154. void yy_switch_to_buffer( new_buffer )
  155. YY_BUFFER_STATE new_buffer;
  156. #endif
  157. X
  158. X    {
  159. X    if ( yy_current_buffer == new_buffer )
  160. X    return;
  161. X
  162. X    if ( yy_current_buffer )
  163. X    {
  164. X    /* flush out information for old buffer */
  165. X    *yy_c_buf_p = yy_hold_char;
  166. X    yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  167. X    yy_current_buffer->yy_n_chars = yy_n_chars;
  168. X    }
  169. X
  170. X    yy_current_buffer = new_buffer;
  171. X    yy_load_buffer_state();
  172. X
  173. X    /* we don't actually know whether we did this switch during
  174. X     * EOF (yywrap()) processing, but the only time this flag
  175. X     * is looked at is after yywrap() is called, so it's safe
  176. X     * to go ahead and always set it.
  177. X     */
  178. X    yy_did_buffer_switch_on_eof = 1;
  179. X    }
  180. X
  181. X
  182. #ifdef YY_USE_PROTOS
  183. void yy_load_buffer_state( void )
  184. #else
  185. void yy_load_buffer_state()
  186. #endif
  187. X
  188. X    {
  189. X    yy_n_chars = yy_current_buffer->yy_n_chars;
  190. X    yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  191. X    yyin = yy_current_buffer->yy_input_file;
  192. X    yy_hold_char = *yy_c_buf_p;
  193. X    }
  194. X
  195. X
  196. #ifdef YY_USE_PROTOS
  197. YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  198. #else
  199. YY_BUFFER_STATE yy_create_buffer( file, size )
  200. FILE *file;
  201. int size;
  202. #endif
  203. X
  204. X    {
  205. X    YY_BUFFER_STATE b;
  206. X
  207. X    b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );
  208. X
  209. X    if ( ! b )
  210. X    YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  211. X
  212. X    b->yy_buf_size = size;
  213. X
  214. X    /* yy_ch_buf has to be 2 characters longer than the size given because
  215. X     * we need to put in 2 end-of-buffer characters.
  216. X     */
  217. X    b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );
  218. X
  219. X    if ( ! b->yy_ch_buf )
  220. X    YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  221. X
  222. X    yy_init_buffer( b, file );
  223. X
  224. X    return ( b );
  225. X    }
  226. X
  227. X
  228. #ifdef YY_USE_PROTOS
  229. void yy_delete_buffer( YY_BUFFER_STATE b )
  230. #else
  231. void yy_delete_buffer( b )
  232. YY_BUFFER_STATE b;
  233. #endif
  234. X
  235. X    {
  236. X    if ( b == yy_current_buffer )
  237. X    yy_current_buffer = (YY_BUFFER_STATE) 0;
  238. X
  239. X    free( (char *) b->yy_ch_buf );
  240. X    free( (char *) b );
  241. X    }
  242. X
  243. X
  244. #ifdef YY_USE_PROTOS
  245. void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
  246. #else
  247. void yy_init_buffer( b, file )
  248. YY_BUFFER_STATE b;
  249. FILE *file;
  250. #endif
  251. X
  252. X    {
  253. X    b->yy_input_file = file;
  254. X
  255. X    /* we put in the '\n' and start reading from [1] so that an
  256. X     * initial match-at-newline will be true.
  257. X     */
  258. X
  259. X    b->yy_ch_buf[0] = '\n';
  260. X    b->yy_n_chars = 1;
  261. X
  262. X    /* we always need two end-of-buffer characters.  The first causes
  263. X     * a transition to the end-of-buffer state.  The second causes
  264. X     * a jam in that state.
  265. X     */
  266. X    b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  267. X    b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
  268. X
  269. X    b->yy_buf_pos = &b->yy_ch_buf[1];
  270. X
  271. X    b->yy_eof_status = EOF_NOT_SEEN;
  272. X    }
  273. # line 225 "b.l"
  274. X
  275. X
  276. SHAR_EOF
  277. echo 'File bib_flex.c is complete' &&
  278. chmod 0644 bib_flex.c ||
  279. echo 'restore of bib_flex.c failed'
  280. Wc_c="`wc -c < 'bib_flex.c'`"
  281. test 33489 -eq "$Wc_c" ||
  282.     echo 'bib_flex.c: original size 33489, current size' "$Wc_c"
  283. rm -f _shar_wnt_.tmp
  284. fi
  285. # ============= bibview.c ==============
  286. if test -f 'bibview.c' -a X"$1" != X"-c"; then
  287.     echo 'x - skipping bibview.c (File already exists)'
  288.     rm -f _shar_wnt_.tmp
  289. else
  290. > _shar_wnt_.tmp
  291. echo 'x - extracting bibview.c (Text)'
  292. sed 's/^X//' << 'SHAR_EOF' > 'bibview.c' &&
  293. /*********************************************************************/
  294. /*  bibView: Administration of bibTex-Databases                      */
  295. /*           (Verwaltung von bibTeX-Literaturdatenbanken)            */
  296. /*                                                                   */
  297. /*  Module:  bibview.c                                               */
  298. /*                                                                   */
  299. /*             - Main Program                                        */
  300. /*             - Signal Handling                                     */
  301. /*                                                                   */
  302. /*  Author:  Holger Martin,  martinh@informatik.tu-muenchen.de       */
  303. /*           Peter M. Urban, urban@informatik.tu-muenchen.de         */
  304. /*                                                                   */
  305. /*  History:                                                         */
  306. /*    11.22.91  PMU  created                                         */
  307. /*    05.26.92       Version 1.0 released                            */
  308. /*                                                                   */
  309. /*  Copyright 1992 TU MUENCHEN                          */
  310. /*    See ./Copyright for complete rights and liability information. */
  311. /*                                                                   */
  312. /*********************************************************************/
  313. X
  314. X
  315. #include <stdio.h>
  316. #include <unistd.h>
  317. #include <X11/Intrinsic.h>
  318. #include <X11/StringDefs.h>
  319. #include <X11/Shell.h>
  320. #include <X11/Xaw/Form.h>
  321. #include <X11/Xaw/Paned.h>
  322. #include <X11/Xaw/Box.h>
  323. #include <X11/Xaw/Command.h>
  324. #include <X11/Xaw/MenuButton.h>
  325. #include <X11/Xaw/SimpleMenu.h>
  326. #include <X11/Xaw/SmeBSB.h>
  327. #include <X11/Xaw/SmeLine.h>
  328. #include <X11/Xos.h>
  329. #include "bibview.h"
  330. #include "bitmaps/bv_ico64"
  331. #include "bitmaps/bv_lst64"
  332. #include "bitmaps/bv_mac64"
  333. #include "bitmaps/bv_crd64"
  334. #include "bitmaps/bv_hlp64"
  335. #include "bitmaps/bv_ann64"
  336. #include "bitmaps/chkmrk16"
  337. #include "bitmaps/error32"
  338. #include "bitmaps/warn32"
  339. #include "bitmaps/notice32"
  340. #include "bitmaps/quest32"
  341. #ifdef GERMAN
  342. #include "bitmaps/proggerm.xbm"
  343. #else
  344. #include "bitmaps/proginfo.xbm"
  345. #endif
  346. X
  347. X
  348. /* external global variables */
  349. /* ------------------------- */
  350. extern Widget desktop;
  351. extern char *latexHeader, *latexFooter;
  352. extern int latexHeaderLen, latexFooterLen;
  353. X
  354. X
  355. /* exported global variables */
  356. /* ------------------------- */
  357. XXtAppContext app_context;
  358. Widget topLevel;
  359. Pixmap bvIconPixmap;
  360. String bvIconName;
  361. Pixmap lstIconPixmap;
  362. Pixmap macIconPixmap;
  363. Pixmap crdIconPixmap;
  364. Pixmap helpIconPixmap;
  365. Pixmap annoteIconPixmap;
  366. Pixmap chkmarkPixmap;
  367. Pixmap errorPixmap;
  368. Pixmap warnPixmap;
  369. Pixmap noticePixmap;
  370. Pixmap questPixmap;
  371. Pixmap progInfoPixmap;
  372. X
  373. X
  374. /* local global variables */
  375. /* ---------------------- */
  376. X
  377. /* fallback resources */
  378. static char *fallback_resources[424] = {
  379. #ifdef GERMAN
  380. X   #include "fb_ger.h"
  381. #else
  382. X   #include "fb_res.h"
  383. #endif
  384. X   NULL
  385. };
  386. X
  387. X
  388. /* command line options */
  389. typedef struct {
  390. X   Boolean quiet;
  391. X   Boolean iconsOnDesk;
  392. X   Boolean makeBackup;
  393. X   Boolean autoCheck;
  394. X   Boolean reqFields;
  395. X   String  bibfile;
  396. X   String  rcfile;
  397. } OptionsRec;
  398. OptionsRec options;
  399. X
  400. #define Offset(field)  XtOffsetOf(OptionsRec, field)
  401. XXtResource resources[] = {
  402. X   { "quiet", "Quiet", XtRBoolean, sizeof(Boolean),
  403. X        Offset(quiet), XtRImmediate, (XtPointer) FALSE },
  404. X   { "iconsOnDesk", "IconsOnDesk", XtRBoolean, sizeof(Boolean),
  405. X    Offset(iconsOnDesk), XtRImmediate, (XtPointer)FALSE },
  406. X   { "makeBackup", "MakeBackup", XtRBoolean, sizeof(Boolean),
  407. X    Offset(makeBackup), XtRImmediate, (XtPointer)TRUE },
  408. X   { "autoCheck", "AutoCheck", XtRBoolean, sizeof(Boolean),
  409. X    Offset(autoCheck), XtRImmediate, (XtPointer)TRUE },
  410. X   { "reqFields", "ReqFields", XtRBoolean, sizeof(Boolean),
  411. X    Offset(reqFields), XtRImmediate, (XtPointer)FALSE },
  412. X   { "bibfile", "Bibfile", XtRString, sizeof(String),
  413. X    Offset(bibfile), XtRString, (XtPointer)NULL },
  414. X   { "rcfile", "Rcfile", XtRString, sizeof(String),
  415. X    Offset(rcfile), XtRString, (XtPointer)NULL }
  416. };
  417. #undef Offset
  418. X
  419. static XrmOptionDescRec optionDesc[] = {
  420. X   { "-quiet",       "*quiet",       XrmoptionNoArg, (XtPointer)"on" },
  421. X   { "-iconsOnDesk", "*iconsOnDesk", XrmoptionNoArg, (XtPointer)"on" },
  422. X   { "-makeBackup",  "*makeBackup",  XrmoptionNoArg, (XtPointer)"on" },
  423. X   { "-autoCheck",   "*autoCheck",   XrmoptionNoArg, (XtPointer)"on" },
  424. X   { "-reqFields",   "*reqFields",   XrmoptionNoArg, (XtPointer)"on" },
  425. X   { "-file",        "*bibfile",     XrmoptionSepArg, (XtPointer)NULL },
  426. X   { "-rcfile",      "*rcfile",      XrmoptionSepArg, (XtPointer)NULL }
  427. };
  428. X
  429. X
  430. /* local function prototypes */
  431. static void printHelp (int argc, char **argv);
  432. static void processCommandlineOptions (void);
  433. static Boolean readBibfile (XtPointer clientData);
  434. static void makeIconPixmaps (void);
  435. static void installErrorHandlers (void);
  436. static XtErrorHandler Xt_warningHandler (String warn);
  437. static XtErrorHandler Xt_errorHandler (String error);
  438. static int X_errorHandler (Display *dsp, XErrorEvent *event);
  439. static int IO_errorHandler (Display *dsp);
  440. static void signalHandler (int signal, int code);
  441. static Errcode saveDataToTmpFiles (void);
  442. static char *getErrorText (unsigned char code);
  443. X
  444. X
  445. X
  446. /*********************************************************************/
  447. /* MAIN:                                                             */
  448. /*********************************************************************/
  449. int
  450. main(int argc, char *argv[])
  451. {
  452. static char iconname[MAX_ICONNAMELEN+1];
  453. static char *p, path[MAX_FILEPATHLEN+1];
  454. int i, status;
  455. X
  456. X   topLevel = XtVaAppInitialize(&app_context, /* Appl context */
  457. X                 "BibView",                   /* Appl class */
  458. X                 optionDesc,                  /* cmdline options */ 
  459. X         XtNumber(optionDesc),
  460. X                 &argc, argv,                 /* command line args */
  461. X                 (String *)fallback_resources,/* fallback resources */
  462. X         NULL);                       /* end varargs list */
  463. X
  464. X   /* process commandline options */
  465. X   XtGetApplicationResources(topLevel,
  466. X                             (XtPointer) &options,
  467. X                             resources, XtNumber(resources),
  468. X                             (Arg *)NULL, 0);
  469. X   if (argc > 1)
  470. X      printHelp(argc, argv);
  471. X   processCommandlineOptions();
  472. X
  473. X   /* read rc options file */
  474. X   if (options.rcfile != NULL)
  475. X      rcfReadCfgFile(options.rcfile);
  476. X   else if (access(DEFAULT_RCFILE, R_OK) != -1) {
  477. X      /* read file in current directory */
  478. X      rcfReadCfgFile(DEFAULT_RCFILE);
  479. X   }
  480. X   else {
  481. X      /* look for file in $HOME-Directory */
  482. X      if ((p = (char *)getenv("HOME")) != NULL) {
  483. X         strcpy(path, p);
  484. X     strcat(path, "/");
  485. X     strcat(path, DEFAULT_RCFILE);
  486. X     if (access(path, R_OK) != -1)
  487. X        rcfReadCfgFile(path);
  488. X      }
  489. X   }
  490. X
  491. X   /* create icon pixmaps, initialize main icon for bibview */
  492. X   makeIconPixmaps();
  493. X   sprintf(iconname, "%s %d.%d", PROGNAME, VERSION, PATCHLEVEL);
  494. X   bvIconName = iconname;
  495. X   XtVaSetValues(topLevel, 
  496. X         XtNiconPixmap, bvIconPixmap,
  497. X         XtNtitle, bvIconName,
  498. X         XtNiconName, bvIconName, NULL);
  499. X
  500. X   /* instance main window */
  501. X   status = gwmMainWin();
  502. X
  503. X   XtRealizeWidget(topLevel);
  504. /* XtInstallAllAccelerators(topLevel, topLevel); */
  505. X
  506. X   /* load a file from command line */
  507. X   if (options.bibfile != NULL)
  508. X      XtAppAddWorkProc(app_context, readBibfile, options.bibfile);
  509. X
  510. X   rcfSetPrintMode(FALSE);
  511. X   rcfReadOptions(FALSE);
  512. X   XtAppMainLoop(app_context);
  513. }
  514. X
  515. X
  516. X
  517. /*********************************************************************/
  518. /* LOCAL FUNCTIONS                                                   */
  519. /*********************************************************************/
  520. X
  521. /*********************************************************************/
  522. /* printHelp:                                                        */
  523. /*   Process excess options and show help                            */
  524. /*********************************************************************/
  525. static void 
  526. printHelp (int argc, char **argv)
  527. {
  528. static char *help[] = {
  529. X "\n",
  530. X "bibview: Usage\n",
  531. X "         bibview understands all standard Xt command-line options.\n",
  532. X "\n",
  533. X "Additional options are as follows:\n",
  534. X "   Option        Valid Range     Function\n",
  535. X "   -quiet        none            Turn on/off beep on error\n",
  536. X "   -iconsOnDesk  none            Keep icons on bibview desktop\n",
  537. X "   -makeBackup   none            Save files to backup on save\n",
  538. X "   -autoCheck    none            Turn on/off consistency checking\n",
  539. X "   -reqFields    none            Disallow empty required fields\n",
  540. X "   -file         bibTeX File     Load bibTeX-File on startup\n",
  541. X "   -rcfile       bibview rcFile  Use specific configuration file\n",
  542. X "   -help         none            Show this list\n",
  543. X "\n",
  544. X NULL
  545. };
  546. char **p;
  547. int  i;
  548. X
  549. X   /* print help message */
  550. X   p = help;
  551. X   while (*p) {
  552. X      fprintf(stderr, *p);
  553. X      p++;
  554. X   }
  555. X
  556. X   /* show illegal arguments */
  557. X   if (strcmp(argv[1], "-help")) {
  558. X      fprintf(stderr, "bibview: command line option unknown:\n");
  559. X      for (i=1; i < argc; i++)
  560. X         fprintf(stderr, " option: %s\n", argv[i]);
  561. X   }
  562. X   else {
  563. X      /* just show help and exit */
  564. X      exit(0);
  565. X   }
  566. }
  567. X
  568. X
  569. /*********************************************************************/
  570. /* processCommandlineOptions:                                        */
  571. /*   Process options not controlling widgets                         */
  572. /*********************************************************************/
  573. static void 
  574. processCommandlineOptions (void)
  575. {
  576. X   optionsStatus[OPT_BEEP_ON_ERROR]   = !options.quiet;
  577. X   optionsStatus[OPT_BACKUP_ON_SAVE]  = options.makeBackup;
  578. X   optionsStatus[OPT_ICON_ON_DESKTOP] = options.iconsOnDesk;
  579. X   optionsStatus[OPT_AUTO_CHECK_BIB]  = options.autoCheck;
  580. X   optionsStatus[OPT_REQUIRED_FIELDS] = options.reqFields;
  581. }
  582. X
  583. X
  584. /*********************************************************************/
  585. /* readBibfile:                                                      */
  586. /*   Read a bibfile with name given on command line                  */
  587. /*********************************************************************/
  588. static Boolean
  589. readBibfile (XtPointer clientData)
  590. {
  591. String filename = (String)clientData;
  592. BibPtr bp;
  593. Position x;
  594. Errcode status;
  595. X
  596. X   /* check whether desktop positioned already */
  597. X   if (XtWindow(desktop) == (Window) NULL)
  598. X      return(False);
  599. X   XtVaGetValues(topLevel, XtNx, &x, NULL);
  600. X   if (x == 0)
  601. X      return(False);
  602. X
  603. X   /* desktop is there, open file and window */
  604. X   if ((status = glbNewBibListEl(&bp)) != OK) {
  605. X      guwError(status);
  606. X      return(True);
  607. X   }
  608. X   strcpy(bp->filename, filename);
  609. X   if ((filename[0]!='/') && (filename[0]!='~')){
  610. X      getcwd(bp->filepath, MAX_FILEPATHLEN);
  611. X      strcat(bp->filepath, "/");
  612. X      strcat(bp->filepath, filename);
  613. X      }
  614. X   else
  615. X      strcpy(bp->filepath, filename);
  616. X   bp->mw=NULL;
  617. X   bp->ew=NULL;
  618. X
  619. X   if ((status = bifFileRead(bp)) == BIF_EOPEN) {
  620. X      glbDelBibListEl(bp);
  621. X      guwError(status);
  622. X      return(True);
  623. X   }
  624. X   if (status != BIF_OK) {
  625. X      status = gueOpenBibErrWin(bp, (int)status); 
  626. X      if (status == ERR_NOBIB)
  627. X        glbDelBibListEl(bp); 
  628. X      return(True);
  629. X   }
  630. X   if ((status = gubOpenBibWin(bp)) != OK) {
  631. /*      glbDelBibListEl(bp); */
  632. X      guwError(status);
  633. X      return(True);
  634. X   }
  635. X
  636. X
  637. X   /* check cards, if option is on */
  638. X   if (cotAutoCheckBib()) 
  639. X      cseCheckBib(bp, False);      
  640. X
  641. X   return(True);
  642. }
  643. X
  644. X
  645. /*********************************************************************/
  646. /* makeIconPixmaps:                                                  */
  647. /*   Create all pixmaps for application                              */
  648. /*********************************************************************/
  649. static void 
  650. makeIconPixmaps (void)
  651. {
  652. X   bvIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
  653. X                RootWindowOfScreen(XtScreen(topLevel)),
  654. X                (char *)bv_ico64_bits,
  655. X                bv_ico64_width, bv_ico64_height);
  656. X   lstIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
  657. X                RootWindowOfScreen(XtScreen(topLevel)),
  658. X                (char *)bv_lst64_bits,
  659. X                bv_lst64_width, bv_lst64_height);
  660. X   macIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
  661. X                RootWindowOfScreen(XtScreen(topLevel)),
  662. X                (char *)bv_mac64_bits,
  663. X                bv_mac64_width, bv_mac64_height);
  664. X   helpIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
  665. X                RootWindowOfScreen(XtScreen(topLevel)),
  666. X                (char *)bv_help64_bits,
  667. X                bv_help64_width, bv_help64_height);
  668. X   annoteIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
  669. X                RootWindowOfScreen(XtScreen(topLevel)),
  670. X                (char *)bv_annote64_bits,
  671. X                bv_annote64_width, bv_annote64_height);
  672. X   crdIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
  673. X                RootWindowOfScreen(XtScreen(topLevel)),
  674. X                (char *)bv_crd64_bits,
  675. X                bv_crd64_width, bv_crd64_height);
  676. X   chkmarkPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
  677. X                RootWindowOfScreen(XtScreen(topLevel)),
  678. X                (char *)chkmrk16_bits,
  679. X                chkmrk16_width, chkmrk16_height);
  680. X   errorPixmap   = XCreateBitmapFromData(XtDisplay(topLevel),
  681. X                RootWindowOfScreen(XtScreen(topLevel)),
  682. X                (char *)error32_bits,
  683. X                error32_width, error32_height);
  684. X   warnPixmap    = XCreateBitmapFromData(XtDisplay(topLevel),
  685. X                RootWindowOfScreen(XtScreen(topLevel)),
  686. X                (char *)warn32_bits,
  687. X                warn32_width, warn32_height);
  688. X   noticePixmap  = XCreateBitmapFromData(XtDisplay(topLevel),
  689. X                RootWindowOfScreen(XtScreen(topLevel)),
  690. X                (char *)notice32_bits,
  691. X                notice32_width, notice32_height);
  692. X   questPixmap   = XCreateBitmapFromData(XtDisplay(topLevel),
  693. X                RootWindowOfScreen(XtScreen(topLevel)),
  694. X                (char *)quest32_bits,
  695. X                quest32_width, quest32_height);
  696. X   progInfoPixmap =XCreateBitmapFromData(XtDisplay(topLevel),
  697. X                RootWindowOfScreen(XtScreen(topLevel)),
  698. X                (char *)proginfo_bits,
  699. X                proginfo_width, proginfo_height);
  700. }
  701. X
  702. X
  703. /*********************************************************************/
  704. /* ERROR HANDLING FUNCTIONS                                          */
  705. /*********************************************************************/
  706. X
  707. /*********************************************************************/
  708. /* installErrorHandlers:                                             */
  709. /*   Register signal, warning and error handlers                     */
  710. /*********************************************************************/
  711. static void
  712. installErrorHandlers (void)
  713. {
  714. int i;
  715. X
  716. X   /* install signal handler */
  717. X   for (i = 1; i<= 15; i++)
  718. X      signal(i, signalHandler); 
  719. X
  720. X   /* install Xtoolkit handlers */
  721. X   XtSetWarningHandler((XtErrorHandler)Xt_warningHandler);
  722. X   XtSetErrorHandler((XtErrorHandler)Xt_errorHandler);
  723. X
  724. X   /* install X error handler */
  725. X   XSetErrorHandler(X_errorHandler);
  726. X   XSetIOErrorHandler(IO_errorHandler);
  727. }
  728. X
  729. X
  730. /*********************************************************************/
  731. /* Xt_warningHandler:                                                */
  732. /*   Xt warning handler                                              */
  733. /*********************************************************************/
  734. static XtErrorHandler
  735. XXt_warningHandler (String warn)
  736. {
  737. }
  738. X
  739. X
  740. /*********************************************************************/
  741. /* Xt_errorHandler:                                                  */
  742. /*   Xt warning handler                                              */
  743. /*********************************************************************/
  744. static XtErrorHandler
  745. XXt_errorHandler (String error)
  746. {
  747. }
  748. X
  749. X
  750. /*********************************************************************/
  751. /* X_errorHandler:                                                   */
  752. /*   Service X protocol errors                                       */
  753. /*********************************************************************/
  754. static int
  755. XX_errorHandler (Display *dsp, XErrorEvent *event)
  756. {
  757. X  char msg[80];
  758. X  XGetErrorText(dsp, event->error_code, msg, 80);
  759. X  fprintf(stderr, "Error code %s\n", msg);
  760. X  return(0);
  761. }
  762. X
  763. X
  764. /*********************************************************************/
  765. /* IO_errorHandler:                                                  */
  766. /*   Service I/O errors from X                                       */
  767. /*********************************************************************/
  768. static int
  769. IO_errorHandler (Display *dsp)
  770. X  fprintf(stderr, "Fatal Error on X Display %s\n",
  771. X          (char *)XDisplayName(NULL));
  772. X  exit(1);
  773. X
  774. }
  775. X
  776. X
  777. /*********************************************************************/
  778. /* signalHandler:                                                    */
  779. /*   Service signals                                                 */
  780. /*********************************************************************/
  781. static void
  782. signalHandler (int signal, int code)
  783. {
  784. X
  785. }
  786. X
  787. X
  788. /*********************************************************************/
  789. /* saveDataToTmpFiles:                                               */
  790. /*   Attempt to save all loaded data to temp files                   */
  791. /*********************************************************************/
  792. static Errcode
  793. saveDataToTmpFiles (void)
  794. {
  795. X
  796. X   return(OK);
  797. }
  798. X
  799. X
  800. /*********************************************************************/
  801. /* getErrorText:                                                     */
  802. /*   Reads XerrorDB and returns string containing error description  */
  803. /*********************************************************************/
  804. static char *
  805. getErrorText (unsigned char code)
  806. {
  807. X
  808. }
  809. X
  810. X
  811. SHAR_EOF
  812. chmod 0644 bibview.c ||
  813. echo 'restore of bibview.c failed'
  814. Wc_c="`wc -c < 'bibview.c'`"
  815. test 17691 -eq "$Wc_c" ||
  816.     echo 'bibview.c: original size 17691, current size' "$Wc_c"
  817. rm -f _shar_wnt_.tmp
  818. fi
  819. # ============= bibview.h ==============
  820. if test -f 'bibview.h' -a X"$1" != X"-c"; then
  821.     echo 'x - skipping bibview.h (File already exists)'
  822.     rm -f _shar_wnt_.tmp
  823. else
  824. > _shar_wnt_.tmp
  825. echo 'x - extracting bibview.h (Text)'
  826. sed 's/^X//' << 'SHAR_EOF' > 'bibview.h' &&
  827. /*********************************************************************/
  828. /*  bibView: Administration of bibTex-Databases                      */
  829. /*           (Verwaltung von bibTeX-Literaturdatenbanken)            */
  830. /*                                                                   */
  831. /*  Module:  bibview.h                                               */
  832. /*                                                                   */
  833. /*             - Headerfile                                          */
  834. /*             -                                                     */
  835. /*                                                                   */
  836. /*  Author:  Holger Martin,  martinh@informatik.tu-muenchen.de       */
  837. /*           Peter M. Urban, urban@informatik.tu-muenchen.de         */
  838. /*                                                                   */
  839. /*  History:                                                         */
  840. /*    11.22.91  PMU  created                                         */
  841. /*    05.26.92       Version 1.0 released                            */
  842. /*                                                                   */
  843. /*  Copyright 1991 Martin, Urban                                     */
  844. /*    See ./Copyright for complete rights and liability information. */
  845. /*                                                                   */
  846. /*********************************************************************/
  847. X
  848. #include "patchlevel.h"
  849. X
  850. /* Macros and Definitions */
  851. /* ---------------------- */
  852. X
  853. /* general stuff */
  854. #define PROGNAME       "bibView"
  855. #define DEFAULT_RCFILE     ".bibviewrc"
  856. #define MAX_BIBTEX_TYPES   14
  857. #define MAX_ICONNAMELEN       25
  858. #define MAX_FILEPATHLEN    1024
  859. #define MAX_FILENAMELEN    256
  860. #define MAX_OPENFILE       256
  861. #define MAXTREEROOTS       MAX_OPENFILE
  862. #define MAX_NEW_USERDEF_FLDS 3
  863. #define OK           1
  864. X
  865. /* defines for window spacing */
  866. #define BIBWIN_MARGIN       20
  867. #define SUBWIN_MARGIN       20
  868. #define BV_ICON_MARGIN       10
  869. #define BV_ICON_WIDTH       75
  870. #define LST_ICON_WIDTH       75
  871. #define LST_ICON_MARGIN       10
  872. #define CARDWIN_MARGIN     20
  873. #define CARD_ICON_MARGIN   10
  874. #define CARD_ICON_WIDTH       75
  875. #define BIBWIN_HSPACE       40
  876. #define BIBWIN_VSPACE       60
  877. #define CARDWIN_HSPACE       40
  878. #define CARDWIN_VSPACE       40
  879. X
  880. #define LST_WHITESPACE        2
  881. #define LST_TYPE_WIDTH            13
  882. #define LST_TITLE_WIDTH        50
  883. #define LST_AUTHOR_WIDTH    30
  884. #define LST_YEAR_WIDTH        4
  885. #define LST_ENTRY_LEN        (LST_TYPE_WIDTH + LST_TITLE_WIDTH +\
  886. X                 LST_AUTHOR_WIDTH + LST_YEAR_WIDTH +\
  887. X                 (3*LST_WHITESPACE) + 1)
  888. X
  889. /* errors of type Errcode */
  890. typedef int Errcode;  /* return type for error codes */
  891. X
  892. /* general errors */
  893. #define ERR_NOT_IMPLEMENTED     -10
  894. #define ERR_NOMALLOC            -11
  895. #define ERR_NOBIB               -12
  896. #define ERR_NOCARD              -13
  897. #define ERR_NOBIBOPEN        -14
  898. #define ERR_COLL_SAME_BIB       -15
  899. #define ERR_COPY_SAME_BIB       -16
  900. #define ERR_NO_USER_FLDS        -17
  901. X
  902. /* gui errors */
  903. #define ERR_NOCASCADE        -30
  904. X
  905. /* file errors */
  906. #define ERR_NO_OPEN_FILE        -50
  907. #define ERR_NO_CFGFILE          -51
  908. #define ERR_NO_OPEN_TMP         -52
  909. #define ERR_SAVING_TMP          -53
  910. #define ERR_IS_CORRECTED        -54
  911. #define BIF_OK          1
  912. #define BIF_ECALLOC         -11
  913. #define BIF_EWRITE          -55
  914. #define BIF_EOPEN           -50
  915. X
  916. /* card errors */
  917. #define ERR_ILLEGAL_CARDS       -60
  918. #define ERR_NO_ILLEGAL_CARDS    -61
  919. #define ERR_ERROR_IN_FILE    -62
  920. #define ERR_REQFIELDS           -63
  921. X
  922. /* database tree errors */
  923. #define DBT_OK                    1
  924. #define DBT_ECALLOC             -11
  925. #define DBT_EDUPKEY             -100
  926. #define DBT_ECOMP               -101
  927. #define DBT_ENOMATCH            -102
  928. #define DBT_ENOCARD             -103
  929. #define DBT_EAUTHOR             -104
  930. #define DBT_ETITLE              -105
  931. #define DBT_EJOURNAL            -106
  932. #define DBT_EYEAR               -107
  933. #define DBT_EPUBLISHER          -108
  934. #define DBT_EBOOKTITLE          -109 
  935. #define DBT_ECHAPTER            -110
  936. #define DBT_ESCHOOL             -111
  937. #define DBT_EINSTITUTION        -112
  938. #define DBT_ENOTE               -113
  939. #define DBT_EAUTHOR_EDITOR      -114
  940. #define DBT_ECHAPTER_PAGES      -115
  941. #define DBT_ROOTSFULL           -120
  942. #define DBT_ENONODE             -121
  943. X
  944. X
  945. /* structure for single linked list of strings */
  946. typedef struct _ListNode {
  947. X   String data;
  948. X   struct _ListNode *next;
  949. } ListNode;
  950. X
  951. /* structure to hold lists of predefined field data */
  952. typedef struct {
  953. X   ListNode *address,
  954. X            *annote,
  955. X            *author,
  956. X            *booktitle,
  957. X            *chapter,
  958. X            *edition,
  959. X            *editor,
  960. X            *howpublished,
  961. X            *institution,
  962. X            *journal,
  963. X            *key,
  964. X            *month,
  965. X            *note,
  966. X            *number,
  967. X            *organization,
  968. X            *pages,
  969. X            *publisher,
  970. X            *school,
  971. X            *series,
  972. X            *title,
  973. X            *type,
  974. X            *volume,
  975. X            *year,
  976. X            *category,
  977. X        *crossref,
  978. X        *mainkey;
  979. } PredefLists;
  980. X
  981. /* type to hold lists of user defined fields */
  982. typedef ListNode *UserDefFld;
  983. X
  984. /* card types possible in a bibTeX file */
  985. typedef enum {  article,
  986. X                book,
  987. X                booklet,
  988. X                conference,
  989. X                inbook,
  990. X                incollection,
  991. X                inproceedings,
  992. X                manual,
  993. X                mastersthesis,
  994. X                misc,
  995. X                phdthesis,
  996. X                proceedings,
  997. X                techreport,
  998. X                unpublished,
  999. X                bibrc,
  1000. X                regexpr,
  1001. X        illegal
  1002. } CardType;
  1003. X
  1004. X
  1005. /* structure for user defined fields */
  1006. typedef struct _UserFld {  
  1007. X   String fldName;
  1008. X   String fldData;
  1009. X   Widget fldLabel;
  1010. X   Widget fldText;
  1011. X   struct _UserFld *next;
  1012. } UserFld;
  1013. X
  1014. X
  1015. /* structure for all possible data of any card */
  1016. typedef struct {
  1017. X   CardType cardtype;
  1018. X   Boolean  annoteDisplayed,
  1019. X            annoteChanged;
  1020. X   String   cardtypestr;
  1021. X   String   address,
  1022. X            annote,
  1023. X            author,
  1024. X            booktitle,
  1025. X            chapter,
  1026. X            edition,
  1027. X            editor,
  1028. X            howpublished,
  1029. X            institution,
  1030. X            journal,
  1031. X            key,
  1032. X            month,
  1033. X            note,
  1034. X            number,
  1035. X            organization,
  1036. X            pages,
  1037. X            publisher,
  1038. X            school,
  1039. X            series,
  1040. X            title,
  1041. X            type,
  1042. X            volume,
  1043. X            year,
  1044. X            category,
  1045. X        crossref,
  1046. X        mainkey;
  1047. X   UserFld  *ufield;
  1048. } CardData, *CardDataPtr;
  1049. X
  1050. typedef struct _CardListNode {
  1051. X                              CardData *data;
  1052. X                              struct _CardListNode *next;
  1053. } CardListNode, *CardDataList;
  1054. X
  1055. /* structure to hold all widget pointers for all card types */
  1056. typedef struct {
  1057. X   Widget address,    addressL,
  1058. X      annoteShell,
  1059. X          annote,    annoteL,
  1060. X          author,    authorL,
  1061. X          booktitle,    booktitleL,
  1062. X          chapter,    chapterL,
  1063. X          edition,    editionL,
  1064. X          editor,    editorL,
  1065. X          howpublished,    howpublishedL,
  1066. X          institution,    institutionL,
  1067. X          journal,    journalL,
  1068. X          key,        keyL,
  1069. X          month,    monthL,
  1070. X          note,        noteL,
  1071. X          number,    numberL,
  1072. X          organization,    organizationL,
  1073. X          pages,    pagesL,
  1074. X          publisher,    publisherL,
  1075. X          school,    schoolL,
  1076. X          series,    seriesL,
  1077. X          title,    titleL,
  1078. X          type,        typeL,
  1079. X          volume,    volumeL,
  1080. X          year,        yearL,
  1081. X      category,    categoryL,
  1082. X      crossref,    crossrefL,
  1083. X      mainkey,      mainkeyL;
  1084. } CardWidgets, *CardWidgetsPtr;
  1085. X
  1086. /* structure that hold widgets for displaying card data */
  1087. typedef struct {
  1088. X   CardWidgets cw;         /* structure of all possible widgets */
  1089. X   CardData buf;    /* pointers in textBuf for string buffers */
  1090. X   String textBuf;      /* ptr to memory malloc'ed in one block */
  1091. } CardTextWin, *CardTextWinPtr;
  1092. X
  1093. /* structure for card window within bibliography wins */
  1094. typedef struct {
  1095. X   String shellName;    /* label for window */
  1096. X   Widget cardShell,    /* popup shell */
  1097. X      cardWin,    /* paned window */
  1098. X      cmdBox,    /* command box */
  1099. X      userDef,    /* user defined command button */
  1100. X      annote,    /* annote command button */
  1101. X      delete,    /* delete command button */
  1102. X      change,    /* change command button */
  1103. X      copy,        /* copy command button */
  1104. X      close,    /* close command button */
  1105. X      cardDesk,    /* desktop for general attribs for all cards */
  1106. X      cardFlds,    /* desktop on which to place display widgets */
  1107. X          usrFldVport,  /* vieport for user def fields */
  1108. X      usrFldDesk,   /* desktop for user def fields */
  1109. X      usrFldHead;   /* heading for user def fields */
  1110. X   Dimension width,     /* Values of Shell without user def fields */
  1111. X         height,
  1112. X         borderWidth;
  1113. X   CardTextWin ct;    /* structure of widgets to display data */
  1114. X   Position winX,    /* x-coord of cardWin relativ to bibDesk */
  1115. X        winY,    /* y-coord of cardWin relativ to bibDesk */
  1116. X        iconX,    /* x-coord of icon for shell */
  1117. X        iconY;    /* y-coord of icon for shell */
  1118. } CardWin, *CardWinPtr;
  1119. X
  1120. /* structure for opened bibliography card */
  1121. typedef struct {
  1122. X   CardDataPtr cd;    /* ptr to card bibliography data */
  1123. X   CardWinPtr cw;    /* ptr to card window data */
  1124. X   Boolean extended;    /* user fields displayed (T/F) */
  1125. X   Boolean changed;    /* card changed flag */
  1126. X   void  *bp;        /* ptr to bib card belongs to */
  1127. } Card, *CardPtr;
  1128. X
  1129. /* structure for linked list of bib cards */
  1130. typedef struct _CardEl {
  1131. X   Card card;
  1132. X   struct _CardEl *next,
  1133. X              *prev;
  1134. } CardEl, *CardList;
  1135. X
  1136. /* structure for list windows within bibliography wins */
  1137. typedef struct {
  1138. X   String shellName;    /* name of popup shell */
  1139. X   Widget lstShell,    /* popup shell */
  1140. X      lstWin,    /* paned window for menu, list and cmds */
  1141. X      lstVp,     /* viewport for list */
  1142. X      vpWin,     /* child of viewport */
  1143. X      cmdBox,    /* command box (menu bar) */
  1144. X      list,        /* window containing list */
  1145. X      headBox,    /* heading for list */
  1146. X      save,            /* save command button */
  1147. X      print,    /* print command button */
  1148. X      quit;        /* quit command button */
  1149. X   int listArgc;    /* no of entries in list */
  1150. X   String *listArgv;    /* argv of ptr to list entries */
  1151. X   String strs;        /* buffer for list entries */
  1152. X   CardListNode *cardLst; /* argv of ptr to cards in list */
  1153. X   Position winX,    /* x-coord of list window */
  1154. X        winY,    /* y-coord of list window */
  1155. X        iconX,    /* x-coord of icon for shell */
  1156. X        iconY;    /* y-coord of icon for shell */
  1157. } LstWin, *LstWinPtr;
  1158. X
  1159. /* structure for macro windows within bibliograhpy wins */
  1160. typedef struct {
  1161. X   String shellName;    /* name of popup shell */
  1162. X   Widget macShell,    /* popup shell */
  1163. X      macWin,    /* paned window for menu, list and cmds */
  1164. X      cmdBox,    /* command box (menu bar) */
  1165. X      save,     /* save command button */
  1166. X      close,    /* close command button */
  1167. X          file;         /* text widget for macro file */
  1168. X   Position winX,    /* x-coord of shell */
  1169. X        winY,    /* y-coord of shell */
  1170. X        iconX,    /* x-coord of icon for shell */
  1171. X        iconY;    /* y-coord of icon for shell */
  1172. X   Boolean changed;    /* macros changed flag */
  1173. } MacroWin, *MacroWinPtr;
  1174. X
  1175. /* structure for bibliography windows */
  1176. typedef struct {
  1177. X   String shellName;    /* label for popup shell */
  1178. X   Widget bibShell,    /* popup shell */
  1179. X          bibWin,    /* main window */
  1180. X      cmdBox,    /* command box */
  1181. X      bibdesk,    /* desktop for cardWins */
  1182. X      new,        /* new command button */
  1183. X      search,    /* search command button */
  1184. X      list,        /* list command button */
  1185. X      macro,    /* macro command button */
  1186. X      print,    /* print command button */
  1187. X      save,        /* save command button */
  1188. X      close,    /* close command button */
  1189. X      window,    /* window command button */
  1190. X      newMenu,    /* pulldown menu new */
  1191. X      windowMenu;    /* pulldown menu window */
  1192. X   Position winX,    /* x-coord of shell */
  1193. X        winY,    /* y-coord of shell */
  1194. X        iconX,    /* x-coord of icon for shell */
  1195. X        iconY;    /* y-coord of icon for shell */
  1196. } BibWin, *BibWinPtr;
  1197. X
  1198. /* structure for an opened bibTeX-file */
  1199. typedef struct {
  1200. X   char filepath[MAX_FILEPATHLEN];    /* bibTex filename */
  1201. X   char filename[MAX_FILENAMELEN];    /* bibTex filename */
  1202. X   char *tempfile;            /* temp   filename */
  1203. X   char *macrofile;            /* macro   filename */
  1204. X   Boolean changed;            /* file changed flag */
  1205. X   int treeIdx;                /* handle of data tree */
  1206. X   BibWinPtr bw;            /* ptr to bib window data */
  1207. X   LstWinPtr lw;            /* ptr to list window data */
  1208. X   MacroWinPtr mw;            /* ptr to macro win data */
  1209. X   MacroWinPtr ew;            /* ptr to edit win data */
  1210. X   CardList  cl;            /* ptr to list of open cards */
  1211. X   int noOfCardWins;            /* number of opened cards */
  1212. X   int nextCardPos;            /* pos of next opened card */
  1213. } Bib, *BibPtr;
  1214. X   
  1215. X
  1216. /* codes and macros for options functions */
  1217. #define OPT_MAX_OPTION        5+1 /* plus line in menu */
  1218. #define OPT_BEEP_ON_ERROR       1
  1219. #define OPT_BACKUP_ON_SAVE      2
  1220. #define OPT_ICON_ON_DESKTOP     3
  1221. #define OPT_AUTO_CHECK_BIB      4
  1222. #define OPT_REQUIRED_FIELDS     5
  1223. #if !defined(COT_OPT)
  1224. extern Boolean optionsStatus[];
  1225. #endif
  1226. #define cotBeepOnError()    (optionsStatus[OPT_BEEP_ON_ERROR])
  1227. #define cotBackupBeforeSave()    (optionsStatus[OPT_BACKUP_ON_SAVE])
  1228. #define cotIconizeOnDesktop()    (optionsStatus[OPT_ICON_ON_DESKTOP])
  1229. #define cotAutoCheckBib()    (optionsStatus[OPT_AUTO_CHECK_BIB])
  1230. #define cotRequiredFields()    (optionsStatus[OPT_REQUIRED_FIELDS])
  1231. X
  1232. X
  1233. /* Prototypes */
  1234. /* ---------- */
  1235. X
  1236. /* types */
  1237. typedef Errcode (*CtlFuncPtr) (BibPtr bp);
  1238. X
  1239. /* bibview.c */
  1240. X
  1241. /* gui_main.c */
  1242. int gumMainWin (void);
  1243. X
  1244. /* ctl_open.c */
  1245. void copNewCmd (Widget w, XtPointer clientData, XtPointer callData);
  1246. void copOpenCmd (Widget w, XtPointer clientData, XtPointer callData);
  1247. void copLoadBibFile (Widget w, XtPointer clientData, XtPointer callData);
  1248. X
  1249. /* ctl_save.c */
  1250. void csaQuitBibviewCmd (Widget w, XtPointer clientData, XtPointer callData);
  1251. void csaCloseBibCmd (Widget w, XtPointer clientData, XtPointer callData);
  1252. void csaCloseCmd (Widget w, XtPointer clientData, XtPointer callData);
  1253. Errcode csaCloseBib (BibPtr bp);
  1254. void csaSaveBibCmd (Widget w, XtPointer clientData, XtPointer callData);
  1255. void csaSaveCmd (Widget w, XtPointer clientData, XtPointer callData);
  1256. void csaSaveAsBibCmd (Widget w, XtPointer clientData, XtPointer callData);
  1257. Errcode csaSaveBib (BibPtr bp);
  1258. Errcode csaSaveAsBib (BibPtr bp);
  1259. X
  1260. /* ctl_serv.c */
  1261. void cseCollateBibCmd (Widget w, XtPointer clientData, XtPointer callData);
  1262. Errcode cseCollateBibs (BibPtr sbp, BibPtr dbp);
  1263. void cseCheckBibCmd (Widget w, XtPointer clientData, XtPointer callData);
  1264. Errcode cseCheckBib (BibPtr bp, Boolean sayOkMsg);
  1265. void cseEditMacrosCmd (Widget w, XtPointer clientData, XtPointer callData);
  1266. void cseMacrosCmd (Widget w, XtPointer clientData, XtPointer callData);
  1267. Errcode cseEditMacros (BibPtr bp);
  1268. void cseSetMacroChangeFlag (Widget w, XtPointer clientData, XtPointer callData);
  1269. void cseQuitMacrosCmd (Widget w, XtPointer clientData, XtPointer callData);
  1270. void cseSaveMacrosCmd (Widget w, XtPointer clientData, XtPointer callData);
  1271. void cseLoadConfigCmd (Widget w, XtPointer clientData, XtPointer callData);
  1272. X
  1273. /* ctl_opt.c */
  1274. void cotOptionsControl (Widget w, XtPointer client_data, XtPointer call_data);
  1275. void cotOptionIconOnDeskCmd (Widget w, XtPointer clientData, XtPointer callData);
  1276. X
  1277. /* gui_bibl.c */
  1278. int gubOpenBibWin(BibPtr bp);
  1279. int gubNoOfOpenBibs (void);
  1280. void gubCloseBibWinCmd(Widget w, XtPointer clientData, XtPointer callData);
  1281. Errcode gubCloseBibWin (BibPtr bp);
  1282. void gubCascadeCmd(Widget w, XtPointer clientData, XtPointer callData);
  1283. Errcode gubCascade(void);
  1284. Errcode gubSetWindowCoords (Boolean calcOnly);
  1285. Errcode gubSetIconCoords (Boolean calcOnly);
  1286. Errcode gubUnsetIconCoords (Boolean calcOnly);
  1287. X
  1288. /* ctl_srch.c */
  1289. void csrSearchCmd (Widget w, XtPointer clientData, XtPointer callData);
  1290. void csrListCmd (Widget w, XtPointer clientData, XtPointer callData);
  1291. void csrDisplayCardCmd (Widget w, XtPointer clientData, XtPointer callData);
  1292. X
  1293. /* gui_card.c */
  1294. Errcode gucOpenCardWin (BibPtr bp, CardPtr cp, Boolean isNew);
  1295. void gucCloseCardCmd (Widget w, XtPointer clientData, XtPointer callData);
  1296. Errcode gucCloseCardWin (CardPtr cp);
  1297. Errcode gucOpenUserFields (CardPtr cp);
  1298. Errcode gucCloseUserFields (CardPtr cp);
  1299. Errcode gucSaveCardData (CardPtr cp);
  1300. Errcode gucSaveUserFields (CardPtr cp);
  1301. Boolean gucStdFldsChanged (CardPtr cp);
  1302. void gucCascadeCmd (Widget w, XtPointer clientData, XtPointer callData);
  1303. Errcode gucCascade (BibPtr bp);
  1304. Errcode gucSetWindowCoords (BibPtr bp, Boolean calcOnly);
  1305. Errcode gucSetIconCoords (BibPtr bp, Boolean calcOnly);
  1306. Errcode gucUnsetIconCoords (BibPtr bp, Boolean calcOnly);
  1307. X
  1308. /* ctl_card.c */
  1309. void ccdNewCardCmd (Widget w, XtPointer clientData, XtPointer callData);
  1310. void ccdUserdataCmd (Widget w, XtPointer clientData, XtPointer callData);
  1311. void ccdSaveCardCmd (Widget w, XtPointer clientData, XtPointer callData);
  1312. void ccdDeleteCardCmd (Widget w, XtPointer clientData, XtPointer callData);
  1313. void ccdAnnoteCardCmd (Widget w, XtPointer clientData, XtPointer callData);
  1314. void ccdChangeCardCmd (Widget w, XtPointer clientData, XtPointer callData);
  1315. void ccdCopyCardCmd (Widget w, XtPointer clientData, XtPointer callData);
  1316. Errcode ccdCopyCard1 (BibPtr bp);
  1317. Errcode ccdCopyCard (BibPtr bp, CardPtr cp);
  1318. void ccdSetChangeFlag (Widget w, XtPointer clientData, XtPointer callData);
  1319. void ccdCloseCardCmd (Widget w, XtPointer clientData, XtPointer callData);
  1320. Errcode ccdCloseCard (BibPtr bp, CardPtr cp);
  1321. X
  1322. /* ctl_prt.c */
  1323. void cprPrintBibCmd (Widget widget, XtPointer clientData, XtPointer callData);
  1324. void cprPrintCmd (Widget widget, XtPointer clientData, XtPointer callData);
  1325. Errcode cprPrintBib (BibPtr bp);
  1326. void cprPrintListCmd (Widget widget, XtPointer clientData, XtPointer callData);
  1327. Errcode cprPrintList (CardListNode *lp, String fname);
  1328. void cprSaveListCmd(Widget widget, XtPointer clientData, XtPointer callData);
  1329. X
  1330. /* gui_list.c */
  1331. Errcode gulOpenListWin (BibPtr bp, CardDataList cl); 
  1332. Boolean gulListWinExists (BibPtr bp);
  1333. Errcode gulReplaceListData (BibPtr bp, CardDataList cl);
  1334. void gulCloseListWinCmd (Widget w, XtPointer clientData, XtPointer callData);
  1335. Errcode gulCloseListWin (BibPtr bp);
  1336. Errcode gulCascade (BibPtr bp);
  1337. Errcode gulSetWindowCoords (BibPtr bp, Boolean calcOnly);
  1338. Errcode gulSetIconCoords (BibPtr bp, Boolean calcOnly);
  1339. Errcode gulUnsetIconCoords (BibPtr bp, Boolean calcOnly);
  1340. X
  1341. /* gui_edit.c */
  1342. Errcode gueOpenListWin (BibPtr bp);
  1343. Boolean gueMacroWinExists (BibPtr bp);
  1344. void    gueCloseMacroWinCmd (Widget w, XtPointer clientData, XtPointer callData);
  1345. Errcode gueCloseMacroWin (BibPtr bp);
  1346. Errcode gueSaveMacrosToFile (BibPtr bp);
  1347. Errcode gueCascade (BibPtr bp);
  1348. Errcode gueSetWindowCoords (BibPtr bp, Boolean calcOnly);
  1349. Errcode gueSetIconCoords (BibPtr bp, Boolean calcOnly);
  1350. Errcode gueUnsetIconCoords (BibPtr bp, Boolean calcOnly);
  1351. Errcode gueOpenBibErrWin(BibPtr bp, int line);
  1352. Errcode gueCloseBibErrWin (BibPtr bp);
  1353. void gueCloseBibErrWinCmd (Widget w, XtPointer clientData, XtPointer callData);
  1354. X
  1355. /* gui_widg.c */
  1356. Errcode guwSelectBib (String head, CtlFuncPtr fct);
  1357. void    guwNotImpl (Widget w, XtPointer clientData, XtPointer callData);
  1358. void hlpOpenHelpWinCmd (Widget w, XtPointer clientData, XtPointer callData);
  1359. void guwError(Errcode errcode);
  1360. void guwWarning(Errcode errcode);
  1361. void guwNotice(Errcode errcode);
  1362. void guwProgInfo (Widget w, XtPointer clientData, XtPointer callData);
  1363. X
  1364. /* bib_file */
  1365. Errcode bifFileRead(BibPtr bp);
  1366. Errcode bifFileWrite(BibPtr bp);
  1367. Errcode bifFileListWrite(BibPtr bp, CardListNode *list, String fname);
  1368. X
  1369. /* rc_file.c */
  1370. Errcode rcfReadCfgFile (char *cfgFname);
  1371. Errcode rcfReadOptions (Boolean bool);
  1372. Errcode rcfSetPrintMode (Boolean bool);
  1373. X
  1374. /* globdata.c */
  1375. char *strupr (char *s);
  1376. String glbNewString (String s);
  1377. String glbTrimString (String s);
  1378. Boolean glbIsStringEmpty (String s);
  1379. String glbTypeToName (CardType type);
  1380. CardType glbNameToType (String name);
  1381. Errcode glbNewBibListEl (BibPtr *bp);
  1382. Errcode glbDelBibListEl (BibPtr bp);
  1383. BibPtr glbFirstBibListEl (void);
  1384. BibPtr glbPrevBibListEl (BibPtr bp);
  1385. BibPtr glbNextBibListEl (BibPtr bp);
  1386. BibPtr glbLastBibListEl (void);
  1387. Boolean glbIsBibListEl (BibPtr bp);
  1388. Errcode glbNewCardListEl (BibPtr bp, CardPtr *cp, CardDataPtr cd);
  1389. Errcode glbDelCardListEl (BibPtr bp, CardPtr cp);
  1390. CardPtr glbFirstCardListEl (BibPtr bp);
  1391. CardPtr glbPrevCardListEl (BibPtr bp, CardPtr cp);
  1392. CardPtr glbNextCardListEl (BibPtr bp, CardPtr cp);
  1393. CardPtr glbLastCardListEl (BibPtr bp);
  1394. Boolean glbIsCardListEl (BibPtr bp, CardPtr cp);
  1395. CardPtr glbFindCard (BibPtr bp, CardDataPtr cd);
  1396. X
  1397. /* db_tree.c */
  1398. Errcode dbtInsert (int treeIdx, CardData *card);
  1399. Errcode dbtDelete (int treeIdx, CardData *card);
  1400. Errcode dbtSearch (int treeIdx, CardData **card);
  1401. Errcode dbtMakeCard (CardData **card);
  1402. Errcode dbtDeleteCard (CardData **card);
  1403. Errcode dbtMakeTreeList (int treeIdx, int listIdx);
  1404. Errcode dbtGetFreeTreeIdx (int *treeIdx);
  1405. Errcode dbtGetFreeListIdx (int *listIdx);
  1406. Errcode dbtSearchList (int treeIdx, CardData *card, CardListNode **list);
  1407. Errcode dbtTestCard (CardData *c);
  1408. Errcode dbtCheckAllCards (int treeIdx, CardListNode **list);
  1409. Errcode dbtDeleteTree (int treeIdx);
  1410. Errcode dbtAppendUserFld(UserFld **list, UserFld *obj);
  1411. Errcode dbtMakeListNode (ListNode **list);
  1412. Errcode dbtListAppend (ListNode **list, String word);
  1413. Errcode dbtCardListDelete(CardListNode **list); 
  1414. SHAR_EOF
  1415. chmod 0644 bibview.h ||
  1416. echo 'restore of bibview.h failed'
  1417. Wc_c="`wc -c < 'bibview.h'`"
  1418. test 21014 -eq "$Wc_c" ||
  1419.     echo 'bibview.h: original size 21014, current size' "$Wc_c"
  1420. rm -f _shar_wnt_.tmp
  1421. fi
  1422. # ============= bibviewrc ==============
  1423. if test -f 'bibviewrc' -a X"$1" != X"-c"; then
  1424.     echo 'x - skipping bibviewrc (File already exists)'
  1425.     rm -f _shar_wnt_.tmp
  1426. else
  1427. > _shar_wnt_.tmp
  1428. echo 'x - extracting bibviewrc (Text)'
  1429. sed 's/^X//' << 'SHAR_EOF' > 'bibviewrc' &&
  1430. # bibviewrc: configuration file for bibview
  1431. # -------------------------------------------
  1432. X
  1433. # The following sections are allowed
  1434. #  [Options]       (optional)
  1435. #  [Fields]        (optional)
  1436. #  [Predefines]    (optional)
  1437. #  [LatexHeader]   (optional)
  1438. #  [LatexFooter]   (optional)
  1439. # All lines must start in the first column
  1440. X
  1441. X
  1442. [Options]
  1443. #
  1444. # The following options are recognized:
  1445. #  Option              Function                  Default
  1446. #  ----------------------------------------------------------------
  1447. #  BeepOnError    = (true|false)  Beep on error             true
  1448. #  IconsOnDesk    = (true|false)  Icons on Desktop          false
  1449. #  MakeBackups    = (true|false)  Backups before Save       true
  1450. #  AutoCheckBib   = (true|false)  Autom. check              true
  1451. #  RequiredFields = (true|false)  Check before Save.        true
  1452. X
  1453. BeepOnError = false
  1454. IconsOnDesk = true
  1455. MakeBackups = true
  1456. AutoCheckBib = true
  1457. RequiredFields= false
  1458. X
  1459. X
  1460. X
  1461. [Fields]
  1462. # Define user defined fields for certain types.
  1463. # If the field should be in ALL types,
  1464. # as type you must enter 'all'
  1465. #
  1466. #  type = fieldname
  1467. # ----------------------
  1468. article = library
  1469. article = read
  1470. book = owner
  1471. all = available 
  1472. X
  1473. [Predefines]
  1474. # Predefined data for search window
  1475. #
  1476. #  field : data
  1477. # --------------------
  1478. address:New York
  1479. address : Berlin
  1480. address:  Washington
  1481. X
  1482. author: Hartson
  1483. author: Hesketh
  1484. author: Hix
  1485. author: McCormack
  1486. author: Nye
  1487. author: O'Reilly
  1488. X
  1489. category: ^unix
  1490. category: ^x
  1491. X
  1492. title: X Toolkit Intrinsics
  1493. X
  1494. year: 198
  1495. year: 199
  1496. X
  1497. X
  1498. [LatexHeader]
  1499. # header of LaTeX file
  1500. # The following lines until the next section are written as header of the
  1501. # LaTeX file.
  1502. # \begin{enumerate} is necessary because the entries are
  1503. # written as LaTeX list
  1504. X
  1505. \documentstyle{article}
  1506. \begin{document}
  1507. {\large \bf Content of BibTeX file -- \today}
  1508. \begin{enumerate} 
  1509. X
  1510. [LatexFooter]
  1511. # end of LaTeX file
  1512. # The following lines until the next section are written as footer of the
  1513. # LaTeX file.
  1514. X
  1515. \end{enumerate} 
  1516. \end{document}
  1517. X
  1518. X
  1519. SHAR_EOF
  1520. chmod 0640 bibviewrc ||
  1521. echo 'restore of bibviewrc failed'
  1522. Wc_c="`wc -c < 'bibviewrc'`"
  1523. test 1949 -eq "$Wc_c" ||
  1524.     echo 'bibviewrc: original size 1949, current size' "$Wc_c"
  1525. rm -f _shar_wnt_.tmp
  1526. fi
  1527. # ============= bitmaps/bv_crd64 ==============
  1528. if test ! -d 'bitmaps'; then
  1529.     echo 'x - creating directory bitmaps'
  1530.     mkdir 'bitmaps'
  1531. fi
  1532. if test -f 'bitmaps/bv_crd64' -a X"$1" != X"-c"; then
  1533.     echo 'x - skipping bitmaps/bv_crd64 (File already exists)'
  1534.     rm -f _shar_wnt_.tmp
  1535. else
  1536. > _shar_wnt_.tmp
  1537. echo 'x - extracting bitmaps/bv_crd64 (Text)'
  1538. sed 's/^X//' << 'SHAR_EOF' > 'bitmaps/bv_crd64' &&
  1539. #define bv_crd64_width 64
  1540. #define bv_crd64_height 64
  1541. static unsigned char bv_crd64_bits[] = {
  1542. X   0x25, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x21, 0x00, 0xf0,
  1543. X   0xdc, 0xf3, 0x01, 0x21, 0x89, 0x10, 0x00, 0x10, 0x49, 0x44, 0x00, 0x12,
  1544. X   0x44, 0x08, 0x00, 0x10, 0x49, 0x44, 0x00, 0x0c, 0x22, 0x04, 0x00, 0xf0,
  1545. X   0xc8, 0x43, 0x00, 0x0c, 0x11, 0x02, 0x00, 0xf0, 0xc9, 0x47, 0x7c, 0x0c,
  1546. X   0x08, 0x01, 0x00, 0x10, 0x49, 0x44, 0x04, 0x0c, 0x84, 0x00, 0x00, 0x10,
  1547. X   0x49, 0x44, 0x04, 0x12, 0x42, 0x00, 0x00, 0xf0, 0xdc, 0x43, 0x3c, 0x21,
  1548. X   0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x10, 0x00, 0x00, 0x00,
  1549. X   0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
  1550. X   0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x02, 0x00, 0x00, 0x00,
  1551. X   0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1552. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1553. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1554. X   0x00, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02,
  1555. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00,
  1556. X   0x00, 0x81, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x03, 0x02,
  1557. X   0x00, 0x00, 0x00, 0x00, 0xf0, 0x41, 0x04, 0xfe, 0xff, 0xff, 0xff, 0x01,
  1558. X   0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00,
  1559. X   0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
  1560. SHAR_EOF
  1561. true || echo 'restore of bitmaps/bv_crd64 failed'
  1562. fi
  1563. echo 'End of  part 5'
  1564. echo 'File bitmaps/bv_crd64 is continued in part 6'
  1565. echo 6 > _shar_seq_.tmp
  1566. exit 0
  1567. -- 
  1568. Senior Systems Scientist        mail: dcmartin@msi.com
  1569. Molecular Simulations, Inc.        uucp: uunet!dcmartin
  1570. 796 North Pastoria Avenue        at&t: 408/522-9236
  1571. Sunnyvale, California 94086        fax: 408/732-0831
  1572.