aboutsummaryrefslogtreecommitdiff
path: root/archive
diff options
context:
space:
mode:
Diffstat (limited to 'archive')
-rw-r--r--archive/README16
-rw-r--r--archive/align_b4_memalign.c24
-rw-r--r--archive/llseek.c128
-rw-r--r--archive/llseek.h14
-rwxr-xr-xarchive/o_scsi_logging_level295
-rw-r--r--archive/sg_json_writer.c360
-rw-r--r--archive/sg_json_writer.h101
7 files changed, 0 insertions, 938 deletions
diff --git a/archive/README b/archive/README
deleted file mode 100644
index e0e32205..00000000
--- a/archive/README
+++ /dev/null
@@ -1,16 +0,0 @@
-The code and scripts in this directory may be removed at some later
-date. The last cleanup (i.e. purge of unused files) of this
-directory occurred between sg3_utils version 1.22 and 1.23 .
-No other code or script in this package currently uses the contents
-of this directory. The contents of this directory are not
-maintained by the author.
-
-The rescan-scsi-bus.sh script was copied long ago from
-http://www.garloff.de/kurt/linux (under the "Rescan SCSI bus"
-heading) and was later placed in this directory. Since others
-do use the version of this script found in this package then
-rescan-scsi-bus.sh was updated in sg3_utils version 1.35 and
-was moved to the scripts directory.
-
-Douglas Gilbert
-9th January 2013
diff --git a/archive/align_b4_memalign.c b/archive/align_b4_memalign.c
deleted file mode 100644
index 1cd4032d..00000000
--- a/archive/align_b4_memalign.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Code fragment of how to get a buffer from the heap that has a specific
- * alignment. The typical alignment is to a "page" whose size is often
- * 4096 bytes. */
-
- uint8_t * wrkBuff; /* will get pointer to heap allocation */
- uint8_t * wrkPos; /* will get aligned pointer within wrkBuff */
- uint32_t sz_of_aligned = 1234; /* number of aligned bytes required */
-
- int psz;
-
-#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
- psz = sysconf(_SC_PAGESIZE); /* POSIX.1 (was getpagesize()) */
-#else
- psz = 4096; /* give up, pick likely figure */
-#endif
-
-
- /* perhaps use posix_memalign() instead. Yes but not always available */
- wrkBuff = (uint8_t *)malloc(sz_of_aligned + psz);
- wrkPos = (uint8_t *)(((sg_uintptr_t)wrkBuff + psz - 1) & (~(psz - 1)));
-
-/* The disadvantage of this approach is that it needs both wrkBuff and wrkPos
- * to be held by the application. The wrkBuff is only needed for the
- * corresponding free(), all other uses should be via wrkPos. */
diff --git a/archive/llseek.c b/archive/llseek.c
deleted file mode 100644
index fcc53faa..00000000
--- a/archive/llseek.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * llseek.c -- stub calling the llseek system call
- *
- * Copyright (C) 1994 Remy Card. This file may be redistributed
- * under the terms of the GNU Public License.
- *
- * This file is borrowed from the util-linux-2.11z tarball's implementation
- * of fdisk. It allows seeks to 64 bit offsets, if supported.
- * Changed "ext2_" prefix to "llse".
- */
-
-#include "config.h"
-
-#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE
-
-#include <sys/types.h>
-
-#include <errno.h>
-#include <unistd.h>
-
-#if defined(__GNUC__) || defined(HAS_LONG_LONG)
-typedef int64_t llse_loff_t;
-#else
-typedef long llse_loff_t;
-#endif
-
-extern llse_loff_t llse_llseek (unsigned int, llse_loff_t, unsigned int);
-
-#ifdef __linux__
-
-#ifdef HAVE_LLSEEK
-#include <syscall.h>
-
-#else /* HAVE_LLSEEK */
-
-#if defined(__alpha__) || defined(__ia64__) || defined(__s390x__) || defined (__x86_64__) || defined (__powerpc64__)
-
-#define my_llseek lseek
-
-#else
-#include <linux/unistd.h> /* for __NR__llseek */
-
-static int _llseek (unsigned int, unsigned long,
- unsigned long, llse_loff_t *, unsigned int);
-
-#ifdef __NR__llseek
-
-static _syscall5(int,_llseek,unsigned int,fd,unsigned long,offset_high,
- unsigned long, offset_low,llse_loff_t *,result,
- unsigned int, origin)
-
-#else
-
-/* no __NR__llseek on compilation machine - might give it explicitly */
-static int _llseek (unsigned int fd, unsigned long oh,
- unsigned long ol, llse_loff_t *result,
- unsigned int origin) {
- errno = ENOSYS;
- return -1;
-}
-
-#endif
-
-static llse_loff_t my_llseek (unsigned int fd, llse_loff_t offset,
- unsigned int origin)
-{
- llse_loff_t result;
- int retval;
-
-#ifdef HAVE_LSEEK64
- return lseek64 (fd, offset, origin);
-#else
- retval = _llseek (fd, ((uint64_t) offset) >> 32,
- ((uint64_t) offset) & 0xffffffff,
- &result, origin);
- return (retval == -1 ? (llse_loff_t) retval : result);
-#endif
-}
-
-#endif /* __alpha__ */
-
-#endif /* HAVE_LLSEEK */
-
-llse_loff_t llse_llseek (unsigned int fd, llse_loff_t offset,
- unsigned int origin)
-{
- llse_loff_t result;
- static int do_compat = 0;
-
- if (!do_compat) {
- result = my_llseek (fd, offset, origin);
- if (!(result == -1 && errno == ENOSYS))
- return result;
-
- /*
- * Just in case this code runs on top of an old kernel
- * which does not support the llseek system call
- */
- do_compat = 1;
- /*
- * Now try ordinary lseek.
- */
- }
-
- if ((sizeof(off_t) >= sizeof(llse_loff_t)) ||
- (offset < ((llse_loff_t) 1 << ((sizeof(off_t)*8) -1))))
- return lseek(fd, (off_t) offset, origin);
-
- errno = EINVAL;
- return -1;
-}
-
-#else /* !linux */
-
-llse_loff_t llse_llseek (unsigned int fd, llse_loff_t offset,
- unsigned int origin)
-{
- if ((sizeof(off_t) < sizeof(llse_loff_t)) &&
- (offset >= ((llse_loff_t) 1 << ((sizeof(off_t)*8) -1)))) {
- errno = EINVAL;
- return -1;
- }
- return lseek (fd, (off_t) offset, origin);
-}
-
-#endif /* linux */
-
diff --git a/archive/llseek.h b/archive/llseek.h
deleted file mode 100644
index 61c12e43..00000000
--- a/archive/llseek.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef LLSEEK_H
-#define LLSEEK_H
-
-#if defined(__GNUC__) || defined(HAS_LONG_LONG)
-typedef int64_t llse_loff_t;
-#else
-typedef long llse_loff_t;
-#endif
-
-extern llse_loff_t llse_llseek(unsigned int fd,
- llse_loff_t offset,
- unsigned int origin);
-
-#endif
diff --git a/archive/o_scsi_logging_level b/archive/o_scsi_logging_level
deleted file mode 100755
index ecbc8277..00000000
--- a/archive/o_scsi_logging_level
+++ /dev/null
@@ -1,295 +0,0 @@
-#! /bin/bash
-###############################################################################
-# Conveniently create and set scsi logging level, show SCSI_LOG fields in human
-# readable form.
-#
-# Copyright (C) IBM Corp. 2006
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or (at
-# your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-###############################################################################
-
-# Contributed by Andreas Herrmann <aherrman@de.ibm.com> 2006/08/18
-
-SCRIPTNAME="scsi_logging_level"
-
-declare -i LOG_ERROR=0
-declare -i LOG_TIMEOUT=0
-declare -i LOG_SCAN=0
-declare -i LOG_MLQUEUE=0
-declare -i LOG_MLCOMPLETE=0
-declare -i LOG_LLQUEUE=0
-declare -i LOG_LLCOMPLETE=0
-declare -i LOG_HLQUEUE=0
-declare -i LOG_HLCOMPLETE=0
-declare -i LOG_IOCTL=0
-
-declare -i LEVEL=0
-
-_ERROR_SHIFT=0
-_TIMEOUT_SHIFT=3
-_SCAN_SHIFT=6
-_MLQUEUE_SHIFT=9
-_MLCOMPLETE_SHIFT=12
-_LLQUEUE_SHIFT=15
-_LLCOMPLETE_SHIFT=18
-_HLQUEUE_SHIFT=21
-_HLCOMPLETE_SHIFT=24
-_IOCTL_SHIFT=27
-
-SET=0
-GET=0
-CREATE=0
-
-OPTS=`getopt -o hvcgsa:E:T:S:I:M:L:H: --long \
-help,version,create,get,set,all:,error:,timeout:,scan:,ioctl:,\
-midlevel:,mlqueue:,mlcomplete:,lowlevel:,llqueue:,llcomplete:,\
-highlevel:,hlqueue:,hlcomplete: -n \'$SCRIPTNAME\' -- "$@"`
-eval set -- "$OPTS"
-
-# print version info
-printversion()
-{
- cat <<EOF
-$SCRIPTNAME (s390-tools) %S390_TOOLS_VERSION%
-(C) Copyright IBM Corp. 2006
-EOF
-}
-
-# print usage and help
-printhelp()
-{
- cat <<EOF
-Usage: $SCRIPTNAME [OPTIONS]
-
-Create, get or set scsi logging level.
-
-Options:
-
- -h, --help print this help
- -v, --version print version information
- -s, --set create and set logging level as specified on
- command line
- -g, --get get current logging level and display it
- -c, --create create logging level as specified on command line
- -a, --all specify value for all SCSI_LOG fields
- -E, --error specify SCSI_LOG_ERROR
- -T, --timeout specify SCSI_LOG_TIMEOUT
- -S, --scan specify SCSI_LOG_SCAN
- -M, --midlevel specify SCSI_LOG_MLQUEUE and SCSI_LOG_MLCOMPLETE
- --mlqueue specify SCSI_LOG_MLQUEUE
- --mlcomplete specify SCSI_LOG_MLCOMPLETE
- -L, --lowlevel specify SCSI_LOG_LLQUEUE and SCSI_LOG_LLCOMPLETE
- --llqueue specify SCSI_LOG_LLQUEUE
- --llcomplete specify SCSI_LOG_LLCOMPLETE
- -H, --highlevel specify SCSI_LOG_HLQUEUE and SCSI_LOG_HLCOMPLETE
- --hlqueue specify SCSI_LOG_HLQUEUE
- --hlcomplete specify SCSI_LOG_HLCOMPLETE
- -I, --ioctl specify SCSI_LOG_IOCTL
-
-Exactly one of the options "-c", "-g" and "-s" has to be specified.
-Valid values for SCSI_LOG fields are integers from 0 to 7.
-
-Note: Several SCSI_LOG fields can be specified using several options.
-When multiple options specify same SCSI_LOG field the most specific
-option has precedence.
-
-Example: "scsi_logging_level --hlqueue 3 --hlcomplete 2 --all 1 -s" sets
-SCSI_LOG_HLQUEUE=3, SCSI_LOG_HLCOMPLETE=2 and assigns all other SCSI_LOG
-fields the value 1.
-EOF
-}
-
-check_level()
-{
-# something is wrong with the following if ... dpg 20061027
-# if [ `echo -n $1 | tr --complement [:digit:] 'a' | grep -s 'a'` ]
-# then
-# invalid_cmdline "log level '$1' out of range [0, 7]"
-# fi
-
- if [ $1 -lt 0 -o $1 -gt 7 ]
- then
- invalid_cmdline "log level '$1' out of range [0, 7]"
- fi
-}
-
-# check cmd line arguments
-check_cmdline()
-{
- while true ; do
- case "$1" in
- -a|--all) _ALL=$2; check_level $2
- shift 2;;
- -c|--create) CREATE=1;
- shift 1;;
- -g|--get) GET=1
- shift 1;;
- -h|--help) printhelp
- exit 0;;
- -s|--set) SET=1
- shift 1;;
- -v|--version) printversion
- exit 0;;
- -E|--error) _ERROR=$2; check_level $2
- shift 2;;
- -T|--timeout) _TIMEOUT=$2; check_level $2
- shift 2;;
- -S|--scan) _SCAN=$2; check_level $2
- shift 2;;
- -M|--midlevel) _ML=$2; check_level $2
- shift 2;;
- --mlqueue) _MLQUEUE=$2; check_level $2
- shift 2;;
- --mlcomplete) _MLCOMPLETE=$2; check_level $2
- shift 2;;
- -L|--lowlevel) _LL=$2; check_level $2
- shift 2;;
- --llqueue) _LLQUEUE=$2; check_level $2
- shift 2;;
- --llcomplete) _LLCOMPLETE=$2; check_level $2
- shift 2;;
- -H|--highlevel) _HL=$2; check_level $2
- shift 2;;
- --hlqueue) _HLQUEUE=$2; check_level $2
- shift 2;;
- --hlcomplete) _HLCOMPLETE=$2; check_level $2
- shift 2;;
- -I|--ioctl) _IOCTL=$2; check_level $2
- shift 2;;
- --) shift; break;;
- *) echo "Internal error!" ; exit 1;;
- esac
- done
-
- if [ -n "$*" ]
- then
- invalid_cmdline invalid parameter $*
- fi
-
- if [ $GET = "1" -a $SET = "1" ]
- then
- invalid_cmdline options \'-c\', \'-g\' and \'-s\' are mutual exclusive
- elif [ $GET = "1" -a $CREATE = "1" ]
- then
- invalid_cmdline options \'-c\', \'-g\' and \'-s\' are mutual exclusive
- elif [ $SET = "1" -a $CREATE = "1" ]
- then
- invalid_cmdline options \'-c\', \'-g\' and \'-s\' are mutual exclusive
- fi
-
- LOG_ERROR=${_ERROR:-${_ALL:-0}}
- LOG_TIMEOUT=${_TIMEOUT:-${_ALL:-0}}
- LOG_SCAN=${_SCAN:-${_ALL:-0}}
- LOG_MLQUEUE=${_MLQUEUE:-${_ML:-${_ALL:-0}}}
- LOG_MLCOMPLETE=${_MLCOMPLETE:-${_ML:-${_ALL:-0}}}
- LOG_LLQUEUE=${_LLQUEUE:-${_LL:-${_ALL:-0}}}
- LOG_LLCOMPLETE=${_LLCOMPLETE:-${_LL:-${_ALL:-0}}}
- LOG_HLQUEUE=${_HLQUEUE:-${_HL:-${_ALL:-0}}}
- LOG_HLCOMPLETE=${_HLCOMPLETE:-${_HL:-${_ALL:-0}}}
- LOG_IOCTL=${_IOCTL:-${_ALL:-0}}
-}
-
-invalid_cmdline()
-{
- echo "$SCRIPTNAME: $*"
- echo "$SCRIPTNAME: Try '$SCRIPTNAME --help' for more information."
- exit 1
-}
-
-get_logging_level()
-{
- echo "Current scsi logging level:"
- LEVEL=`sysctl -n dev.scsi.logging_level`
- if [ $? != 0 ]
- then
- echo "$SCRIPTNAME: could not read scsi logging level" \
- "(kernel probably without SCSI_LOGGING support)"
- exit 1
- fi
-}
-
-show_logging_level()
-{
- echo "dev.scsi.logging_level = $LEVEL"
-
- LOG_ERROR=$((($LEVEL>>$_ERROR_SHIFT) & 7))
- LOG_TIMEOUT=$((($LEVEL>>$_TIMEOUT_SHIFT) & 7))
- LOG_SCAN=$((($LEVEL>>$_SCAN_SHIFT) & 7))
- LOG_MLQUEUE=$((($LEVEL>>$_MLQUEUE_SHIFT) & 7))
- LOG_MLCOMPLETE=$((($LEVEL>>$_MLCOMPLETE_SHIFT) & 7))
- LOG_LLQUEUE=$((($LEVEL>>$_LLQUEUE_SHIFT) & 7))
- LOG_LLCOMPLETE=$((($LEVEL>>$_LLCOMPLETE_SHIFT) & 7))
- LOG_HLQUEUE=$((($LEVEL>>$_HLQUEUE_SHIFT) & 7))
- LOG_HLCOMPLETE=$((($LEVEL>>$_HLCOMPLETE_SHIFT) & 7))
- LOG_IOCTL=$((($LEVEL>>$_IOCTL_SHIFT) & 7))
-
- echo "SCSI_LOG_ERROR=$LOG_ERROR"
- echo "SCSI_LOG_TIMEOUT=$LOG_TIMEOUT"
- echo "SCSI_LOG_SCAN=$LOG_SCAN"
- echo "SCSI_LOG_MLQUEUE=$LOG_MLQUEUE"
- echo "SCSI_LOG_MLCOMPLETE=$LOG_MLCOMPLETE"
- echo "SCSI_LOG_LLQUEUE=$LOG_LLQUEUE"
- echo "SCSI_LOG_LLCOMPLETE=$LOG_LLCOMPLETE"
- echo "SCSI_LOG_HLQUEUE=$LOG_HLQUEUE"
- echo "SCSI_LOG_HLCOMPLETE=$LOG_HLCOMPLETE"
- echo "SCSI_LOG_IOCTL=$LOG_IOCTL"
-}
-
-set_logging_level()
-{
- echo "New scsi logging level:"
- sysctl -q -w dev.scsi.logging_level=$LEVEL
- if [ $? != 0 ]
- then
- echo "$SCRIPTNAME: could not write scsi logging level" \
- "(kernel probably without SCSI_LOGGING support)"
- exit 1
- fi
-}
-
-create_logging_level()
-{
- LEVEL=$((($LOG_ERROR & 7)<<$_ERROR_SHIFT))
- LEVEL=$(($LEVEL|(($LOG_TIMEOUT & 7)<<$_TIMEOUT_SHIFT)))
- LEVEL=$(($LEVEL|(($LOG_SCAN & 7)<<$_SCAN_SHIFT)))
- LEVEL=$(($LEVEL|(($LOG_MLQUEUE & 7)<<$_MLQUEUE_SHIFT)))
- LEVEL=$(($LEVEL|(($LOG_MLCOMPLETE & 7)<<$_MLCOMPLETE_SHIFT)))
- LEVEL=$(($LEVEL|(($LOG_LLQUEUE & 7)<<$_LLQUEUE_SHIFT)))
- LEVEL=$(($LEVEL|(($LOG_LLCOMPLETE & 7)<<$_LLCOMPLETE_SHIFT)))
- LEVEL=$(($LEVEL|(($LOG_HLQUEUE & 7)<<$_HLQUEUE_SHIFT)))
- LEVEL=$(($LEVEL|(($LOG_HLCOMPLETE & 7)<<$_HLCOMPLETE_SHIFT)))
- LEVEL=$(($LEVEL|(($LOG_IOCTL & 7)<<$_IOCTL_SHIFT)))
-}
-
-check_cmdline $*
-
-if [ $SET = "1" ]
-then
- create_logging_level
- set_logging_level
- show_logging_level
-elif [ $GET = "1" ]
-then
- get_logging_level
- show_logging_level
-elif [ $CREATE = "1" ]
-then
- create_logging_level
- show_logging_level
-else
- invalid_cmdline missing option \'-g\', \'-s\' or \'-c\'
-fi
-
diff --git a/archive/sg_json_writer.c b/archive/sg_json_writer.c
deleted file mode 100644
index bc1c7b16..00000000
--- a/archive/sg_json_writer.c
+++ /dev/null
@@ -1,360 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
-/*
- * Simple streaming JSON writer
- *
- * This takes care of the annoying bits of JSON syntax like the commas
- * after elements
- *
- * Authors: Stephen Hemminger <stephen@networkplumber.org>
- *
- * Borrowed from Linux kernel [5.17.0]: tools/bpf/bpftool/json_writer.[hc]
- */
-
-#include <stdio.h>
-#include <stdbool.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <malloc.h>
-#include <inttypes.h>
-#include <stdint.h>
-
-#include "sg_json_writer.h"
-
-struct json_writer {
- FILE *out; /* output file */
- unsigned depth; /* nesting */
- bool pretty; /* optional whitepace */
- char sep; /* either nul or comma */
-};
-
-/* indentation for pretty print */
-static void jsonw_indent(json_writer_t *self)
-{
- unsigned i;
- for (i = 0; i < self->depth; ++i)
- fputs(" ", self->out);
-}
-
-/* end current line and indent if pretty printing */
-static void jsonw_eol(json_writer_t *self)
-{
- if (!self->pretty)
- return;
-
- putc('\n', self->out);
- jsonw_indent(self);
-}
-
-/* If current object is not empty print a comma */
-static void jsonw_eor(json_writer_t *self)
-{
- if (self->sep != '\0')
- putc(self->sep, self->out);
- self->sep = ',';
-}
-
-
-/* Output JSON encoded string */
-/* Handles C escapes, does not do Unicode */
-static void jsonw_puts(json_writer_t *self, const char *str)
-{
- putc('"', self->out);
- for (; *str; ++str)
- switch (*str) {
- case '\t':
- fputs("\\t", self->out);
- break;
- case '\n':
- fputs("\\n", self->out);
- break;
- case '\r':
- fputs("\\r", self->out);
- break;
- case '\f':
- fputs("\\f", self->out);
- break;
- case '\b':
- fputs("\\b", self->out);
- break;
- case '\\':
- fputs("\\n", self->out);
- break;
- case '"':
- fputs("\\\"", self->out);
- break;
- case '\'':
- fputs("\\\'", self->out);
- break;
- default:
- putc(*str, self->out);
- }
- putc('"', self->out);
-}
-
-/* Create a new JSON stream */
-json_writer_t *jsonw_new(FILE *f)
-{
- json_writer_t *self = malloc(sizeof(*self));
- if (self) {
- self->out = f;
- self->depth = 0;
- self->pretty = false;
- self->sep = '\0';
- }
- return self;
-}
-
-/* End output to JSON stream */
-void jsonw_destroy(json_writer_t **self_p)
-{
- json_writer_t *self = *self_p;
-
- assert(self->depth == 0);
- fputs("\n", self->out);
- fflush(self->out);
- free(self);
- *self_p = NULL;
-}
-
-void jsonw_pretty(json_writer_t *self, bool on)
-{
- self->pretty = on;
-}
-
-void jsonw_reset(json_writer_t *self)
-{
- assert(self->depth == 0);
- self->sep = '\0';
-}
-
-/* Basic blocks */
-static void jsonw_begin(json_writer_t *self, int c)
-{
- jsonw_eor(self);
- putc(c, self->out);
- ++self->depth;
- self->sep = '\0';
-}
-
-static void jsonw_end(json_writer_t *self, int c)
-{
- assert(self->depth > 0);
-
- --self->depth;
- if (self->sep != '\0')
- jsonw_eol(self);
- putc(c, self->out);
- self->sep = ',';
-}
-
-
-/* Add a JSON property name */
-void jsonw_name(json_writer_t *self, const char *name)
-{
- jsonw_eor(self);
- jsonw_eol(self);
- self->sep = '\0';
- jsonw_puts(self, name);
- putc(':', self->out);
- if (self->pretty)
- putc(' ', self->out);
-}
-
-void jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap)
-{
- jsonw_eor(self);
- putc('"', self->out);
- vfprintf(self->out, fmt, ap);
- putc('"', self->out);
-}
-
-void jsonw_printf(json_writer_t *self, const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- jsonw_eor(self);
- vfprintf(self->out, fmt, ap);
- va_end(ap);
-}
-
-/* Collections */
-void jsonw_start_object(json_writer_t *self)
-{
- jsonw_begin(self, '{');
-}
-
-void jsonw_end_object(json_writer_t *self)
-{
- jsonw_end(self, '}');
-}
-
-void jsonw_start_array(json_writer_t *self)
-{
- jsonw_begin(self, '[');
-}
-
-void jsonw_end_array(json_writer_t *self)
-{
- jsonw_end(self, ']');
-}
-
-/* JSON value types */
-void jsonw_string(json_writer_t *self, const char *value)
-{
- jsonw_eor(self);
- jsonw_puts(self, value);
-}
-
-void jsonw_bool(json_writer_t *self, bool val)
-{
- jsonw_printf(self, "%s", val ? "true" : "false");
-}
-
-void jsonw_null(json_writer_t *self)
-{
- jsonw_printf(self, "null");
-}
-
-void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num)
-{
- jsonw_printf(self, fmt, num);
-}
-
-// #ifdef notused
-void jsonw_float(json_writer_t *self, double num)
-{
- jsonw_printf(self, "%g", num);
-}
-// #endif
-
-void jsonw_hu(json_writer_t *self, unsigned short num)
-{
- jsonw_printf(self, "%hu", num);
-}
-
-void jsonw_uint(json_writer_t *self, uint64_t num)
-{
- jsonw_printf(self, "%"PRIu64, num);
-}
-
-void jsonw_lluint(json_writer_t *self, unsigned long long int num)
-{
- jsonw_printf(self, "%llu", num);
-}
-
-void jsonw_int(json_writer_t *self, int64_t num)
-{
- jsonw_printf(self, "%"PRId64, num);
-}
-
-/* Basic name/value objects */
-void jsonw_string_field(json_writer_t *self, const char *prop, const char *val)
-{
- jsonw_name(self, prop);
- jsonw_string(self, val);
-}
-
-void jsonw_bool_field(json_writer_t *self, const char *prop, bool val)
-{
- jsonw_name(self, prop);
- jsonw_bool(self, val);
-}
-
-// #ifdef notused
-void jsonw_float_field(json_writer_t *self, const char *prop, double val)
-{
- jsonw_name(self, prop);
- jsonw_float(self, val);
-}
-// #endif
-
-void jsonw_float_field_fmt(json_writer_t *self,
- const char *prop,
- const char *fmt,
- double val)
-{
- jsonw_name(self, prop);
- jsonw_float_fmt(self, fmt, val);
-}
-
-void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num)
-{
- jsonw_name(self, prop);
- jsonw_uint(self, num);
-}
-
-void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num)
-{
- jsonw_name(self, prop);
- jsonw_hu(self, num);
-}
-
-void jsonw_lluint_field(json_writer_t *self,
- const char *prop,
- unsigned long long int num)
-{
- jsonw_name(self, prop);
- jsonw_lluint(self, num);
-}
-
-void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num)
-{
- jsonw_name(self, prop);
- jsonw_int(self, num);
-}
-
-void jsonw_null_field(json_writer_t *self, const char *prop)
-{
- jsonw_name(self, prop);
- jsonw_null(self);
-}
-
-#ifdef TEST
-int main(int argc, char **argv)
-{
- json_writer_t *wr = jsonw_new(stdout);
-
- jsonw_start_object(wr);
- jsonw_pretty(wr, true);
- jsonw_name(wr, "Vyatta");
- jsonw_start_object(wr);
- jsonw_string_field(wr, "url", "http://vyatta.com");
- jsonw_uint_field(wr, "downloads", 2000000ul);
- jsonw_float_field(wr, "stock", 8.16);
-
- jsonw_name(wr, "ARGV");
- jsonw_start_array(wr);
- while (--argc)
- jsonw_string(wr, *++argv);
- jsonw_end_array(wr);
-
- jsonw_name(wr, "empty");
- jsonw_start_array(wr);
- jsonw_end_array(wr);
-
- jsonw_name(wr, "NIL");
- jsonw_start_object(wr);
- jsonw_end_object(wr);
-
- jsonw_null_field(wr, "my_null");
-
- jsonw_name(wr, "special chars");
- jsonw_start_array(wr);
- jsonw_string_field(wr, "slash", "/");
- jsonw_string_field(wr, "newline", "\n");
- jsonw_string_field(wr, "tab", "\t");
- jsonw_string_field(wr, "ff", "\f");
- jsonw_string_field(wr, "quote", "\"");
- jsonw_string_field(wr, "tick", "\'");
- jsonw_string_field(wr, "backslash", "\\");
- jsonw_end_array(wr);
-
- jsonw_end_object(wr);
-
- jsonw_end_object(wr);
- jsonw_destroy(&wr);
- return 0;
-}
-
-#endif
diff --git a/archive/sg_json_writer.h b/archive/sg_json_writer.h
deleted file mode 100644
index c751ade8..00000000
--- a/archive/sg_json_writer.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
-/*
- * Simple streaming JSON writer
- *
- * This takes care of the annoying bits of JSON syntax like the commas
- * after elements
- *
- * Authors: Stephen Hemminger <stephen@networkplumber.org>
- *
- * Borrowed from Linux kernel [5.17.0]: tools/bpf/bpftool/json_writer.[hc]
- */
-
-#ifndef SG_JSON_WRITER_H_
-#define SG_JSON_WRITER_H_
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <stdarg.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Need to resolve __printf(a, b) macro calls
-#if defined(__GNUC__) || defined(__clang__)
-#ifdef SG_LIB_MINGW
-/* MinGW uses Microsoft's printf */
-
-#define __printf(a, b)
-
-#else /* GNU/clang other than MinGW */
-
-#define __printf(a, b) __attribute__ ((format (printf, a, b)))
-
-#endif
-
-#else /* not GNU (and not clang) */
-
-#define __printf(a, b)
-
-#endif
-
-/* Opaque class structure */
-typedef struct json_writer json_writer_t;
-
-/* Create a new JSON stream */
-json_writer_t *jsonw_new(FILE *f);
-/* End output to JSON stream */
-void jsonw_destroy(json_writer_t **self_p);
-
-/* Cause output to have pretty whitespace */
-void jsonw_pretty(json_writer_t *self, bool on);
-
-/* Reset separator to create new JSON */
-void jsonw_reset(json_writer_t *self);
-
-/* Add property name */
-void jsonw_name(json_writer_t *self, const char *name);
-
-/* Add value */
-void __printf(2, 0) jsonw_vprintf_enquote(json_writer_t *self, const char *fmt,
- va_list ap);
-void __printf(2, 3) jsonw_printf(json_writer_t *self, const char *fmt, ...);
-void jsonw_string(json_writer_t *self, const char *value);
-void jsonw_bool(json_writer_t *self, bool value);
-void jsonw_float(json_writer_t *self, double number);
-void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num);
-void jsonw_uint(json_writer_t *self, uint64_t number);
-void jsonw_hu(json_writer_t *self, unsigned short number);
-void jsonw_int(json_writer_t *self, int64_t number);
-void jsonw_null(json_writer_t *self);
-void jsonw_lluint(json_writer_t *self, unsigned long long int num);
-
-/* Useful Combinations of name and value */
-void jsonw_string_field(json_writer_t *self, const char *prop, const char *val);
-void jsonw_bool_field(json_writer_t *self, const char *prop, bool value);
-void jsonw_float_field(json_writer_t *self, const char *prop, double num);
-void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num);
-void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num);
-void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num);
-void jsonw_null_field(json_writer_t *self, const char *prop);
-void jsonw_lluint_field(json_writer_t *self, const char *prop,
- unsigned long long int num);
-void jsonw_float_field_fmt(json_writer_t *self, const char *prop,
- const char *fmt, double val);
-
-/* Collections */
-void jsonw_start_object(json_writer_t *self);
-void jsonw_end_object(json_writer_t *self);
-
-void jsonw_start_array(json_writer_t *self);
-void jsonw_end_array(json_writer_t *self);
-
-/* Override default exception handling */
-typedef void (jsonw_err_handler_fn)(const char *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SG_JSON_WRITER_H_ */