]> git.lyx.org Git - lyx.git/blobdiff - src/lyxserver.C
frontends fixes from Juergen S
[lyx.git] / src / lyxserver.C
index 3e16f061389964d1d8574028a98af5e0d31460f3..64d0c156221b9686a1629b37552e5ae789ce85ff 100644 (file)
@@ -62,7 +62,7 @@
 #define INCL_DOSNMPIPES
 #define INCL_DOSERRORS
 #include <os2.h>
-#include "os2_errortable.h"
+#include "support/os2_errortable.h"
 #endif
 
 using std::endl;
@@ -108,7 +108,12 @@ void LyXComm::openConnection()
        // We assume that we don't make it
        ready = false;
  
-       if (pipename.empty()) return;
+       if (pipename.empty()) {
+               lyxerr[Debug::LYXSERVER]
+                       << "LyXComm: server is disabled, nothing to do"
+                       << endl;
+               return;
+       }
 
        if ((infd = startPipe(inPipeName(), false)) == -1)
                return;
@@ -136,6 +141,9 @@ void LyXComm::closeConnection()
                lyxerr[Debug::LYXSERVER] << "LyXComm: Closing connection" << endl;
 
        if (pipename.empty()) {
+               lyxerr[Debug::LYXSERVER]
+                       << "LyXComm: server is disabled, nothing to do"
+                       << endl;
                return;
        }
 
@@ -243,7 +251,7 @@ void LyXComm::endPipe(int & fd, string const & filename)
  
 // OS/2 pipes are deleted automatically
 #ifndef __EMX__
-       if (lyx::unlink(filename) < 0){
+       if (lyx::unlink(filename) < 0) {
                lyxerr << "LyXComm: Could not remove pipe " << filename
                       << '\n' << strerror(errno) << endl;
        };
@@ -255,8 +263,10 @@ void LyXComm::endPipe(int & fd, string const & filename)
 
 void LyXComm::emergencyCleanup()
 {
-       endPipe(infd, inPipeName());
-       endPipe(outfd, outPipeName());
+       if (!pipename.empty()) {
+               endPipe(infd, inPipeName());
+               endPipe(outfd, outPipeName());
+       }
 }
 
 
@@ -278,14 +288,14 @@ void LyXComm::callback(int fd, void *v)
        errno = 0;
        int status;
        // the single = is intended here.
-       while((status = read(fd, charbuf, CMDBUFLEN-1)))
+       while ((status = read(fd, charbuf, CMDBUFLEN-1)))
        {// break and return in loop
                if (status > 0) // got something
                {
                        charbuf[status]= '\0'; // turn it into a c string
                        lsbuf += strip(charbuf, '\r');
                        // commit any commands read
-                       while(lsbuf.find('\n') != string::npos) // while still
+                       while (lsbuf.find('\n') != string::npos) // while still
                                                        // commands
                                                        // left 
                        {
@@ -308,7 +318,7 @@ void LyXComm::callback(int fd, void *v)
                        errno = 0;
                        return; // up to libforms select-loop (*crunch*)
                }
-               if (errno != 0 )
+               if (errno != 0)
                {
                        lyxerr << "LyXComm: " << strerror(errno) << endl;
                        if (!lsbuf.empty())
@@ -396,7 +406,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
        //  Format: LYXCMD:<client>:<func>:<argstring>\n
        //
        bool server_only = false;
-       while(*p) {
+       while (*p) {
                // --- 1. check 'header' ---
 
                if (compare(p, "LYXSRV:", 7) == 0) {
@@ -409,20 +419,20 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
                
                // --- 2. for the moment ignore the client name ---
                string client;
-               while(*p && *p != ':')
+               while (*p && *p != ':')
                        client += char(*p++);
                if (*p == ':') ++p;
                if (!*p) return;
                
                // --- 3. get function name ---
                string cmd;
-               while(*p && *p != ':')
+               while (*p && *p != ':')
                        cmd += char(*p++);
                
                // --- 4. parse the argument ---
                string arg;
                if (!server_only && *p == ':' && *(++p)) {
-                       while(*p && *p != '\n')
+                       while (*p && *p != '\n')
                                arg += char(*p++);
                        if (*p) ++p;
                }
@@ -440,7 +450,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
                        // we are listening.
                        if (cmd == "hello") {
                                // One more client
-                               if (serv->numclients == MAX_CLIENTS){ //paranoid check
+                               if (serv->numclients == MAX_CLIENTS) { //paranoid check
                                        lyxerr[Debug::LYXSERVER]
                                                << "LyXServer: too many clients..."
                                                << endl;
@@ -491,7 +501,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
                        // connect to the lyxfunc in the single LyXView we
                        // support currently. (Lgb)
 
-                       int action = lyxaction.LookupFunc(cmd);
+                       kb_action action = static_cast<kb_action>(lyxaction.LookupFunc(cmd));
                        //int action = -1;
                        string rval, buf;