X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Fsocktools.cpp;h=d4aab38f5fec0306766a8cca0394d48e5eb114e2;hb=59e4d16ab9611732dbc208f23d3de4b9da321dce;hp=b6c6e5ac07824ccb2b6eede373dc5737bdf557da;hpb=0e40512c861cf69088d422de7bc159cddbde5c64;p=lyx.git diff --git a/src/support/socktools.cpp b/src/support/socktools.cpp index b6c6e5ac07..d4aab38f5f 100644 --- a/src/support/socktools.cpp +++ b/src/support/socktools.cpp @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author João Luis M. Assirati + * \author João Luis M. Assirati * * Full author contact details are available in file CREDITS. */ @@ -37,10 +37,11 @@ int accept(int) #else // defined (HAVE_FCNTL) -#include "support/lyxlib.h" - -#include "debug.h" +#include "support/debug.h" +#ifdef HAVE_SYS_TYPES_H +# include +#endif #include #include #include @@ -49,12 +50,12 @@ int accept(int) #endif #include +#include +//needed for Mac OSX 10.5.2 Leopard +#include -using std::string; +using namespace std; -#ifndef CXX_GLOBAL_CSTD -using std::strerror; -#endif // This MACRO eppears to be defined only on Linux. #if !defined(SUN_LEN) @@ -81,7 +82,7 @@ int listen(FileName const & name, int queue) string::size_type len = localname.size(); // the field sun_path in sockaddr_un is a char[108] if (len > 107) { - LYXERR(Debug::ANY, "lyx: Socket address '" << name.absFilename() << "' too long."); + LYXERR0("lyx: Socket address '" << name.absFileName() << "' too long."); return -1; } // Synonims for AF_UNIX are AF_LOCAL and AF_FILE @@ -94,14 +95,14 @@ int listen(FileName const & name, int queue) // For local sockets, the protocol is always 0 // socket() returns -1 in case of error if ((fd = ::socket(PF_UNIX, SOCK_STREAM, 0))== -1) { - LYXERR(Debug::ANY, "lyx: Could not create socket descriptor: " + LYXERR0("lyx: Could not create socket descriptor: " << strerror(errno)); return -1; } // Set NONBLOCK mode for the file descriptor if (::fcntl(fd, F_SETFL, O_NONBLOCK) == -1) { - LYXERR(Debug::ANY, "lyx: Could not set NONBLOCK mode for socket descriptor: " + LYXERR0("lyx: Could not set NONBLOCK mode for socket descriptor: " << strerror(errno)); ::close(fd); return -1; @@ -111,10 +112,10 @@ int listen(FileName const & name, int queue) // the socket special file in the filesystem. bind() returns -1 // in case of error if ((::bind (fd, reinterpret_cast(&addr), SUN_LEN(&addr))) == -1) { - LYXERR(Debug::ANY, "lyx: Could not bind address '" << name.absFilename() + LYXERR0("lyx: Could not bind address '" << name.absFileName() << "' to socket descriptor: " << strerror(errno)); ::close(fd); - unlink(name); + name.removeFile(); return -1; } @@ -124,10 +125,10 @@ int listen(FileName const & name, int queue) // It is not a restriction on the number of connections the socket // can accept. Returns -1 in case of error if (::listen (fd, queue) == -1) { - LYXERR(Debug::ANY, "lyx: Could not put socket in 'listen' state: " + LYXERR0("lyx: Could not put socket in 'listen' state: " << strerror(errno)); ::close(fd); - unlink(name); + name.removeFile(); return -1; } @@ -144,14 +145,14 @@ int accept(int sd) // Using null pointers for the second and third arguments // dismiss all information about the connecting client if ((fd = accept(sd, reinterpret_cast(0), reinterpret_cast(0))) == -1) { - LYXERR(Debug::ANY, "lyx: Could not accept connection: " + LYXERR0("lyx: Could not accept connection: " << strerror(errno)); return -1; } // Sets NONBLOCK mode for the file descriptor if (::fcntl(fd, F_SETFL, O_NONBLOCK) == -1) { - LYXERR(Debug::ANY, "lyx: Could not set NONBLOCK mode for connection: " + LYXERR0("lyx: Could not set NONBLOCK mode for connection: " << strerror(errno)); ::close(fd); return -1;