home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / spxdos.exe / EDIT.C < prev    next >
Text File  |  1995-01-27  |  4KB  |  158 lines

  1. /****************************************************************************
  2. **    File:    EDIT.C
  3. **
  4. **    Desc:    Sample SPX chat program.    
  5. **
  6. **        This Sample code demonstrates how to set up and use SPX
  7. **        communications to communicate between 2 nodes.
  8. **        
  9. **        
  10. **        
  11. **
  12. **        DISCLAIMER  
  13. **  
  14. **    Novell, Inc. makes no representations or warranties with respect to
  15. **    any NetWare software, and specifically disclaims any express or
  16. **    implied warranties of merchantability, title, or fitness for a
  17. **    particular purpose.  
  18. **
  19. **    Distribution of any NetWare software is forbidden without the
  20. **    express written consent of Novell, Inc.  Further, Novell reserves
  21. **    the right to discontinue distribution of any NetWare software.
  22. **    
  23. **    Novell is not responsible for lost profits or revenue, loss of use
  24. **    of the software, loss of data, costs of re-creating lost data, the
  25. **    cost of any substitute equipment or program, or claims by any party
  26. **    other than you.  Novell strongly recommends a backup be made before
  27. **    any software is installed.   Technical support for this software
  28. **    may be provided at the discretion of Novell.
  29. **
  30. **    Programmers:
  31. **
  32. **        Ini    Who                        Firm
  33. **        -----------------------------------------------------------------------
  34. **        TDOC  Technical Documentation Team
  35. **        KLB    Karl Bunnell                Novell Developer Support.
  36. **
  37. **    History:
  38. **
  39. **        When        Who    What
  40. **        -----------------------------------------------------------------------
  41. **        10-25-88    TDOC    First code.
  42. **        01-27-95 KLB   Ported this example to the NetWare Client SDK
  43. */
  44.  
  45. /****************************************************************************
  46. **    Include headers, macros, function prototypes, etc.
  47. */
  48.     /*------------------------------------------------------------------------
  49.     **    MACROS
  50.     */
  51.     #define NWDOS
  52.  
  53.  
  54.     /*------------------------------------------------------------------------
  55.     **    ANSI
  56.     */
  57.     #include <stdio.h>
  58.     #include <dos.h>
  59.  
  60.  
  61.     /*------------------------------------------------------------------------
  62.     **    NetWare
  63.     */
  64.     #include <nwcalls.h>
  65.     #include <nwipxspx.h>
  66.     #include "chat.h"
  67.  
  68.  
  69.     /*------------------------------------------------------------------------
  70.     **    Globals
  71.     */
  72.  
  73.  
  74.     void     Dispatcher();
  75.     void     DisplayChar();
  76.     int         InputChar();
  77.     void     DeleteChar();
  78.     void     DisplayOff();
  79.  
  80.     extern int    PRINT_FLAG,
  81.                 RECEIVE_FLAG;
  82.  
  83.     char    charBuffer;
  84.  
  85.     int     sendRow = TOP_SEND_ROW,
  86.             sendCol = FIRST_TEXT_COL,
  87.             receiveRow = TOP_RECEIVE_ROW,
  88.             receiveCol = FIRST_TEXT_COL;
  89.  
  90.  
  91. void Dispatcher(key)
  92. char    key;
  93. {
  94.     int        ccode;
  95.  
  96.     if (key == TAB)
  97.         ClearSendBox();
  98.     
  99.     else if (key == ENTER)
  100.     {
  101.         sendRow++;
  102.         if (sendRow > LAST_SEND_ROW) 
  103.         {
  104.             sendRow = LAST_SEND_ROW;
  105.             ScrollUp (1, TOP_SEND_ROW, LAST_SEND_ROW, FIRST_TEXT_COL, LAST_TEXT_COL);
  106.         }
  107.         sendCol = FIRST_TEXT_COL;
  108.         SetCursor(sendRow,sendCol);
  109.     }
  110.     
  111.     else if (key == BACKSPACE)
  112.     {
  113.         if (sendCol > FIRST_TEXT_COL)
  114.             DeleteChar (&sendCol, &sendRow);
  115.     }
  116.     
  117.     else if ( key == 0 || (key > 6 && key < 20) )
  118.     {
  119.         key = 2;
  120.         DisplayChar(key);
  121.     }
  122.     else
  123.         DisplayChar(key);
  124.     
  125.     SendPacket(&key);
  126. }                        
  127.  
  128.  
  129. void DisplayChar(key)
  130. char    key;
  131. {
  132.     if(sendCol == LAST_TEXT_COL)
  133.     {
  134.         sendCol = FIRST_TEXT_COL;
  135.         sendRow++;
  136.         if (sendRow > LAST_SEND_ROW) 
  137.         {
  138.             sendRow = LAST_SEND_ROW;
  139.             ScrollUp (1, TOP_SEND_ROW, LAST_SEND_ROW, FIRST_TEXT_COL, LAST_TEXT_COL);
  140.         }
  141.     }
  142.     SetCursor(sendRow,sendCol++);
  143.     WriteChar(key);
  144.     SetCursor(sendRow,sendCol);
  145. }
  146.  
  147.  
  148. void DeleteChar(col,row)
  149. int        *col, *row;
  150. {
  151.     --*col;
  152.     SetCursor(*row, *col);
  153.     WriteChar(' ');
  154.     SetCursor(*row, *col);
  155. }
  156.  
  157.  
  158.