]> code.citadel.org Git - citadel.git/commitdiff
some fixes
authorArt Cancro <ajc@citadel.org>
Mon, 1 Mar 1999 04:33:04 +0000 (04:33 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 1 Mar 1999 04:33:04 +0000 (04:33 +0000)
daphne/citclient.cpp
daphne/citclient.hpp
daphne/tcp_sockets.cpp
daphne/tcp_sockets.hpp

index 98395d87321968d957618123751e2215e10333da..3ad9cfddbda48f85c966d5cdb681d54082b1184f 100644 (file)
 int CitClient::attach(const wxString& host, const wxString& port) {
        wxString ServerReady;
 
-       //if (sock.IsConnected())
-       //      sock.Close();
-       //addr.Hostname(host);
-       //addr.Service(port);
-       //sock.SetNotify(0);
-       //sock.Connect(addr, TRUE);
-       //if (sock.IsConnected()) {
-       //      serv_gets(ServerReady);
-       //      initialize_session();
-       //      return(0);
-       //}
-       //else return(1);
-
        if (sock.is_connected())
                sock.detach();
        if (sock.attach(host, port)==0) {
@@ -40,17 +27,11 @@ int CitClient::attach(const wxString& host, const wxString& port) {
 }
 
 
-
-// constructor
+// constructur
 CitClient::CitClient(void) {
-  //wxSocketHandler::Master();
-  //sock.SetFlags(wxSocketBase::WAITALL);
-  //wxSocketHandler::Master().Register(&sock);
-  //sock.SetNotify(wxSocketBase::REQ_LOST);
 }
 
 
-
 // destructor
 CitClient::~CitClient(void) {
 
@@ -61,11 +42,9 @@ CitClient::~CitClient(void) {
 void CitClient::detach(void) {
        wxString buf;
 
-       //if (sock.IsConnected()) {
        if (sock.is_connected()) {
                serv_puts("QUIT");
                serv_gets(buf);
-               //sock.Close();
                sock.detach();
        }
 }
@@ -73,7 +52,6 @@ void CitClient::detach(void) {
 
 // Is this client connected?  Simply return the IsConnected status of sock.
 bool CitClient::IsConnected(void) {
-       //return sock.IsConnected();
        return sock.is_connected();
 }
 
@@ -85,20 +63,11 @@ void CitClient::serv_gets(wxString& buf) {
        
        sock.serv_gets(charbuf);
        buf = charbuf;
-
-       //buf.Empty();
-       //do {
-       //      while (sock.IsData()==FALSE) ;;
-       //      sock.Read(charbuf, 1);
-       //      if (isprint(charbuf[0])) buf.Append(charbuf[0], 1);
-       //} while(isprint(charbuf[0]));
 }
 
 
 // Write a line of text to the server
 void CitClient::serv_puts(wxString buf) {
-       //sock.Write(buf, strlen(buf));
-       //sock.Write("\n", 1);
        sock.serv_puts(buf);
 }
 
@@ -117,12 +86,15 @@ int CitClient::serv_trans(
 
        int first_digit;
        wxString buf;
+       bool express_messages_waiting = FALSE;
 
        serv_puts(command);
        serv_gets(response);
-       // if (response.Length()==0) serv_gets(response);
        first_digit = (response.GetChar(0)) - '0';
 
+       if (response.GetChar(3) == '*')
+               express_messages_waiting = TRUE;
+
        if (first_digit == 1) {                 // LISTING_FOLLOWS
                xferbuf.Clear();
                while (serv_gets(buf), buf != "000") {
@@ -134,6 +106,9 @@ int CitClient::serv_trans(
        }
 
 
+       if (express_messages_waiting) {
+               // FIX do something here
+       }
 
        return first_digit;
 }
index 5a787fe091fb317a48eb824c5078dbceb6c651bd..732065462074a2924b16c83dc41fb2d9aca0f578 100644 (file)
@@ -36,8 +36,6 @@ public:
 private:
        void serv_gets(wxString& buf);
        void serv_puts(wxString buf);
-       // wxSocketClient sock = (-1);
-       // wxIPV4address addr;
        TCPsocket sock;
        void CitClient::initialize_session(void);
 };
index e91a99fcfd5c691e15c4a6d67e959957a552af8e..41c5d2942e2c4618c3a5f9407c68cb197ff7f161 100644 (file)
@@ -7,9 +7,7 @@
  */
 
 #include <stdlib.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
 #include <stdio.h>
 #include <fcntl.h>
 #include <signal.h>
@@ -38,7 +36,8 @@ void TCPsocket::timeout(int signum) {
        serv_sock = (-1);
 }
 
-int TCPsocket::connectsock(char *host, char *service, char *protocol)
+int TCPsocket::connectsock(const char *host, const char *service,
+                       const char *protocol)
 {
        struct hostent *phe;
        struct servent *pse;
@@ -181,7 +180,6 @@ void TCPsocket::serv_puts(char *string)
 
 
 int TCPsocket::attach(char *host, char *port) {
-       printf("attach() called\n");
        serv_sock = connectsock(host, port, "tcp");
        if (serv_sock >= 0) return 0;
        else return (-1);
@@ -193,7 +191,6 @@ void TCPsocket::detach() {
 }
 
 bool TCPsocket::is_connected(void) {
-       printf("is_connected() called, serv_sock is %d\n", serv_sock);
        if (serv_sock >= 0) return TRUE;
        else return FALSE;
        }
index 95ae97554ff87e94b1121d3dd0435a13b2c834e5..bca0271450a72a1476df28bc3cc507bfcac8a0c0 100644 (file)
@@ -10,7 +10,7 @@ public:
        bool is_connected(void);
 private:
        int serv_sock;
-       int connectsock(char *, char *, char *);
+       int connectsock(const char *, const char *, const char *);
        void timeout(int);
 };