home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / xp / xp_trace.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.2 KB  |  85 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19.  
  20. #include <stddef.h>
  21. #include <stdio.h>
  22.  
  23. #include "xp_trace.h"
  24. #include "xp_mcom.h"
  25.  
  26. #ifndef NSPR20
  27. #if defined(__sun)
  28. #include "sunos4.h"
  29. #endif
  30. #endif /* NSPR20 */
  31.  
  32. void XP_TraceV (const char* message, va_list args)
  33. {
  34. #ifdef DEBUG
  35.     char buf[2000]; 
  36.     PR_vsnprintf(buf, sizeof(buf), message, args);
  37.     FE_Trace(buf);
  38. #endif /* DEBUG */
  39. }
  40.  
  41. /* Trace with trailing newline */
  42. void XP_Trace (const char* message, ...)
  43. {
  44. #ifdef DEBUG
  45.     va_list args;
  46.     va_start(args, message);
  47.     XP_TraceV(message, args);
  48.     va_end(args);
  49.     FE_Trace("\n");
  50. #endif /* DEBUG */
  51. }
  52.  
  53. /* Trace without trailing newline */
  54. void XP_Trace1 (const char* message, ...)
  55. {
  56. #ifdef DEBUG
  57.     va_list args;
  58.     va_start(args, message);
  59.     XP_TraceV(message, args);
  60.     va_end(args);
  61. #endif /* DEBUG */
  62. }
  63.  
  64. #if defined(XP_UNIX)
  65. FILE *real_stderr = stderr;
  66. #endif /* XP_UNIX */
  67.  
  68. #if defined(XP_UNIX) && defined(DEBUG)
  69. void FE_Trace (const char* buffer)
  70. {
  71. #if defined(DEBUG_warren)
  72.     int len = XP_STRLEN(buffer); /* vsprintf does not return length */
  73.     fwrite(buffer, 1, len, real_stderr);
  74. #endif
  75. }
  76. #endif /* defined(XP_UNIX) && defined(DEBUG) */
  77.  
  78. /*-----------------------------------------------------------------------------
  79.     Macintosh FE_Trace
  80.     Always exists, doesn't do anything unless in DEBUG
  81.     
  82.     Implemented in MemAllocatorPPCDebug project because of linkage conflicts.
  83. -----------------------------------------------------------------------------*/
  84.  
  85.