176910425Smrg
276910425Smrg  /*\
376910425Smrg   *
49ff100acSmrg   *                          COPYRIGHT 1990
59ff100acSmrg   *                    DIGITAL EQUIPMENT CORPORATION
69ff100acSmrg   *                       MAYNARD, MASSACHUSETTS
79ff100acSmrg   *                        ALL RIGHTS RESERVED.
876910425Smrg   *
976910425Smrg   * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
1076910425Smrg   * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
119ff100acSmrg   * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE
129ff100acSmrg   * FOR ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED
1376910425Smrg   * WARRANTY.
1476910425Smrg   *
1576910425Smrg   * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
1676910425Smrg   * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
1776910425Smrg   * ADDITION TO THAT SET FORTH ABOVE.
1876910425Smrg   *
1976910425Smrg   * Permission to use, copy, modify, and distribute this software and its
2076910425Smrg   * documentation for any purpose and without fee is hereby granted, provided
2176910425Smrg   * that the above copyright notice appear in all copies and that both that
2276910425Smrg   * copyright notice and this permission notice appear in supporting
2376910425Smrg   * documentation, and that the name of Digital Equipment Corporation not be
249ff100acSmrg   * used in advertising or publicity pertaining to distribution of the
2576910425Smrg   * software without specific, written prior permission.
2676910425Smrg  \*/
2776910425Smrg
2876910425Smrg#include 	"utils.h"
2976910425Smrg#include	<ctype.h>
3076910425Smrg#include	<stdlib.h>
3176910425Smrg
3276910425Smrg/***====================================================================***/
3376910425Smrg
349ff100acSmrgstatic FILE *errorFile = NULL;
3576910425Smrg
3676910425SmrgBoolean
379ff100acSmrguSetErrorFile(const char *name)
3876910425Smrg{
399ff100acSmrg    if ((errorFile != NULL) && (errorFile != stderr)) {
409ff100acSmrg        fprintf(errorFile, "switching to %s\n", name ? name : "stderr");
419ff100acSmrg        fclose(errorFile);
4276910425Smrg    }
439ff100acSmrg    if (name != NullString)
449ff100acSmrg        errorFile = fopen(name, "w");
459ff100acSmrg    else
469ff100acSmrg        errorFile = stderr;
479ff100acSmrg    if (errorFile == NULL) {
489ff100acSmrg        errorFile = stderr;
499ff100acSmrg        return (False);
5076910425Smrg    }
519ff100acSmrg    return (True);
5276910425Smrg}
5376910425Smrg
5476910425Smrgvoid
559ff100acSmrguInformation(const char *s, ...)
5676910425Smrg{
5776910425Smrg    va_list ap;
5876910425Smrg
5976910425Smrg    va_start(ap, s);
609ff100acSmrg    vfprintf(errorFile, s, ap);
6176910425Smrg    fflush(errorFile);
6276910425Smrg    va_end(ap);
6376910425Smrg    return;
6476910425Smrg}
6576910425Smrg
6676910425Smrg/***====================================================================***/
6776910425Smrg
6876910425Smrgvoid
699ff100acSmrguAction(const char *s, ...)
7076910425Smrg{
7176910425Smrg    va_list ap;
7276910425Smrg
7376910425Smrg    va_start(ap, s);
749ff100acSmrg    fprintf(errorFile, "                  ");
759ff100acSmrg    vfprintf(errorFile, s, ap);
7676910425Smrg    fflush(errorFile);
7776910425Smrg    va_end(ap);
7876910425Smrg    return;
7976910425Smrg}
8076910425Smrg
8176910425Smrg/***====================================================================***/
8276910425Smrg
8376910425Smrgvoid
849ff100acSmrguWarning(const char *s, ...)
8576910425Smrg{
8676910425Smrg    va_list ap;
8776910425Smrg
8876910425Smrg    va_start(ap, s);
899ff100acSmrg    fprintf(errorFile, "Warning:          ");
909ff100acSmrg    vfprintf(errorFile, s, ap);
9176910425Smrg    fflush(errorFile);
9276910425Smrg    va_end(ap);
9376910425Smrg    return;
9476910425Smrg}
9576910425Smrg
9676910425Smrg/***====================================================================***/
9776910425Smrg
9876910425Smrgvoid
999ff100acSmrguError(const char *s, ...)
10076910425Smrg{
10176910425Smrg    va_list ap;
10276910425Smrg
10376910425Smrg    va_start(ap, s);
1049ff100acSmrg    fprintf(errorFile, "Error:            ");
1059ff100acSmrg    vfprintf(errorFile, s, ap);
10676910425Smrg    fflush(errorFile);
10776910425Smrg    va_end(ap);
10876910425Smrg    return;
10976910425Smrg}
11076910425Smrg
11176910425Smrg/***====================================================================***/
11276910425Smrg
11376910425Smrgvoid
1149ff100acSmrguInternalError(const char *s, ...)
11576910425Smrg{
11676910425Smrg    va_list ap;
11776910425Smrg
11876910425Smrg    va_start(ap, s);
1199ff100acSmrg    fprintf(errorFile, "Internal error:   ");
1209ff100acSmrg    vfprintf(errorFile, s, ap);
12176910425Smrg    fflush(errorFile);
12276910425Smrg    va_end(ap);
12376910425Smrg    return;
12476910425Smrg}
12576910425Smrg
12676910425Smrg/***====================================================================***/
12776910425Smrg
128