Пример #1
0
void main()
{
	int fd;
	char buf[10];
	memset(buf, 0, sizeof(buf));
	if ((fd = OpenTTY("/dev/tty1a")) == -1) return;/* ´ò¿ª´®¿Ú1 */
	InputSe(fd);									/* ·¢²¼¡±ÊäÈëÃÜÂë¡°ÃüÁî */
	ReadFromSe(fd, buf, 6);							/* ¶ÁÈ¡ÃÜÂë¼üÅÌÊäÈë */
	fprintf(stderr, "input [%s]\n", buf);			/* ÏÔʾÊäÈëÊý¾Ý */
	CloseSe(fd);									/* ¹Ø±ÕÃÜÂë¼üÅÌ */;
	CloseTTY(fd);									/* ¹Ø±Õ´®¿ÚÉ豸 */
}
Пример #2
0
void main()
{
	int fd;
	char buf[10];
	memset(buf, 0, sizeof(buf));
	if ((fd = OpenTTY(ttyname(0))) == -1) return;	/* ���ն��豸 */
	write(fd,"\x1b[2h",4);		/* ���������*/
	write(fd,"\x1b[>",3);		/* ѡ�񸨴���1*/
	InputSe(fd);			/* �������������롰���� */
	ReadFromSe(fd, buf, 6);		/* ��ȡ����������� */
	write(fd,"\x1b[<",3);		/* �رո�����1*/
	write(fd,"\x1b[2l",4);		/* ���������*/
	fprintf(stderr, "input [%s]\n", buf);	/* ��ʾ�������� */
	CloseSe(fd);			/* �ر�������� */;
	CloseTTY(fd);			/* �ر��ն��豸 */
}
Пример #3
0
int GrabPseudoTTY(int *pty, int *tty)
{
char c1,c2;
char *Buffer=NULL;

//first try unix98 style
*pty=open("/dev/ptmx",O_RDWR);
if (*pty > -1)
{
	grantpt(*pty);
	unlockpt(*pty);
	if ( (*tty=open((char *) ptsname(*pty),O_RDWR)) >-1)
	{
		InitTTY(*tty,0,0);
		return(1);
	}
	
}

//if unix98 fails, try old BSD style

for (c1='p'; c1 < 's'; c1++)
{
  for (c2='5'; c2 <='9'; c2++)
  {
   Buffer=FormatStr(Buffer,"/dev/pty%c%c",c1,c2);
   if ( (*pty=open(Buffer,O_RDWR)) >-1)
   {
      Buffer=FormatStr(Buffer,"/dev/tty%c%c",c1,c2);
      if ( (*tty=OpenTTY(Buffer,0,0)) >-1)
      {
				DestroyString(Buffer);
        return(1);
      }
      else close(*pty);
   }

  }

}

DestroyString(Buffer);
return(0);
}