home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Interapplication Comm / MakeStartupAliasToMe / debugf.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  5.1 KB  |  121 lines  |  [TEXT/MPS ]

  1. /*
  2.     File: debugf.h
  3.     
  4.     Description:
  5.         debugf is like printf.  Routines implemented herein provide a subset
  6.     of the standard C library's sprintf functionality.  The differences
  7.     with this implementation include:
  8.     
  9.     it's small (around 2k once compiled)
  10.     
  11.     it doesn't call any toolbox or os routines.  it's entirely self contained
  12.     and does not call any toolbox routines or stdclib routines.  The only call
  13.     made outside of this library is the DebugStr call inside of the debugf
  14.     routine.
  15.  
  16.     it's safe to call at interrupt time (assuming there's the stack
  17.     space to do it).
  18.     
  19.     debugf can be called anywhere it is safe to call DebugStr.
  20.  
  21.     Copyright:
  22.         © Copyright 2000 Apple Computer, Inc. All rights reserved.
  23.     
  24.     Disclaimer:
  25.         IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  26.         ("Apple") in consideration of your agreement to the following terms, and your
  27.         use, installation, modification or redistribution of this Apple software
  28.         constitutes acceptance of these terms.  If you do not agree with these terms,
  29.         please do not use, install, modify or redistribute this Apple software.
  30.  
  31.         In consideration of your agreement to abide by the following terms, and subject
  32.         to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  33.         copyrights in this original Apple software (the "Apple Software"), to use,
  34.         reproduce, modify and redistribute the Apple Software, with or without
  35.         modifications, in source and/or binary forms; provided that if you redistribute
  36.         the Apple Software in its entirety and without modifications, you must retain
  37.         this notice and the following text and disclaimers in all such redistributions of
  38.         the Apple Software.  Neither the name, trademarks, service marks or logos of
  39.         Apple Computer, Inc. may be used to endorse or promote products derived from the
  40.         Apple Software without specific prior written permission from Apple.  Except as
  41.         expressly stated in this notice, no other rights or licenses, express or implied,
  42.         are granted by Apple herein, including but not limited to any patent rights that
  43.         may be infringed by your derivative works or by other works in which the Apple
  44.         Software may be incorporated.
  45.  
  46.         The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  47.         WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  48.         WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  49.         PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  50.         COMBINATION WITH YOUR PRODUCTS.
  51.  
  52.         IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  53.         CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  54.         GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  55.         ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  56.         OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  57.         (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  58.         ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59.  
  60.     Change History (most recent first):
  61.         Wed, Feb 16, 2000 -- created
  62. */
  63.  
  64. #ifndef __DEBUGF__
  65. #define __DEBUGF__
  66.  
  67. #include <Types.h>
  68. #include <StdArg.h>
  69.  
  70. /* vsoutputf is like vsprintf except:
  71.     - it only understands a different set of format specifies:
  72.     format:  %[.N]F
  73.     .N is an optional argument specifying the width of the printed field.
  74.     F is the format specifier.  it can be one of the following:
  75.         s - argument is a c style string,
  76.         p - argument is a pascal style string
  77.         c - argument is a single character
  78.         b - print argument as a binary number
  79.         n - print argument as a base 4 number
  80.         o - print argument as an octal number
  81.         d - print argument as a signed decimal number
  82.         u - print argument as an unsigned decimal number
  83.         x - print argument as a hexidecimal number.
  84.     example:
  85.         debugf("%s bug is %x %.4d %p.", "That", 57005, 10, "\ptimes over");
  86.     calls up macsbug and prints:
  87.         That bug is DEAD 0010 times over.
  88.     */
  89.  
  90. #ifdef __cplusplus
  91. extern "C" {
  92. #endif
  93.  
  94. /* vsoutputf outputs args using format to the string s.  it returns
  95.     the length of the string data stored in s.  This routine
  96.     does not add a trailing zero byte to the end of the output
  97.     string.  */
  98. int vsoutputf(char *s, const char *fmt, va_list arg);
  99.  
  100. /* soutputf is like sprintf, except it is safe to call it at
  101.     interrupt time. it outputs fmt using the ... arguments
  102.     to the string s and adds a trailing zero to the end
  103.     of the generated string. it returns the length of the
  104.     string (including the trailing zero byte). */
  105. int soutputf(char *s, const char *fmt, ...);
  106.  
  107. /* PLoutputf is like soutputf, except it outputs the string
  108.     to a pascal style string p and returns a pointer to
  109.     that string. */
  110. StringPtr PLoutputf(StringPtr p, const char *fmt, ...);
  111.  
  112. /* debugf outputs the fmt and ... parameters to a pascal string
  113.     and passes that string to DebugStr(). */
  114. void debugf(char const *fmt, ...);
  115.  
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119.  
  120. #endif
  121.