| 1 |
$FreeWRT$ |
| 2 |
--- busybox-1.4.2.orig/console-tools/Config.in 2007-03-18 17:59:28.000000000 +0100 |
| 3 |
+++ busybox-1.4.2/console-tools/Config.in 2007-08-01 15:52:07.000000000 +0200 |
| 4 |
@@ -5,6 +5,13 @@ |
| 5 |
|
| 6 |
menu "Console Utilities" |
| 7 |
|
| 8 |
+config CHKUTERM |
| 9 |
+ bool "chkuterm" |
| 10 |
+ default n |
| 11 |
+ help |
| 12 |
+ This programme determines whether the current terminal |
| 13 |
+ is in UTF-8 mode. |
| 14 |
+ |
| 15 |
config CHVT |
| 16 |
bool "chvt" |
| 17 |
default n |
| 18 |
--- busybox-1.4.2.orig/console-tools/Kbuild 2007-03-18 17:59:28.000000000 +0100 |
| 19 |
+++ busybox-1.4.2/console-tools/Kbuild 2007-08-01 15:51:38.000000000 +0200 |
| 20 |
@@ -5,6 +5,7 @@ |
| 21 |
# Licensed under the GPL v2, see the file LICENSE in this tarball. |
| 22 |
|
| 23 |
lib-y:= |
| 24 |
+lib-$(CONFIG_CHKUTERM) += chkuterm.o |
| 25 |
lib-$(CONFIG_CHVT) += chvt.o |
| 26 |
lib-$(CONFIG_CLEAR) += clear.o |
| 27 |
lib-$(CONFIG_DEALLOCVT) += deallocvt.o |
| 28 |
--- busybox-1.4.2.orig/console-tools/chkuterm.c 1970-01-01 00:00:00.000000000 +0100 |
| 29 |
+++ busybox-1.4.2/console-tools/chkuterm.c 2007-08-02 16:25:45.000000000 +0200 |
| 30 |
@@ -0,0 +1,130 @@ |
| 31 |
+/* From: $MirOS: ports/sysutils/chkuterm/dist/chkuterm.c,v 1.11 2007/05/10 13:02:22 tg Exp $ */ |
| 32 |
+ |
| 33 |
+/*- |
| 34 |
+ * Copyright (c) 2006, 2007 |
| 35 |
+ * Thorsten Glaser <tg@mirbsd.de> |
| 36 |
+ * |
| 37 |
+ * Provided that these terms and disclaimer and all copyright notices |
| 38 |
+ * are retained or reproduced in an accompanying document, permission |
| 39 |
+ * is granted to deal in this work without restriction, including un- |
| 40 |
+ * limited rights to use, publicly perform, distribute, sell, modify, |
| 41 |
+ * merge, give away, or sublicence. |
| 42 |
+ * |
| 43 |
+ * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to |
| 44 |
+ * the utmost extent permitted by applicable law, neither express nor |
| 45 |
+ * implied; without malicious intent or gross negligence. In no event |
| 46 |
+ * may a licensor, author or contributor be held liable for indirect, |
| 47 |
+ * direct, other damage, loss, or other issues arising in any way out |
| 48 |
+ * of dealing in the work, even if advised of the possibility of such |
| 49 |
+ * damage or existence of a defect, except proven that it results out |
| 50 |
+ * of said person's immediate fault when using the work as intended. |
| 51 |
+ */ |
| 52 |
+ |
| 53 |
+#include "busybox.h" |
| 54 |
+#include <err.h> |
| 55 |
+ |
| 56 |
+#if 0 |
| 57 |
+__RCSID("$miros: src/usr.sbin/wsconfig/wsconfig.c,v 1.16 2007/05/10 13:02:21 tg Exp $"); |
| 58 |
+__RCSID("$MirOS: ports/sysutils/chkuterm/dist/chkuterm.c,v 1.11 2007/05/10 13:02:22 tg Exp $"); |
| 59 |
+__RCSID("$miros: ports/misc/screen/patches/patch-screen_c,v 1.12 2007/05/10 13:02:23 tg Exp $"); |
| 60 |
+#endif |
| 61 |
+ |
| 62 |
+/* query string sent to the terminal for LC_CTYPE detection */ |
| 63 |
+/* XXX is U+20AC U+002E ok or some other char better? Think EUC, SJIS, etc. */ |
| 64 |
+const char ctype_qstr[] = "\030\032\r\xE2\x82\xAC.\033[6n"; |
| 65 |
+ |
| 66 |
+int |
| 67 |
+chkuterm_main(int argc, char *argv[]) |
| 68 |
+{ |
| 69 |
+ const char *wsdev, *est; |
| 70 |
+ char ch; |
| 71 |
+ int wsfd, rv = 0; |
| 72 |
+ int nr = 0; |
| 73 |
+ struct termios tio, otio; |
| 74 |
+ fd_set fds; |
| 75 |
+ struct timeval tv; |
| 76 |
+ FILE *wsf; |
| 77 |
+ |
| 78 |
+ wsdev = "/dev/tty"; |
| 79 |
+ |
| 80 |
+ /* apparently O_RDONLY wouldn't matter but we stay safe */ |
| 81 |
+ if ((est = ttyname(STDIN_FILENO)) != NULL && !strcmp(wsdev, est)) |
| 82 |
+ wsfd = STDIN_FILENO; |
| 83 |
+ else if ((est = ttyname(STDOUT_FILENO)) != NULL && !strcmp(wsdev, est)) |
| 84 |
+ wsfd = STDOUT_FILENO; |
| 85 |
+ else |
| 86 |
+ if ((wsfd = open(wsdev, O_RDWR, 0)) < 0) |
| 87 |
+ err(2, "open %s", wsdev); |
| 88 |
+ wsf = fdopen(wsfd, "rb+"); |
| 89 |
+ |
| 90 |
+ tcdrain(wsfd); |
| 91 |
+ if (tcgetattr(wsfd, &otio)) |
| 92 |
+ err(3, "tcgetattr"); |
| 93 |
+ tio = otio; |
| 94 |
+ cfmakeraw(&tio); |
| 95 |
+ if (tcflush(wsfd, TCIOFLUSH)) |
| 96 |
+ warn("tcflush"); |
| 97 |
+ rv = /* error */ 3; |
| 98 |
+ if (tcsetattr(wsfd, TCSANOW, &tio)) { |
| 99 |
+ warn("tcsetattr\r"); |
| 100 |
+ goto tios_err; |
| 101 |
+ } |
| 102 |
+ tv.tv_sec = 0; |
| 103 |
+ tv.tv_usec = 75; |
| 104 |
+ select(0, NULL, NULL, NULL, &tv); /* sleep 75 msec */ |
| 105 |
+ if ((size_t)write(wsfd, ctype_qstr, strlen(ctype_qstr)) != |
| 106 |
+ strlen(ctype_qstr)) { |
| 107 |
+ warn("write\r"); |
| 108 |
+ goto noin; |
| 109 |
+ } |
| 110 |
+ select(0, NULL, NULL, NULL, &tv); /* sleep 75 msec */ |
| 111 |
+ FD_ZERO(&fds); |
| 112 |
+ FD_SET(wsfd, &fds); |
| 113 |
+ tv.tv_sec = 2; |
| 114 |
+ tv.tv_usec = 0; |
| 115 |
+ if (select(wsfd + 1, &fds, NULL, NULL, &tv) <= 0) |
| 116 |
+ goto noin; |
| 117 |
+ nr = read(wsfd, &ch, 1); |
| 118 |
+ rv = /* unknown */ 1; |
| 119 |
+ if (wsf != NULL && nr == 1 && ch == 033) { |
| 120 |
+ unsigned zeile, spalte; |
| 121 |
+ |
| 122 |
+ if (fscanf(wsf, "[%u;%u", &zeile, &spalte) == 2) |
| 123 |
+ switch (spalte) { |
| 124 |
+ case 1: /* EUC-JP, EUC-KR kterm */ |
| 125 |
+ case 5: /* Shift-JIS kterm */ |
| 126 |
+ break; |
| 127 |
+ case 3: /* UTF-8 xterm, screen */ |
| 128 |
+ rv = 0; |
| 129 |
+ break; |
| 130 |
+ case 4: /* ISO-8859-1 xterm, screen */ |
| 131 |
+ rv = 2; |
| 132 |
+ break; |
| 133 |
+ default: |
| 134 |
+ rv = 0x1000 | spalte; |
| 135 |
+ break; |
| 136 |
+ } |
| 137 |
+ } |
| 138 |
+ noin: |
| 139 |
+ write(wsfd, "\r \r", 8); |
| 140 |
+ tios_err: |
| 141 |
+ if (tcflush(wsfd, TCIOFLUSH)) |
| 142 |
+ warn("tcflush"); |
| 143 |
+ if (tcsetattr(wsfd, TCSANOW, &otio)) |
| 144 |
+ err(3, "tcsetattr"); |
| 145 |
+ if (rv & 0x1000) { |
| 146 |
+ /* unknown charset */ |
| 147 |
+ printf("# unknown column %d\n", rv & 0xFFF); |
| 148 |
+ rv = 1; |
| 149 |
+ } |
| 150 |
+ printf("LC_CTYPE=%s; export LC_CTYPE\n", |
| 151 |
+ rv == 0 ? "en_US.UTF-8" : "C"); |
| 152 |
+ if (rv > 2) |
| 153 |
+ puts("# warning: problems occured!\n"); |
| 154 |
+ |
| 155 |
+ if (wsf == NULL) |
| 156 |
+ close(wsfd); |
| 157 |
+ else |
| 158 |
+ fclose(wsf); |
| 159 |
+ return (rv); |
| 160 |
+} |
| 161 |
--- busybox-1.4.2.orig/include/applets.h 2007-03-18 17:59:34.000000000 +0100 |
| 162 |
+++ busybox-1.4.2/include/applets.h 2007-08-01 15:51:11.000000000 +0200 |
| 163 |
@@ -70,6 +70,7 @@ USE_CAT(APPLET(cat, _BB_DIR_BIN, _BB_SUI |
| 164 |
USE_CATV(APPLET(catv, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 165 |
USE_CHATTR(APPLET(chattr, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 166 |
USE_CHGRP(APPLET(chgrp, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 167 |
+USE_CHKUTERM(APPLET_NOUSAGE(chkuterm, chkuterm, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
| 168 |
USE_CHMOD(APPLET(chmod, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 169 |
USE_CHOWN(APPLET(chown, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 170 |
USE_CHPST(APPLET(chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |