Changeset 195 for libmpc/branches/r2d/mpcenc/stderr.c
- Timestamp:
- 12/29/06 15:21:35 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/branches/r2d/mpcenc/stderr.c
r46 r195 2 2 * stderr - Message output system 3 3 * 4 * (C) Frank Klemm, Janne Hyv ärinen 2002. All rights reserved.4 * (C) Frank Klemm, Janne Hyvï¿œinen 2002. All rights reserved. 5 5 * 6 6 * Principles: … … 20 20 */ 21 21 22 #include "mppdec.h" 22 #include <mpc/mpc_types.h> 23 23 24 #ifdef _WIN32 24 25 # include <windows.h> 25 26 #endif 26 27 28 #include <stdio.h> 29 #include <stdarg.h> 30 // #include "mpcenc.h" 27 31 28 static Bool_t stderr_silent = 0; 32 #define WRITE(fp,ptr,len) fwrite (ptr, 1, len, fp) // WRITE returns -1 or 0 on error/EOF, otherwise > 0 33 34 static mpc_bool_t stderr_silent = 0; 29 35 30 36 31 37 void 32 SetStderrSilent ( Bool_t state )38 SetStderrSilent ( mpc_bool_t state ) 33 39 { 34 40 stderr_silent = state; … … 36 42 37 43 38 Bool_t44 mpc_bool_t 39 45 GetStderrSilent ( void ) 40 46 { … … 43 49 44 50 45 int Cdecl51 int mpc_cdecl 46 52 stderr_printf ( const char* format, ... ) 47 53 { 48 char buff [2 * PATHLEN_MAX+ 3072];54 char buff [2 * 1024 + 3072]; 49 55 char* p = buff; 50 56 char* q; … … 61 67 #if defined __unix__ || defined __UNIX__ 62 68 63 WRITE ( STDERR, buff, ret );69 WRITE ( stderr, buff, ret ); 64 70 65 71 #elif defined _WIN32 … … 89 95 if ( hSTDERR == INVALID_HANDLE_VALUE ) { 90 96 while ( ( q = strchr (p, '\n')) != NULL ) { 91 WRITE ( STDERR, p, q-p );92 WRITE ( STDERR, "\r\n", 2 );97 WRITE ( stderr, p, q-p ); 98 WRITE ( stderr, "\r\n", 2 ); 93 99 p = q+1; 94 100 } 95 WRITE ( STDERR, p, strlen (p) );101 WRITE ( stderr, p, strlen (p) ); 96 102 } 97 103 else { … … 165 171 // for non-Unix systems we must merge carriage returns into the stream to avoid staircases 166 172 while ( ( q = strchr (p, '\n')) != NULL ) { 167 WRITE ( STDERR, p, q-p );168 WRITE ( STDERR, "\r\n", 2 );173 WRITE ( stderr, p, q-p ); 174 WRITE ( stderr, "\r\n", 2 ); 169 175 p = q+1; 170 176 } 171 WRITE ( STDERR, p, strlen (p) );177 WRITE ( stderr, p, strlen (p) ); 172 178 173 179 #endif
Note: See TracChangeset
for help on using the changeset viewer.