home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / FACETV.ZIP / SCRNMSG.C < prev    next >
C/C++ Source or Header  |  1994-01-03  |  3KB  |  87 lines

  1. /************************************************************************
  2. **
  3. ** @(#)scrnmsg.c    08/11/93    Chris Ahlstrom
  4. **
  5. **    C version
  6. **
  7. **    Tentative interface between Turbo Vision and user functions.
  8. ** This interface will allow the user to write functions without much
  9. ** regard to how Turbo Vision works.
  10. **
  11. **    This routine is callable from a C program that knows nothing
  12. ** about Turbo-Vision, that doesn't even link in to the Turbo Vision
  13. ** libraries.  It is also callable from a C++ program.
  14. **
  15. *************************************************************************
  16. **
  17. **    I tried an experiment, loading two versions of the same
  18. ** function into a library.  The C++ version of screenmsg() should
  19. ** get name-mangled, and hence shouldn't conflict with the C version
  20. ** of screenmsg().  I was able to create a C program that found the
  21. ** regular screenmsg() [under the name _screenmsg].  But, when I created
  22. ** a C++ program, somehow the name-mangled screenmsg() function
  23. ** pre-empted access to the _screenmsg name, and it came up at link-time
  24. ** as an unresolved external.
  25. **
  26. **    This worked only for the Borland compiler, which detects the
  27. ** difference between a *.CPP and *.C file.
  28. **
  29. *************************************************************************
  30. **
  31. *************************************************************************/
  32.  
  33. #define SCRNMSG_c
  34.  
  35. #include <stdio.h>
  36. #include "cnscreen.h"
  37.  
  38.  
  39. /************************************************************************
  40. ** screenmsg()
  41. **
  42. **    This will be the primary interface for writing to the screen.
  43. **
  44. **    If the text is to be displayed (use_io is true), then the output
  45. ** goes to the system console if the handle is NULL.  Otherwise, it is
  46. ** assumed that the handle refered to a TWindowScreen pointer, and
  47. ** the string goes to that window.
  48. **
  49. **     Defined as a macro in screnmsg.h.
  50. **
  51. *************************************************************************/
  52.  
  53.  
  54. /************************************************************************
  55. ** cnScreenmsg()
  56. **
  57. **    C version of screenmsg() function.
  58. **
  59. *************************************************************************/
  60.  
  61. int
  62. cnScreenmsg
  63. (
  64.     int use_io,                // whether to ignore output
  65.     void *handle,            // bogus for now
  66.     char *string            // string to display
  67. )
  68. {
  69.     int err = 0;
  70.  
  71.     if (use_io)                // use the I/O
  72.     {
  73.     if (handle != (void *) 0)    // use console I/O
  74.     {
  75.         printf
  76.         (
  77.         "%%Programmer error: "
  78.         "Can't handle anything but console I/O here\n"
  79.         );
  80.         err = 1;            // return error code
  81.     }
  82.     printf("%s", string);
  83.     }
  84.     return err;
  85. }
  86.  
  87.