#include <config.h>
-//#include <cstring>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
extern LyXAction lyxaction;
-// C wrapper
-extern "C" void C_LyXComm_callback(int fd, void *v);
+
+extern "C" {
+
+ // C wrapper
+ static
+ void C_LyXComm_callback(int fd, void *v)
+ {
+ LyXComm::callback(fd, v);
+ }
+
+}
// LyXComm class
-
- // Open pipes
-void LyXComm::openConnection() {
+
+// Open pipes
+void LyXComm::openConnection()
+{
lyxerr[Debug::LYXSERVER] << "LyXComm: Opening connection" << endl;
// If we are up, that's an error
// The current emx implementation of access() won't work with pipes.
rc = DosCreateNPipe(tmp.c_str(), &fd, NP_ACCESS_INBOUND,
NP_NOWAIT|0x01, 0600, 0600, 0);
- if (rc == ERROR_PIPE_BUSY) {
+ if (rc == ERROR_PIPE_BUSY)
#else
- if (::access(tmp.c_str(), F_OK) == 0) {
+ if (::access(tmp.c_str(), F_OK) == 0)
#endif
+ {
lyxerr << "LyXComm: Pipe " << tmp << " already exists.\n"
<< "If no other LyX program is active, please delete"
" the pipe by hand and try again." << endl;
tmp = pipename + ".out";
#ifndef __EMX__
- if (::access(tmp.c_str(), F_OK) == 0) {
+ if (::access(tmp.c_str(), F_OK) == 0)
#else
rc = DosCreateNPipe(tmp.c_str(), &fd, NP_ACCESS_DUPLEX,
NP_NOWAIT|0x01, 0600, 0600, 0);
- if (rc == ERROR_PIPE_BUSY) {
+ if (rc == ERROR_PIPE_BUSY)
#endif
+ {
lyxerr << "LyXComm: Pipe " << tmp << " already exists.\n"
<< "If no other LyX program is active, please delete"
" the pipe by hand and try again." << endl;
lyxerr << "LyXComm: Could not set flags on pipe " << tmp
<< '\n' << strerror(errno) << endl;
return;
- };
+ }
// We made it!
ready = true;
lyxerr[Debug::LYXSERVER] << "LyXComm: Connection established" << endl;
}
-
+
+
/// Close pipes
-void LyXComm::closeConnection() {
+void LyXComm::closeConnection()
+{
#ifdef __EMX__
APIRET rc;
int errnum;
}
ready = false;
}
-
+
+
// Receives messages and sends then to client
void LyXComm::callback(int fd, void *v)
{
errno= 0;
}
-extern "C" void C_LyXComm_callback(int fd, void *v)
-{
- LyXComm::callback(fd, v);
-}
-
-void LyXComm::send(string const & msg) {
+void LyXComm::send(string const & msg)
+{
if (msg.empty()) {
lyxerr << "LyXComm: Request to send empty string. Ignoring."
<< endl;