home *** CD-ROM | disk | FTP | other *** search
- //************************************************************************
- //
- // GateTool.m.
- //
- // by Felipe A. Rodriguez
- //
- //
- // This code is supplied "as is" the author makes no warranty as to its
- // suitability for any purpose. This code is free and may be distributed
- // in accordance with the terms of the:
- //
- // GNU GENERAL PUBLIC LICENSE
- // Version 2, June 1991
- // copyright (C) 1989, 1991 Free Software Foundation, Inc.
- // 675 Mass Ave, Cambridge, MA 02139, USA
- //
- //************************************************************************
-
- #import "GateTool.h"
- #import <appkit/nextstd.h>
- #import <dpsclient/dpsNeXT.h>
- #import <stdio.h>
- #import <sys/types.h>
- #import <sys/ioctl.h>
- #import <bsd/unistd.h>
-
- extern void strToScript(const char *buffer);
- extern void sendScriptToModem(char *buffer);
- extern void unlockPort();
-
- extern int alarmArmed; // alarm is armed or disarmed
-
-
- @implementation GateTool
-
- //************************************************************************
- //
- // write a str to the serial port
- //
- //************************************************************************
-
- - writePty:(char *)buffer
- {
- static char minBuffer[2] = {"b"};
-
- if(*buffer == CINTR)
- ualarm(1000, 0); // turn on alarm
- while(*buffer)
- {
- minBuffer[0] = *buffer++; //send one chr at a time
- if(write(ptyMaster, minBuffer, 1) != 1) // Write to Master Pty
- perror("Error writing to Master Pty from GateThread");
- }
-
- return self;
- }
- //************************************************************************
- //
- // send a str to extern func strtoScript
- //
- //************************************************************************
-
- - (void)enScript:(const char *)buffer
- {
- strToScript(buffer);
- sendScriptToModem("\r");
- }
- //************************************************************************
- //
- // set port fd
- //
- //************************************************************************
-
- - setPty:(int)pty
- {
- ptyMaster = pty;
-
- return self;
- }
- //************************************************************************
- //
- // unlock the serial port
- //
- //************************************************************************
-
- - unlockSerialPort
- {
- unlockPort();
-
- return self;
- }
-
- @end
-
-