1 /*********************************************************************/
2 /* bibView: Administration of BibTeX-Databases */
3 /* (Verwaltung von BibTeX-Literaturdatenbanken) */
4 /* */
5 /* Module: bibview.c */
6 /* */
7 /* - Main Program */
8 /* - Signal Handling */
9 /* */
10 /* Author: Holger Martin, martinh@informatik.tu-muenchen.de */
11 /* Peter M. Urban, urban@informatik.tu-muenchen.de */
12 /* */
13 /* History: */
14 /* 11.22.91 PMU created */
15 /* 05.26.92 Version 1.0 released */
16 /* */
17 /* Copyright 1992 TU MUENCHEN */
18 /* See ./Copyright for complete rights and liability information. */
19 /* */
20 /*********************************************************************/
21
22
23 #include <stdio.h>
24 #include <unistd.h>
25 #include <sys/param.h>
26 #include <X11/Intrinsic.h>
27 #include <X11/StringDefs.h>
28 #include <X11/Shell.h>
29 #include <X11/Xaw/Form.h>
30 #include <X11/Xaw/Paned.h>
31 #include <X11/Xaw/Box.h>
32 #include <X11/Xaw/Command.h>
33 #include <X11/Xaw/MenuButton.h>
34 #include <X11/Xaw/SimpleMenu.h>
35 #include <X11/Xaw/SmeBSB.h>
36 #include <X11/Xaw/SmeLine.h>
37 #include <X11/Xos.h>
38 #include "bibview.h"
39 #include "bitmaps/bv_ico64"
40 #include "bitmaps/bv_lst64"
41 #include "bitmaps/bv_mac64"
42 #include "bitmaps/bv_crd64"
43 #include "bitmaps/bv_hlp64"
44 #include "bitmaps/bv_ann64"
45 #include "bitmaps/chkmrk16"
46 #include "bitmaps/error32"
47 #include "bitmaps/warn32"
48 #include "bitmaps/notice32"
49 #include "bitmaps/quest32"
50 #ifdef GERMAN
51 #include "bitmaps/proggerm.xbm"
52 #else
53 #include "bitmaps/proginfo.xbm"
54 #endif
55
56
57 /* external global variables */
58 /* ------------------------- */
59 extern Widget desktop;
60 extern char *latexHeader, *latexFooter;
61 extern int latexHeaderLen, latexFooterLen;
62 extern char *style_file;
63 extern int cont_indent, fld_indent, newline_indent, max_linelen;
64 extern char *actual_path;
65 extern UserDefFld userDefFlds[];
66 extern PredefLists predefLst;
67 extern listEntry *list_layout;
68
69
70
71 /* exported global variables */
72 /* ------------------------- */
73 XtAppContext app_context;
74 Widget topLevel;
75 Pixmap bvIconPixmap;
76 String bvIconName;
77 Pixmap lstIconPixmap;
78 Pixmap macIconPixmap;
79 Pixmap crdIconPixmap;
80 Pixmap helpIconPixmap;
81 Pixmap annoteIconPixmap;
82 Pixmap chkmarkPixmap;
83 Pixmap errorPixmap;
84 Pixmap warnPixmap;
85 Pixmap noticePixmap;
86 Pixmap questPixmap;
87 Pixmap progInfoPixmap;
88
89 int sortedby;
90
91
92 /* names for card types , the order must be the same as */
93 /* for the type CardType in bibview.h */
94 String cardNames[MAX_BIBTEX_TYPES+1] = {
95 "article",
96 "book",
97 "booklet",
98 "conference",
99 "inbook",
100 "incollection",
101 "inproceedings",
102 "manual",
103 "mastersthesis",
104 "misc",
105 "phdthesis",
106 "proceedings",
107 "techreport",
108 "unpublished",
109 NULL,
110 NULL, NULL, NULL, NULL, NULL,
111 NULL, NULL, NULL, NULL, NULL,
112 NULL, NULL, NULL, NULL, NULL,
113 "userdefined"
114 };
115
116 /* names for fields , the order must be the same as for */
117 /* the type FieldName in bibview.h */
118 String fieldNames[MAX_FIELDS] = {
119 "crossref",
120 "key",
121 "author",
122 "editor",
123 "title",
124 "booktitle",
125 "institution",
126 "journal",
127 "organization",
128 "chapter",
129 "pages",
130 "year",
131 "month",
132 "publisher",
133 "address",
134 "school",
135 "edition",
136 "howpublished",
137 "volume",
138 "number",
139 "series",
140 "type",
141 "note",
142 NULL, NULL,
143 NULL, NULL, NULL, NULL, NULL,
144 NULL, NULL, NULL, NULL, NULL,
145 NULL, NULL, NULL, NULL, NULL,
146 NULL, NULL, NULL, NULL, NULL,
147 NULL, NULL, NULL, NULL, NULL,
148 NULL, NULL, NULL, NULL, NULL,
149 NULL, NULL, NULL, NULL, NULL,
150 NULL, NULL, NULL, NULL, NULL,
151 NULL, NULL, NULL, NULL, NULL,
152 NULL, NULL, NULL, NULL, NULL,
153 NULL, NULL, NULL, NULL, NULL
154 };
155
156 char sort_field[MAX_FIELDS];
157 char is_search_field[MAX_FIELDS];
158
159 char standardfields [MAX_BIBTEX_TYPES+1][MAX_FIELDS];
160 char requiredfields [MAX_BIBTEX_TYPES+1][MAX_FIELDS];
161
162 int max_fields;
163 int max_bibtex_types;
164
165
166
167 /* local global variables */
168 /* ---------------------- */
169
170 /* fallback resources */
171 static char *fallback_resources[] = {
172 #ifdef GERMAN
173 #include "fb_ger.h"
174 #else
175 #include "fb_res.h"
176 #endif
177 NULL
178 };
179
180
181 static char bibfile[MAXPATHLEN+1];
182
183 OptionsRec options;
184
185 #define Offset(field) XtOffsetOf(OptionsRec, field)
186 XtResource resources[] = {
187 { "quiet", "Quiet", XtRBoolean, sizeof(Boolean),
188 Offset(quiet), XtRString, "False" },
189 { "iconsOnDesk", "IconsOnDesk", XtRBoolean, sizeof(Boolean),
190 Offset(iconsOnDesk), XtRString, (XtPointer)"False" },
191 { "makeBackup", "MakeBackup", XtRBoolean, sizeof(Boolean),
192 Offset(makeBackup), XtRString, (XtPointer)"True" },
193 { "autoCheck", "AutoCheck", XtRBoolean, sizeof(Boolean),
194 Offset(autoCheck), XtRString, (XtPointer)"True" },
195 { "reqFields", "ReqFields", XtRBoolean, sizeof(Boolean),
196 Offset(reqFields), XtRString, (XtPointer)"False" },
197 { "ignoreCase", "IgnoreCase", XtRBoolean, sizeof(Boolean),
198 Offset(ignoreCase), XtRString, (XtPointer)"True" },
199 { "printAsBib", "PrintAsBib", XtRBoolean, sizeof(Boolean),
200 Offset(printAsBib), XtRString, (XtPointer)"True" },
201 { "displayErrWin", "DisplayErrWin", XtRBoolean, sizeof(Boolean),
202 Offset(displayErrWin), XtRString, (XtPointer)"True" },
203 { "focus", "Focus", XtRBoolean, sizeof(Boolean),
204 Offset(focus), XtRString, (XtPointer)"True" },
205 { "orig", "Orig", XtRBoolean, sizeof(Boolean),
206 Offset(orig), XtRString, (XtPointer)"False" },
207 { "bibfile", "Bibfile", XtRString, sizeof(String),
208 Offset(bibfile), XtRString, (XtPointer)NULL },
209 { "rcfile", "Rcfile", XtRString, sizeof(String),
210 Offset(rcfile), XtRString, (XtPointer)NULL },
211 { "bibdir", "Bibdir", XtRString, sizeof(String),
212 Offset(bibdir), XtRString, (XtPointer)NULL },
213 { "focusColor", "FocusColor", XtRPixel, sizeof(Pixel),
214 Offset(focusColor), XtRString, XtDefaultBackground },
215 { "reqColor", "ReqColor", XtRPixel, sizeof(Pixel),
216 Offset(reqColor), XtRString, XtDefaultBackground },
217 { "authedColor", "AuthedColor", XtRPixel, sizeof(Pixel),
218 Offset(authedColor), XtRString, XtDefaultBackground },
219 };
220 #undef Offset
221
222 static XrmOptionDescRec optionDesc[] = {
223 { "-quiet", "*quiet", XrmoptionNoArg, (XtPointer)"on" },
224 { "+quiet", "*quiet", XrmoptionNoArg, (XtPointer)"off" },
225 { "-iconsOnDesk", "*iconsOnDesk", XrmoptionNoArg, (XtPointer)"on" },
226 { "+iconsOnDesk", "*iconsOnDesk", XrmoptionNoArg, (XtPointer)"off" },
227 { "-makeBackup", "*makeBackup", XrmoptionNoArg, (XtPointer)"on" },
228 { "+makeBackup", "*makeBackup", XrmoptionNoArg, (XtPointer)"off" },
229 { "-autoCheck", "*autoCheck", XrmoptionNoArg, (XtPointer)"on" },
230 { "+autoCheck", "*autoCheck", XrmoptionNoArg, (XtPointer)"off" },
231 { "-reqFields", "*reqFields", XrmoptionNoArg, (XtPointer)"on" },
232 { "+reqFields", "*reqFields", XrmoptionNoArg, (XtPointer)"off" },
233 { "-ignoreCase", "*ignoreCase", XrmoptionNoArg, (XtPointer)"on" },
234 { "+ignoreCase", "*ignoreCase", XrmoptionNoArg, (XtPointer)"off" },
235 { "-printAsBib", "*printAsBib", XrmoptionNoArg, (XtPointer)"on" },
236 { "+printAsBib", "*printAsBib", XrmoptionNoArg, (XtPointer)"off" },
237 { "-displayErrWin","*displayErrWin", XrmoptionNoArg, (XtPointer)"on" },
238 { "+displayErrWin","*displayErrWin", XrmoptionNoArg, (XtPointer)"off" },
239 { "-focus", "*focus", XrmoptionNoArg, (XtPointer)"on" },
240 { "+focus", "*focus", XrmoptionNoArg, (XtPointer)"off" },
241 { "-orig", "*orig", XrmoptionNoArg, (XtPointer)"on" },
242 { "+orig", "*orig", XrmoptionNoArg, (XtPointer)"off" },
243 { "-rcfile", "*rcfile", XrmoptionSepArg, (XtPointer)NULL },
244 { "-bibdir", "*bibdir", XrmoptionSepArg, (XtPointer)NULL },
245 { "-file", "*bibfile", XrmoptionSepArg, (XtPointer)NULL }
246 };
247
248
249 /* local function prototypes */
250 static void printHelp (int argc, char **argv);
251 static void processCommandlineOptions (void);
252 static Boolean readBibfile (XtPointer clientData);
253 static void makeIconPixmaps (void);
254 static void installErrorHandlers (void);
255 static XtErrorHandler Xt_warningHandler (String warn);
256 static XtErrorHandler Xt_errorHandler (String error);
257 static int X_errorHandler (Display *dsp, XErrorEvent *event);
258 static int IO_errorHandler (Display *dsp);
259 static void signalHandler (int signal, int code);
260 static void initializeFields (void);
261
262
263
264 /*********************************************************************/
265 /* MAIN: */
266 /*********************************************************************/
267 int
main(int argc,char * argv[])268 main(int argc, char *argv[])
269 {
270 static char iconname[MAX_ICONNAMELEN+1];
271 static char *p, path[MAX_FILEPATHLEN+1];
272 int i;
273
274 topLevel = XtVaAppInitialize(&app_context, /* Appl context */
275 "BibView", /* Appl class */
276 optionDesc, /* cmdline options */
277 XtNumber(optionDesc),
278 &argc, argv, /* command line args */
279 (String *)fallback_resources,/* fallback resources */
280 NULL); /* end varargs list */
281
282 /* process commandline options */
283 XtGetApplicationResources(topLevel,
284 (XtPointer) &options,
285 resources, XtNumber(resources),
286 (Arg *)NULL, 0);
287 if (argc > 1)
288 printHelp(argc, argv);
289
290 style_file = XtMalloc(MAXPATHLEN+1);
291 strcpy(style_file, "alpha");
292
293 sortedby = SORT_UNSRT;
294 cont_indent = CONTINDENT;
295 fld_indent = FLDINDENT;
296 newline_indent = NEWLINEINDENT;
297 max_linelen = MAX_LINELEN;
298 actual_path = XtMalloc(MAXPATHLEN+1);
299
300 for (i=0; i<MAX_BIBTEX_TYPES+1; i++)
301 userDefFlds[i] = NULL;
302
303 predefLst.allfields = NULL;
304 predefLst.bibtype = NULL;
305 predefLst.mainkey = NULL;
306 for (i=0; i<MAX_FIELDS; i++)
307 predefLst.field[i] = NULL;
308
309 initializeFields();
310
311 #ifdef SYSV
312 (void) getcwd(actual_path, MAX_FILEPATHLEN);
313 #else
314 (void) getwd(actual_path);
315 #endif
316
317
318 fieldNames[nannote] = XtCalloc(7, sizeof(char));
319 strcpy(fieldNames[nannote], "annote");
320
321
322 /* read rc options file */
323 if (options.rcfile != NULL)
324 rcfReadCfgFile(options.rcfile);
325 else if (access(DEFAULT_RCFILE, R_OK) != -1) {
326 /* read file in current directory */
327 rcfReadCfgFile(DEFAULT_RCFILE);
328 }
329 else {
330 /* look for file in $HOME-Directory */
331 if ((p = (char *)getenv("HOME")) != NULL) {
332 strcpy(path, p);
333 strcat(path, "/");
334 strcat(path, DEFAULT_RCFILE);
335 if (access(path, R_OK) != -1)
336 rcfReadCfgFile(path);
337 }
338 }
339
340 processCommandlineOptions();
341
342 if (options.bibdir != NULL)
343 procDefaultDirLine(options.bibdir);
344
345 /* create icon pixmaps, initialize main icon for bibview */
346 makeIconPixmaps();
347 sprintf(iconname, "%s %d.%d", PROGNAME, VERSION, PATCHLEVEL);
348 bvIconName = iconname;
349 XtVaSetValues(topLevel,
350 XtNiconPixmap, bvIconPixmap,
351 XtNtitle, bvIconName,
352 XtNiconName, bvIconName, NULL);
353
354 /* instance main window */
355 gwmMainWin();
356
357 XtRealizeWidget(topLevel);
358
359 /* load a file from command line */
360 if (options.bibfile != NULL)
361 {CollapsePath(options.bibfile, bibfile);
362 XtAppAddWorkProc(app_context, readBibfile, bibfile);
363 }
364
365 rcfSetPrintMode(FALSE);
366 rcfReadOptions(FALSE);
367 XtAppMainLoop(app_context);
368 }
369
370
371
372 /*********************************************************************/
373 /* LOCAL FUNCTIONS */
374 /*********************************************************************/
375
376
377 /*********************************************************************/
378 /* printHelp: */
379 /* Process excess options and show help */
380 /*********************************************************************/
381 static void
printHelp(int argc,char ** argv)382 printHelp (int argc, char **argv)
383 {
384 static char *help[] = {
385 "\n",
386 "bibview: Usage\n",
387 " bibview understands all standard Xt command-line options.\n",
388 "\n",
389 "Additional options are as follows:\n",
390 " Option Valid Range Function\n",
391 " -quiet none Turn off beep on error\n",
392 " -iconsOnDesk none Keep icons on bibview desktop\n",
393 " -makeBackup none Save files to backup on save\n",
394 " -autoCheck none Turn on/off consistency checking\n",
395 " -reqFields none Disallow empty required fields\n",
396 " -ignoreCase none Ignore case in search\n",
397 " -focus none Use <tab> and <esc> key in card window\n",
398 " -orig none Edit fields in original style\n",
399 " +quiet none Turn on/off beep on error\n",
400 " +iconsOnDesk none Don't keep icons on bibview desktop\n",
401 " +makeBackup none Don't save files to backup on save\n",
402 " +autoCheck none Turn off consistency checking\n",
403 " +reqFields none Allow empty required fields\n",
404 " +ignoreCase none Use case in search\n",
405 " +focus none Use mouse in card window\n",
406 " +orig none Edit fields in bibview style\n",
407 " -file BibTeX File Load BibTeX-File on startup\n",
408 " -rcfile bibview rcFile Use specific configuration file\n",
409 " -help none Show this list\n",
410 "\n",
411 NULL
412 };
413 char **p;
414 int i;
415
416 /* print help message */
417 p = help;
418 while (*p) {
419 fprintf(stderr, *p);
420 p++;
421 }
422
423 /* show illegal arguments */
424 if (strcmp(argv[1], "-help")) {
425 fprintf(stderr, "bibview: command line option unknown:\n");
426 for (i=1; i < argc; i++)
427 fprintf(stderr, " option: %s\n", argv[i]);
428 }
429 else {
430 /* just show help and exit */
431 exit(0);
432 }
433 }
434
435
436 /*********************************************************************/
437 /* processCommandlineOptions: */
438 /* Process options not controlling widgets */
439 /*********************************************************************/
440 static void
processCommandlineOptions(void)441 processCommandlineOptions (void)
442 {
443 optionsStatus[OPT_BEEP_ON_ERROR] = !options.quiet;
444 optionsStatus[OPT_BACKUP_ON_SAVE] = options.makeBackup;
445 optionsStatus[OPT_ICON_ON_DESKTOP] = options.iconsOnDesk;
446 optionsStatus[OPT_AUTO_CHECK_BIB] = options.autoCheck;
447 optionsStatus[OPT_REQUIRED_FIELDS] = options.reqFields;
448 optionsStatus[OPT_IGNORE_CASE] = options.ignoreCase;
449 optionsStatus[OPT_PRINT_AS_BIB] = options.printAsBib;
450 optionsStatus[OPT_DISPLAY_ERRWIN] = options.displayErrWin;
451 optionsStatus[OPT_FOCUS] = options.focus;
452 optionsStatus[OPT_ORIG] = options.orig;
453 }
454
455
456 /*********************************************************************/
457 /* readBibfile: */
458 /* Read a bibfile with name given on command line */
459 /*********************************************************************/
460 static Boolean
readBibfile(XtPointer clientData)461 readBibfile (XtPointer clientData)
462 {
463 String filename = (String)clientData;
464 BibPtr bp;
465 Errcode status;
466
467 /* check whether desktop positioned already */
468 if (XtWindow(desktop) == (Window) NULL)
469 return (False);
470
471 /* desktop is there, open file and window */
472 if ((status = glbNewBibListEl(&bp)) != OK) {
473 guwError(status);
474 return (True);
475 }
476 strcpy(bp->filename, filename);
477 if ((filename[0]!='/') && (filename[0]!='~')){
478 #ifdef SYSV
479 (void) getcwd(bp->filepath, MAX_FILEPATHLEN);
480 #else
481 (void) getwd(bp->filepath);
482 #endif
483 strcat(bp->filepath, "/");
484 strcat(bp->filepath, filename);
485 CollapsePath(bp->filepath, filename);
486 strcpy(bp->filepath, filename);
487 }
488 else
489 CollapsePath(filename, bp->filepath);
490 bp->mw=NULL;
491 bp->ew=NULL;
492 bp->lw=NULL;
493 bp->sortedby=sortedby;
494 glbReadFileOpenBib(bp);
495 return(True);
496
497 }
498
499
500 /*********************************************************************/
501 /* initializeFields: */
502 /* initialize standardfields and requiredfields */
503 /*********************************************************************/
504 static void
initializeFields(void)505 initializeFields (void)
506 {
507 int i, j;
508
509
510 max_fields = 24;
511 max_bibtex_types = 14;
512
513 list_layout = (listEntry *) XtCalloc(1, sizeof(listEntry));
514 list_layout->number = 0;
515 list_layout->field[list_layout->number] = nauthor;
516 list_layout->width[(list_layout->number)++] = 30;
517 list_layout->field[list_layout->number] = ntitle;
518 list_layout->width[(list_layout->number)++] = 50;
519 list_layout->field[list_layout->number] = nyear;
520 list_layout->width[(list_layout->number)++] = 5;
521 list_layout->field[list_layout->number] = -2; /* BibTeX type */
522 list_layout->width[(list_layout->number)++] = 10;
523 list_layout->field[list_layout->number] = -1; /* mainkey */
524 list_layout->width[(list_layout->number)++] = 10;
525
526 for (i=0; i< MAX_BIBTEX_TYPES+1; i++){
527 for (j=0; j< MAX_FIELDS; j++){
528 standardfields[i][j] = '0';
529 requiredfields[i][j] = '0';
530 }
531 }
532 for (i=0; i< max_bibtex_types; i++){
533 for (j=0; j<max_fields; j++){
534 standardfields[i][nmonth] = '1';
535 standardfields[i][nyear] = '1';
536 standardfields[i][nnote] = '1';
537 standardfields[i][nkey] = '1';
538 standardfields[i][nannote] = '1';
539 standardfields[i][ncrossref] = '1';
540 }
541 }
542
543 for (i=0; i< MAX_FIELDS; i++){
544 sort_field[i] = '0';
545 is_search_field[i] = '0';
546 }
547
548 for (i=0; i< max_fields; i++){
549 sort_field[i] = '1';
550 is_search_field[i] = '1';
551 }
552
553 sort_field[nauthor] = 'n';
554 sort_field[neditor] = 'n';
555
556 /* article */
557 standardfields[article][nauthor] =
558 requiredfields[article][nauthor] = '1';
559 standardfields[article][ntitle] =
560 requiredfields[article][ntitle] = '1';
561 standardfields[article][njournal] =
562 requiredfields[article][njournal] = '1';
563 requiredfields[article][nyear] = '1';
564
565 standardfields[article][nvolume] = '1';
566 standardfields[article][nnumber] = '1';
567 standardfields[article][npages] = '1';
568
569 /* book */
570 standardfields[book][nauthor] =
571 requiredfields[book][nauthor] = '1';
572 standardfields[book][neditor] =
573 requiredfields[book][neditor] = '1';
574 standardfields[book][ntitle] =
575 requiredfields[book][ntitle] = '1';
576 standardfields[book][npublisher] =
577 requiredfields[book][npublisher] = '1';
578 requiredfields[book][nyear] = '1';
579
580 standardfields[book][nvolume] = '1';
581 standardfields[book][nnumber] = '1';
582 standardfields[book][nseries] = '1';
583 standardfields[book][naddress] = '1';
584 standardfields[book][nedition] = '1';
585
586 /* booklet */
587 standardfields[booklet][ntitle] =
588 requiredfields[booklet][ntitle] = '1';
589
590 standardfields[booklet][nauthor] = '1';
591 standardfields[booklet][nhowpublished] = '1';
592 standardfields[booklet][naddress] = '1';
593
594 /* conference */
595 standardfields[conference][nauthor] =
596 requiredfields[conference][nauthor] = '1';
597 standardfields[conference][ntitle] =
598 requiredfields[conference][ntitle] = '1';
599 standardfields[conference][nbooktitle] =
600 requiredfields[conference][nbooktitle] = '1';
601 requiredfields[conference][nyear] = '1';
602
603 standardfields[conference][neditor] = '1';
604 standardfields[conference][nseries] = '1';
605 standardfields[conference][nvolume] = '1';
606 standardfields[conference][nnumber] = '1';
607 standardfields[conference][npages] = '1';
608 standardfields[conference][norganization] = '1';
609 standardfields[conference][npublisher] = '1';
610 standardfields[conference][naddress] = '1';
611
612 /* inbook */
613 standardfields[inbook][nauthor] =
614 requiredfields[inbook][nauthor] = '1';
615 standardfields[inbook][neditor] =
616 requiredfields[inbook][neditor] = '1';
617 standardfields[inbook][ntitle] =
618 requiredfields[inbook][ntitle] = '1';
619 standardfields[inbook][nchapter] =
620 requiredfields[inbook][nchapter] = '1';
621 standardfields[inbook][npages] =
622 requiredfields[inbook][npages] = '1';
623 standardfields[inbook][npublisher] =
624 requiredfields[inbook][npublisher] = '1';
625 requiredfields[inbook][nyear] = '1';
626
627 standardfields[inbook][nvolume] = '1';
628 standardfields[inbook][nnumber] = '1';
629 standardfields[inbook][nseries] = '1';
630 standardfields[inbook][naddress] = '1';
631 standardfields[inbook][ntype] = '1';
632 standardfields[inbook][nedition] = '1';
633
634 /* incollection */
635 standardfields[incollection][nauthor] =
636 requiredfields[incollection][nauthor] = '1';
637 standardfields[incollection][ntitle] =
638 requiredfields[incollection][ntitle] = '1';
639 standardfields[incollection][nbooktitle] =
640 requiredfields[incollection][nbooktitle] = '1';
641 standardfields[incollection][npublisher] =
642 requiredfields[incollection][npublisher] = '1';
643 requiredfields[incollection][nyear] = '1';
644
645 standardfields[incollection][neditor] = '1';
646 standardfields[incollection][nedition] = '1';
647 standardfields[incollection][nvolume] = '1';
648 standardfields[incollection][nnumber] = '1';
649 standardfields[incollection][nseries] = '1';
650 standardfields[incollection][ntype] = '1';
651 standardfields[incollection][nchapter] = '1';
652 standardfields[incollection][npages] = '1';
653 standardfields[incollection][naddress] = '1';
654
655 /* inproceedings */
656 standardfields[inproceedings][nauthor] =
657 requiredfields[inproceedings][nauthor] = '1';
658 standardfields[inproceedings][ntitle] =
659 requiredfields[inproceedings][ntitle] = '1';
660 standardfields[inproceedings][nbooktitle] =
661 requiredfields[inproceedings][nbooktitle] = '1';
662 requiredfields[inproceedings][nyear] = '1';
663
664 standardfields[inproceedings][neditor] = '1';
665 standardfields[inproceedings][nseries] = '1';
666 standardfields[inproceedings][nvolume] = '1';
667 standardfields[inproceedings][nnumber] = '1';
668 standardfields[inproceedings][npages] = '1';
669 standardfields[inproceedings][norganization] = '1';
670 standardfields[inproceedings][npublisher] = '1';
671 standardfields[inproceedings][naddress] = '1';
672
673
674 /* manual */
675 standardfields[manual][ntitle] =
676 requiredfields[manual][ntitle] = '1';
677
678 standardfields[manual][nauthor] = '1';
679 standardfields[manual][norganization] = '1';
680 standardfields[manual][naddress] = '1';
681 standardfields[manual][nedition] = '1';
682
683 /* mastersthesis */
684 standardfields[mastersthesis][nauthor] =
685 requiredfields[mastersthesis][nauthor] = '1';
686 standardfields[mastersthesis][ntitle] =
687 requiredfields[mastersthesis][ntitle] = '1';
688 standardfields[mastersthesis][nschool] =
689 requiredfields[mastersthesis][nschool] = '1';
690 requiredfields[mastersthesis][nyear] = '1';
691
692 standardfields[mastersthesis][naddress] = '1';
693 standardfields[mastersthesis][ntype] = '1';
694
695 /* misc */
696 standardfields[misc][nauthor] = '1';
697 standardfields[misc][ntitle] = '1';
698 standardfields[misc][nhowpublished] = '1';
699
700 /* phdthesis */
701 standardfields[phdthesis][nauthor] =
702 requiredfields[phdthesis][nauthor] = '1';
703 standardfields[phdthesis][ntitle] =
704 requiredfields[phdthesis][ntitle] = '1';
705 standardfields[phdthesis][nschool] =
706 requiredfields[phdthesis][nschool] = '1';
707 requiredfields[phdthesis][nyear] = '1';
708
709 standardfields[phdthesis][naddress] = '1';
710 standardfields[phdthesis][ntype] = '1';
711
712 /* proceedings */
713 standardfields[proceedings][ntitle] =
714 requiredfields[proceedings][ntitle] = '1';
715 requiredfields[proceedings][nyear] = '1';
716
717 standardfields[proceedings][neditor] = '1';
718 standardfields[proceedings][nvolume] = '1';
719 standardfields[proceedings][nnumber] = '1';
720 standardfields[proceedings][nseries] = '1';
721 standardfields[proceedings][npublisher] = '1';
722 standardfields[proceedings][norganization] = '1';
723 standardfields[proceedings][naddress] = '1';
724
725 /* techreport */
726 standardfields[techreport][nauthor] =
727 requiredfields[techreport][nauthor] = '1';
728 standardfields[techreport][ntitle] =
729 requiredfields[techreport][ntitle] = '1';
730 standardfields[techreport][ninstitution] =
731 requiredfields[techreport][ninstitution] = '1';
732 requiredfields[techreport][nyear] = '1';
733
734 standardfields[techreport][ntype] = '1';
735 standardfields[techreport][nnumber] = '1';
736 standardfields[techreport][naddress] = '1';
737
738 /* unpublished */
739 standardfields[unpublished][nauthor] =
740 requiredfields[unpublished][nauthor] = '1';
741 standardfields[unpublished][ntitle] =
742 requiredfields[unpublished][ntitle] = '1';
743 standardfields[unpublished][nnote] =
744 requiredfields[unpublished][nnote] = '1';
745
746 standardfields[MAX_BIBTEX_TYPES][nannote] = '1';
747 standardfields[MAX_BIBTEX_TYPES][nkey] = '1';
748 standardfields[MAX_BIBTEX_TYPES][nnote] = '1';
749 standardfields[MAX_BIBTEX_TYPES][ncrossref] = '1';
750
751 }
752
753
754 /*********************************************************************/
755 /* makeIconPixmaps: */
756 /* Create all pixmaps for application */
757 /*********************************************************************/
758 static void
makeIconPixmaps(void)759 makeIconPixmaps (void)
760 {
761 bvIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
762 RootWindowOfScreen(XtScreen(topLevel)),
763 (char *)bv_ico64_bits,
764 bv_ico64_width, bv_ico64_height);
765 lstIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
766 RootWindowOfScreen(XtScreen(topLevel)),
767 (char *)bv_lst64_bits,
768 bv_lst64_width, bv_lst64_height);
769 macIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
770 RootWindowOfScreen(XtScreen(topLevel)),
771 (char *)bv_mac64_bits,
772 bv_mac64_width, bv_mac64_height);
773 helpIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
774 RootWindowOfScreen(XtScreen(topLevel)),
775 (char *)bv_help64_bits,
776 bv_help64_width, bv_help64_height);
777 annoteIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
778 RootWindowOfScreen(XtScreen(topLevel)),
779 (char *)bv_annote64_bits,
780 bv_annote64_width, bv_annote64_height);
781 crdIconPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
782 RootWindowOfScreen(XtScreen(topLevel)),
783 (char *)bv_crd64_bits,
784 bv_crd64_width, bv_crd64_height);
785 chkmarkPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
786 RootWindowOfScreen(XtScreen(topLevel)),
787 (char *)chkmrk16_bits,
788 chkmrk16_width, chkmrk16_height);
789 errorPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
790 RootWindowOfScreen(XtScreen(topLevel)),
791 (char *)error32_bits,
792 error32_width, error32_height);
793 warnPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
794 RootWindowOfScreen(XtScreen(topLevel)),
795 (char *)warn32_bits,
796 warn32_width, warn32_height);
797 noticePixmap = XCreateBitmapFromData(XtDisplay(topLevel),
798 RootWindowOfScreen(XtScreen(topLevel)),
799 (char *)notice32_bits,
800 notice32_width, notice32_height);
801 questPixmap = XCreateBitmapFromData(XtDisplay(topLevel),
802 RootWindowOfScreen(XtScreen(topLevel)),
803 (char *)quest32_bits,
804 quest32_width, quest32_height);
805 progInfoPixmap =XCreateBitmapFromData(XtDisplay(topLevel),
806 RootWindowOfScreen(XtScreen(topLevel)),
807 (char *)proginfo_bits,
808 proginfo_width, proginfo_height);
809 }
810
811
812 /*********************************************************************/
813 /* ERROR HANDLING FUNCTIONS */
814 /*********************************************************************/
815
816 /*********************************************************************/
817 /* installErrorHandlers: */
818 /* Register signal, warning and error handlers */
819 /*********************************************************************/
820 static void
installErrorHandlers(void)821 installErrorHandlers (void)
822 {
823 int i;
824
825 /* install signal handler */
826 for (i = 1; i<= 15; i++)
827 signal(i, (sig_t)signalHandler);
828
829 /* install Xtoolkit handlers */
830 XtSetWarningHandler((XtErrorHandler)Xt_warningHandler);
831 XtSetErrorHandler((XtErrorHandler)Xt_errorHandler);
832
833 /* install X error handler */
834 XSetErrorHandler(X_errorHandler);
835 XSetIOErrorHandler(IO_errorHandler);
836 }
837
838
839 /*********************************************************************/
840 /* Xt_warningHandler: */
841 /* Xt warning handler */
842 /*********************************************************************/
843 static XtErrorHandler
Xt_warningHandler(String warn)844 Xt_warningHandler (String warn)
845 {
846 }
847
848
849 /*********************************************************************/
850 /* Xt_errorHandler: */
851 /* Xt warning handler */
852 /*********************************************************************/
853 static XtErrorHandler
Xt_errorHandler(String error)854 Xt_errorHandler (String error)
855 {
856 }
857
858
859 /*********************************************************************/
860 /* X_errorHandler: */
861 /* Service X protocol errors */
862 /*********************************************************************/
863 static int
X_errorHandler(Display * dsp,XErrorEvent * event)864 X_errorHandler (Display *dsp, XErrorEvent *event)
865 {
866 char msg[80];
867 XGetErrorText(dsp, event->error_code, msg, 80);
868 fprintf(stderr, "Error code %s\n", msg);
869 return(0);
870 }
871
872
873 /*********************************************************************/
874 /* IO_errorHandler: */
875 /* Service I/O errors from X */
876 /*********************************************************************/
877 static int
IO_errorHandler(Display * dsp)878 IO_errorHandler (Display *dsp)
879 {
880 fprintf(stderr, "Fatal Error on X Display %s\n",
881 (char *)XDisplayName(NULL));
882 exit(1);
883
884 }
885
886
887 /*********************************************************************/
888 /* signalHandler: */
889 /* Service signals */
890 /*********************************************************************/
891 static void
signalHandler(int s,int code)892 signalHandler (int s, int code)
893 {
894 signal(s, (sig_t)signalHandler);
895 }
896
897
898