home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Connectivity / GateKeeper-2.1 / MODEM.tproj / GateTool.m < prev    next >
Encoding:
Text File  |  1997-01-26  |  2.2 KB  |  95 lines

  1. //************************************************************************
  2. //
  3. //    GateTool.m.  
  4. //
  5. //    by    Felipe A. Rodriguez        
  6. //
  7. //
  8. //    This code is supplied "as is" the author makes no warranty as to its 
  9. //    suitability for any purpose.  This code is free and may be distributed 
  10. //    in accordance with the terms of the:
  11. //        
  12. //            GNU GENERAL PUBLIC LICENSE
  13. //            Version 2, June 1991
  14. //            copyright (C) 1989, 1991 Free Software Foundation, Inc.
  15. //             675 Mass Ave, Cambridge, MA 02139, USA
  16. //
  17. //************************************************************************
  18.  
  19. #import "GateTool.h"
  20. #import <appkit/nextstd.h>
  21. #import <dpsclient/dpsNeXT.h>
  22. #import <stdio.h>
  23. #import <sys/types.h>
  24. #import <sys/ioctl.h>
  25. #import <bsd/unistd.h>
  26.  
  27. extern void strToScript(const char *buffer);
  28. extern void sendScriptToModem(char *buffer);
  29. extern void unlockPort();
  30.  
  31.     extern int alarmArmed;        // alarm is armed or disarmed
  32.  
  33.  
  34. @implementation GateTool
  35.  
  36. //************************************************************************
  37. //
  38. //         write a str to the serial port 
  39. //
  40. //************************************************************************
  41.  
  42. - writePty:(char *)buffer
  43. {
  44. static char minBuffer[2] = {"b"};
  45.  
  46.     if(*buffer == CINTR)
  47.         ualarm(1000, 0);                            // turn on alarm
  48.     while(*buffer)
  49.         {
  50.         minBuffer[0] = *buffer++;                    //send one chr at a time
  51.         if(write(ptyMaster, minBuffer, 1) != 1)        // Write to Master Pty
  52.             perror("Error writing to Master Pty from GateThread");                        
  53.         }
  54.  
  55.     return self;
  56. }
  57. //************************************************************************
  58. //
  59. //         send a str to extern func strtoScript 
  60. //
  61. //************************************************************************
  62.  
  63. - (void)enScript:(const char *)buffer
  64. {
  65.     strToScript(buffer);
  66.     sendScriptToModem("\r");
  67. }
  68. //************************************************************************
  69. //
  70. //         set port fd  
  71. //
  72. //************************************************************************
  73.  
  74. - setPty:(int)pty
  75. {
  76.     ptyMaster = pty;
  77.     
  78.     return self;
  79. }
  80. //************************************************************************
  81. //
  82. //         unlock the serial port 
  83. //
  84. //************************************************************************
  85.  
  86. - unlockSerialPort
  87. {
  88.     unlockPort();
  89.     
  90.     return self;
  91. }
  92.  
  93. @end
  94.  
  95.