summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2006-12-07 00:25:44 +0100
committerKarel Zak <kzak@redhat.com>2006-12-07 00:25:44 +0100
commit66ee8158b69525e12060ef558cb5d77feadab1dc (patch)
tree08b30f2d07df9213f5647bc6f60b5090a263ef43 /lib
parent22853e4a82c6ef7b336527529acb94b14a0b0fd8 (diff)
downloadutil-linux-old-66ee8158b69525e12060ef558cb5d77feadab1dc.tar.gz
Imported from util-linux-2.10s tarball.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile6
-rw-r--r--lib/carefulputc.c26
-rw-r--r--lib/carefulputc.h1
-rw-r--r--lib/nls.h1
-rw-r--r--lib/pathnames.h2
-rw-r--r--lib/widechar.h2
6 files changed, 34 insertions, 4 deletions
diff --git a/lib/Makefile b/lib/Makefile
index a9f8596d..31e953ce 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,9 +1,7 @@
include ../make_include
include ../MCONFIG
-CFLAGS=-I$(LIB) $(OPT)
-
-all: err.o my_reboot.o setproctitle.o env.o
+all: err.o my_reboot.o setproctitle.o env.o carefulputc.o
err.o: err.c
@@ -13,6 +11,8 @@ env.o: env.h
setproctitle.o: setproctitle.h
+carefulputc.o: carefulputc.h
+
.PHONY: clean
clean:
-rm -f *.o *~ core
diff --git a/lib/carefulputc.c b/lib/carefulputc.c
new file mode 100644
index 00000000..93223377
--- /dev/null
+++ b/lib/carefulputc.c
@@ -0,0 +1,26 @@
+/* putc() for use in write and wall (that sometimes are sgid tty) */
+/* Avoid control characters in our locale, and also ASCII control characters.
+ Note that the locale of the recipient is unknown. */
+#include <stdio.h>
+#include <ctype.h>
+#include "carefulputc.h"
+
+#define iso8859x_iscntrl(c) \
+ (((c) & 0x7f) < 0x20 || (c) == 0x7f)
+
+int
+carefulputc(int c, FILE *fp) {
+ int ret;
+
+ if (c == '\007' || c == '\t' || c == '\r' || c == '\n' ||
+ (!iso8859x_iscntrl(c) && (isprint(c) || isspace(c))))
+ ret = putc(c, fp);
+ else if ((c & 0x80) || !isprint(c^0x40))
+ ret = fprintf(fp, "\\%3o", (unsigned char) c);
+ else {
+ ret = putc('^', fp);
+ if (ret != EOF)
+ ret = putc(c^0x40, fp);
+ }
+ return (ret < 0) ? EOF : 0;
+}
diff --git a/lib/carefulputc.h b/lib/carefulputc.h
new file mode 100644
index 00000000..29cc75da
--- /dev/null
+++ b/lib/carefulputc.h
@@ -0,0 +1 @@
+extern int carefulputc(int c, FILE *fp);
diff --git a/lib/nls.h b/lib/nls.h
index 67b42a99..d36a5bc8 100644
--- a/lib/nls.h
+++ b/lib/nls.h
@@ -1,3 +1,4 @@
+int main(int argc, char *argv[]);
#include "../defines.h" /* for HAVE_locale_h */
diff --git a/lib/pathnames.h b/lib/pathnames.h
index 60797f94..672b58e9 100644
--- a/lib/pathnames.h
+++ b/lib/pathnames.h
@@ -128,7 +128,7 @@ Libc5 and glibc 2.0-2.1 have /var/spool/mail, but glibc 2.1.1 has /var/mail.
/* used in login-utils/shutdown.c */
#define _PATH_MTAB "/etc/mtab"
#define _PATH_UMOUNT "/bin/umount"
-#define UMOUNT_ARGS "umount", "-a"
+#define UMOUNT_ARGS "umount", "-a", "-t", "nodevfs"
#define SWAPOFF_ARGS "swapoff", "-a"
/* used in login-utils/setpwnam.h and login-utils/islocal.c */
diff --git a/lib/widechar.h b/lib/widechar.h
index a8d28829..c440006f 100644
--- a/lib/widechar.h
+++ b/lib/widechar.h
@@ -38,4 +38,6 @@
# define wcsdup strdup
# define wcslen strlen
+# define wcwidth(c) 1
+
#endif