summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:26:54 +0100
committerKarel Zak2006-12-07 00:26:54 +0100
commit48d7b13a1eab85fab91c8d6c5ddf298f733c74f5 (patch)
tree8813d36590ee3361bd75f57a12fd2032e9296ddb /include
parentImported from util-linux-2.12r tarball. (diff)
downloadkernel-qcow2-util-linux-48d7b13a1eab85fab91c8d6c5ddf298f733c74f5.tar.gz
kernel-qcow2-util-linux-48d7b13a1eab85fab91c8d6c5ddf298f733c74f5.tar.xz
kernel-qcow2-util-linux-48d7b13a1eab85fab91c8d6c5ddf298f733c74f5.zip
Imported from util-linux-2.13-pre1 tarball.
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am3
-rw-r--r--include/carefulputc.h29
-rw-r--r--include/env.h2
-rw-r--r--include/errs.h125
-rw-r--r--include/linux_reboot.h72
-rw-r--r--include/md5.h27
-rw-r--r--include/nls.h24
-rw-r--r--include/pathnames.h152
-rw-r--r--include/setproctitle.h7
-rw-r--r--include/widechar.h49
-rw-r--r--include/xstrncpy.h8
11 files changed, 498 insertions, 0 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644
index 000000000..e55ea0786
--- /dev/null
+++ b/include/Makefile.am
@@ -0,0 +1,3 @@
+include $(top_srcdir)/config/include-Makefile.am
+
+EXTRA_DIST = carefulputc.h env.h errs.h linux_reboot.h md5.h nls.h pathnames.h setproctitle.h widechar.h xstrncpy.h
diff --git a/include/carefulputc.h b/include/carefulputc.h
new file mode 100644
index 000000000..2d857ebb0
--- /dev/null
+++ b/include/carefulputc.h
@@ -0,0 +1,29 @@
+#ifndef _CAREFUULPUTC_H
+#define _CAREFUULPUTC_H
+
+/* 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>
+
+#define iso8859x_iscntrl(c) \
+ (((c) & 0x7f) < 0x20 || (c) == 0x7f)
+
+static inline 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;
+}
+
+#endif /* _CAREFUULPUTC_H */
diff --git a/include/env.h b/include/env.h
new file mode 100644
index 000000000..d69b4f295
--- /dev/null
+++ b/include/env.h
@@ -0,0 +1,2 @@
+extern void sanitize_env (void);
+
diff --git a/include/errs.h b/include/errs.h
new file mode 100644
index 000000000..bc0f69448
--- /dev/null
+++ b/include/errs.h
@@ -0,0 +1,125 @@
+#ifndef _ERR_H_
+#define _ERR_H_
+
+/*-
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+
+
+#ifdef HAVE___PROGNAME
+extern char *__progname; /* Program name, from crt0. */
+#else
+char *__progname = "foo"; /* probably libc4 */
+#endif
+
+/* Some compilers complain "null format string" upon err(1,NULL) */
+/* Make them happy with a separate routine. */
+static inline void err_nomsg(int exitval) {
+ (void)fprintf(stderr, "%s: %s\n", __progname, strerror(errno));
+ exit(exitval);
+}
+
+static inline void verr(int exitval, const char *fmt, va_list ap) {
+ int sverrno;
+
+ sverrno = errno;
+ (void)fprintf(stderr, "%s: ", __progname);
+ if (fmt != NULL && *fmt != 0) {
+ (void)vfprintf(stderr, fmt, ap);
+ (void)fprintf(stderr, ": ");
+ }
+ (void)fprintf(stderr, "%s\n", strerror(sverrno));
+ exit(exitval);
+}
+
+static inline void err(int exitval, const char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ verr(exitval, fmt, ap);
+ va_end(ap);
+}
+
+static inline void verrx(int exitval, const char *fmt, va_list ap) {
+ (void)fprintf(stderr, "%s: ", __progname);
+ if (fmt != NULL)
+ (void)vfprintf(stderr, fmt, ap);
+ (void)fprintf(stderr, "\n");
+ exit(exitval);
+}
+
+static inline void errx(int exitval, const char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ verrx(exitval, fmt, ap);
+ va_end(ap);
+}
+
+static inline void vwarn(const char *fmt, va_list ap) {
+ int sverrno;
+
+ sverrno = errno;
+ (void)fprintf(stderr, "%s: ", __progname);
+ if (fmt != NULL) {
+ (void)vfprintf(stderr, fmt, ap);
+ (void)fprintf(stderr, ": ");
+ }
+ (void)fprintf(stderr, "%s\n", strerror(sverrno));
+}
+
+static inline void warn(const char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ vwarn(fmt, ap);
+ va_end(ap);
+}
+
+static inline void vwarnx(const char *fmt, va_list ap) {
+ (void)fprintf(stderr, "%s: ", __progname);
+ if (fmt != NULL)
+ (void)vfprintf(stderr, fmt, ap);
+ (void)fprintf(stderr, "\n");
+}
+
+static inline void warnx(const char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ vwarnx(fmt, ap);
+ va_end(ap);
+}
+
+#endif /* !_ERR_H_ */
diff --git a/include/linux_reboot.h b/include/linux_reboot.h
new file mode 100644
index 000000000..9cebc67e8
--- /dev/null
+++ b/include/linux_reboot.h
@@ -0,0 +1,72 @@
+#ifndef _LINUX_REBOOT_H
+#define _LINUX_REBOOT_H
+
+/*
+ * Magic values required to use _reboot() system call.
+ */
+
+#define LINUX_REBOOT_MAGIC1 0xfee1dead
+#define LINUX_REBOOT_MAGIC2 672274793
+#define LINUX_REBOOT_MAGIC2A 85072278
+#define LINUX_REBOOT_MAGIC2B 369367448
+
+
+/*
+ * Commands accepted by the _reboot() system call.
+ *
+ * RESTART Restart system using default command and mode.
+ * HALT Stop OS and give system control to ROM monitor, if any.
+ * CAD_ON Ctrl-Alt-Del sequence causes RESTART command.
+ * CAD_OFF Ctrl-Alt-Del sequence sends SIGINT to init task.
+ * POWER_OFF Stop OS and remove all power from system, if possible.
+ * RESTART2 Restart system using given command string.
+ */
+
+#define LINUX_REBOOT_CMD_RESTART 0x01234567
+#define LINUX_REBOOT_CMD_HALT 0xCDEF0123
+#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF
+#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000
+#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC
+#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
+
+/* Including <unistd.h> makes sure that on a glibc system
+ <features.h> is included, which again defines __GLIBC__ */
+#include <unistd.h>
+#include "linux_reboot.h"
+
+#define USE_LIBC
+
+#ifdef USE_LIBC
+
+/* libc version */
+#if defined __GLIBC__ && __GLIBC__ >= 2
+# include <sys/reboot.h>
+# define REBOOT(cmd) reboot(cmd)
+#else
+extern int reboot(int, int, int);
+# define REBOOT(cmd) reboot(LINUX_REBOOT_MAGIC1,LINUX_REBOOT_MAGIC2,(cmd))
+#endif
+static inline int my_reboot(int cmd) {
+ return REBOOT(cmd);
+}
+
+#else /* no USE_LIBC */
+
+/* direct syscall version */
+#include <linux/unistd.h>
+
+#ifdef _syscall3
+_syscall3(int, reboot, int, magic, int, magic_too, int, cmd);
+#else
+/* Let us hope we have a 3-argument reboot here */
+extern int reboot(int, int, int);
+#endif
+
+static inline int my_reboot(int cmd) {
+ return reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd);
+}
+
+#endif
+
+
+#endif /* _LINUX_REBOOT_H */
diff --git a/include/md5.h b/include/md5.h
new file mode 100644
index 000000000..d598e81be
--- /dev/null
+++ b/include/md5.h
@@ -0,0 +1,27 @@
+#ifndef MD5_H
+#define MD5_H
+
+#if HAVE_STDINT_H
+#include <stdint.h>
+#else
+typedef unsigned int uint32_t;
+#endif
+
+struct MD5Context {
+ uint32_t buf[4];
+ uint32_t bits[2];
+ unsigned char in[64];
+};
+
+void MD5Init(struct MD5Context *context);
+void MD5Update(struct MD5Context *context, unsigned char const *buf,
+ unsigned len);
+void MD5Final(unsigned char digest[16], struct MD5Context *context);
+void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
+
+/*
+ * This is needed to make RSAREF happy on some MS-DOS compilers.
+ */
+typedef struct MD5Context MD5_CTX;
+
+#endif /* !MD5_H */
diff --git a/include/nls.h b/include/nls.h
new file mode 100644
index 000000000..858fdb61e
--- /dev/null
+++ b/include/nls.h
@@ -0,0 +1,24 @@
+int main(int argc, char *argv[]);
+
+#ifndef LOCALEDIR
+#define LOCALEDIR "/usr/share/locale"
+#endif
+
+#ifdef ENABLE_NLS
+# include <libintl.h>
+# define _(Text) gettext (Text)
+# ifdef gettext_noop
+# define N_(String) gettext_noop (String)
+# else
+# define N_(String) (String)
+# endif
+#else
+# undef bindtextdomain
+# define bindtextdomain(Domain, Directory) /* empty */
+# undef textdomain
+# define textdomain(Domain) /* empty */
+# define _(Text) (Text)
+# define N_(Text) (Text)
+#endif
+
+
diff --git a/include/pathnames.h b/include/pathnames.h
new file mode 100644
index 000000000..d9e05b321
--- /dev/null
+++ b/include/pathnames.h
@@ -0,0 +1,152 @@
+/*
+ * Vaguely based on
+ * @(#)pathnames.h 5.3 (Berkeley) 5/9/89
+ * This code is in the public domain.
+ */
+#include <paths.h>
+
+#ifndef __STDC__
+# error "we need an ANSI compiler"
+#endif
+
+/* The paths for some of these are wrong in /usr/include/paths.h,
+ but we re-define them here. */
+
+/* Used in login.c, agetty.c, simpleinit.c, shutdown.c, write.c */
+#undef _PATH_UTMP
+/* Used in login.c, agetty.c, simpleinit.c, shutdown.c, last.c */
+#undef _PATH_WTMP
+/* These four are used in login.c only */
+#undef _PATH_DEFPATH
+#undef _PATH_DEFPATH_ROOT
+#undef _PATH_LASTLOG
+
+/*
+ * HISTORY
+ *
+What is the history of these six, and related defines?
+------------------------------------------------------------------------
+_PATH_UTMP and UTMP_FILE and UTMP_FILENAME
+ /etc/utmp > /var/adm/utmp > /var/run/utmp.
+Traditionally we have /etc/utmp.
+In <paths.h> we have /etc/utmp, but since 4.6.0 /var/adm/utmp
+and since 5.0.9 (and in glibc2) /var/run/utmp.
+In login/pathnames.h we have /etc/utmp, but since 4.6.6 /var/adm/utmp.
+In <utmp.h> UTMP_FILE is defined as /etc/utmp, but in 4.6.* as _PATH_UTMP.
+
+_PATH_WTMP and WTMP_FILE and WTMP_FILENAME
+ /etc/wtmp > /usr/adm/wtmp > /var/adm/wtmp > /var/log/wtmp.
+Traditionally we have /etc/wtmp.
+In <paths.h> we have /usr/adm/wtmp, but since 4.5.13 /var/adm/wtmp,
+and since 5.0.9 (and in glibc2) /var/log/wtmp.
+In login/pathnames.h. we have /etc/wtmp, but since 4.6.6 /var/adm/wtmp.
+In <utmp.h> WTMP_FILE is defined as /usr/adm/wtmp, but in 4.5.* as
+/var/adm/wtmp, and in 4.6.* as _PATH_WTMP.
+
+_PATH_DEFPATH
+Long ago this was ".:/bin:/usr/bin".
+In <paths.h> libc 4.4.1-4.4.4 have "/usr/bin:/bin"
+and libc 4.5.21-5.4.23 have "/usr/local/bin:/usr/bin:/bin:."
+and libc 5.4.38-5.4.46 have "/usr/local/bin:/usr/bin:/bin".
+In login/pathnames.h libc4 and libc5 have "/usr/local/bin:/bin:/usr/bin:."
+
+_PATH_DEFPATH_ROOT
+Long ago this was identical to _PATH_DEFPATH.
+In <paths.h> no definition is present before libc 4.5.13.
+Libc 4.5.13 has "/bin:/usr/bin:/etc"
+Libc 4.5.14-5.4.46 have "/sbin:/bin:/usr/sbin:/usr/bin"
+In login/pathnames.h libc4 and libc5 have "/bin:/usr/bin:/etc"
+
+_PATH_LASTLOG
+ /etc/lastlog > /usr/adm/lastlog > /var/adm/lastlog > /var/log/lastlog.
+Traditionally we have /etc/lastlog.
+In <bsd/utmp.h> libc 4.4.1-4.5.12 have /usr/adm/lastlog, 4.5.13 and
+later have /var/adm/lastlog.
+In paths.h all libc5 and glibc2 versions have /var/log/lastlog.
+In login/pathnames.h all libc4 and libc5 versions have /usr/adm/lastlog.
+
+_PATH_MAILDIR
+ /usr/spool/mail > /var/spool/mail > /var/mail.
+Traditionally we have /usr/spool/mail.
+In <paths.h> we have /usr/spool/mail, but since libc 4.5.13 /var/spool/mail.
+In login/pathnames.h all libc4 versions have /var/spool/mail.
+Libc5 and glibc 2.0-2.1 have /var/spool/mail, but glibc 2.1.1 has /var/mail.
+------------------------------------------------------------------------*/
+
+
+#ifndef SBINDIR
+#define SBINDIR "/sbin"
+#endif
+
+#ifndef USRSBINDIR
+#define USRSBINDIR "/usr/sbin"
+#endif
+
+#ifndef LOGDIR
+#define LOGDIR "/var/log"
+#endif
+
+#ifndef VARPATH
+#define VARPATH "/var"
+#endif
+
+#ifndef UT_NAMESIZE
+#define UT_NAMESIZE 8
+#endif
+
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_CSHELL "/bin/csh"
+#define _PATH_TTY "/dev/tty"
+#define TTYTYPES "/etc/ttytype"
+#define SECURETTY "/etc/securetty"
+#define _PATH_UTMP "/var/run/utmp"
+#define _PATH_WTMP LOGDIR "/wtmp"
+#define _PATH_WTMPLOCK "/etc/wtmplock"
+
+/* no more . in DEFPATH */
+#define _PATH_DEFPATH "/usr/local/bin:/bin:/usr/bin"
+#define _PATH_DEFPATH_ROOT "/usr/local/sbin:/usr/local/bin:" SBINDIR ":/bin:" USRSBINDIR ":/usr/bin"
+#define _PATH_HUSHLOGIN ".hushlogin"
+#define _PATH_LASTLOG LOGDIR "/lastlog"
+
+#ifndef _PATH_MAILDIR
+#define _PATH_MAILDIR VARPATH "/spool/mail"
+#endif
+#define _PATH_MOTDFILE "/etc/motd"
+#define _PATH_NOLOGIN "/etc/nologin"
+
+#define _PATH_LOGIN "/bin/login"
+#define _PATH_INITTAB "/etc/inittab"
+#define _PATH_RC "/etc/rc"
+#define _PATH_REBOOT SBINDIR "/reboot"
+#define _PATH_SINGLE "/etc/singleboot"
+#define _PATH_SHUTDOWN_CONF "/etc/shutdown.conf"
+
+#define _PATH_SECURE "/etc/securesingle"
+#define _PATH_USERTTY "/etc/usertty"
+
+/* used in login-utils/shutdown.c */
+#define _PATH_MTAB "/etc/mtab"
+#define _PATH_UMOUNT "/bin/umount"
+#define UMOUNT_ARGS "umount", "-a", "-t", "nodevfs"
+#define SWAPOFF_ARGS "swapoff", "-a"
+
+/* used in login-utils/setpwnam.h and login-utils/islocal.c */
+#define _PATH_PASSWD "/etc/passwd"
+
+/* used in login-utils/setpwnam.h */
+#define _PATH_PTMP "/etc/ptmp"
+#define _PATH_PTMPTMP "/etc/ptmptmp"
+#define _PATH_GROUP "/etc/group"
+#define _PATH_GTMP "/etc/gtmp"
+#define _PATH_GTMPTMP "/etc/gtmptmp"
+#define _PATH_SHADOW_PASSWD "/etc/shadow"
+#define _PATH_SHADOW_PTMP "/etc/sptmp"
+#define _PATH_SHADOW_PTMPTMP "/etc/sptmptmp"
+#define _PATH_SHADOW_GROUP "/etc/gshadow"
+#define _PATH_SHADOW_GTMP "/etc/sgtmp"
+#define _PATH_SHADOW_GTMPTMP "/etc/sgtmptmp"
+
+/* used in misc-utils/look.c */
+#define _PATH_WORDS "/usr/share/dict/words"
+#define _PATH_WORDS_ALT "/usr/share/dict/web2"
diff --git a/include/setproctitle.h b/include/setproctitle.h
new file mode 100644
index 000000000..d57abda6b
--- /dev/null
+++ b/include/setproctitle.h
@@ -0,0 +1,7 @@
+
+void initproctitle (int argc, char **argv);
+#if 0
+void setproctitle (const char *fmt, ...);
+#else
+void setproctitle (const char *prog, const char *txt);
+#endif
diff --git a/include/widechar.h b/include/widechar.h
new file mode 100644
index 000000000..d056aa394
--- /dev/null
+++ b/include/widechar.h
@@ -0,0 +1,49 @@
+/* Declarations for wide characters */
+/* This file must be included last because the redefinition of wchar_t may
+ cause conflicts when system include files were included after it. */
+
+#ifdef ENABLE_WIDECHAR
+
+# include <wchar.h>
+# include <wctype.h>
+#if 0 /* for testing on platforms without built-in wide character support */
+# include <libutf8.h>
+#endif
+
+#if 1
+/* explicit prototypes, since sometimes <wchar.h> does not give them */
+extern int wcwidth (wchar_t c); /* old: wint_t c */
+extern int wcswidth (const wchar_t *s, size_t n);
+extern size_t wcslen (const wchar_t *s);
+extern wchar_t *wcsdup (const wchar_t *s);
+#endif
+
+#else
+
+# include <ctype.h>
+ /* Fallback for types */
+# define wchar_t char
+# define wint_t int
+# define WEOF EOF
+ /* Fallback for input operations */
+# define fgetwc fgetc
+# define getwc getc
+# define getwchar getchar
+# define fgetws fgets
+ /* Fallback for output operations */
+# define fputwc fputc
+# define putwc putc
+# define putwchar putchar
+# define fputws fputs
+ /* Fallback for character classification */
+# define iswgraph isgraph
+# define iswprint isprint
+# define iswspace isspace
+ /* Fallback for string functions */
+# define wcschr strchr
+# define wcsdup strdup
+# define wcslen strlen
+
+# define wcwidth(c) 1
+
+#endif
diff --git a/include/xstrncpy.h b/include/xstrncpy.h
new file mode 100644
index 000000000..7ed4109d6
--- /dev/null
+++ b/include/xstrncpy.h
@@ -0,0 +1,8 @@
+/* NUL-terminated version of strncpy() */
+#include <string.h>
+
+/* caller guarantees n > 0 */
+static inline void xstrncpy(char *dest, const char *src, size_t n) {
+ strncpy(dest, src, n-1);
+ dest[n-1] = 0;
+}