]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/busybox/busybox-1.00/add-getkey-applet.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / busybox / busybox-1.00 / add-getkey-applet.patch
1
2 #
3 # Patch managed by http://www.holgerschurig.de/patcher.html
4 #
5
6 --- /dev/null
7 +++ busybox-1.00/console-tools/getkey.c
8 @@ -0,0 +1,94 @@
9 +/* vi: set sw=4 ts=4: */
10 +/*
11 + * getkey.c - Michael 'Mickey' Lauer
12 + *
13 + * Version 0.1
14 + *
15 + * A simple keygrapper. Displays a configurable message and waits a dedicated number
16 + * of seconds for a keypress. Sets the exit code accordingly (SUCCESS on keypress).
17 + */
18 +#include <stdio.h>
19 +#include <fcntl.h>
20 +#include <memory.h>
21 +#include <stdlib.h>
22 +#include <unistd.h>
23 +#include <sys/types.h>
24 +#include <errno.h>
25 +#include <sys/ioctl.h>
26 +#include <sys/kd.h>
27 +#include "busybox.h"
28 +
29 +extern int getkey_main(int argc, char **argv)
30 +{
31 +    int status = EXIT_FAILURE;
32 +
33 +    if ( argc < 2 )
34 +    {
35 +       bb_show_usage();
36 +    }
37 +
38 +    /*
39 +     * If no terminal is attached it is quite useless
40 +     * to treat it like one.
41 +     */
42 +    if( !isatty(STDIN_FILENO) )
43 +    {
44 +       goto error_hard;
45 +    }
46 +
47 +    //bb_printf( "DEBUG: time = '%s'\n", argv[1] );
48 +    //bb_printf( "DEBUG: mesg = '%s'\n", argv[2] );
49 +
50 +    struct termios orig;
51 +    struct termios attr;
52 +
53 +    if ( tcgetattr(STDIN_FILENO, &orig) == -1 )
54 +    {
55 +       goto error_hard;
56 +    }
57 +
58 +    attr = orig;
59 +    attr.c_cc[VMIN] = 0;
60 +    attr.c_cc[VTIME] = 0;
61 +    attr.c_iflag |= INLCR;
62 +    attr.c_oflag |= OPOST|ONLCR;
63 +    attr.c_cflag &= ~PARENB;
64 +    attr.c_lflag &= ~(ICANON/*|ECHO*/);
65 +    if ( tcsetattr(STDIN_FILENO,TCSANOW,&attr) == -1 )
66 +    {
67 +       goto error_hard;
68 +    }
69 +
70 +    fd_set rfds;
71 +    struct timeval tv;
72 +    int retval;
73 +
74 +    FD_ZERO(&rfds);
75 +    FD_SET(0, &rfds);
76 +
77 +    tv.tv_sec = atoi( argv[1] );
78 +    tv.tv_usec = 0;
79 +
80 +    if ( argc == 3 )
81 +    {
82 +       bb_printf( argv[2], tv.tv_sec );
83 +       bb_printf( "\n" );
84 +       fflush(stdout);
85 +    }
86 +    retval = select(1, &rfds, NULL, NULL, &tv);
87 +    if (retval > 0)
88 +    {
89 +       status = EXIT_SUCCESS;
90 +    }
91 +
92 +    if (tcsetattr(STDIN_FILENO,TCSANOW,&orig) == -1 )
93 +    {
94 +       goto error_hard;
95 +    }
96 +
97 +    return status;
98 +
99 +error_hard   :
100 +    return EXIT_FAILURE;
101 +};
102 +
103 --- busybox-1.00/console-tools/Makefile.in~add-getkey-applet.patch
104 +++ busybox-1.00/console-tools/Makefile.in
105 @@ -28,6 +28,7 @@
106  CONSOLETOOLS_DIR-$(CONFIG_CLEAR)       += clear.o
107  CONSOLETOOLS_DIR-$(CONFIG_DEALLOCVT)   += deallocvt.o
108  CONSOLETOOLS_DIR-$(CONFIG_DUMPKMAP)    += dumpkmap.o
109 +CONSOLETOOLS_DIR-$(CONFIG_GETKEY)      += getkey.o
110  CONSOLETOOLS_DIR-$(CONFIG_LOADFONT)    += loadfont.o
111  CONSOLETOOLS_DIR-$(CONFIG_LOADKMAP)    += loadkmap.o
112  CONSOLETOOLS_DIR-$(CONFIG_OPENVT)      += openvt.o
113 --- busybox-1.00/console-tools/Config.in~add-getkey-applet.patch
114 +++ busybox-1.00/console-tools/Config.in
115 @@ -31,6 +31,14 @@
116           This program dumps the kernel's keyboard translation table to
117           stdout, in binary format. You can then use loadkmap to load it.
118  
119 +config CONFIG_GETKEY
120 +       bool "getkey"
121 +       default n
122 +       help
123 +         This program displays a configurable message and waits
124 +         a dedicated number of seconds for a keypress. It sets
125 +         the exit code accordingly, i.e. SUCCESS if there was a keypress.
126 +
127  config CONFIG_LOADFONT
128         bool "loadfont"
129         default n
130 --- busybox-1.00/include/applets.h~add-getkey-applet.patch
131 +++ busybox-1.00/include/applets.h
132 @@ -223,6 +223,9 @@
133  #ifdef CONFIG_FTPPUT
134         APPLET(ftpput, ftpgetput_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
135  #endif
136 +#ifdef CONFIG_GETKEY
137 +       APPLET(getkey, getkey_main, _BB_DIR_SBIN, _BB_SUID_NEVER)
138 +#endif
139  #ifdef CONFIG_GETOPT
140         APPLET(getopt, getopt_main, _BB_DIR_BIN, _BB_SUID_NEVER)
141  #endif
142 --- busybox-1.00/include/usage.h~add-getkey-applet.patch
143 +++ busybox-1.00/include/usage.h
144 @@ -734,6 +734,13 @@
145         "\t-p, --password         Password to be used\n" \
146         "\t-P, --port             Port number to be used"
147  
148 +#define getkey_trivial_usage \
149 +       "time [message]"
150 +#define getkey_full_usage \
151 +       "Display a message and wait for a keypress."
152 +#define getkey_example_usage \
153 +       "$ getkey 5 'Press a key within %d seconds to interrupt autoboot.'"
154 +
155  #define getopt_trivial_usage \
156         "[OPTIONS]..."
157  #define getopt_full_usage \