5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the
17 // Free Software Foundation, Inc.,
18 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 \brief UNAddressing non-inline non-template implementation */
23 #include "UNAddressing.hh"
24 //#include "UNAddressing.ih"
28 #include <boost/operators.hpp>
29 #include <boost/filesystem/path.hpp>
30 #include "../../../Utils/SafeBool.hh"
31 //#include "UNAddressing.mpp"
33 ///////////////////////////////cc.p////////////////////////////////////////
34 prefix_ senf::UNSocketAddress::UNSocketAddress(boost::filesystem::path p)
36 chdir(p.branch_path().string().c_str());
37 //Check if the unix domain socket already exists...
38 if(!remove(p.leaf().c_str()))
39 printf("File already existed and therefore was deleted!\n");
41 printf("File not found, will be created.\n");
44 sockAddr.sun_family = AF_UNIX;
45 strcpy(sockAddr.sun_path, p.string().c_str());
48 prefix_ senf::UNSocketAddress fromString(std::string s)
50 return senf::UNSocketAddress::UNSocketAddress(boost::filesystem::path(s));
53 prefix_ senf::UNSocketAddress fromPath(boost::filesystem::path p)
55 return senf::UNSocketAddress::UNSocketAddress(p);
57 prefix_ std::string senf::UNSocketAddress::path()
59 return std::string(sockAddr.sun_path);
62 prefix_ sockaddr_un senf::UNSocketAddress::sockaddr()
64 struct sockaddr_un out;
65 out.sun_family = sockAddr.sun_family;
66 strcpy(out.sun_path, sockAddr.sun_path);
70 prefix_ sockaddr * senf::UNSocketAddress::sockaddr_p()
72 return reinterpret_cast <struct sockaddr *> (&sockAddr);
76 prefix_ sockaddr const * senf::UNSocketAddress::sockaddr_p()
79 return reinterpret_cast <struct sockaddr const *> (&sockAddr);
82 prefix_ unsigned senf::UNSocketAddress::sockaddr_len()
85 return sizeof(sockAddr);
88 prefix_ std::ostream & operator<<(std::ostream & os, senf::UNSocketAddress::UNSocketAddress const & addr){
94 ///////////////////////////////cc.e////////////////////////////////////////
96 //#include "UNAddressing.mpp"
102 // comment-column: 40
103 // c-file-style: "senf"
104 // indent-tabs-mode: nil
105 // ispell-local-dictionary: "american"
106 // compile-command: "scons -u test"