aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/clef/Makefile.in2
-rw-r--r--src/clef/edible.c3
-rw-r--r--src/include/openpty.H13
-rw-r--r--src/lib/openpty.c66
-rw-r--r--src/sman/Makefile.in6
-rw-r--r--src/sman/sman.c4
7 files changed, 39 insertions, 56 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c3a50351..d0b3f19d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2008-11-01 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * sman/sman.c (ptsPath): Remove.
+ * sman/Makefile.in: Add additional C runtimes for link.
+ * lib/openpty.c: Include <pty.h> and <util.h> where available.
+ (ptyopen): Lose third parameter. Tidy.
+ (makeNextPtyNames): Now static.
+ * clef/edible.c (controllerPath): Remove.
+ Adjust call to ptyopen.
+ * clef/Makefile.in (clef_LDADD): Add extra C runtimes.
+
2008-10-31 Gabriel Dos Reis <gdr@cs.tamu.edu>
* boot/ast.boot (genECLnativeTranslation): Fix thinko.
diff --git a/src/clef/Makefile.in b/src/clef/Makefile.in
index 42a233e4..764df763 100644
--- a/src/clef/Makefile.in
+++ b/src/clef/Makefile.in
@@ -41,7 +41,7 @@ clef_objects = $(clef_SOURCES:.c=.lo)
build_libdir = $(top_builddir)/src/lib
-clef_LDADD = -L$(build_libdir) -lspad -lopen-axiom-core
+clef_LDADD = -L$(build_libdir) -lspad -lopen-axiom-core $(oa_c_runtime_extra)
clef_DEPENDENCIES =
diff --git a/src/clef/edible.c b/src/clef/edible.c
index 069ff8f7..0e7b9756 100644
--- a/src/clef/edible.c
+++ b/src/clef/edible.c
@@ -101,7 +101,6 @@ int buff_flag[MAXLINE]; /** flags for whether buff chars
or non-printing **/
-char controllerPath[20]; /* path name for opening the controller side */
char serverPath[20]; /* path name for opening the server side */
int contNum, serverNum; /* file descriptors for pty's */
@@ -130,7 +129,7 @@ main(int argc, char *argv[])
/* try to get a pseudoterminal to play with */
- if (ptyopen(&contNum, &serverNum, controllerPath, serverPath) == -1) {
+ if (ptyopen(&contNum, &serverNum, serverPath) == -1) {
perror("ptyopen failed");
exit(-1);
}
diff --git a/src/include/openpty.H1 b/src/include/openpty.H1
index dc46a190..95f9192b 100644
--- a/src/include/openpty.H1
+++ b/src/include/openpty.H1
@@ -1,2 +1 @@
-extern void makeNextPtyNames(char * , char * );
-extern int ptyopen(int * , int * , char * , char * );
+extern int ptyopen(int*, int*, char*);
diff --git a/src/lib/openpty.c b/src/lib/openpty.c
index 94f76735..eee46d04 100644
--- a/src/lib/openpty.c
+++ b/src/lib/openpty.c
@@ -38,8 +38,17 @@
#include <fcntl.h>
#include <string.h>
+#ifdef HAVE_PTY_H
+# include <pty.h>
+#endif
+#ifdef HAVE_UTIL_H
+# include <util.h>
+#endif
+
#include "openpty.H1"
+static void makeNextPtyNames(char * , char * );
+
/*
* The main function is ptyopen. It simply opens up both sides of a
@@ -52,8 +61,6 @@
* ptyopen(controller, server, controllerPath, serverPath)
* int *controller; The file descriptor for controller side of the pty
* int *server; The file descriptor for the server side
- * char *controllerPath; actually , this is not used anywhere on return
- and can be taken out of the call sequence
* char *serverPath;
*
* The path name vars should be declared of size 11 or more
@@ -61,11 +68,15 @@
int
-ptyopen(int *controller,int * server, char *controllerPath,char * serverPath)
+ptyopen(int *controller,int * server,char * serverPath)
{
-#if defined(SUNplatform) || defined (HP9platform) || defined(RTplatform) ||defined(AIX370platform) || defined(BSDplatform)
+#if HAVE_DECL_OPENPTY
+ return openpty(controller,server, serverPath, NULL, NULL);
+#else
+#if defined(SUNplatform)
int looking = 1, i;
int oflag = O_RDWR; /* flag for opening the pty */
+ char controllerPath[128];
for (i = 0; looking && i < 1000; i++) {
makeNextPtyNames(controllerPath, serverPath);
@@ -85,28 +96,7 @@ ptyopen(int *controller,int * server, char *controllerPath,char * serverPath)
}
return (*controller);
#endif
-#if defined RIOSplatform
- int fdm,fds;
- char *slavename;
-
- /* open master */
- if ((fdm=open("/dev/ptc",O_RDWR))<0)
- perror("ptyopen failed to open /dev/ptc");
- else {
- /* get slave name */
- if((slavename = ttyname(fdm))==0)
- perror("ptyopen failed to get the slave device name");
- /* open slave */
- if ((fds = open(slavename, O_RDWR)) < 0 )
- perror("ptyopen: Failed to open slave");
- strcpy(serverPath,slavename);
- *controller=fdm;
- *server=fds;
- }
- return(fdm);
-#endif
-
-#if defined(SUN4OS5platform) ||defined(ALPHAplatform) || defined(HP10platform) || defined(LINUXplatform) || defined(MACOSXplatform) || defined(BSDplatform)
+#if defined(SUN4OS5platform)
extern int grantpt(int);
extern int unlockpt(int);
extern char* ptsname(int);
@@ -130,7 +120,7 @@ extern char* ptsname(int);
if ((fds = open(slavename, O_RDWR)) < 0 )
perror("ptyopen: Failed to open slave");
else {
-#if defined(SUN4OS5platform) || defined(HP10platform)
+#if defined(SUN4OS5platform)
/* push ptem */
if (ioctl(fds, I_PUSH, "ptem") < 0)
perror("ptyopen: Failed to push ptem");
@@ -145,32 +135,16 @@ extern char* ptsname(int);
}
return(fdm);
#endif
-#if defined SGIplatform
- char *fds;
- fds = _getpty(controller, O_RDWR|O_NDELAY, 0600, 0);
- strcpy(serverPath,fds);
- if (0 == serverPath)
- return(-1);
- if (0 > (*server = open(serverPath,O_RDWR))) {
- (void) close(*controller);
- return(-1);
- }
- return (*controller);
+# error "don't know open to open a pty"
#endif
}
-void
+static void
makeNextPtyNames(char *cont,char * serv)
{
-#ifdef AIX370platform
- static int channelNo = 0;
- sprintf(cont, "/dev/ptyp%02x", channelNo);
- sprintf(serv, "/dev/ttyp%02x", channelNo);
- channelNo++;
-#endif
-#if defined(SUNplatform) || defined(HP9platform) || defined(LINUXplatform) || defined(MACOSXplatform) || defined(BSDplatform)
+#if defined(SUNplatform)
static int channelNo = 0;
static char group[] = "pqrstuvwxyzPQRST";
static int groupNo = 0;
diff --git a/src/sman/Makefile.in b/src/sman/Makefile.in
index 53bb15c3..e87ff546 100644
--- a/src/sman/Makefile.in
+++ b/src/sman/Makefile.in
@@ -49,19 +49,19 @@ libspad_la = $(build_libdir)/libspad.$(LIBEXT)
session_SOURCES = session.c
session_objects = $(session_SOURCES:.c=.lo)
-session_LDADD = $(libspad_la) @axiom_c_runtime_extra@ \
+session_LDADD = $(libspad_la) $(oa_c_runtime_extra) \
-L$(build_libdir) -lopen-axiom-core
session_DEPENDENCIES =
spadclient_SOURCES = spadclient.c
spadclient_objects = $(spadclient_SOURCES:.c=.lo)
-spadclient_LDADD = $(libspad_la) @axiom_c_runtime_extra@ \
+spadclient_LDADD = $(libspad_la) $(oa_c_runtime_extra) \
-L$(build_libdir) -lopen-axiom-core
spadclient_DEPENDENCIES =
sman_SOURCES = sman.c
sman_objects = $(sman_SOURCES:.c=.lo) $(top_builddir)/src/driver/utils.lo
-sman_LDADD = $(libspad_la) @axiom_c_runtime_extra@ \
+sman_LDADD = $(libspad_la) $(oa_c_runtime_extra) \
-L$(build_libdir) -lopen-axiom-core
sman_DEPENDENCIES =
diff --git a/src/sman/sman.c b/src/sman/sman.c
index 8fa71a67..4488948a 100644
--- a/src/sman/sman.c
+++ b/src/sman/sman.c
@@ -137,7 +137,7 @@ unsigned char _INTR, _QUIT, _ERASE, _KILL, _EOF, _EOL, _RES1, _RES2;
/*************************************/
int ptsNum, ptcNum;
-char ptsPath[20], ptcPath[20];
+char ptsPath[20];
char **new_envp; /* new environment for the core executable */
int child_pid; /* child's process id */
@@ -556,7 +556,7 @@ start_the_Axiom(char **envp)
fprintf(stderr, "could not get an OpenAxiom server number\n");
exit(-1);
}
- if (ptyopen(&ptcNum, &ptsNum, ptcPath, ptsPath) == -1) {
+ if (ptyopen(&ptcNum, &ptsNum, ptsPath) == -1) {
perror("start_the_Axiom: ptyopen failed");
exit(-1);
}