home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / languages / progs / shell / Sources / c / Printf < prev    next >
Encoding:
Text File  |  1994-05-17  |  1.2 KB  |  59 lines

  1. #include <stdarg.h>
  2. #include <string.h>
  3.  
  4. #include "DeskLib:Event.h"
  5.  
  6. #include "Shell.SafeAlloc.h"
  7. #include "Shell.TextRect.h"
  8. #include "Shell.Printf.h"
  9.  
  10.  
  11.  
  12. void    Shell_Printf( const char *fmt, ...)
  13. {    va_list args;
  14. va_start( args, fmt);
  15. vsprintf( Shell_string, fmt, args);
  16. va_end( args);
  17. Shell_TextRectPrint( NULL, Shell_string);
  18. }
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. static BOOL Shell_WaitPrintfNullHandler( event_pollblock *event, void *reference)
  28. {
  29. UNUSED( event);
  30. Shell_TextRectPrint( NULL, (char *) reference);
  31. Event_Release( event_NULL, event_ANY, event_ANY, Shell_WaitPrintfNullHandler, reference);
  32. free( reference);
  33. return TRUE;
  34. }
  35.  
  36.  
  37.  
  38.  
  39. void    Shell_WaitPrintf( const char *fmt, ...)
  40.     /* You can call this anytime, even inside a redraw function.    */
  41. {    va_list args;
  42.     char    *text;
  43.  
  44. va_start( args, fmt);
  45. vsprintf( Shell_string, fmt, args);
  46. va_end( args);
  47.  
  48. text = Shell_SafeMalloc( 1 + strlen( Shell_string));
  49. strcpy( text, Shell_string);
  50.  
  51. Event_Claim( event_NULL, event_ANY, event_ANY, Shell_WaitPrintfNullHandler, (void *) text);
  52.     /* Shell_WaitPrintfNullHandler will Event_Release itself when it is called and then     */
  53.     /* free the malloc-ed memoy 'text', so the data gets printed just once.            */
  54.     /* Isn't Event_* wonderful ?                                */
  55. }
  56.  
  57.  
  58.  
  59.