Switch to unified view

a/src/netcon.h b/src/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
#ifdef BUILDING_RECOLL
20
#include "autoconfig.h"
21
#else
22
#include "config.h"
23
#endif
24
19
#include <sys/time.h>
25
#include <sys/time.h>
20
21
#include <map>
26
#include <map>
22
#include <memory>
23
#include <string>
27
#include <string>
28
29
#include MEMORY_INCLUDE
24
30
25
/// A set of classes to manage client-server communication over a
31
/// A set of classes to manage client-server communication over a
26
/// connection-oriented network, or a pipe.
32
/// connection-oriented network, or a pipe.
27
///
33
///
28
/// The listening/connection-accepting code currently only uses
34
/// The listening/connection-accepting code currently only uses
...
...
35
/// timeout-protected/asynchronous io using a given fd (ie a pipe
41
/// timeout-protected/asynchronous io using a given fd (ie a pipe
36
/// descriptor)
42
/// descriptor)
37
43
38
/// Base class for all network endpoints:
44
/// Base class for all network endpoints:
39
class Netcon;
45
class Netcon;
40
typedef std::shared_ptr<Netcon> NetconP;
46
typedef STD_SHARED_PTR<Netcon> NetconP;
41
class SelectLoop;
47
class SelectLoop;
42
48
43
class Netcon {
49
class Netcon {
44
public:
50
public:
45
    enum Event {NETCONPOLL_READ = 0x1, NETCONPOLL_WRITE = 0x2};
51
    enum Event {NETCONPOLL_READ = 0x1, NETCONPOLL_WRITE = 0x2};
...
...
238
    /// Read a line of text on an ascii connection. Returns -1 or byte count
244
    /// Read a line of text on an ascii connection. Returns -1 or byte count
239
    /// including final 0. \n is kept
245
    /// including final 0. \n is kept
240
    virtual int getline(char *buf, int cnt, int timeo = -1);
246
    virtual int getline(char *buf, int cnt, int timeo = -1);
241
    /// Set handler to be called when the connection is placed in the
247
    /// Set handler to be called when the connection is placed in the
242
    /// selectloop and an event occurs.
248
    /// selectloop and an event occurs.
243
    virtual void setcallback(std::shared_ptr<NetconWorker> user) {
249
    virtual void setcallback(STD_SHARED_PTR<NetconWorker> user) {
244
        m_user = user;
250
        m_user = user;
245
    }
251
    }
246
252
247
private:
253
private:
248
    char *m_buf;    // Buffer. Only used when doing getline()s
254
    char *m_buf;    // Buffer. Only used when doing getline()s
249
    char *m_bufbase;    // Pointer to current 1st byte of useful data
255
    char *m_bufbase;    // Pointer to current 1st byte of useful data
250
    int m_bufbytes; // Bytes of data.
256
    int m_bufbytes; // Bytes of data.
251
    int m_bufsize;  // Total buffer size
257
    int m_bufsize;  // Total buffer size
252
    std::shared_ptr<NetconWorker> m_user;
258
    STD_SHARED_PTR<NetconWorker> m_user;
253
    virtual int cando(Netcon::Event reason); // Selectloop slot
259
    virtual int cando(Netcon::Event reason); // Selectloop slot
254
};
260
};
255
261
256
/// Network endpoint, client side.
262
/// Network endpoint, client side.
257
class NetconCli : public NetconData {
263
class NetconCli : public NetconData {
...
...
329
    /// connections. It will usually call NetconServLis::accept(), and
335
    /// connections. It will usually call NetconServLis::accept(), and
330
    /// insert the new connection in the selectloop.
336
    /// insert the new connection in the selectloop.
331
    virtual int cando(Netcon::Event reason);
337
    virtual int cando(Netcon::Event reason);
332
338
333
    // Empty if port was numeric, else service name or socket path
339
    // Empty if port was numeric, else service name or socket path
334
    std::string m_serv; 
340
    std::string m_serv;
335
341
336
private:
342
private:
337
#ifdef NETCON_ACCESSCONTROL
343
#ifdef NETCON_ACCESSCONTROL
338
    int permsinit;
344
    int permsinit;
339
    struct intarrayparam okaddrs;
345
    struct intarrayparam okaddrs;