Hi developers, I attach patches for lyxserver.h/C for the 1.0.x CVS tree. They have identical functionality as those for 1.1.x I submitted some days ago, but do not use STL constructs. Acutally, there is a hard coded limit to 10 simultaneous clients. LyX will not crash if this is reached, only issue a warning message. Additional clients can still issue commands but LyX will not remember their names nor send a "bye" message to them upon quitting. If included, this patch will allow the LyX::Client perl class to work with 1.0.x releases. Client developers will thus have a stable LyX to talk to. All the best, Stefano Stefano Ghirlanda, Zoologiska Institutionen, Stockholms Universitet Office: D554, Arrheniusv. 14, S-106 91 Stockholm, Sweden Phone: +46 8 164055, Fax: +46 8 167715, Email: [EMAIL PROTECTED] Support Free Science, look at: http://rerumnatura.zool.su.se
Index: lyx-1_0_x//src/lyxserver.C =================================================================== RCS file: /usr/local/lyxsrc/cvsroot/lyx-1_0_x/src/lyxserver.C,v retrieving revision 1.5 diff -r1.5 lyxserver.C 393c393,399 < if (clients > 0) pipes.send("LYXSRV:*:bye"); --- > // modified june 1999 by [EMAIL PROTECTED] to send as many bye > // messages as there are clients, each with client's name. > LString message; > for (int i=0; i<numclients; i++) { > message = "LYXSRV:" + clients[i] + ":bye\n"; > pipes.send(message); > } 454c460,467 < serv->clients++; --- > if(serv->numclients==10){ //paranoid check > lyxerr.debug("LyXServer: too many clients...", >Error::LYXSERVER); > return; > } > int i=0; //find place in clients[] > while (serv->clients[i] != "" && i<serv->numclients) >i++; > serv->clients[i] = client; > serv->numclients++; 461,462c474,481 < serv->clients--; < lyxerr.debug("LyXServer: Client " + client + " said goodbye", --- > int i; //look if client is registered > for (i=0; i<serv->numclients; i++) { > if (serv->clients[i] == client) break; > } > if (i<serv->numclients) { > serv->numclients--; > serv->clients[i] = ""; > lyxerr.debug("LyXServer: Client " + client + " >said goodbye", 463a483,486 > } else { > lyxerr.debug("LyXServer: ignoring bye messge >from unregistered client" + > client + "\n", Error::LYXSERVER); > } 488,501c511,527 < if(!rval.empty()) { < if (action<0 || serv->func->errorStat()) < buf = "ERROR:"; < else < buf = "INFO:"; < buf += LString(client) + ":" + cmd < + ":" + rval + "\n"; < serv->pipes.send(buf); < // !!! we don't do any error checking - < // if the client won't listen, the < // message is lost and others too < // maybe; so the client should empty < // the outpipe before issuing a request. < } --- > //modified june 1999 [EMAIL PROTECTED]: > //all commands produce an INFO or ERROR message > //in the output pipe, even if they do not return > //anything. See chapter 4 of Customization doc. > if (action<0 || serv->func->errorStat()) > buf = "ERROR:"; > else > buf = "INFO:"; > buf += LString(client) + ":" + cmd + ":" + rval + "\n"; > serv->pipes.send(buf); > > // !!! we don't do any error checking - > // if the client won't listen, the > // message is lost and others too > // maybe; so the client should empty > // the outpipe before issuing a request. > Index: lyx-1_0_x//src/lyxserver.h =================================================================== RCS file: /usr/local/lyxsrc/cvsroot/lyx-1_0_x/src/lyxserver.h,v retrieving revision 1.2 diff -r1.2 lyxserver.h 101c101 < : clients(0), func(f), pipes(pip, (this), callback) --- > : numclients(0), func(f), pipes(pip, (this), callback) 110,111c110,112 < /// Number of current clients < int clients; --- > /// Names and number of current clients > LString clients[10]; > int numclients;