OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [expect/] [exp_console.c] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* exp_console.c - grab console.  This stuff is in a separate file to
2
avoid unpleasantness of AIX (3.2.4) .h files which provide no way to
3
reference TIOCCONS and include both sys/ioctl.h and sys/sys/stropts.h
4
without getting some sort of warning from the compiler.  The problem
5
is that both define _IO but only ioctl.h checks to see if it is
6
defined first.  This would suggest that it is sufficient to include
7
ioctl.h after stropts.h.  Unfortunately, ioctl.h, having seen that _IO
8
is defined, then fails to define other important things (like _IOW).
9
 
10
Written by: Don Libes, NIST, 2/6/90
11
 
12
Design and implementation of this program was paid for by U.S. tax
13
dollars.  Therefore it is public domain.  However, the author and NIST
14
would appreciate credit if this program or parts of it are used.
15
*/
16
 
17
#include "expect_cf.h"
18
#include <stdio.h>
19
#include <sys/types.h>
20
#include <sys/ioctl.h>
21
 
22
#ifdef HAVE_STRREDIR_H
23
#include <sys/strredir.h>
24
# ifdef SRIOCSREDIR
25
#  undef TIOCCONS
26
# endif
27
#endif
28
 
29
#ifdef HAVE_SYS_FCNTL_H
30
#include <sys/fcntl.h>
31
#endif
32
 
33
#include "tcl.h"
34
#include "exp_rename.h"
35
#include "exp_prog.h"
36
#include "exp_log.h"
37
 
38
static void
39
exp_console_manipulation_failed(s)
40
char *s;
41
{
42
        exp_errorlog("expect: spawn: cannot %s console, check permissions of /dev/console\n",s);
43
        exit(-1);
44
}
45
 
46
void
47
exp_console_set()
48
{
49
#ifdef SRIOCSREDIR
50
        int fd;
51
 
52
        if ((fd = open("/dev/console", O_RDONLY)) == -1) {
53
                exp_console_manipulation_failed("open");
54
        }
55
        if (ioctl(fd, SRIOCSREDIR, 0) == -1) {
56
                exp_console_manipulation_failed("redirect");
57
        }
58
        close(fd);
59
#endif
60
 
61
#ifdef TIOCCONS
62
        int on = 1;
63
 
64
        if (ioctl(0,TIOCCONS,(char *)&on) == -1) {
65
                exp_console_manipulation_failed("redirect");
66
        }
67
#endif /*TIOCCONS*/
68
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.