home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk1.iso
/
altsrc
/
articles
/
10712
< prev
next >
Wrap
Internet Message Format
|
1994-06-19
|
69KB
Path: wupost!howland.reston.ans.net!gatech!news-feed-1.peachnet.edu!news.duke.edu!solaris.cc.vt.edu!uunet!tsw!not-for-mail
From: dean%tsw@uunet.UU.NET (Dean Collins)
Newsgroups: alt.sources
Subject: X Problem Tracking System (14/16)
Followup-To: alt.sources.d
Date: 18 Jun 1994 12:23:25 -0700
Organization: Zombie Software
Lines: 2164
Distribution: world
Message-ID: <2tvhjd$2uo@hal.sea.tsw.com>
References: <2tvhif$q4k@hal.sea.tsw.com>
Reply-To: dean@halcyon.com
NNTP-Posting-Host: hal.sea.tsw.com
Archive-name: pts/part14
Submitted-by: dean@halcyon.com (Dean Collins)
Version: 1.05
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 14 (of 16)."
# Contents: pts-1.05/xpts/misc.c
# Wrapped by dean@hal on Sat Jun 18 12:08:20 1994
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'pts-1.05/xpts/misc.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'pts-1.05/xpts/misc.c'\"
else
echo shar: Extracting \"'pts-1.05/xpts/misc.c'\" \(64402 characters\)
sed "s/^X//" >'pts-1.05/xpts/misc.c' <<'END_OF_FILE'
X/*
X * misc.c -- Miscellaneous functions for the X user interface
X * to the Problem Tracking System (PTS) database.
X * Dean Collins
X *
X * created: Wed Aug 5 09:31:11 PDT 1992
X * Version 1.0: Sat Jan 9 10:44:49 PST 1993
X * Version 1.01: Wed Mar 7 00:00:00 PST 1993
X * Version 1.03: Fri Nov 26 16:13:59 PST 1993
X * Version 1.03b: Sat Feb 12 17:23:17 PST 1994
X * Version 1.04: Mon Mar 7 18:07:14 PST 1994
X *
X * Modified: Dean Collins Sat Feb 12 17:16:41 1994
X * Modification inspired by Jaap Haalboom (haalboom@prl.philips.nl).
X * Added Xlibint.h include for _XExtension. Added for all architectures,
X * not just __hppa.
X *
X * Modified: Dean Collins Mon Mar 7 18:03:35 PST 1994
X * Modification inspired by Ove Hansen.
X * Added USESYSDEFERR to ignore my not-so-portable error handler
X * Define this if you're getting compiler errors for the function
X * XPrintDefaultError().
X *
X * Modified: Dean Collins Fri May 06 19:47:40 1994
X * Relocated the inclusion of <X11/Xlibint.h> so that it's after
X * <X11/Intrinsic.h>, which was causing grief.
X */
X
X/*
X * Copyright (c) 1992,1993,1994 Dean Collins.
X * Copyright (c) 1992 University of Idaho, Moscow, Idaho.
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation free of charge for any purpose is hereby granted without
X * fee, provided that the above copyright notices appear in all copies and
X * that both those copyright notices and this permission notice appear in
X * supporting documentation, and that neither the name of the University of
X * Idaho nor the name of Dean Collins be used in advertising or publicity
X * pertaining to distribution of the software without specific, written
X * prior permission from both parties. Neither The University of Idaho
X * nor Dean Collins make any representations about the suitability of
X * this software for any purpose. It is provided "as is" without express
X * or implied warranty.
X *
X * THE UNIVERSITY OF IDAHO AND DEAN COLLINS DISCLAIM ALL WARRANTIES WITH
X * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
X * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE UNIVERSITY OF IDAHO
X * OR DEAN COLLINS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
X * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
X * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
X * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
X * THIS SOFTWARE.
X */
X
X#include <stdlib.h> /* General C utilities header file */
X#include <stdio.h> /* Standard input/output utilities hdr. file */
X#include <errno.h> /* Error utilities header file */
X
X#include <X11/Intrinsic.h> /* Include standard Toolkit Header file */
X#include <X11/StringDefs.h> /* Include StringDefs header file */
X#include <X11/Shell.h> /* Include the Shell header file for popups */
X
X#ifndef NOEXTVAR
X#include <X11/Xlibint.h> /* Include internal support routines hdr. file*/
X#endif /*NOEXTVAR*/
X
X#include <X11/Xaw/AsciiText.h> /* Include the ascii Text widget hdr. file */
X#include <X11/Xaw/Box.h> /* Include the Box widget header file */
X#include <X11/Xaw/Command.h> /* Include the Command widget header file */
X#include <X11/Xaw/Dialog.h> /* Include the Dialog widget header file */
X#include <X11/Xaw/Form.h> /* Include the Form widget header file */
X#include <X11/Xaw/List.h> /* Include the List widget header file */
X#include <X11/Xaw/Paned.h> /* Include the Paned widget header file */
X#include <X11/Xaw/Scrollbar.h> /* Include the Scrollbar widget header file */
X#include <X11/Xaw/Viewport.h> /* Include the Viewport widget header file */
X
X#include <X11/Xaw/Cardinals.h> /* Definitions of ZERO, ONE, etc... */
X
X#include <X11/Xmu/Error.h> /* Error handler functions */
X
X#include "zdbm.h" /* Zombie Database Manager header file */
X#include "cloud.h" /* Nebulous Cloud header file */
X#include "clouderror.h" /* Nebulous Cloud error rtn. header file */
X#include "xpts.h" /* Xpts header file */
X
X
Xextern bool NoQuit; /* True if user started PTS in "no-quit" mode, */
X /* false otherwise. */
X
X /* The current problem record. This ideally would
X * be part of a new widget. The widget would have the
X * resources listed in ProblemType. It would have functions
X * to display, read and write the problem.
X * Next version, maybe...
X */
Xextern problem_record * ProblemRecord ;
X
X /* The current list of problem summaries. Similar
X * comment to that above.
X */
Xextern String *SummaryItems ;
X
X /* The problem types tree. */
Xextern ProblemTree *ProbTree ;
X
X /* Information about the user. */
Xextern UserInfo UserInfoRec ;
X
X /* The path for the problem types tree. */
Xextern char Path[] ;
X
Xextern char Node[] ;
Xextern char ProblemText[] ;
X
Xextern String *ProblemItems ;
X
X/* The following string will be displayed by the "About PTS" button
X * on the Main Menu:
X */
Xextern const char PTSInfoText[] ;
X
Xextern Summary *CloudUnSummaries ;
Xextern Summary *CloudSummaries ;
X
Xextern Widget GlobalNewProblemButton ;
Xextern Widget GlobalPreviousButton ;
Xextern Widget GlobalMainMenuWidget ;
X
Xextern int WarningFlag ;
X
X#ifndef NOSIGNALS
Xextern SigType SigRec ;
X#endif
X
X/******************** MODULES *************************************/
X
X/*
X______________________________________________________________________
XChangeList()
X
XFUNCTION DESCRIPTION:
X
X This function will allow the user to select a sub-type of the current
Xproblem type. Selecting a sub-type which contains no further sub-types
Xcauses a list of problem summaries for that sub-type to be displayed.
XThere are two ways to call this function. First, you can specify
Xa complete problem type. Second, you can specify an incomplete problem
Xtype and indicate the child of that type you have selected.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 2/20/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xvoid
XChangeList(String type,
X int item,
X int flag,
X XtPointer client_data)
X
X /* Interface description:
X INPUT:
X type - The specified problem type to display, OR
X the parent of the problem type to display.
X item - The index of the selected child of the
X specified problem type if flag=INC_TYPE, OR
X NULL otherwise.
X flag - Equal to ABS_TYPE if type is the
X complete problem type to display, OR
X equal to INC_TYPE if type is the parent of
X the problem to display and item is the
X index of the selected child of this type, OR
X equal to PREV_TYPE if item is a child
X of the desired problem type path.
X client_data - This is an array of pointers to widgets.
X It is defined in the following manner:
X
X client_data[0] = list widget
X client_data[1] = dialog widget
X client_data[2] = parent widget
X client_data[3] = quitButton widget
X client_data[4] = previousButton widget
X client_data[5] = newProblem widget
X client_data[6] = pickProblem popup widget
X
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X
X /* Major */
X Widget list ;
X Widget dialog ;
X Widget parent ;
X Widget quitButton ;
X Widget previousButton ;
X Widget newProblem ;
X Widget pickProblem ;
X Widget panes ;
X XtPointer *ptrlist ;
X XtPointer *ptrlist2 ;
X
X /* Minor */
X Arg args[3] ;
X int status=0;
X char OldPath[DBPATHLEN+1] ;
X Dimension width=0, height=0 ;
X Dimension pwidth=0, pheight=0 ;
X Dimension border ;
X static int insummaries=FALSE ; /* Whether we're currently in the problem
X * summaries list or not.
X */
X
X
X /*----------------- Start of ChangeList() routine ------------------*/
X#ifdef DEBUG
X printf("XPTS(misc.c): Entering ChangeList()\n") ;
X#endif
X
X /* Make local widgets for each of the items in client_data */
X ptrlist2 = (XtPointer *)client_data ;
X list = (Widget) (ptrlist2[0]) ;
X dialog = (Widget) (ptrlist2[1]) ;
X parent = (Widget) (ptrlist2[2]) ;
X quitButton = (Widget) (ptrlist2[3]) ;
X previousButton = (Widget) (ptrlist2[4]) ;
X newProblem = (Widget) (ptrlist2[5]) ;
X pickProblem = (Widget) (ptrlist2[6]) ;
X
X panes = XtParent(XtParent(list)) ;
X
X#ifdef STUPIDXSERVER
X /* The list widget keeps getting mangled, so lets unmanage it
X * for the time being. Once everything is ready, manage it again.
X * This problem needs to be tracked down. (XtUnmangleChild() ! :-)
X */
X XtUnmanageChild(list) ;
X#endif
X
X
X AllocProblemItems() ; /* Allocate ProblemItems strings */
X
X#ifdef DEBUG
X printf("XPTS(misc.c): Calling FormatProblemTypes with Path=%s\n",Path) ;
X#endif
X /* Attempt to change to the new problem time. */
X/*CLD*/ status = FormatProblemTypes(ProbTree,Path,item,flag,ProblemItems) ;
X
X#ifdef DEBUG
X printf("XPTS(misc.c): Returned from FormatProblemTypes()...Path=%s\n",Path) ;
X printf("XPTS(misc.c): FormatProblemTypes status is %d\n", status) ;
X printf("XPTS(misc.c): ChangeList(): Removing extra ProblemItems strings\n") ;
X#endif
X FreeItems(ProblemItems, MAXBRANCHES) ;/* Remove unused ProblemItems strings*/
X
X
X
X /* If the problem type doesn't exist in the problem tree,
X * then call ErrorPopup() with an appropriate error message,
X * and return.
X */
X if (status < 0) /* Error in problem-type path */
X { /* Might be an error, might be a summary selection.
X * Call ReadProblem to decide. If it returns NULL there
X * was an error.
X * Make a copy of Path, since ReadProblem will probably mess it up.
X */
X#ifdef DEBUG
X printf("XPTS(misc.c): FormatProblemTypes() returned an error,\t(OK, if already at a leaf).\n") ;
X#endif
X strcpy(OldPath, Path) ; /* Save the Path */
X#ifdef DEBUG
X printf("XPTS(misc.c): Calling ReadProblem() in cloud...\n") ;
X#endif
X/*CLD*/ ProblemRecord=ReadProblem(ProbTree, Path, item, CloudSummaries) ;
X#ifdef DEBUG
X printf("XPTS(misc.c): Returned from ReadProblem()...ProblemRecord=%p\n",
X ProblemRecord) ;
X#endif
X
X if (ProblemRecord == NULL)
X {
X#ifdef DEBUG
X printf("XPTS(misc.c): ReadProblem() returned a NULL\n") ;
X#endif
X ErrorPopup("error",pickProblem,"Problem nonexistent!\n") ;
X strcpy(Path, OldPath) ; /* Restore the Path */
X XtManageChild(list) ;
X return ;
X }
X else
X { strcpy(Path, OldPath) ; /* Restore the Path */
X /* Call ViewProblemActivate() with ANYPROB and item */
X ptrlist = (XtPointer *) XtCalloc(2, sizeof(XtPointer)) ;
X ptrlist[0] = (XtPointer) pickProblem ;
X ptrlist[1] = (XtPointer) ANYPROB ;
X#ifdef DEBUG
X printf("XPTS(misc.c): Calling ViewProblemActivate()...\n"
X "\tptrlist=%p,ptrlist[0]=%p,ptrlist[1]=%p,list=%p,Path=%p\n",
X ptrlist,ptrlist[0],ptrlist[1],list,Path) ;
X#endif
X ViewProblemActivate(list, (XtPointer)ptrlist, (XtPointer)item) ;
X }
X
X }
X
X
X
X /**** NOT A LEAF ****/
X
X if (status > 0) /* Child types exist, returned in ProblemItems */
X {
X /* If the problem type specified is NOT a leaf,
X * Generate a printable list of problem types.
X * Change the list widget's text.
X * Change the list to be two column.
X * Get rid of the newProblem button, if present.
X * Change the dialog widget's text to be the new problem type.
X */
X
X XtSetArg(args[0], XtNdefaultColumns, TWO) ;
X XtSetValues(list, args, ONE) ;
X
X if (insummaries) /* Halve height & width of popup */
X { insummaries=FALSE ;
X XtUnmanageChild(panes) ;
X XtSetArg(args[0], XtNwidth, &width) ;
X XtSetArg(args[1], XtNheight, &height) ;
X XtGetValues(pickProblem, args, TWO) ;
X#ifdef DEBUG
X printf("XPTS(misc.c): width=%d, height=%d. Halving popup size...\n",
X (int)width, (int)height) ;
X#endif
X width=width/2 ; height=height/2 ;
X XawPanedAllowResize(XtParent(list), True) ;
X XtSetArg(args[0], XtNwidth, width) ;
X XtSetArg(args[1], XtNheight, height) ;
X XtSetValues(pickProblem, args, TWO) ;
X
X /* Shrink panes */
X XtSetArg(args[0], XtNborderWidth, &border) ;
X XtGetValues(panes, args, ONE) ;
X pwidth = width - 2 * border ;
X pheight = height - 2 * border ;
X XtSetArg(args[0], XtNwidth, pwidth) ;
X XtSetArg(args[1], XtNheight, pheight) ;
X#ifdef DEBUG
X printf("XPTS(misc.c): "
X "Setting -- panewidth=%d, paneheight=%d. (border=%d)\n",
X (int)pwidth, (int)pheight, (int)border) ;
X#endif
X XtSetValues(panes, args, TWO) ;
X XtSetArg(args[0], XtNwidth, &pwidth) ;
X XtSetArg(args[1], XtNheight, &pheight) ;
X XtGetValues(panes, args, TWO) ;
X#ifdef DEBUG
X printf("XPTS(misc.c): Result -- panewidth=%d, paneheight=%d\n",
X (int)pwidth, (int)pheight) ;
X if (pwidth > width || pheight > height)
X printf("XPTS(misc.c): Paned widget resize failure. Darn.\n") ;
X#endif
X }
X
X XawListChange(list, ProblemItems, ZERO, ZERO, TRUE) ;
X XtSetSensitive(list, True) ;
X XtUnmanageChild(newProblem) ;
X }
X
X
X
X /**** IS A LEAF ****/
X
X if (status == 0) /* No child types, only summaries exist */
X {
X /* If the problem type specified IS a leaf,
X * Read the problem summaries for the problem type
X * from the database.
X * Change the list widget's text.
X * Change the list to be one column only.
X * Add the newProblem button to the button box.
X */
X if (!insummaries)
X XtUnmanageChild(panes) ;
X
X XtSetArg(args[0], XtNdefaultColumns, ONE) ;
X XtSetValues(list, args, ONE) ;
X
X if (!insummaries) /* Double the height & width for the summaries list*/
X { insummaries=TRUE ;
X XtSetArg(args[0], XtNwidth, &width) ;
X XtSetArg(args[1], XtNheight, &height) ;
X XtGetValues(pickProblem, args, TWO) ;
X#ifdef DEBUG
X printf("XPTS(misc.c): width=%d, height=%d. Doubling popup size...\n",
X (int)width, (int)height) ;
X#endif
X width=width*2 ; height=height*2 ;
X XawPanedAllowResize(XtParent(list), True) ;
X XtSetArg(args[0], XtNwidth, width) ;
X XtSetArg(args[1], XtNheight, height) ;
X#ifdef DEBUG
X printf("ChangeList() pickProblem=%p\n", (XtPointer)pickProblem) ;
X#endif
X XtSetValues(pickProblem, args, TWO) ;
X
X /* Stretch panes */
X XtSetArg(args[0], XtNborderWidth, &border) ;
X XtGetValues(panes, args, ONE) ;
X pwidth = width - 2 * border ;
X pheight = height - 2 * border ;
X XtSetArg(args[0], XtNwidth, pwidth) ;
X XtSetArg(args[1], XtNheight, pheight) ;
X#ifdef DEBUG
X printf("XPTS(misc.c): "
X "Setting -- panewidth=%d, paneheight=%d. (border=%d)\n",
X (int)pwidth, (int)pheight, (int)border) ;
X#endif
X XtSetValues(panes, args, TWO) ;
X XtSetArg(args[0], XtNwidth, &pwidth) ;
X XtSetArg(args[1], XtNheight, &pheight) ;
X XtGetValues(panes, args, TWO) ;
X#ifdef DEBUG
X printf("XPTS(misc.c): Result -- panewidth=%d, paneheight=%d\n",
X (int)pwidth, (int)pheight) ;
X if (pwidth != width-2*border || pheight != height-2*border)
X printf("XPTS(misc.c): Paned widget resize failure. Darn.\n") ;
X#endif
X }
X
X ReadList(pickProblem, pickProblem) ; /* Fill in the summaries list. */
X XtManageChild(newProblem) ;
X }
X
X
X
X /* If the problem type is ROOTSTR, the problem tree root,
X * unrealize the previousButton widget and
X * realize the quitButton widget.
X * else
X * unrealize the quitButton widget and
X * realize the previousButton widget.
X */
X#ifdef DEBUG
X printf("XPTS(misc.c): ChangeList(): "
X "About to compare ROOTSTR (%s) to Path (%s)...\n",
X ROOTSTR, Path) ;
X#endif
X/* if (strcmp(ROOTSTR, Path) == 0)*/
X/*CLD*/ if (strcmp(FixPath(Path), "") == 0) /*FixPath because ROOT = ROOT/ */
X { XtManageChild(quitButton) ;
X XtUnmanageChild(previousButton) ;
X }
X else
X { XtManageChild(previousButton) ;
X XtUnmanageChild(quitButton) ;
X }
X
X#ifdef STUPIDXSERVER
X XtManageChild(list) ;
X#endif
X
X
X XtManageChild(panes) ;
X
X#ifdef DEBUG
X printf("XPTS(misc.c): Leaving ChangeList()\n") ;
X#endif
X
X} /*--------------------- End of ChangeList() ------------------------*/
X
X
X/*
X______________________________________________________________________
XDoDeleteProblem()
X
XFUNCTION DESCRIPTION:
X This function is called when the user has indicated that they
Xdo want to delete a problem.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 6/23/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
X
Xvoid
XDoDeleteProblem(Widget w,
X XtPointer client_data,
X XtPointer call_data)
X
X /* Interface description:
X INPUT:
X w - The widget for which this callback is registered.
X client_data - Specifies arbitrary client-supplied data
X that the widget w should pass back to the
X client when the widget executes the client's
X callback procedure. In this callback,
X this is the problem viewer popup widget.
X call_data - Specifies any callback-specific data the widget w
X wants to pass to the client.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X Widget warning ;
X Widget probViewer ;
X Widget list ;
X /* Minor */
X char errorstr[MAXERROR] ;
X
X
X /*------------- Start of DoDeleteProblem() routine --------------*/
X#ifdef DEBUG
X printf("XPTS(misc.c): Entering DoDeleteProblem()\n") ;
X#endif
X
X /* Make sure only sysops are executing this function. */
X if (!IsSysop(&UserInfoRec))
X {
X#ifdef DEBUG
X fprintf(stderr,
X "XPTS(DoDeleteProblem()): Illegal access to DoDeleteProblem() "
X "by non-sysop.\n") ;
X#endif
X return ;
X }
X
X /* Get values for the warning and list widgets. */
X probViewer = (Widget)client_data ;
X warning = XtNameToWidget(probViewer, "warning") ;
X list = XtNameToWidget(XtParent(probViewer), "*list") ;
X
X#ifdef DEBUG
X printf("XPTS(DoDeleteProblem()): probViewer=%p, parent=%p, warning=%p,\n"
X " list=%p.",
X probViewer, XtParent(probViewer), warning, list) ;
X#endif
X
X /* Are there any reopen requests for this problem?
X * if so, call SuperWarningPopup().
X */
X if (IsReopened(Path, ProblemRecord) > 0)
X { sprintf(errorstr,
X "WARNING: This problem has reopen requests. Deleteing this\n"
X "problem will delete the reopen requests as well. You should\n"
X "probably accept or deny each reopen request before deleting.\n") ;
X#ifdef DEBUG
X printf("XPTS(misc.c): Calling SuperWarningPopup!\n") ;
X#endif
X XtSetSensitive(probViewer, False) ;
X XFlush(XtDisplay(probViewer)) ;
X SuperWarningPopup("warning", warning, errorstr) ;
X XtSetSensitive(probViewer, True) ;
X if (!WarningFlag) return ;
X#ifdef DEBUG
X printf("XPTS(misc.c): SuperWarningPopup returned True! Continuing...\n") ;
X#endif
X }
X
X /* Delete the problem. */
X/*CLD*/ if (DeleteProblem(ProbTree, Path, ProblemRecord) == (int)NULL)
X { /* An error occured */
X sprintf(errorstr,
X "Error deleting problem!\n\nPossible error cause:\n%s\n",
X/*CLD*/ CloudStrerror()) ;
X ErrorPopup("error", warning, errorstr) ;
X return ;
X }
X
X /* Update the list of summaries for the parent popup.
X * This might be the pickProblem popup or the unsolvedPopup popup.
X */
X ReadList(XtParent(probViewer), probViewer) ;
X
X
X /* Destroy the problem viewer widget. Realize it's parent,
X * the problem tree navigation widget.
X */
X
X#ifdef DEBUG
X printf("XPTS(DoDeleteProblem()): setting the parent to be sensitive again.\n") ;
X#endif
X XtSetSensitive(XtParent(probViewer), True) ;
X
X#ifdef DEBUG
X printf("XPTS(DoDeleteProblem()): Destroying the warning popup '%s'...\n"
X " warning popup window-ID=%d\n",
X XtName(warning), XtWindow(warning)) ;
X#endif
X/* XtDestroyWidget(warning) ;Don't do, since destroying probViewer will
X * also destroy the warning popup
X */
X
X#ifdef DEBUG
X printf("XPTS(DoDeleteProblem()): probViewer=%p, parent=%p.\n",
X probViewer, XtParent(probViewer)) ;
X printf("XPTS(misc.c): Destroying the problem viewer "
X "for the deleted problem, '%s'...\n", XtName(probViewer)) ;
X#endif
X XtDestroyWidget(probViewer) ;
X
X
X#ifdef DEBUG
X printf("XPTS(misc.c): Leaving DoDeleteProblem()\n") ;
X#endif
X
X} /*------------ End of DoDeleteProblem() --------------------*/
X
X
X/*
X______________________________________________________________________
XDoMoveProblem1()
X
XFUNCTION DESCRIPTION:
X This function is called when the user has indicated what problem
Xtype to move the problem to.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 6/23/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xvoid
XDoMoveProblem1(Widget w,
X XtPointer client_data,
X XtPointer call_data)
X
X /* Interface description:
X INPUT:
X w - The widget for which this callback is registered.
X client_data - Specifies arbitrary client-supplied data
X that the widget w should pass back to the
X client when the widget executes the client's
X callback procedure. In this callback,
X this is the parent widget.
X call_data - Specifies any callback-specific data the widget w
X wants to pass to the client.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X /* Minor */
X /* NONE */
X
X
X /*------------------ Start of DoMoveProblem1() routine -------------------*/
X#ifdef DEBUG
X printf("XPTS(misc.c): Entering DoMoveProblem1()\n") ;
X#endif
X
X /* Make sure only sysops are executing this function. */
X if (!IsSysop(&UserInfoRec))
X {
X#ifdef DEBUG
X fprintf(stderr,
X "XPTS(misc.c): Illegal access to DoMoveProblem1() by non-sysop.\n") ;
X#endif
X return ;
X }
X
X /* Display a warning using WarningPopup(). */
X
X /* If the user responds to the warning with "continue",
X * use DoMoveProblem2() to move the problem from one place in
X * the database to another.
X */
X/* for now, don't do the warning...cut to the chase. */
XDoMoveProblem2(w, client_data, call_data) ;
X
X#ifdef DEBUG
X printf("XPTS(misc.c): Leaving DoMoveProblem1()\n") ;
X#endif
X} /*----------------- End of DoMoveProblem1() -------------------------*/
X
X
X/*
X______________________________________________________________________
XDoMoveProblem2()
X
XFUNCTION DESCRIPTION:
X This function moves a problem from one type to another.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 6/23/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
X
Xvoid
XDoMoveProblem2(Widget w,
X XtPointer client_data,
X XtPointer call_data)
X
X /* Interface description:
X INPUT:
X w - The widget for which this callback is registered.
X client_data - Specifies arbitrary client-supplied data
X that the widget w should pass back to the
X client when the widget executes the client's
X callback procedure. In this callback,
X this is an array of pointers to widgets,
X defined like this:
X client_data[0] = move problem popup widget
X client_data[1] = dialog widget containing
X new problem type.
X
X call_data - Specifies any callback-specific data the widget w
X wants to pass to the client.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X XtPointer *ptrlist ;
X XtPointer *ptrlist2 ;
X Widget parent ;
X Widget probViewer ;
X
X /* Minor */
X String newtype ;
X Arg args[5] ;
X char errorstr[MAXERROR] ;
X
X
X /*--------------- Start of DoMoveProblem2() routine ----------------*/
X#ifdef DEBUG
X printf("XPTS(misc.c): Entering DoMoveProblem2()\n") ;
X#endif
X
X /* Make sure only sysops are executing this function. */
X if (!IsSysop(&UserInfoRec))
X {
X#ifdef DEBUG
X fprintf(stderr,
X "XPTS(misc.c): Illegal access to DoMoveProblem2() by non-sysop.\n") ;
X#endif
X return ;
X }
X
X if (ProblemRecord == NULL)
X {
X#ifdef DEBUG
X printf("XPTS(select.c): ProblemRecord is null !!! Returning.\n");
X#endif
X return ;
X }
X
X
X ptrlist = (XtPointer *)client_data ;
X newtype = XawDialogGetValueString((Widget)(ptrlist[1])) ;
X parent = (Widget) (ptrlist[0]) ;
X probViewer = XtParent(parent) ;
X
X#ifdef DEBUG
X printf("XPTS(misc.c): DoMoveProblem2(): Moving problem to type %s\n", newtype) ;
X#endif
X
X /* Use MoveProblem to move the problem from one place in
X * the database to another.
X */
X/*CLD*/ if (MoveProblem(ProbTree, Path, ProblemRecord, newtype) == (int)NULL)
X {
X /* If an error occurs, use ErrorPopup() to show a message
X * and quit.
X */
X sprintf(errorstr, "Error moving problem!\n\nPossible error cause:\n%s\n",
X/*CLD*/ CloudStrerror()) ;
X ErrorPopup("error", parent, errorstr) ;
X return ;
X }
X
X /* Update the screen. */
X
X /* Change problem viewer "Problem Type" dialog box
X * to reflect the new problem type.
X */
X
X /* Get rid of the "move problem" popup. */
X ptrlist2 = (XtPointer *) XtCalloc(2, sizeof(XtPointer)) ;
X ptrlist2[0] = ptrlist[0] ;
X ptrlist2[1] = NULL ;
X DestroyPopup(w, (XtPointer)ptrlist2, (XtPointer)NULL) ;
X
X
X /* Update the list of summaries for the parent popup.
X * This might be the pickProblem popup or the unsolvedPopup popup.
X */
X ReadList(XtParent(probViewer), probViewer) ;
X
X /* Destroy the problem viewer widget. Realize it's parent,
X * the problem tree navigation widget.
X */
X
X#ifdef DEBUG
X printf("XPTS(DoMoveProblem()): setting the parent to be sensitive again.\n"
X) ;
X#endif
X XtSetSensitive(XtParent(probViewer), True) ;
X
X#ifdef DEBUG
X printf("XPTS(misc.c): Destroying the problem viewer "
X "for the moved problem, '%s'...\n", XtName(probViewer)) ;
X#endif
X XtDestroyWidget(probViewer) ;
X
X
X#ifdef DEBUG
X printf("XPTS(misc.c): Leaving DoMoveProblem2()\n") ;
X#endif
X} /*--------------------- End of DoMoveProblem2() -------------------*/
X
X
X/*
X______________________________________________________________________
XGotoProblemType()
X
XFUNCTION DESCRIPTION:
X
X This function will change the list widget so that it represents the
Xspecified problem type. (This function is not implemented.)
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 2/25/92
X______________________________________________________________________
X*/
X
X
Xvoid
XGotoProblemType(Widget w,
X XtPointer client_data,
X XtPointer call_data)
X
X /* Interface description:
X INPUT:
X w - The widget for which this callback is registered.
X client_data - Specifies arbitrary client-supplied data
X that the widget w should pass back to the
X client when the widget executes the client's
X callback procedure. In this callback,
X this is information to be passed to
X ChangeList().
X call_data - Specifies any callback-specific data the widget w
X wants to pass to the client. In this callback,
X this is a pointer to a record containing
X information about the list selection.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X /* NONE */
X /* Minor */
X /* NONE */
X
X
X
X /*----------------- Start of GotoProblemType() routine ------------------*/
X#ifdef DEBUG
X printf("XPTS(misc.c): Entering gotoProblemType()\n") ;
X#endif
X
X /* Convert what the user has entered into the dialog box
X * into a problem type string.
X * Ideally, this would:
X * 1. convert to lower-case.
X * 2. interpret ".." as super-type.
X * 3. ignore ".".
X * 4. interpret problem-type paths not beginning with "/"
X * to be relative to current problem path.
X * 5. (what else?)
X * For this version, only 1 & 4 are to be implemented.
X */
X
X /* If the input path begins with "/", send this path
X * to ChangeList().
X */
X
X /* If the input path doesn't begin with "/", append
X * it to the current path and send this to ChangeList().
X */
X
X#ifdef DEBUG
X printf("XPTS(misc.c): Leaving GotoProblemType()\n") ;
X#endif
X
X} /*--------------------- End of GotoProblemType() ------------------------*/
X
X
X/*
X______________________________________________________________________
XSyntax()
X
XFUNCTION DESCRIPTION:
X
X This function prints an error message indicating there was a syntax
Xerror on the command-line and exits the application.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 2/20/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xvoid
XSyntax(XtAppContext app_con,
X char *call)
X
X /* Interface description:
X INPUT:
X app_con - The application context
X call - The name of the program, from the command line
X OUTPUT:
X None.
X RETURN VALUE:
X None. (exits application with a value of 1.)
X */
X
X{
X /* Internal variables: */
X /* Major */
X /* NONE */
X /* Minor */
X /* NONE */
X
X /*---------------------- Start of Syntax() routine -----------------------*/
X#ifdef DEBUG
X printf("XPTS(misc.c): Entering Syntax()\n") ;
X#endif
X
X /* Destroy the X application context, which will close any and all
X * windows using XtDestroyApplicationContext().
X */
X XtDestroyApplicationContext(app_con) ;
X
X /* Print an error message indicating there was a syntax error on
X * the command-line.
X */
X fprintf(stderr, "Usage: %s [-noquit]\n", call) ;
X fprintf(stderr,
X " (Standard X Toolkit options are acceptable, also.)\n") ;
X
X /* exit the application with a non-zero value, indicating
X * there was an error.
X */
X exit(1) ;
X
X} /*-------------------------- End of Syntax() -----------------------------*/
X
X
X/*
X______________________________________________________________________
XNoOp()
X
XFUNCTION DESCRIPTION:
X
X This function does nothing, but it does it well.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 10/29/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
XXtActionProc
XNoOp(void)
X
X /* Interface description:
X INPUT:
X None.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X /* NONE */
X /* Minor */
X /* NONE */
X
X /*----------------- Start of NoOp() routine ------------------*/
X
X#ifdef DEBUG
X printf ("NoOp() called\n") ;
X#endif
X
X return;
X
X} /*--------------------- End of NoOp() ------------------------*/
X
X
X/*
X______________________________________________________________________
XAllocProblemItems()
X
XFUNCTION DESCRIPTION:
X
X This function allocates Strings for the ProblemItems array.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 11/14/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xvoid
XAllocProblemItems(void)
X
X /* Interface description:
X INPUT:
X None.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X /* NONE */
X /* Minor */
X int i ;
X
X /*-------------- Start of AllocProblemItems() routine ---------------*/
X
X#ifdef DEBUG
X printf("XPTS(misc.c): AllocProblemItems(): Allocating ProblemItems strings.\n") ;
X#endif
X
X if (ProblemItems == NULL)
X { /* Allocate the needed number of strings for ProblemItems */
X ProblemItems = (String *)XtCalloc(MAXBRANCHES, sizeof(String)) ;
X for (i=0; i<MAXBRANCHES; ++i)
X { ProblemItems[i]=(String)XtMalloc(DBPATHLEN) ;
X ProblemItems[i][0]='\0' ;
X }
X }
X else for (i=0; i<MAXBRANCHES; ++i) /* Allocate any needed strings */
X { if (ProblemItems[i] == NULL)
X ProblemItems[i]=(String)XtMalloc(DBPATHLEN) ;
X ProblemItems[i][0]='\0' ;
X }
X
X#ifdef DEBUG
X printf("XPTS(popup.c): AllocProblemItems(): Done allocating ProblemItems strings.\n") ;
X#endif
X} /*-------------- End of AllocProblemItems() routine ---------------*/
X
X
X/*
X______________________________________________________________________
XFreeItems()
X
XFUNCTION DESCRIPTION:
X
X This function Frees items from an array of Strings that are
Xempty.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 11/14/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xvoid
XFreeItems(char **Items, int MaxItems)
X
X /* Interface description:
X INPUT:
X Items - Array of strings to free.
X MaxItems - Maximum number of strings to free.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X /* NONE */
X /* Minor */
X int i ;
X
X /*----------------- Start of FreeItems() routine ------------------*/
X
X#ifdef DEBUG
X printf("XPTS(misc.c): FreeItems(): Removing extra Items strings with XtFree().\n") ;
X#endif
X
X /* Remove extra Items strings with XtFree().*/
X if (Items != NULL)
X for (i=0; i<MaxItems; ++i)
X { if (Items[i] != NULL)
X if (Items[i][0] == '\0')
X { XtFree(Items[i]) ;
X Items[i]=NULL ;
X }
X }
X
X#ifdef DEBUG
X printf("XPTS(misc.c): FreeItems(): Done removing extra Items strings with XtFree().\n") ;
X
X for (i=0; Items[i] != NULL; ++i)
X { printf("XPTS(misc.c): Items[%d]=%p\n",i, Items[i]) ;
X printf("XPTS(misc.c): Items[%d]='%s'\n", i, Items[i]) ;
X }
X printf("XPTS(misc.c): Items[%d] is NULL\n", i) ;
X
X#endif
X
X} /*--------------------- End of FreeItems() ------------------------*/
X
X
X/*
X______________________________________________________________________
XAppMainLoop()
X
XFUNCTION DESCRIPTION:
X
X This function is the X application main loop, and is patterned
Xafter XtAppMainLoop(). It is used to aid debugging efforts, since
Xit's difficult do some (debugging) things once you call XtAppMainLoop().
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 11/16/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xvoid
XAppMainLoop(XtAppContext app_con)
X
X /* Interface description:
X INPUT:
X app_con - The application context structure.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X XEvent event ;
X Arg args[5] ;
X
X /* Minor */
X String tmpstr ;
X int lasttype=0 ;
X
X
X /*----------------- Start of AppMainLoop() routine ------------------*/
X
X forever()
X {
X XtAppNextEvent(app_con, &event) ;
X
X/* This spews like crazy. */
X/*
X#ifdef DEBUG
X if (lasttype != event.type)
X { lasttype=event.type ;
X printf("XPTS(AppMainLoop()) -- Event: <%d> ", event.type) ;
X printf("\n") ;
X }
X#endif
X*/
X
X#ifndef NOSIGNALS
X if (SigRec.count) DoSignal(SigRec.signal) ;/* Deal with pending signals*/
X#endif
X
X XtDispatchEvent(&event) ;
X
X#ifndef NOSIGNALS
X if (SigRec.count) DoSignal(SigRec.signal) ;/* Deal with pending signals*/
X#endif
X }
X} /*--------------------- End of AppMainLoop() ------------------------*/
X
X
X/*
X______________________________________________________________________
XPrintNewProblemLabel()
X
XFUNCTION DESCRIPTION:
X
X This function is used for debugging. It prints the label
Xassociated with the "New Problem" button, if defined.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 11/20/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xvoid
XPrintNewProblemLabel(void)
X
X /* Interface description:
X INPUT:
X None.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X String tmpstr ;
X Arg args[5] ;
X
X /* Minor */
X int i ;
X
X
X /*------------ Start of PrintNewProblemLabel() routine -------------*/
X
X if (GlobalNewProblemButton != NULL)
X if (XtIsWidget(GlobalNewProblemButton))
X { XtSetArg(args[0], XtNlabel, &tmpstr) ;
X XtGetValues(GlobalNewProblemButton, args, ONE) ;
X printf("-- label = `%s' ", tmpstr) ;
X }
X
X} /*---------------- End of PrintNewProblemLabel() -------------------*/
X
X
X/*
X______________________________________________________________________
XLockedProblem()
X
XFUNCTION DESCRIPTION:
X
X This function will set or reset the flag indicating that there
Xis a locked problem, or query the current state of the flag.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 11/21/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xint
XLockedProblem(int newflag)
X /* Interface description:
X INPUT:
X newflag - The new value of the flag, TRUE or FALSE, or
X QUERY, to just return the current flag.
X OUTPUT:
X None.
X RETURN VALUE:
X int - True if the flag is true, false if it is false.
X */
X
X{
X /* Internal variables: */
X /* Major */
X static int flag=FALSE;
X /* Minor */
X int tmpflag ;
X
X /*----------------- Start of LockedProblem() routine ------------------*/
X
X# ifdef DEBUG
X printf("XPTS(misc.c): LockedProblem() -- flag = %d; newflag = %d\n", flag, newflag) ;
X# endif /*DEBUG*/
X
X if (newflag == QUERY) return(flag) ;
X
X tmpflag=flag ;
X flag=newflag ;
X return(tmpflag) ;
X
X} /*--------------------- End of LockedProblem() ------------------------*/
X
X
X/*
X______________________________________________________________________
XPTS_XIOErrorHandler()
X
XFUNCTION DESCRIPTION:
X
X This function handles fatal IO errors for X.
X______________________________________________________________________
XREVISION HISTORY:
X Author: X Library authors Date: 1989
X
X Revised: Dean Collins Date: 11/28/92
X Added call to ShutDownDB().
X Changed to modern ANSI function declaration.
X
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xint
XPTS_XIOErrorHandler(Display *display)
X
X /* Interface description:
X INPUT:
X display - The X display pointer.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X char msg[80] ;
X /* Minor */
X /* NONE */
X
X /*-------------- Start of PTS_XIOErrorHandler() routine ---------------*/
X
X# ifdef DEBUG
X fprintf(stderr, "XPTS(misc.c): Entering PTS_XIOErrorHandler()...\n") ;
X#endif
X
X fprintf(stderr, "Fatal IO error detected!\n"
X "XPTS is unlocking any locked problems and exiting immediatly...\n") ;
X
X
X /* Unlock any locked problems... */
X
X ShutDownDB(FALSE) ;
X
X
X /* Print error message */
X fprintf (stderr, "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n",
X errno, strerror(errno), DisplayString (display));
X fprintf (stderr, " after %lu requests (%lu known processed) "
X "with %d events remaining.\r\n",
X NextRequest(display) - 1, LastKnownRequestProcessed(display),
X QLength(display));
X
X if (errno == EPIPE)
X {
X fprintf (stderr, " The connection was probably broken by a server "
X "shutdown or KillClient.\r\n");
X }
X
X# ifdef DEBUG
X fprintf(stderr, "XPTS(misc.c): Leaving PTS_XIOErrorHandler().\n") ;
X#endif
X
X exit (1);
X
X} /*------------------ End of PTS_XIOErrorHandler() ---------------------*/
X
X
X/*
X______________________________________________________________________
XPTS_XErrorHandler()
X
XFUNCTION DESCRIPTION:
X
X This function handles fatal X errors.
X______________________________________________________________________
XUNIT TESTING:
X This function will be tested by using a combination of white-box and
Xblack-box tests.
X______________________________________________________________________
XREVISION HISTORY:
X Author: X Library authors Date: 1989
X
X Revised: Dean Collins Date: 11/28/92
X Added call to ShutDownDB().
X Changed to modern ANSI function declaration.
X Revised: Dean Collins Date: 3/7/94
X Added USESYSDEFERR. See comment for XPrintDefaultError().
X
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X Version 1.04 finalized: Dean Collins Date: 3/7/94
X______________________________________________________________________
X*/
X
X
Xint
XPTS_XErrorHandler(Display *dpy,
X XErrorEvent *event)
X
X /* Interface description:
X INPUT:
X dpy - The X display pointer.
X event - The X error event record.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X /* NONE */
X /* Minor */
X /* NONE */
X
X /*-------------- Start of PTS_XErrorHandler() routine ---------------*/
X
X# ifdef DEBUG
X fprintf(stderr, "XPTS(misc.c): Entering PTS_XErrorHandler()...\n") ;
X# endif
X
X /* Use XPrintDefaultError() or XmuPrintDefaultErrorMessage() to print
X * the error message.
X */
X#ifndef USESYSDEFERR
X if (XPrintDefaultError (dpy, event, stderr) == 0) return 0;
X#else
X if (XmuPrintDefaultErrorMessage (dpy, event, stderr) == 0) return 0;
X#endif /*USESYSDEFERR*/
X
X /* OK, Here's my other change... Call ShutDownDB() before exiting.
X * This is the whole reason for having this otherwise duplicate code.
X */
X fprintf(stderr, "X error detected!\n"
X "XPTS is unlocking any locked problems and exiting immediatly...\n") ;
X
X ShutDownDB(FALSE) ;
X
X exit(1);
X
X} /*------------------ End of PTS_XErrorHandler() ---------------------*/
X
X
X/*
X______________________________________________________________________
XXPrintDefaultError()
X
XFUNCTION DESCRIPTION:
X
X This function prints an error message for a fatal X error.
X______________________________________________________________________
XREVISION HISTORY:
X Author: X Library authors Date: 1989
X
X Revised: Dean Collins Date: 11/28/92
X Changed function declaration to ANSI syntax.
X Revised: Dean Collins Date: 12/6/92
X Added BadGC hack to ignore mysterious protocol error. (yuck.)
X (Somebody please figure out what is causing this...)
X Revised: Dean Collins Date: 3/7/93
X Changed from ignoring BadGC to printing a special message.
X Please help me track down this problem!
X Revised: Dean Collins Date: 3/7/94
X Added USESYSDEFERR flag for systems where this function
X breaks (it uses variables that are not necessarily available
X on all systems unless they have "true" X11R4/5 from MIT.)
X If they're using a vendor's version it may well break,
X so just call the default error handler instead.
X No catching of BadGC, however, if this is done.
X
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X Version 1.01 finalized: Dean Collins Date: 3/7/93
X Version 1.04 finalized: Dean Collins Date: 3/7/94 (a whole year?!)
X______________________________________________________________________
X*/
X
X
Xint
XXPrintDefaultError(Display *dpy,
X XErrorEvent *event,
X FILE *fp)
X
X /* Interface description:
X INPUT:
X dpy - The X display pointer.
X event - The X error event structure.
X fp - The file to print the error message to.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X char buffer[BUFSIZ];
X char mesg[BUFSIZ];
X char number[32];
X char *mtype = "XlibMessage";
X#ifndef NOEXTVAR
X register _XExtension *ext = (_XExtension *)NULL;
X#endif
X
X /* Minor */
X /* NONE */
X
X
X /*-------------- Start of XPrintDefaultError() routine ---------------*/
X
X#ifdef USESYSDEFERR
X XmuPrintDefaultErrorMessage (dpy, event, fp) ;
X#else
X
X/* Borrowed, verbatum, from R4 Xlib _PrintDefaultError() function. All I
X * changed (originally) was the declaration, which is now modern ANSI.
X * I've added some #ifdefs and a variable initialization.
X *
X * _XExtension is private to the library, so this routine may break.
X * If it does, eliminate all references to _XExtension and the variable 'ext'
X * by definining NOEXTVAR.
X */
X
X buffer[0] = '\0'; /* Added DC, 5/6/94*/
X XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
X XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
X (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
X XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
X mesg, BUFSIZ);
X (void) fprintf(fp, mesg, event->request_code);
X if (event->request_code < 128) {
X sprintf(number, "%d", event->request_code);
X XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
X }
X else {
X#ifndef NOEXTVAR
X for (ext = dpy->ext_procs;
X ext && (ext->codes.major_opcode != event->request_code);
X ext = ext->next)
X ;
X if (ext)
X strcpy(buffer, ext->name);
X else
X buffer[0] = '\0';
X
X#endif /*NOEXTVAR*/
X }
X (void) fprintf(fp, " (%s)\n ", buffer);
X XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
X mesg, BUFSIZ);
X (void) fprintf(fp, mesg, event->minor_code);
X#ifndef NOEXTVAR
X if (ext) {
X sprintf(mesg, "%s.%d", ext->name, event->minor_code);
X XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
X (void) fprintf(fp, " (%s)", buffer);
X }
X#endif
X fputs("\n ", fp);
X XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
X mesg, BUFSIZ);
X (void) fprintf(fp, mesg, event->resourceid);
X fputs("\n ", fp);
X XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
X mesg, BUFSIZ);
X (void) fprintf(fp, mesg, event->serial);
X fputs("\n ", fp);
X XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
X mesg, BUFSIZ);
X (void) fprintf(fp, mesg, dpy->request);
X fputs("\n", fp);
X if (event->error_code == BadImplementation) return 0;
X
X if (event->error_code == BadGC) /* Does this still happen??? */
X { fputs("\nNOTICE: You have uncovered the mysterious BadGC error.\n",fp) ;
X fputs("Please send a description of EXACTLY what you were doing\n",fp);
X fputs("when this occured to \"dean@halcyon.com\". Include all\n",fp);
X fputs("error information possible. You assistance in tracking\n",fp) ;
X fputs("down this error will be greatly appreciated.\n",fp) ;
X }
X
X#endif /*USESYSDEFERR*/
X
X return 1;
X
X
X} /*------------------ End of XPrintDefaultError() ---------------------*/
X
X
X/*
X______________________________________________________________________
XReadList()
X
XFUNCTION DESCRIPTION:
X
X This function reads a list of summaries and fills in the list
Xfor the problem selection or the unsolved problems windows.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 11/29/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
Xint
XReadList(Widget popup,
X Widget probViewer)
X
X /* Interface description:
X INPUT:
X popup - The popup that contains the list to update.
X probViewer - The parent widget of any error message popups.
X OUTPUT:
X None.
X RETURN VALUE:
X int - 0 means success, non-zero means error.
X */
X
X{
X /* Internal variables: */
X /* Major */
X static String EmptySummariesList[] = { EMPTY_SUMMARIES, NULL } ;
X static String EmptyUnsolvedList[] = { EMPTY_UNSOLVED, NULL } ;
X Widget list=NULL ;
X Widget parent=NULL ;
X static String *UnsolvedList=NULL ;
X char errorstr[MAXERROR] ;
X String *NewList=NULL ;
X Widget warning=NULL ;
X
X /* Minor */
X int i ;
X int flag ;
X Arg args[5] ;
X
X
X /*----------------- Start of ReadList() routine ------------------*/
X
X /* Assign local list widget a value */
X list = XtNameToWidget(popup, "*list") ;
X
X
X /* Re-read the problem summaries for the current problem type,
X * using ChangeList, giving it the current problem type as
X * argument one, and an XtPointer array as argument two,
X * where the array contains the list, dialog and parent widgets.
X */
X#ifdef DEBUG
X printf("XPTS(misc.c): Updating popup's summary list...\n") ;
X printf("XPTS(misc.c): popup's name='%s'\n",
X XtName(popup)) ;
X#endif
X
X
X /* IS POPUP pickProblem? */
X if (strcmp(XtName(popup), "pickProblem") == 0)
X {
X /**** Popup is pickProblem popup ****/
X
X#ifdef DEBUG
X
X printf("XPTS(misc.c): Calling ReadSummaries()...") ;
X#endif
X /* Have to store the new list in NewList and not directly in
X * SummaryItems since the list widget requires that its list resource
X * only be changed through XawListChange() or XtSetValues(),
X * and it must exist unchanged otherwise.
X */
X/*CLD*/ CloudSummaries = ReadSummaries(ProbTree, Path, &NewList) ;
X#ifdef DEBUG
X printf("XPTS(misc.c): Returned from ReadSummaries()...\n") ;
X#endif
X
X#ifdef DEBUG
X if (NewList != NULL)
X { for (i=0; NewList[i] != NULL; ++i)
X { printf("XPTS(misc.c): NewList[%d]=%p\n",i, NewList[i]) ;
X printf("XPTS(misc.c): NewList[%d]='%s'\n", i, NewList[i]) ;
X }
X printf("XPTS(misc.c): NewList[%d] is NULL\n", i) ;
X } else printf("XPTS(misc.c): NewList is NULL\n") ;
X#endif
X
X flag=0 ;
X if (NewList == NULL) flag=1 ;
X else if ((int) (NewList[0]) == (int)NULL) flag=1 ;
X
X if (flag)
X { /* NO PROBLEMS! */
X /* if an empty list was returned, set the value of list to
X * be EmptySummariesList.
X */
X
X#ifdef DEBUG
X printf("XPTS(misc.c): Setting list to be EMPTY_SUMMARIES.\n") ;
X#endif
X
X
X XawListChange(list, EmptySummariesList, ONE, ZERO, TRUE) ;
X XtSetSensitive(list, False) ;
X }
X else
X {
X /* if an empty list was not returned, set the value of list to
X * be NewList.
X */
X XawListChange(list, NewList, ZERO, ZERO, TRUE);
X XtSetSensitive(list, True) ;
X }
X if (SummaryItems) FreeList(SummaryItems) ;
X SummaryItems=NewList ;
X }
X
X
X
X else /**** Popup is unsolvedPopup ****/
X {
X
X#ifdef DEBUG
X printf("XPTS(misc.c): Updating UnsolvedList...\n") ;
X#endif
X /* Set the value of list to be the list of unsolved problem summaries. */
X
X /* Have to store the new list in NewList and not directly in
X * SummaryItems since the list widget requires that its list resource
X * only be changed through XawListChange() or XtSetValues(),
X * and it must exist unchanged otherwise.
X */
X/*CLD*/ CloudUnSummaries = ReadUnsolvedSummaries(ProbTree, &NewList) ;
X/* <= means error, 0 means none, positive is ptr to linked list. */
X#ifdef DEBUG
X printf("XPTS(misc.c): CloudUnSummaries = %p\n", CloudUnSummaries) ;
X#endif
X
X if ((int)CloudUnSummaries < 0)
X {
X sprintf(errorstr, "Error reading problem summaries!\n\n"
X "Possible error cause:\n%s\n",
X/*CLD*/ CloudStrerror()) ;
X ErrorPopup("error", probViewer, errorstr) ;
X return (-1) ;
X }
X
X#ifdef DEBUG
X if (NewList != NULL)
X { for (i=0; NewList[i] != NULL; ++i)
X { printf("XPTS(misc.c): NewList[%d]=%p\n",i, NewList[i]) ;
X printf("XPTS(misc.c): NewList[%d]='%s'\n", i, NewList[i]) ;
X }
X printf("XPTS(misc.c): NewList[%d] is NULL\n", i) ;
X } else printf("XPTS(misc.c): NewList is NULL\n") ;
X#endif
X
X flag=0 ;
X if (NewList == NULL) flag=1 ;
X else if ((int) (NewList[0]) == (int)NULL) flag=1 ;
X
X if (flag)
X { /* NO UNSOLVED PROBLEMS! EXCELLENT! */
X /* if an empty list was returned, set the value of list to
X * be EmptyUnsolvedList.
X */
X XawListChange(list, EmptyUnsolvedList, ZERO, ZERO, TRUE) ;
X XtSetSensitive(list, False) ;
X }
X else
X { /* if an empty list was not returned, set the value of list to
X * be NewList.
X */
X XawListChange(list, NewList, ZERO, ZERO, TRUE) ;
X XtSetSensitive(list, True) ;
X }
X if (UnsolvedList) FreeList(UnsolvedList) ;
X UnsolvedList=NewList ;
X
X }
X
X return (0) ;
X
X} /*--------------------- End of ReadList() ------------------------*/
X
X
X/*
X______________________________________________________________________
XShutDownDB()
X
XFUNCTION DESCRIPTION:
X
X This function unlocks any currently locked problems.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 11/21/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xvoid
XShutDownDB(int AllowPopups)
X
X /* Interface description:
X INPUT:
X AllowPopups - Flag for whether to warn/inform with popups.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X /* NONE */
X /* Minor */
X /* NONE */
X
X /*----------------- Start of ShutDownDB() routine ------------------*/
X
X# ifdef DEBUG
X printf("XPTS(misc.c): ShutDownDB() is making sure the database "
X "is shut down nicely...\n") ;
X printf("XPTS(misc.c): LockedProblem() returns: %d\n",
X LockedProblem(QUERY)) ;
X# endif
X
X
X if (LockedProblem(FALSE))
X {
X# ifdef DEBUG
X printf("XPTS(misc.c): Calling UnlockProblem()...\n") ;
X# endif
X /* Unlock the problem with UnlockProblem() since we're done
X * editing it.
X */
X/*CLD*/ if (UnlockProblem(Path, ProblemRecord) == (int)NULL)
X {
X /* An error occured; call ErrorPopup if allowed */
X
X if (AllowPopups)
X { char errorstr[MAXERROR] ;
X sprintf(errorstr, "Error unlocking problem!\n"
X "\nPossible error cause:\n%s\n",
X/*CLD*/ CloudStrerror()) ;
X ErrorPopup("error", GlobalMainMenuWidget, errorstr) ;
X return ;
X }
X else fprintf(stderr, "xpts: Error unlocking problem!\n") ;
X return ;
X }
X# ifdef DEBUG
X printf("XPTS(misc.c): Returned without an error from UnlockProblem().\n") ;
X# endif
X }
X# ifdef DEBUG
X printf("XPTS(misc.c): LockedProblem() was FALSE.\n") ;
X# endif
X
X} /*--------------------- End of ShutDownDB() ------------------------*/
X
X
X
X/*
X______________________________________________________________________
XSuperWarningPopup()
X
XFUNCTION DESCRIPTION:
X
X This function prompts the user for a True/False selection.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 11/15/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xint
XSuperWarningPopup(String name,
X Widget parent,
X String message)
X
X /* Interface description:
X INPUT:
X name - The resource name of the popup.
X parent - The parent of the popup widget.
X message - The specific error message to display.
X OUTPUT:
X None.
X RETURN VALUE:
X int - True/False user selection.
X */
X
X{
X /* Internal variables: */
X /* Major */
X char btnname[80] ;
X Widget warningPopup=NULL ;
X Widget quitButton=NULL ;
X Widget continueButton=NULL ;
X XtPointer *ptrlist=NULL ;
X XEvent event ;
X XtAppContext app_con ;
X
X /* Minor */
X int done=0 ;
X int ToggledSensitive=FALSE ;
X
X /*-------------- Start of SuperWarningPopup() routine ---------------*/
X
X#ifdef DEBUG
X printf("XPTS(misc.c): Entering SuperWarningPopup.\n") ;
X#endif
X
X
X if (XtIsSensitive(parent) == True)
X { XtSetSensitive(parent,False) ;
X ToggledSensitive=TRUE ;
X#ifdef DEBUG
X printf ("XPTS(misc.c): Parent was sensitive.\n") ;
X#endif
X }
X#ifdef DEBUG
X else
X printf ("XPTS(misc.c): Parent was insensitive.\n") ;
X#endif
X
X /* Use an ErrorPopup widget to start with, even though it's not
X * REALLY an error.
X */
X ErrorPopup(name, parent, message) ;
X
X /* Have the quit button also call SuperWarningFalse() */
X sprintf(btnname, "*%s*quitButton", name) ;
X#ifdef DEBUG
X printf("XPTS(signal.c): SuperWarningPopup() converting name '%s' to widget...\n", btnname) ;
X#endif
X quitButton = XtNameToWidget(parent, btnname) ;
X XtAddCallback(quitButton, XtNcallback, (XtCallbackProc)SuperWarningFalse,
X parent) ;
X
X /* Have the continue button also call SuperWarningTrue() */
X continueButton = XtCreateManagedWidget("continueButton", commandWidgetClass,
X XtParent(quitButton), NULL, ZERO) ;
X XtAddCallback(continueButton, XtNcallback, (XtCallbackProc)SuperWarningTrue,
X parent) ;
X
X warningPopup = XtNameToWidget(parent, name) ;
X ptrlist = (XtPointer *) XtCalloc(2, sizeof(XtPointer)) ;
X ptrlist[0] = (XtPointer) warningPopup;
X if (ToggledSensitive == TRUE)
X ptrlist[1] = (XtPointer) parent ;
X else ptrlist[1] = NULL ;
X#ifdef DEBUG
X printf("XPTS(popup.c): ptrlist[1]=%p\n", ptrlist[1]) ;
X#endif
X XtAddCallback(continueButton, XtNcallback, DestroyPopup, (XtPointer)ptrlist);
X
X
X /* Loop, watching for the DestroyNotify event */
X app_con = XtWidgetToApplicationContext(warningPopup) ;
X while (!done)
X { XtAppNextEvent(app_con, &event) ;
X if (event.type == DestroyNotify)
X {
X#ifdef DEBUG
X printf("XPTS(signal.c): Found a 'DestroyNotify' event.\n") ;
X#endif
X done=1 ;
X }
X XtDispatchEvent(&event) ;
X }
X
X#ifdef DEBUG
X printf("XPTS(signal.c): Leaving SuperWarningPopup.\n") ;
X#endif
X
X return (WarningFlag) ;
X
X} /*------------------ End of SuperWarningPopup() ---------------------*/
X
X
X/*
X______________________________________________________________________
XSuperWarningTrue()
X
XFUNCTION DESCRIPTION:
X
X This function is called if the user selects the continue button
Xfor the warning popup.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 11/15/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xint
XSuperWarningTrue( Widget w,
X XtPointer client_data,
X XtPointer call_data)
X
X /* Interface description:
X INPUT:
X w - The widget for which this callback is registered.
X client_data - Specifies arbitrary client-supplied data
X that the widget w should pass back to the
X client when the widget executes the client's
X callback procedure. In this callback,
X this is ignored.
X call_data - Specifies any callback-specific data the widget w
X wants to pass to the client.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X /* Internal variables: */
X /* Major */
X /* NONE */
X /* Minor */
X /* NONE */
X
X /*-------------- Start of SuperWarningTrue() routine ---------------*/
X
X#ifdef DEBUG
X printf("XPTS(signal.c): Called SuperWarningTrue!!!!!\n") ;
X#endif
X return(WarningFlag=TRUE) ;
X
X} /*------------------ End of SuperWarningTrue() ---------------------*/
X
X
X/*
X______________________________________________________________________
XSuperWarningFalse()
X
XFUNCTION DESCRIPTION:
X
X This function is called if the user selects the quit button
Xfor the warning popup.
X______________________________________________________________________
XREVISION HISTORY:
X Author: Dean Collins Date: 11/15/92
X Version 1.0 finalized: Dean Collins Date: 1/9/93
X______________________________________________________________________
X*/
X
X
Xint
XSuperWarningFalse( Widget w,
X XtPointer client_data,
X XtPointer call_data)
X
X /* Interface description:
X INPUT:
X w - The widget for which this callback is registered.
X client_data - Specifies arbitrary client-supplied data
X that the widget w should pass back to the
X client when the widget executes the client's
X callback procedure. In this callback,
X this is ignored.
X call_data - Specifies any callback-specific data the widget w
X wants to pass to the client.
X OUTPUT:
X None.
X RETURN VALUE:
X None.
X */
X
X{
X
X /* Internal variables: */
X /* Major */
X /* NONE */
X /* Minor */
X /* NONE */
X
X /*-------------- Start of SuperWarningFalse() routine ---------------*/
X
X#ifdef DEBUG
X printf("XPTS(signal.c): Called SuperWarningFalse!!!!!\n") ;
X#endif
X return(WarningFlag=FALSE) ;
X
X} /*------------------ End of SuperWarningFalse() ---------------------*/
X
X/* end of misc.c */
END_OF_FILE
if test 64402 -ne `wc -c <'pts-1.05/xpts/misc.c'`; then
echo shar: \"'pts-1.05/xpts/misc.c'\" unpacked with wrong size!
fi
# end of 'pts-1.05/xpts/misc.c'
fi
echo shar: End of archive 14 \(of 16\).
cp /dev/null ark14isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 16 archives.
echo "\nNow execute the command 'touch pts-1.05/xpts/xpts.help' and \nread the INSTALL document.\n"
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0