home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / desklib / sources / DeskLib / !DLSources / OtherLibs / Debugs / c / uniquepipe < prev   
Encoding:
Text File  |  1995-07-10  |  1.6 KB  |  80 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Debug1.c.uniquepipe
  12.     Author:  Julian Smith
  13.     Version: 0.00 (04 Jun 1995)
  14.     Purpose: Provides a set of Debug_ function which send stuff to a unique
  15.              file in a given directory.
  16. */
  17.  
  18.  
  19. #include <stdarg.h>
  20. #include <stdio.h>
  21.  
  22. #include "DeskLib:Error.h"
  23.  
  24. #include "DeskLib:Debug.h"
  25.  
  26. #include "DeskLib:Str.h"
  27.  
  28. static char    debug_filename[ 256] = "";
  29.  
  30.  
  31.  
  32.  
  33.  
  34. void    Debug_Initialise( void)
  35. {
  36. sprintf( debug_filename, "Pipe:$.DeskLib.%s", LeafName( tmpnam( NULL)));
  37. }
  38.  
  39.  
  40. static FILE    *Debug__OpenPipeFile( void)
  41. {
  42. FILE    *file;
  43. if ( debug_filename[ 0] == 0)    Debug_Initialise();
  44. file = fopen( debug_filename, "a");
  45. if ( !file)    Error_ReportFatal( 0, "Can't open debugging pipe file '%s'");
  46. return file;
  47. }
  48.  
  49. #define Debug__ClosePipeFile( f)    fclose( f)
  50.  
  51.  
  52.  
  53. int    Debug_Printf( const char *format, ...)
  54. {
  55. va_list    va;
  56. int    i;
  57. FILE    *f;
  58.  
  59. f = Debug__OpenPipeFile();
  60.  
  61. va_start(va, format);
  62. i = vfprintf( f, format, va);
  63. va_end(va);
  64.  
  65. Debug__ClosePipeFile( f);
  66. return i;
  67. }
  68.  
  69.  
  70.  
  71. void    Debug_Print( const char *text)
  72. {
  73. FILE    *f;
  74. f = Debug__OpenPipeFile();
  75. fputs( text, f);
  76. Debug__ClosePipeFile( f);
  77. }
  78.  
  79.  
  80.