home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / g / gs / !GS / ps / Source / WimpPlus / h / wimpc next >
Encoding:
Text File  |  1991-11-21  |  2.3 KB  |  66 lines

  1. #ifndef __wimpc_h
  2. #define __wimpc_h
  3.  
  4. /* wimpc.h */
  5.  
  6. /* Copyright (C) David Elworthy 1991. No warranty is given on this code. */
  7.  
  8. /*
  9.    1.0  --  April 1991  --  First working version
  10.    2.0  --  July 1991   --  Force creation parameter added to initialise
  11.  
  12.  * This file provides functions for adapting command line c programs to
  13.  * use the wimp.
  14.  * This means intercepting printf amd fread, providing an event handler,
  15.  * and generally getting things going.
  16.  * As explained in wimpio.h, scanf can't be intercepted which is a pain in the bum.
  17.  *
  18.  * Much of the work is automatic, e.g. you need not call printf_select. The things
  19.  * you have to call are:
  20.  * wimpc_init
  21.  *
  22.  */
  23.  
  24. #include <stdio.h>
  25.  
  26. /* Select how output to stdout and stderr appears. Default is to a window for
  27.    both.
  28. */
  29. extern void printf_select(int w_stdout, /* 1 for window, 0 for real stdout */
  30.                    int w_stderr  /* 1 for window, 0 for real, -1 for werr */);
  31.  
  32. /* Do all the initialisation you need to set up the wimp.
  33.    taskname is used for the task display. resources is used for application
  34.    files: we look in resources$dir.
  35.    The two flags allow you to initialise heap and/or flex
  36.    The create flag, forces creation of the print and read windows,
  37.    which are otherwise created when they are needed. It is intended when you want to
  38.    fiddle with the windows, e.g. by changing the event handler. You can create the
  39.    windows without showing them. See wimpio.h for suitable values.
  40. */
  41.  
  42. extern void wimpc_init(char *taskname, char *resources, int init_heap, int init_flex, int create);
  43.  
  44. /* Checkpoint. Calling this allows event handlers and other tasks to get a look in.
  45.    If there are any active windows, it will process one event. This will not cause the
  46.    program to close down, even if there are no active windows.
  47.  */
  48. extern void wimpc_checkpoint(void);
  49.  
  50. /* Fake input - transfer to the stdio buffer */
  51. extern void w_fake_input(char *string, int len);
  52.  
  53.  
  54. /* C library functions */
  55. #define printf  w_printf
  56. #define fprintf w_fprintf
  57. #define fread   w_fread
  58. #define fwrite  w_fwrite
  59.  
  60. extern int w_fprintf(FILE *stream, const char *format, ...);
  61. extern int w_printf(const char *format, ...);
  62. extern size_t w_fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
  63. extern size_t w_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
  64.  
  65. #endif
  66.