File: streams.c

package info (click to toggle)
shhmsg 1.4.1-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 148 kB
  • ctags: 78
  • sloc: ansic: 319; makefile: 134; sh: 10
file content (94 lines) | stat: -rw-r--r-- 2,906 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* $Id: streams.c,v 1.4 2002/03/02 19:37:36 sverrehu Exp $ */
/*------------------------------------------------------------------------
 |  FILE            streams.c
 |  MODULE OF       shhmsg - library for displaying messages.
 |
 |  DESCRIPTION     Routines for handling the stream that output goes to.
 |                  This allows using streams other than stderr and stdout.
 |
 |  WRITTEN BY      Sverre H. Huseby <shh@thathost.com>
 |                  This file is mainly contributed by
 |                    Louis W. Erickson <loue@skylight.com>
 +----------------------------------------------------------------------*/

#include <stdio.h>
#include <string.h>

#include "internal.h"
#include "shhmsg.h"

/*-----------------------------------------------------------------------+
|  PUBLIC FUNCTIONS                                                      |
+-----------------------------------------------------------------------*/

/*------------------------------------------------------------------------
 |
 |  NAME          msgSetErrorStream
 |
 |  FUNCTION      Specify the file stream error values should go to.
 |
 |  SYNOPSIS      #include "shhmsg.h"
 |                FILE *msgSetErrorStream(FILE *f);
 |
 |  INPUT         f       pointer to a FILE that holds stream to write to.
 |
 |  RETURNS       Pointer to the old stream used for output.
 |
 |  DESCRIPTION   The stream passed is used to write all errors to.
 */
FILE *
msgSetErrorStream(FILE *f)
{
    FILE *ret = GET_ERROR_STREAM;

    _msgErrorStream = f ? f : MSG_DEFAULT_ERROR_STREAM;
    return ret;
}

/*------------------------------------------------------------------------
 |
 |  NAME          msgSetVerboseStream
 |
 |  FUNCTION      Specify the file stream verbose output should go to.
 |
 |  SYNOPSIS      #include "shhmsg.h"
 |                FILE *msgSetVerboseStream(FILE *f);
 |
 |  INPUT         f       pointer to a FILE that holds stream to write to.
 |
 |  RETURNS       Pointer to the old stream used for output.
 |
 |  DESCRIPTION   The stream passed is used to write all verbose output to.
 */
FILE *
msgSetVerboseStream(FILE *f)
{
    FILE *ret = GET_VERBOSE_STREAM;

    _msgVerboseStream = f ? f : MSG_DEFAULT_VERBOSE_STREAM;
    return ret;
}

/*------------------------------------------------------------------------
 |
 |  NAME          msgSetMessageStream
 |
 |  FUNCTION      Specify the file stream message output should go to.
 |
 |  SYNOPSIS      #include "shhmsg.h"
 |                FILE *msgSetMessageStream(FILE *f);
 |
 |  INPUT         f       pointer to a FILE that holds stream to write to.
 |
 |  RETURNS       Pointer to the old stream used for output.
 |
 |  DESCRIPTION   The stream passed is used to write all "messages" to.
 */
FILE *
msgSetMessageStream(FILE *f)
{
    FILE *ret = GET_MESSAGE_STREAM;

    _msgMessageStream = f ? f : MSG_DEFAULT_MESSAGE_STREAM;
    return ret;
}