- // --- prepare input pipe ---------------------------------------
-
- string tmp = pipename + ".in";
-
-#ifdef __EMX__
- HPIPE fd;
- APIRET rc;
- int errnum;
- // Try create one instance of named pipe with the mode O_RDONLY|O_NONBLOCK.
- // 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) {
-#else
- 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;
- pipename.clear();
- return;
- }
-#ifndef __EMX__
- if (mkfifo(tmp.c_str(), 0600) < 0) {
- lyxerr << "LyXComm: Could not create pipe " << tmp << '\n'
- << strerror(errno) << endl;
- return;
- };
- infd = open(tmp.c_str(), O_RDONLY|O_NONBLOCK);
-#else
- if (rc != NO_ERROR) {
- errnum = TranslateOS2Error(rc);
- lyxerr <<"LyXComm: Could not create pipe " << tmp
- << strerror(errnum) << endl;
- return;
- };
- // Listen to it.
- rc = DosConnectNPipe(fd);
- if (rc != NO_ERROR && rc != ERROR_PIPE_NOT_CONNECTED) {
- errnum = TranslateOS2Error(rc);
- lyxerr <<"LyXComm: Could not create pipe " << tmp
- << strerror(errnum) << endl;
- return;
- };
- // Imported handles can be used both with OS/2 APIs and emx
- // library functions.
- infd = _imphandle(fd);
-#endif
- if (infd < 0) {
- lyxerr << "LyXComm: Could not open pipe " << tmp << '\n'
- << strerror(errno) << endl;
- return;
- }
- fl_add_io_callback(infd, FL_READ, C_LyXComm_callback, (void*)this);
-
- // --- prepare output pipe ---------------------------------------
-
- tmp = pipename + ".out";
-
-#ifndef __EMX__
- 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) {
-#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;
- pipename.clear();
- return;
- }
-#ifndef __EMX__
- if (mkfifo(tmp.c_str(), 0600) < 0) {
- lyxerr << "LyXComm: Could not create pipe " << tmp << '\n'
- << strerror(errno) << endl;
- return;
- };
- if (access(tmp.c_str(), F_OK) != 0) {
- lyxerr << "LyXComm: Pipe " << tmp
- << " does not exist" << endl;
- return;
- }
- outfd = open(tmp.c_str(), O_RDWR);
-#else
- if (rc != NO_ERROR) {
- errnum = TranslateOS2Error(rc);
- lyxerr << "LyXComm: Could not create pipe " << tmp << '\n'
- << strerror(errnum) << endl;
- return;
- }
- rc = DosConnectNPipe(fd);
- if (rc == ERROR_BAD_PIPE) {
- lyxerr << "LyXComm: Pipe " << tmp
- << " does not exist" << endl;