WvStreams
|
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * Copyright (C) 1999 Red Hat, Inc. 00006 * 00007 * Definition of the WvModemBase and WvModem classes. Inherit from WvFile, 00008 * but do various important details related to modems, like setting baud 00009 * rates and dropping DTR and the like. 00010 * 00011 */ 00012 00013 #ifndef __WVMODEM_H 00014 #define __WVMODEM_H 00015 00016 #include "wvlockdev.h" 00017 #include "wvfile.h" 00018 #include "wvlog.h" 00019 #include <termios.h> 00020 00021 #ifndef IUCLC 00022 #define IUCLC 0 00023 #endif 00024 00025 #ifndef OLCUC 00026 #define OLCUC 0 00027 #endif 00028 00029 #ifndef XCASE 00030 #define XCASE 0 00031 #endif 00032 00039 class WvModemBase : public WvFile 00040 { 00041 protected: 00042 struct termios t; 00043 int baud; 00044 00045 WvModemBase() { } 00046 00047 int get_real_speed(); 00048 00049 public: 00050 bool die_fast; 00051 00052 WvModemBase(int _fd); 00053 virtual ~WvModemBase(); 00054 00056 virtual void close(); 00057 00059 virtual bool carrier(); 00060 00062 virtual int speed(int _baud); 00063 00065 int getspeed() 00066 { return baud; } 00067 00069 virtual void hangup(); 00070 00071 public: 00072 const char *wstype() const { return "WvModemBase"; } 00073 }; 00074 00075 00080 class WvModem : public WvModemBase 00081 { 00082 private: 00083 WvLockDev lock; 00084 WvLog log; 00085 bool have_old_t; 00086 struct termios old_t; 00087 bool closing; 00088 bool no_reset; 00089 00094 void setup_modem(bool rtscts); 00095 00097 int getstatus(); 00098 00099 public: 00100 WvModem(WvStringParm filename, int _baud, bool rtscts = true, 00101 bool _no_reset = false); 00102 virtual ~WvModem(); 00103 00105 virtual void close(); 00106 00108 virtual bool carrier(); 00109 00114 virtual int speed(int _baud); 00115 00116 public: 00117 const char *wstype() const { return "WvModem"; } 00118 }; 00119 00120 #endif