njn | 36a20fa | 2005-06-03 03:08:39 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Printing libc stuff. pub_tool_libcprint.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
njn | 9f20746 | 2009-03-10 22:02:09 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2009 Julian Seward |
njn | 36a20fa | 2005-06-03 03:08:39 +0000 | [diff] [blame] | 11 | jseward@acm.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __PUB_TOOL_LIBCPRINT_H |
| 32 | #define __PUB_TOOL_LIBCPRINT_H |
| 33 | |
| 34 | /* --------------------------------------------------------------------- |
| 35 | Basic printing |
| 36 | ------------------------------------------------------------------ */ |
| 37 | |
| 38 | /* Note that they all output to the file descriptor given by the |
sewardj | 5d9dc75 | 2009-07-15 14:52:18 +0000 | [diff] [blame] | 39 | --log-fd/--log-file/--log-socket argument, which defaults to 2 |
| 40 | (stderr). Hence no need for VG_(fprintf)(). |
| 41 | */ |
| 42 | extern UInt VG_(printf) ( const HChar *format, ... ) |
| 43 | PRINTF_CHECK(1, 2); |
| 44 | |
| 45 | extern UInt VG_(vprintf) ( const HChar *format, va_list vargs ) |
| 46 | PRINTF_CHECK(1, 0); |
| 47 | |
| 48 | extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... ) |
| 49 | PRINTF_CHECK(2, 3); |
| 50 | |
| 51 | extern UInt VG_(vsprintf) ( Char* buf, const HChar* format, va_list vargs ) |
| 52 | PRINTF_CHECK(2, 0); |
| 53 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 54 | extern UInt VG_(snprintf) ( Char* buf, Int size, |
sewardj | 5d9dc75 | 2009-07-15 14:52:18 +0000 | [diff] [blame] | 55 | const HChar *format, ... ) |
| 56 | PRINTF_CHECK(3, 4); |
| 57 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 58 | extern UInt VG_(vsnprintf)( Char* buf, Int size, |
sewardj | 5d9dc75 | 2009-07-15 14:52:18 +0000 | [diff] [blame] | 59 | const HChar *format, va_list vargs ) |
| 60 | PRINTF_CHECK(3, 0); |
| 61 | |
| 62 | /* Yet another, totally general, version of vprintf, which hands all |
| 63 | output bytes to CHAR_SINK, passing it OPAQUE as the second arg. */ |
| 64 | extern void VG_(vcbprintf)( void(*char_sink)(HChar, void* opaque), |
| 65 | void* opaque, |
| 66 | const HChar* format, va_list vargs ); |
| 67 | |
| 68 | /* These are the same as the non "_xml" versions above, except the |
| 69 | output goes on the selected XML output channel instead of the |
| 70 | normal one. |
| 71 | */ |
| 72 | extern UInt VG_(printf_xml) ( const HChar *format, ... ) |
| 73 | PRINTF_CHECK(1, 2); |
| 74 | |
| 75 | extern UInt VG_(vprintf_xml) ( const HChar *format, va_list vargs ) |
| 76 | PRINTF_CHECK(1, 0); |
| 77 | |
| 78 | extern UInt VG_(printf_xml_no_f_c) ( const HChar *format, ... ); |
njn | 36a20fa | 2005-06-03 03:08:39 +0000 | [diff] [blame] | 79 | |
njn | 7a5915e | 2005-07-17 16:12:59 +0000 | [diff] [blame] | 80 | // Percentify n/m with d decimal places. Includes the '%' symbol at the end. |
njn | 5eaff2f | 2005-09-25 19:11:45 +0000 | [diff] [blame] | 81 | // Right justifies in 'buf'. |
| 82 | extern void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, char buf[]); |
njn | 856c54e | 2005-06-26 18:43:40 +0000 | [diff] [blame] | 83 | |
sewardj | 5d9dc75 | 2009-07-15 14:52:18 +0000 | [diff] [blame] | 84 | |
njn | 36a20fa | 2005-06-03 03:08:39 +0000 | [diff] [blame] | 85 | /* --------------------------------------------------------------------- |
| 86 | Messages for the user |
| 87 | ------------------------------------------------------------------ */ |
| 88 | |
njn | 3e11452 | 2005-06-11 03:31:09 +0000 | [diff] [blame] | 89 | /* No, really. I _am_ that strange. */ |
sewardj | 5d9dc75 | 2009-07-15 14:52:18 +0000 | [diff] [blame] | 90 | #define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d\n",nnn) |
njn | 3e11452 | 2005-06-11 03:31:09 +0000 | [diff] [blame] | 91 | |
njn | 36a20fa | 2005-06-03 03:08:39 +0000 | [diff] [blame] | 92 | /* Print a message prefixed by "??<pid>?? "; '?' depends on the VgMsgKind. |
| 93 | Should be used for all user output. */ |
| 94 | |
| 95 | typedef |
| 96 | enum { Vg_UserMsg, /* '?' == '=' */ |
| 97 | Vg_DebugMsg, /* '?' == '-' */ |
| 98 | Vg_DebugExtraMsg, /* '?' == '+' */ |
| 99 | Vg_ClientMsg /* '?' == '*' */ |
| 100 | } |
| 101 | VgMsgKind; |
| 102 | |
sewardj | 5d9dc75 | 2009-07-15 14:52:18 +0000 | [diff] [blame] | 103 | /* Send a single-part message. The format specification may contain |
| 104 | any ISO C format specifier or %t. No attempt is made to let the |
| 105 | compiler verify consistency of the format string and the argument |
| 106 | list. */ |
bart | a0b6b2c | 2008-07-07 06:49:24 +0000 | [diff] [blame] | 107 | extern UInt VG_(message_no_f_c)( VgMsgKind kind, const HChar* format, ... ); |
sewardj | 5d9dc75 | 2009-07-15 14:52:18 +0000 | [diff] [blame] | 108 | /* Send a single-part message. The format specification may contain |
| 109 | any ISO C format specifier. The gcc compiler will verify |
| 110 | consistency of the format string and the argument list. */ |
bart | a0b6b2c | 2008-07-07 06:49:24 +0000 | [diff] [blame] | 111 | extern UInt VG_(message)( VgMsgKind kind, const HChar* format, ... ) |
| 112 | PRINTF_CHECK(2, 3); |
njn | 36a20fa | 2005-06-03 03:08:39 +0000 | [diff] [blame] | 113 | |
bart | a0b6b2c | 2008-07-07 06:49:24 +0000 | [diff] [blame] | 114 | extern UInt VG_(vmessage)( VgMsgKind kind, const HChar* format, va_list vargs ) |
| 115 | PRINTF_CHECK(2, 0); |
| 116 | |
njn | 6f74a7e | 2009-03-12 00:06:45 +0000 | [diff] [blame] | 117 | // Short-cuts for VG_(message)(). |
sewardj | 5d9dc75 | 2009-07-15 14:52:18 +0000 | [diff] [blame] | 118 | extern UInt VG_(umsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2); |
| 119 | extern UInt VG_(dmsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2); |
| 120 | extern UInt VG_(emsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2); |
| 121 | |
| 122 | /* Flush any output cached by previous calls to VG_(message) et al. */ |
| 123 | extern void VG_(message_flush) ( void ); |
bart | a0b6b2c | 2008-07-07 06:49:24 +0000 | [diff] [blame] | 124 | |
njn | 36a20fa | 2005-06-03 03:08:39 +0000 | [diff] [blame] | 125 | #endif // __PUB_TOOL_LIBCPRINT_H |
| 126 | |
| 127 | /*--------------------------------------------------------------------*/ |
| 128 | /*--- end ---*/ |
| 129 | /*--------------------------------------------------------------------*/ |