summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
authorJason King <jason.king@joyent.com>2018-02-16 16:21:53 +0000
committerDan McDonald <danmcd@joyent.com>2018-08-28 10:23:33 -0400
commit500cf85b0395b6835818b6248681bbbc27563dc1 (patch)
tree2ea59ada8aeeeb746404c53003cfad37d9331077 /usr/src/lib
parentf8e0ecf7cceff807dcd13fe031936e1ff28193e3 (diff)
downloadillumos-gate-500cf85b0395b6835818b6248681bbbc27563dc1.tar.gz
9762 Split the custr functions into their own library
Reviewed by: Igor Kozhukhov <igor@dilos.org> Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Yuri Pankov <yuripv@yuripv.net> Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/Makefile2
-rw-r--r--usr/src/lib/libcmdutils/Makefile.com3
-rw-r--r--usr/src/lib/libcmdutils/common/mapfile-vers21
-rw-r--r--usr/src/lib/libcmdutils/libcmdutils.h56
-rw-r--r--usr/src/lib/libcustr/Makefile43
-rw-r--r--usr/src/lib/libcustr/Makefile.com40
-rw-r--r--usr/src/lib/libcustr/amd64/Makefile19
-rw-r--r--usr/src/lib/libcustr/common/custr.c (renamed from usr/src/lib/libcmdutils/common/custr.c)5
-rw-r--r--usr/src/lib/libcustr/common/libcustr.h82
-rw-r--r--usr/src/lib/libcustr/common/llib-lcustr20
-rw-r--r--usr/src/lib/libcustr/common/mapfile-vers46
-rw-r--r--usr/src/lib/libcustr/i386/Makefile18
-rw-r--r--usr/src/lib/libcustr/sparc/Makefile18
-rw-r--r--usr/src/lib/libcustr/sparcv9/Makefile19
14 files changed, 324 insertions, 68 deletions
diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile
index 90cffe62f7..21a3bde545 100644
--- a/usr/src/lib/Makefile
+++ b/usr/src/lib/Makefile
@@ -105,6 +105,7 @@ SUBDIRS += \
libcryptoutil \
libctf \
libcurses \
+ libcustr \
libdevice \
libdevid \
libdevinfo \
@@ -377,6 +378,7 @@ HDRSUBDIRS= \
libcryptoutil \
libctf \
libcurses \
+ libcustr \
libdevice \
libdevid \
libdevinfo \
diff --git a/usr/src/lib/libcmdutils/Makefile.com b/usr/src/lib/libcmdutils/Makefile.com
index 9cb35f8795..72e7330eba 100644
--- a/usr/src/lib/libcmdutils/Makefile.com
+++ b/usr/src/lib/libcmdutils/Makefile.com
@@ -21,12 +21,13 @@
#
# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013 RackTop Systems.
+# Copyright 2018, Joyent, Inc.
#
LIBRARY= libcmdutils.a
VERS= .1
CMD_OBJS= avltree.o sysattrs.o writefile.o process_xattrs.o uid.o gid.o \
- custr.o nicenum.o
+ nicenum.o
COM_OBJS= list.o
OBJECTS= $(CMD_OBJS) $(COM_OBJS)
diff --git a/usr/src/lib/libcmdutils/common/mapfile-vers b/usr/src/lib/libcmdutils/common/mapfile-vers
index 0ac77eb010..2a3e95f95c 100644
--- a/usr/src/lib/libcmdutils/common/mapfile-vers
+++ b/usr/src/lib/libcmdutils/common/mapfile-vers
@@ -21,6 +21,7 @@
#
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013 RackTop Systems.
+# Copyright 2018, Joyent, Inc.
#
#
@@ -42,16 +43,16 @@ $mapfile_version 2
SYMBOL_VERSION SUNWprivate_1.1 {
global:
add_tnode;
- custr_alloc;
- custr_alloc_buf;
- custr_append;
- custr_appendc;
- custr_append_printf;
- custr_append_vprintf;
- custr_cstr;
- custr_free;
- custr_len;
- custr_reset;
+ custr_alloc { TYPE = FUNCTION; FILTER = libcustr.so.1 };
+ custr_alloc_buf { TYPE = FUNCTION; FILTER = libcustr.so.1 };
+ custr_append { TYPE = FUNCTION; FILTER = libcustr.so.1 };
+ custr_appendc { TYPE = FUNCTION; FILTER = libcustr.so.1 };
+ custr_append_printf { TYPE = FUNCTION; FILTER = libcustr.so.1 };
+ custr_append_vprintf { TYPE = FUNCTION; FILTER = libcustr.so.1 };
+ custr_cstr { TYPE = FUNCTION; FILTER = libcustr.so.1 };
+ custr_free { TYPE = FUNCTION; FILTER = libcustr.so.1 };
+ custr_len { TYPE = FUNCTION; FILTER = libcustr.so.1 };
+ custr_reset { TYPE = FUNCTION; FILTER = libcustr.so.1 };
destroy_tree;
findnextgid;
findnextuid;
diff --git a/usr/src/lib/libcmdutils/libcmdutils.h b/usr/src/lib/libcmdutils/libcmdutils.h
index 5f9957b861..c9a61aab4d 100644
--- a/usr/src/lib/libcmdutils/libcmdutils.h
+++ b/usr/src/lib/libcmdutils/libcmdutils.h
@@ -26,7 +26,7 @@
* Copyright (c) 2013 RackTop Systems.
*/
/*
- * Copyright 2017 Joyent, Inc.
+ * Copyright 2018 Joyent, Inc.
*/
/*
@@ -162,60 +162,6 @@ extern int findnextuid(uid_t, uid_t, uid_t *);
*/
extern int findnextgid(gid_t, gid_t, gid_t *);
-
-
- /* dynamic string utilities */
-
-typedef struct custr custr_t;
-
-/*
- * Allocate and free a "custr_t" dynamic string object. Returns 0 on success
- * and -1 otherwise.
- */
-extern int custr_alloc(custr_t **);
-extern void custr_free(custr_t *);
-
-/*
- * Allocate a "custr_t" dynamic string object that operates on a fixed external
- * buffer.
- */
-extern int custr_alloc_buf(custr_t **, void *, size_t);
-
-/*
- * Append a single character, or a NUL-terminated string of characters, to a
- * dynamic string. Returns 0 on success and -1 otherwise. The dynamic string
- * will be unmodified if the function returns -1.
- */
-extern int custr_appendc(custr_t *, char);
-extern int custr_append(custr_t *, const char *);
-
-/*
- * Append a format string and arguments as though the contents were being parsed
- * through snprintf. Returns 0 on success and -1 otherwise. The dynamic string
- * will be unmodified if the function returns -1.
- */
-extern int custr_append_printf(custr_t *, const char *, ...);
-extern int custr_append_vprintf(custr_t *, const char *, va_list);
-
-/*
- * Determine the length in bytes, not including the NUL terminator, of the
- * dynamic string.
- */
-extern size_t custr_len(custr_t *);
-
-/*
- * Clear the contents of a dynamic string. Does not free the underlying
- * memory.
- */
-extern void custr_reset(custr_t *);
-
-/*
- * Retrieve a const pointer to a NUL-terminated string version of the contents
- * of the dynamic string. Storage for this string should not be freed, and
- * the pointer will be invalidated by any mutations to the dynamic string.
- */
-extern const char *custr_cstr(custr_t *str);
-
#define NN_DIVISOR_1000 (1U << 0)
/* Minimum size for the output of nicenum, including NULL */
diff --git a/usr/src/lib/libcustr/Makefile b/usr/src/lib/libcustr/Makefile
new file mode 100644
index 0000000000..19b08dc521
--- /dev/null
+++ b/usr/src/lib/libcustr/Makefile
@@ -0,0 +1,43 @@
+#
+# 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 2018, Joyent, Inc.
+#
+
+include $(SRC)/lib/Makefile.lib
+
+HDRS = libcustr.h
+HDRDIR = common
+
+SUBDIRS = $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+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)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include $(SRC)/lib/Makefile.targ
diff --git a/usr/src/lib/libcustr/Makefile.com b/usr/src/lib/libcustr/Makefile.com
new file mode 100644
index 0000000000..cbd61ece4b
--- /dev/null
+++ b/usr/src/lib/libcustr/Makefile.com
@@ -0,0 +1,40 @@
+#
+# 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 2018, Joyent, Inc.
+#
+
+LIBRARY = libcustr.a
+VERS = .1
+OBJECTS = custr.o
+
+include $(SRC)/lib/Makefile.lib
+
+# On some illumos distributions (e.g. SmartOS), utilities in /sbin require
+# custr. Place libcustr in /lib so such distros can work even if /usr is
+# split onto its own filesystem.
+include $(SRC)/lib/Makefile.rootfs
+
+LIBS = $(DYNLIB) $(LINTLIB)
+LDLIBS += -lc
+CPPFLAGS += -D__EXTENSIONS__
+
+SRCDIR = ../common
+$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+lint: lintcheck
+
+include $(SRC)/lib/Makefile.targ
diff --git a/usr/src/lib/libcustr/amd64/Makefile b/usr/src/lib/libcustr/amd64/Makefile
new file mode 100644
index 0000000000..4b3c5dd187
--- /dev/null
+++ b/usr/src/lib/libcustr/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 2018, Joyent, Inc.
+#
+
+include ../Makefile.com
+include $(SRC)/lib/Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libcmdutils/common/custr.c b/usr/src/lib/libcustr/common/custr.c
index 95d44e431f..5c5b0e370a 100644
--- a/usr/src/lib/libcmdutils/common/custr.c
+++ b/usr/src/lib/libcustr/common/custr.c
@@ -14,17 +14,18 @@
*/
/*
- * Copyright 2016 Joyent, Inc.
+ * Copyright 2018 Joyent, Inc.
*/
#include <stdlib.h>
#include <err.h>
+#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/debug.h>
-#include "libcmdutils.h"
+#include "libcustr.h"
typedef enum {
CUSTR_FIXEDBUF = 0x01
diff --git a/usr/src/lib/libcustr/common/libcustr.h b/usr/src/lib/libcustr/common/libcustr.h
new file mode 100644
index 0000000000..7671390d7f
--- /dev/null
+++ b/usr/src/lib/libcustr/common/libcustr.h
@@ -0,0 +1,82 @@
+/*
+ * 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 2018, Joyent, Inc.
+ */
+
+#ifndef _LIBCUSTR_H
+#define _LIBCUSTR_H
+
+#include <stdarg.h>
+#include <sys/types.h>
+
+/* dynamic string utilities */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct custr custr_t;
+
+/*
+ * Allocate and free a "custr_t" dynamic string object. Returns 0 on success
+ * and -1 otherwise.
+ */
+int custr_alloc(custr_t **);
+void custr_free(custr_t *);
+
+/*
+ * Allocate a "custr_t" dynamic string object that operates on a fixed external
+ * buffer.
+ */
+int custr_alloc_buf(custr_t **, void *, size_t);
+
+/*
+ * Append a single character, or a NUL-terminated string of characters, to a
+ * dynamic string. Returns 0 on success and -1 otherwise. The dynamic string
+ * will be unmodified if the function returns -1.
+ */
+int custr_appendc(custr_t *, char);
+int custr_append(custr_t *, const char *);
+
+/*
+ * Append a format string and arguments as though the contents were being parsed
+ * through snprintf. Returns 0 on success and -1 otherwise. The dynamic string
+ * will be unmodified if the function returns -1.
+ */
+int custr_append_printf(custr_t *, const char *, ...);
+int custr_append_vprintf(custr_t *, const char *, va_list);
+
+/*
+ * Determine the length in bytes, not including the NUL terminator, of the
+ * dynamic string.
+ */
+size_t custr_len(custr_t *);
+
+/*
+ * Clear the contents of a dynamic string. Does not free the underlying
+ * memory.
+ */
+void custr_reset(custr_t *);
+
+/*
+ * Retrieve a const pointer to a NUL-terminated string version of the contents
+ * of the dynamic string. Storage for this string should not be freed, and
+ * the pointer will be invalidated by any mutations to the dynamic string.
+ */
+const char *custr_cstr(custr_t *str);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBCUSTR_H */
diff --git a/usr/src/lib/libcustr/common/llib-lcustr b/usr/src/lib/libcustr/common/llib-lcustr
new file mode 100644
index 0000000000..61a1885c85
--- /dev/null
+++ b/usr/src/lib/libcustr/common/llib-lcustr
@@ -0,0 +1,20 @@
+/*
+ * 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 2018, Joyent, Inc.
+ */
+
+/*LINTLIBRARY*/
+/*PROTOLIB1*/
+
+#include <sys/debug.h>
+#include <libcustr.h>
diff --git a/usr/src/lib/libcustr/common/mapfile-vers b/usr/src/lib/libcustr/common/mapfile-vers
new file mode 100644
index 0000000000..369771929a
--- /dev/null
+++ b/usr/src/lib/libcustr/common/mapfile-vers
@@ -0,0 +1,46 @@
+#
+# 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 2018, Joyent, 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:
+ custr_alloc;
+ custr_alloc_buf;
+ custr_append;
+ custr_appendc;
+ custr_append_printf;
+ custr_append_vprintf;
+ custr_cstr;
+ custr_free;
+ custr_len;
+ custr_reset;
+ local:
+ *;
+};
diff --git a/usr/src/lib/libcustr/i386/Makefile b/usr/src/lib/libcustr/i386/Makefile
new file mode 100644
index 0000000000..f32d7a5b91
--- /dev/null
+++ b/usr/src/lib/libcustr/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 2018, Joyent, Inc.
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libcustr/sparc/Makefile b/usr/src/lib/libcustr/sparc/Makefile
new file mode 100644
index 0000000000..f32d7a5b91
--- /dev/null
+++ b/usr/src/lib/libcustr/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 2018, Joyent, Inc.
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libcustr/sparcv9/Makefile b/usr/src/lib/libcustr/sparcv9/Makefile
new file mode 100644
index 0000000000..4b3c5dd187
--- /dev/null
+++ b/usr/src/lib/libcustr/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 2018, Joyent, Inc.
+#
+
+include ../Makefile.com
+include $(SRC)/lib/Makefile.lib.64
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)