Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add an XSH5 fmtmsg() implementation.



details:   https://anonhg.NetBSD.org/src/rev/cde8b8a06421
branches:  trunk
changeset: 476301:cde8b8a06421
user:      kleink <kleink%NetBSD.org@localhost>
date:      Sun Sep 12 19:04:30 1999 +0000

description:
Add an XSH5 fmtmsg() implementation.

diffstat:

 include/Makefile          |   18 +-
 include/fmtmsg.h          |   88 ++++++++++++++++
 lib/libc/gen/Makefile.inc |    6 +-
 lib/libc/gen/fmtmsg.3     |  223 +++++++++++++++++++++++++++++++++++++++++
 lib/libc/gen/fmtmsg.c     |  248 ++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 571 insertions(+), 12 deletions(-)

diffs (truncated from 630 to 300 lines):

diff -r d1cfab5fb278 -r cde8b8a06421 include/Makefile
--- a/include/Makefile  Sun Sep 12 18:54:34 1999 +0000
+++ b/include/Makefile  Sun Sep 12 19:04:30 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.77 1999/07/20 09:47:08 mrg Exp $
+#      $NetBSD: Makefile,v 1.78 1999/09/12 19:04:30 kleink Exp $
 #      @(#)Makefile    8.2 (Berkeley) 1/4/94
 
 SRCTOP=        ..
@@ -9,14 +9,14 @@
 # Missing: mp.h
 
 INCS=  a.out.h ar.h assert.h bitstring.h bm.h cpio.h ctype.h db.h dirent.h \
-       disktab.h dlfcn.h err.h errno.h fnmatch.h fstab.h fts.h glob.h grp.h \
-       hesiod.h ieeefp.h iso646.h kvm.h langinfo.h libgen.h limits.h link.h \
-       link_aout.h link_elf.h locale.h malloc.h math.h md4.h memory.h mpool.h \
-       ndbm.h netdb.h netgroup.h nlist.h nl_types.h nsswitch.h paths.h pwd.h \
-       ranlib.h re_comp.h regex.h regexp.h resolv.h rmt.h search.h setjmp.h \
-       sgtty.h signal.h stab.h stddef.h stdio.h stdlib.h string.h strings.h \
-       stringlist.h struct.h sysexits.h tar.h time.h ttyent.h tzfile.h \
-       unistd.h util.h utime.h utmp.h vis.h
+       disktab.h dlfcn.h err.h errno.h fmtmsg.h fnmatch.h fstab.h fts.h \
+       glob.h grp.h hesiod.h ieeefp.h iso646.h kvm.h langinfo.h libgen.h \
+       limits.h link.h link_aout.h link_elf.h locale.h malloc.h math.h md4.h \
+       memory.h mpool.h ndbm.h netdb.h netgroup.h nlist.h nl_types.h \
+       nsswitch.h paths.h pwd.h ranlib.h re_comp.h regex.h regexp.h resolv.h \
+       rmt.h search.h setjmp.h sgtty.h signal.h stab.h stddef.h stdio.h \
+       stdlib.h string.h strings.h stringlist.h struct.h sysexits.h tar.h \
+       time.h ttyent.h tzfile.h unistd.h util.h utime.h utmp.h vis.h
 INCS+= arpa/ftp.h arpa/inet.h arpa/nameser.h arpa/telnet.h arpa/tftp.h
 INCS+= protocols/dumprestore.h protocols/routed.h protocols/rwhod.h \
        protocols/talkd.h protocols/timed.h
