~ubuntu-branches/ubuntu/saucy/zeromq3/saucy

« back to all changes in this revision

Viewing changes to src/ipc_address.cpp

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2012-06-04 21:21:09 UTC
  • Revision ID: package-import@ubuntu.com-20120604212109-b7b3m0rn21o8oo2q
Tags: upstream-3.1.0~beta+dfsg
ImportĀ upstreamĀ versionĀ 3.1.0~beta+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2011 250bpm s.r.o.
 
3
    Copyright (c) 2011 Other contributors as noted in the AUTHORS file
 
4
 
 
5
    This file is part of 0MQ.
 
6
 
 
7
    0MQ is free software; you can redistribute it and/or modify it under
 
8
    the terms of the GNU Lesser General Public License as published by
 
9
    the Free Software Foundation; either version 3 of the License, or
 
10
    (at your option) any later version.
 
11
 
 
12
    0MQ is distributed in the hope that it will be useful,
 
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
    GNU Lesser General Public License for more details.
 
16
 
 
17
    You should have received a copy of the GNU Lesser General Public License
 
18
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*/
 
20
 
 
21
#include "ipc_address.hpp"
 
22
 
 
23
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
 
24
 
 
25
#include "err.hpp"
 
26
 
 
27
#include <string.h>
 
28
 
 
29
zmq::ipc_address_t::ipc_address_t ()
 
30
{
 
31
    memset (&address, 0, sizeof (address));
 
32
}
 
33
 
 
34
zmq::ipc_address_t::~ipc_address_t ()
 
35
{
 
36
}
 
37
 
 
38
int zmq::ipc_address_t::resolve (const char *path_)
 
39
{
 
40
    if (strlen (path_) >= sizeof (address.sun_path)) {
 
41
        errno = ENAMETOOLONG;
 
42
        return -1;
 
43
    }
 
44
 
 
45
    address.sun_family = AF_UNIX;
 
46
    strcpy (address.sun_path, path_);
 
47
    return 0;
 
48
}
 
49
 
 
50
sockaddr *zmq::ipc_address_t::addr ()
 
51
{
 
52
    return (sockaddr*) &address;
 
53
}
 
54
 
 
55
socklen_t zmq::ipc_address_t::addrlen ()
 
56
{
 
57
    return (socklen_t) sizeof (address);
 
58
}
 
59
 
 
60
#endif