mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-19 01:51:09 +00:00
* Modules/Debuggers/ProjectCenter/PTYView.[mh]: Changes to use
new openpty replacement code on systems which don't have openpty, otherwise use the built-in version. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@27493 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
90c55771fd
commit
6a062ed252
3 changed files with 20 additions and 76 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2009-01-01 19:40-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Modules/Debuggers/ProjectCenter/PTYView.[mh]: Changes to use
|
||||||
|
new openpty replacement code on systems which don't have
|
||||||
|
openpty, otherwise use the built-in version.
|
||||||
|
|
||||||
2009-01-01 17:41-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
2009-01-01 17:41-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Modules/Debuggers/ProjectCenter/Resources/Info.table: Add blank
|
* Modules/Debuggers/ProjectCenter/Resources/Info.table: Add blank
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
@interface PTYView : NSTextView
|
@interface PTYView : NSTextView
|
||||||
{
|
{
|
||||||
char pty_name[12]; /* "/dev/[pt]tyXY" = 10 chars + null byte */
|
|
||||||
NSTask *task;
|
NSTask *task;
|
||||||
NSFileHandle *master_handle;
|
NSFileHandle *master_handle;
|
||||||
NSFileHandle *slave_handle;
|
NSFileHandle *slave_handle;
|
||||||
|
@ -33,9 +32,7 @@
|
||||||
int master_fd, slave_fd;
|
int master_fd, slave_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)master;
|
- (int)openpty;
|
||||||
|
|
||||||
- (int)slave: (int)master;
|
|
||||||
|
|
||||||
- (void)logString:(NSString *)str
|
- (void)logString:(NSString *)str
|
||||||
newLine:(BOOL)newLine;
|
newLine:(BOOL)newLine;
|
||||||
|
|
|
@ -39,7 +39,17 @@
|
||||||
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]
|
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
/* check for solaris */
|
||||||
|
#if defined (__SVR4) && defined (__sun)
|
||||||
|
#define __SOLARIS__ 1
|
||||||
|
#define USE_FORKPTY_REPLACEMENT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !(defined (__NetBSD__)) && !(defined (__SOLARIS__))
|
||||||
|
# include <pty.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_FORKPTY_REPLACEMENT
|
||||||
int openpty(int *amaster, int *aslave, char *name, const struct termios *termp, const struct winsize *winp)
|
int openpty(int *amaster, int *aslave, char *name, const struct termios *termp, const struct winsize *winp)
|
||||||
{
|
{
|
||||||
int fdm, fds;
|
int fdm, fds;
|
||||||
|
@ -113,84 +123,16 @@ int openpty(int *amaster, int *aslave, char *name, const struct termios *termp,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@implementation PTYView
|
@implementation PTYView
|
||||||
/**
|
|
||||||
* Instantiate this view.
|
|
||||||
*/
|
|
||||||
- (id) initWithCoder: (NSCoder *)coder
|
|
||||||
{
|
|
||||||
self = [super initWithCoder: coder];
|
|
||||||
if(self != nil)
|
|
||||||
{
|
|
||||||
// initialize the pty name field.
|
|
||||||
strcpy(pty_name, "/dev/ptyXY");
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates master device.
|
* Creates master device.
|
||||||
*/
|
*/
|
||||||
- (int) master
|
- (int) openpty
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
struct stat buff;
|
|
||||||
static char hex[] = "0123456789abcdef";
|
|
||||||
static char pty[] = "pqrs";
|
|
||||||
int i, fd;
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
for (p = pty; *p != 0; p++)
|
|
||||||
{
|
|
||||||
pty_name[8] = *p;
|
|
||||||
pty_name[9] = '0';
|
|
||||||
|
|
||||||
if (stat(pty_name, &buff) < 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
pty_name[9] = hex[i];
|
|
||||||
if ((fd = open(pty_name, O_RDWR)) >= 0)
|
|
||||||
{
|
|
||||||
return(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(-1);
|
|
||||||
#else
|
|
||||||
char *ptyname = NULL;
|
|
||||||
int fd = 0;
|
|
||||||
int sl = 0;
|
|
||||||
if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) == -1)
|
if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) == -1)
|
||||||
{
|
{
|
||||||
NSLog(@"Call to openpty(...) failed.");
|
NSLog(@"Call to openpty(...) failed.");
|
||||||
}
|
}
|
||||||
return master_fd;
|
return master_fd;
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Open the slave half of a pseudo-terminal.
|
|
||||||
*/
|
|
||||||
- (int) slave:(int)master_fd
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
// change to t, for slave tty.
|
|
||||||
pty_name[5] = 't';
|
|
||||||
if ((fd = open(pty_name, O_RDWR)) < 0)
|
|
||||||
{
|
|
||||||
close(master_fd);
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
return(fd);
|
|
||||||
#else
|
|
||||||
return slave_fd;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -329,10 +271,9 @@ int openpty(int *amaster, int *aslave, char *name, const struct termios *termp,
|
||||||
[task setCurrentDirectoryPath: directory];
|
[task setCurrentDirectoryPath: directory];
|
||||||
[task setLaunchPath: path];
|
[task setLaunchPath: path];
|
||||||
|
|
||||||
master_fd = [self master];
|
master_fd = [self openpty];
|
||||||
if(master_fd > 0)
|
if(master_fd > 0)
|
||||||
{
|
{
|
||||||
slave_fd = [self slave: master_fd];
|
|
||||||
if(slave_fd > 0)
|
if(slave_fd > 0)
|
||||||
{
|
{
|
||||||
slave_handle = [[NSFileHandle alloc] initWithFileDescriptor: slave_fd];
|
slave_handle = [[NSFileHandle alloc] initWithFileDescriptor: slave_fd];
|
||||||
|
|
Loading…
Reference in a new issue