~ubuntu-branches/ubuntu/wily/zeromq3/wily-proposed

« back to all changes in this revision

Viewing changes to src/ipc_address.cpp

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2014-03-16 14:02:28 UTC
  • mfrom: (1.1.6) (6.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140316140228-ig1sgh7czk59m9ux
Tags: 4.0.4+dfsg-1
* QA upload; orphan the package
  - Upload to unstable
* New upstream release
* Update repack.stub script
* Drop 02_fix-exported-symbols.patch and 03_fix-s390-rdtsc.patch
  (merged upstream)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
    Copyright (c) 2011 250bpm s.r.o.
3
 
    Copyright (c) 2011 Other contributors as noted in the AUTHORS file
 
2
    Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
4
3
 
5
4
    This file is part of 0MQ.
6
5
 
52
51
        errno = ENAMETOOLONG;
53
52
        return -1;
54
53
    }
 
54
#if defined ZMQ_HAVE_LINUX
 
55
    if (path_[0] == '@' && !path_[1]) {
 
56
            errno = EINVAL;
 
57
            return -1;
 
58
    }
 
59
#endif
55
60
 
56
61
    address.sun_family = AF_UNIX;
57
62
    strcpy (address.sun_path, path_);
 
63
#if defined ZMQ_HAVE_LINUX
 
64
    /* Abstract sockets on Linux start with '\0' */
 
65
    if (path_[0] == '@')
 
66
        *address.sun_path = '\0';
 
67
#endif
58
68
    return 0;
59
69
}
60
70
 
66
76
    }
67
77
 
68
78
    std::stringstream s;
 
79
#if !defined ZMQ_HAVE_LINUX
69
80
    s << "ipc://" << address.sun_path;
 
81
#else
 
82
    s << "ipc://";
 
83
    if (!address.sun_path[0] && address.sun_path[1])
 
84
       s << "@" << address.sun_path + 1;
 
85
    else
 
86
       s << address.sun_path;
 
87
#endif
70
88
    addr_ = s.str ();
71
89
    return 0;
72
90
}
78
96
 
79
97
socklen_t zmq::ipc_address_t::addrlen () const
80
98
{
 
99
#if defined ZMQ_HAVE_LINUX
 
100
    if (!address.sun_path[0] && address.sun_path[1])
 
101
        return (socklen_t) strlen(address.sun_path + 1) + sizeof (sa_family_t) + 1;
 
102
#endif
81
103
    return (socklen_t) sizeof (address);
82
104
}
83
105