/[ascend]/trunk/base/generic/utilities/ascPrint.h
ViewVC logotype

Contents of /trunk/base/generic/utilities/ascPrint.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 49 - (show annotations) (download) (as text)
Tue Apr 12 23:36:01 2005 UTC (14 years, 10 months ago) by ben.allan
File MIME type: text/x-chdr
File size: 5095 byte(s)
fixed the problems with return codes jerry found.
1 /**<
2 * ASCEND Printf stdout/stderr Substitutes Dispatcher
3 * by Benjamin Allan
4 * Created: 4.March.2005
5 * Version: $Revision: 1.6 $
6 * Version control file: $RCSfile: ascPrint.h,v $
7 * Date last modified: $Date: 1997/10/29 13:08:50 $
8 * Last modified by: $Author: mthomas $
9 *
10 * This file is part of the ASCEND utilities.
11 *
12 * Copyright 2005, Benjamin Andrew Allan
13 *
14 * The ASCEND utilities is free software; you can redistribute
15 * it and/or modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * The ASCEND utilities is distributed in hope that it will be
20 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with the program; if not, write to the Free Software Foundation,
26 * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
27 * COPYING. COPYING is found in ../compiler.
28 */
29
30 #ifndef _ASCPRINT_H
31 #define _ASCPRINT_H
32
33 /**<
34 * When including this file, you must include:
35 * #include <stdarg.h>
36 * #include "compiler/compiler.h"
37 * #include "utilities/ascprint.h"
38 */
39
40
41 /**
42 * Output functions interceptor vtable. This should be constructed
43 * and the functions fully operational before it is
44 * pushed on the stack of output tables.
45 */
46 struct Asc_PrintVTable {
47 CONST char *name;
48 int (*print)(FILE *fp, CONST char *format, va_list args);
49 int (*fflush)(FILE *);
50 struct Asc_PrintVTable *next;
51 };
52
53
54 extern int Asc_PrintPushVTable(struct Asc_PrintVTable *vtable);
55 /**<
56 * int Asc_PrintPushVTable(v)
57 *
58 * Add a vtable to the ascend output interceptor list.
59 * This function should be called after the user interface io channels
60 * has been initialized. Any calls to Asc_Printf() made prior to calling
61 * Asc_PrintAddVTable() will use ordinary printf().
62 * More than one vtable can be pushed, in which case output will go
63 * to all the outputs setup in the reverse or in which tables were pushed.
64 * The vtable will be rejected if it or any field in it is null,
65 * other than next which must be null.
66 * If the vtable's name conflicts, return 1 otherwise return 0.
67 *
68 * He who pushes a vtable should eventually remove it and destroy it.
69 */
70
71 extern struct Asc_PrintVTable * Asc_PrintRemoveVTable(CONST char *name);
72 /**<
73 * oldVt = Asc_PrintRemoveVTable(name);
74 *
75 * Take a vtable out of the printing list and return it.
76 * If not found in list, return is NULL.
77 */
78
79 extern int Asc_Printf(CONST char *, ...);
80 /**<
81 * int Asc_Printf(format, variable_number_args)
82 * CONST char *format; // sprintf-style format string
83 * va_list variable_number_args; // arguments for the `format' string
84 *
85 * Loops over all defined print vtables.
86 * Using the sprintf-style format string `format', print the
87 * `variable_number_args' to some approximation of stdout. Return the
88 * number of bytes printed from the final vtable that is called.
89 *
90 * This is needed under Windows to redirect stdout to the TkConsole
91 * instead of into the bit bucket.
92 */
93
94 extern int Asc_FPrintf(FILE *, CONST char *, ...);
95 /**<
96 * int Asc_FPrintf(fileptr, format, variable_number_args)
97 * FILE *fileptr; // file handle to send output to
98 * CONST char *format; // sprintf-style format string
99 * va_list variable_number_args; // arguments for the `format' string
100 *
101 * Loops over all defined print vtables.
102 * Using the sprintf-style format string `format', print the
103 * `variable_number_args' to the file handle `fileptr'. Return the
104 * number of bytes printed from the final vtable that is called.
105 *
106 * This is needed under Windows to redirect stdout and stderr to the
107 * TkConsole instead of into the bit bucket.
108 */
109
110
111 extern int Asc_FFlush(FILE *);
112 /**<
113 * int Asc_FFlush(fileptr)
114 * FILE *fileptr;
115 *
116 * Loops over all defined print vtables.
117 * Flush output to the file pointed to by the file pointer `fileptr';
118 * return 0 for success and EOF for failure.
119 *
120 * This is needed for consistency with Asc_FPrintf() and Asc_Printf().
121 */
122
123
124 extern int Asc_FPutc(int, FILE*);
125 /**<
126 * int Asc_FPutc( c, fileptr );
127 * int c;
128 * FILE *fileptr;
129 *
130 * Loops over all defined print vtables.
131 * Print the character `c' to the output file pointed to by the
132 * file pointer `fileptr'; return 1 for success and EOF for failure.
133 *
134 * This is needed under Windows to redirect stdout and stderr to the
135 * TkConsole instead of into the bit bucket.
136 */
137
138
139 extern int Asc_Putchar(int);
140 /**<
141 * int Asc_Putchar( c );
142 * int c;
143 *
144 * Loops over all defined print vtables.
145 * Print the character `c' to `stdout'; return 1 for success and
146 * EOF for failure.
147 *
148 * This is needed under Windows to redirect stdout and stderr to the
149 * TkConsole instead of into the bit bucket.
150 */
151 #endif /**< _ASCPRINT_H */

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22