diff -r d1cfab5fb278 -r cde8b8a06421 include/fmtmsg.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/include/fmtmsg.h  Sun Sep 12 19:04:30 1999 +0000
@@ -0,0 +1,88 @@
+/*     $NetBSD: fmtmsg.h,v 1.1 1999/09/12 19:04:30 kleink Exp $        */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * 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 NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#ifndef _FMTMSG_H_
+#define _FMTMSG_H_
+
+/* Major Classifications: identifies the source of the condition. */
+#define MM_HARD                0x01L   /* Hardware */
+#define MM_SOFT                0x02L   /* Software */
+#define MM_FIRM                0x03L   /* Firmware */
+
+/* Message Source Subclassifications: type of software. */
+#define MM_APPL                0x04L   /* Application */
+#define MM_UTIL                0x08L   /* Utility */
+#define MM_OPSYS       0x0cL   /* Operating system */
+
+/* Display Subclassifications: where to display the message. */
+#define MM_PRINT       0x10L   /* Display on standard error */
+#define MM_CONSOLE     0x20L   /* Display on system console */
+
+/* Status subclassifications: whether the application will recover. */
+#define MM_RECOVER     0x40L   /* Recoverable */
+#define MM_NRECOV      0x80L   /* Non-recoverable */
+
+/* Severity: seriousness of the condition. */
+#define MM_NOSEV       0       /* No severity level provided */
+#define MM_HALT                1       /* Error causing application to halt */
+#define MM_ERROR       2       /* Encountered a non-fatal fault */
+#define MM_WARNING     3       /* Unusual non-error condition */
+#define MM_INFO                4       /* Informative message */
+
+/* `Null' values for message components. */
+#define MM_NULLMC      0L              /* `Null' classsification component */
+#define MM_NULLLBL     (char *)0       /* `Null' label component */
+#define MM_NULLSEV     0               /* `Null' severity component */
+#define MM_NULLTXT     (char *)0       /* `Null' text component */
+#define MM_NULLACT     (char *)0       /* `Null' action component */
+#define MM_NULLTAG     (char *)0       /* `Null' tag component */
+
+/* Return values for fmtmsg(). */
+#define MM_OK          0       /* Function succeeded */
+#define MM_NOTOK       (-1)    /* Function failed completely */
+#define MM_NOMSG       0x01    /* Unable to perform MM_PRINT */
+#define MM_NOCON       0x02    /* Unable to perform MM_CONSOLE */
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int    fmtmsg __P((long, const char *, int, const char *, const char *,
+           const char *));
+__END_DECLS
+
+#endif /* !_FMTMSG_H_ */
diff -r d1cfab5fb278 -r cde8b8a06421 lib/libc/gen/Makefile.inc
--- a/lib/libc/gen/Makefile.inc Sun Sep 12 18:54:34 1999 +0000
+++ b/lib/libc/gen/Makefile.inc Sun Sep 12 19:04:30 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.100 1999/09/12 18:54:34 kleink Exp $
+#      $NetBSD: Makefile.inc,v 1.101 1999/09/12 19:04:31 kleink Exp $
 #      from: @(#)Makefile.inc  8.6 (Berkeley) 5/4/95
 
 # gen sources
@@ -7,7 +7,7 @@
 SRCS+=         _errno.c alarm.c assert.c basename.c clock.c closedir.c \
        confstr.c ctermid.c ctype_.c daemon.c devname.c dirname.c \
        disklabel.c err.c errx.c __errlist14.c errlist.c errno.c execl.c \
-       execle.c execlp.c execv.c execvp.c fnmatch.c fstab.c \
+       execle.c execlp.c execv.c execvp.c fmtmsg.c fnmatch.c fstab.c \
        ftok.c __fts13.c fts.c getbsize.c getcap.c getcwd.c \
        getdomainname.c getgrent.c getgrouplist.c gethostname.c \
        getloadavg.c getlogin.c getmntinfo.c getnetgrent.c \
@@ -37,7 +37,7 @@
 .include "${ARCHDIR}/gen/Makefile.inc"
 
 MAN+=  alarm.3 basename.3 bswap.3 clock.3 confstr.3 ctermid.3 ctype.3 \
