mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
make lyxclient work with LYXSOCKET
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8039 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ee252d8fe4
commit
7871470eb0
@ -1,3 +1,9 @@
|
|||||||
|
|
||||||
|
2003-11-05 João Luis M. Assirati <assirati@fma.if.usp.br>
|
||||||
|
|
||||||
|
* lyxsocket/lyxclient.C: makes lyxclient work with LYXSOCKET
|
||||||
|
environment variable.
|
||||||
|
|
||||||
2003-09-11 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
2003-09-11 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||||
|
|
||||||
* MacOSX/lyx.xpm: remove. Not needed after all...
|
* MacOSX/lyx.xpm: remove. Not needed after all...
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
// getpid(), getppid()
|
// getpid(), getppid()
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -35,6 +34,8 @@
|
|||||||
// fcntl()
|
// fcntl()
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
// getenv()
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@ -75,8 +76,7 @@ bool prefixIs(string const & a, string const & pre)
|
|||||||
|
|
||||||
|
|
||||||
// Parts stolen from lyx::support::DirList()
|
// Parts stolen from lyx::support::DirList()
|
||||||
// Returns pathnames begining with dir and ending with
|
// Returns the absolute pathnames of all lyx local sockets
|
||||||
// pathname separator (/ in unix)
|
|
||||||
vector<string> lyxSockets(string const & dir, string const & pid)
|
vector<string> lyxSockets(string const & dir, string const & pid)
|
||||||
{
|
{
|
||||||
vector<string> dirlist;
|
vector<string> dirlist;
|
||||||
@ -94,6 +94,7 @@ vector<string> lyxSockets(string const & dir, string const & pid)
|
|||||||
string lyxsocket = dir + '/' + fil + "/lyxsocket";
|
string lyxsocket = dir + '/' + fil + "/lyxsocket";
|
||||||
struct stat status;
|
struct stat status;
|
||||||
// not checking if it is a socket -- just if it exists
|
// not checking if it is a socket -- just if it exists
|
||||||
|
// and has reading permissions
|
||||||
if (!::stat(lyxsocket.c_str(), &status)) {
|
if (!::stat(lyxsocket.c_str(), &status)) {
|
||||||
dirlist.push_back(lyxsocket);
|
dirlist.push_back(lyxsocket);
|
||||||
}
|
}
|
||||||
@ -124,7 +125,7 @@ int connect(string const & name)
|
|||||||
addr.sun_path[len] = '\0';
|
addr.sun_path[len] = '\0';
|
||||||
|
|
||||||
if((fd = ::socket(PF_UNIX, SOCK_STREAM, 0))== -1) {
|
if((fd = ::socket(PF_UNIX, SOCK_STREAM, 0))== -1) {
|
||||||
cerr << "lyxclient: Could not create socket: "
|
cerr << "lyxclient: Could not create socket descriptor: "
|
||||||
<< strerror(errno) << endl;
|
<< strerror(errno) << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -415,7 +416,8 @@ int g(vector<char *> const & arg)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * serverAddress;
|
// 0 if LYXSOCKET is not set in the environment
|
||||||
|
char * serverAddress = getenv("LYXSOCKET");
|
||||||
int a(vector<char *> const & arg)
|
int a(vector<char *> const & arg)
|
||||||
{
|
{
|
||||||
if(arg.size() < 1) {
|
if(arg.size() < 1) {
|
||||||
@ -423,6 +425,7 @@ int a(vector<char *> const & arg)
|
|||||||
<< endl;
|
<< endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
// -a supercedes LYXSOCKET environment variable
|
||||||
serverAddress = arg[0];
|
serverAddress = arg[0];
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -457,25 +460,25 @@ using support::prefixIs;
|
|||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
CmdLineParser parser;
|
CmdLineParser args;
|
||||||
parser.helper["-h"] = cmdline::h;
|
args.helper["-h"] = cmdline::h;
|
||||||
parser.helper["-c"] = cmdline::c;
|
args.helper["-c"] = cmdline::c;
|
||||||
parser.helper["-g"] = cmdline::g;
|
args.helper["-g"] = cmdline::g;
|
||||||
parser.helper["-n"] = cmdline::n;
|
args.helper["-n"] = cmdline::n;
|
||||||
parser.helper["-a"] = cmdline::a;
|
args.helper["-a"] = cmdline::a;
|
||||||
parser.helper["-t"] = cmdline::t;
|
args.helper["-t"] = cmdline::t;
|
||||||
parser.helper["-p"] = cmdline::p;
|
args.helper["-p"] = cmdline::p;
|
||||||
// Command line failure conditions:
|
// Command line failure conditions:
|
||||||
if((!parser.parse(argc, argv))
|
if((!args.parse(argc, argv))
|
||||||
|| (parser.isset["-c"] && parser.isset["-g"])
|
|| (args.isset["-c"] && args.isset["-g"])
|
||||||
|| (parser.isset["-a"] && parser.isset["-p"])) {
|
|| (args.isset["-a"] && args.isset["-p"])) {
|
||||||
cmdline::usage();
|
cmdline::usage();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LyXDataSocket * server;
|
LyXDataSocket * server;
|
||||||
|
|
||||||
if(parser.isset["-a"]) {
|
if(cmdline::serverAddress) {
|
||||||
server = new LyXDataSocket(cmdline::serverAddress);
|
server = new LyXDataSocket(cmdline::serverAddress);
|
||||||
if(!server->connected()) {
|
if(!server->connected()) {
|
||||||
cerr << "lyxclient: " << "Could not connect to "
|
cerr << "lyxclient: " << "Could not connect to "
|
||||||
@ -526,7 +529,7 @@ int main(int argc, char * argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(parser.isset["-g"] || parser.isset["-c"]) {
|
if(args.isset["-g"] || args.isset["-c"]) {
|
||||||
server->writeln(cmdline::singleCommand);
|
server->writeln(cmdline::singleCommand);
|
||||||
iowatch.wait(2.0);
|
iowatch.wait(2.0);
|
||||||
if(iowatch.isset(serverfd) && server->readln(answer)) {
|
if(iowatch.isset(serverfd) && server->readln(answer)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user