Switch to unified view

a/src/utils/netcon.h b/src/utils/netcon.h
...
...
14
 *   You should have received a copy of the GNU General Public License
14
 *   You should have received a copy of the GNU General Public License
15
 *   along with this program; if not, write to the
15
 *   along with this program; if not, write to the
16
 *   Free Software Foundation, Inc.,
16
 *   Free Software Foundation, Inc.,
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
 */
18
 */
19
#include "autoconfig.h"
20
19
#include <sys/time.h>
21
#include <sys/time.h>
20
#include <map>
22
#include <map>
21
#include <string>
23
#include <string>
22
24
23
#include "refcntr.h"
25
#include MEMORY_INCLUDE
24
26
25
/// A set of classes to manage client-server communication over a
27
/// A set of classes to manage client-server communication over a
26
/// connection-oriented network, or a pipe.
28
/// connection-oriented network, or a pipe.
27
///
29
///
28
/// The listening/connection-accepting code currently only uses
30
/// The listening/connection-accepting code currently only uses
...
...
35
/// timeout-protected/asynchronous io using a given fd (ie a pipe
37
/// timeout-protected/asynchronous io using a given fd (ie a pipe
36
/// descriptor)
38
/// descriptor)
37
39
38
/// Base class for all network endpoints:
40
/// Base class for all network endpoints:
39
class Netcon;
41
class Netcon;
40
typedef RefCntr<Netcon> NetconP;
42
typedef STD_SHARED_PTR<Netcon> NetconP;
41
class SelectLoop;
43
class SelectLoop;
42
44
43
class Netcon {
45
class Netcon {
44
public:
46
public:
45
    enum Event {NETCONPOLL_READ = 0x1, NETCONPOLL_WRITE=0x2};
47
    enum Event {NETCONPOLL_READ = 0x1, NETCONPOLL_WRITE=0x2};
...
...
238
    /// Read a line of text on an ascii connection. Returns -1 or byte count
240
    /// Read a line of text on an ascii connection. Returns -1 or byte count
239
    /// including final 0. \n is kept
241
    /// including final 0. \n is kept
240
    virtual int getline(char *buf, int cnt, int timeo = -1);
242
    virtual int getline(char *buf, int cnt, int timeo = -1);
241
    /// Set handler to be called when the connection is placed in the
243
    /// Set handler to be called when the connection is placed in the
242
    /// selectloop and an event occurs.
244
    /// selectloop and an event occurs.
243
    virtual void setcallback(RefCntr<NetconWorker> user) {
245
    virtual void setcallback(STD_SHARED_PTR<NetconWorker> user) {
244
        m_user = user;
246
        m_user = user;
245
    }
247
    }
246
248
247
private:
249
private:
248
    char *m_buf;    // Buffer. Only used when doing getline()s
250
    char *m_buf;    // Buffer. Only used when doing getline()s
249
    char *m_bufbase;    // Pointer to current 1st byte of useful data
251
    char *m_bufbase;    // Pointer to current 1st byte of useful data
250
    int m_bufbytes; // Bytes of data.
252
    int m_bufbytes; // Bytes of data.
251
    int m_bufsize;  // Total buffer size
253
    int m_bufsize;  // Total buffer size
252
    RefCntr<NetconWorker> m_user;
254
    STD_SHARED_PTR<NetconWorker> m_user;
253
    virtual int cando(Netcon::Event reason); // Selectloop slot
255
    virtual int cando(Netcon::Event reason); // Selectloop slot
254
};
256
};
255
257
256
/// Network endpoint, client side.
258
/// Network endpoint, client side.
257
class NetconCli : public NetconData {   
259
class NetconCli : public NetconData {