1 /* tsprintf.h 2 * =========================================================================== 3 * 4 * PUBLIC DOMAIN NOTICE 5 * National Center for Biotechnology Information 6 * 7 * This software/database is a "United States Government Work" under the 8 * terms of the United States Copyright Act. It was written as part of 9 * the author's official duties as a United States Government employee and 10 * thus cannot be copyrighted. This software/database is freely available 11 * to the public for use. The National Library of Medicine and the U.S. 12 * Government have not placed any restriction on its use or reproduction. 13 * 14 * Although all reasonable efforts have been taken to ensure the accuracy 15 * and reliability of the software and data, the NLM and the U.S. 16 * Government do not and cannot warrant the performance or results that 17 * may be obtained by using this software or data. The NLM and the U.S. 18 * Government disclaim all warranties, express or implied, including 19 * warranties of performance, merchantability or fitness for any particular 20 * purpose. 21 * 22 * Please cite the author in any work or product based on this material. 23 * 24 * =========================================================================== 25 * 26 * File Name: tsprintf.h 27 * 28 * Author: Denis Vakatov 29 * 30 * Version Creation Date: 07/10/96 31 * 32 * $Id: tsprintf.h,v 6.0 1997/08/25 18:17:42 madden Exp $ 33 * 34 * File Description: 35 * Memory- and MT-safe "sprintf()" 36 * 37 * ========================================================================== 38 */ 39 40 41 #ifndef TSPRINTF_H 42 #define TSPRINTF_H 43 44 #include <ncbilcl.h> 45 #include <ncbistd.h> 46 #ifdef VAR_ARGS 47 #include <varargs.h> 48 #else 49 #include <stdarg.h> 50 #endif 51 52 53 #undef NLM_EXTERN 54 #ifdef NLM_IMPORT 55 #define NLM_EXTERN NLM_IMPORT 56 #else 57 #define NLM_EXTERN extern 58 #endif 59 60 #ifdef __cplusplus 61 extern "C" { 62 #endif 63 64 /* 65 * Return pointer to a temporary (based on the thread's scratch 66 * buffer) memory area containing the resulting formatted output 67 * The resulting string is '\0'-terminated 68 * Return NULL on error 69 */ 70 NLM_EXTERN const Nlm_Char PNTR Nlm_TSPrintf VPROTO ( 71 (const Nlm_Char PNTR fmt, 72 ...) 73 ); 74 #define TSPrintf Nlm_TSPrintf 75 76 77 NLM_EXTERN const Nlm_Char PNTR Nlm_TSPrintfArgs VPROTO ( 78 (const Nlm_Char PNTR fmt, 79 va_list args) 80 ); 81 #define TSPrintfArgs Nlm_TSPrintfArgs 82 83 84 /* 85 * Attention!!! the resulting pointer points to the scratch buffer area, 86 * so it must be used immediately and should not be explicitly deallocated 87 */ 88 89 #ifdef VAR_ARGS 90 #define TSPRINTF(const_char_ptr, fmt) \ 91 {{ \ 92 va_list args; \ 93 va_start(args); \ 94 const_char_ptr = TSPrintfArgs(fmt, args); \ 95 va_end( args ); \ 96 }} 97 #else 98 #define TSPRINTF(const_char_ptr, fmt) \ 99 {{ \ 100 va_list args; \ 101 va_start(args, fmt); \ 102 const_char_ptr = TSPrintfArgs(fmt, args); \ 103 va_end( args ); \ 104 }} 105 #endif 106 107 108 #ifdef __cplusplus 109 } 110 #endif 111 112 113 #undef NLM_EXTERN 114 #ifdef NLM_EXPORT 115 #define NLM_EXTERN NLM_EXPORT 116 #else 117 #define NLM_EXTERN 118 #endif 119 120 #endif /* TSPRINTF_H */ 121 122