~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina6/tina-libs/tina/sys/sysGen_format.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-libs/tina/sys/sysGen_format.c,v $
 37  * Date    :  $Date: 2007/02/15 01:52:29 $
 38  * Version :  $Revision: 1.6 $
 39  * CVS Id  :  $Id: sysGen_format.c,v 1.6 2007/02/15 01:52:29 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42 */
 43 /** 
 44  * @file Basic text output (Tina's printf)
 45  * @brief Norm is output to Top tool's text subwindow
 46  * If 2 (or more) text subwindows, then output to most recently CREATED
 47  * If no text subwindow, then output to shell
 48  *
 49  *********
 50 */
 51 
 52 #include "sysGen_format.h"
 53 
 54 #if HAVE_CONFIG_H
 55   #include <config.h>
 56 #endif
 57 
 58 #include <stdio.h>
 59 
 60 #if HAVE_STDARG_H
 61 #  include <stdarg.h>
 62 #  define VA_START(a, f)                va_start(a, f)
 63 #else
 64 #  if HAVE_VARARGS_H
 65 #    include <varargs.h>
 66 #    define VA_START(a, f)  va_start(a)
 67 #  endif
 68 #endif /* HAVE_STDARG_H */
 69 #ifndef VA_START
 70   error no variadic api available
 71 #endif
 72 
 73 #include <tina/sys/sys_GenDef.h>
 74 
 75 
 76 void    default_print(char *msg)
 77 {
 78     (void) printf("%s", msg);
 79 }
 80 
 81 void    default_print_sw(void* text_subwin, char * msg)
 82 {
 83     (void) printf("%s", msg);
 84 }
 85 
 86 static void (*print) () = default_print;
 87 static void (*print_sw) (void*text_subwin, char *msg) = default_print_sw;
 88 
 89 void    format_set_print(void (*func) ( /* ??? */ ))
 90 {
 91     print = func;
 92 }
 93 
 94 void    (*format_get_print(void)) ( /* ??? */ )
 95 {
 96     return (print);
 97 }
 98 
 99 void    (*format_get_print_sw(void)) (void (*format_sw)
100                                       (void* text_subwin, char *msg))
101 {
102   /* warning: return from incompatible pointer type */
103     return print_sw;
104 }
105 
106 void    format_set_print_sw(void (*format_sw_func) (void* text_subwin, char *msg))
107 {
108     print_sw = format_sw_func;
109 }
110 
111 static void default_flush(void)
112 {
113 }
114 
115 static void (*flush) () = default_flush;        /* static data! */
116 
117 void    format_set_flush(void (*func) ( /* ??? */ ))
118 {
119     flush = func;
120 }
121 
122 void    (*format_get_flush(void)) ( /* ??? */ )
123 {
124     return (flush);
125 }
126 
127 
128 void
129 #if HAVE_STDARG_H
130 format(char *fmt,...)
131 #else
132 format(fmt, va_alist)
133         char   *fmt;
134         va_dcl
135 #endif /* HAVE_STDARG_H */
136 {
137     va_list ap;
138     char    string[1024];
139 
140     VA_START(ap, fmt);
141     (void) vsprintf(string, fmt, ap);
142     print(string);
143     va_end(ap);
144 }
145 
146 void
147 #if HAVE_STDARG_H
148 format_sw(void* text_subwin, char *fmt,...)
149 #else
150 format_sw(text_subwin, fmt, va_alist)
151         void *text_subwin;
152         char *fmt;
153         va_dcl
154 #endif /* HAVE_STDARG_H */
155 {
156     va_list ap;
157     char    string[1024];
158 
159     VA_START(ap, fmt);
160     (void) vsprintf(string, fmt, ap);
161     print_sw(text_subwin, string);
162     va_end(ap);
163 }
164 
165 
166 void
167 #if HAVE_STDARG_H
168 format_flush(char *fmt,...)
169 #else
170 format_flush(fmt, va_alist)
171         char   *fmt;
172         va_dcl
173 #endif /* HAVE_STDARG_H */
174 {
175     va_list ap;
176     char    string[1024];
177 
178     VA_START(ap, fmt);
179     (void) vsprintf(string, fmt, ap);
180     format(string);
181     flush();
182     va_end(ap);
183 }
184 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.