-       daemon.3 devname.3 directory.3 dirname.3 err.3 exec.3 \
+       daemon.3 devname.3 directory.3 dirname.3 err.3 exec.3 fmtmsg.3 \
        fnmatch.3 fpgetmask.3 frexp.3 ftok.3 fts.3 getbsize.3 getcap.3 \
        getcwd.3 getdomainname.3 getdiskbyname.3 getfsent.3 \
        getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \
diff -r d1cfab5fb278 -r cde8b8a06421 lib/libc/gen/fmtmsg.3
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/gen/fmtmsg.3     Sun Sep 12 19:04:30 1999 +0000
@@ -0,0 +1,223 @@
+.\"    $NetBSD: fmtmsg.3,v 1.1 1999/09/12 19:04:31 kleink Exp $
+.\"
+.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Klaus Klein.
+.\"
+.\" 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 NetBSD
+.\"        Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+.\"
+.Dd September 10, 1999
+.Dt FMTMSG 3
+.Os
+.Sh NAME
+.Nm fmtmsg
+.Nd format and display a message
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.Fd #include <fmtmsg.h>
+.Ft int
+.Fn fmtmsg "long classification" "const char *label" "int severity" "const char *text" "const char *action" "const char *tag"
+.Sh DESCRIPTION
+The
+.Fn fmtmsg
+function can be used to display messages in the specified format.
+Messages may be written either to standard error, to the console, or both.
+.Pp
+A formatted message consists of up to five components specified in
+.Fa label ,
+.Fa severity ,
+.Fa text ,
+.Fa action
+and
+.Fa tag .
+Further information such as the origin of the message, the recoverability
+from the condition causing the message and where to display the message
+is specified in
+.Fa classification.
+.Ss classification
+The
+.Fa classification
+argument consists of a major classification and several sub-classifications.
+It has no effect on the content of the message displayed.
+With the exception of the display sub-classification, only a single identifier
+may be specified for each (sub-)classification.  The following classifications
+are available:
+.Bl -tag -width MessageXSourceXSub-classificationsXX
+.It Major Classifications
+The source of the condition.  Available identifiers are:
+.Dv MM_HARD
+(hardware),
+.Dv MM_SOFT
+(software), and
+.Dv MM_FIRM
+(firmware).
+.It Message Source Sub-classifications
+The type of software detecting the condition.  Available identifiers are:
+.Dv MM_APPL
+(application),
+.Dv MM_UTIL
+(utility), and
+.Dv MM_OPSYS
+(operating system).
+.It Display Sub-classifications
+The displays the formatted messages is to be written to.
+Available identifiers are:
+.Dv MM_PRINT
+(standard error stream) and
+.Dv MM_CONSOLE
+(system console).
+.It Status Sub-classifications
+The capability of the calling software to recover from the condition.
+Available identifiers are:
+.Dv MM_RECOVER
+(recoverable) and
+.Dv MM_NRECOV
+(non-recoverable).
+.El
+.Pp
+If no
+.Fa classification
+is to be supplied,
+.Dv MM_NULLMC
+must be specified.
+.Ss label
+The
+.Fa label
+argument identifies the source of the message.  It consists of two fields
+separated by a colon (:).  The first field is up to 10 characters, the second
+is up to 14 characters.
+.Pp
+If no
+.Fa label
+is to be supplied,
+.Dv MM_NULLLBL
+must be specified.
+.Ss severity
+The seriousness of the condition causing the message.
+The following
+.Fa severity
+levels are available:
+.Bl -tag -width MM_WARNINGXX
+.It Dv MM_HALT
+The software has encountered a severe fault and is halting.
+.It Dv MM_ERROR
+The software has encountered a fault.
+.It Dv MM_WARNING
+The software has encountered an unusual non-fault condition.
+.It Dv MM_INFO
+The software informs about a non-error condition.
+.El
+.Pp
+If no
+.Fa severity
+level is to be supplied,
+.Dv MM_NOSEV
+must be specified.
+.Ss text



Home | Main Index | Thread Index | Old Index