diff options
Diffstat (limited to 'usr/src')
32 files changed, 638 insertions, 49 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile index a3afee1f15..b9307b48cc 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile +++ b/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile @@ -32,7 +32,7 @@ include ../../../Makefile.cmd include ../../../Makefile.ctf include ../../Makefile.cmd-inet -LDLIBS += -lcmdutils -lsocket -lnsl -lilb -linetutil -lkstat +LDLIBS += -lcmdutils -lsocket -lnsl -lilb -lkstat -lofmt CPPFLAGS += -I$(SRC)/lib/libilb/common -I$(SRC)/uts/common CERRWARN += -_gcc=-Wno-switch diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/Makefile index 57ae86b9e6..2a44c5b6aa 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/Makefile +++ b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/Makefile @@ -27,7 +27,7 @@ PROG = ipadm ROOTFS_PROG = $(PROG) LOCALOBJS= ipadm.o -COMMONOBJS= +COMMONOBJS= OBJS= $(LOCALOBJS) $(COMMONOBJS) include ../../../Makefile.cmd @@ -41,7 +41,7 @@ SRCS= $(LOCALSRCS) $(COMMONSRCS) CPPFLAGS += -I$(CMDINETCOMMONDIR) CERRWARN += -_gcc=-Wno-unused-label CERRWARN += -_gcc=-Wno-uninitialized -LDLIBS += -linetutil -lipadm -lnvpair +LDLIBS += -lofmt -linetutil -lipadm -lnvpair LINTFLAGS += -m ROOTUSRSBINLINKS = $(PROG:%=$(ROOTUSRSBIN)/%) diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipmpstat/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/ipmpstat/Makefile index f070273015..a15c3fce80 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ipmpstat/Makefile +++ b/usr/src/cmd/cmd-inet/usr.sbin/ipmpstat/Makefile @@ -30,7 +30,7 @@ include $(SRC)/cmd/Makefile.cmd C99MODE = $(C99_ENABLE) CERRWARN += -_gcc=-Wno-uninitialized -LDLIBS += -lipmp -lsocket -lsysevent -lnvpair -linetutil +LDLIBS += -lipmp -lsocket -lsysevent -lnvpair -lofmt XGETFLAGS += -a -x $(PROG).xcl .KEEP_STATE: diff --git a/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/Makefile index 87c91b39eb..00c4998b2b 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/Makefile +++ b/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/Makefile @@ -31,7 +31,7 @@ PROG= nwamadm include ../../../Makefile.cmd XGETFLAGS += -a -x $(PROG).xcl -LDLIBS += -linetutil -lnsl -lnwam -lumem -lscf +LDLIBS += -lofmt -linetutil -lnsl -lnwam -lumem -lscf CERRWARN += -_gcc=-Wno-switch CERRWARN += -_gcc=-Wno-uninitialized diff --git a/usr/src/cmd/dladm/Makefile b/usr/src/cmd/dladm/Makefile index 43f24b484f..1eeede7152 100644 --- a/usr/src/cmd/dladm/Makefile +++ b/usr/src/cmd/dladm/Makefile @@ -38,7 +38,7 @@ include $(SRC)/cmd/Makefile.ctf XGETFLAGS += -a -x $(PROG).xcl LDLIBS += -L$(ROOT)/lib -lsocket -LDLIBS += -ldladm -ldlpi -lkstat -lsecdb -lbsm -linetutil -ldevinfo +LDLIBS += -ldladm -ldlpi -lkstat -lsecdb -lbsm -lofmt -linetutil -ldevinfo LDLIBS += $(ZLAZYLOAD) -lrstp $(ZNOLAZYLOAD) CERRWARN += -_gcc=-Wno-switch diff --git a/usr/src/cmd/dlstat/Makefile b/usr/src/cmd/dlstat/Makefile index c37982a686..c24ce1a62d 100644 --- a/usr/src/cmd/dlstat/Makefile +++ b/usr/src/cmd/dlstat/Makefile @@ -37,11 +37,11 @@ CERRWARN += -_gcc=-Wno-uninitialized XGETFLAGS += -a -x $(PROG).xcl LDLIBS += -L$(ROOT)/lib -LDLIBS += -ldladm -linetutil +LDLIBS += -ldladm -lofmt .KEEP_STATE: -all: $(ROOTFS_PROG) +all: $(ROOTFS_PROG) install: all $(ROOTSBINPROG) $(RM) $(ROOTUSRSBINPROG) diff --git a/usr/src/cmd/flowadm/Makefile b/usr/src/cmd/flowadm/Makefile index 19a15a1b47..24362b698a 100644 --- a/usr/src/cmd/flowadm/Makefile +++ b/usr/src/cmd/flowadm/Makefile @@ -23,7 +23,7 @@ # Use is subject to license terms. # -PROG=flowadm +PROG=flowadm ROOTFS_PROG= $(PROG) @@ -34,7 +34,7 @@ include ../Makefile.cmd XGETFLAGS += -a -x $(PROG).xcl LDLIBS += -L$(ROOT)/lib -LDLIBS += -ldladm -linetutil +LDLIBS += -ldladm -lofmt ROOTCFGDIR= $(ROOTETC)/dladm ROOTCFGFILES= $(CONFIGFILES:%=$(ROOTCFGDIR)/%) @@ -43,7 +43,7 @@ $(ROOTCFGFILES):= FILEMODE= 644 .KEEP_STATE: -all: $(ROOTFS_PROG) +all: $(ROOTFS_PROG) # # Message catalog diff --git a/usr/src/cmd/flowstat/Makefile b/usr/src/cmd/flowstat/Makefile index 7e0ee8bfb2..e9efa364e0 100644 --- a/usr/src/cmd/flowstat/Makefile +++ b/usr/src/cmd/flowstat/Makefile @@ -23,7 +23,7 @@ # Use is subject to license terms. # -PROG=flowstat +PROG=flowstat ROOTFS_PROG= $(PROG) @@ -33,7 +33,7 @@ include ../Makefile.cmd XGETFLAGS += -a -x $(PROG).xcl LDLIBS += -L$(ROOT)/lib -LDLIBS += -ldladm -linetutil +LDLIBS += -ldladm -lofmt CERRWARN += -_gcc=-Wno-implicit-function-declaration CERRWARN += -_gcc=-Wno-uninitialized @@ -42,7 +42,7 @@ ROOTCFGDIR= $(ROOTETC)/dladm .KEEP_STATE: -all: $(ROOTFS_PROG) +all: $(ROOTFS_PROG) # # Message catalog diff --git a/usr/src/cmd/mandoc/lib.in b/usr/src/cmd/mandoc/lib.in index b083172c2d..79f249fb5f 100644 --- a/usr/src/cmd/mandoc/lib.in +++ b/usr/src/cmd/mandoc/lib.in @@ -53,6 +53,7 @@ LINE("libmp", "Multiple Precision Library (libmp, -lmp)") LINE("libmpapi", "Common Multipath Management Library (libmpapi, -lMPAPI)") LINE("libnsl", "Network Services Library (libnsl, \\-lnsl)") LINE("libnvpair", "Name-Value Pair Library (libnvpair, \\-lnvpair)") +LINE("libofmt", "Formatted output library (libofmt, \\-lofmt)") LINE("libpam", "PAM (Pluggable Authentication Module) Library (libpam, \\-lpam)") LINE("libpicl", "PICL Library (libpicl, \\-lpicl)") LINE("libpicltree", "PICL Plug-In Library (libpicltree, \\-lpicltree)") diff --git a/usr/src/cmd/mandoc/msec.in b/usr/src/cmd/mandoc/msec.in index c47dff6112..10861ddd07 100644 --- a/usr/src/cmd/mandoc/msec.in +++ b/usr/src/cmd/mandoc/msec.in @@ -62,6 +62,7 @@ LINE("3MP", "Multiple Precision Library Functions") LINE("3MPAPI", "Common Multipath Management Library Functions") LINE("3NSL", "Networking Services Library Functions") LINE("3NVPAIR", "Name-value Pair Library Functions") +LINE("3OFMT", "Formatted Output Functions") LINE("3PAM", "PAM Library Functions") LINE("3PAPI", "PAPI Library Functions") LINE("3PERL", "Perl Library Functions") diff --git a/usr/src/cmd/vrrpadm/Makefile b/usr/src/cmd/vrrpadm/Makefile index c63a09589d..61167ab1cb 100644 --- a/usr/src/cmd/vrrpadm/Makefile +++ b/usr/src/cmd/vrrpadm/Makefile @@ -28,13 +28,13 @@ PROG= vrrpadm include ../Makefile.cmd XGETFLAGS += -a -x $(PROG).xcl -LDLIBS += -lvrrpadm -lnsl -linetutil +LDLIBS += -lvrrpadm -lnsl -lofmt CERRWARN += -_gcc=-Wno-unused-label .KEEP_STATE: -all: $(PROG) +all: $(PROG) install: all $(ROOTUSRSBINPROG) diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile index 05de71f42d..36367793ac 100644 --- a/usr/src/lib/Makefile +++ b/usr/src/lib/Makefile @@ -168,6 +168,7 @@ SUBDIRS += \ libnls \ libnsctl \ libnwam \ + libofmt \ libpam \ libpcidb \ libpctx \ @@ -316,7 +317,6 @@ MSGSUBDIRS= \ libgss \ libidmap \ libilb \ - libinetutil \ libinstzones \ libipadm \ libipmp \ @@ -324,6 +324,7 @@ MSGSUBDIRS= \ libldap5 \ libnsl \ libnwam \ + libofmt \ libpam \ libpicl \ libpkg \ @@ -427,6 +428,7 @@ HDRSUBDIRS= \ libnsl \ libnvpair \ libnwam \ + libofmt \ libpam \ libpcidb \ libpctx \ diff --git a/usr/src/lib/libinetutil/Makefile b/usr/src/lib/libinetutil/Makefile index 0bc13a5c87..1d1ed69ccd 100644 --- a/usr/src/lib/libinetutil/Makefile +++ b/usr/src/lib/libinetutil/Makefile @@ -26,15 +26,11 @@ include ../Makefile.lib -HDRS = libinetutil.h ofmt.h +HDRS = libinetutil.h HDRDIR = common SUBDIRS = $(MACH) $(BUILD64)SUBDIRS += $(MACH64) -POFILE = libinetutil.po -MSGFILES = common/ofmt.c -XGETFLAGS = -a - all := TARGET = all clean := TARGET = clean clobber := TARGET = clobber @@ -49,15 +45,9 @@ install_h: $(ROOTHDRS) check: $(CHECKHDRS) -$(POFILE): $(MSGFILES) - $(BUILDPO.msgfiles) - -_msg: $(MSGDOMAINPOFILE) - $(SUBDIRS): FRC @cd $@; pwd; $(MAKE) $(TARGET) FRC: -include $(SRC)/Makefile.msg.targ include ../Makefile.targ diff --git a/usr/src/lib/libinetutil/Makefile.com b/usr/src/lib/libinetutil/Makefile.com index e866d1c434..d22ab84726 100644 --- a/usr/src/lib/libinetutil/Makefile.com +++ b/usr/src/lib/libinetutil/Makefile.com @@ -25,8 +25,7 @@ LIBRARY = libinetutil.a VERS = .1 -OBJECTS = octet.o inetutil.o ifspec.o ifaddrlist.o ifaddrlistx.o eh.o tq.o \ - ofmt.o +OBJECTS = octet.o inetutil.o ifspec.o ifaddrlist.o ifaddrlistx.o eh.o tq.o include ../../Makefile.lib @@ -39,8 +38,7 @@ SRCDIR = ../common COMDIR = $(SRC)/common/net/dhcp SRCS = $(COMDIR)/octet.c $(SRCDIR)/inetutil.c \ $(SRCDIR)/ifspec.c $(SRCDIR)/eh.c $(SRCDIR)/tq.c \ - $(SRCDIR)/ifaddrlist.c $(SRCDIR)/ifaddrlistx.c \ - $(SRCDIR)/ofmt.c + $(SRCDIR)/ifaddrlist.c $(SRCDIR)/ifaddrlistx.c $(LINTLIB):= SRCS = $(SRCDIR)/$(LINTSRC) LDLIBS += -lsocket -lc @@ -48,7 +46,6 @@ LDLIBS += -lsocket -lc CFLAGS += $(CCVERBOSE) CPPFLAGS += -I$(SRCDIR) -CERRWARN += -_gcc=-Wno-uninitialized CERRWARN += -_gcc=-Wno-parentheses .KEEP_STATE: diff --git a/usr/src/lib/libinetutil/common/llib-linetutil b/usr/src/lib/libinetutil/common/llib-linetutil index 9dd868fa9f..03504ac752 100644 --- a/usr/src/lib/libinetutil/common/llib-linetutil +++ b/usr/src/lib/libinetutil/common/llib-linetutil @@ -27,4 +27,3 @@ /* PROTOLIB1 */ #include <libinetutil.h> -#include <ofmt.h> diff --git a/usr/src/lib/libinetutil/common/mapfile-vers b/usr/src/lib/libinetutil/common/mapfile-vers index f47657c56e..a26d988990 100644 --- a/usr/src/lib/libinetutil/common/mapfile-vers +++ b/usr/src/lib/libinetutil/common/mapfile-vers @@ -63,11 +63,11 @@ SYMBOL_VERSION SUNWprivate_1.1 { iu_tq_destroy; iu_unregister_event; octet_to_hexascii; - ofmt_open; - ofmt_close; - ofmt_print; - ofmt_update_winsize; - ofmt_strerror; + ofmt_open { TYPE = FUNCTION; FILTER = libofmt.so.1 }; + ofmt_close { TYPE = FUNCTION; FILTER = libofmt.so.1 }; + ofmt_print { TYPE = FUNCTION; FILTER = libofmt.so.1 }; + ofmt_update_winsize { TYPE = FUNCTION; FILTER = libofmt.so.1 }; + ofmt_strerror { TYPE = FUNCTION; FILTER = libofmt.so.1 }; mask2plen; plen2mask; sockaddrcmp; diff --git a/usr/src/lib/libofmt/Makefile b/usr/src/lib/libofmt/Makefile new file mode 100644 index 0000000000..21bb7cdea8 --- /dev/null +++ b/usr/src/lib/libofmt/Makefile @@ -0,0 +1,52 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2017 Nexenta Systems, Inc. +# + +include $(SRC)/lib/Makefile.lib + +SUBDIRS= $(MACH) $(BUILD64) $(MACH64) + +HDRS= ofmt.h +HDRDIR= common + +POFILE= libofmt.po +MSGFILES= common/ofmt.c +XGETFLAGS= -a + +all := TARGET= all +clean := TARGET= clean +clobber := TARGET= clobber +install := TARGET= install +lint := TARGET= lint + +.KEEP_STATE: + +all clean clobber install lint: $(SUBDIRS) + +install_h: $(ROOTHDRS) + +check: $(CHECKHDRS) + +$(POFILE): $(MSGFILES) + $(BUILDPO.msgfiles) + +_msg: $(MSGDOMAINPOFILE) + +$(SUBDIRS): FRC + @cd $@; pwd; $(MAKE) $(TARGET) + +FRC: + +include $(SRC)/Makefile.msg.targ +include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/libofmt/Makefile.com b/usr/src/lib/libofmt/Makefile.com new file mode 100644 index 0000000000..1d27b92411 --- /dev/null +++ b/usr/src/lib/libofmt/Makefile.com @@ -0,0 +1,37 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2017 Nexenta Systems, Inc. +# + +LIBRARY= libofmt.a +VERS= .1 + +OBJECTS= ofmt.o + +include $(SRC)/lib/Makefile.lib +include $(SRC)/lib/Makefile.rootfs + +SRCDIR= ../common + +LIBS= $(DYNLIB) $(LINTLIB) +SRCS= $(SRCDIR)/ofmt.c + +LDLIBS += -lc + +.KEEP_STATE: + +all: $(LIBS) + +lint: lintcheck + +include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/libofmt/amd64/Makefile b/usr/src/lib/libofmt/amd64/Makefile new file mode 100644 index 0000000000..ea4e1ac4f2 --- /dev/null +++ b/usr/src/lib/libofmt/amd64/Makefile @@ -0,0 +1,19 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2017 Nexenta Systems, Inc. +# + +include ../Makefile.com +include $(SRC)/lib/Makefile.lib.64 + +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/lib/libofmt/common/llib-lofmt b/usr/src/lib/libofmt/common/llib-lofmt new file mode 100644 index 0000000000..3abbb9f946 --- /dev/null +++ b/usr/src/lib/libofmt/common/llib-lofmt @@ -0,0 +1,19 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2017 Nexenta Systems, Inc. + */ + +/* LINTLIBRARY */ +/* PROTOLIB1 */ + +#include <ofmt.h> diff --git a/usr/src/lib/libofmt/common/mapfile-vers b/usr/src/lib/libofmt/common/mapfile-vers new file mode 100644 index 0000000000..b2a87b3ecc --- /dev/null +++ b/usr/src/lib/libofmt/common/mapfile-vers @@ -0,0 +1,42 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2017 Nexenta Systems, Inc. +# + +# +# MAPFILE HEADER START +# +# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. +# Object versioning must comply with the rules detailed in +# +# usr/src/lib/README.mapfiles +# +# You should not be making modifications here until you've read the most current +# copy of that file. If you need help, contact a gatekeeper for guidance. +# +# MAPFILE HEADER END +# + +$mapfile_version 2 + +SYMBOL_VERSION ILLUMOSprivate { + global: + ofmt_close; + ofmt_open; + ofmt_print; + ofmt_strerror; + ofmt_update_winsize; + + local: + *; +}; diff --git a/usr/src/lib/libinetutil/common/ofmt.c b/usr/src/lib/libofmt/common/ofmt.c index 63d744cdc9..bab3da7311 100644 --- a/usr/src/lib/libinetutil/common/ofmt.c +++ b/usr/src/lib/libofmt/common/ofmt.c @@ -182,9 +182,9 @@ ofmt_open(const char *str, const ofmt_field_t *template, uint_t flags, uint_t i, j, of_index; const ofmt_field_t *ofp; ofmt_field_t *of; - ofmt_state_t *os; + ofmt_state_t *os = NULL; int nfields = 0; - ofmt_status_t err = OFMT_SUCCESS; + ofmt_status_t error = OFMT_SUCCESS; boolean_t parsable = (flags & OFMT_PARSABLE); boolean_t wrap = (flags & OFMT_WRAP); boolean_t multiline = (flags & OFMT_MULTILINE); @@ -247,7 +247,7 @@ ofmt_open(const char *str, const ofmt_field_t *template, uint_t flags, if (j == nfields) { int nbad = os->os_nbad++; - err = OFMT_EBADFIELDS; + error = OFMT_EBADFIELDS; if (os->os_badfields == NULL) { os->os_badfields = malloc(sp->s_nfields * sizeof (char *)); @@ -277,14 +277,14 @@ ofmt_open(const char *str, const ofmt_field_t *template, uint_t flags, return (OFMT_ENOFIELDS); os->os_nfields = of_index; /* actual number of fields printed */ ofmt_update_winsize(*ofmt); - return (err); + return (error); nomem: - err = OFMT_ENOMEM; + error = OFMT_ENOMEM; if (os != NULL) ofmt_close(os); *ofmt = NULL; splitfree(sp); - return (err); + return (error); } /* @@ -537,7 +537,8 @@ ofmt_update_winsize(ofmt_handle_t ofmt) * Return error diagnostics using the information in the ofmt_handle_t */ char * -ofmt_strerror(ofmt_handle_t ofmt, ofmt_status_t err, char *buf, uint_t bufsize) +ofmt_strerror(ofmt_handle_t ofmt, ofmt_status_t error, char *buf, + uint_t bufsize) { ofmt_state_t *os = ofmt; int i; @@ -551,7 +552,7 @@ ofmt_strerror(ofmt_handle_t ofmt, ofmt_status_t err, char *buf, uint_t bufsize) */ ebuf[0] = '\0'; - switch (err) { + switch (error) { case OFMT_SUCCESS: s = "success"; break; @@ -604,7 +605,7 @@ ofmt_strerror(ofmt_handle_t ofmt, ofmt_status_t err, char *buf, uint_t bufsize) default: (void) snprintf(buf, bufsize, dgettext(TEXT_DOMAIN, "unknown ofmt error (%d)"), - err); + error); return (buf); } (void) snprintf(buf, bufsize, dgettext(TEXT_DOMAIN, s)); diff --git a/usr/src/lib/libinetutil/common/ofmt.h b/usr/src/lib/libofmt/common/ofmt.h index e69d43e20a..e69d43e20a 100644 --- a/usr/src/lib/libinetutil/common/ofmt.h +++ b/usr/src/lib/libofmt/common/ofmt.h diff --git a/usr/src/lib/libofmt/i386/Makefile b/usr/src/lib/libofmt/i386/Makefile new file mode 100644 index 0000000000..d00779a2ee --- /dev/null +++ b/usr/src/lib/libofmt/i386/Makefile @@ -0,0 +1,18 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2017 Nexenta Systems, Inc. +# + +include ../Makefile.com + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/lib/libofmt/sparc/Makefile b/usr/src/lib/libofmt/sparc/Makefile new file mode 100644 index 0000000000..d00779a2ee --- /dev/null +++ b/usr/src/lib/libofmt/sparc/Makefile @@ -0,0 +1,18 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2017 Nexenta Systems, Inc. +# + +include ../Makefile.com + +install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff --git a/usr/src/lib/libofmt/sparcv9/Makefile b/usr/src/lib/libofmt/sparcv9/Makefile new file mode 100644 index 0000000000..ea4e1ac4f2 --- /dev/null +++ b/usr/src/lib/libofmt/sparcv9/Makefile @@ -0,0 +1,19 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2017 Nexenta Systems, Inc. +# + +include ../Makefile.com +include $(SRC)/lib/Makefile.lib.64 + +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/man/Makefile b/usr/src/man/Makefile index 74d27fb221..7bfd356b32 100644 --- a/usr/src/man/Makefile +++ b/usr/src/man/Makefile @@ -60,6 +60,7 @@ SUBDIRS= man1 \ man3nsl \ man3nvpair \ man3pam \ + man3ofmt \ man3papi \ man3perl \ man3picl \ diff --git a/usr/src/man/man3ofmt/Makefile b/usr/src/man/man3ofmt/Makefile new file mode 100644 index 0000000000..b89d88fb35 --- /dev/null +++ b/usr/src/man/man3ofmt/Makefile @@ -0,0 +1,38 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet +# at http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2017 Nexenta Systems, Inc. +# + +include $(SRC)/Makefile.master + +MANSECT= 3ofmt + +MANFILES= ofmt.3ofmt + +MANLINKS= ofmt_close.3ofmt \ + ofmt_open.3ofmt \ + ofmt_print.3ofmt \ + ofmt_strerror.3ofmt \ + ofmt_update_winsize.3ofmt + +ofmt_close.3ofmt := LINKSRC = ofmt.3ofmt +ofmt_open.3ofmt := LINKSRC = ofmt.3ofmt +ofmt_print.3ofmt := LINKSRC = ofmt.3ofmt +ofmt_strerror.3ofmt := LINKSRC = ofmt.3ofmt +ofmt_update_winsize.3ofmt := LINKSRC = ofmt.3ofmt + +.KEEP_STATE: + +include $(SRC)/man/Makefile.man + +install: $(ROOTMANFILES) $(ROOTMANLINKS) diff --git a/usr/src/man/man3ofmt/ofmt.3ofmt b/usr/src/man/man3ofmt/ofmt.3ofmt new file mode 100644 index 0000000000..99b431f014 --- /dev/null +++ b/usr/src/man/man3ofmt/ofmt.3ofmt @@ -0,0 +1,305 @@ +.\" +.\" This file and its contents are supplied under the terms of the +.\" Common Development and Distribution License ("CDDL"), version 1.0. +.\" You may only use this file in accordance with the terms of version +.\" 1.0 of the CDDL. +.\" +.\" A full copy of the text of the CDDL should have accompanied this +.\" source. A copy of the CDDL is also available via the Internet at +.\" http://www.illumos.org/license/CDDL. +.\" +.\" +.\" Copyright 2010 Sun Microsystems, Inc. All rights reserved. +.\" Copyright 2017 Nexenta Systems, Inc. +.\" +.Dd June 1, 2017 +.Dt OFMT 3OFMT +.Os +.Sh NAME +.Nm ofmt_open , +.Nm ofmt_print , +.Nm ofmt_update_winsize , +.Nm ofmt_strerror , +.Nm ofmt_close +.Nd data structures and routines for printing output +.Sh LIBRARY +.Lb libofmt +.Sh SYNOPSIS +.In ofmt.h +.Ft ofmt_status_t +.Fo ofmt_open +.Fa "const char *fields" +.Fa "const ofmt_field_t *template" +.Fa "uint_t flags" +.Fa "uint_t maxcols" +.Fa "ofmt_handle_t *ofmt" +.Fc +.Ft void +.Fo ofmt_print +.Fa "ofmt_handle_t ofmt" +.Fa "void *cbarg" +.Fc +.Ft void +.Fo ofmt_update_winsize +.Fa "ofmt_handle_t ofmt" +.Fc +.Ft "char *" +.Fo ofmt_strerror +.Fa "ofmt_handle_t ofmt" +.Fa "ofmt_status_t error" +.Fa "char *buf" +.Fa "uint_t bufsize" +.Fc +.Ft void +.Fo ofmt_close +.Fa "ofmt_handle_t ofmt" +.Fc +.Sh DESCRIPTION +The +.Nm libofmt +library provides data structures and routines for printing output. +.Pp +Currently this is an internal interface. +The interface can and will change without notice as the project needs, at any +time. +.Pp +All output is assumed to be in a columnar format, where each column represents +a field to be printed out. +Multiple fields in parsable output are separated by +.Sq \&: , +with the +.Sq \&: +character itself escaped by a +.Sq \e +.Po e.g., IPv6 addresses may be printed as +.Qq fe80\e:\e:1 +.Pc ; +single field output is printed as-is. +In multiline mode, every +.Bq field,value +pair is printed in a line of its own, thus: +.Qq field: value . +.Ss Data Structures +The +.Vt ofmt_field_t +data structure used in +.Sx ofmt_open +is defined as follows: +.Bd -literal +typedef struct ofmt_field_s { + char *of_name; /* column name */ + uint_t of_width; /* output column width */ + uint_t of_id; /* implementation specific cookie */ + ofmt_cb_t *of_cb; /* callback function defined by caller */ +} ofmt_field_t; +.Ed +.Pp +The +.Vt ofmt_arg_t +data structure which is passed to callback function is defined as follows: +.Bd -literal +typedef struct ofmt_arg_s { + uint_t ofmt_id; /* implementation specific cookie */ + uint_t ofmt_width; /* output column width */ + uint_t ofmt_index; /* unused */ + void *ofmt_cbarg; /* argument passed to ofmt_print() */ +} ofmt_arg_t; +.Ed +.Ss Fn ofmt_open +The +.Fn ofmt_open +function opens a handle returned in +.Fa ofmt +for each set of fields to be printed. +.Pp +.Fa fields +is a comma-separated list of the fields that have been selected for output +.Po typically the string passed to +.Fl o +in the command-line +.Pc . +Columns selected for output are identified by a match between the +.Va of_name +value in the +.Fa template +and the +.Fa fields +requested. +In human-friendly +.Pq non machine-parsable +mode, +.Dv NULL +.Fa fields , +or a value of +.Qq all +is treated as a request to print all allowable fields that fit other applicable +constraints. +.Pp +.Fa template +specifies the list of supported fields, along with formatting information +.Pq e.g., field width , +and a pointer to a callback function that can provide a string representation of +the value to be printed out. +The set of supported fields must be a +.Dv NULL +terminated array of type +.Vt ofmt_field_t , +described in +.Sx Data Structures , +as follows: +.Bd -literal -offset indent +{<of_name>, <of_width>, <of_id>, <of_cb> }, +\&.\&.\&. +{<of_name>, <of_width>, <of_id>, <of_cb> }, +{NULL, 0, 0, NULL} +.Ed +.Pp +.Va of_cb +is the application-specified callback function with the following prototype that +provides a string representation of the value to be printed for the field: +.Bd -literal -offset indent +(*of_cb)(ofmt_arg_t *ofmt_arg, char *buf, uint_t bufsize) +.Ed +.Pp +The interpretation of the +.Va of_id +field is completely private to the caller, and can be optionally used by the +callback function as a cookie to identify the field being printed when a single +callback function is shared between multiple +.Fa template +entries. +.Pp +The +.Fa flags +can be any valid combination of the following: +.Pp +.Bl -tag -width "OFMT_MULTILINE" -compact +.It Dv OFMT_PARSABLE +Machine-parsable mode. +Specifying a null or empty +.Va fields +in the machine-parsable mode will result in a returned error value of +.Dv OFMT_EPARSENONE . +An attempt to create a handle in machine-parsable mode with the +.Fa fields +set to +.Qq all +will result in a returned error value of +.Dv OFMT_EPARSEALL . +.It Dv OFMT_WRAP +Wrap output if field width is exceeded. +Currently output is wrapped at whitespace or comma characters. +.It Dv OFMT_MULTILINE +Multiline mode. +Specifying both +.Dv OFMT_MULTILINE +and +.Dv OFMT_PARSABLE +will result in +.Dv OFMT_EPARSEMULTI . +.It Dv OFMT_RIGHTJUST +Right justified output. +.El +.Pp +The non-zero +.Fa maxcols +limits the number of output columns. +.Ss Fn ofmt_print +The +.Fn ofmt_print +function prints a row of output. +.Pp +.Fa cbarg +points at the arguments to be passed to the callback function for each column in +the row. +The call to +.Fn ofmt_print +will result in the callback function of each selected field invoked with +.Va of_id , +.Va of_width +and +.Fa cbarg +embedded in +.Fa ofmt_arg , +described in +.Sx Data Structures . +.Pp +The callback function should fill +.Fa buf +with the string to be printed for the field using the data in +.Fa cbarg . +.Ss Fn ofmt_update_winsize +The +.Fn ofmt_update_winsize +function updates the window size information +.Pq which is initially computed when the handle is created +in the +.Fa ofmt . +If the +.Dv TIOCGWINSZ +ioctl fails, the window size is set to 80x24. +.Ss Fn ofmt_strerror +The +.Fn ofmt_strerror +function returns error diagnostics in +.Fa buf +using the information in the +.Fa ofmt +and +.Fa error . +.Pp +Using a +.Fa buf +size of +.Dv OFMT_BUFSIZE +is recommended. +.Ss Fn ofmt_close +The +.Fn ofmt_close +function frees any resources allocated for the handle after printing is +completed. +.Sh RETURN VALUES +If successful, the +.Fn ofmt_open +function will return +.Dv OFMT_SUCCESS , +with a non-null +.Fa ofmt_handle . +The function returns one of the failure codes +.Po enumerated in +.Vt ofmt_status_t +.Pc +listed below otherwise: +.Pp +.Bl -tag -width "OFMT_ENOTEMPLATE" -compact +.It Dv OFMT_ENOMEM +out of memory +.It Dv OFMT_EBADFIELDS +one or more bad fields with good fields +.It Dv OFMT_ENOFIELDS +no valid output fields +.It Dv OFMT_EPARSEALL +"all" is invalid in parsable mode +.It Dv OFMT_EPARSENONE +output fields missing in parsable mode +.It Dv OFMT_EPARSEWRAP +parsable mode incompatible with wrap mode +.It Dv OFMT_ENOTEMPLATE +no template provided for fields +.It Dv OFMT_EPARSEMULTI +parsable and multiline don't mix +.El +.Pp +More information about the type of failure can be obtained by calling +.Fn ofmt_strerror . +.Pp +The +.Fn ofmt_strerror +function returns the +.Fa buf . +.Sh INTERFACE STABILITY +.Sy Private . +.Sh SEE ALSO +.Xr ioctl 2 , +.Xr strerror 3C , +.Xr attributes 5 diff --git a/usr/src/pkg/manifests/developer-library-lint.mf b/usr/src/pkg/manifests/developer-library-lint.mf index 452abff215..c77e0ff388 100644 --- a/usr/src/pkg/manifests/developer-library-lint.mf +++ b/usr/src/pkg/manifests/developer-library-lint.mf @@ -73,6 +73,7 @@ file path=lib/$(ARCH64)/llib-lmd.ln file path=lib/$(ARCH64)/llib-lmd5.ln file path=lib/$(ARCH64)/llib-lnsl.ln file path=lib/$(ARCH64)/llib-lnvpair.ln +file path=lib/$(ARCH64)/llib-lofmt.ln file path=lib/$(ARCH64)/llib-lpam.ln file path=lib/$(ARCH64)/llib-lproc.ln file path=lib/$(ARCH64)/llib-lpthread.ln @@ -155,6 +156,8 @@ file path=lib/llib-lnvpair file path=lib/llib-lnvpair.ln file path=lib/llib-lnwam file path=lib/llib-lnwam.ln +file path=lib/llib-lofmt +file path=lib/llib-lofmt.ln file path=lib/llib-lpam file path=lib/llib-lpam.ln file path=lib/llib-lproc diff --git a/usr/src/pkg/manifests/system-library.man3ofmt.inc b/usr/src/pkg/manifests/system-library.man3ofmt.inc new file mode 100644 index 0000000000..f9e49c3c26 --- /dev/null +++ b/usr/src/pkg/manifests/system-library.man3ofmt.inc @@ -0,0 +1,21 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet +# at http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2017 Nexenta Systems, Inc. +# + +file path=usr/share/man/man3ofmt/ofmt.3ofmt +link path=usr/share/man/man3ofmt/ofmt_close.3ofmt target=ofmt.3ofmt +link path=usr/share/man/man3ofmt/ofmt_open.3ofmt target=ofmt.3ofmt +link path=usr/share/man/man3ofmt/ofmt_print.3ofmt target=ofmt.3ofmt +link path=usr/share/man/man3ofmt/ofmt_strerror.3ofmt target=ofmt.3ofmt +link path=usr/share/man/man3ofmt/ofmt_update_winsize.3ofmt target=ofmt.3ofmt diff --git a/usr/src/pkg/manifests/system-library.mf b/usr/src/pkg/manifests/system-library.mf index 06a7e9bab4..0ca8d3a587 100644 --- a/usr/src/pkg/manifests/system-library.mf +++ b/usr/src/pkg/manifests/system-library.mf @@ -23,7 +23,7 @@ # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved. # Copyright (c) 2013 Gary Mills -# Copyright 2014 Nexenta Systems, Inc. All rights reserved. +# Copyright 2017 Nexenta Systems, Inc. # <include system-library.man3.inc> @@ -53,6 +53,7 @@ <include system-library.man3mp.inc> <include system-library.man3nsl.inc> <include system-library.man3nvpair.inc> +<include system-library.man3ofmt.inc> <include system-library.man3pam.inc> <include system-library.man3proc.inc> <include system-library.man3project.inc> @@ -154,6 +155,7 @@ dir path=usr/share/man/man3malloc dir path=usr/share/man/man3mp dir path=usr/share/man/man3nsl dir path=usr/share/man/man3nvpair +dir path=usr/share/man/man3ofmt dir path=usr/share/man/man3pam dir path=usr/share/man/man3pool dir path=usr/share/man/man3proc @@ -214,6 +216,7 @@ file path=lib/$(ARCH64)/libmd5.so.1 file path=lib/$(ARCH64)/libmp.so.2 file path=lib/$(ARCH64)/libnsl.so.1 file path=lib/$(ARCH64)/libnvpair.so.1 +file path=lib/$(ARCH64)/libofmt.so.1 file path=lib/$(ARCH64)/libpam.so.1 file path=lib/$(ARCH64)/libproc.so.1 file path=lib/$(ARCH64)/libpthread.so.1 @@ -296,6 +299,7 @@ file path=lib/libmp.so.2 file path=lib/libnsl.so.1 file path=lib/libnvpair.so.1 file path=lib/libnwam.so.1 +file path=lib/libofmt.so.1 file path=lib/libpam.so.1 file path=lib/libproc.so.1 file path=lib/libpthread.so.1 @@ -639,6 +643,7 @@ link path=lib/$(ARCH64)/libmd5.so target=libmd5.so.1 link path=lib/$(ARCH64)/libmp.so target=libmp.so.2 link path=lib/$(ARCH64)/libnsl.so target=libnsl.so.1 link path=lib/$(ARCH64)/libnvpair.so target=libnvpair.so.1 +link path=lib/$(ARCH64)/libofmt.so target=libofmt.so.1 link path=lib/$(ARCH64)/libpam.so target=libpam.so.1 link path=lib/$(ARCH64)/libposix4.so target=libposix4.so.1 link path=lib/$(ARCH64)/libposix4.so.1 target=librt.so.1 @@ -706,6 +711,7 @@ link path=lib/libmp.so target=libmp.so.2 link path=lib/libnsl.so target=libnsl.so.1 link path=lib/libnvpair.so target=libnvpair.so.1 link path=lib/libnwam.so target=libnwam.so.1 +link path=lib/libofmt.so target=libofmt.so.1 link path=lib/libpam.so target=libpam.so.1 link path=lib/libposix4.so target=libposix4.so.1 link path=lib/libposix4.so.1 target=librt.so.1 |