Cleaned up some of the comments ... removed vestiges of last year's doxygen experiment
[citadel.git] / webcit / tcp_sockets.c
index 4b0e51c1f38a2303a60c82217c5ba41bb5380f58..d7a43f414006e84a4e1d4dcf6681ec35a84ac2bf 100644 (file)
@@ -1,23 +1,19 @@
 /*
  * $Id$
  */
-/** 
- * \defgroup TcpSockets TCP client socket module for WebCit
- * \ingroup CitadelCommunitacion
- */
-/*@{*/
 
 /*
  * Uncomment this to log all communications with the Citadel server
 #define SERV_TRACE 1
  */
 
+
 #include "webcit.h"
 #include "webserver.h"
 
-/**
- * \brief register the timeout
- * \param signum signalhandler number
+/*
+ *  register the timeout
+ *  signum signalhandler number
  * \return signals
  */
 RETSIGTYPE timeout(int signum)
@@ -27,9 +23,9 @@ RETSIGTYPE timeout(int signum)
 }
 
 
-/**
- * \brief Connect a unix domain socket
- * \param sockpath where to open a unix domain socket
+/*
+ *  Connect a unix domain socket
+ *  sockpath where to open a unix domain socket
  */
 int uds_connectsock(char *sockpath)
 {
@@ -58,10 +54,10 @@ int uds_connectsock(char *sockpath)
 }
 
 
-/**
- * \brief Connect a TCP/IP socket
- * \param host the host to connect to
- * \param service the service on the host to call
+/*
+ *  Connect a TCP/IP socket
+ *  host the host to connect to
+ *  service the service on the host to call
  */
 int tcp_connectsock(char *host, char *service)
 {
@@ -118,10 +114,10 @@ int tcp_connectsock(char *host, char *service)
 
 
 
-/**
- * \brief Input binary data from socket
- * \param buf the buffer to get the input to
- * \param bytes the maximal number of bytes to read
+/*
+ *  Input binary data from socket
+ *  buf the buffer to get the input to
+ *  bytes the maximal number of bytes to read
  */
 inline void _serv_read(char *buf, int bytes, struct wcsession *WCC)
 {
@@ -151,8 +147,8 @@ void serv_read(char *buf, int bytes)
        _serv_read(buf, bytes, WCC);
 }
 
-/**
- * \brief input string from pipe
+/*
+ *  input string from pipe
  */
 int serv_getln(char *strbuf, int bufsize)
 {
@@ -176,14 +172,48 @@ int serv_getln(char *strbuf, int bufsize)
        return len;
 }
 
+int StrBuf_ServGetln(StrBuf *buf)
+{
+       const char *ErrStr;
+       int rc;
+
+       rc = StrBufTCP_read_line(buf, &WC->serv_sock, 0, &ErrStr);
+       if (rc < 0)
+       {
+               lprintf(1, "Server connection broken: %s\n",
+                       ErrStr);
+               wc_backtrace();
+               WC->serv_sock = (-1);
+               WC->connected = 0;
+               WC->logged_in = 0;
+       }
+       return rc;
+}
 
+int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize)
+{
+       const char *Err;
+       int rc;
+       
+       rc = StrBufReadBLOB(buf, &WC->serv_sock, 1, BlobSize, &Err);
+       if (rc < 0)
+       {
+               lprintf(1, "Server connection broken: %s\n",
+                       Err);
+               wc_backtrace();
+               WC->serv_sock = (-1);
+               WC->connected = 0;
+               WC->logged_in = 0;
+       }
+       return rc;
+}
 
-/**
- * \brief send binary to server
- * \param buf the buffer to write to citadel server
- * \param nbytes how many bytes to send to citadel server
+/*
+ *  send binary to server
+ *  buf the buffer to write to citadel server
+ *  nbytes how many bytes to send to citadel server
  */
-void serv_write(char *buf, int nbytes)
+void serv_write(const char *buf, int nbytes)
 {
        int bytes_written = 0;
        int retval;
@@ -204,11 +234,11 @@ void serv_write(char *buf, int nbytes)
 }
 
 
-/**
- * \brief send line to server
- * \param string the line to send to the citadel server
+/*
+ *  send line to server
+ *  string the line to send to the citadel server
  */
-void serv_puts(char *string)
+void serv_puts(const char *string)
 {
 #ifdef SERV_TRACE
        lprintf(9, "%3d<%s\n", WC->serv_sock, string);
@@ -217,11 +247,24 @@ void serv_puts(char *string)
        serv_write("\n", 1);
 }
 
+/*
+ *  send line to server
+ *  string the line to send to the citadel server
+ */
+void serv_putbuf(const StrBuf *string)
+{
+#ifdef SERV_TRACE
+       lprintf(9, "%3d<%s\n", WC->serv_sock, ChrPtr(string));
+#endif
+       serv_write(ChrPtr(string), StrLength(string));
+       serv_write("\n", 1);
+}
+
 
-/**
- * \brief convenience function to send stuff to the server
- * \param format the formatstring
- * \param ... the entities to insert into format 
+/*
+ *  convenience function to send stuff to the server
+ *  format the formatstring
+ *  ... the entities to insert into format 
  */
 void serv_printf(const char *format,...)
 {
@@ -242,5 +285,3 @@ void serv_printf(const char *format,...)
 #endif
 }
 
-
-/*@}*/