1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#define _XOPEN_SOURCE
#include <features.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include "putty.h"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
int pty_master_fd;
static void pty_size(void);
static void c_write(char *buf, int len)
{
from_backend(0, buf, len);
}
/*
* Called to set up the pty.
*
* Returns an error message, or NULL on success.
*
* Also places the canonical host name into `realhost'. It must be
* freed by the caller.
|
>
>
>
<
<
<
<
<
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#define _XOPEN_SOURCE
#define _XOPEN_SOURCE_EXTENDED
#include <features.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <sys/ioctl.h>
#include "putty.h"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
int pty_master_fd;
static void pty_size(void);
/*
* Called to set up the pty.
*
* Returns an error message, or NULL on success.
*
* Also places the canonical host name into `realhost'. It must be
* freed by the caller.
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
name[FILENAME_MAX-1] = '\0';
strncpy(name, ptsname(pty_master_fd), FILENAME_MAX-1);
slavefd = open(name, O_RDWR);
if (slavefd < 0) {
perror("slave pty: open");
return 1;
}
/*
* Fork and execute the command.
*/
pid = fork();
if (pid < 0) {
perror("fork");
return 1;
}
if (pid == 0) {
int i;
/*
* We are the child.
*/
|
|
|
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
name[FILENAME_MAX-1] = '\0';
strncpy(name, ptsname(pty_master_fd), FILENAME_MAX-1);
slavefd = open(name, O_RDWR);
if (slavefd < 0) {
perror("slave pty: open");
exit(1);
}
/*
* Fork and execute the command.
*/
pid = fork();
if (pid < 0) {
perror("fork");
exit(1);
}
if (pid == 0) {
int i;
/*
* We are the child.
*/
|
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
}
/*
* Called to set the size of the window
*/
static void pty_size(void)
{
/* FIXME: will need to do TIOCSWINSZ or whatever. */
return;
}
/*
* Send special codes.
*/
static void pty_special(Telnet_Special code)
|
>
|
>
>
>
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
}
/*
* Called to set the size of the window
*/
static void pty_size(void)
{
struct winsize size;
size.ws_row = (unsigned short)rows;
size.ws_col = (unsigned short)cols;
ioctl(pty_master_fd, TIOCSWINSZ, (void *)&size);
return;
}
/*
* Send special codes.
*/
static void pty_special(Telnet_Special code)
|