1
0

Source code upload

This commit is contained in:
calmsacibis995
2022-09-29 17:59:04 +03:00
parent 72fa9da3d7
commit 8fc8fa8089
33399 changed files with 11964078 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
#
#**************************************************************************
#* *
#* Copyright (c) 1993 Silicon Graphics, Inc. *
#* All Rights Reserved *
#* *
#* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
#* *
#* The copyright notice above does not evidence any actual of intended *
#* publication of such source code, and is an unpublished work by Silicon *
#* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
#* the property of Silicon Graphics, Inc. Any use, duplication or *
#* disclosure not specifically authorized by Silicon Graphics is strictly *
#* prohibited. *
#* *
#* RESTRICTED RIGHTS LEGEND: *
#* *
#* Use, duplication or disclosure by the Government is subject to *
#* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
#* Technical Data and Computer Software clause at DFARS 52.227-7013, *
#* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
#* Supplement. Unpublished - rights reserved under the Copyright Laws of *
#* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
#* Shoreline Blvd., Mountain View, CA 94039-7311 *
#**************************************************************************
#*
#* Makefile - grelnotes viewer top level
#*
#* $Revision: 1.1 $
#*
#*
#**************************************************************************
DEPTH = .
include $(DEPTH)/viewerdefs
#
# If a subdirectory needs to be built it must be in this list. The
# include directory should be built first followed by the lib
# directory since subsequent directories depend on the include
# files and libraries.
#
SUBDIRS = include lib src cdrom
.PRECIOUS: $(SUBDIRS)
COMMONPREF = viewers_
default install $(COMMONTARGS):
@for d in $(SUBDIRS); do \
echo "=====\tcd $$d; $(MAKE) $@"; \
cd $$d; $(MAKE) $@; cd ..; \
done
$(SUBDIRS): $(_FORCE)
cd $@; $(MAKE)
include $(COMMONRULES)
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
SRCDIR=`dirname $0`/relnotes/
grelnotes -xrm "Grelnotes*relnotesPath: $SRCDIR"
+131
View File
@@ -0,0 +1,131 @@
#! /bin/sh
#Tag 0x00000600
# 'relnotes' - View on-line release notes
SRCDIR=`dirname $0`/relnotes/
Usage="\n
'relnotes -h' -- print this message\n
'relnotes' -- list products that have on-line release notes \n
\t\t\tcurrently installed\n
'relnotes <product>' -- show table of contents for a product's \n
\t\t\ton-line release notes\n
'relnotes <product> <chapter> ... ' -- display specific chapters of \n
\t\t\t\ta product's on-line release notes\n
'relnotes -t <product> <chapter> ... ' -- print specific chapters of \n
\t\t\t\ta product's on-line release notes\n"
if [ "$1" = "-h" ] # give help and exit
then
echo $Usage
exit
fi
list_relnotes=/tmp/relnoteslist$$
product=/tmp/relnotesproduct$$
cleanup="rm -f $list_relnotes $product"
trap "$cleanup" 1 2 3 15
# Create a list of products which have release notes installed.
HERE=`pwd`
cd $SRCDIR
find . -follow -type f -name "ch*.z" -print | \
sed -e 's%./%%' -e 's%/ch.*\.z%%' | sort -u > $list_relnotes
cd $HERE
if [ ! -s $list_relnotes ]
then
echo "Sorry, but no products have release notes installed\n"
rm -f $list_relnotes
exit
fi
if [ $# -eq 0 ] # no args - show installed relnotes
then
echo "The following products have release notes installed:\n"
cat $list_relnotes
$cleanup
exit
fi
validproduct=no
tflag=
while [ $# -gt 0 ] # As long as we have arguments ....
do
# Recognize old-style args, but don't support them.
if [ "$1" = "-p" ]
then
echo "The -p and -c options are no longer needed."
echo $Usage
$cleanup
exit 1
fi
# Support for printing chapters.
if [ "$1" = "-t" ]
then
tflag=$1
shift
continue
fi
# Invalid option?
if [ `expr "$1" : '\(.\).*'` = "-" ]
then
echo "$1 is an invalid option."
echo $Usage
$cleanup
exit 1
fi
if [ "$validproduct" = "no" ]
then
echo $1 > $product
match=`comm -12 $list_relnotes $product | wc -l`
if [ $match -eq 1 ];
then
validproduct=$1
shift
if [ $# -gt 0 ];
then
continue
fi
if [ -f $SRCDIR$validproduct/TC ];
then
echo "The chapters for the \"$validproduct\" product's release notes are:\n"
cat $SRCDIR$validproduct/TC
else
echo "The \"$validproduct\" product's release notes are installed, "
echo "but its table of contents file is missing.\n"
echo "The chapters that are installed are:\n"
cd $SRCDIR${validproduct}; /bin/ls ch*.z | sed -e 's/ch//' -e 's/.z//'
fi
else # Not an installed product
echo "Sorry, but there are no installed release notes for the \"$1\" product.\n"
$cleanup ; exit 1
fi
else # Have a valid product.
cd $SRCDIR$validproduct
# Check for the existence of ch#.z. If not found check
# for ch0#.z. If still not found report an error
if [ -r ch${1}.z ]; then
man $tflag -d ch${1}.z
elif [ -r ch0${1}.z ]; then
man $tflag -d ch0${1}.z
else
echo "There is no chapter $1 in the \"$validproduct\" release notes."
fi
shift
if [ $# -gt 0 ];
then
echo "Next chapter ('q' to quit):\c"
read ans
if [ "$ans" = "q" ];
then
$cleanup
exit
fi
fi
fi
done
$cleanup
+41
View File
@@ -0,0 +1,41 @@
#**************************************************************************
#* *
#* Copyright (C) 1991, Silicon Graphics, Inc. *
#* All Rights Reserved. *
#* *
#* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
#* the contents of this file may not be disclosed to third parties, *
#* copied or duplicated in any form, in whole or in part, without the *
#* prior written permission of Silicon Graphics, Inc. *
#* *
#* RESTRICTED RIGHTS LEGEND: *
#* Use, duplication or disclosure by the Government is subject to *
#* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
#* in Technical Data and Computer Software clause at DFARS *
#* 252.227-7013, and/or in similar or successor clauses in the FAR, *
#* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
#* the Copyright Laws of the United States. *
#**************************************************************************
#*
#* Makefile - CD ROM based release note tools
#*
#* $Revision: 1.1 $
#*
#*
#**************************************************************************/
DEPTH = ..
include $(DEPTH)/viewerdefs
SHFILES = CDrelnotes.sh CDgrelnotes.sh
TARGETS = CDgrelnotes CDrelnotes
default all: $(TARGETS)
include $(COMMONRULES)
install: all
+129
View File
@@ -0,0 +1,129 @@
/**************************************************************************
* *
* Copyright (c) 1991 Silicon Graphics, Inc. *
* All Rights Reserved *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
* *
* The copyright notice above does not evidence any actual of intended *
* publication of such source code, and is an unpublished work by Silicon *
* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
* the property of Silicon Graphics, Inc. Any use, duplication or *
* disclosure not specifically authorized by Silicon Graphics is strictly *
* prohibited. *
* *
* RESTRICTED RIGHTS LEGEND: *
* *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
* Technical Data and Computer Software clause at DFARS 52.227-7013, *
* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
* Supplement. Unpublished - rights reserved under the Copyright Laws of *
* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
* Shoreline Blvd., Mountain View, CA 94039-7311 *
**************************************************************************
*
* File: Formatter.h
*
* Description: Include file for the text document reading functions
*
**************************************************************************/
#ident "$Revision: 1.2 $"
#ifndef _VWR_FORMATTER_H_
#define _VWR_FORMATTER_H_
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
/* Text format tokens */
#define FMT_UNKNOWN 0
#define FMT_GENERIC 1
#define FMT_NROFF_MAN 2
#define FMT_NROFF_MM 3
#define FMT_ZCAT 4
#define FMT_PCAT 5
#define FMT_GZCAT 6
#define FMT_GZCAT_HTML 7
#define NUM_FMT 8
/* Font style tokens */
#define NUM_STYLES 8
#define NUM_NORM_STYLES 4
#define UNKNOWN_STYLE 0xF
#define NORMAL_STYLE 0x0
#define UNDERLINE_STYLE 0x1
#define BOLD_STYLE 0x2
#define BOLDUNDER_STYLE 0x3
#define NORMAL_SELECT 0x4
#define UNDERLINE_SELECT 0x5
#define BOLD_SELECT 0x6
#define BOLDUNDER_SELECT 0x7
#define SELECT_MASK 0x4
/* Text style structure */
typedef struct {
XFontStruct *font; /* Font */
Pixel fore; /* Foreground color */
GC gc; /* Graphics context */
} vwr_text_style_t;
/* Text segment structure */
/* A contiguous piece of text on a line in the same font
*/
typedef struct _vwr_text_seg_t {
ushort seg_nchars; /* # chars in segment */
uint seg_len: 12; /* Pixel length of segment */
uint seg_type: 4; /* Style type index */
struct _vwr_text_seg_t *next; /* Pointer to next segment on list */
} vwr_text_seg_t;
/* Text line structure */
typedef struct {
char *line_chars; /* Line text string */
vwr_text_seg_t *segs; /* List of string segments */
vwr_text_seg_t *last_seg; /* Last segment on list */
ushort line_nchars; /* # chars (not incl. \n) */
uint line_len: 15; /* Total pixel length of line */
uint end_select: 1; /* End of line selected flag */
} vwr_text_line_t;
/* Text structure */
typedef struct {
vwr_text_line_t *lines; /* Lines of text */
int nlines; /* Number of lines of text */
uint max_line_len; /* Pixel length of longest line */
char *char_buf; /* Complete processed text buffer */
} vwr_text_t;
/* Public functions */
#ifdef __cplusplus
extern "C" {
#endif
extern int VwrFormatText(char*, char*, int);
extern void VwrInitText(vwr_text_t*);
extern int VwrReadText(char*, vwr_text_t*, vwr_text_style_t*, int);
extern void VwrFreeText(vwr_text_t*);
#ifdef __cplusplus
}
#endif
#endif
+44
View File
@@ -0,0 +1,44 @@
#
#**************************************************************************
#* *
#* Copyright (c) 1991 Silicon Graphics, Inc. *
#* All Rights Reserved *
#* *
#* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
#* *
#* The copyright notice above does not evidence any actual of intended *
#* publication of such source code, and is an unpublished work by Silicon *
#* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
#* the property of Silicon Graphics, Inc. Any use, duplication or *
#* disclosure not specifically authorized by Silicon Graphics is strictly *
#* prohibited. *
#* *
#* RESTRICTED RIGHTS LEGEND: *
#* *
#* Use, duplication or disclosure by the Government is subject to *
#* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
#* Technical Data and Computer Software clause at DFARS 52.227-7013, *
#* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
#* Supplement. Unpublished - rights reserved under the Copyright Laws of *
#* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
#* Shoreline Blvd., Mountain View, CA 94039-7311 *
#**************************************************************************
#*
#* Makefile - include, libvwr header files
#*
#* $Revision: 1.1 $
#*
#**************************************************************************
DEPTH = ..
include $(DEPTH)/viewerdefs
TARGETS =
default:
include $(COMMONRULES)
install: default
+117
View File
@@ -0,0 +1,117 @@
/**************************************************************************
* *
* Copyright (c) 1991 Silicon Graphics, Inc. *
* All Rights Reserved *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
* *
* The copyright notice above does not evidence any actual of intended *
* publication of such source code, and is an unpublished work by Silicon *
* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
* the property of Silicon Graphics, Inc. Any use, duplication or *
* disclosure not specifically authorized by Silicon Graphics is strictly *
* prohibited. *
* *
* RESTRICTED RIGHTS LEGEND: *
* *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
* Technical Data and Computer Software clause at DFARS 52.227-7013, *
* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
* Supplement. Unpublished - rights reserved under the Copyright Laws of *
* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
* Shoreline Blvd., Mountain View, CA 94039-7311 *
**************************************************************************
*
* File: TextView.h
*
* Description: Public include file for the multi-font text viewer widget.
*
**************************************************************************/
#ident "$Revision: 1.1 $"
#ifndef _VWR_TEXTVIEW_H_
#define _VWR_TEXTVIEW_H_
/* Resource names */
#define VwrNtextColumns "textColumns"
#define VwrNtextRows "textRows"
#define VwrNblankCompress "blankCompress"
#define VwrNtextFile "textFile"
#define VwrNverticalScrollBar "verticalScrollBar"
#define VwrNhorizontalScrollBar "horizontalScrollBar"
#define VwrNnormFont "normalFont"
#define VwrNunderlineFont "underlineFont"
#define VwrNboldFont "boldFont"
#define VwrNboldUnderFont "boldUnderFont"
#define VwrNnormFore "normalForeground"
#define VwrNunderlineFore "underlineForeground"
#define VwrNboldFore "boldForeground"
#define VwrNboldUnderFore "boldUnderForeground"
#define VwrNselectionFore "selectionForeground"
#define VwrNselectionBack "selectionBackground"
#define VwrNloadCallback "loadCallback"
/* Resource classes */
#define VwrCTextColumns "TextColumns"
#define VwrCTextRows "TextRows"
#define VwrCBlankCompress "BlankCompress"
#define VwrCTextFile "TextFile"
#define VwrCScrollBar "ScrollBar"
#define VwrCLoadCallback "LoadCallback"
/* Class record info */
extern WidgetClass vwrTextViewWidgetClass;
typedef struct _VwrTextViewClassRec *VwrTextViewWidgetClass;
typedef struct _VwrTextViewRec *VwrTextViewWidget;
/* Text position structure */
typedef struct {
int line; /* Line number (starts at 0) */
int col; /* Column number (starts at 0) */
} VwrPositionStruct;
/* File load callback structure */
/* Note that storage for the fields is reused and members
of long term interest should be copied to the user space
*/
typedef struct {
char *filename; /* Name of file that was loaded */
} VwrTextViewLoadCallbackStruct;
/* Public functions */
#ifdef __cplusplus
extern "C" {
#endif
extern Widget VwrCreateScrolledTextView(Widget, char*, Boolean, Boolean);
extern void VwrTextViewClearSelection(Widget);
extern void VwrTextViewSetSelection(Widget, VwrPositionStruct*,
VwrPositionStruct*, Boolean);
extern char* VwrTextViewReadSelection(Widget, unsigned long*);
extern int VwrTextViewSearch(Widget, char*, Boolean, VwrPositionStruct*,
VwrPositionStruct*);
#ifdef __cplusplus
}
#endif
#endif
+131
View File
@@ -0,0 +1,131 @@
/**************************************************************************
* *
* Copyright (c) 1991 Silicon Graphics, Inc. *
* All Rights Reserved *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
* *
* The copyright notice above does not evidence any actual of intended *
* publication of such source code, and is an unpublished work by Silicon *
* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
* the property of Silicon Graphics, Inc. Any use, duplication or *
* disclosure not specifically authorized by Silicon Graphics is strictly *
* prohibited. *
* *
* RESTRICTED RIGHTS LEGEND: *
* *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
* Technical Data and Computer Software clause at DFARS 52.227-7013, *
* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
* Supplement. Unpublished - rights reserved under the Copyright Laws of *
* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
* Shoreline Blvd., Mountain View, CA 94039-7311 *
**************************************************************************
*
* File: TextViewP.h
*
* Description: Private include file for the multi-font text viewer widget.
*
**************************************************************************/
#ident "$Revision: 1.1 $"
#ifndef _VWR_TEXTVIEWP_H_
#define _VWR_TEXTVIEWP_H_
#include <Xm/XmP.h>
#include <Xm/PrimitiveP.h>
#include "TextView.h"
/* No resource specified defaults */
#define DEF_COLOR 0xFFFFFFFF
#define DEF_TEXT_COLS 80
#define DEF_TEXT_ROWS 24
#define DEF_NORM_FONT "Fixed"
#define DEF_UNDERLINE_FONT "Fixed"
#define DEF_BOLD_FONT "Fixed"
#define DEF_BOLDUNDER_FONT "Fixed"
#define DEF_NORM_FORE DEF_COLOR
#define DEF_UNDERLINE_FORE DEF_COLOR
#define DEF_BOLD_FORE DEF_COLOR
#define DEF_BOLDUNDER_FORE DEF_COLOR
#define DEF_SELECT_FORE DEF_COLOR
#define DEF_SELECT_BACK DEF_COLOR
#define DEF_BLANK_COMPRESS 0
/* Misc macros */
#define TV_FWIDTH(f) (((f)->per_char) ? (\
((f)->per_char['n'].width > 0) ? \
(f)->per_char['n'].width: \
(f)->max_bounds.width \
): (f)->max_bounds.width)
#define TV_MAX(a,b) (((a) > (b)) ? (a) : (b))
/* Class part and record structures */
typedef struct {
int dummy; /* To keep compiler happy */
} VwrTextViewClassPart;
typedef struct _VwrTextViewClassRec {
CoreClassPart core_class;
XmPrimitiveClassPart primitive_class;
VwrTextViewClassPart vwrTextView_class;
} VwrTextViewClassRec;
/* Instance part and record structures */
typedef struct {
/* Resources */
int text_columns; /* Number of columns for text view */
int text_rows; /* Number of rows for text view */
vwr_text_style_t styles[NUM_STYLES];/* Text styles (font, fore, etc.) */
Pixel select_fore; /* Selection foreground color */
Pixel select_back; /* Selection background color */
int blank_compress; /* Num lines for blank compression */
char *filename; /* Text file to view */
Widget vsb; /* Viewer's vert. scrollbar, if any */
Widget hsb; /* Viewer's horiz. scrollbar, if any */
XtCallbackList load_callback; /* Viewer load callback functions */
/* Private state */
vwr_text_t text; /* Viewer text */
GC fill_gc; /* GC for line filling */
GC select_fill_gc; /* GC for selected line filling */
GC blanks[NUM_NORM_STYLES]; /* Line clearing GCs */
int def_height, def_width; /* Default height and width */
int fontheight; /* Max font height, descent + ascent */
int fontwidth; /* Max font width */
int fontascent; /* Max font ascent */
int top; /* Line at top of window */
int left; /* Column at left of window */
VwrPositionStruct sel_mark; /* Select mark */
VwrPositionStruct sel_point; /* Select point */
XtIntervalId timer; /* Scrolling timer */
int top_pending; /* Scroll drag value */
char *sel_data; /* Selection data buffer */
char *search_next; /* Start addr for next text search */
char *comp_exp; /* Compiled search regular expr */
} VwrTextViewPart;
typedef struct _VwrTextViewRec {
CorePart core;
XmPrimitivePart primitive;
VwrTextViewPart textView;
} VwrTextViewRec;
#endif
+819
View File
@@ -0,0 +1,819 @@
/**************************************************************************
* *
* Copyright (C) 1991, Silicon Graphics, Inc. *
* All Rights Reserved. *
* *
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
* the contents of this file may not be disclosed to third parties, *
* copied or duplicated in any form, in whole or in part, without the *
* prior written permission of Silicon Graphics, Inc. *
* *
* RESTRICTED RIGHTS LEGEND: *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
* in Technical Data and Computer Software clause at DFARS *
* 252.227-7013, and/or in similar or successor clauses in the FAR, *
* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
* the Copyright Laws of the United States. *
**************************************************************************
*
* File: Formatter.c
*
* Description: Routines for formatting and reading ASCII and nroff
* text into a program buffer.
*
**************************************************************************/
#ident "$Revision: 1.3 $"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <malloc.h>
#include "Formatter.h"
#define MAXLINESIZE BUFSIZ /* BUFSIZ defined in stdio.h */
#define TABSIZE 8 /* Number of spaces in a tab */
/* Line buffer allocation constants */
#define CHARS_PER_LINE 40 /* Guess as to # chars per line */
#define ADD_MORE_LINES 100 /* Add in 100 line chunks */
#define ADD_MORE_CHARS 1024 /* Amount to grow the text buffer */
/* Characters */
#define CAR_RET '\r'
#define TAB '\t'
#define ESCAPE '\033'
#define BACKSPACE '\010'
/* Formatting commands */
#define NEQN_CMD "/usr/bin/neqn /usr/pub/eqnchar"
#define TBL_CMD "/usr/bin/tbl"
#define NROFF_CMD "/usr/bin/nroff -i"
#define COL_CMD "/usr/bin/col -f"
#define ZCAT_CMD "/usr/bsd/zcat"
#define PCAT_CMD "/usr/bin/pcat"
#define CAT_CMD "/bin/cat"
#define GZCAT_CMD "/usr/sbin/gzcat -c"
#define HTML_CMD "/usr/sbin/html2term"
/* Font change test macro */
/* Tests whether the current font is the same as the specified font.
If the fonts are different, a new segment is added to the current
line in the current font and the buffer is reset.
*/
#define FONT_CHANGE_TEST(font) if (font_flag != UNKNOWN_STYLE && \
font_flag != (font)) { \
*tbptr = '\0'; \
skip_under = 0; \
add_text(line, line_chars, temp_buf, \
font_flag); \
*temp_buf = '\0'; \
tbptr = temp_buf; \
}
static char *process_line(vwr_text_line_t*, char*, char**);
static char *classify(char*, char*, int*);
static void add_text(vwr_text_line_t*, char*, char*, int);
static vwr_text_style_t *text_styles;
/* Formatting commands */
static char *format_cmds[] = {
{""}, /* FMT_NULL */
{CAT_CMD" %s > %s"}, /* FMT_GENERIC */
{NEQN_CMD" %s|"TBL_CMD"|"NROFF_CMD" -man|"COL_CMD">%s"}, /* FMT_NROFF_MAN */
{NEQN_CMD" %s|"TBL_CMD"|"NROFF_CMD" -mm|"COL_CMD">%s"}, /* FMT_NROFF_MM */
{ZCAT_CMD" %s|"COL_CMD">%s"}, /* FMT_ZCAT */
{PCAT_CMD" %s|"COL_CMD">%s"}, /* FMT_PCAT */
{GZCAT_CMD" %s|"COL_CMD">%s"}, /* FMT_GZCAT */
{GZCAT_CMD" %s|"HTML_CMD"|"COL_CMD">%s"}, /* FMT_GZCAT_HTML*/
};
/**************************************************************************
*
* Function: VwrFormatText
*
* Description: Takes a file in a number of formats and converts it to
* nroff output format. The resulting file can then be read by
* VwrReadText into a program buffer.
*
* Parameters:
* source_name (I) - source text file pathname
* dest_name (I) - formatted output file pathname
* source_format (I) - format of source file. One of:
*
* FMT_NROFF_MAN - Unformatted nroff man page
* FMT_NROFF_MM - Unformatted nroff mm doc
* FMT_ZCAT - Compressed formatted nroff
* FMT_PCAT - Packed formatted nroff
* FMT_GENERIC - A copy operation
* FMT_UNKNOWN - Unknown, take best guess
*
* Return: 0 if successfull at formatting. If an error has occurred -1
* will be returned and errno will be set.
*
**************************************************************************/
int VwrFormatText(char *source_name, char *dest_name, int source_format)
{
char cmd[BUFSIZ], buffer[BUFSIZ], new_name[BUFSIZ];
char *suffix;
int exit_status;
/*
* Determine the file suffix
*/
suffix = strrchr(source_name, '.');
/*
* If format unknown try to determine it by
* looking at the file suffix
*/
if (source_format == FMT_UNKNOWN) {
if (!suffix)
source_format = FMT_NROFF_MM;
else if (strcmp(suffix, ".z") == 0)
source_format = FMT_PCAT;
else if (strcmp(suffix, ".Z") == 0)
source_format = FMT_ZCAT;
else
source_format = FMT_NROFF_MAN;
}
if (strcmp(suffix, ".gz") == 0) {
if (strstr(source_name, "/ch"))
source_format = FMT_GZCAT;
else
source_format = FMT_GZCAT_HTML;
}
/*
* pcat and zcat are very finnicky. They insist on the files they work
* with ending in .z and .Z repsectively. We now ensure that this is the
* case for those formatting situations.
*
* We finally issue the formatting command.
*/
if (source_format == FMT_PCAT) {
if (strcmp(source_name, ".z") != 0) {
sprintf(new_name, "%s.z", dest_name);
sprintf(buffer, "ln -s %s %s; %s; rm -f %s",
source_name, new_name,
format_cmds[source_format],
new_name);
sprintf(cmd, buffer, new_name, dest_name);
} else
sprintf(cmd, format_cmds[source_format], source_name, dest_name);
} else if (source_format == FMT_ZCAT) {
if (strcmp(source_name, ".Z") != 0) {
sprintf(new_name, "%s.Z", dest_name);
sprintf(buffer, "ln -s %s %s; %s; rm -f %s",
source_name, new_name,
format_cmds[source_format],
new_name);
sprintf(cmd, buffer, new_name, dest_name);
} else
sprintf(cmd, format_cmds[source_format], source_name, dest_name);
} else {
sprintf(cmd, format_cmds[source_format], source_name, dest_name);
}
exit_status = system(cmd);
return(WEXITSTATUS(exit_status));
}
/**************************************************************************
*
* Function: VwrReadText
*
* Description: Reads the nroff output format text from the file specified.
* Each line of text in the file is processed such that the text and
* attributes are separated. The text goes into one large text buffer,
* while the attributes for each line are formed into a linked list
* of text attribute segment for each line. A text attribute segment
* is a continous piece of the text line in the same font. So a line
* all in normal font text would consist of one segment whereas a line
* of text with the first word bolded and all subsequent text in normal
* font would consist of two segments. Each segment contains the number
* of characters in the segment and the line structure contains a
* pointer to the \n terminated string of characters in the text buffer
* that comprises the line.
*
* The motivation for one large text buffer is to allow regular
* expression text searching using the off-the-shelf search routines.
*
* Parameters:
* filename (I) - name of text file to read
* text (O) - text structure to fill with newly read text
* styles (I) - array of styles for the text. The array of styles must
* be organised as follows:
* styles[0] - style for normal text
* styles[1] - style for underlined text
* styles[2] - style for bold text
* styles[3] - style for bold underlined text
* blank_compress (I) - Blank line compression
*
* Return: If successful, 0 is returned. If an error occurs, a message
* is printed to stderr, errno is set and -1 is returned.
*
**************************************************************************/
int VwrReadText(char *filename, vwr_text_t *text, vwr_text_style_t *styles,
int blank_compress)
{
FILE *fp;
char buf[MAXLINESIZE], *new_buf, *bptr;
char *processed_line;
vwr_text_line_t *tlptr;
int nlines_guess, len;
int buf_amount;
register int char_buf_off;
register int buf_used;
register int i, line_num, blank_count, base;
struct stat fileinfo;
/*
* Save the list of styles for future reference
*/
text_styles = styles;
/*
* Open the file.
*/
if ((fp = fopen(filename, "rb")) == NULL) {
(void)fprintf(stderr, "Unable to open %s\n", filename);
return(-1);
}
/*
* Based on the size of the file and a guess as to the number of
* characters per line we will take a guess as to the number of lines
* of text in the file. We will allocate the line buffers based on
* this guess. If it proves to be insufficient we will grow the
* buffer dynamically based on ADD_MORE_LINES
*/
if (fstat(fileno(fp), &fileinfo)) {
(void)fprintf(stderr, "Unable to stat %s\n", filename);
return(-1);
}
VwrFreeText(text);
buf_amount = fileinfo.st_size;
nlines_guess = buf_amount / CHARS_PER_LINE;
text->lines = (vwr_text_line_t*)malloc(nlines_guess *
sizeof(vwr_text_line_t));
/*
* Based on the size of the unprocessed text file we will allocate
* the text buffer. This is ussually sufficient, but in uncommon cases
* where the file contains a large number of tab characters we will have
* to grow this buffer.
*/
text->char_buf = (char*)malloc(buf_amount);
/*
* Read each line of the file into the buffer, process the line
* to interpret bolds, underlines and tabs. Some lines
* (mainly tbl output) contain multiple lines. These are broken
* into separate lines and added to the text structure.
*/
char_buf_off = 0; /* Start at beginning of char buf */
line_num = blank_count = 0; /* First line, no blanks */
buf_used = 0; /* Haven't used any of the char buf */
while ((bptr = fgets(buf, MAXLINESIZE, fp)) != NULL) {
do {
/*
* Blank compression
*/
if (blank_compress && (*bptr == '\n')) {
if (++blank_count / blank_compress)
continue;
}
else
blank_count = 0;
/*
* Line buffer allocation heuristic
*/
if ((line_num + 1) > nlines_guess) {
nlines_guess += ADD_MORE_LINES;
text->lines = (vwr_text_line_t*)realloc((char*)text->lines,
nlines_guess * sizeof(vwr_text_line_t));
}
/*
* Process the line into attributes and plain text
*/
tlptr = &text->lines[line_num];
processed_line = process_line(tlptr, bptr, &new_buf);
/*
* Add a \n to the end of the plain text line and
* append this line to the character buffer. The buffer
* is grown if necessary
*/
len = tlptr->line_nchars;
processed_line[len++] = '\n';
processed_line[len] = '\0';
buf_used += len + 2;
if (buf_used >= buf_amount) {
buf_amount += ADD_MORE_CHARS;
text->char_buf = (char*)realloc(text->char_buf, buf_amount);
}
(void)memcpy(text->char_buf + char_buf_off, processed_line, len+1);
tlptr->line_chars = (char*)char_buf_off;
char_buf_off += len;
/*
* Check max line length stat
*/
if (tlptr->line_len > text->max_line_len)
text->max_line_len = tlptr->line_len;
/*
* Next line
*/
line_num++;
/*
* Multiple lines on a single line processing
*/
if (new_buf)
bptr = new_buf;
} while (new_buf); /* Do while multiple lines on single line */
}
/*
* Close the file.
*/
(void)fclose(fp);
/*
* Save the number of lines
*/
text->nlines = line_num;
/*
* Convert the text buffer offsets into text buffer addresses.
* This is done by adding the text buffer base address to the
* offsets for each line
*/
base = (int)(text->char_buf);
for (i = 0, tlptr = text->lines; i < line_num; i++, tlptr++)
tlptr->line_chars += base;
return(0);
}
/**************************************************************************
*
* Function: VwrInitText
*
* Description: Initializes a text buffer
*
* Parameters:
* text (I) - newly instanciated text buffer
*
* Return: none
*
**************************************************************************/
void VwrInitText(vwr_text_t *text)
{
text->nlines = 0;
text->lines = (vwr_text_line_t*)NULL;
text->char_buf = NULL;
text->max_line_len = 0;
}
/**************************************************************************
*
* Function: VwrFreeText
*
* Description: Frees the text buffer if one has been allocated.
*
* Parameters: none
*
* Return: none
*
**************************************************************************/
void VwrFreeText(vwr_text_t *tbuf)
{
register int i;
register vwr_text_line_t *tptr;
register vwr_text_seg_t *tsptr, *temp;
/*
* Free each string segment, then free each lines segment array
* and finally free the array of lines. Make sure that we have a
* non-NULL pointer and a non-zero line count.
*/
if (tbuf->lines && tbuf->nlines) {
for (i = 0, tptr = tbuf->lines; i < tbuf->nlines; i++, tptr++) {
if (tptr->segs) {
tsptr = tptr->segs;
while (tsptr) {
temp = tsptr->next;
free((char*)tsptr);
tsptr = temp;
}
}
tptr->line_len = 0;
tptr->segs = tptr->last_seg = NULL;
}
free((char*)tbuf->lines);
}
if (tbuf->char_buf)
free((char*)tbuf->char_buf);
VwrInitText(tbuf);
}
/*
==========================================================================
LOCAL FUNCTIONS
==========================================================================
*/
/**************************************************************************
*
* Function: process_line
*
* Description: Takes the specified, null terminated line and constructs
* a string segment array based on the text in that string. The
* function interprets normal text, boldifying and underlining and
* converts these to different fonts. The function also expands
* tabs. The function also handles the occurence of multiple lines
* contained on a single input line. This occurs with tbl output
* since it contains forward half-newlines followed by the \r
* character.
*
* Parameters:
* line (O) - Pointer to the text line structure
* buf (I) - Null terminated line of text
* new_bufp (O) - A new line of text extracted from the original
* line and detected by the presence of a ^M. If
* the original line does not contain another line,
* this variable will be set to NULL.
*
* Return: Pointer to processed plain text line buffer.
*
**************************************************************************/
static char *process_line(vwr_text_line_t *line, char *buf, char **new_bufp)
{
int skip_under = 0;
int len, again;
int fill, cpos;
int font_flag, style;
register int i, j;
char temp_buf[MAXLINESIZE];
char line_chars[MAXLINESIZE];
char base_char, next_base;
register char *tbptr, *bptr;
/*
* Get length of string and strip trailing \n if any
*/
len = strlen(buf);
if (buf[len-1] == '\n')
buf[len-1] = '\0';
/*
* Interpret the line
*
* buf - original string
* temp_buf - processed string segment. Added to string segment array
* with each font change and at end of line.
*/
line->segs = NULL; /* Initially empty list */
line->last_seg = NULL; /* Nothing in list */
line->line_len = 0; /* And no line length */
line->line_nchars = 0; /* And no characters */
line->end_select = False; /* End of line not selected */
line->line_chars = NULL; /* Start with empty line */
*line_chars = '\0'; /* Start with empty accum buffer */
cpos = 0; /* Processed line character position */
bptr = buf; /* Line buffer pointer */
tbptr = temp_buf; /* String building buffer ptr */
font_flag = UNKNOWN_STYLE; /* Font is not known at start */
*new_bufp = (char*)NULL; /* Assume no addtional lines */
again = TRUE; /* Continue flag */
for (i = 0; i <= len && again; i++) {
switch (*bptr) {
/*
* A NULL indicates the end of the line. Just tack it
* onto the accumulation buffer and signal to stop processing.
*/
case '\0':
*tbptr = *bptr; /* Pass character from buf to temp */
again = FALSE; /* End of the line */
break;
/*
* Tabs will be expanded with enough ' ' characters to get
* to the next tab stop. The number of ' ' characters between
* tab stops is specified by TABSIZE.
*/
case TAB:
fill = (cpos / TABSIZE + 1) * TABSIZE - cpos;
cpos += fill;
for (j = 0; j < fill; j++)
*tbptr++ = ' ';
bptr++;
break;
/*
* tbl output processed by col -f has forward half linefeeds
* and can follow these with a \r character for table lines.
* We break this kind of thing into multiple lines and use the
* new_buf pointer to indicate the condition.
*/
case CAR_RET:
*bptr = '\0';
*new_bufp = bptr + 1;
break;
/*
* Escape characters will be ignored. We must also ignore
* the '9' charcter that follows an escape since an ESC-9
* is the forward half-linefeed indication output by col -f.
*/
case ESCAPE:
bptr++;
if (*bptr == '9')
bptr++;
break;
/*
* Handle printable characters. This part of the switch
* supervises the classification of the unprocessed
* character and the addition of text to the output
* text buffer.
*/
default:
bptr = classify(bptr, &base_char, &style);
/*
* For bold, underline and bold underlined text
*/
if (style != NORMAL_STYLE) {
FONT_CHANGE_TEST(style);
font_flag = style;
*tbptr = base_char;
/*
* If the current character is caps then decide
* if '_' should be skipped for this segment. We
* skip '_' if this segment has any words that start
* with cap letters.
*/
if (isupper((int)base_char)) {
if (tbptr == temp_buf) {
skip_under = 1;
} else if (tbptr[-1] == ' ') {
skip_under = 1;
}
}
tbptr++;
}
/*
* For normal text
*/
else {
/*
* Note that when in underline or bold underline font
* words are separated with '_' instead of ' '. This
* posess a problem for variables in these fonts that
* use underscores as part of the variable. We use a
* heuristic to determine whether to print the '_'.
* The heuristic is:
*
* if (current font is underline or bold underline)
* If (no upper case chars have started words
* in this text segment and we have not
* skipped any '_' in this segment)
* If (char after '_' is lower case or
* is a digit or segment started
* with '|' [tbl])
* print '_'
* else
* print ' '
* skip all rest of '_' in this segment
*/
if (base_char == '_' && (font_flag == UNDERLINE_STYLE ||
font_flag == BOLDUNDER_STYLE)) {
(void)classify(bptr, &next_base, &style);
if (skip_under || (!islower((int)next_base) &&
!isdigit((int)next_base)) &&
*temp_buf != '|') {
*tbptr++ = ' ';
skip_under = 1;
} else {
*tbptr++ = base_char;
}
}
/*
* Purely normal text
*/
else {
FONT_CHANGE_TEST(style);
font_flag = style;
*tbptr++ = base_char;
}
}
cpos++;
break;
}
}
/*
* End last part of line, if any
*/
if (tbptr != temp_buf && font_flag != UNKNOWN_STYLE)
add_text(line, line_chars, temp_buf, font_flag);
return line_chars;
}
/**************************************************************************
*
* Function: classify
*
* Description: Classifies the font style of the specified unprocessed
* character.
*
* The font styles are identified in the text as follows:
*
* abcd Normal font
* _^Ha_^Hb_^Hc_^Hd Underline font
* a^Ha^Hab^Hb^Hb Bold font
* _^Ha^Ha^Ha_^Hb^Hb^Hb Bold underline font
*
* For underline, bold and bold underline fonts the base character
* (ie. the character that is actually printed on the screen) is
* the character following the first backspace.
*
* Parameters:
* bptr (I) - Pointer to location in unprocessed character buffer
* where character starts,
* basep (O) - Actual character represented
* stylep (O) - Character font style. One of NORMAL_STYLE, BOLD_STYLE,
* UNDERLINE_STYLE or BOLDUNDER_STYLE.
*
* Return: Pointer to start of next unprocessed character
*
**************************************************************************/
static char *classify(char *bptr, char *basep, int *stylep)
{
/*
* Non-normal font with have a BACKSPACE immediately after
* the current character.
*/
if (bptr[1] == BACKSPACE) {
*basep = bptr[2];
/* Bold font */
if (*basep == *bptr) {
*stylep = BOLD_STYLE;
while (bptr[1] == BACKSPACE) /* Skip repeats */
bptr += 2;
bptr++;
}
/* Underline or bold underline font */
else if (*bptr == '_') {
/* Bold underline font */
if (bptr[3] == BACKSPACE) {
*stylep = BOLDUNDER_STYLE;
while (bptr[1] == BACKSPACE) /* Skip repeats */
bptr += 2;
bptr++;
}
/* Underline font */
else {
*stylep = UNDERLINE_STYLE;
bptr += 3;
}
}
/* Normal font - bullet character a^Hb */
else {
*stylep = NORMAL_STYLE;
bptr += 3;
}
}
/*
* Normal font. Also need to handle the '_' character
* if in underline or bold underline font
*/
else {
*basep = *bptr;
*stylep = NORMAL_STYLE;
bptr++;
}
/*
* Return pointer to next unprocessed character
*/
return bptr;
}
/**************************************************************************
*
* Function: add_text
*
* Description: Adds the new string segment to the lines strings segment
* array using the specified GC.
*
* Parameters:
* line (I) - current text line structure
* line_buf (I,O) - text line accumaltion buffer
* new_text (I) - new text to be added to the end of the original
* string segment array.
* font_flag (I) - font style to render new string. One of
* NORMAL_STYLE, UNDERLINE_STYLE, BOLD_STYLE,
* or BOLDUNDER_STYLE.
*
* Return: none
*
**************************************************************************/
static void add_text(vwr_text_line_t *line, char *line_buf,
char *new_text, int font_flag)
{
vwr_text_seg_t *sptr;
int nchars;
static char *buf_ptr;
/*
* Get the segment length
*/
nchars = strlen(new_text);
/*
* Copy new text to the accumulation text buffer
*/
if (!(*line_buf))
buf_ptr = line_buf;
(void)memcpy(buf_ptr, new_text, nchars + 1);
buf_ptr += nchars;
/*
* Allocate a new string segment and fill it with the
* relevant info
*/
sptr = (vwr_text_seg_t*)malloc(sizeof(vwr_text_seg_t));
sptr->next = NULL;
sptr->seg_type = font_flag;
sptr->seg_nchars = nchars;
sptr->seg_len = XTextWidth(text_styles[font_flag].font, new_text,
sptr->seg_nchars);
/*
* Update the line length and char count fields
*/
line->line_len += sptr->seg_len;
line->line_nchars += nchars;
/*
* Link this new segment onto segment list and update segment
* count
*/
if (line->segs) {
line->last_seg->next = sptr;
line->last_seg = sptr;
} else {
line->segs = line->last_seg = sptr;
}
}
+56
View File
@@ -0,0 +1,56 @@
#! smake
#**************************************************************************
#* *
#* Copyright (C) 1991, Silicon Graphics, Inc. *
#* All Rights Reserved. *
#* *
#* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
#* the contents of this file may not be disclosed to third parties, *
#* copied or duplicated in any form, in whole or in part, without the *
#* prior written permission of Silicon Graphics, Inc. *
#* *
#* RESTRICTED RIGHTS LEGEND: *
#* Use, duplication or disclosure by the Government is subject to *
#* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
#* in Technical Data and Computer Software clause at DFARS *
#* 252.227-7013, and/or in similar or successor clauses in the FAR, *
#* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
#* the Copyright Laws of the United States. *
#**************************************************************************
#*
#* Makefile - libvwr, text formatting and viewing library
#*
#* $Revision: 1.2 $
#*
#*
#**************************************************************************/
DEPTH = ..
include $(DEPTH)/viewerdefs
LIBRARY = libvwr.a
CFILES = TextView.c \
Formatter.c
CVERSION = -xansi
OPTIMIZER = -O2
LINTFLAGS = -u -z -y -woff 91
LCINCS = -I$(VIEWERINC_DIR)
LCDEFS = -DFUNCPROTO -DNARROWPROTO -DNeedFunctionPrototypes -DFAST_QUARKS
LCOPTS = -fullwarn
ARFLAGS = crls
TARGETS = $(LIBRARY)
default all: $(TARGETS)
include $(COMMONRULES)
$(LIBRARY): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBRARY) $?
install: all
File diff suppressed because it is too large Load Diff
+290
View File
@@ -0,0 +1,290 @@
!
!**************************************************************************
!* *
!* Copyright (C) 1991, Silicon Graphics, Inc. *
!* All Rights Reserved. *
!* *
!**************************************************************************
!*
!* File: Grelnotes
!*
!* $Revision: 1.5 $
!*
!* Description: App default file for the graphical release notes browser.
!*
!**************************************************************************/
! SGI Schemes Resources
*sgiMode: True
*useSchemes: all
*schemeFileList: SgiSpec
! Release notes root directory
*relnotesPath: /usr/relnotes/
! Temporary file directory
*tempPath: /usr/tmp
! Dimension bounds
Grelnotes.minWidth: 300
Grelnotes.minHeight: 200
! Place indicator
*placeFrame.shadowType: XmSHADOW_IN
*productLabel.labelString: Product
*chapterLabel.labelString: , Chapter
*product.labelString: [none]
*chapter.labelString: [none]
*placeForm*background: gray72
! Printing dialog
*printDialogLabel.labelString: For current product print:
*printAll.labelString: All chapters
*printSingle.labelString: Current chapter only
*printDialog_popup*minWidth: 250
*printDialog_popup*minHeight: 370
Grelnotes*printDialog*Text.background: gray72
*printDialog*textColumns: 32
*printDialog*printPrinterList*visibleItemCount: 8
*printDialog*printPrinterList*background: gray72
*printDialog*printScopeRadio*marginWidth: 20
*printDialog.cancelLabelString: Cancel
*printDialog.okLabelString: Print
*printDialog.dialogTitle: Print
*printDialog.selectionLabelString: Print Job Info:
*printScopeLabel.labelString: For current product print:
*printPrinterListLabel.labelString: Printers Available:
*printScopeRadio.button_0.labelString: Current chapter
*printScopeRadio.button_1.labelString: All chapters
*printSubmitMsg: Submitting print job...
! Search dialog
*searchDialog*XmText*background: gray72
*searchDialog*XmTextField*background: rosy brown
! Error dialog
*errorDialog.cancelLabelString: Quit
*errorDialog.dialogTitle: Error
*productNotFoundMsg: Release notes for the product '%s' were not found.\n\
Please select a product from the Product menu.
*chapterNotFoundMsg: Release notes chapter '%s' was not found.\n\
Please select a chapter from the Chapter menu.
*noProductsMsg: There are no release notes installed on this system.\n\
Use the 'inst' program to install release notes for\n\
a particular product.
*noPrinterMsg: No printer has been selected.\n\
Select a printer from the list and print again.
! Help dialog
*helpDialog.dialogTitle: Help
*helpProgramMsg: Program: %s
*helpVersionMsg: Version: %s
! Browsing buttons
*prevChapter.labelString: Prev Chapter
*nextChapter.labelString: Next Chapter
*prevProduct.labelString: Prev Product
*nextProduct.labelString: Next Product
! Menu bar
*fileMenuButton.labelString: File
*fileMenuButton.mnemonic: F
*productsMenuButton.labelString: Products
*productsMenuButton.mnemonic: P
*chaptersMenuButton.labelString: Chapters
*chaptersMenuButton.mnemonic: C
*moreMenuButton.labelString: more...
*moreMenuButton.mnemonic: m
*helpMenuButton.labelString: Help
*helpMenuButton.mnemonic: H
! File menu
*searchMenuButton.labelString: Search...
*printMenuButton.labelString: Print...
*printMenuButton.accelerator: Ctrl<Key>P
*printMenuButton.acceleratorText: Ctrl+P
*updateMenuButton.labelString: Update List
*quitMenuButton.labelString: Quit
*quitMenuButton.acceleratorText: Ctrl+Q
*quitMenuButton.accelerator: Ctrl<Key>q
! Help menu
*progHelpMenuButton.labelString: On Program
*verHelpMenuButton.labelString: On Version
! Text window fonts
!
! A fixed width font should be selected since the text was formatted
! based on a fixed width display device.
!
*textView.normalFont: -*-courier-medium-r-normal-*-14-*-*-*-m-*-iso8859-*
*textView.underlineFont: -*-courier-bold-r-normal-*-14-*-*-*-m-*-iso8859-*
*textView.boldFont: -*-courier-medium-o-normal-*-14-*-*-*-m-*-iso8859-*
*textView.boldUnderFont: -*-courier-bold-o-normal-*-14-*-*-*-m-*-iso8859-*
! Text window text colors
!
! A text character background and foreground color can be set for each
! font style.
!
*textView.normalForeground: white
*textView.underlineForeground: white
*textView.boldForeground: white
*textView.boldUnderForeground: white
*textView.selectionBackground: white
*textView.selectionForeground: black
! Text window sizes - columns (characters) and rows (lines)
*textView.textColumns: 80
*textView.textRows: 35
! Text window colors
Grelnotes*textView.foreground: white
Grelnotes*textView.background: DeepSkyBlue4
! Heuristics
! Up to this number of consective blank lines will be displayed. Set
! this to 0 for no compression.
*blankCompress: 4
!
! SGI Look Resources
!
! Fonts
! all labels should be bold
*XmLabel*fontList: -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
*XmLabelGadget*fontList: -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
*XmScale*fontList: -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
*XmBulletinBoard*labelFontList: -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
*optionMenu.XmLabelGadget*fontList: -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
! all buttons, toggles, and radio buttons should be plain
*XmPushButton*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*XmPushButtonGadget*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*XmToggleButton*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*XmToggleButtonGadget*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*optionMenu*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*XmIconGadget*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*XmBulletinBoard*buttonFontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
! menuBar entries, panes, popups, and option menus should be oblique
*menuBar*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
! for entries in popup menus
*XmMenuShell*XmPushButton*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmLabelGadget*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmPushButtonGadget*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmCascadeButton*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmCascadeButtonGadget*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmToggleButton*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmToggleButtonGadget*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*optionPane*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
! Lists
*XmList*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
! Text fonts
*XmText.fontList: -*-screen-medium-r-normal-*-14*ascii
*XmTextField.fontList: -*-screen-medium-r-normal-*-14*ascii
!
! Spacing stuff, probably belongs in master scheme file
!
! buttons shouldn't look "cramped"
! (24 pixels across face from top to bottom and 8 in margin on face)
*XmPushButton*marginHeight: 4
*XmPushButton*marginWidth: 7
! option menu buttons shouldn't look "cramped" either
! but need to be a bit smaller than regular buttons and the
! same as the menu bar
*optionMenu*marginHeight: 0
*optionMenu*marginTop: 5
*optionMenu*marginBottom: 5
*optionMenu*marginWidth: 0
! option menu panes are more like pulldown menus than buttons
*optionPane*XmPushButton*marginHeight: 1
*optionPane*XmPushButton*marginWidth: 1
*optionPane*XmPushButton*marginLeft: 3
*optionPane*XmPushButton*marginRight: 3
! move the text in lists slightly right to improve legibility
*XmList*listMarginWidth: 3
! height of menuBar should be 22 pixels
*menuBar*marginHeight: 1
*menuBar.marginHeight: 0
*menuBar*marginLeft: 1
*menuBar.spacing: 7
*XmMenuShell*marginLeft: 3
*XmMenuShell*marginRight: 4
! spacing between indicator and label should be only 6 in menus
*XmMenuShell*XmToggleButtonGadget*spacing: 2
*XmMenuShell*XmToggleButtonGadget*marginHeight: 0
*XmMenuShell*XmToggleButtonGadget*indicatorSize: 10
*XmMenuShell*XmLabelGadget*marginHeight: 4
! spacing between indicator and label should be 8 outside of menus
*XmToggleButtonGadget*spacing: 4
*XmToggleButton*spacing: 4
! spacing between scrollbars and clients should be 2 pixels
*XmScrolledWindow*spacing: 0
! Scrollbars
*XmScrollBar*width: 18
*XmScrollBar*height: 18
! sliders should be slightly narrower than scrollbars ->
! 12 pixels across the trough as opposed to 14
*XmScale*scaleHeight: 20
! in a perfect world, text fields would be the same size as buttons
! (28 pixels including shadow) but since lucidatypwriter14 is really
! only 13 pixels, our text fields will be 27 pixels high
*XmText*marginHeight: 4
!
! Color Mappings
!
*foreground: Black
*background: gray
*XmList*background: gray50
*XmPushButton*background: gray68
*XmText.background: gray72
*XmTextField.background: rosy brown
*troughColor: gray52
! color all dialogs, warnings, and errors the same
*XmSelectionBox*background: gray84
*XmSelectionBox*XmText*background: rosy brown
*XmMessageBox*background: gray84
! color all radio and toggle buttons when they are selected
*fillOnSelect: True
*visibleWhenOff: True
*selectColor: yellow
! for keyboard traversal
*highlightColor: Black
*XmText*highlightThickness: 1
*XmTextField*highlightThickness: 1
*XmPushButton*highlightThickness: 1
!! no need for anything else to highlight itself
*highlightThickness: 0
+290
View File
@@ -0,0 +1,290 @@
!
!**************************************************************************
!* *
!* Copyright (C) 1991, Silicon Graphics, Inc. *
!* All Rights Reserved. *
!* *
!**************************************************************************
!*
!* File: Grelnotes.fr
!*
!* $Revision: 1.5 $
!*
!* Description: App default file for the graphical release notes browser
!* (French edition).
!*
!**************************************************************************/
! SGI Schemes Resources
*sgiMode: True
*useSchemes: all
*schemeFileList: SgiSpec
! Release notes root directory
*relnotesPath: /usr/relnotes/
! Temporary file directory
*tempPath: /usr/tmp
! Dimension bounds
Grelnotes.minWidth: 300
Grelnotes.minHeight: 200
! Place indicator
*placeFrame.shadowType: XmSHADOW_IN
*productLabel.labelString: Produit
*chapterLabel.labelString: , Chapître
*product.labelString: [none]
*chapter.labelString: [none]
*placeForm*background: gray72
! Printing dialog
*printDialogLabel.labelString: For current product print:
*printAll.labelString: All chapters
*printSingle.labelString: Current chapter only
*printDialog_popup*minWidth: 250
*printDialog_popup*minHeight: 370
Grelnotes*printDialog*Text.background: gray72
*printDialog*textColumns: 32
*printDialog*printPrinterList*visibleItemCount: 8
*printDialog*printPrinterList*background: gray72
*printDialog*printScopeRadio*marginWidth: 20
*printDialog.cancelLabelString: Cancel
*printDialog.okLabelString: Print
*printDialog.dialogTitle: Print
*printDialog.selectionLabelString: Print Job Info:
*printScopeLabel.labelString: For current product print:
*printPrinterListLabel.labelString: Printers Available:
*printScopeRadio.button_0.labelString: Current chapter
*printScopeRadio.button_1.labelString: All chapters
*printSubmitMsg: Submitting print job...
! Search dialog
*searchDialog*XmText*background: gray72
*searchDialog*XmTextField*background: rosy brown
! Error dialog
*errorDialog.cancelLabelString: Quit
*errorDialog.dialogTitle: Error
*productNotFoundMsg: Release notes for the product '%s' were not found.\n\
Please select a product from the Product menu.
*chapterNotFoundMsg: Release notes chapter '%s' was not found.\n\
Please select a chapter from the Chapter menu.
*noProductsMsg: There are no release notes installed on this system.\n\
Use the 'inst' program to install release notes for\n\
a particular product.
*noPrinterMsg: No printer has been selected.\n\
Select a printer from the list and print again.
! Help dialog
*helpDialog.dialogTitle: Help
*helpProgramMsg: Program: %s
*helpVersionMsg: Version: %s
! Browsing buttons
*prevChapter.labelString: Prev Chapter
*nextChapter.labelString: Next Chapter
*prevProduct.labelString: Prev Product
*nextProduct.labelString: Next Product
! Menu bar
*fileMenuButton.labelString: File
*fileMenuButton.mnemonic: F
*productsMenuButton.labelString: Products
*productsMenuButton.mnemonic: P
*chaptersMenuButton.labelString: Chapters
*chaptersMenuButton.mnemonic: C
*moreMenuButton.labelString: more...
*moreMenuButton.mnemonic: m
*helpMenuButton.labelString: Help
*helpMenuButton.mnemonic: H
! File menu
*searchMenuButton.labelString: Search...
*printMenuButton.labelString: Print...
*printMenuButton.accelerator: Ctrl<Key>P
*printMenuButton.acceleratorText: Ctrl+P
*updateMenuButton.labelString: Update List
*quitMenuButton.labelString: Quit
*quitMenuButton.acceleratorText: Ctrl+Q
*quitMenuButton.accelerator: Ctrl<Key>q
! Help menu
*progHelpMenuButton.labelString: On Program
*verHelpMenuButton.labelString: On Version
! Text window fonts
!
! A fixed width font should be selected since the text was formatted
! based on a fixed width display device.
!
*textView.normalFont: -*-courier-medium-r-normal-*-14-*-*-*-m-*-iso8859-*
*textView.underlineFont: -*-courier-bold-r-normal-*-14-*-*-*-m-*-iso8859-*
*textView.boldFont: -*-courier-medium-o-normal-*-14-*-*-*-m-*-iso8859-*
*textView.boldUnderFont: -*-courier-bold-o-normal-*-14-*-*-*-m-*-iso8859-*
! Text window text colors
!
! A text character background and foreground color can be set for each
! font style.
!
*textView.normalForeground: white
*textView.underlineForeground: white
*textView.boldForeground: white
*textView.boldUnderForeground: white
*textView.selectionBackground: white
*textView.selectionForeground: black
! Text window sizes - columns (characters) and rows (lines)
*textView.textColumns: 80
*textView.textRows: 35
! Text window colors
Grelnotes*textView.foreground: white
Grelnotes*textView.background: DeepSkyBlue4
! Heuristics
! Up to this number of consective blank lines will be displayed. Set
! this to 0 for no compression.
*blankCompress: 4
!
! SGI Look Resources
!
! Fonts
! all labels should be bold
*XmLabel*fontList: -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
*XmLabelGadget*fontList: -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
*XmScale*fontList: -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
*XmBulletinBoard*labelFontList: -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
*optionMenu.XmLabelGadget*fontList: -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-1
! all buttons, toggles, and radio buttons should be plain
*XmPushButton*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*XmPushButtonGadget*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*XmToggleButton*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*XmToggleButtonGadget*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*optionMenu*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*XmIconGadget*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
*XmBulletinBoard*buttonFontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
! menuBar entries, panes, popups, and option menus should be oblique
*menuBar*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
! for entries in popup menus
*XmMenuShell*XmPushButton*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmLabelGadget*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmPushButtonGadget*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmCascadeButton*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmCascadeButtonGadget*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmToggleButton*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*XmMenuShell*XmToggleButtonGadget*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
*optionPane*fontList: -*-helvetica-bold-o-normal-*-14*iso8859-1
! Lists
*XmList*fontList: -*-helvetica-medium-r-normal-*-14*iso8859-1
! Text fonts
*XmText.fontList: -*-screen-medium-r-normal-*-14*ascii
*XmTextField.fontList: -*-screen-medium-r-normal-*-14*ascii
!
! Spacing stuff, probably belongs in master scheme file
!
! buttons shouldn't look "cramped"
! (24 pixels across face from top to bottom and 8 in margin on face)
*XmPushButton*marginHeight: 4
*XmPushButton*marginWidth: 7
! option menu buttons shouldn't look "cramped" either
! but need to be a bit smaller than regular buttons and the
! same as the menu bar
*optionMenu*marginHeight: 0
*optionMenu*marginTop: 5
*optionMenu*marginBottom: 5
*optionMenu*marginWidth: 0
! option menu panes are more like pulldown menus than buttons
*optionPane*XmPushButton*marginHeight: 1
*optionPane*XmPushButton*marginWidth: 1
*optionPane*XmPushButton*marginLeft: 3
*optionPane*XmPushButton*marginRight: 3
! move the text in lists slightly right to improve legibility
*XmList*listMarginWidth: 3
! height of menuBar should be 22 pixels
*menuBar*marginHeight: 1
*menuBar.marginHeight: 0
*menuBar*marginLeft: 1
*menuBar.spacing: 7
*XmMenuShell*marginLeft: 3
*XmMenuShell*marginRight: 4
! spacing between indicator and label should be only 6 in menus
*XmMenuShell*XmToggleButtonGadget*spacing: 2
*XmMenuShell*XmToggleButtonGadget*marginHeight: 0
*XmMenuShell*XmToggleButtonGadget*indicatorSize: 10
*XmMenuShell*XmLabelGadget*marginHeight: 4
! spacing between indicator and label should be 8 outside of menus
*XmToggleButtonGadget*spacing: 4
*XmToggleButton*spacing: 4
! spacing between scrollbars and clients should be 2 pixels
*XmScrolledWindow*spacing: 0
! Scrollbars
*XmScrollBar*width: 18
*XmScrollBar*height: 18
! sliders should be slightly narrower than scrollbars ->
! 12 pixels across the trough as opposed to 14
*XmScale*scaleHeight: 20
! in a perfect world, text fields would be the same size as buttons
! (28 pixels including shadow) but since lucidatypwriter14 is really
! only 13 pixels, our text fields will be 27 pixels high
*XmText*marginHeight: 4
!
! Color Mappings
!
*foreground: Black
*background: gray
*XmList*background: gray50
*XmPushButton*background: gray68
*XmText.background: gray72
*XmTextField.background: rosy brown
*troughColor: gray52
! color all dialogs, warnings, and errors the same
*XmSelectionBox*background: gray84
*XmSelectionBox*XmText*background: rosy brown
*XmMessageBox*background: gray84
! color all radio and toggle buttons when they are selected
*fillOnSelect: True
*visibleWhenOff: True
*selectColor: yellow
! for keyboard traversal
*highlightColor: Black
*XmText*highlightThickness: 1
*XmTextField*highlightThickness: 1
*XmPushButton*highlightThickness: 1
!! no need for anything else to highlight itself
*highlightThickness: 0
+70
View File
@@ -0,0 +1,70 @@
#! smake
#**************************************************************************
#* *
#* Copyright (C) 1991, Silicon Graphics, Inc. *
#* All Rights Reserved. *
#* *
#* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
#* the contents of this file may not be disclosed to third parties, *
#* copied or duplicated in any form, in whole or in part, without the *
#* prior written permission of Silicon Graphics, Inc. *
#* *
#* RESTRICTED RIGHTS LEGEND: *
#* Use, duplication or disclosure by the Government is subject to *
#* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
#* in Technical Data and Computer Software clause at DFARS *
#* 252.227-7013, and/or in similar or successor clauses in the FAR, *
#* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
#* the Copyright Laws of the United States. *
#**************************************************************************
#*
#* Makefile - grelnotes, graphical release notes browser
#*
#* $Revision: 1.3 $
#*
#*
#**************************************************************************/
DEPTH = ..
include $(DEPTH)/viewerdefs
IDB_TAG = "eoe1.sw.unix"
TARGETS = grelnotes
CFILES = main.c \
menus.c \
place.c \
buttons.c \
finder.c \
errors.c \
print.c \
search.c \
help.c
LIBRARIES = $(VIEWERLIB_DIR)/libvwr.a
LCINCS = -I$(VIEWERINC_DIR)
# Uncomment this to have product movement buttons
#LCDEFS = -DPRODBUTTONS
LCDEFS += -DFUNCPROTO -DNARROWPROTO -DNeedFunctionPrototypes -DFAST_QUARKS
LCOPTS = -fullwarn
LLDOPTS = -L$(VIEWERLIB_DIR)
LLDLIBS = -lvwr -lXm -lXt -lX11 -lXmu -lgen -lmalloc
LINTFLAGS = -u -z -y -woff 91
CVERSION = -xansi
OPTIMIZER = -O2
default all: $(TARGETS)
include $(COMMONRULES)
$(TARGETS): $(OBJECTS) $(LIBRARIES)
$(CCF) $(OBJECTS) $(LDFLAGS) -o $@
install: all
$(INSTALL) -m 755 -idb $(IDB_TAG) -F /usr/sbin $(TARGETS)
$(INSTALL) -m 644 -idb $(IDB_TAG) \
-F /usr/lib/X11/app-defaults Grelnotes
+152
View File
@@ -0,0 +1,152 @@
/**************************************************************************
* *
* Copyright (C) 1991, Silicon Graphics, Inc. *
* All Rights Reserved. *
* *
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
* the contents of this file may not be disclosed to third parties, *
* copied or duplicated in any form, in whole or in part, without the *
* prior written permission of Silicon Graphics, Inc. *
* *
* RESTRICTED RIGHTS LEGEND: *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
* in Technical Data and Computer Software clause at DFARS *
* 252.227-7013, and/or in similar or successor clauses in the FAR, *
* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
* the Copyright Laws of the United States. *
**************************************************************************
*
* File: buttons.c
*
* Description: Creates and handles the text browsing control buttons.
*
**************************************************************************/
#ident "$Revision: 1.1 $"
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/RowColumn.h>
#include <Xm/PushB.h>
#include "grelnotes.h"
static Widget chapter_next, chapter_prev; /* Chapter motion buttons */
static Widget product_next, product_prev; /* Product motion buttons */
/**************************************************************************
*
* Function: create_buttons
*
* Description: Supervises the creation of the text browsing control
* buttons. These buttons control chapter and product selection
* in a sequential manner.
*
* Parameters:
* parent (I) - parent widget
*
* Return: The created button RowColumn widget is returned.
*
**************************************************************************/
Widget create_buttons(Widget parent)
{
Widget button_rc, left_rc, right_rc;
DEFARGS(10);
/*
* Create a RowColumns to hold the buttons
*/
STARTARGS;
SETARG(XmNorientation, XmHORIZONTAL);
SETARG(XmNpacking, XmPACK_COLUMN);
SETARG(XmNnumColumns, 1);
button_rc = XtCreateManagedWidget("buttonRc", xmRowColumnWidgetClass,
parent, ARGLIST);
#ifdef PRODBUTTONS
left_rc = XtCreateManagedWidget("leftButtonRc", xmRowColumnWidgetClass,
button_rc, ARGLIST);
#endif
right_rc = XtCreateManagedWidget("rightButtonRc", xmRowColumnWidgetClass,
button_rc, ARGLIST);
#ifdef PRODBUTTONS
/*
* Create product browsing buttons
*/
product_prev = XtCreateManagedWidget("prevProduct",
xmPushButtonWidgetClass,
left_rc, NULL, 0);
product_next = XtCreateManagedWidget("nextProduct",
xmPushButtonWidgetClass,
left_rc, NULL, 0);
XtAddCallback(product_prev, XmNactivateCallback, next_product,
(XtPointer)MOVE_PREV);
XtAddCallback(product_next, XmNactivateCallback, next_product,
(XtPointer)MOVE_NEXT);
#endif
/*
* Create chapter browsing buttons
*/
chapter_prev = XtCreateManagedWidget("prevChapter",
xmPushButtonWidgetClass,
right_rc, NULL, 0);
chapter_next = XtCreateManagedWidget("nextChapter",
xmPushButtonWidgetClass,
right_rc, NULL, 0);
XtAddCallback(chapter_prev, XmNactivateCallback, next_chapter,
(XtPointer)MOVE_PREV);
XtAddCallback(chapter_next, XmNactivateCallback, next_chapter,
(XtPointer)MOVE_NEXT);
/*
* Start with all buttons disabled
*/
set_button_state(CHAPTER_BUTTONS, DISABLED);
set_button_state(PRODUCT_BUTTONS, DISABLED);
return button_rc;
}
/**************************************************************************
*
* Function: set_button_state
*
* Description: Sets the product or chapter movement button sensitivity
*
* Parameters:
* buttons (I) - button set on which to set state. One of
* PRODUCT_BUTTONS, CHAPTER_BUTTONS.
* state (I) - ENABLED or DISABLED
*
* Return: none
*
**************************************************************************/
void set_button_state(int buttons, int state)
{
DEFARGS(5);
STARTARGS;
SETARG(XmNsensitive, state);
switch (buttons) {
case PRODUCT_BUTTONS:
#ifdef PRODBUTTONS
XtSetValues(product_prev, ARGLIST);
XtSetValues(product_next, ARGLIST);
#endif
break;
case CHAPTER_BUTTONS:
XtSetValues(chapter_prev, ARGLIST);
XtSetValues(chapter_next, ARGLIST);
break;
}
}
+188
View File
@@ -0,0 +1,188 @@
/**************************************************************************
* *
* Copyright (C) 1991, Silicon Graphics, Inc. *
* All Rights Reserved. *
* *
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
* the contents of this file may not be disclosed to third parties, *
* copied or duplicated in any form, in whole or in part, without the *
* prior written permission of Silicon Graphics, Inc. *
* *
* RESTRICTED RIGHTS LEGEND: *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
* in Technical Data and Computer Software clause at DFARS *
* 252.227-7013, and/or in similar or successor clauses in the FAR, *
* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
* the Copyright Laws of the United States. *
**************************************************************************
*
* File: errors.c
*
* Description: Error messages and dialog handling.
*
**************************************************************************/
#ident "$Revision: 1.2 $"
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/MessageB.h>
#include "grelnotes.h"
static Widget create_error_dialog(void);
static void cancel_callback(Widget, XtPointer, XtPointer);
/**************************************************************************
*
* Function: display_error
*
* Description: Displays the error dialog with the speicifed message
*
* Parameters:
* error_id (I) - integer ID for the error
* client_str (I) - a client specified string to display with certain
* error messages
* quit_button (I) - if TRUE a quit button is provided. Otherwise
* only the OK button is provided.
*
* Note: client_str is only used by the NO_CMDLINE_PRODUCT to display
* the product name and NO_CMDLINE_CHAPTER to display the chapter
* name.
*
* Return: none
*
**************************************************************************/
void display_error(int error_id, char *client_str, int quit_button)
{
static Widget error_dialog = NULL;
char buffer[1024];
XmString mess;
DEFARGS(5);
/*
* If first time, create the error dialog window
*/
if (!error_dialog)
error_dialog = create_error_dialog();
/*
* Construct the error message into a multi-line compound string
*/
STARTARGS;
switch (error_id) {
case NO_CMDLINE_PRODUCT:
(void)sprintf(buffer, app_data.product_notfound_msg, client_str);
mess = XmStringCreateLtoR(buffer, XmFONTLIST_DEFAULT_TAG);
SETARG(XmNmessageString, mess);
XtSetValues(error_dialog, ARGLIST);
XmStringFree(mess);
break;
case NO_CMDLINE_CHAPTER:
(void)sprintf(buffer, app_data.chapter_notfound_msg, client_str);
mess = XmStringCreateLtoR(buffer, XmFONTLIST_DEFAULT_TAG);
SETARG(XmNmessageString, mess);
XtSetValues(error_dialog, ARGLIST);
XmStringFree(mess);
break;
case NO_PRODUCTS:
SETARG(XmNmessageString, app_data.no_products_msg);
XtSetValues(error_dialog, ARGLIST);
break;
case NO_PRINTER:
SETARG(XmNmessageString, app_data.no_printer_msg);
XtSetValues(error_dialog, ARGLIST);
break;
}
/*
* Display the string then free it
*/
/*
* Decide on whether we need the quit button
*/
if (quit_button)
XtManageChild(XmMessageBoxGetChild(error_dialog,
XmDIALOG_CANCEL_BUTTON));
else
XtUnmanageChild(XmMessageBoxGetChild(error_dialog,
XmDIALOG_CANCEL_BUTTON));
/*
* Bring up the dialog
*/
XtManageChild(error_dialog);
}
/*
==========================================================================
LOCAL FUNCTIONS
==========================================================================
*/
/**************************************************************************
*
* Function: create_error_dialog
*
* Description: Creates the error dialog
*
* Parameters: none
*
* Return: Created dialog widget
*
**************************************************************************/
static Widget create_error_dialog()
{
Widget dialog;
DEFARGS(10);
/*
* Create a modal dialog
*/
STARTARGS;
SETARG(XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
dialog = XmCreateErrorDialog(toplevel, "errorDialog", ARGLIST);
/*
* Register callbacks for OK and Cancel and blow off Help
*/
XtAddCallback(dialog, XmNcancelCallback, cancel_callback, NULL);
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
return dialog;
}
/**************************************************************************
*
* Function: cancel_callback
*
* Description: Handles the cancel error dialog button. In this case we quit
* the app.
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - client data
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
static void cancel_callback(Widget w, XtPointer client_data, XtPointer call_data)
{
XtUnmanageChild(w);
quit(NULL, NULL, NULL);
}
+477
View File
@@ -0,0 +1,477 @@
/**************************************************************************
* *
* Copyright (C) 1991, Silicon Graphics, Inc. *
* All Rights Reserved. *
* *
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
* the contents of this file may not be disclosed to third parties, *
* copied or duplicated in any form, in whole or in part, without the *
* prior written permission of Silicon Graphics, Inc. *
* *
* RESTRICTED RIGHTS LEGEND: *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
* in Technical Data and Computer Software clause at DFARS *
* 252.227-7013, and/or in similar or successor clauses in the FAR, *
* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
* the Copyright Laws of the United States. *
**************************************************************************
*
* File: finder.c
*
* Description: Routines to scan for products with release notes and
* build the appropriate data structures.
*
**************************************************************************/
#ident "$Revision: 1.4 $"
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <stdlib.h>
#include <Xm/Xm.h>
#include "grelnotes.h"
#define MAXLINE 1024 /* Largest line */
#define NPROD_INCR 10 /* Allocation increment for products */
#define NCHAP_INCR 5 /* Allocation increment for chapters */
static PRODUCT_LIST product_list; /* Head of the product list struct */
static void product_scan(PRODUCT_LIST*);
static int chapter_scan(PRODUCT*, char*);
static void chapter_title(CHAPTER*, char*);
static int chapter_compare(const void*, const void*);
static int product_compare(const void*, const void*);
static void add_product(PRODUCT_LIST*, char*);
static void add_chapter(PRODUCT*, char*, char*);
static void free_products(PRODUCT_LIST*);
static void free_chapters(PRODUCT*);
/**************************************************************************
*
* Function: find_relnotes
*
* Description: Supervises the search for products with release notes
* and the building of the product list data structure.
*
* Parameters: none
*
* Return: Pointer to a product list.
*
**************************************************************************/
PRODUCT_LIST *find_relnotes()
{
PRODUCT_LIST *plist = &product_list;
product_scan(plist);
return plist;
}
/*
==========================================================================
LOCAL FUNCTIONS
==========================================================================
*/
/**************************************************************************
*
* Function: product_scan
*
* Description: Searches for products with release notes and creates the
* PRODUCT list filling out the product chapter entries.
*
* Parameters:
* plist (I) - Head of product list
*
* Return: none
*
**************************************************************************/
static void product_scan(PRODUCT_LIST *plist)
{
DIR *pdirp;
struct dirent *pdp;
/*
* Make sure the product list has been freed
*/
free_products(plist);
/*
* Scan the release notes directory for potential products. A
* product is not officially entered in the product list until
* it has been verified that the products has at least one chapter
* of release notes.
*/
if ((pdirp = opendir(real_relnotes_path)) != NULL) {
while ((pdp = readdir(pdirp)) != NULL) {
if (*pdp->d_name != '.') {
add_product(plist, pdp->d_name);
}
}
(void)closedir(pdirp);
}
/*
* Sort the products for user convenience
*/
if (plist->nproducts)
qsort(plist->products, plist->nproducts,
sizeof(PRODUCT), product_compare);
}
/**************************************************************************
*
* Function: chapter_scan
*
* Description: Fills the chapter structure of the specified product
*
* Parameters:
* product (I) - pointer to a product structure
* prod_title (I) - product title
*
* Return: The number of chapters is returned.
*
**************************************************************************/
static int chapter_scan(PRODUCT *product, char *prod_title)
{
FILE *tcptr;
DIR *cdirp;
struct dirent *cdp;
char dir[MAXLINE], buffer[MAXLINE];
int hasTC, i;
/*
* Make path to relntoes chapters
*/
(void)sprintf(dir, "%s%s/", real_relnotes_path, prod_title);
hasTC = FALSE; /* Assume not table of contents */
/*
* Scan the product directory looking for chapters and a table of
* contents.
*/
if ((cdirp = opendir(dir)) != NULL) {
while ((cdp = readdir(cdirp)) != NULL) {
if (*cdp->d_name == '.')
continue;
if (strstr(cdp->d_name, "ch") || strstr(cdp->d_name, ".gz")) {
add_chapter(product, dir, cdp->d_name);
} else if (strstr(cdp->d_name, "TC"))
hasTC = TRUE;
}
(void)closedir(cdirp);
}
if (!product->nchapters)
return 0;
/*
* Sort the chapters so that they are in the same order as would
* be found in the table of contents
*/
qsort(product->chapters, product->nchapters, sizeof(CHAPTER),
chapter_compare);
/*
* If a table of contents exists, read it and augment the chapter
* titles with the information found in the TC
*/
if (hasTC) {
(void)sprintf(buffer, "%sTC", dir);
if ((tcptr = fopen(buffer, "r")) != NULL) {
i = 0;
if (fgets(buffer, MAXLINE, tcptr)) {
while (fgets(buffer, MAXLINE, tcptr) &&
(i < product->nchapters)) {
chapter_title(&product->chapters[i], buffer);
i++;
}
}
(void)fclose(tcptr);
}
}
return product->nchapters;
}
/**************************************************************************
*
* Function: chapter_title
*
* Description: Replaces tabs between chapter number and description in TC
* with a text string. Note that we must take care to replace only
* the first tab character we encounter. Some Bozo TC entries
* apparently have tabs in the title.
*
* Parameters:
* chapter (O) - destination chapter whose title is to be expanded
* source (I) - sources string from TC
*
* Return: none
*
**************************************************************************/
static void chapter_title(CHAPTER *chapter, char *source)
{
int len, first_tab = 1;
char *sptr, *dptr, *dest;
dest = chapter->title;
len = strlen(source);
dest = (char*)realloc(dest, strlen(dest) + len + 5);
source[len - 1] = '\0';
*dest = '\0';
for (sptr = source, dptr = dest; *sptr; sptr++) {
if (*sptr == '\t' && first_tab) {
(void)strcat(dptr, ". ");
dptr += 3;
first_tab = 0;
}
else {
if (*sptr == '\t')
*dptr++ = ' ';
else
*dptr++ = *sptr;
}
}
*dptr = '\0';
chapter->title = dest;
}
/**************************************************************************
*
* Function: chapter_compare, product_compare
*
* Description: Comparison functions for the product and chapter list
* sorting routine. Note that numerical chapters must be compared
* by magnitude while appendices (letter chapters) must be compared
* lexically.
*
* Parameters:
* va, vb (I) - values to compare
*
* Return: <, =, > 0 depending on the comparison of the two values.
*
**************************************************************************/
static int chapter_compare(const void *va, const void *vb)
{
char *a_title, *b_title;
int a_num, b_num;
a_title = ((CHAPTER*)va)->title;
b_title = ((CHAPTER*)vb)->title;
a_num = atoi(a_title);
b_num = atoi(b_title);
return ((a_num && b_num) ? a_num - b_num: strcmp(a_title, b_title));
}
static int product_compare(const void *va, const void *vb)
{
return strcasecmp(((PRODUCT*)va)->title, ((PRODUCT*)vb)->title);
}
/**************************************************************************
*
* Function: add_product
*
* Description: Adds a product to the product list if there are chapters
* available for it.
*
* Parameters:
* plist (I) - product list
* title (I) - title of product
*
* Return: none
*
**************************************************************************/
static void add_product(PRODUCT_LIST *plist, char *title)
{
register PRODUCT *prods;
register ushort nprods;
/*
* Save structure vars in register vars
*/
prods = plist->products;
nprods = plist->nproducts;
/*
* If this is the first allocation then malloc, otherwise
* realloc for NPROD_INCR more products
*/
if (!plist->nprod_alloc) {
prods = (PRODUCT*)malloc(NPROD_INCR * sizeof(PRODUCT));
plist->nprod_alloc = NPROD_INCR;
} else if (nprods / plist->nprod_alloc) {
plist->nprod_alloc += NPROD_INCR;
prods = (PRODUCT*)realloc(prods, plist->nprod_alloc * sizeof(PRODUCT));
}
/*
* Copy the title to the product and scan for chapters, don't
* actually incr the product count unless there are chapters
*/
prods[nprods].nchapters = 0;
if (chapter_scan(&prods[nprods], title)) {
prods[nprods].title = strdup(title);
nprods++;
}
/*
* Update the structure vars
*/
plist->products = prods;
plist->nproducts = nprods;
}
/**************************************************************************
*
* Function: add_chapter
*
* Description: Adds a chapter to the chapter list
*
* Parameters:
* product (I) - pointer to the product
* dir (I) - chapter directory
* fname (I) - chapter filaname
*
* Return: none
*
**************************************************************************/
static void add_chapter(PRODUCT *product, char *dir, char *fname)
{
register unchar nchaps;
register CHAPTER *chaps;
register int flen;
register char *tptr;
/*
* Put frequently accessed variables into registers
*/
nchaps = product->nchapters;
chaps = product->chapters;
/*
* If this is the first allocation then malloc, otherwise
* realloc for NCHAP_INCR more chapters
*/
if (!nchaps) {
chaps = (CHAPTER*)malloc(NCHAP_INCR * sizeof(CHAPTER));
} else if (!(nchaps % NCHAP_INCR)) {
chaps = (CHAPTER*)realloc(chaps, (nchaps + NCHAP_INCR) *
sizeof(CHAPTER));
}
/*
* Copy the title and pathname to the chapters
*/
flen = strlen(fname);
chaps[nchaps].fname = (char*)malloc(strlen(dir) + flen + 2);
memset(chaps[nchaps].fname, '\0', (strlen(dir) + flen + 2));
chaps[nchaps].title = (char*)malloc(flen + 1);
memset(chaps[nchaps].title, '\0', (flen + 1));
(void)sprintf(chaps[nchaps].fname, "%s%s", dir, fname);
if ((tptr = strrchr(chaps[nchaps].fname, '/'))
&&
strlen(tptr) > 3 && *(tptr+1) == 'c' && *(tptr+2) == 'h' ) {
for ((tptr += 3); *tptr == '0'; tptr++)
;
(void)strcpy(chaps[nchaps].title, tptr);
(void)strtok(chaps[nchaps].title, ".");
}
/*
* Update the structure variables
*/
product->nchapters++;
product->chapters = chaps;
}
/**************************************************************************
*
* Function: free_products
*
* Description: Frees strorage for all products on the product list
*
* Parameters:
* plist (I) - head of product list
*
* Return: none
*
**************************************************************************/
static void free_products(PRODUCT_LIST *plist)
{
register int i;
register PRODUCT *pptr;
if (plist->nprod_alloc) {
for (i = 0, pptr = plist->products; i < plist->nproducts;
i++, pptr++) {
free((char*)pptr->title);
free_chapters(pptr);
}
free((char*)plist->products);
plist->nprod_alloc = 0;
plist->nproducts = 0;
plist->products = NULL;
}
}
/**************************************************************************
*
* Function: free_chapters
*
* Description: Frees storage for all chapters on a products chapter list
*
* Parameters:
* product (I) - product whose chapters are to be freed
*
* Return: none
*
**************************************************************************/
static void free_chapters(PRODUCT *product)
{
register int i;
register CHAPTER *cptr;
if (product->nchapters) {
for (i = 0, cptr = product->chapters; i < product->nchapters;
i++, cptr++) {
free((char*)cptr->title);
free((char*)cptr->fname);
}
free((char*)product->chapters);
product->nchapters = 0;
product->chapters = NULL;
}
}
+186
View File
@@ -0,0 +1,186 @@
/**************************************************************************
* *
* Copyright (C) 1991, Silicon Graphics, Inc. *
* All Rights Reserved. *
* *
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
* the contents of this file may not be disclosed to third parties, *
* copied or duplicated in any form, in whole or in part, without the *
* prior written permission of Silicon Graphics, Inc. *
* *
* RESTRICTED RIGHTS LEGEND: *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
* in Technical Data and Computer Software clause at DFARS *
* 252.227-7013, and/or in similar or successor clauses in the FAR, *
* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
* the Copyright Laws of the United States. *
**************************************************************************
*
* File: grelnotes.h
*
* Description: Primary include file for the graphical release notes
* browser.
*
**************************************************************************/
#ident "$Revision: 1.3 $"
#define PROG_VERSION "3.1"
/* Environment variables */
#define ENV_RELNOTES_PATH "RELNOTESPATH"
/* No resource specified defaults */
#define DEF_RELNOTES_PATH "/usr/relnotes/"
#define DEF_TEMP_PATH "/usr/tmp"
#define DEF_HELP_PROG_MSG "Program: %s"
#define DEF_HELP_VER_MSG "Version: %s"
/* Temporary filename info */
#define TEMP_PREFIX "grel"
/* Cursor types */
#define BUSY_CURSOR 0
#define NORMAL_CURSOR 1
/* Movement button info */
#define PRODUCT_BUTTONS 0
#define CHAPTER_BUTTONS 1
#define MOVE_NEXT 0
#define MOVE_PREV 1
/* Button sensitivity */
#define ENABLED True
#define DISABLED False
/* Error conditions */
#define NO_CMDLINE_PRODUCT 0
#define NO_CMDLINE_CHAPTER 1
#define NO_PRODUCTS 2
#define NO_PRINTER 3
/* Help tokens */
#define PROGRAM_HELP 0
#define VERSION_HELP 1
/* Resource macros */
#define DEFARGS(num) Arg _args[num]; register int _n
#define STARTARGS _n = 0
#define SETARG(r,v) XtSetArg(_args[_n], r, v); _n++
#define ARGLIST _args, _n
/* Application Resources */
/* Resource names and classes */
#define GrNrelnotesPath "relnotesPath"
#define GrCRelnotesPath "RelnotesPath"
#define GrNtempPath "tempPath"
#define GrCTempPath "TempPath"
#define GrNhelpProgramMsg "helpProgramMsg"
#define GrCHelpProgramMsg "HelpProgramMsg"
#define GrNhelpVersionMsg "helpVersionMsg"
#define GrCHelpVersionMsg "HelpVersionMsg"
#define GrNprintSubmitMsg "printSubmitMsg"
#define GrCPrintSubmitMsg "PrintSubmitMsg"
#define GrNproductNotFoundMsg "productNotFoundMsg"
#define GrCProductNotFoundMsg "ProductNotFoundMsg"
#define GrNchapterNotFoundMsg "chapterNotFoundMsg"
#define GrCChapterNotFoundMsg "ChapterNotFoundMsg"
#define GrNnoProductsMsg "noProductsMsg"
#define GrCNoProductsMsg "NoProductsMsg"
#define GrNnoPrinterMsg "noPrinterMsg"
#define GrCNoPrinterMsg "NoPrinterMsg"
/* Resource structure */
typedef struct {
char *relnotes_path; /* Release notes root directory */
char *temp_path; /* Temporary file directory */
char *help_prog_msg; /* Help program name message */
char *help_ver_msg; /* Help program version message */
char *print_submit_msg; /* Print job submittal message */
char *product_notfound_msg; /* Product not found message */
char *chapter_notfound_msg; /* Chapter not found message */
XmString no_products_msg; /* No release notes isntalled message */
XmString no_printer_msg; /* No printer selected message */
} app_data_t;
/* Product and Chapter structures */
typedef struct {
char *title; /* Chapter title from TC */
char *fname; /* Chapter filename */
} CHAPTER;
typedef struct {
char *title; /* Product title */
unchar nchapters; /* Number of chapters in product */
CHAPTER *chapters; /* List of chapters */
} PRODUCT;
typedef struct {
ushort nproducts; /* Number of products */
ushort nprod_alloc; /* Product space allocation */
PRODUCT *products; /* List of products */
} PRODUCT_LIST;
/* Public variables */
extern Widget toplevel;
extern Widget text_viewer;
extern PRODUCT *current_product;
extern CHAPTER *current_chapter;
extern char real_relnotes_path[];
extern char *temp_fname;
extern char *prog_name, *prog_classname, *prog_version;
extern app_data_t app_data;
/* Public functions */
extern Widget create_appmenu(Widget);
extern Widget create_place(Widget);
extern Widget create_buttons(Widget);
extern PRODUCT_LIST *find_relnotes(void);
extern void scan(void);
extern int build_prodmenu(PRODUCT_LIST*);
extern int build_chapmenu(PRODUCT*);
extern void display_product(Widget, XtPointer, XtPointer);
extern void display_chapter(Widget, XtPointer, XtPointer);
extern void set_product_name(char*);
extern void set_chapter_name(char*);
extern void quit(Widget, XtPointer, XtPointer);
extern void set_cursor(Widget, int);
extern void set_button_state(int, int);
extern void next_product(Widget, XtPointer, XtPointer);
extern void next_chapter(Widget, XtPointer, XtPointer);
extern void display_error(int, char*, int);
extern void display_help(Widget, XtPointer, XtPointer);
extern void print_handler(Widget, XtPointer, XtPointer);
extern void search_handler(Widget, XtPointer, XtPointer);
extern void set_print_search_state(int);
extern XmString create_message(char**);
+29
View File
@@ -0,0 +1,29 @@
"GENERAL",
" ",
"This program allows browsing of the on-line release notes",
"provided with each Silicon Graphics software product.",
" ",
" ",
"VIEWING RELEASE NOTES",
" ",
"From the 'Products' menu select the software product whose",
"release notes you wish to view. The first chapter of the",
"release notes will be displayed. After browsing this",
"chapter a new chapter may be selected using the 'Chapter'",
"menu.",
" ",
#ifdef PRODBUTTONS
"To select chapters or products in sequence use the buttons",
"located at the bottom of the program window.",
#else
"To select chapters in sequence use the buttons located at",
"the bottom of the program window.",
#endif
" ",
" ",
"PRINTING RELEASE NOTES",
" ",
"When a product has been selected the release notes for that",
"product may be printed by selecting the 'Print...' item from",
"the 'File' menu.",
"",
+147
View File
@@ -0,0 +1,147 @@
/**************************************************************************
* *
* Copyright (C) 1991, Silicon Graphics, Inc. *
* All Rights Reserved. *
* *
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
* the contents of this file may not be disclosed to third parties, *
* copied or duplicated in any form, in whole or in part, without the *
* prior written permission of Silicon Graphics, Inc. *
* *
* RESTRICTED RIGHTS LEGEND: *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
* in Technical Data and Computer Software clause at DFARS *
* 252.227-7013, and/or in similar or successor clauses in the FAR, *
* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
* the Copyright Laws of the United States. *
**************************************************************************
*
* File: help.c
*
* Description: Help messages and dialog handling.
*
**************************************************************************/
#ident "$Revision: 1.2 $"
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/MessageB.h>
#include "grelnotes.h"
/* Help message - text is contained in the file grelnotes.hlp */
static char *program_help[] = {
#include "grelnotes.hlp"
};
static Widget create_help_dialog(void);
/**************************************************************************
*
* Function: display_help
*
* Description: Displays the help dialog with the speicifed help message
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - help ID token
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
void display_help(Widget w, XtPointer client_data, XtPointer call_data)
{
static Widget help_dialog = NULL;
char buffer[512];
XmString mess;
DEFARGS(5);
/*
* If this is first time, create the dialog window
*/
if (!help_dialog)
help_dialog = create_help_dialog();
/*
* Construct the help message into a multi-line compound string
*/
switch ((int)client_data) {
case PROGRAM_HELP:
mess = create_message(program_help);
break;
case VERSION_HELP:
(void)sprintf(buffer, app_data.help_prog_msg, prog_name);
mess = XmStringCreateSimple(buffer);
mess = XmStringConcat(mess, XmStringSeparatorCreate());
mess = XmStringConcat(mess, XmStringSeparatorCreate());
(void)sprintf(buffer, app_data.help_ver_msg, prog_version);
mess = XmStringConcat(mess, XmStringCreateSimple(buffer));
break;
}
/*
* Display the string then free it
*/
STARTARGS;
SETARG(XmNmessageString, mess);
XtSetValues(help_dialog, ARGLIST);
XmStringFree(mess);
/*
* Display the dialog
*/
XtManageChild(help_dialog);
}
/*
==========================================================================
LOCAL FUNCTIONS
==========================================================================
*/
/**************************************************************************
*
* Function: create_help_dialog
*
* Description: Creates the help dialog
*
* Parameters: none
*
* Return: Created dialog widget
*
**************************************************************************/
static Widget create_help_dialog()
{
Widget dialog;
DEFARGS(5);
/*
* Create a modeless information dialog
*/
STARTARGS;
SETARG(XmNdialogStyle, XmDIALOG_MODELESS);
dialog = XmCreateInformationDialog(toplevel, "helpDialog", ARGLIST);
/*
* Blow off the Cancel and Help buttons
*/
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
XtUnmanageChild(XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
return dialog;
}
+778
View File
@@ -0,0 +1,778 @@
/**************************************************************************
* *
* Copyright (C) 1991, Silicon Graphics, Inc. *
* All Rights Reserved. *
* *
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
* the contents of this file may not be disclosed to third parties, *
* copied or duplicated in any form, in whole or in part, without the *
* prior written permission of Silicon Graphics, Inc. *
* *
* RESTRICTED RIGHTS LEGEND: *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
* in Technical Data and Computer Software clause at DFARS *
* 252.227-7013, and/or in similar or successor clauses in the FAR, *
* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
* the Copyright Laws of the United States. *
**************************************************************************
*
* File: main.c
*
* Description: Main file for the graphical release notes browser.
*
**************************************************************************/
#ident "$Revision: 1.5 $"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <locale.h>
#include <sys/param.h>
#include <Xm/Xm.h>
#include <X11/StringDefs.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
#include <Xm/Protocols.h>
#include <Xm/AtomMgr.h>
#include <Xm/Form.h>
#include <Xm/Frame.h>
#include "grelnotes.h"
#include "TextView.h"
#include "Formatter.h"
/* Program globals */
Widget toplevel; /* Top level window */
Widget text_viewer; /* Text viewer widget */
PRODUCT *current_product; /* Currently selected product */
CHAPTER *current_chapter; /* Currently selected chapter */
char *temp_fname; /* A unique temporary filename */
char real_relnotes_path[MAXPATHLEN]; /* Release notes root directory */
char *prog_name; /* The program name (path stripped) */
char *prog_classname = "Grelnotes"; /* The program class name */
char *prog_version = PROG_VERSION; /* The program version */
app_data_t app_data; /* Application resources */
/* File globals */
static Cursor busy_cursor; /* A busy cursor */
static PRODUCT_LIST *plist; /* Head of product list struct */
static char *cmdline_product; /* Product specified on command line */
static char *cmdline_chapter; /* Chapter specified on command line */
/* Application resouce list */
static XtResource resources[] = {
/* Public Resources */
/* Release notes root directory */
{
GrNrelnotesPath, GrCRelnotesPath, XtRString, sizeof(char*),
XtOffsetOf(app_data_t, relnotes_path), XtRImmediate,
(XtPointer)DEF_RELNOTES_PATH
},
/* Temporary file directory */
{
GrNtempPath, GrCTempPath, XtRString, sizeof(char*),
XtOffsetOf(app_data_t, temp_path), XtRImmediate,
(XtPointer)DEF_TEMP_PATH
},
/* Private Resources */
/* Help on program name message */
{
GrNhelpProgramMsg, GrCHelpProgramMsg, XtRString, sizeof(char*),
XtOffsetOf(app_data_t, help_prog_msg), XtRImmediate,
(XtPointer)DEF_HELP_PROG_MSG
},
/* Help on program version message */
{
GrNhelpVersionMsg, GrCHelpVersionMsg, XtRString, sizeof(char*),
XtOffsetOf(app_data_t, help_ver_msg), XtRImmediate,
(XtPointer)DEF_HELP_VER_MSG
},
/* Print job submittal message */
{
GrNprintSubmitMsg, GrCPrintSubmitMsg, XtRString, sizeof(char*),
XtOffsetOf(app_data_t, print_submit_msg), XtRImmediate, (XtPointer)""
},
/* Product not found message */
{
GrNproductNotFoundMsg, GrCProductNotFoundMsg, XtRString, sizeof(char*),
XtOffsetOf(app_data_t, product_notfound_msg), XtRImmediate,
(XtPointer)""
},
/* Chapter not found message */
{
GrNchapterNotFoundMsg, GrCChapterNotFoundMsg, XtRString, sizeof(char*),
XtOffsetOf(app_data_t, chapter_notfound_msg), XtRImmediate,
(XtPointer)""
},
/* No products message */
{
GrNnoProductsMsg, GrCNoProductsMsg, XmRXmString,
sizeof(XmString),
XtOffsetOf(app_data_t, no_products_msg), XtRString, (XtPointer)""
},
/* No pritner message */
{
GrNnoPrinterMsg, GrCNoPrinterMsg, XmRXmString,
sizeof(XmString),
XtOffsetOf(app_data_t, no_printer_msg), XtRString, (XtPointer)""
},
};
/* Application specific command-line options */
static XrmOptionDescRec app_options[] = {
{ "-rpath", "*relnotesPath", XrmoptionSepArg, NULL},
};
/* Local functions */
static int parse_chapter(char*, char*);
static PRODUCT *find_product(char*);
static CHAPTER *find_chapter(PRODUCT*, char*);
/**************************************************************************
*
* Function: main
*
* Description: Program entry point
*
* Parameters:
* argc (I) - command line argument count
* argv (I) - command line arguments
*
* Return: None
*
**************************************************************************/
int main(int argc, char *argv[])
{
XtAppContext app_context;
Widget top_form, appmenu, place_frame;
Widget buttons;
Atom destroy_atom;
char *rpath;
DEFARGS(15);
/*
* i18n support
*/
setlocale(LC_ALL, "");
XtSetLanguageProc(NULL, NULL, NULL);
/*
* Initialize the app and retrieve app specific resources
*/
toplevel = XtAppInitialize(&app_context, prog_classname,
app_options, XtNumber(app_options),
&argc, argv, NULL, NULL, 0);
XtGetApplicationResources(toplevel, (XtPointer)&app_data, resources,
XtNumber(resources), NULL, 0);
/*
* Set program name
*/
prog_name = strrchr(argv[0], '/');
prog_name = (prog_name == NULL) ? argv[0]: prog_name + 1;
/*
* Set release notes root directory. If the environment
* variable defined by ENV_RELNOTES_PATH is set it will
* take precedence over the value of the resource. Note
* that we tack on a '/' to the end of the path if the
* user has not specified one.
*/
if ((rpath = getenv(ENV_RELNOTES_PATH)) == NULL)
rpath = app_data.relnotes_path;
if (rpath == NULL || *rpath == '\0')
rpath = " ";
realpath((rpath)? rpath: "", real_relnotes_path);
if (real_relnotes_path[strlen(real_relnotes_path) - 1] != '/')
strcat(real_relnotes_path, "/");
/*
* Check for product and possibly chapter specified on command line
*/
if (argc >= 3)
cmdline_chapter = argv[2];
if (argc >= 2)
cmdline_product = argv[1];
/*
* Indicate an interest in WM app destruction if available
*/
if ((destroy_atom = XmInternAtom(XtDisplay(toplevel),
"WM_DELETE_WINDOW", True)) != None) {
XmAddWMProtocols(toplevel, &destroy_atom, 1);
XmAddWMProtocolCallback(toplevel, destroy_atom, quit, NULL);
}
/*
* Create Form Widget to hold everything
*/
top_form = XtCreateManagedWidget("topForm", xmFormWidgetClass,
toplevel, NULL, 0);
/*
* Create menubar and menu structure
*/
appmenu = create_appmenu(top_form);
STARTARGS;
SETARG(XmNtopAttachment, XmATTACH_FORM);
SETARG(XmNleftAttachment, XmATTACH_FORM);
SETARG(XmNrightAttachment, XmATTACH_FORM);
XtSetValues(appmenu, ARGLIST);
/*
* Create the place indication frame and labels
*/
STARTARGS;
SETARG(XmNtopAttachment, XmATTACH_WIDGET);
SETARG(XmNtopWidget, appmenu);
SETARG(XmNtopOffset, 10);
SETARG(XmNleftAttachment, XmATTACH_FORM);
SETARG(XmNleftOffset, 10);
SETARG(XmNrightAttachment, XmATTACH_FORM);
SETARG(XmNrightOffset, 10);
place_frame = XtCreateManagedWidget("placeFrame", xmFrameWidgetClass,
top_form, ARGLIST);
(void)create_place(place_frame);
/*
* Create a scrolled text viewer
*/
text_viewer = VwrCreateScrolledTextView(top_form, "textView", True, True);
STARTARGS;
SETARG(XmNtopAttachment, XmATTACH_WIDGET);
SETARG(XmNtopWidget, place_frame);
SETARG(XmNtopOffset, 10);
SETARG(XmNbottomAttachment, XmATTACH_FORM);
SETARG(XmNbottomOffset, 55);
SETARG(XmNleftAttachment, XmATTACH_FORM);
SETARG(XmNleftOffset, 10);
SETARG(XmNrightAttachment, XmATTACH_FORM);
SETARG(XmNrightOffset, 10);
XtSetValues(XtParent(XtParent(text_viewer)), ARGLIST);
/*
* Create browsing control buttons
*/
buttons = create_buttons(top_form);
STARTARGS;
SETARG(XmNtopAttachment, XmATTACH_OPPOSITE_FORM);
SETARG(XmNtopOffset, -50);
SETARG(XmNleftAttachment, XmATTACH_FORM);
SETARG(XmNleftOffset, 10);
SETARG(XmNrightAttachment, XmATTACH_FORM);
SETARG(XmNrightOffset, 10);
XtSetValues(buttons, ARGLIST);
/*
* Realize all widgets
*/
XtRealizeWidget(toplevel);
/*
* Create a unique temporary filename for the relnotes chapters
* to pcat and col into
*/
temp_fname = tempnam(app_data.temp_path, TEMP_PREFIX);
/*
* Create a busy cursor glyph for later use
*/
busy_cursor = XCreateFontCursor(XtDisplay(toplevel), XC_watch);
/*
* Catch the killing signals so that proper cleanup can be done
*/
(void)signal(SIGINT, quit);
(void)signal(SIGTERM, quit);
(void)signal(SIGHUP, quit);
/*
* Scan for products
*/
scan();
/*
* Off we go
*/
XtAppMainLoop(app_context);
/* NOTREACHED */
return(1);
}
/**************************************************************************
*
* Function: scan
*
* Description: Supervises the scanning of products with release notes,
* the building of the product menu and the enabling or disabling
* of the product movement buttons. The first chapter of the first
* product in the list, if any, is displayed.
*
* Parameters: none
*
* Return: none
*
**************************************************************************/
void scan()
{
PRODUCT *product;
CHAPTER *chapter;
/*
* Look for release notes and if there are any, build the Product
* menu.
*/
set_cursor(toplevel, BUSY_CURSOR); /* Set busy cursor */
plist = find_relnotes(); /* Search for relnotes */
if (!build_prodmenu(plist)) { /* Build the product menu */
set_button_state(PRODUCT_BUTTONS, DISABLED); /* No products */
set_print_search_state(DISABLED);
}
set_cursor(toplevel, NORMAL_CURSOR); /* Clear busy cursor */
/*
* If there are product with release notes installed, check if
* a particular product was specified on the command line and if
* a particular chapter of that product was specified, otherwise
* look for the 'IRIX' or 'eoe' release notes and failing
* that display first product on the product list
*/
if (plist->nproducts) {
chapter = NULL; /* Assume no chapter or product match */
product = NULL;
/*
* If specified product on command line, look for it in list
* and if specified a chapter with it look for that too
*/
if (cmdline_product) {
product = find_product(cmdline_product);
if (product && cmdline_chapter)
chapter = find_chapter(product, cmdline_chapter);
if (!product)
display_error(NO_CMDLINE_PRODUCT, cmdline_product, TRUE);
else if (chapter == NULL && cmdline_chapter)
display_error(NO_CMDLINE_CHAPTER, cmdline_chapter, TRUE);
cmdline_product = NULL;
cmdline_chapter = NULL;
}
/*
* If no product specified on command line or if that product
* was not found, look for 'IRIX' or 'eoe' products and if
* that fails use first product on list.
*/
if (!product) {
if ((product = find_product("IRIX")) == NULL)
if ((product = find_product("eoe")) == NULL)
product = plist->products;
}
/*
* Finally, display the product and chapter if different
* from the first chapter
*/
display_product(NULL, (XtPointer)product, NULL);
if (chapter != NULL && chapter != product->chapters)
display_chapter(NULL, (XtPointer)chapter, NULL);
}
/*
* If there are no products with relnotes tell the world
*/
else {
display_error(NO_PRODUCTS, NULL, TRUE);
}
}
/**************************************************************************
*
* Function: display_product
*
* Description: Supervises the selection and display of a product's
* release notes.
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - pointer to the selected product structure
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
void display_product(Widget w, XtPointer client_data, XtPointer call_data)
{
PRODUCT *product = (PRODUCT*)client_data;
set_product_name(product->title); /* Display product title */
current_product = product; /* Set current product */
if (plist->nproducts > 1) /* If more than 1 product */
set_button_state(PRODUCT_BUTTONS, ENABLED); /* ungray buttons */
set_print_search_state(ENABLED); /* Enable Print item */
if (build_chapmenu(product) > 1) /* Build chapter menu */
set_button_state(CHAPTER_BUTTONS, ENABLED);
else
set_button_state(CHAPTER_BUTTONS, DISABLED);
if (product->nchapters) /* Display first chapter */
display_chapter(NULL, (XtPointer)product->chapters, NULL);
}
/**************************************************************************
*
* Function: display_chapter
*
* Description: Supervises the selection and display of a chapter of a
* product's release notes.
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - pointer to the selected chapter structure
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
void display_chapter(Widget w, XtPointer client_data, XtPointer call_data)
{
CHAPTER *chapter = (CHAPTER*)client_data;
DEFARGS(5);
set_cursor(toplevel, BUSY_CURSOR);
set_chapter_name(chapter->title); /* Display chapter name */
current_chapter = chapter; /* Set current chapter */
/*
* Issue the a command to the shell to uncompress the relnotes
* pass them through col and output the result into the temporary
* file
*/
if (VwrFormatText(chapter->fname, temp_fname, FMT_PCAT) < 0) {
perror(prog_name);
exit(1);
}
STARTARGS;
SETARG(VwrNtextFile, temp_fname);
XtSetValues(text_viewer, ARGLIST);
set_cursor(toplevel, NORMAL_CURSOR);
}
/**************************************************************************
*
* Function: next_product
*
* Description: Moves to the next product in the list either up or down
* as specified.
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - movement direction (MOVE_NEXT, MOVE_PREV)
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
void next_product(Widget w, XtPointer client_data, XtPointer call_data)
{
PRODUCT *product;
int nproducts;
/*
* Make the button's tab group current only if the button
* was pressed using the keyboard. Otherwise, send focus
* back to the top level group.
*/
if (((XmPushButtonCallbackStruct*)call_data)->event->type != KeyPress)
XmProcessTraversal(w, XmTRAVERSE_PREV_TAB_GROUP);
product = plist->products;
nproducts = plist->nproducts;
switch ((int)client_data) {
case MOVE_NEXT:
if (current_product == &product[nproducts-1])
display_product(NULL, (XtPointer)product, NULL);
else
display_product(NULL, (XtPointer)(current_product + 1), NULL);
break;
case MOVE_PREV:
if (current_product == product)
display_product(NULL, (XtPointer)&product[nproducts - 1],
NULL);
else
display_product(NULL, (XtPointer)(current_product - 1), NULL);
break;
}
}
/**************************************************************************
*
* Function: next_chapter
*
* Description: Moves to the next chapter in the list either up or down
* as specified.
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - movement direction (MOVE_NEXT, MOVE_PREV)
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
void next_chapter(Widget w, XtPointer client_data, XtPointer call_data)
{
CHAPTER *chapter;
int nchapters;
/*
* Make the button's tab group current only if the button
* was pressed using the keyboard. Otherwise, send focus
* back to the top level group.
*/
if (((XmPushButtonCallbackStruct*)call_data)->event->type != KeyPress)
XmProcessTraversal(w, XmTRAVERSE_NEXT_TAB_GROUP);
chapter = current_product->chapters;
nchapters = current_product->nchapters;
switch ((int)client_data) {
case MOVE_NEXT:
if (current_chapter == &chapter[nchapters-1])
display_chapter(NULL, (XtPointer)chapter, NULL);
else
display_chapter(NULL, (XtPointer)(current_chapter + 1), NULL);
break;
case MOVE_PREV:
if (current_chapter == chapter)
display_chapter(NULL, (XtPointer)&chapter[nchapters - 1], NULL);
else
display_chapter(NULL, (XtPointer)(current_chapter - 1), NULL);
break;
}
}
/**************************************************************************
*
* Function: quit
*
* Description: Program cleanup and exit routine. This routine is called
* by the Quit item on the File menu and also from the window manager
* if it supports the WM_DELETE_WINDOW protocol.
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - client data
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
void quit(Widget w, XtPointer client_data, XtPointer call_data)
{
/*
* Delete the temporary file if it exists
*/
if (access(temp_fname, F_OK) == 0)
(void)unlink(temp_fname);
exit(0);
}
/**************************************************************************
*
* Function: set_cursor
*
* Description: Sets the cursor to either busy (BUSY_CURSOR) or normal
* (NORMAL_CURSOR).
*
* Parameters:
* w (I) - widget for which cursor is to be changed
* type (I) - one of BUSY_CURSOR or NORMAL_CURSOR
*
* Return: none
*
**************************************************************************/
void set_cursor(Widget w, int type)
{
switch (type) {
case BUSY_CURSOR:
XDefineCursor(XtDisplay(w), XtWindow(w), busy_cursor);
break;
case NORMAL_CURSOR:
XUndefineCursor(XtDisplay(w), XtWindow(w));
break;
}
XFlush(XtDisplay(w));
}
/**************************************************************************
*
* Function: create_message
*
* Description: A utility function to create a compound string message from
* a multi-element array of strings. The array must be NULL terminated.
*
* Parameters:
* str_array (I) - NULL terminated array of message strings.
*
* Return: A compound string.
*
**************************************************************************/
XmString create_message(char **str_array)
{
XmString xm_newstr, xtemp, xmstr = NULL;
char *str;
int i;
for (i = 0, str = *str_array; *str; str = *++str_array, i++) {
if (i) {
xm_newstr = XmStringSeparatorCreate();
xtemp = xmstr;
xmstr = XmStringConcat(xtemp, xm_newstr);
XmStringFree(xtemp);
XmStringFree(xm_newstr);
}
xm_newstr = XmStringCreateSimple(str);
xtemp = xmstr;
xmstr = XmStringConcat(xtemp, xm_newstr);
XmStringFree(xtemp);
XmStringFree(xm_newstr);
}
return xmstr;
}
/*
==========================================================================
LOCAL FUNCTIONS
==========================================================================
*/
/**************************************************************************
*
* Function: parse_chapter
*
* Description: Parses the chapter number from the chapter title and
* compares it to the specified chapter number.
*
* Parameters:
* title (I) - chapter title
* str (I) - string for comparison
*
* Return: TRUE if the chapter numbers match. FALSE if the do not match.
*
**************************************************************************/
static int parse_chapter(char *title, char *str)
{
char *cptr, buffer[256];
(void)strcpy(buffer, title);
if ((cptr = strtok(buffer, ".")) == NULL)
return FALSE;
if (!strcasecmp(cptr, str))
return TRUE;
return FALSE;
}
/**************************************************************************
*
* Function: find_product, find_chapter
*
* Description: Linearly searches the product/chapter list for the speicified
* product/chapter.
*
* Parameters:
* product_name (I) - name of product to search for
* p (I) - product whose chapters are to be searched
* chapter_name (I) - name of chapter to search for
*
* Return: Pointer to found product or NULL if not found
*
**************************************************************************/
static PRODUCT *find_product(char *product_name)
{
PRODUCT *product, *p;
int i;
product = NULL;
for (i = 0, p = plist->products; i < plist->nproducts; i++, p++) {
if (!strcasecmp(p->title, product_name)) {
product = p;
break;
}
}
return product;
}
static CHAPTER *find_chapter(PRODUCT *p, char *chapter_name)
{
CHAPTER *chapter, *c;
int i;
chapter = NULL;
for (i = 0, c = p->chapters; i < p->nchapters; i++, c++) {
if (parse_chapter(c->title, chapter_name)) {
chapter = c;
break;
}
}
return chapter;
}
+474
View File
@@ -0,0 +1,474 @@
/**************************************************************************
* *
* Copyright (C) 1991, Silicon Graphics, Inc. *
* All Rights Reserved. *
* *
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
* the contents of this file may not be disclosed to third parties, *
* copied or duplicated in any form, in whole or in part, without the *
* prior written permission of Silicon Graphics, Inc. *
* *
* RESTRICTED RIGHTS LEGEND: *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
* in Technical Data and Computer Software clause at DFARS *
* 252.227-7013, and/or in similar or successor clauses in the FAR, *
* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
* the Copyright Laws of the United States. *
**************************************************************************
*
* File: menus.c
*
* Description: Creates the application menu bar, and associated menu
* widgets. The appripriate callbacks are also registered.
*
**************************************************************************/
#ident "$Revision: 1.4 $"
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/RowColumn.h>
#include <Xm/PushBG.h>
#include <Xm/CascadeBG.h>
#include "grelnotes.h"
#define MAX_ITEMS_PER_PANE 20
/* Menu item structure */
typedef struct _menu_item {
char *name; /* Item name */
void (*func)(); /* Callback to be invoked */
caddr_t data; /* Client data for callback */
Boolean insensitive; /* TRUE = insensitive */
Widget button; /* Assigned to button holding item */
} menu_item_t;
typedef struct {
char *name; /* Cascade button name */
Boolean insensitive; /* TRUE = insensitive */
Boolean help; /* TRUE = help item */
int nitems; /* Number of items in menu */
menu_item_t *items; /* List of menu items */
} menu_t;
static void create_menu(Widget, menu_t*, Widget*, Widget*);
static void add_menu_items(Widget, menu_item_t*, int);
static void clear_menu_items(Widget);
static void update_disp(Widget, XtPointer, XtPointer);
/* Menu item initialization */
/* File menu pane */
static menu_item_t file_menu_items[] = {
#ifdef notdef
{ "searchMenuButton", search_handler, NULL, TRUE, NULL },
#endif
{ "printMenuButton", print_handler, NULL, TRUE, NULL },
{ "updateMenuButton", scan, NULL, FALSE, NULL },
{ "quitMenuButton", quit, NULL, FALSE, NULL },
};
/* Help menu pane */
static menu_item_t help_menu_items[] = {
{ "progHelpMenuButton", display_help, (caddr_t)PROGRAM_HELP,
FALSE, NULL },
{ "verHelpMenuButton", display_help, (caddr_t)VERSION_HELP,
FALSE, NULL },
};
/* Menu bar items */
static menu_t file_menu_data[] = {
{ "fileMenuButton", FALSE, FALSE,
XtNumber(file_menu_items), file_menu_items
}
};
static menu_t product_menu_data[] = {
{ "productsMenuButton", TRUE, FALSE, 0, NULL }
};
static menu_t chapter_menu_data[] = {
{ "chaptersMenuButton", TRUE, FALSE, 0, NULL }
};
static menu_t more_menu_data[] = {
{ "moreMenuButton", FALSE, FALSE, 0, NULL }
};
static menu_t help_menu_data[] = {
{ "helpMenuButton", FALSE, TRUE,
XtNumber(help_menu_items), help_menu_items
}
};
static Widget product_pane, product_button;
static Widget chapter_pane, chapter_button;
/**************************************************************************
*
* Function: create_appmenu
*
* Description: Supervises the creation of the application menu bar,
* buttons and pulldowns. Callback registration is also performed.
*
* Parameters:
* parent (I) - parent widget
*
* Return: The created menubar widget is returned.
*
**************************************************************************/
Widget create_appmenu(Widget parent)
{
Widget menubar;
Widget pane, button;
/*
* Create the app menubar
*/
menubar = XmCreateMenuBar(parent, "menuBar", NULL, 0);
XtManageChild(menubar);
/*
* Add the menu items, also registers callbacks
*/
create_menu(menubar, file_menu_data, &pane, &button);
create_menu(menubar, product_menu_data, &product_pane, &product_button);
create_menu(menubar, chapter_menu_data, &chapter_pane, &chapter_button);
create_menu(menubar, help_menu_data, &pane, &button);
return menubar;
}
/**************************************************************************
*
* Function: build_prodmenu
*
* Description: Builds the product selection menu by searching for
* products and building the correponding menu structure.
*
* Parameters: none
*
* Return: Number of products found
*
**************************************************************************/
int build_prodmenu(PRODUCT_LIST *plist)
{
int i;
static menu_item_t *prod_menu_items = 0;
DEFARGS(5);
/*
* If there are no products with relnotes gray out the menubar
* Product item
*/
if (plist->nproducts == 0) {
STARTARGS;
SETARG(XmNsensitive, FALSE);
XtSetValues(product_button, ARGLIST);
return 0;
}
/*
* Allocate room for the Product menu items
*/
if (prod_menu_items)
XtFree((char*)prod_menu_items);
prod_menu_items = (menu_item_t*)XtMalloc(plist->nproducts *
sizeof(menu_item_t));
/*
* Put the products in the list
*/
for (i = 0; i < plist->nproducts; i++) {
prod_menu_items[i].name = plist->products[i].title;
prod_menu_items[i].func = display_product;
prod_menu_items[i].data = (XtPointer)&plist->products[i];
prod_menu_items[i].insensitive = FALSE;
}
/*
* Clear old Product menu and build new one
*/
clear_menu_items(product_pane);
add_menu_items(product_pane, prod_menu_items, plist->nproducts);
STARTARGS;
SETARG(XmNsensitive, TRUE);
XtSetValues(product_button, ARGLIST);
return plist->nproducts;
}
/**************************************************************************
*
* Function: build_chapmenu
*
* Description: Builds the chapter selection menu based on the specified
* product.
*
* Parameters:
* product (I) - product from which to build chapter menu
*
* Return: Number of chapters found
*
**************************************************************************/
int build_chapmenu(PRODUCT *product)
{
int i;
static menu_item_t *chap_menu_items = 0;
DEFARGS(5);
if (product->nchapters == 0) {
STARTARGS;
SETARG(XmNsensitive, FALSE);
XtSetValues(chapter_button, ARGLIST);
return 0;
}
if (chap_menu_items)
XtFree((char*)chap_menu_items);
chap_menu_items = (menu_item_t*)XtMalloc(product->nchapters *
sizeof(menu_item_t));
for (i = 0; i < product->nchapters; i++) {
chap_menu_items[i].name = product->chapters[i].title;
chap_menu_items[i].func = display_chapter;
chap_menu_items[i].data = (XtPointer)&product->chapters[i];
chap_menu_items[i].insensitive = FALSE;
}
clear_menu_items(chapter_pane);
add_menu_items(chapter_pane, chap_menu_items, product->nchapters);
STARTARGS;
SETARG(XmNsensitive, TRUE);
XtSetValues(chapter_button, ARGLIST);
return product->nchapters;
}
/**************************************************************************
*
* Function: set_print_search_state
*
* Description: Makes print and search menu items sensitive or insensitive
*
* Parameters:
* sensitive (I) - TRUE = make sensitive, FALSE = make insensitive
*
* Return: none
*
**************************************************************************/
void set_print_search_state(int sensitive)
{
int i;
DEFARGS(5);
STARTARGS;
SETARG(XmNsensitive, sensitive);
for (i = 0; i < XtNumber(file_menu_items); i++) {
if (file_menu_items[i].func == print_handler ||
file_menu_items[i].func == search_handler) {
XtSetValues(file_menu_items[i].button, ARGLIST);
}
}
}
/*
==========================================================================
LOCAL FUNCTIONS
==========================================================================
*/
/**************************************************************************
*
* Function: create_menu
*
* Description: Creates the menu bar button and menu pane on the specified
* menubar.
*
* Parameters:
* menubar (I) - parent menubar widget
* menu (I) - pointer to menu data structure
* panep (O) - pointer to created menu pane
* buttonp (O) - pointer to created menu cascade button
*
* Return: Menu bar cascade button widget.
*
**************************************************************************/
static void create_menu(Widget menubar, menu_t *menu,
Widget *panep, Widget *buttonp)
{
Widget menu_pane, menu_button;
DEFARGS(5);
/*
* Create the menu bar items and cascade buttons
*/
menu_pane = XmCreatePulldownMenu(menubar, menu->name, NULL, 0);
STARTARGS;
SETARG(XmNsubMenuId, menu_pane);
menu_button = XtCreateManagedWidget(menu->name, xmCascadeButtonGadgetClass,
menubar, ARGLIST);
if (menu->help) {
STARTARGS;
SETARG(XmNmenuHelpWidget, menu_button);
XtSetValues(menubar, ARGLIST);
}
if (menu->insensitive) {
STARTARGS;
SETARG(XmNsensitive, FALSE);
XtSetValues(menu_button, ARGLIST);
}
/*
* Add menu items to panes
*/
add_menu_items(menu_pane, menu->items, menu->nitems);
*panep = menu_pane;
*buttonp = menu_button;
}
/**************************************************************************
*
* Function: add_menu_items
*
* Description: Adds menu items to a menu pane. Note that for each item
* added both the specified callback routine and the update display
* callback are added to the item's callback list. The update display
* function will always be called first so that pending expose
* events are processed before the specified callback function.
*
* Parameters:
* pane (I) - parent menu pane
* items (I) - list of menu items
* nitems (I) - number of menu items
*
* Return: none
*
**************************************************************************/
static void add_menu_items(Widget pane, menu_item_t *items, int nitems)
{
Widget cur_pane, moreb;
WidgetList buttons;
menu_item_t *iptr;
int i, bcount = 0, item_count;
DEFARGS(5);
if (nitems) {
cur_pane = pane;
STARTARGS;
SETARG(XmNsensitive, FALSE);
buttons = (WidgetList) XtMalloc(nitems * sizeof(Widget));
for (i = 0, item_count = 1, iptr = items; i < nitems;
i++, item_count++, iptr++) {
if (item_count % MAX_ITEMS_PER_PANE == 0) {
XtManageChildren(buttons, bcount);
bcount = 0;
create_menu(cur_pane, more_menu_data, &cur_pane, &moreb);
item_count++;
}
iptr->button = buttons[bcount] = XtCreateWidget(iptr->name,
xmPushButtonGadgetClass,
cur_pane, NULL, 0);
XtAddCallback(buttons[bcount], XmNactivateCallback,
update_disp, NULL);
XtAddCallback(buttons[bcount], XmNactivateCallback,
iptr->func, iptr->data);
if (iptr->insensitive)
XtSetValues(buttons[bcount], ARGLIST);
bcount++;
}
XtManageChildren(buttons, bcount);
XtFree((char*)buttons);
}
}
/**************************************************************************
*
* Function: clear_menu_items
*
* Description: Removes and destroys all menu items on the specified
* menu pane.
*
* Parameters:
* pane (I) - pane to have menu items cleared
*
* Return: none
*
**************************************************************************/
static void clear_menu_items(Widget pane)
{
Widget sub_pane;
WidgetList items;
WidgetClass class;
int i, num;
DEFARGS(5);
STARTARGS;
SETARG(XmNnumChildren, &num);
XtGetValues(pane, ARGLIST);
if (!num)
return;
STARTARGS;
SETARG(XmNchildren, &items);
XtGetValues(pane, ARGLIST);
for (i = 0; i < num; i++) {
if (XtIsSubclass(items[i], xmCascadeButtonGadgetClass) == True) {
STARTARGS;
SETARG(XmNsubMenuId, &sub_pane);
XtGetValues(items[i], ARGLIST);
clear_menu_items(sub_pane);
XtDestroyWidget(sub_pane);
STARTARGS;
SETARG(XmNsubMenuId, NULL);
XtSetValues(items[i], ARGLIST);
}
XtDestroyWidget(items[i]);
}
}
/**************************************************************************
*
* Function: update_disp
*
* Description: Processes pending exposure events before the menu pane
* item callbacks are invoked.
*
* Parameters:
* w (I) - widget that invoked this callback
* client_data (I) - not used
* call_data (I) - not used
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
static void update_disp(Widget w, XtPointer client_data, XtPointer call_data)
{
XmUpdateDisplay(w);
}
+160
View File
@@ -0,0 +1,160 @@
/**************************************************************************
* *
* Copyright (C) 1991, Silicon Graphics, Inc. *
* All Rights Reserved. *
* *
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
* the contents of this file may not be disclosed to third parties, *
* copied or duplicated in any form, in whole or in part, without the *
* prior written permission of Silicon Graphics, Inc. *
* *
* RESTRICTED RIGHTS LEGEND: *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
* in Technical Data and Computer Software clause at DFARS *
* 252.227-7013, and/or in similar or successor clauses in the FAR, *
* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
* the Copyright Laws of the United States. *
**************************************************************************
*
* File: place.c
*
* Description: Provides widget creation, layout and access methods for
* the current product and chapter place indication labels.
*
**************************************************************************/
#ident "$Revision: 1.1 $"
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include "grelnotes.h"
static Widget product_name, chapter_name;
/**************************************************************************
*
* Function: create_place
*
* Description: Creates the place indication widgets and arranges them.
*
* Parameters:
* parent (I) - parent widget
*
* Return: The created place indication widget grouping form is returned.
*
**************************************************************************/
Widget create_place(Widget parent)
{
Widget form;
Widget product_label, chapter_label;
DEFARGS(15);
/*
* Create a form to hold everything
*/
form = XtCreateManagedWidget("placeForm", xmFormWidgetClass,
parent, NULL, 0);
/*
* Create the place component labels
*/
STARTARGS;
SETARG(XmNalignment, XmALIGNMENT_BEGINNING);
SETARG(XmNtopAttachment, XmATTACH_FORM);
SETARG(XmNleftAttachment, XmATTACH_FORM);
SETARG(XmNleftOffset, 5);
SETARG(XmNbottomAttachment, XmATTACH_FORM);
product_label = XtCreateManagedWidget("productLabel", xmLabelWidgetClass,
form, ARGLIST);
STARTARGS;
SETARG(XmNalignment, XmALIGNMENT_BEGINNING);
SETARG(XmNtopAttachment, XmATTACH_FORM);
SETARG(XmNleftAttachment, XmATTACH_WIDGET);
SETARG(XmNleftWidget, product_label);
SETARG(XmNbottomAttachment, XmATTACH_FORM);
product_name = XtCreateManagedWidget("product", xmLabelWidgetClass,
form, ARGLIST);
STARTARGS;
SETARG(XmNalignment, XmALIGNMENT_BEGINNING);
SETARG(XmNtopAttachment, XmATTACH_FORM);
SETARG(XmNleftAttachment, XmATTACH_WIDGET);
SETARG(XmNleftWidget, product_name);
SETARG(XmNbottomAttachment, XmATTACH_FORM);
chapter_label = XtCreateManagedWidget("chapterLabel", xmLabelWidgetClass,
form, ARGLIST);
STARTARGS;
SETARG(XmNalignment, XmALIGNMENT_BEGINNING);
SETARG(XmNtopAttachment, XmATTACH_FORM);
SETARG(XmNleftAttachment, XmATTACH_WIDGET);
SETARG(XmNleftWidget, chapter_label);
SETARG(XmNbottomAttachment, XmATTACH_FORM);
SETARG(XmNrightAttachment, XmATTACH_FORM);
chapter_name = XtCreateManagedWidget("chapter", xmLabelWidgetClass,
form, ARGLIST);
return form;
}
/**************************************************************************
*
* Function: set_product_name, set_chapter_name
*
* Description: Sets the string for the product and chapter names
* respectively.
*
* Parameters:
* name (I) - string to display
*
* Return: none
*
**************************************************************************/
void set_product_name(char *name)
{
char buffer[256];
XmString text;
DEFARGS(5);
(void)sprintf(buffer, "\"%s\"", name);
text = XmStringCreateSimple(buffer);
STARTARGS;
SETARG(XmNlabelString, text);
XtSetValues(product_name, ARGLIST);
XmStringFree(text);
/*
* Required to force geometry recomputation (bug in Motif?)
*/
XtUnmanageChild(product_name);
XtManageChild(product_name);
}
void set_chapter_name(char *name)
{
DEFARGS(5);
XmString text = XmStringCreateSimple(name);
STARTARGS;
SETARG(XmNlabelString, text);
XtSetValues(chapter_name, ARGLIST);
XmStringFree(text);
/*
* Required to force geometry recomputation (bug in Motif?)
*/
XtUnmanageChild(chapter_name);
XtManageChild(chapter_name);
}
+538
View File
@@ -0,0 +1,538 @@
/**************************************************************************
* *
* Copyright (C) 1991, Silicon Graphics, Inc. *
* All Rights Reserved. *
* *
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
* the contents of this file may not be disclosed to third parties, *
* copied or duplicated in any form, in whole or in part, without the *
* prior written permission of Silicon Graphics, Inc. *
* *
* RESTRICTED RIGHTS LEGEND: *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
* in Technical Data and Computer Software clause at DFARS *
* 252.227-7013, and/or in similar or successor clauses in the FAR, *
* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
* the Copyright Laws of the United States. *
**************************************************************************
*
* File: print.c
*
* Description: Printing support for the release notes browser. Provides
* printing of single chapter or all chapters in a product.
*
**************************************************************************/
#ident "$Revision: 1.6 $"
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <limits.h>
#include <Xm/Xm.h>
#include <Xm/RowColumn.h>
#include <Xm/Label.h>
#include <Xm/ToggleB.h>
#include <Xm/SelectioB.h>
#include <Xm/List.h>
#include <Xm/Text.h>
#include "grelnotes.h"
/* Print selections */
#define PRINT_CHAPTER 0
#define PRINT_PRODUCT 1
/* Printer listing command */
#define PRINTER_LIST_CMD "LANG=C lpstat -d -a | LANG=C awk '/accepting/ {if ($2 != \"not\") print $1}; /^system default destination:/ { print $4 }; /^no system default destination/ { print \"_none_\"} '"
/* Misc info */
#define MAX_PRINTERS 256
static Widget create_print_dialog(void);
static void set_scope(Widget, XtPointer, XtPointer);
static void printit(Widget, XtPointer, XtPointer);
static void dismiss(Widget, XtPointer, XtPointer);
static void get_printer_list(void);
static int find_printer(char*);
static void printer_select_cb(Widget, XtPointer, XtPointer);
static int print_mode = PRINT_CHAPTER;
static char *printer_list[MAX_PRINTERS];
static char *default_printer;
static char *selected_printer;
static int num_printers;
static Widget plist_widget;
/**************************************************************************
*
* Function: print_handler
*
* Description: Brings up the print handler dialog
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - client data
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
void print_handler(Widget w, XtPointer client_data, XtPointer call_data)
{
static Widget print_dialog = NULL;
/*
* Create the dialog if first time
*/
if (!print_dialog)
print_dialog = create_print_dialog();
/*
* Clear the info text
*/
XmTextSetString(XmSelectionBoxGetChild(print_dialog, XmDIALOG_TEXT), " ");
/*
* Put up printer list and selected printer
*/
get_printer_list();
/*
* Popup the dialog
*/
XtManageChild(print_dialog);
}
/*
==========================================================================
LOCAL FUNCTIONS
==========================================================================
*/
/**************************************************************************
*
* Function: create_print_dialog
*
* Description: Creates the print dialog
*
* Parameters: none
*
* Return: Created dialog widget
*
**************************************************************************/
static Widget create_print_dialog()
{
Widget dialog, scope_radio;
Widget rowc;
DEFARGS(20);
/*
* Create a prompt dialog
*/
STARTARGS;
SETARG(XmNautoUnmanage, False);
dialog = XmCreatePromptDialog(toplevel, "printDialog", ARGLIST);
XtUnmanageChild(XmSelectionBoxGetChild(dialog, XmDIALOG_SEPARATOR));
/*
* Make the info text field read-only
*/
STARTARGS;
SETARG(XmNeditable, False);
XtSetValues(XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT), ARGLIST);
/*
* Create a row column to hold the additional dialog items
*/
rowc = XtCreateManagedWidget("printDialogRc", xmRowColumnWidgetClass,
dialog, NULL, 0);
/*
* Create the scope label
*/
XtCreateManagedWidget("printScopeLabel", xmLabelWidgetClass, rowc,
NULL, 0);
/*
* Create the print scope toggle buttons
*/
scope_radio = XmVaCreateSimpleRadioBox(rowc, "printScopeRadio",
0, set_scope,
XmNspacing, 0,
XmVaRADIOBUTTON, NULL, 0, NULL, NULL,
XmVaRADIOBUTTON, NULL, 0, NULL, NULL,
NULL);
XtManageChild(scope_radio);
/*
* Printer selection list and label
*/
XtCreateManagedWidget("printPrinterListLabel", xmLabelWidgetClass,
rowc, NULL, 0);
plist_widget = XmCreateScrolledList(rowc, "printPrinterList", NULL, 0);
XtManageChild(plist_widget);
/*
* Register the dialog action button callbacks
*/
XtAddCallback(dialog, XmNokCallback, printit, (XtPointer)dialog);
XtAddCallback(dialog, XmNcancelCallback, dismiss, (XtPointer)dialog);
XtAddCallback(dialog, XmNhelpCallback, display_help,
(XtPointer)PROGRAM_HELP);
/*
* Register the printer selection callback
*/
XtAddCallback(plist_widget, XmNbrowseSelectionCallback,
printer_select_cb, NULL);
return dialog;
}
/**************************************************************************
*
* Function: set_scope
*
* Description: Sets the print scope (all chapters or just one chapter).
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - client data
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
static void set_scope(Widget w, XtPointer client_data, XtPointer call_data)
{
if (((XmToggleButtonCallbackStruct*)call_data)->set == False)
return;
print_mode = ((int)client_data) ? PRINT_PRODUCT: PRINT_CHAPTER;
}
/**************************************************************************
*
* Function: printit
*
* Description: Handles the OK to print dialog button and prints the
* selected release notes chapter(s). pcat is piped to lp for
* the selected printer.
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - dialog widget
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
static void printit(Widget w, XtPointer client_data, XtPointer call_data)
{
Widget dialog = (Widget)client_data;
char buffer[BUFSIZ];
int i;
short bGzMode;
FILE *fptr;
/*
* Set cursor to busy
*/
set_cursor(toplevel, BUSY_CURSOR);
set_cursor(dialog, BUSY_CURSOR);
/*
* Get the currently selected printer and remember
* it for future use.
*/
if (!selected_printer) {
set_cursor(toplevel, NORMAL_CURSOR);
set_cursor(dialog, NORMAL_CURSOR);
display_error(NO_PRINTER, NULL, FALSE);
return;
}
/*
* gzipped/html file
*/
if (strstr(current_chapter->fname, ".gz")) {
bGzMode = 1;
} else {
bGzMode = 0;
}
/*
* Print a single chapter
*/
if (print_mode == PRINT_CHAPTER) {
if (bGzMode == 1) {
(void)sprintf(buffer,
"/usr/sbin/gzcat -c %s | %s /usr/bin/col | "
"/usr/bin/lp -d%s -t'%s Relnotes, Ch. %d' 2>&1",
current_chapter->fname,
(strstr(current_chapter->fname, "/ch") ?
"" : "/usr/sbin/html2term | "),
selected_printer, current_product->title,
atoi(strrchr(current_chapter->fname, '/')+3));
} else {
(void)sprintf(buffer,
"/usr/bin/pcat %s | /usr/bin/col | "
"/usr/bin/lp -d%s -t'%s Relnotes, Ch. %d' 2>&1",
current_chapter->fname, selected_printer,
current_product->title,
atoi(strrchr(current_chapter->fname, '/')+3));
}
}
/*
* Print all chapters
*/
else {
if (bGzMode == 1) {
(void)strcpy(buffer, "/usr/sbin/gzcat -c ");
} else {
(void)strcpy(buffer, "/usr/bin/pcat ");
}
for (i = 0; i < current_product->nchapters; i++) {
(void)strcat(buffer, current_product->chapters[i].fname);
(void)strcat(buffer, " ");
}
if (bGzMode == 1 && current_product->nchapters > 0
&&
!(strstr(current_product->chapters[0].fname, "/ch"))) {
(void)strcat(buffer, "| /usr/sbin/html2term ");
}
(void)strcat(buffer, "| /usr/bin/col | /usr/bin/lp -d");
(void)strcat(buffer, selected_printer);
(void)strcat(buffer, " -t'");
(void)strcat(buffer, current_product->title);
(void)strcat(buffer, " Relnotes' 2>&1");
}
/*
* Post a job submitted message
*/
XmTextSetString(XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT),
app_data.print_submit_msg);
XFlush(XtDisplay(dialog));
/*
* Issue the actual command to print and read the
* response.
*/
if ((fptr = popen(buffer, "r")) == NULL) {
(void)sprintf(buffer, "%s - cannot popen printing command\n",
prog_name);
set_cursor(toplevel, NORMAL_CURSOR);
set_cursor(dialog, NORMAL_CURSOR);
XtWarning(buffer);
return;
}
*buffer = '\0';
while (fgets(buffer, BUFSIZ, fptr) != NULL)
;
(void)pclose(fptr);
/*
* Post response in info field
*/
buffer[strlen(buffer)-1] = '\0';
XmTextSetString(XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT), buffer);
/*
* Set cursor to normal
*/
set_cursor(toplevel, NORMAL_CURSOR);
set_cursor(dialog, NORMAL_CURSOR);
}
/**************************************************************************
*
* Function: dismiss
*
* Description: Handles the dismiss dialog button.
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - dialog widget
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
static void dismiss(Widget w, XtPointer client_data, XtPointer call_data)
{
XtUnmanageChild((Widget)client_data);
}
/**************************************************************************
*
* Function: get_printer_list
*
* Description: Creates a list of available printers and determines
* the default printer. The list of printer is then displayed.
*
* Parameters: none
*
* Return: none
*
**************************************************************************/
static void get_printer_list()
{
register int i, select_pos;
char buffer[PATH_MAX];
FILE *fptr;
XmString *printers_str;
DEFARGS(5);
/*
* Free any existing printer information
*/
if (default_printer) {
free((char*)default_printer);
default_printer = NULL;
}
if (num_printers) {
for (i = 0; i < num_printers; i++)
free((char*)printer_list[i]);
num_printers = 0;
}
/*
* Get new printer info
*/
if ((fptr = popen(PRINTER_LIST_CMD, "r")) == NULL) {
(void)sprintf(buffer, "%s - cannot popen printing command\n",
prog_name);
XtWarning(buffer);
return;
}
i = -1;
while (fgets(buffer, PATH_MAX, fptr) != NULL) {
buffer[strlen(buffer)-1] = '\0';
if (i == -1)
default_printer = strdup(buffer);
else
printer_list[i] = strdup(buffer);
if (++i >= MAX_PRINTERS)
break;
}
num_printers = i;
(void)pclose(fptr);
/*
* Display the new printer info
*/
if (!num_printers)
return;
printers_str = (XmString*)XtMalloc(num_printers * sizeof(XmString));
for (i = 0; i < num_printers; i++)
printers_str[i] = XmStringCreateSimple(printer_list[i]);
STARTARGS;
SETARG(XmNitems, printers_str);
SETARG(XmNitemCount, num_printers);
XtSetValues(plist_widget, ARGLIST);
for (i = 0; i < num_printers; i++)
XmStringFree(printers_str[i]);
XtFree((char*)printers_str);
/*
* Select the appropriate printer
*/
select_pos = 0;
if (selected_printer)
select_pos = find_printer(selected_printer);
if (!select_pos)
select_pos = find_printer(default_printer);
if (!select_pos)
select_pos = 1;
XmListSelectPos(plist_widget, select_pos, True);
XmListSetBottomPos(plist_widget, select_pos);
}
/**************************************************************************
*
* Function: find_printer
*
* Description: Linearly searches the list of available printers looking
* for the specified printer name.
*
* Parameters:
* printer_name (I) - name of printer to find
*
* Return: Returns the list index if the printer is found. Returns 0
* if the printer is not found.
*
**************************************************************************/
static int find_printer(char *printer_name)
{
register int i;
int loc = 0;
for (i = 0; i < num_printers; i++) {
if (!strcmp(printer_list[i], printer_name)) {
loc = i + 1;
break;
}
}
return loc;
}
/**************************************************************************
*
* Function: printer_select_cb
*
* Description: Called when a printer is selected.
*
* Parameters:
* w (I) - the invoking widget
* client_data (I) - not used
* call_data (I) - list callback struct
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
static void printer_select_cb(Widget w, XtPointer client_data,
XtPointer call_data)
{
if (selected_printer)
XtFree((char*)selected_printer);
XmStringGetLtoR(((XmListCallbackStruct*)call_data)->item,
XmSTRING_DEFAULT_CHARSET, &selected_printer);
}
+373
View File
@@ -0,0 +1,373 @@
/**************************************************************************
* *
* Copyright (C) 1991, Silicon Graphics, Inc. *
* All Rights Reserved. *
* *
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; *
* the contents of this file may not be disclosed to third parties, *
* copied or duplicated in any form, in whole or in part, without the *
* prior written permission of Silicon Graphics, Inc. *
* *
* RESTRICTED RIGHTS LEGEND: *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights *
* in Technical Data and Computer Software clause at DFARS *
* 252.227-7013, and/or in similar or successor clauses in the FAR, *
* DOD or NASA FAR Supplement. Unpublished - rights reserved under *
* the Copyright Laws of the United States. *
**************************************************************************
*
* File: search.c
*
* Description: Regular expression text search support for the release
* notes browser.
*
**************************************************************************/
#ident "$Revision: 1.1 $"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <Xm/Xm.h>
#include <Xm/RowColumn.h>
#include <Xm/Label.h>
#include <Xm/SelectioB.h>
#include <Xm/Text.h>
#include <Xm/TextF.h>
#include "grelnotes.h"
#include "TextView.h"
/* File scope globals */
static Widget search_expr_widget;
static Widget searchb_widget;
static Widget info_widget;
static expr_changed;
static VwrPositionStruct orig_start_pos, orig_end_pos;
/* Local functions */
static Widget create_search_dialog(void);
static void search_cb(Widget, XtPointer, XtPointer);
static void dismiss_cb(Widget, XtPointer, XtPointer);
static void search_sense_cb(Widget, XtPointer, XtPointer);
static void init_orig_pos_cb(Widget, XtPointer, XtPointer);
/**************************************************************************
*
* Function: search_handler
*
* Description: Brings up the search dialog
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - client data
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
void search_handler(Widget w, XtPointer client_data, XtPointer call_data)
{
static Widget search_dialog = NULL;
/*
* Create the dialog if first time
*/
if (!search_dialog)
search_dialog = create_search_dialog();
/*
* Check for search button sensitivity
*/
search_sense_cb(NULL, NULL, NULL);
/*
* Popup the dialog
*/
XtManageChild(search_dialog);
}
/*
==========================================================================
LOCAL FUNCTIONS
==========================================================================
*/
/**************************************************************************
*
* Function: create_search_dialog
*
* Description: Creates the search dialog
*
* Parameters: none
*
* Return: Created dialog widget
*
**************************************************************************/
static Widget create_search_dialog()
{
XmString dismiss_str, search_str, expr_str;
XmString info_str;
Widget dialog, rowc;
Widget widget;
DEFARGS(20);
/*
* Create labels for buttons and such
*/
dismiss_str = XmStringCreateSimple("Dismiss");
search_str = XmStringCreateSimple("Search");
expr_str = XmStringCreateSimple("Search For:");
info_str = XmStringCreateSimple("Search Info:");
/*
* Create a prompt dialog
*/
STARTARGS;
SETARG(XmNokLabelString, search_str);
SETARG(XmNcancelLabelString, dismiss_str);
SETARG(XmNdialogTitle, search_str);
SETARG(XmNautoUnmanage, False);
SETARG(XmNselectionLabelString, info_str);
dialog = XmCreatePromptDialog(toplevel, "searchDialog", ARGLIST);
XtUnmanageChild(XmSelectionBoxGetChild(dialog, XmDIALOG_SEPARATOR));
/*
* Get the widget IDs for later use
*/
searchb_widget = XmSelectionBoxGetChild(dialog, XmDIALOG_OK_BUTTON);
info_widget = XmSelectionBoxGetChild(dialog, XmDIALOG_TEXT);
/*
* Make the info text field read-only
*/
STARTARGS;
SETARG(XmNeditable, False);
XtSetValues(info_widget, ARGLIST);
/*
* Create a row column to hold the additional dialog items
*/
rowc = XtCreateManagedWidget("searchDialogRc", xmRowColumnWidgetClass,
dialog, NULL, 0);
/*
* Create search string label and text field
*/
STARTARGS;
SETARG(XmNlabelString, expr_str);
XtCreateManagedWidget("searchExprLabel", xmLabelWidgetClass,
rowc, ARGLIST);
search_expr_widget = XtCreateManagedWidget("searchExprText",
xmTextFieldWidgetClass,
rowc, NULL, 0);
/*
* Register a value changed callback for the search
* expression field so that we can set search button
* sensitivity.
*/
XtAddCallback(search_expr_widget, XmNvalueChangedCallback,
search_sense_cb, NULL);
/*
* Register action button callbacks
*/
XtAddCallback(dialog, XmNokCallback, search_cb, (XtPointer)dialog);
XtAddCallback(dialog, XmNcancelCallback, dismiss_cb, (XtPointer)dialog);
XtAddCallback(dialog, XmNhelpCallback, display_help,
(XtPointer)PROGRAM_HELP);
/*
* Deallocate all strings
*/
XmStringFree(dismiss_str);
XmStringFree(search_str);
XmStringFree(expr_str);
XmStringFree(info_str);
/*
* Add callback for text load notifications and
* initialize the positions
*/
XtAddCallback(text_viewer, VwrNloadCallback, init_orig_pos_cb,
(XtPointer)NULL);
init_orig_pos_cb(NULL, NULL, NULL);
return dialog;
}
/**************************************************************************
*
* Function: search_cb
*
* Description: Performs the requested regular expression text search.
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - dialog widget
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
static void search_cb(Widget w, XtPointer client_data, XtPointer call_data)
{
Widget dialog = (Widget)client_data;
char *search_expr;
VwrPositionStruct start_pos, end_pos;
int found, back = 0;
/*
* Set cursor to busy
*/
set_cursor(toplevel, BUSY_CURSOR);
set_cursor(dialog, BUSY_CURSOR);
/*
* Get the search expression and search for it in
* the text. We only want to specify the string when
* it has changed.
*/
if (expr_changed) {
expr_changed = False;
init_orig_pos_cb(NULL, NULL, NULL);
search_expr = XmTextFieldGetString(search_expr_widget);
if ((found = VwrTextViewSearch(text_viewer, search_expr, False,
&start_pos, &end_pos)) == 1) {
orig_start_pos = start_pos;
orig_end_pos = end_pos;
}
XtFree((char*)search_expr);
} else {
if ((found = VwrTextViewSearch(text_viewer, NULL, False,
&start_pos, &end_pos)) == 1) {
if (!memcmp(&start_pos, &orig_start_pos, sizeof(VwrPositionStruct))
&& !memcmp(&end_pos, &orig_end_pos,
sizeof(VwrPositionStruct))) {
back = 1;
} else {
back = 0;
}
}
}
/*
* If we found the string highlight it otherwise indicate
* not found to the user
*/
if (found) {
if (back)
XmTextSetString(info_widget, "Found (back to start)");
else
XmTextSetString(info_widget, "Found");
VwrTextViewSetSelection(text_viewer, &start_pos, &end_pos, False);
} else {
XmTextSetString(info_widget, "Not Found");
}
/*
* Set cursor to normal
*/
set_cursor(toplevel, NORMAL_CURSOR);
set_cursor(dialog, NORMAL_CURSOR);
}
/**************************************************************************
*
* Function: dismiss_cb
*
* Description: Handles the dismiss dialog button.
*
* Parameters:
* w (I) - invoking widget
* client_data (I) - dialog widget
* call_data (I) - standard callback info
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
static void dismiss_cb(Widget w, XtPointer client_data, XtPointer call_data)
{
XtUnmanageChild((Widget)client_data);
}
/**************************************************************************
*
* Function: search_sense_cb
*
* Description: Checks whether there is a search expression entered in the
* search expression text field to determine whether the search
* button should be set to sensitive or insensitive.
*
* Parameters:
* w (I) - widget that invoked this callback
* client_data (I) - unused
* call_data (I) - unused
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
static void search_sense_cb(Widget w, XtPointer client_data,
XtPointer call_data)
{
char *str;
register char *sptr;
Boolean sensitive = False;
expr_changed = True;
str = XmTextFieldGetString(search_expr_widget);
if (*str)
sensitive = True;
XtFree((char*)str);
XtSetSensitive(searchb_widget, sensitive);
}
/**************************************************************************
*
* Function: init_orig_pos_cb
*
* Description: Initializes the original search find position variables.
*
* Parameters:
* w (I) - widget that invoked this callback
* client_data (I) - unused
* call_data (I) - unused
*
* Return: none
*
**************************************************************************/
/* ARGSUSED */
static void init_orig_pos_cb(Widget w, XtPointer client_data,
XtPointer call_data)
{
orig_start_pos.col = orig_start_pos.line = -1;
orig_end_pos.col = orig_end_pos.line = -1;
}
+44
View File
@@ -0,0 +1,44 @@
#
#**************************************************************************
#* *
#* Copyright (c) 1991 Silicon Graphics, Inc. *
#* All Rights Reserved *
#* *
#* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
#* *
#* The copyright notice above does not evidence any actual of intended *
#* publication of such source code, and is an unpublished work by Silicon *
#* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
#* the property of Silicon Graphics, Inc. Any use, duplication or *
#* disclosure not specifically authorized by Silicon Graphics is strictly *
#* prohibited. *
#* *
#* RESTRICTED RIGHTS LEGEND: *
#* *
#* Use, duplication or disclosure by the Government is subject to *
#* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
#* Technical Data and Computer Software clause at DFARS 52.227-7013, *
#* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
#* Supplement. Unpublished - rights reserved under the Copyright Laws of *
#* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
#* Shoreline Blvd., Mountain View, CA 94039-7311 *
#**************************************************************************
#*
#* File: viewerdefs
#*
#* $Revision: 1.1 $
#*
#* Description: Commondefs wrapper for inclusion in Makefiles under the
#* grelnotes viewer directory.
#*
#**************************************************************************
include $(ROOT)/usr/include/make/commondefs
#
# Source tree info
#
VIEWERINC_DIR = $(DEPTH)/include
VIEWERLIB_DIR = $(DEPTH)/lib