mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-12 20:14:36 +08:00
Update to FreeBSD head 2016-08-23
Git mirror commit 9fe7c416e6abb28b1398fd3e5687099846800cfd.
This commit is contained in:
parent
8c0eebac7d
commit
c40e45b75e
@ -104,3 +104,43 @@ $(LOCAL_INC)/mmcbr_if.h: $(FREEBSD_SRC)/sys/dev/mmc/mmcbr_if.m
|
||||
$(LOCAL_SRC)/mmcbr_if.c: $(FREEBSD_SRC)/sys/dev/mmc/mmcbr_if.m
|
||||
awk -f $(TOOLS)/makeobjops.awk $< -c
|
||||
mv mmcbr_if.c $@
|
||||
|
||||
$(LOCAL_INC)/if_dwc_if.h: $(FREEBSD_SRC)/sys/dev/dwc/if_dwc_if.m
|
||||
awk -f $(TOOLS)/makeobjops.awk $< -h
|
||||
mv if_dwc_if.h $@
|
||||
|
||||
$(LOCAL_SRC)/if_dwc_if.c: $(FREEBSD_SRC)/sys/dev/dwc/if_dwc_if.m
|
||||
awk -f $(TOOLS)/makeobjops.awk $< -c
|
||||
mv if_dwc_if.c $@
|
||||
|
||||
$(LOCAL_INC)/gpio_if.h: $(FREEBSD_SRC)/sys/dev/gpio/gpio_if.m
|
||||
awk -f $(TOOLS)/makeobjops.awk $< -h
|
||||
mv gpio_if.h $@
|
||||
|
||||
$(LOCAL_SRC)/gpio_if.c: $(FREEBSD_SRC)/sys/dev/gpio/gpio_if.m
|
||||
awk -f $(TOOLS)/makeobjops.awk $< -c
|
||||
mv gpio_if.c $@
|
||||
|
||||
freebsd/usr.bin/netstat/nl_symbols.c: $(FREEBSD_SRC)/usr.bin/netstat/nlist_symbols
|
||||
awk '\
|
||||
BEGIN { \
|
||||
print "#include <sys/param.h>"; \
|
||||
print "#include <nlist.h>"; \
|
||||
print "const struct nlist nl[] = {"; \
|
||||
} \
|
||||
!/^\#/ { printf("\t{ .n_name = \"%s\" },\n", $$2); } \
|
||||
END { print "\t{ .n_name = NULL },\n};" } \
|
||||
' < $< > $@ || rm -f $@
|
||||
|
||||
freebsd/usr.bin/netstat/nl_defs.h: $(FREEBSD_SRC)/usr.bin/netstat/nlist_symbols
|
||||
awk '\
|
||||
BEGIN { \
|
||||
print "#include <nlist.h>"; \
|
||||
print "extern const struct nlist nl[];"; \
|
||||
i = 0; \
|
||||
} \
|
||||
!/^\#/ { printf("\#define\tN%s\t%s\n", toupper($$2), i++); }' \
|
||||
< $< > $@ || rm -f $@
|
||||
|
||||
clean:
|
||||
rm $(GENERATED)
|
||||
|
@ -173,8 +173,8 @@ def commonNoWarnings():
|
||||
def includes():
|
||||
return ['-Irtemsbsd/include',
|
||||
'-Ifreebsd/sys',
|
||||
'-Ifreebsd/sys/contrib/altq',
|
||||
'-Ifreebsd/sys/contrib/pf',
|
||||
'-Ifreebsd/sys/net',
|
||||
'-Ifreebsd/include',
|
||||
'-Ifreebsd/lib/libc/include',
|
||||
'-Ifreebsd/lib/libc/isc/include',
|
||||
@ -184,6 +184,7 @@ def includes():
|
||||
'-Ifreebsd/lib/libmemstat',
|
||||
'-Ifreebsd/lib/libipsec',
|
||||
'-Ifreebsd/contrib/libpcap',
|
||||
'-Ifreebsd/contrib/libxo',
|
||||
'-Irtemsbsd/sys',
|
||||
'-ImDNSResponder/mDNSCore',
|
||||
'-ImDNSResponder/mDNSShared',
|
||||
@ -205,7 +206,6 @@ def headerPaths():
|
||||
return [('rtemsbsd/include', '*.h', ''),
|
||||
('rtemsbsd/mghttpd', 'mongoose.h', 'mghttpd'),
|
||||
('freebsd/include', '*.h', ''),
|
||||
('freebsd/sys/contrib/altq/altq', '*.h', 'altq'),
|
||||
('freebsd/sys/bsm', '*.h', 'bsm'),
|
||||
('freebsd/sys/cam', '*.h', 'cam'),
|
||||
('freebsd/sys/net', '*.h', 'net'),
|
||||
|
@ -72,7 +72,6 @@ objdump --syms `for i in build/*rtems* ; do \
|
||||
| sed '/^max_linkhdr$/d' \
|
||||
| sed '/^max_protohdr$/d' \
|
||||
| sed '/^maxsockets$/d' \
|
||||
| sed '/^mbstat$/d' \
|
||||
| sed '/^nd6_debug$/d' \
|
||||
| sed '/^nd6_delay$/d' \
|
||||
| sed '/^nd6_gctimer$/d' \
|
||||
@ -92,6 +91,7 @@ objdump --syms `for i in build/*rtems* ; do \
|
||||
| sed '/^pause$/d' \
|
||||
| sed '/^pf_osfp_entry_pl$/d' \
|
||||
| sed '/^pf_osfp_pl$/d' \
|
||||
| sed '/^pipe$/d' \
|
||||
| sed '/^poll$/d' \
|
||||
| sed '/^random$/d' \
|
||||
| sed '/^realloc$/d' \
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 99a648a912e81e29d9c4c159cbbe263462f2d719
|
||||
Subproject commit 9fe7c416e6abb28b1398fd3e5687099846800cfd
|
8080
freebsd/contrib/libxo/libxo/libxo.c
Normal file
8080
freebsd/contrib/libxo/libxo/libxo.c
Normal file
File diff suppressed because it is too large
Load Diff
666
freebsd/contrib/libxo/libxo/xo.h
Normal file
666
freebsd/contrib/libxo/libxo/xo.h
Normal file
@ -0,0 +1,666 @@
|
||||
/*
|
||||
* Copyright (c) 2014-2015, Juniper Networks, Inc.
|
||||
* All rights reserved.
|
||||
* This SOFTWARE is licensed under the LICENSE provided in the
|
||||
* ../Copyright file. By downloading, installing, copying, or otherwise
|
||||
* using the SOFTWARE, you agree to be bound by the terms of that
|
||||
* LICENSE.
|
||||
* Phil Shafer, July 2014
|
||||
*/
|
||||
|
||||
/**
|
||||
* libxo provides a means of generating text, XML, JSON, and HTML output
|
||||
* using a single set of function calls, maximizing the value of output
|
||||
* while minimizing the cost/impact on the code.
|
||||
*
|
||||
* Full documentation is available in ./doc/libxo.txt or online at:
|
||||
* http://juniper.github.io/libxo/libxo-manual.html
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_XO_H
|
||||
#define INCLUDE_XO_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef __dead2
|
||||
#define NORETURN __dead2
|
||||
#else
|
||||
#define NORETURN
|
||||
#endif /* __dead2 */
|
||||
|
||||
/*
|
||||
* Normally we'd use the HAVE_PRINTFLIKE define triggered by the
|
||||
* --enable-printflike option to configure, but we don't install
|
||||
* our internal "xoconfig.h", and I'd rather not. Taking the
|
||||
* coward's path, we'll turn it on inside a #if that allows
|
||||
* others to turn it off where needed. Not ideal, but functional.
|
||||
*/
|
||||
#if !defined(NO_PRINTFLIKE) && !defined(__linux__)
|
||||
#define PRINTFLIKE(_x, _y) __printflike(_x, _y)
|
||||
#else
|
||||
#define PRINTFLIKE(_x, _y)
|
||||
#endif /* NO_PRINTFLIKE */
|
||||
|
||||
/** Formatting types */
|
||||
typedef unsigned short xo_style_t;
|
||||
#define XO_STYLE_TEXT 0 /** Generate text output */
|
||||
#define XO_STYLE_XML 1 /** Generate XML output */
|
||||
#define XO_STYLE_JSON 2 /** Generate JSON output */
|
||||
#define XO_STYLE_HTML 3 /** Generate HTML output */
|
||||
#define XO_STYLE_SDPARAMS 4 /* Generate syslog structured data params */
|
||||
#define XO_STYLE_ENCODER 5 /* Generate calls to external encoder */
|
||||
|
||||
/** Flags for libxo */
|
||||
typedef unsigned long long xo_xof_flags_t;
|
||||
#define XOF_BIT(_n) ((xo_xof_flags_t) 1 << (_n))
|
||||
#define XOF_CLOSE_FP XOF_BIT(0) /** Close file pointer on xo_close() */
|
||||
#define XOF_PRETTY XOF_BIT(1) /** Make 'pretty printed' output */
|
||||
#define XOF_LOG_SYSLOG XOF_BIT(2) /** Log (on stderr) our syslog content */
|
||||
#define XOF_RESV3 XOF_BIT(3) /* Unused */
|
||||
|
||||
#define XOF_WARN XOF_BIT(4) /** Generate warnings for broken calls */
|
||||
#define XOF_XPATH XOF_BIT(5) /** Emit XPath attributes in HTML */
|
||||
#define XOF_INFO XOF_BIT(6) /** Emit additional info fields (HTML) */
|
||||
#define XOF_WARN_XML XOF_BIT(7) /** Emit warnings in XML (on stdout) */
|
||||
|
||||
#define XOF_NO_ENV XOF_BIT(8) /** Don't look at LIBXO_OPTIONS env var */
|
||||
#define XOF_NO_VA_ARG XOF_BIT(9) /** Don't advance va_list w/ va_arg() */
|
||||
#define XOF_DTRT XOF_BIT(10) /** Enable "do the right thing" mode */
|
||||
#define XOF_KEYS XOF_BIT(11) /** Flag 'key' fields for xml and json */
|
||||
|
||||
#define XOF_IGNORE_CLOSE XOF_BIT(12) /** Ignore errors on close tags */
|
||||
#define XOF_NOT_FIRST XOF_BIT(13) /* Not the first item (JSON) */
|
||||
#define XOF_NO_LOCALE XOF_BIT(14) /** Don't bother with locale */
|
||||
#define XOF_RESV15 XOF_BIT(15) /* Unused */
|
||||
|
||||
#define XOF_NO_TOP XOF_BIT(16) /** Don't emit the top braces in JSON */
|
||||
#define XOF_RESV17 XOF_BIT(17) /* Unused */
|
||||
#define XOF_UNITS XOF_BIT(18) /** Encode units in XML */
|
||||
#define XOF_RESV19 XOF_BIT(19) /* Unused */
|
||||
|
||||
#define XOF_UNDERSCORES XOF_BIT(20) /** Replace dashes with underscores (JSON)*/
|
||||
#define XOF_COLUMNS XOF_BIT(21) /** xo_emit should return a column count */
|
||||
#define XOF_FLUSH XOF_BIT(22) /** Flush after each xo_emit call */
|
||||
#define XOF_FLUSH_LINE XOF_BIT(23) /** Flush after each newline */
|
||||
|
||||
#define XOF_NO_CLOSE XOF_BIT(24) /** xo_finish won't close open elements */
|
||||
#define XOF_COLOR_ALLOWED XOF_BIT(25) /** Allow color/effects to be enabled */
|
||||
#define XOF_COLOR XOF_BIT(26) /** Enable color and effects */
|
||||
#define XOF_NO_HUMANIZE XOF_BIT(27) /** Block the {h:} modifier */
|
||||
|
||||
#define XOF_LOG_GETTEXT XOF_BIT(28) /** Log (stderr) gettext lookup strings */
|
||||
#define XOF_UTF8 XOF_BIT(29) /** Force text output to be UTF8 */
|
||||
#define XOF_RETAIN_ALL XOF_BIT(30) /** Force use of XOEF_RETAIN */
|
||||
#define XOF_RETAIN_NONE XOF_BIT(31) /** Prevent use of XOEF_RETAIN */
|
||||
|
||||
typedef unsigned xo_emit_flags_t; /* Flags to xo_emit() and friends */
|
||||
#define XOEF_RETAIN (1<<0) /* Retain parsed formatting information */
|
||||
|
||||
/*
|
||||
* The xo_info_t structure provides a mapping between names and
|
||||
* additional data emitted via HTML.
|
||||
*/
|
||||
typedef struct xo_info_s {
|
||||
const char *xi_name; /* Name of the element */
|
||||
const char *xi_type; /* Type of field */
|
||||
const char *xi_help; /* Description of field */
|
||||
} xo_info_t;
|
||||
|
||||
#define XO_INFO_NULL NULL, NULL, NULL /* Use '{ XO_INFO_NULL }' to end lists */
|
||||
|
||||
struct xo_handle_s; /* Opaque structure forward */
|
||||
typedef struct xo_handle_s xo_handle_t; /* Handle for XO output */
|
||||
|
||||
typedef int (*xo_write_func_t)(void *, const char *);
|
||||
typedef void (*xo_close_func_t)(void *);
|
||||
typedef int (*xo_flush_func_t)(void *);
|
||||
typedef void *(*xo_realloc_func_t)(void *, size_t);
|
||||
typedef void (*xo_free_func_t)(void *);
|
||||
|
||||
/*
|
||||
* The formatter function mirrors "vsnprintf", with an additional argument
|
||||
* of the xo handle. The caller should return the number of bytes _needed_
|
||||
* to fit the data, even if this exceeds 'len'.
|
||||
*/
|
||||
typedef int (*xo_formatter_t)(xo_handle_t *, char *, int,
|
||||
const char *, va_list);
|
||||
typedef void (*xo_checkpointer_t)(xo_handle_t *, va_list, int);
|
||||
|
||||
xo_handle_t *
|
||||
xo_create (xo_style_t style, xo_xof_flags_t flags);
|
||||
|
||||
xo_handle_t *
|
||||
xo_create_to_file (FILE *fp, xo_style_t style, xo_xof_flags_t flags);
|
||||
|
||||
void
|
||||
xo_destroy (xo_handle_t *xop);
|
||||
|
||||
void
|
||||
xo_set_writer (xo_handle_t *xop, void *opaque, xo_write_func_t write_func,
|
||||
xo_close_func_t close_func, xo_flush_func_t flush_func);
|
||||
|
||||
void
|
||||
xo_set_allocator (xo_realloc_func_t realloc_func, xo_free_func_t free_func);
|
||||
|
||||
void
|
||||
xo_set_style (xo_handle_t *xop, xo_style_t style);
|
||||
|
||||
xo_style_t
|
||||
xo_get_style (xo_handle_t *xop);
|
||||
|
||||
int
|
||||
xo_set_style_name (xo_handle_t *xop, const char *style);
|
||||
|
||||
int
|
||||
xo_set_options (xo_handle_t *xop, const char *input);
|
||||
|
||||
xo_xof_flags_t
|
||||
xo_get_flags (xo_handle_t *xop);
|
||||
|
||||
void
|
||||
xo_set_flags (xo_handle_t *xop, xo_xof_flags_t flags);
|
||||
|
||||
void
|
||||
xo_clear_flags (xo_handle_t *xop, xo_xof_flags_t flags);
|
||||
|
||||
int
|
||||
xo_set_file_h (xo_handle_t *xop, FILE *fp);
|
||||
|
||||
int
|
||||
xo_set_file (FILE *fp);
|
||||
|
||||
void
|
||||
xo_set_info (xo_handle_t *xop, xo_info_t *infop, int count);
|
||||
|
||||
void
|
||||
xo_set_formatter (xo_handle_t *xop, xo_formatter_t func, xo_checkpointer_t);
|
||||
|
||||
void
|
||||
xo_set_depth (xo_handle_t *xop, int depth);
|
||||
|
||||
int
|
||||
xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap);
|
||||
|
||||
int
|
||||
xo_emit_h (xo_handle_t *xop, const char *fmt, ...);
|
||||
|
||||
int
|
||||
xo_emit (const char *fmt, ...);
|
||||
|
||||
int
|
||||
xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
|
||||
const char *fmt, va_list vap);
|
||||
|
||||
int
|
||||
xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...);
|
||||
|
||||
int
|
||||
xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...);
|
||||
|
||||
PRINTFLIKE(2, 0)
|
||||
static inline int
|
||||
xo_emit_hvp (xo_handle_t *xop, const char *fmt, va_list vap)
|
||||
{
|
||||
return xo_emit_hv(xop, fmt, vap);
|
||||
}
|
||||
|
||||
PRINTFLIKE(2, 3)
|
||||
static inline int
|
||||
xo_emit_hp (xo_handle_t *xop, const char *fmt, ...)
|
||||
{
|
||||
va_list vap;
|
||||
va_start(vap, fmt);
|
||||
int rc = xo_emit_hv(xop, fmt, vap);
|
||||
va_end(vap);
|
||||
return rc;
|
||||
}
|
||||
|
||||
PRINTFLIKE(1, 2)
|
||||
static inline int
|
||||
xo_emit_p (const char *fmt, ...)
|
||||
{
|
||||
va_list vap;
|
||||
va_start(vap, fmt);
|
||||
int rc = xo_emit_hv(NULL, fmt, vap);
|
||||
va_end(vap);
|
||||
return rc;
|
||||
}
|
||||
|
||||
PRINTFLIKE(3, 0)
|
||||
static inline int
|
||||
xo_emit_hvfp (xo_handle_t *xop, xo_emit_flags_t flags,
|
||||
const char *fmt, va_list vap)
|
||||
{
|
||||
return xo_emit_hvf(xop, flags, fmt, vap);
|
||||
}
|
||||
|
||||
PRINTFLIKE(3, 4)
|
||||
static inline int
|
||||
xo_emit_hfp (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...)
|
||||
{
|
||||
va_list vap;
|
||||
va_start(vap, fmt);
|
||||
int rc = xo_emit_hvf(xop, flags, fmt, vap);
|
||||
va_end(vap);
|
||||
return rc;
|
||||
}
|
||||
|
||||
PRINTFLIKE(2, 3)
|
||||
static inline int
|
||||
xo_emit_fp (xo_emit_flags_t flags, const char *fmt, ...)
|
||||
{
|
||||
va_list vap;
|
||||
va_start(vap, fmt);
|
||||
int rc = xo_emit_hvf(NULL, flags, fmt, vap);
|
||||
va_end(vap);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
xo_open_container_h (xo_handle_t *xop, const char *name);
|
||||
|
||||
int
|
||||
xo_open_container (const char *name);
|
||||
|
||||
int
|
||||
xo_open_container_hd (xo_handle_t *xop, const char *name);
|
||||
|
||||
int
|
||||
xo_open_container_d (const char *name);
|
||||
|
||||
int
|
||||
xo_close_container_h (xo_handle_t *xop, const char *name);
|
||||
|
||||
int
|
||||
xo_close_container (const char *name);
|
||||
|
||||
int
|
||||
xo_close_container_hd (xo_handle_t *xop);
|
||||
|
||||
int
|
||||
xo_close_container_d (void);
|
||||
|
||||
int
|
||||
xo_open_list_h (xo_handle_t *xop, const char *name);
|
||||
|
||||
int
|
||||
xo_open_list (const char *name);
|
||||
|
||||
int
|
||||
xo_open_list_hd (xo_handle_t *xop, const char *name);
|
||||
|
||||
int
|
||||
xo_open_list_d (const char *name);
|
||||
|
||||
int
|
||||
xo_close_list_h (xo_handle_t *xop, const char *name);
|
||||
|
||||
int
|
||||
xo_close_list (const char *name);
|
||||
|
||||
int
|
||||
xo_close_list_hd (xo_handle_t *xop);
|
||||
|
||||
int
|
||||
xo_close_list_d (void);
|
||||
|
||||
int
|
||||
xo_open_instance_h (xo_handle_t *xop, const char *name);
|
||||
|
||||
int
|
||||
xo_open_instance (const char *name);
|
||||
|
||||
int
|
||||
xo_open_instance_hd (xo_handle_t *xop, const char *name);
|
||||
|
||||
int
|
||||
xo_open_instance_d (const char *name);
|
||||
|
||||
int
|
||||
xo_close_instance_h (xo_handle_t *xop, const char *name);
|
||||
|
||||
int
|
||||
xo_close_instance (const char *name);
|
||||
|
||||
int
|
||||
xo_close_instance_hd (xo_handle_t *xop);
|
||||
|
||||
int
|
||||
xo_close_instance_d (void);
|
||||
|
||||
int
|
||||
xo_open_marker_h (xo_handle_t *xop, const char *name);
|
||||
|
||||
int
|
||||
xo_open_marker (const char *name);
|
||||
|
||||
int
|
||||
xo_close_marker_h (xo_handle_t *xop, const char *name);
|
||||
|
||||
int
|
||||
xo_close_marker (const char *name);
|
||||
|
||||
int
|
||||
xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...);
|
||||
|
||||
int
|
||||
xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap);
|
||||
|
||||
int
|
||||
xo_attr (const char *name, const char *fmt, ...);
|
||||
|
||||
void
|
||||
xo_error_hv (xo_handle_t *xop, const char *fmt, va_list vap);
|
||||
|
||||
void
|
||||
xo_error_h (xo_handle_t *xop, const char *fmt, ...);
|
||||
|
||||
void
|
||||
xo_error (const char *fmt, ...);
|
||||
|
||||
int
|
||||
xo_flush_h (xo_handle_t *xop);
|
||||
|
||||
int
|
||||
xo_flush (void);
|
||||
|
||||
int
|
||||
xo_finish_h (xo_handle_t *xop);
|
||||
|
||||
int
|
||||
xo_finish (void);
|
||||
|
||||
void
|
||||
xo_finish_atexit (void);
|
||||
|
||||
void
|
||||
xo_set_leading_xpath (xo_handle_t *xop, const char *path);
|
||||
|
||||
void
|
||||
xo_warn_hc (xo_handle_t *xop, int code, const char *fmt, ...) PRINTFLIKE(3, 4);
|
||||
|
||||
void
|
||||
xo_warn_c (int code, const char *fmt, ...) PRINTFLIKE(2, 3);
|
||||
|
||||
void
|
||||
xo_warn (const char *fmt, ...) PRINTFLIKE(1, 2);
|
||||
|
||||
void
|
||||
xo_warnx (const char *fmt, ...) PRINTFLIKE(1, 2);
|
||||
|
||||
void
|
||||
xo_err (int eval, const char *fmt, ...) NORETURN PRINTFLIKE(2, 3);
|
||||
|
||||
void
|
||||
xo_errx (int eval, const char *fmt, ...) NORETURN PRINTFLIKE(2, 3);
|
||||
|
||||
void
|
||||
xo_errc (int eval, int code, const char *fmt, ...) NORETURN PRINTFLIKE(3, 4);
|
||||
|
||||
void
|
||||
xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap) PRINTFLIKE(3, 0);
|
||||
|
||||
void
|
||||
xo_message_hc (xo_handle_t *xop, int code, const char *fmt, ...) PRINTFLIKE(3, 4);
|
||||
|
||||
void
|
||||
xo_message_c (int code, const char *fmt, ...) PRINTFLIKE(2, 3);
|
||||
|
||||
void
|
||||
xo_message_e (const char *fmt, ...) PRINTFLIKE(1, 2);
|
||||
|
||||
void
|
||||
xo_message (const char *fmt, ...) PRINTFLIKE(1, 2);
|
||||
|
||||
void
|
||||
xo_emit_warn_hcv (xo_handle_t *xop, int as_warning, int code,
|
||||
const char *fmt, va_list vap);
|
||||
|
||||
void
|
||||
xo_emit_warn_hc (xo_handle_t *xop, int code, const char *fmt, ...);
|
||||
|
||||
void
|
||||
xo_emit_warn_c (int code, const char *fmt, ...);
|
||||
|
||||
void
|
||||
xo_emit_warn (const char *fmt, ...);
|
||||
|
||||
void
|
||||
xo_emit_warnx (const char *fmt, ...);
|
||||
|
||||
void
|
||||
xo_emit_err (int eval, const char *fmt, ...) NORETURN;
|
||||
|
||||
void
|
||||
xo_emit_errx (int eval, const char *fmt, ...) NORETURN;
|
||||
|
||||
void
|
||||
xo_emit_errc (int eval, int code, const char *fmt, ...) NORETURN;
|
||||
|
||||
PRINTFLIKE(4, 0)
|
||||
static inline void
|
||||
xo_emit_warn_hcvp (xo_handle_t *xop, int as_warning, int code,
|
||||
const char *fmt, va_list vap)
|
||||
{
|
||||
xo_emit_warn_hcv(xop, as_warning, code, fmt, vap);
|
||||
}
|
||||
|
||||
PRINTFLIKE(3, 4)
|
||||
static inline void
|
||||
xo_emit_warn_hcp (xo_handle_t *xop, int code, const char *fmt, ...)
|
||||
{
|
||||
va_list vap;
|
||||
va_start(vap, fmt);
|
||||
xo_emit_warn_hcv(xop, 1, code, fmt, vap);
|
||||
va_end(vap);
|
||||
}
|
||||
|
||||
PRINTFLIKE(2, 3)
|
||||
static inline void
|
||||
xo_emit_warn_cp (int code, const char *fmt, ...)
|
||||
{
|
||||
va_list vap;
|
||||
va_start(vap, fmt);
|
||||
xo_emit_warn_hcv(NULL, 1, code, fmt, vap);
|
||||
va_end(vap);
|
||||
}
|
||||
|
||||
PRINTFLIKE(1, 2)
|
||||
static inline void
|
||||
xo_emit_warn_p (const char *fmt, ...)
|
||||
{
|
||||
int code = errno;
|
||||
va_list vap;
|
||||
va_start(vap, fmt);
|
||||
xo_emit_warn_hcv(NULL, 1, code, fmt, vap);
|
||||
va_end(vap);
|
||||
}
|
||||
|
||||
PRINTFLIKE(1, 2)
|
||||
static inline void
|
||||
xo_emit_warnx_p (const char *fmt, ...)
|
||||
{
|
||||
va_list vap;
|
||||
va_start(vap, fmt);
|
||||
xo_emit_warn_hcv(NULL, 1, -1, fmt, vap);
|
||||
va_end(vap);
|
||||
}
|
||||
|
||||
NORETURN PRINTFLIKE(2, 3)
|
||||
static inline void
|
||||
xo_emit_err_p (int eval, const char *fmt, ...)
|
||||
{
|
||||
int code = errno;
|
||||
va_list vap;
|
||||
va_start(vap, fmt);
|
||||
xo_emit_warn_hcv(NULL, 0, code, fmt, vap);
|
||||
va_end(vap);
|
||||
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
PRINTFLIKE(2, 3)
|
||||
static inline void
|
||||
xo_emit_errx_p (int eval, const char *fmt, ...)
|
||||
{
|
||||
va_list vap;
|
||||
va_start(vap, fmt);
|
||||
xo_emit_warn_hcv(NULL, 0, -1, fmt, vap);
|
||||
va_end(vap);
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
PRINTFLIKE(3, 4)
|
||||
static inline void
|
||||
xo_emit_errc_p (int eval, int code, const char *fmt, ...)
|
||||
{
|
||||
va_list vap;
|
||||
va_start(vap, fmt);
|
||||
xo_emit_warn_hcv(NULL, 0, code, fmt, vap);
|
||||
va_end(vap);
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
void
|
||||
xo_emit_err_v (int eval, int code, const char *fmt, va_list vap) NORETURN PRINTFLIKE(3, 0);
|
||||
|
||||
void
|
||||
xo_no_setlocale (void);
|
||||
|
||||
/**
|
||||
* @brief Lift libxo-specific arguments from a set of arguments
|
||||
*
|
||||
* libxo-enable programs typically use command line options to enable
|
||||
* all the nifty-cool libxo features. xo_parse_args() makes this simple
|
||||
* by pre-processing the command line arguments given to main(), handling
|
||||
* and removing the libxo-specific ones, meaning anything starting with
|
||||
* "--libxo". A full description of these arguments is in the base
|
||||
* documentation.
|
||||
* @param[in] argc Number of arguments (ala #main())
|
||||
* @param[in] argc Array of argument strings (ala #main())
|
||||
* @return New number of arguments, or -1 for failure.
|
||||
*/
|
||||
int
|
||||
xo_parse_args (int argc, char **argv);
|
||||
|
||||
/**
|
||||
* This is the "magic" number returned by libxo-supporting commands
|
||||
* when passed the equally magic "--libxo-check" option. If you
|
||||
* return this, we can (unsafely) assume that since you know the magic
|
||||
* handshake, you'll happily handle future --libxo options and not do
|
||||
* something violent like reboot the box or create another hole in the
|
||||
* ozone layer.
|
||||
*/
|
||||
#define XO_HAS_LIBXO 121
|
||||
|
||||
/**
|
||||
* externs for libxo's version number strings
|
||||
*/
|
||||
extern const char xo_version[]; /** Base version triple string */
|
||||
extern const char xo_version_extra[]; /** Extra version magic content */
|
||||
|
||||
/**
|
||||
* @brief Dump the internal stack of a libxo handle.
|
||||
*
|
||||
* This diagnostic function is something I will ask you to call from
|
||||
* your program when you write to tell me libxo has gone bat-stink
|
||||
* crazy and has discarded your list or container or content. Output
|
||||
* content will be what we lovingly call "developer entertainment".
|
||||
* @param[in] xop A valid libxo handle, or NULL for the default handle
|
||||
*/
|
||||
void
|
||||
xo_dump_stack (xo_handle_t *xop);
|
||||
|
||||
/**
|
||||
* @brief Recode the name of the program, suitable for error output.
|
||||
*
|
||||
* libxo will record the given name for use while generating error
|
||||
* messages. The contents are not copied, so the value must continue
|
||||
* to point to a valid memory location. This allows the caller to change
|
||||
* the value, but requires the caller to manage the memory. Typically
|
||||
* this is called with argv[0] from main().
|
||||
* @param[in] name The name of the current application program
|
||||
*/
|
||||
void
|
||||
xo_set_program (const char *name);
|
||||
|
||||
/**
|
||||
* @brief Add a version string to the output, where possible.
|
||||
*
|
||||
* Adds a version number to the output, suitable for tracking
|
||||
* changes in the content. This is only important for the "encoding"
|
||||
* format styles (XML and JSON) and allows a user of the data to
|
||||
* discern which version of the data model is in use.
|
||||
* @param[in] version The version number, encoded as a string
|
||||
*/
|
||||
void
|
||||
xo_set_version (const char *version);
|
||||
|
||||
/**
|
||||
* #xo_set_version with a handle.
|
||||
* @param[in] xop A valid libxo handle, or NULL for the default handle
|
||||
* @param[in] version The version number, encoded as a string
|
||||
*/
|
||||
void
|
||||
xo_set_version_h (xo_handle_t *xop, const char *version);
|
||||
|
||||
void
|
||||
xo_open_log (const char *ident, int logopt, int facility);
|
||||
|
||||
void
|
||||
xo_close_log (void);
|
||||
|
||||
int
|
||||
xo_set_logmask (int maskpri);
|
||||
|
||||
void
|
||||
xo_set_unit_test_mode (int value);
|
||||
|
||||
void
|
||||
xo_syslog (int priority, const char *name, const char *message, ...);
|
||||
|
||||
void
|
||||
xo_vsyslog (int priority, const char *name, const char *message, va_list args);
|
||||
|
||||
typedef void (*xo_syslog_open_t)(void);
|
||||
typedef void (*xo_syslog_send_t)(const char *full_msg,
|
||||
const char *v0_hdr, const char *text_only);
|
||||
typedef void (*xo_syslog_close_t)(void);
|
||||
|
||||
void
|
||||
xo_set_syslog_handler (xo_syslog_open_t open_func, xo_syslog_send_t send_func,
|
||||
xo_syslog_close_t close_func);
|
||||
|
||||
void
|
||||
xo_set_syslog_enterprise_id (unsigned short eid);
|
||||
|
||||
typedef void (*xo_simplify_field_func_t)(const char *, unsigned, int);
|
||||
|
||||
char *
|
||||
xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers,
|
||||
xo_simplify_field_func_t field_cb);
|
||||
|
||||
int
|
||||
xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
|
||||
const char *fmt, const char *efmt,
|
||||
va_list vap);
|
||||
|
||||
int
|
||||
xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
|
||||
const char *fmt, const char *efmt, ...);
|
||||
|
||||
int
|
||||
xo_emit_field (const char *rolmod, const char *contents,
|
||||
const char *fmt, const char *efmt, ...);
|
||||
|
||||
void
|
||||
xo_retain_clear_all (void);
|
||||
|
||||
void
|
||||
xo_retain_clear (const char *fmt);
|
||||
|
||||
#endif /* INCLUDE_XO_H */
|
158
freebsd/contrib/libxo/libxo/xo_buf.h
Normal file
158
freebsd/contrib/libxo/libxo/xo_buf.h
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Juniper Networks, Inc.
|
||||
* All rights reserved.
|
||||
* This SOFTWARE is licensed under the LICENSE provided in the
|
||||
* ../Copyright file. By downloading, installing, copying, or otherwise
|
||||
* using the SOFTWARE, you agree to be bound by the terms of that
|
||||
* LICENSE.
|
||||
* Phil Shafer, August 2015
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is an _internal_ part of the libxo plumbing, not suitable
|
||||
* for external use. It is not considered part of the libxo API and
|
||||
* will not be a stable part of that API. Mine, not your's, dude...
|
||||
* The real hope is that something like this will become a standard part
|
||||
* of libc and I can kill this off.
|
||||
*/
|
||||
|
||||
#ifndef XO_BUF_H
|
||||
#define XO_BUF_H
|
||||
|
||||
#define XO_BUFSIZ (8*1024) /* Initial buffer size */
|
||||
#define XO_BUF_HIGH_WATER (XO_BUFSIZ - 512) /* When to auto-flush */
|
||||
/*
|
||||
* xo_buffer_t: a memory buffer that can be grown as needed. We
|
||||
* use them for building format strings and output data.
|
||||
*/
|
||||
typedef struct xo_buffer_s {
|
||||
char *xb_bufp; /* Buffer memory */
|
||||
char *xb_curp; /* Current insertion point */
|
||||
unsigned xb_size; /* Size of buffer */
|
||||
} xo_buffer_t;
|
||||
|
||||
/*
|
||||
* Initialize the contents of an xo_buffer_t.
|
||||
*/
|
||||
static inline void
|
||||
xo_buf_init (xo_buffer_t *xbp)
|
||||
{
|
||||
xbp->xb_size = XO_BUFSIZ;
|
||||
xbp->xb_bufp = xo_realloc(NULL, xbp->xb_size);
|
||||
xbp->xb_curp = xbp->xb_bufp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the buffer to empty
|
||||
*/
|
||||
static inline void
|
||||
xo_buf_reset (xo_buffer_t *xbp)
|
||||
{
|
||||
xbp->xb_curp = xbp->xb_bufp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the number of bytes left in the buffer
|
||||
*/
|
||||
static inline int
|
||||
xo_buf_left (xo_buffer_t *xbp)
|
||||
{
|
||||
return xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
|
||||
}
|
||||
|
||||
/*
|
||||
* See if the buffer to empty
|
||||
*/
|
||||
static inline int
|
||||
xo_buf_is_empty (xo_buffer_t *xbp)
|
||||
{
|
||||
return (xbp->xb_curp == xbp->xb_bufp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the current offset
|
||||
*/
|
||||
static inline unsigned
|
||||
xo_buf_offset (xo_buffer_t *xbp)
|
||||
{
|
||||
return xbp ? (xbp->xb_curp - xbp->xb_bufp) : 0;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
xo_buf_data (xo_buffer_t *xbp, unsigned offset)
|
||||
{
|
||||
if (xbp == NULL)
|
||||
return NULL;
|
||||
return xbp->xb_bufp + offset;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
xo_buf_cur (xo_buffer_t *xbp)
|
||||
{
|
||||
if (xbp == NULL)
|
||||
return NULL;
|
||||
return xbp->xb_curp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the contents of an xo_buffer_t.
|
||||
*/
|
||||
static inline void
|
||||
xo_buf_cleanup (xo_buffer_t *xbp)
|
||||
{
|
||||
if (xbp->xb_bufp)
|
||||
xo_free(xbp->xb_bufp);
|
||||
bzero(xbp, sizeof(*xbp));
|
||||
}
|
||||
|
||||
/*
|
||||
* Does the buffer have room for the given number of bytes of data?
|
||||
* If not, realloc the buffer to make room. If that fails, we
|
||||
* return 0 to tell the caller they are in trouble.
|
||||
*/
|
||||
static inline int
|
||||
xo_buf_has_room (xo_buffer_t *xbp, int len)
|
||||
{
|
||||
if (xbp->xb_curp + len >= xbp->xb_bufp + xbp->xb_size) {
|
||||
int sz = xbp->xb_size + XO_BUFSIZ;
|
||||
char *bp = xo_realloc(xbp->xb_bufp, sz);
|
||||
if (bp == NULL)
|
||||
return 0;
|
||||
|
||||
xbp->xb_curp = bp + (xbp->xb_curp - xbp->xb_bufp);
|
||||
xbp->xb_bufp = bp;
|
||||
xbp->xb_size = sz;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Append the given string to the given buffer
|
||||
*/
|
||||
static inline void
|
||||
xo_buf_append (xo_buffer_t *xbp, const char *str, int len)
|
||||
{
|
||||
if (!xo_buf_has_room(xbp, len))
|
||||
return;
|
||||
|
||||
memcpy(xbp->xb_curp, str, len);
|
||||
xbp->xb_curp += len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Append the given NUL-terminated string to the given buffer
|
||||
*/
|
||||
static inline void
|
||||
xo_buf_append_str (xo_buffer_t *xbp, const char *str)
|
||||
{
|
||||
int len = strlen(str);
|
||||
|
||||
if (!xo_buf_has_room(xbp, len))
|
||||
return;
|
||||
|
||||
memcpy(xbp->xb_curp, str, len);
|
||||
xbp->xb_curp += len;
|
||||
}
|
||||
|
||||
#endif /* XO_BUF_H */
|
254
freebsd/contrib/libxo/libxo/xo_config.h
Normal file
254
freebsd/contrib/libxo/libxo/xo_config.h
Normal file
@ -0,0 +1,254 @@
|
||||
/* $FreeBSD$ */
|
||||
/* libxo/xo_config.h. Generated from xo_config.h.in by configure. */
|
||||
/* libxo/xo_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
/* #undef CRAY_STACKSEG_END */
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
/* #undef C_ALLOCA */
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
/* #undef HAVE_ALLOCA_H */
|
||||
|
||||
/* Define to 1 if you have the `asprintf' function. */
|
||||
#define HAVE_ASPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the `bzero' function. */
|
||||
#define HAVE_BZERO 1
|
||||
|
||||
/* Define to 1 if you have the `ctime' function. */
|
||||
#define HAVE_CTIME 1
|
||||
|
||||
/* Define to 1 if you have the <ctype.h> header file. */
|
||||
#define HAVE_CTYPE_H 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `__isthreaded', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL___ISTHREADED 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the `dlfunc' function. */
|
||||
#define HAVE_DLFUNC 1
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the `fdopen' function. */
|
||||
#define HAVE_FDOPEN 1
|
||||
|
||||
/* Define to 1 if you have the `flock' function. */
|
||||
#define HAVE_FLOCK 1
|
||||
|
||||
/* Define to 1 if you have the `getpass' function. */
|
||||
#define HAVE_GETPASS 1
|
||||
|
||||
/* Define to 1 if you have the `getprogname' function. */
|
||||
#define HAVE_GETPROGNAME 1
|
||||
|
||||
/* Define to 1 if you have the `getrusage' function. */
|
||||
#define HAVE_GETRUSAGE 1
|
||||
|
||||
/* gettext(3) */
|
||||
/* #undef HAVE_GETTEXT */
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* humanize_number(3) */
|
||||
#define HAVE_HUMANIZE_NUMBER 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `crypto' library (-lcrypto). */
|
||||
#define HAVE_LIBCRYPTO 1
|
||||
|
||||
/* Define to 1 if you have the `m' library (-lm). */
|
||||
#define HAVE_LIBM 1
|
||||
|
||||
/* Define to 1 if you have the <libutil.h> header file. */
|
||||
#define HAVE_LIBUTIL_H 1
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
to 0 otherwise. */
|
||||
#define HAVE_MALLOC 1
|
||||
|
||||
/* Define to 1 if you have the `memmove' function. */
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <monitor.h> header file. */
|
||||
/* #undef HAVE_MONITOR_H */
|
||||
|
||||
/* Support printflike */
|
||||
/* #undef HAVE_PRINTFLIKE */
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
|
||||
and to 0 otherwise. */
|
||||
#define HAVE_REALLOC 1
|
||||
|
||||
/* Define to 1 if you have the `srand' function. */
|
||||
#define HAVE_SRAND 1
|
||||
|
||||
/* Define to 1 if you have the `sranddev' function. */
|
||||
#define HAVE_SRANDDEV 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdio_ext.h> header file. */
|
||||
/* #undef HAVE_STDIO_EXT_H */
|
||||
|
||||
/* Define to 1 if you have the <stdio.h> header file. */
|
||||
#define HAVE_STDIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdtime/tzfile.h> header file. */
|
||||
/* #undef HAVE_STDTIME_TZFILE_H */
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#define HAVE_STRCHR 1
|
||||
|
||||
/* Define to 1 if you have the `strcspn' function. */
|
||||
#define HAVE_STRCSPN 1
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#define HAVE_STRERROR 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strlcpy' function. */
|
||||
#define HAVE_STRLCPY 1
|
||||
|
||||
/* Define to 1 if you have the `strspn' function. */
|
||||
#define HAVE_STRSPN 1
|
||||
|
||||
/* Have struct sockaddr_un.sun_len */
|
||||
#define HAVE_SUN_LEN 1
|
||||
|
||||
/* Define to 1 if you have the `sysctlbyname' function. */
|
||||
#define HAVE_SYSCTLBYNAME 1
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/sysctl.h> header file. */
|
||||
#define HAVE_SYS_SYSCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <threads.h> header file. */
|
||||
#define HAVE_THREADS_H 1
|
||||
|
||||
/* thread-local setting */
|
||||
#define HAVE_THREAD_LOCAL THREAD_LOCAL_before
|
||||
|
||||
/* Define to 1 if you have the <tzfile.h> header file. */
|
||||
/* #undef HAVE_TZFILE_H */
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the `__flbf' function. */
|
||||
/* #undef HAVE___FLBF */
|
||||
|
||||
/* Enable debugging */
|
||||
/* #undef LIBXO_DEBUG */
|
||||
|
||||
/* Enable text-only rendering */
|
||||
/* #undef LIBXO_TEXT_ONLY */
|
||||
|
||||
/* Version number as dotted value */
|
||||
#define LIBXO_VERSION "0.6.2"
|
||||
|
||||
/* Version number extra information */
|
||||
#define LIBXO_VERSION_EXTRA ""
|
||||
|
||||
/* Version number as a number */
|
||||
#define LIBXO_VERSION_NUMBER 6002
|
||||
|
||||
/* Version number as string */
|
||||
#define LIBXO_VERSION_STRING "6002"
|
||||
|
||||
/* Enable local wcwidth implementation */
|
||||
#define LIBXO_WCWIDTH 1
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "libxo"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "phil@juniper.net"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libxo"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libxo 0.6.2"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libxo"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "0.6.2"
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
/* #undef STACK_DIRECTION */
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.6.2"
|
||||
|
||||
/* Retain hash bucket size */
|
||||
/* #undef XO_RETAIN_SIZE */
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
/* #undef inline */
|
||||
#endif
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
/* #undef malloc */
|
||||
|
||||
/* Define to rpl_realloc if the replacement function should be used. */
|
||||
/* #undef realloc */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
435
freebsd/contrib/libxo/libxo/xo_encoder.c
Normal file
435
freebsd/contrib/libxo/libxo/xo_encoder.c
Normal file
@ -0,0 +1,435 @@
|
||||
#include <machine/rtems-bsd-user-space.h>
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015, Juniper Networks, Inc.
|
||||
* All rights reserved.
|
||||
* This SOFTWARE is licensed under the LICENSE provided in the
|
||||
* ../Copyright file. By downloading, installing, copying, or otherwise
|
||||
* using the SOFTWARE, you agree to be bound by the terms of that
|
||||
* LICENSE.
|
||||
* Phil Shafer, August 2015
|
||||
*/
|
||||
|
||||
#ifndef __rtems__
|
||||
/**
|
||||
* libxo includes a number of fixed encoding styles. But other
|
||||
* external encoders are need to deal with new encoders. Rather
|
||||
* than expose a swarm of libxo internals, we create a distinct
|
||||
* API, with a simpler API than we use internally.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/queue.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "xo_config.h"
|
||||
#include "xo.h"
|
||||
#include "xo_encoder.h"
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include <dlfcn.h>
|
||||
#if !defined(HAVE_DLFUNC)
|
||||
#define dlfunc(_p, _n) dlsym(_p, _n)
|
||||
#endif
|
||||
#else /* HAVE_DLFCN_H */
|
||||
#define dlopen(_n, _f) NULL /* Fail */
|
||||
#define dlsym(_p, _n) NULL /* Fail */
|
||||
#define dlfunc(_p, _n) NULL /* Fail */
|
||||
#endif /* HAVE_DLFCN_H */
|
||||
|
||||
static void xo_encoder_setup (void); /* Forward decl */
|
||||
|
||||
/*
|
||||
* Need a simple string collection
|
||||
*/
|
||||
typedef struct xo_string_node_s {
|
||||
TAILQ_ENTRY(xo_string_node_s) xs_link; /* Next string */
|
||||
char xs_data[0]; /* String data */
|
||||
} xo_string_node_t;
|
||||
|
||||
typedef TAILQ_HEAD(xo_string_list_s, xo_string_node_s) xo_string_list_t;
|
||||
|
||||
static inline void
|
||||
xo_string_list_init (xo_string_list_t *listp)
|
||||
{
|
||||
if (listp->tqh_last == NULL)
|
||||
TAILQ_INIT(listp);
|
||||
}
|
||||
|
||||
static inline xo_string_node_t *
|
||||
xo_string_add (xo_string_list_t *listp, const char *str)
|
||||
{
|
||||
if (listp == NULL || str == NULL)
|
||||
return NULL;
|
||||
|
||||
xo_string_list_init(listp);
|
||||
size_t len = strlen(str);
|
||||
xo_string_node_t *xsp;
|
||||
|
||||
xsp = xo_realloc(NULL, sizeof(*xsp) + len + 1);
|
||||
if (xsp) {
|
||||
memcpy(xsp->xs_data, str, len);
|
||||
xsp->xs_data[len] = '\0';
|
||||
TAILQ_INSERT_TAIL(listp, xsp, xs_link);
|
||||
}
|
||||
|
||||
return xsp;
|
||||
}
|
||||
|
||||
#define XO_STRING_LIST_FOREACH(_xsp, _listp) \
|
||||
xo_string_list_init(_listp); \
|
||||
TAILQ_FOREACH(_xsp, _listp, xs_link)
|
||||
|
||||
static inline void
|
||||
xo_string_list_clean (xo_string_list_t *listp)
|
||||
{
|
||||
xo_string_node_t *xsp;
|
||||
|
||||
xo_string_list_init(listp);
|
||||
|
||||
for (;;) {
|
||||
xsp = TAILQ_FIRST(listp);
|
||||
if (xsp == NULL)
|
||||
break;
|
||||
TAILQ_REMOVE(listp, xsp, xs_link);
|
||||
xo_free(xsp);
|
||||
}
|
||||
}
|
||||
|
||||
static xo_string_list_t xo_encoder_path;
|
||||
|
||||
void
|
||||
xo_encoder_path_add (const char *path)
|
||||
{
|
||||
xo_encoder_setup();
|
||||
|
||||
if (path)
|
||||
xo_string_add(&xo_encoder_path, path);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
typedef struct xo_encoder_node_s {
|
||||
TAILQ_ENTRY(xo_encoder_node_s) xe_link; /* Next session */
|
||||
char *xe_name; /* Name for this encoder */
|
||||
xo_encoder_func_t xe_handler; /* Callback function */
|
||||
void *xe_dlhandle; /* dlopen handle */
|
||||
} xo_encoder_node_t;
|
||||
|
||||
typedef TAILQ_HEAD(xo_encoder_list_s, xo_encoder_node_s) xo_encoder_list_t;
|
||||
|
||||
#define XO_ENCODER_LIST_FOREACH(_xep, _listp) \
|
||||
xo_encoder_list_init(_listp); \
|
||||
TAILQ_FOREACH(_xep, _listp, xe_link)
|
||||
|
||||
static xo_encoder_list_t xo_encoders;
|
||||
|
||||
static void
|
||||
xo_encoder_list_init (xo_encoder_list_t *listp)
|
||||
{
|
||||
if (listp->tqh_last == NULL)
|
||||
TAILQ_INIT(listp);
|
||||
}
|
||||
|
||||
static xo_encoder_node_t *
|
||||
xo_encoder_list_add (const char *name)
|
||||
{
|
||||
if (name == NULL)
|
||||
return NULL;
|
||||
|
||||
xo_encoder_node_t *xep = xo_realloc(NULL, sizeof(*xep));
|
||||
if (xep) {
|
||||
int len = strlen(name) + 1;
|
||||
xep->xe_name = xo_realloc(NULL, len);
|
||||
if (xep->xe_name == NULL) {
|
||||
xo_free(xep);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(xep->xe_name, name, len);
|
||||
|
||||
TAILQ_INSERT_TAIL(&xo_encoders, xep, xe_link);
|
||||
}
|
||||
|
||||
return xep;
|
||||
}
|
||||
|
||||
void
|
||||
xo_encoders_clean (void)
|
||||
{
|
||||
xo_encoder_node_t *xep;
|
||||
|
||||
xo_encoder_setup();
|
||||
|
||||
for (;;) {
|
||||
xep = TAILQ_FIRST(&xo_encoders);
|
||||
if (xep == NULL)
|
||||
break;
|
||||
|
||||
TAILQ_REMOVE(&xo_encoders, xep, xe_link);
|
||||
|
||||
if (xep->xe_dlhandle)
|
||||
dlclose(xep->xe_dlhandle);
|
||||
|
||||
xo_free(xep);
|
||||
}
|
||||
|
||||
xo_string_list_clean(&xo_encoder_path);
|
||||
}
|
||||
|
||||
static void
|
||||
xo_encoder_setup (void)
|
||||
{
|
||||
static int initted;
|
||||
if (!initted) {
|
||||
initted = 1;
|
||||
|
||||
xo_string_list_init(&xo_encoder_path);
|
||||
xo_encoder_list_init(&xo_encoders);
|
||||
|
||||
xo_encoder_path_add(XO_ENCODERDIR);
|
||||
}
|
||||
}
|
||||
|
||||
static xo_encoder_node_t *
|
||||
xo_encoder_find (const char *name)
|
||||
{
|
||||
xo_encoder_node_t *xep;
|
||||
|
||||
xo_encoder_list_init(&xo_encoders);
|
||||
|
||||
XO_ENCODER_LIST_FOREACH(xep, &xo_encoders) {
|
||||
if (strcmp(xep->xe_name, name) == 0)
|
||||
return xep;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static xo_encoder_node_t *
|
||||
xo_encoder_discover (const char *name)
|
||||
{
|
||||
void *dlp = NULL;
|
||||
char buf[MAXPATHLEN];
|
||||
xo_string_node_t *xsp;
|
||||
xo_encoder_node_t *xep = NULL;
|
||||
|
||||
XO_STRING_LIST_FOREACH(xsp, &xo_encoder_path) {
|
||||
static const char fmt[] = "%s/%s.enc";
|
||||
char *dir = xsp->xs_data;
|
||||
size_t len = snprintf(buf, sizeof(buf), fmt, dir, name);
|
||||
|
||||
if (len > sizeof(buf)) /* Should not occur */
|
||||
continue;
|
||||
|
||||
dlp = dlopen((const char *) buf, RTLD_NOW);
|
||||
if (dlp)
|
||||
break;
|
||||
}
|
||||
|
||||
if (dlp) {
|
||||
/*
|
||||
* If the library exists, find the initializer function and
|
||||
* call it.
|
||||
*/
|
||||
xo_encoder_init_func_t func;
|
||||
|
||||
func = (xo_encoder_init_func_t) dlfunc(dlp, XO_ENCODER_INIT_NAME);
|
||||
if (func) {
|
||||
xo_encoder_init_args_t xei;
|
||||
|
||||
bzero(&xei, sizeof(xei));
|
||||
|
||||
xei.xei_version = XO_ENCODER_VERSION;
|
||||
int rc = func(&xei);
|
||||
if (rc == 0 && xei.xei_handler) {
|
||||
xep = xo_encoder_list_add(name);
|
||||
if (xep) {
|
||||
xep->xe_handler = xei.xei_handler;
|
||||
xep->xe_dlhandle = dlp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (xep == NULL)
|
||||
dlclose(dlp);
|
||||
}
|
||||
|
||||
return xep;
|
||||
}
|
||||
|
||||
void
|
||||
xo_encoder_register (const char *name, xo_encoder_func_t func)
|
||||
{
|
||||
xo_encoder_setup();
|
||||
|
||||
xo_encoder_node_t *xep = xo_encoder_find(name);
|
||||
|
||||
if (xep) /* "We alla-ready got one" */
|
||||
return;
|
||||
|
||||
xep = xo_encoder_list_add(name);
|
||||
if (xep)
|
||||
xep->xe_handler = func;
|
||||
}
|
||||
|
||||
void
|
||||
xo_encoder_unregister (const char *name)
|
||||
{
|
||||
xo_encoder_setup();
|
||||
|
||||
xo_encoder_node_t *xep = xo_encoder_find(name);
|
||||
if (xep) {
|
||||
TAILQ_REMOVE(&xo_encoders, xep, xe_link);
|
||||
xo_free(xep);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
xo_encoder_init (xo_handle_t *xop, const char *name)
|
||||
{
|
||||
xo_encoder_setup();
|
||||
|
||||
/* Can't have names containing '/' or ':' */
|
||||
if (strchr(name, '/') != NULL || strchr(name, ':') != NULL)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* First we look on the list of known (registered) encoders.
|
||||
* If we don't find it, we follow the set of paths to find
|
||||
* the encoding library.
|
||||
*/
|
||||
xo_encoder_node_t *xep = xo_encoder_find(name);
|
||||
if (xep == NULL) {
|
||||
xep = xo_encoder_discover(name);
|
||||
if (xep == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
xo_set_encoder(xop, xep->xe_handler);
|
||||
|
||||
return xo_encoder_handle(xop, XO_OP_CREATE, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* A couple of function varieties here, to allow for multiple
|
||||
* use cases. This variant is for when the main program knows
|
||||
* its own encoder needs.
|
||||
*/
|
||||
xo_handle_t *
|
||||
xo_encoder_create (const char *name, xo_xof_flags_t flags)
|
||||
{
|
||||
xo_handle_t *xop;
|
||||
|
||||
xop = xo_create(XO_STYLE_ENCODER, flags);
|
||||
if (xop) {
|
||||
if (xo_encoder_init(xop, name)) {
|
||||
xo_destroy(xop);
|
||||
xop = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return xop;
|
||||
}
|
||||
|
||||
int
|
||||
xo_encoder_handle (xo_handle_t *xop, xo_encoder_op_t op,
|
||||
const char *name, const char *value)
|
||||
{
|
||||
void *private = xo_get_private(xop);
|
||||
xo_encoder_func_t func = xo_get_encoder(xop);
|
||||
|
||||
if (func == NULL)
|
||||
return -1;
|
||||
|
||||
return func(xop, op, name, value, private);
|
||||
}
|
||||
|
||||
const char *
|
||||
xo_encoder_op_name (xo_encoder_op_t op)
|
||||
{
|
||||
static const char *names[] = {
|
||||
/* 0 */ "unknown",
|
||||
/* 1 */ "create",
|
||||
/* 2 */ "open_container",
|
||||
/* 3 */ "close_container",
|
||||
/* 4 */ "open_list",
|
||||
/* 5 */ "close_list",
|
||||
/* 6 */ "open_leaf_list",
|
||||
/* 7 */ "close_leaf_list",
|
||||
/* 8 */ "open_instance",
|
||||
/* 9 */ "close_instance",
|
||||
/* 10 */ "string",
|
||||
/* 11 */ "content",
|
||||
/* 12 */ "finish",
|
||||
/* 13 */ "flush",
|
||||
/* 14 */ "destroy",
|
||||
/* 15 */ "attr",
|
||||
/* 16 */ "version",
|
||||
};
|
||||
|
||||
if (op > sizeof(names) / sizeof(names[0]))
|
||||
return "unknown";
|
||||
|
||||
return names[op];
|
||||
}
|
||||
#else /* __rtems__ */
|
||||
|
||||
/*
|
||||
* Not supported on RTEMS. Just return errors on all functions.
|
||||
*/
|
||||
#include "xo.h"
|
||||
#include "xo_encoder.h"
|
||||
|
||||
void
|
||||
xo_encoder_register (const char *name, xo_encoder_func_t func)
|
||||
{
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
void
|
||||
xo_encoder_unregister (const char *name)
|
||||
{
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
void
|
||||
xo_encoder_path_add (const char *path)
|
||||
{
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
int
|
||||
xo_encoder_init (xo_handle_t *xop, const char *name)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
xo_handle_t *
|
||||
xo_encoder_create (const char *name, xo_xof_flags_t flags)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
xo_encoder_handle (xo_handle_t *xop, xo_encoder_op_t op,
|
||||
const char *name, const char *value)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
xo_encoders_clean (void)
|
||||
{
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
const char *
|
||||
xo_encoder_op_name (xo_encoder_op_t op)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
#endif /* __rtems__ */
|
116
freebsd/contrib/libxo/libxo/xo_encoder.h
Normal file
116
freebsd/contrib/libxo/libxo/xo_encoder.h
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Juniper Networks, Inc.
|
||||
* All rights reserved.
|
||||
* This SOFTWARE is licensed under the LICENSE provided in the
|
||||
* ../Copyright file. By downloading, installing, copying, or otherwise
|
||||
* using the SOFTWARE, you agree to be bound by the terms of that
|
||||
* LICENSE.
|
||||
* Phil Shafer, August 2015
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE WELL: This file is needed to software that implements an
|
||||
* external encoder for libxo that allows libxo data to be encoded in
|
||||
* new and bizarre formats. General libxo code should _never_
|
||||
* include this header file.
|
||||
*/
|
||||
|
||||
#ifndef XO_ENCODER_H
|
||||
#define XO_ENCODER_H
|
||||
|
||||
/*
|
||||
* Expose libxo's memory allocation functions
|
||||
*/
|
||||
extern xo_realloc_func_t xo_realloc;
|
||||
extern xo_free_func_t xo_free;
|
||||
|
||||
typedef unsigned xo_encoder_op_t;
|
||||
|
||||
/* Encoder operations; names are in xo_encoder.c:xo_encoder_op_name() */
|
||||
#define XO_OP_UNKNOWN 0
|
||||
#define XO_OP_CREATE 1 /* Called when the handle is init'd */
|
||||
#define XO_OP_OPEN_CONTAINER 2
|
||||
#define XO_OP_CLOSE_CONTAINER 3
|
||||
#define XO_OP_OPEN_LIST 4
|
||||
#define XO_OP_CLOSE_LIST 5
|
||||
#define XO_OP_OPEN_LEAF_LIST 6
|
||||
#define XO_OP_CLOSE_LEAF_LIST 7
|
||||
#define XO_OP_OPEN_INSTANCE 8
|
||||
#define XO_OP_CLOSE_INSTANCE 9
|
||||
#define XO_OP_STRING 10 /* Quoted UTF-8 string */
|
||||
#define XO_OP_CONTENT 11 /* Other content */
|
||||
#define XO_OP_FINISH 12 /* Finish any pending output */
|
||||
#define XO_OP_FLUSH 13 /* Flush any buffered output */
|
||||
#define XO_OP_DESTROY 14 /* Clean up function */
|
||||
#define XO_OP_ATTRIBUTE 15 /* Attribute name/value */
|
||||
#define XO_OP_VERSION 16 /* Version string */
|
||||
|
||||
#define XO_ENCODER_HANDLER_ARGS \
|
||||
xo_handle_t *xop __attribute__ ((__unused__)), \
|
||||
xo_encoder_op_t op __attribute__ ((__unused__)), \
|
||||
const char *name __attribute__ ((__unused__)), \
|
||||
const char *value __attribute__ ((__unused__)), \
|
||||
void *private __attribute__ ((__unused__))
|
||||
|
||||
typedef int (*xo_encoder_func_t)(XO_ENCODER_HANDLER_ARGS);
|
||||
|
||||
typedef struct xo_encoder_init_args_s {
|
||||
unsigned xei_version; /* Current version */
|
||||
xo_encoder_func_t xei_handler; /* Encoding handler */
|
||||
} xo_encoder_init_args_t;
|
||||
|
||||
#define XO_ENCODER_VERSION 1 /* Current version */
|
||||
|
||||
#define XO_ENCODER_INIT_ARGS \
|
||||
xo_encoder_init_args_t *arg __attribute__ ((__unused__))
|
||||
|
||||
typedef int (*xo_encoder_init_func_t)(XO_ENCODER_INIT_ARGS);
|
||||
/*
|
||||
* Each encoder library must define a function named xo_encoder_init
|
||||
* that takes the arguments defined in XO_ENCODER_INIT_ARGS. It
|
||||
* should return zero for success.
|
||||
*/
|
||||
#define XO_ENCODER_INIT_NAME_TOKEN xo_encoder_library_init
|
||||
#define XO_STRINGIFY(_x) #_x
|
||||
#define XO_STRINGIFY2(_x) XO_STRINGIFY(_x)
|
||||
#define XO_ENCODER_INIT_NAME XO_STRINGIFY2(XO_ENCODER_INIT_NAME_TOKEN)
|
||||
extern int XO_ENCODER_INIT_NAME_TOKEN (XO_ENCODER_INIT_ARGS);
|
||||
|
||||
void
|
||||
xo_encoder_register (const char *name, xo_encoder_func_t func);
|
||||
|
||||
void
|
||||
xo_encoder_unregister (const char *name);
|
||||
|
||||
void *
|
||||
xo_get_private (xo_handle_t *xop);
|
||||
|
||||
void
|
||||
xo_encoder_path_add (const char *path);
|
||||
|
||||
void
|
||||
xo_set_private (xo_handle_t *xop, void *opaque);
|
||||
|
||||
xo_encoder_func_t
|
||||
xo_get_encoder (xo_handle_t *xop);
|
||||
|
||||
void
|
||||
xo_set_encoder (xo_handle_t *xop, xo_encoder_func_t encoder);
|
||||
|
||||
int
|
||||
xo_encoder_init (xo_handle_t *xop, const char *name);
|
||||
|
||||
xo_handle_t *
|
||||
xo_encoder_create (const char *name, xo_xof_flags_t flags);
|
||||
|
||||
int
|
||||
xo_encoder_handle (xo_handle_t *xop, xo_encoder_op_t op,
|
||||
const char *name, const char *value);
|
||||
|
||||
void
|
||||
xo_encoders_clean (void);
|
||||
|
||||
const char *
|
||||
xo_encoder_op_name (xo_encoder_op_t op);
|
||||
|
||||
#endif /* XO_ENCODER_H */
|
169
freebsd/contrib/libxo/libxo/xo_humanize.h
Normal file
169
freebsd/contrib/libxo/libxo/xo_humanize.h
Normal file
@ -0,0 +1,169 @@
|
||||
/* $NetBSD: humanize_number.c,v 1.8 2004/07/27 01:56:24 enami Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
||||
* NASA Ames Research Center, by Luke Mewburn and by Tomas Svensson.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* humanize_number(3) */
|
||||
#define HN_DECIMAL 0x01
|
||||
#define HN_NOSPACE 0x02
|
||||
#define HN_B 0x04
|
||||
#define HN_DIVISOR_1000 0x08
|
||||
|
||||
#define HN_GETSCALE 0x10
|
||||
#define HN_AUTOSCALE 0x20
|
||||
|
||||
static int
|
||||
xo_humanize_number (char *buf, size_t len, int64_t bytes,
|
||||
const char *suffix, int scale, int flags)
|
||||
{
|
||||
const char *prefixes, *sep;
|
||||
int b, i, r, maxscale, s1, s2, sign;
|
||||
int64_t divisor, max;
|
||||
// We multiply bytes by 100 to deal with rounding, so we need something
|
||||
// big enough to hold LLONG_MAX * 100. On 64-bit we can use 128-bit wide
|
||||
// integers with __int128_t, but on 32-bit we have to use long double.
|
||||
#ifdef __LP64__
|
||||
__int128_t scalable = (__int128_t)bytes;
|
||||
#else
|
||||
long double scalable = (long double)bytes;
|
||||
#endif
|
||||
size_t baselen;
|
||||
|
||||
assert(buf != NULL);
|
||||
assert(suffix != NULL);
|
||||
assert(scale >= 0);
|
||||
|
||||
if (flags & HN_DIVISOR_1000) {
|
||||
/* SI for decimal multiplies */
|
||||
divisor = 1000;
|
||||
if (flags & HN_B)
|
||||
prefixes = "B\0k\0M\0G\0T\0P\0E";
|
||||
else
|
||||
prefixes = "\0\0k\0M\0G\0T\0P\0E";
|
||||
} else {
|
||||
/*
|
||||
* binary multiplies
|
||||
* XXX IEC 60027-2 recommends Ki, Mi, Gi...
|
||||
*/
|
||||
divisor = 1024;
|
||||
if (flags & HN_B)
|
||||
prefixes = "B\0K\0M\0G\0T\0P\0E";
|
||||
else
|
||||
prefixes = "\0\0K\0M\0G\0T\0P\0E";
|
||||
}
|
||||
|
||||
#define SCALE2PREFIX(scale) (&prefixes[(scale) << 1])
|
||||
maxscale = 7;
|
||||
|
||||
if (scale >= maxscale &&
|
||||
(scale & (HN_AUTOSCALE | HN_GETSCALE)) == 0)
|
||||
return (-1);
|
||||
|
||||
if (buf == NULL || suffix == NULL)
|
||||
return (-1);
|
||||
|
||||
if (len > 0)
|
||||
buf[0] = '\0';
|
||||
if (bytes < 0) {
|
||||
sign = -1;
|
||||
scalable *= -100;
|
||||
baselen = 3; /* sign, digit, prefix */
|
||||
} else {
|
||||
sign = 1;
|
||||
scalable *= 100;
|
||||
baselen = 2; /* digit, prefix */
|
||||
}
|
||||
if (flags & HN_NOSPACE)
|
||||
sep = "";
|
||||
else {
|
||||
sep = " ";
|
||||
baselen++;
|
||||
}
|
||||
baselen += strlen(suffix);
|
||||
|
||||
/* Check if enough room for `x y' + suffix + `\0' */
|
||||
if (len < baselen + 1)
|
||||
return (-1);
|
||||
|
||||
if (scale & (HN_AUTOSCALE | HN_GETSCALE)) {
|
||||
/* See if there is additional columns can be used. */
|
||||
for (max = 100, i = len - baselen; i-- > 0;)
|
||||
max *= 10;
|
||||
|
||||
for (i = 0; scalable >= max && i < maxscale; i++)
|
||||
scalable /= divisor;
|
||||
|
||||
if (scale & HN_GETSCALE)
|
||||
return (i);
|
||||
} else
|
||||
for (i = 0; i < scale && i < maxscale; i++)
|
||||
scalable /= divisor;
|
||||
|
||||
/* If a value <= 9.9 after rounding and ... */
|
||||
if (scalable < 995 && i > 0 && flags & HN_DECIMAL) {
|
||||
/* baselen + \0 + .N */
|
||||
if (len < baselen + 1 + 2)
|
||||
return (-1);
|
||||
b = ((int)scalable + 5) / 10;
|
||||
s1 = b / 10;
|
||||
s2 = b % 10;
|
||||
r = snprintf(buf, len, "%s%d%s%d%s%s%s",
|
||||
((sign == -1) ? "-" : ""),
|
||||
s1, localeconv()->decimal_point, s2,
|
||||
sep, SCALE2PREFIX(i), suffix);
|
||||
} else
|
||||
r = snprintf(buf, len, "%s%lld%s%s%s",
|
||||
/* LONGLONG */
|
||||
((sign == -1) ? "-" : ""),
|
||||
(long long)((scalable + 50) / 100),
|
||||
sep, SCALE2PREFIX(i), suffix);
|
||||
|
||||
return (r);
|
||||
}
|
313
freebsd/contrib/libxo/libxo/xo_wcwidth.h
Normal file
313
freebsd/contrib/libxo/libxo/xo_wcwidth.h
Normal file
@ -0,0 +1,313 @@
|
||||
/*
|
||||
* This is an implementation of wcwidth() and wcswidth() (defined in
|
||||
* IEEE Std 1002.1-2001) for Unicode.
|
||||
*
|
||||
* http://www.opengroup.org/onlinepubs/007904975/functions/wcwidth.html
|
||||
* http://www.opengroup.org/onlinepubs/007904975/functions/wcswidth.html
|
||||
*
|
||||
* In fixed-width output devices, Latin characters all occupy a single
|
||||
* "cell" position of equal width, whereas ideographic CJK characters
|
||||
* occupy two such cells. Interoperability between terminal-line
|
||||
* applications and (teletype-style) character terminals using the
|
||||
* UTF-8 encoding requires agreement on which character should advance
|
||||
* the cursor by how many cell positions. No established formal
|
||||
* standards exist at present on which Unicode character shall occupy
|
||||
* how many cell positions on character terminals. These routines are
|
||||
* a first attempt of defining such behavior based on simple rules
|
||||
* applied to data provided by the Unicode Consortium.
|
||||
*
|
||||
* For some graphical characters, the Unicode standard explicitly
|
||||
* defines a character-cell width via the definition of the East Asian
|
||||
* FullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes.
|
||||
* In all these cases, there is no ambiguity about which width a
|
||||
* terminal shall use. For characters in the East Asian Ambiguous (A)
|
||||
* class, the width choice depends purely on a preference of backward
|
||||
* compatibility with either historic CJK or Western practice.
|
||||
* Choosing single-width for these characters is easy to justify as
|
||||
* the appropriate long-term solution, as the CJK practice of
|
||||
* displaying these characters as double-width comes from historic
|
||||
* implementation simplicity (8-bit encoded characters were displayed
|
||||
* single-width and 16-bit ones double-width, even for Greek,
|
||||
* Cyrillic, etc.) and not any typographic considerations.
|
||||
*
|
||||
* Much less clear is the choice of width for the Not East Asian
|
||||
* (Neutral) class. Existing practice does not dictate a width for any
|
||||
* of these characters. It would nevertheless make sense
|
||||
* typographically to allocate two character cells to characters such
|
||||
* as for instance EM SPACE or VOLUME INTEGRAL, which cannot be
|
||||
* represented adequately with a single-width glyph. The following
|
||||
* routines at present merely assign a single-cell width to all
|
||||
* neutral characters, in the interest of simplicity. This is not
|
||||
* entirely satisfactory and should be reconsidered before
|
||||
* establishing a formal standard in this area. At the moment, the
|
||||
* decision which Not East Asian (Neutral) characters should be
|
||||
* represented by double-width glyphs cannot yet be answered by
|
||||
* applying a simple rule from the Unicode database content. Setting
|
||||
* up a proper standard for the behavior of UTF-8 character terminals
|
||||
* will require a careful analysis not only of each Unicode character,
|
||||
* but also of each presentation form, something the author of these
|
||||
* routines has avoided to do so far.
|
||||
*
|
||||
* http://www.unicode.org/unicode/reports/tr11/
|
||||
*
|
||||
* Markus Kuhn -- 2007-05-26 (Unicode 5.0)
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* for any purpose and without fee is hereby granted. The author
|
||||
* disclaims all warranties with regard to this software.
|
||||
*
|
||||
* Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
struct interval {
|
||||
wchar_t first;
|
||||
wchar_t last;
|
||||
};
|
||||
|
||||
/* auxiliary function for binary search in interval table */
|
||||
static int
|
||||
xo_bisearch (wchar_t ucs, const struct interval *table, int max)
|
||||
{
|
||||
int min = 0;
|
||||
int mid;
|
||||
|
||||
if (ucs < table[0].first || ucs > table[max].last)
|
||||
return 0;
|
||||
while (max >= min) {
|
||||
mid = (min + max) / 2;
|
||||
if (ucs > table[mid].last)
|
||||
min = mid + 1;
|
||||
else if (ucs < table[mid].first)
|
||||
max = mid - 1;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* The following two functions define the column width of an ISO 10646
|
||||
* character as follows:
|
||||
*
|
||||
* - The null character (U+0000) has a column width of 0.
|
||||
*
|
||||
* - Other C0/C1 control characters and DEL will lead to a return
|
||||
* value of -1.
|
||||
*
|
||||
* - Non-spacing and enclosing combining characters (general
|
||||
* category code Mn or Me in the Unicode database) have a
|
||||
* column width of 0.
|
||||
*
|
||||
* - SOFT HYPHEN (U+00AD) has a column width of 1.
|
||||
*
|
||||
* - Other format characters (general category code Cf in the Unicode
|
||||
* database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
|
||||
*
|
||||
* - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
|
||||
* have a column width of 0.
|
||||
*
|
||||
* - Spacing characters in the East Asian Wide (W) or East Asian
|
||||
* Full-width (F) category as defined in Unicode Technical
|
||||
* Report #11 have a column width of 2.
|
||||
*
|
||||
* - All remaining characters (including all printable
|
||||
* ISO 8859-1 and WGL4 characters, Unicode control characters,
|
||||
* etc.) have a column width of 1.
|
||||
*
|
||||
* This implementation assumes that wchar_t characters are encoded
|
||||
* in ISO 10646.
|
||||
*/
|
||||
|
||||
static int
|
||||
xo_wcwidth (wchar_t ucs)
|
||||
{
|
||||
/* sorted list of non-overlapping intervals of non-spacing characters */
|
||||
/* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
|
||||
static const struct interval combining[] = {
|
||||
{ 0x0300, 0x036F }, { 0x0483, 0x0486 }, { 0x0488, 0x0489 },
|
||||
{ 0x0591, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
|
||||
{ 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, { 0x0600, 0x0603 },
|
||||
{ 0x0610, 0x0615 }, { 0x064B, 0x065E }, { 0x0670, 0x0670 },
|
||||
{ 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
|
||||
{ 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
|
||||
{ 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, { 0x0901, 0x0902 },
|
||||
{ 0x093C, 0x093C }, { 0x0941, 0x0948 }, { 0x094D, 0x094D },
|
||||
{ 0x0951, 0x0954 }, { 0x0962, 0x0963 }, { 0x0981, 0x0981 },
|
||||
{ 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD },
|
||||
{ 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C },
|
||||
{ 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D },
|
||||
{ 0x0A70, 0x0A71 }, { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC },
|
||||
{ 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD },
|
||||
{ 0x0AE2, 0x0AE3 }, { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C },
|
||||
{ 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, { 0x0B4D, 0x0B4D },
|
||||
{ 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 },
|
||||
{ 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 },
|
||||
{ 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0CBC, 0x0CBC },
|
||||
{ 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
|
||||
{ 0x0CE2, 0x0CE3 }, { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D },
|
||||
{ 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 },
|
||||
{ 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E },
|
||||
{ 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC },
|
||||
{ 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 },
|
||||
{ 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E },
|
||||
{ 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 },
|
||||
{ 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 },
|
||||
{ 0x1032, 0x1032 }, { 0x1036, 0x1037 }, { 0x1039, 0x1039 },
|
||||
{ 0x1058, 0x1059 }, { 0x1160, 0x11FF }, { 0x135F, 0x135F },
|
||||
{ 0x1712, 0x1714 }, { 0x1732, 0x1734 }, { 0x1752, 0x1753 },
|
||||
{ 0x1772, 0x1773 }, { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD },
|
||||
{ 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD },
|
||||
{ 0x180B, 0x180D }, { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 },
|
||||
{ 0x1927, 0x1928 }, { 0x1932, 0x1932 }, { 0x1939, 0x193B },
|
||||
{ 0x1A17, 0x1A18 }, { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 },
|
||||
{ 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 },
|
||||
{ 0x1B6B, 0x1B73 }, { 0x1DC0, 0x1DCA }, { 0x1DFE, 0x1DFF },
|
||||
{ 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2063 },
|
||||
{ 0x206A, 0x206F }, { 0x20D0, 0x20EF }, { 0x302A, 0x302F },
|
||||
{ 0x3099, 0x309A }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B },
|
||||
{ 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F },
|
||||
{ 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB },
|
||||
{ 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F },
|
||||
{ 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x1D167, 0x1D169 },
|
||||
{ 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD },
|
||||
{ 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F },
|
||||
{ 0xE0100, 0xE01EF }
|
||||
};
|
||||
|
||||
/* test for 8-bit control characters */
|
||||
if (ucs == 0)
|
||||
return 0;
|
||||
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
|
||||
return -1;
|
||||
|
||||
/* binary search in table of non-spacing characters */
|
||||
if (xo_bisearch(ucs, combining,
|
||||
sizeof(combining) / sizeof(struct interval) - 1))
|
||||
return 0;
|
||||
|
||||
/* if we arrive here, ucs is not a combining or C0/C1 control character */
|
||||
|
||||
return 1 +
|
||||
(ucs >= 0x1100 &&
|
||||
(ucs <= 0x115f || /* Hangul Jamo init. consonants */
|
||||
ucs == 0x2329 || ucs == 0x232a ||
|
||||
(ucs >= 0x2e80 && ucs <= 0xa4cf &&
|
||||
ucs != 0x303f) || /* CJK ... Yi */
|
||||
(ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
|
||||
(ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
|
||||
(ucs >= 0xfe10 && ucs <= 0xfe19) || /* Vertical forms */
|
||||
(ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
|
||||
(ucs >= 0xff00 && ucs <= 0xff60) || /* Fullwidth Forms */
|
||||
(ucs >= 0xffe0 && ucs <= 0xffe6) ||
|
||||
(ucs >= 0x20000 && ucs <= 0x2fffd) ||
|
||||
(ucs >= 0x30000 && ucs <= 0x3fffd)));
|
||||
}
|
||||
|
||||
#if UNUSED_CODE
|
||||
static int xo_wcswidth(const wchar_t *pwcs, size_t n)
|
||||
{
|
||||
int w, width = 0;
|
||||
|
||||
for (;*pwcs && n-- > 0; pwcs++)
|
||||
if ((w = mk_wcwidth(*pwcs)) < 0)
|
||||
return -1;
|
||||
else
|
||||
width += w;
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The following functions are the same as mk_wcwidth() and
|
||||
* mk_wcswidth(), except that spacing characters in the East Asian
|
||||
* Ambiguous (A) category as defined in Unicode Technical Report #11
|
||||
* have a column width of 2. This variant might be useful for users of
|
||||
* CJK legacy encodings who want to migrate to UCS without changing
|
||||
* the traditional terminal character-width behaviour. It is not
|
||||
* otherwise recommended for general use.
|
||||
*/
|
||||
int mk_wcwidth_cjk(wchar_t ucs)
|
||||
{
|
||||
/* sorted list of non-overlapping intervals of East Asian Ambiguous
|
||||
* characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
|
||||
static const struct interval ambiguous[] = {
|
||||
{ 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 },
|
||||
{ 0x00AA, 0x00AA }, { 0x00AE, 0x00AE }, { 0x00B0, 0x00B4 },
|
||||
{ 0x00B6, 0x00BA }, { 0x00BC, 0x00BF }, { 0x00C6, 0x00C6 },
|
||||
{ 0x00D0, 0x00D0 }, { 0x00D7, 0x00D8 }, { 0x00DE, 0x00E1 },
|
||||
{ 0x00E6, 0x00E6 }, { 0x00E8, 0x00EA }, { 0x00EC, 0x00ED },
|
||||
{ 0x00F0, 0x00F0 }, { 0x00F2, 0x00F3 }, { 0x00F7, 0x00FA },
|
||||
{ 0x00FC, 0x00FC }, { 0x00FE, 0x00FE }, { 0x0101, 0x0101 },
|
||||
{ 0x0111, 0x0111 }, { 0x0113, 0x0113 }, { 0x011B, 0x011B },
|
||||
{ 0x0126, 0x0127 }, { 0x012B, 0x012B }, { 0x0131, 0x0133 },
|
||||
{ 0x0138, 0x0138 }, { 0x013F, 0x0142 }, { 0x0144, 0x0144 },
|
||||
{ 0x0148, 0x014B }, { 0x014D, 0x014D }, { 0x0152, 0x0153 },
|
||||
{ 0x0166, 0x0167 }, { 0x016B, 0x016B }, { 0x01CE, 0x01CE },
|
||||
{ 0x01D0, 0x01D0 }, { 0x01D2, 0x01D2 }, { 0x01D4, 0x01D4 },
|
||||
{ 0x01D6, 0x01D6 }, { 0x01D8, 0x01D8 }, { 0x01DA, 0x01DA },
|
||||
{ 0x01DC, 0x01DC }, { 0x0251, 0x0251 }, { 0x0261, 0x0261 },
|
||||
{ 0x02C4, 0x02C4 }, { 0x02C7, 0x02C7 }, { 0x02C9, 0x02CB },
|
||||
{ 0x02CD, 0x02CD }, { 0x02D0, 0x02D0 }, { 0x02D8, 0x02DB },
|
||||
{ 0x02DD, 0x02DD }, { 0x02DF, 0x02DF }, { 0x0391, 0x03A1 },
|
||||
{ 0x03A3, 0x03A9 }, { 0x03B1, 0x03C1 }, { 0x03C3, 0x03C9 },
|
||||
{ 0x0401, 0x0401 }, { 0x0410, 0x044F }, { 0x0451, 0x0451 },
|
||||
{ 0x2010, 0x2010 }, { 0x2013, 0x2016 }, { 0x2018, 0x2019 },
|
||||
{ 0x201C, 0x201D }, { 0x2020, 0x2022 }, { 0x2024, 0x2027 },
|
||||
{ 0x2030, 0x2030 }, { 0x2032, 0x2033 }, { 0x2035, 0x2035 },
|
||||
{ 0x203B, 0x203B }, { 0x203E, 0x203E }, { 0x2074, 0x2074 },
|
||||
{ 0x207F, 0x207F }, { 0x2081, 0x2084 }, { 0x20AC, 0x20AC },
|
||||
{ 0x2103, 0x2103 }, { 0x2105, 0x2105 }, { 0x2109, 0x2109 },
|
||||
{ 0x2113, 0x2113 }, { 0x2116, 0x2116 }, { 0x2121, 0x2122 },
|
||||
{ 0x2126, 0x2126 }, { 0x212B, 0x212B }, { 0x2153, 0x2154 },
|
||||
{ 0x215B, 0x215E }, { 0x2160, 0x216B }, { 0x2170, 0x2179 },
|
||||
{ 0x2190, 0x2199 }, { 0x21B8, 0x21B9 }, { 0x21D2, 0x21D2 },
|
||||
{ 0x21D4, 0x21D4 }, { 0x21E7, 0x21E7 }, { 0x2200, 0x2200 },
|
||||
{ 0x2202, 0x2203 }, { 0x2207, 0x2208 }, { 0x220B, 0x220B },
|
||||
{ 0x220F, 0x220F }, { 0x2211, 0x2211 }, { 0x2215, 0x2215 },
|
||||
{ 0x221A, 0x221A }, { 0x221D, 0x2220 }, { 0x2223, 0x2223 },
|
||||
{ 0x2225, 0x2225 }, { 0x2227, 0x222C }, { 0x222E, 0x222E },
|
||||
{ 0x2234, 0x2237 }, { 0x223C, 0x223D }, { 0x2248, 0x2248 },
|
||||
{ 0x224C, 0x224C }, { 0x2252, 0x2252 }, { 0x2260, 0x2261 },
|
||||
{ 0x2264, 0x2267 }, { 0x226A, 0x226B }, { 0x226E, 0x226F },
|
||||
{ 0x2282, 0x2283 }, { 0x2286, 0x2287 }, { 0x2295, 0x2295 },
|
||||
{ 0x2299, 0x2299 }, { 0x22A5, 0x22A5 }, { 0x22BF, 0x22BF },
|
||||
{ 0x2312, 0x2312 }, { 0x2460, 0x24E9 }, { 0x24EB, 0x254B },
|
||||
{ 0x2550, 0x2573 }, { 0x2580, 0x258F }, { 0x2592, 0x2595 },
|
||||
{ 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 }, { 0x25B2, 0x25B3 },
|
||||
{ 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD }, { 0x25C0, 0x25C1 },
|
||||
{ 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB }, { 0x25CE, 0x25D1 },
|
||||
{ 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF }, { 0x2605, 0x2606 },
|
||||
{ 0x2609, 0x2609 }, { 0x260E, 0x260F }, { 0x2614, 0x2615 },
|
||||
{ 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 },
|
||||
{ 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 },
|
||||
{ 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F },
|
||||
{ 0x273D, 0x273D }, { 0x2776, 0x277F }, { 0xE000, 0xF8FF },
|
||||
{ 0xFFFD, 0xFFFD }, { 0xF0000, 0xFFFFD }, { 0x100000, 0x10FFFD }
|
||||
};
|
||||
|
||||
/* binary search in table of non-spacing characters */
|
||||
if (xo_bisearch(ucs, ambiguous,
|
||||
sizeof(ambiguous) / sizeof(struct interval) - 1))
|
||||
return 2;
|
||||
|
||||
return mk_wcwidth(ucs);
|
||||
}
|
||||
|
||||
|
||||
int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
|
||||
{
|
||||
int w, width = 0;
|
||||
|
||||
for (;*pwcs && n-- > 0; pwcs++)
|
||||
if ((w = mk_wcwidth_cjk(*pwcs)) < 0)
|
||||
return -1;
|
||||
else
|
||||
width += w;
|
||||
|
||||
return width;
|
||||
}
|
||||
#endif /* UNUSED_CODE */
|
@ -1,26 +0,0 @@
|
||||
#include <rtems/linkersets.h>
|
||||
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, extern int altqsupport);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static char*anchoropt);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static const char *clearopt);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static const char *debugopt);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, extern int dev);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int first_title);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static char*ifaceopt);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int labels);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, extern int loadopt);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static const char *optiopt);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl,
|
||||
static struct pf_anchor_global pf_anchors);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static const char *pf_device);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl,
|
||||
static struct pf_anchor pf_main_anchor);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static char*rulesopt);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static const char *showopt);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static char*src_node_kill[2]);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int src_node_killers);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static char*state_kill[2]);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int state_killers);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static char*tableopt);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static const char *tblcmdopt);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static const char *tblcmdopt);
|
@ -1,13 +0,0 @@
|
||||
#include <rtems/linkersets.h>
|
||||
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int add_opt_table_num);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int pf_opt_create_table_num);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl,
|
||||
static struct pf_rule_field pf_rule_desc[]);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int
|
||||
(*skip_comparitors[PF_SKIP_COUNT])(struct pf_rule *, struct pf_rule *));
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl,
|
||||
static const char *skip_comparitors_names[PF_SKIP_COUNT]);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl,
|
||||
static struct pfr_buffer table_buffer);
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static int table_identifier);
|
@ -1,3 +0,0 @@
|
||||
#include <rtems/linkersets.h>
|
||||
|
||||
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_pfctl, static char next_ch);
|
@ -106,7 +106,7 @@ typedef enum __ns_sect {
|
||||
} ns_sect;
|
||||
|
||||
/*%
|
||||
* Network name (compressed or not) type. Equivilent to a pointer when used
|
||||
* Network name (compressed or not) type. Equivalent to a pointer when used
|
||||
* in a function prototype. Can be const'd.
|
||||
*/
|
||||
typedef u_char ns_nname[NS_MAXNNAME];
|
||||
|
@ -67,7 +67,7 @@ typedef struct {
|
||||
/* fields in third byte */
|
||||
unsigned qr: 1; /*%< response flag */
|
||||
unsigned opcode: 4; /*%< purpose of message */
|
||||
unsigned aa: 1; /*%< authoritive answer */
|
||||
unsigned aa: 1; /*%< authoritative answer */
|
||||
unsigned tc: 1; /*%< truncated message */
|
||||
unsigned rd: 1; /*%< recursion desired */
|
||||
/* fields in fourth byte */
|
||||
@ -81,7 +81,7 @@ typedef struct {
|
||||
/* fields in third byte */
|
||||
unsigned rd :1; /*%< recursion desired */
|
||||
unsigned tc :1; /*%< truncated message */
|
||||
unsigned aa :1; /*%< authoritive answer */
|
||||
unsigned aa :1; /*%< authoritative answer */
|
||||
unsigned opcode :4; /*%< purpose of message */
|
||||
unsigned qr :1; /*%< response flag */
|
||||
/* fields in fourth byte */
|
||||
|
@ -31,21 +31,46 @@
|
||||
#ifndef _GSSAPI_GSSAPI_H_
|
||||
#define _GSSAPI_GSSAPI_H_
|
||||
|
||||
/*
|
||||
* First, include stddef.h to get size_t defined.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/_types.h>
|
||||
|
||||
/*
|
||||
* Include stdint.h to get explicitly sized data types.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#ifndef _SIZE_T_DECLARED
|
||||
typedef __size_t size_t;
|
||||
#define _SIZE_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef _SSIZE_T_DECLARED
|
||||
typedef __ssize_t ssize_t;
|
||||
#define _SSIZE_T_DECLARED
|
||||
#endif
|
||||
|
||||
/* Compatibility with Heimdal 1.5.1 */
|
||||
#ifndef GSSAPI_CPP_START
|
||||
#ifdef __cplusplus
|
||||
#define GSSAPI_CPP_START extern "C" {
|
||||
#define GSSAPI_CPP_END }
|
||||
#else
|
||||
#define GSSAPI_CPP_START
|
||||
#define GSSAPI_CPP_END
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Compatibility with Heimdal 1.5.1 */
|
||||
#ifndef BUILD_GSSAPI_LIB
|
||||
#define GSSAPI_LIB_FUNCTION
|
||||
#define GSSAPI_LIB_CALL
|
||||
#define GSSAPI_LIB_VARIABLE
|
||||
#endif
|
||||
|
||||
/* Compatibility with Heimdal 1.5.1 */
|
||||
#ifndef GSSAPI_DEPRECATED_FUNCTION
|
||||
#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1 )))
|
||||
#define GSSAPI_DEPRECATED_FUNCTION(X) __attribute__((deprecated))
|
||||
#else
|
||||
#define GSSAPI_DEPRECATED_FUNCTION(X)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* If the platform supports the xom.h header file, it should be
|
||||
@ -67,7 +92,7 @@ typedef struct _gss_name_t *gss_name_t;
|
||||
* unsigned integer supported by the platform that has at least
|
||||
* 32 bits of precision.
|
||||
*/
|
||||
typedef uint32_t gss_uint32;
|
||||
typedef __uint32_t gss_uint32;
|
||||
|
||||
|
||||
#ifdef OM_STRING
|
||||
@ -89,7 +114,7 @@ typedef OM_object_identifier gss_OID_desc, *gss_OID;
|
||||
*/
|
||||
|
||||
typedef gss_uint32 OM_uint32;
|
||||
typedef uint64_t OM_uint64;
|
||||
typedef __uint64_t OM_uint64;
|
||||
|
||||
typedef struct gss_OID_desc_struct {
|
||||
OM_uint32 length;
|
||||
@ -756,11 +781,11 @@ OM_uint32 gss_release_oid
|
||||
OM_uint32 gss_decapsulate_token
|
||||
(const gss_buffer_t, /* mechanism independent token */
|
||||
gss_OID, /* desired mechanism */
|
||||
gss_buffer_t /* decapsulated mechanism dependant token */
|
||||
gss_buffer_t /* decapsulated mechanism dependent token */
|
||||
);
|
||||
|
||||
OM_uint32 gss_encapsulate_token
|
||||
(const gss_buffer_t, /* mechanism dependant token */
|
||||
(const gss_buffer_t, /* mechanism dependent token */
|
||||
gss_OID, /* desired mechanism */
|
||||
gss_buffer_t /* encapsulated mechanism independent token */
|
||||
);
|
||||
|
@ -31,7 +31,7 @@
|
||||
struct ifaddrs {
|
||||
struct ifaddrs *ifa_next;
|
||||
char *ifa_name;
|
||||
u_int ifa_flags;
|
||||
unsigned int ifa_flags;
|
||||
struct sockaddr *ifa_addr;
|
||||
struct sockaddr *ifa_netmask;
|
||||
struct sockaddr *ifa_dstaddr;
|
||||
|
@ -60,6 +60,16 @@
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/_types.h>
|
||||
|
||||
#ifndef _IN_ADDR_T_DECLARED
|
||||
typedef __uint32_t in_addr_t;
|
||||
#define _IN_ADDR_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef _IN_PORT_T_DECLARED
|
||||
typedef __uint16_t in_port_t;
|
||||
#define _IN_PORT_T_DECLARED
|
||||
#endif
|
||||
|
||||
#ifndef _SIZE_T_DECLARED
|
||||
typedef __size_t size_t;
|
||||
#define _SIZE_T_DECLARED
|
||||
@ -122,7 +132,7 @@ struct protoent {
|
||||
|
||||
struct addrinfo {
|
||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
|
||||
int ai_family; /* PF_xxx */
|
||||
int ai_family; /* AF_xxx */
|
||||
int ai_socktype; /* SOCK_xxx */
|
||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
||||
socklen_t ai_addrlen; /* length of ai_addr */
|
||||
@ -131,6 +141,8 @@ struct addrinfo {
|
||||
struct addrinfo *ai_next; /* next structure in linked list */
|
||||
};
|
||||
|
||||
#define IPPORT_RESERVED 1024
|
||||
|
||||
/*
|
||||
* Error return codes from gethostbyname() and gethostbyaddr()
|
||||
* (left in h_errno).
|
||||
@ -179,7 +191,7 @@ struct addrinfo {
|
||||
/* valid flags for addrinfo (not a standard def, apps should not use it) */
|
||||
#define AI_MASK \
|
||||
(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | \
|
||||
AI_ADDRCONFIG)
|
||||
AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED)
|
||||
|
||||
#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
|
||||
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
|
||||
@ -202,9 +214,7 @@ struct addrinfo {
|
||||
#define NI_NAMEREQD 0x00000004
|
||||
#define NI_NUMERICSERV 0x00000008
|
||||
#define NI_DGRAM 0x00000010
|
||||
#if 0 /* obsolete */
|
||||
#define NI_WITHSCOPEID 0x00000020
|
||||
#endif
|
||||
#define NI_NUMERICSCOPE 0x00000020
|
||||
|
||||
/*
|
||||
* Scope delimit character
|
||||
@ -263,6 +273,7 @@ int getnetbyname_r(const char *, struct netent *, char *, size_t,
|
||||
int getnetent_r(struct netent *, char *, size_t, struct netent **,
|
||||
int *);
|
||||
int getnetgrent(char **, char **, char **);
|
||||
int getnetgrent_r(char **, char **, char **, char *, size_t);
|
||||
int getprotobyname_r(const char *, struct protoent *, char *,
|
||||
size_t, struct protoent **);
|
||||
int getprotobynumber_r(int, struct protoent *, char *, size_t,
|
||||
@ -276,7 +287,7 @@ int getservbyport_r(int, const char *, struct servent *, char *,
|
||||
int getservent_r(struct servent *, char *, size_t,
|
||||
struct servent **);
|
||||
void herror(const char *);
|
||||
__const char *hstrerror(int);
|
||||
const char *hstrerror(int);
|
||||
int innetgr(const char *, const char *, const char *, const char *);
|
||||
void setnetgrent(const char *);
|
||||
#endif
|
||||
|
@ -184,7 +184,7 @@ struct __res_state {
|
||||
u_int16_t nscount;
|
||||
u_int16_t nstimes[MAXNS]; /*%< ms. */
|
||||
int nssocks[MAXNS];
|
||||
struct __res_state_ext *ext; /*%< extention for IPv6 */
|
||||
struct __res_state_ext *ext; /*%< extension for IPv6 */
|
||||
} _ext;
|
||||
} _u;
|
||||
u_char *_rnd; /*%< PRIVATE: random state */
|
||||
|
@ -56,7 +56,7 @@ __BEGIN_DECLS
|
||||
* These interfaces are currently implemented through nsswitch and are
|
||||
* MT-safe.
|
||||
*/
|
||||
extern struct rpcent *getrpcbyname(char *);
|
||||
extern struct rpcent *getrpcbyname(const char *);
|
||||
extern struct rpcent *getrpcbynumber(int);
|
||||
extern struct rpcent *getrpcent(void);
|
||||
extern void setrpcent(int);
|
||||
|
@ -90,6 +90,7 @@ enum xprt_stat {
|
||||
*/
|
||||
typedef struct __rpc_svcxprt {
|
||||
int xp_fd;
|
||||
#define xp_sock xp_fd
|
||||
u_short xp_port; /* associated port number */
|
||||
const struct xp_ops {
|
||||
/* receive incoming requests */
|
||||
@ -226,7 +227,7 @@ struct svc_req {
|
||||
* const SVCXPRT *xprt;
|
||||
* const rpcprog_t prog;
|
||||
* const rpcvers_t vers;
|
||||
* const void (*dispatch)();
|
||||
* const void (*dispatch)(struct svc_req *, SVCXPRT *);
|
||||
* const struct netconfig *nconf;
|
||||
*/
|
||||
|
||||
@ -314,7 +315,7 @@ __END_DECLS
|
||||
* Somebody has to wait for incoming requests and then call the correct
|
||||
* service routine. The routine svc_run does infinite waiting; i.e.,
|
||||
* svc_run never returns.
|
||||
* Since another (co-existant) package may wish to selectively wait for
|
||||
* Since another (co-existent) package may wish to selectively wait for
|
||||
* incoming calls or other events outside of the rpc architecture, the
|
||||
* routine svc_getreq is provided. It must be passed readfds, the
|
||||
* "in-place" results of a select system call (see select, section 2).
|
||||
@ -376,7 +377,7 @@ __BEGIN_DECLS
|
||||
extern int svc_create(void (*)(struct svc_req *, SVCXPRT *),
|
||||
const rpcprog_t, const rpcvers_t, const char *);
|
||||
/*
|
||||
* void (*dispatch)(); -- dispatch routine
|
||||
* void (*dispatch)(struct svc_req *, SVCXPRT *);
|
||||
* const rpcprog_t prognum; -- program number
|
||||
* const rpcvers_t versnum; -- version number
|
||||
* const char *nettype; -- network type
|
||||
@ -392,7 +393,7 @@ extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
|
||||
const rpcprog_t, const rpcvers_t,
|
||||
const struct netconfig *);
|
||||
/*
|
||||
* void (*dispatch)(); -- dispatch routine
|
||||
* void (*dispatch)(struct svc_req *, SVCXPRT *);
|
||||
* const rpcprog_t prognum; -- program number
|
||||
* const rpcvers_t versnum; -- version number
|
||||
* const struct netconfig *nconf; -- netconfig structure
|
||||
|
@ -219,15 +219,11 @@ xdr_putint32(XDR *xdrs, int32_t *ip)
|
||||
(*(xdrs)->x_ops->x_control)(xdrs, req, op)
|
||||
#define xdr_control(xdrs, req, op) XDR_CONTROL(xdrs, req, op)
|
||||
|
||||
/*
|
||||
* Solaris strips the '_t' from these types -- not sure why.
|
||||
* But, let's be compatible.
|
||||
*/
|
||||
#define xdr_rpcvers(xdrs, versp) xdr_u_int32(xdrs, versp)
|
||||
#define xdr_rpcprog(xdrs, progp) xdr_u_int32(xdrs, progp)
|
||||
#define xdr_rpcproc(xdrs, procp) xdr_u_int32(xdrs, procp)
|
||||
#define xdr_rpcprot(xdrs, protp) xdr_u_int32(xdrs, protp)
|
||||
#define xdr_rpcport(xdrs, portp) xdr_u_int32(xdrs, portp)
|
||||
#define xdr_rpcvers(xdrs, versp) xdr_u_int32_t(xdrs, versp)
|
||||
#define xdr_rpcprog(xdrs, progp) xdr_u_int32_t(xdrs, progp)
|
||||
#define xdr_rpcproc(xdrs, procp) xdr_u_int32_t(xdrs, procp)
|
||||
#define xdr_rpcprot(xdrs, protp) xdr_u_int32_t(xdrs, protp)
|
||||
#define xdr_rpcport(xdrs, portp) xdr_u_int32_t(xdrs, portp)
|
||||
|
||||
/*
|
||||
* Support struct for discriminated unions.
|
||||
@ -355,7 +351,7 @@ extern void xdrrec_create(XDR *, u_int, u_int, void *,
|
||||
int (*)(void *, void *, int));
|
||||
|
||||
/* make end of xdr record */
|
||||
extern bool_t xdrrec_endofrecord(XDR *, int);
|
||||
extern bool_t xdrrec_endofrecord(XDR *, bool_t);
|
||||
|
||||
/* move to beginning of next record */
|
||||
extern bool_t xdrrec_skiprecord(XDR *);
|
||||
|
@ -1,31 +1,32 @@
|
||||
%/*
|
||||
% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
% * unrestricted use provided that this legend is included on all tape
|
||||
% * media and as a part of the software program in whole or part. Users
|
||||
% * may copy or modify Sun RPC without charge, but are not authorized
|
||||
% * to license or distribute it to anyone else except as part of a product or
|
||||
% * program developed by the user or with the express written consent of
|
||||
% * Sun Microsystems, Inc.
|
||||
%/*-
|
||||
% * Copyright (c) 2010, Oracle America, Inc.
|
||||
% *
|
||||
% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||
% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||
% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
||||
% * Redistribution and use in source and binary forms, with or without
|
||||
% * modification, are permitted provided that the following conditions are
|
||||
% * met:
|
||||
% *
|
||||
% * Sun RPC is provided with no support and without any obligation on the
|
||||
% * part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||
% * modification or enhancement.
|
||||
% * * Redistributions of source code must retain the above copyright
|
||||
% * notice, this list of conditions and the following disclaimer.
|
||||
% * * 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.
|
||||
% * * Neither the name of the "Oracle America, Inc." nor the names of its
|
||||
% * contributors may be used to endorse or promote products derived
|
||||
% * from this software without specific prior written permission.
|
||||
% *
|
||||
% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||
% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||
% * OR ANY PART THEREOF.
|
||||
% *
|
||||
% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||
% * or profits or other special, indirect and consequential damages, even if
|
||||
% * Sun has been advised of the possibility of such damages.
|
||||
% *
|
||||
% * Sun Microsystems, Inc.
|
||||
% * 2550 Garcia Avenue
|
||||
% * Mountain View, California 94043
|
||||
% * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
|
||||
% * COPYRIGHT HOLDER 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 RPC_HDR
|
||||
@ -192,8 +193,8 @@ struct ping_args {
|
||||
* note that modifications will appear as two entries, for names, they have
|
||||
* an "OLD" entry followed by a "NEW" entry. For entries in tables, there
|
||||
* is a remove followed by an add. It is done this way so that we can read
|
||||
* the log backwards to back out transactions and forwards to propogate
|
||||
* updated.
|
||||
* the log backwards to back out transactions and forwards to propagate
|
||||
* updates.
|
||||
*/
|
||||
enum log_entry_t {
|
||||
LOG_NOP = 0,
|
||||
@ -399,10 +400,7 @@ program NIS_PROG {
|
||||
%#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights)
|
||||
%#define WORLD_DEFAULT (NIS_READ_ACC)
|
||||
%#define GROUP_DEFAULT (NIS_READ_ACC << 8)
|
||||
%#define OWNER_DEFAULT ((NIS_READ_ACC +\
|
||||
NIS_MODIFY_ACC +\
|
||||
NIS_CREATE_ACC +\
|
||||
NIS_DESTROY_ACC) << 16)
|
||||
%#define OWNER_DEFAULT ((NIS_READ_ACC + NIS_MODIFY_ACC + NIS_CREATE_ACC + NIS_DESTROY_ACC) << 16)
|
||||
%#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT)
|
||||
%
|
||||
%/* Result manipulation defines ... */
|
||||
@ -431,10 +429,8 @@ program NIS_PROG {
|
||||
% * these definitions they take an nis_object *, and an int and return
|
||||
% * a u_char * for Value, and an int for length.
|
||||
% */
|
||||
%#define ENTRY_VAL(obj, col) \
|
||||
(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
|
||||
%#define ENTRY_LEN(obj, col) \
|
||||
(obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
|
||||
%#define ENTRY_VAL(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
|
||||
%#define ENTRY_LEN(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
|
||||
%
|
||||
%#ifdef __cplusplus
|
||||
%}
|
||||
|
@ -1,30 +1,32 @@
|
||||
/*
|
||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
||||
* unrestricted use provided that this legend is included on all tape
|
||||
* media and as a part of the software program in whole or part. Users
|
||||
* may copy or modify Sun RPC without charge, but are not authorized
|
||||
* to license or distribute it to anyone else except as part of a product or
|
||||
* program developed by the user.
|
||||
/*-
|
||||
* Copyright (c) 2010, Oracle America, Inc.
|
||||
*
|
||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Sun RPC is provided with no support and without any obligation on the
|
||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
||||
* modification or enhancement.
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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.
|
||||
* * Neither the name of the "Oracle America, Inc." nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
||||
* OR ANY PART THEREOF.
|
||||
*
|
||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
||||
* or profits or other special, indirect and consequential damages, even if
|
||||
* Sun has been advised of the possibility of such damages.
|
||||
*
|
||||
* Sun Microsystems, Inc.
|
||||
* 2550 Garcia Avenue
|
||||
* Mountain View, California 94043
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
|
||||
* COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -41,6 +43,7 @@
|
||||
#ifndef _RPCSVC_NIS_TAGS_H
|
||||
#define _RPCSVC_NIS_TAGS_H
|
||||
|
||||
/* $FreeBSD$ */
|
||||
/* From: #pragma ident "@(#)nis_tags.h 1.10 94/05/03 SMI" */
|
||||
/* from file: zns_tags.h 1.7 Copyright (c) 1990 Sun Microsystems */
|
||||
|
||||
|
@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
#include "libc_private.h"
|
||||
|
||||
#include <db.h>
|
||||
#include "btree.h"
|
||||
@ -198,7 +199,7 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int
|
||||
goto einval;
|
||||
}
|
||||
|
||||
if ((t->bt_fd = _open(fname, flags, mode)) < 0)
|
||||
if ((t->bt_fd = _open(fname, flags | O_CLOEXEC, mode)) < 0)
|
||||
goto err;
|
||||
|
||||
} else {
|
||||
@ -209,9 +210,6 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int
|
||||
F_SET(t, B_INMEM);
|
||||
}
|
||||
|
||||
if (_fcntl(t->bt_fd, F_SETFD, 1) == -1)
|
||||
goto err;
|
||||
|
||||
if (_fstat(t->bt_fd, &sb))
|
||||
goto err;
|
||||
if (sb.st_size) {
|
||||
@ -281,7 +279,7 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int
|
||||
b.cachesize = b.psize * MINCACHE;
|
||||
|
||||
/* Calculate number of pages to cache. */
|
||||
ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize;
|
||||
ncache = howmany(b.cachesize, t->bt_psize);
|
||||
|
||||
/*
|
||||
* The btree data structure requires that at least two keys can fit on
|
||||
@ -406,10 +404,10 @@ tmp(void)
|
||||
}
|
||||
|
||||
(void)sigfillset(&set);
|
||||
(void)_sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
if ((fd = mkstemp(path)) != -1)
|
||||
(void)__libc_sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
if ((fd = mkostemp(path, O_CLOEXEC)) != -1)
|
||||
(void)unlink(path);
|
||||
(void)_sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
(void)__libc_sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
return(fd);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ static EPG *bt_fast(BTREE *, const DBT *, const DBT *, int *);
|
||||
* dbp: pointer to access method
|
||||
* key: key
|
||||
* data: data
|
||||
* flag: R_NOOVERWRITE
|
||||
* flag: R_NOOVERWRITE, R_SETCURSOR, R_CURSOR
|
||||
*
|
||||
* Returns:
|
||||
* RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is already in the
|
||||
@ -93,6 +93,7 @@ __bt_put(const DB *dbp, DBT *key, const DBT *data, u_int flags)
|
||||
switch (flags) {
|
||||
case 0:
|
||||
case R_NOOVERWRITE:
|
||||
case R_SETCURSOR:
|
||||
break;
|
||||
case R_CURSOR:
|
||||
/*
|
||||
|
@ -38,7 +38,6 @@ static char sccsid[] = "@(#)bt_split.c 8.10 (Berkeley) 1/9/95";
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
|
||||
#include <limits.h>
|
||||
@ -238,9 +237,12 @@ __bt_split(BTREE *t, PAGE *sp, const DBT *key, const DBT *data, int flags,
|
||||
WR_BINTERNAL(dest, nksize ? nksize : bl->ksize,
|
||||
rchild->pgno, bl->flags & P_BIGKEY);
|
||||
memmove(dest, bl->bytes, nksize ? nksize : bl->ksize);
|
||||
if (bl->flags & P_BIGKEY &&
|
||||
bt_preserve(t, *(pgno_t *)bl->bytes) == RET_ERROR)
|
||||
if (bl->flags & P_BIGKEY) {
|
||||
pgno_t pgno;
|
||||
memcpy(&pgno, bl->bytes, sizeof(pgno));
|
||||
if (bt_preserve(t, pgno) == RET_ERROR)
|
||||
goto err1;
|
||||
}
|
||||
break;
|
||||
case P_RINTERNAL:
|
||||
/*
|
||||
@ -546,9 +548,12 @@ bt_broot(BTREE *t, PAGE *h, PAGE *l, PAGE *r)
|
||||
* If the key is on an overflow page, mark the overflow chain
|
||||
* so it isn't deleted when the leaf copy of the key is deleted.
|
||||
*/
|
||||
if (bl->flags & P_BIGKEY &&
|
||||
bt_preserve(t, *(pgno_t *)bl->bytes) == RET_ERROR)
|
||||
if (bl->flags & P_BIGKEY) {
|
||||
pgno_t pgno;
|
||||
memcpy(&pgno, bl->bytes, sizeof(pgno));
|
||||
if (bt_preserve(t, pgno) == RET_ERROR)
|
||||
return (RET_ERROR);
|
||||
}
|
||||
break;
|
||||
case P_BINTERNAL:
|
||||
bi = GETBINTERNAL(r, 0);
|
||||
|
@ -46,6 +46,10 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
static int __dberr(void);
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
DB *
|
||||
dbopen(const char *fname, int flags, int mode, DBTYPE type, const void *openinfo)
|
||||
{
|
||||
@ -53,7 +57,7 @@ dbopen(const char *fname, int flags, int mode, DBTYPE type, const void *openinfo
|
||||
#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN)
|
||||
#define USE_OPEN_FLAGS \
|
||||
(O_CREAT | O_EXCL | O_EXLOCK | O_NOFOLLOW | O_NONBLOCK | \
|
||||
O_RDONLY | O_RDWR | O_SHLOCK | O_SYNC | O_TRUNC)
|
||||
O_RDONLY | O_RDWR | O_SHLOCK | O_SYNC | O_TRUNC | O_CLOEXEC)
|
||||
|
||||
if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)
|
||||
switch (type) {
|
||||
|
@ -66,7 +66,7 @@ __rec_open(const char *fname, int flags, int mode, const RECNOINFO *openinfo,
|
||||
int rfd, sverrno;
|
||||
|
||||
/* Open the user's file -- if this fails, we're done. */
|
||||
if (fname != NULL && (rfd = _open(fname, flags, mode)) < 0)
|
||||
if (fname != NULL && (rfd = _open(fname, flags | O_CLOEXEC, mode)) < 0)
|
||||
return (NULL);
|
||||
|
||||
/* Create a btree in memory (backed by disk). */
|
||||
|
@ -142,8 +142,7 @@ einval: errno = EINVAL;
|
||||
return (RET_ERROR);
|
||||
if (nrec > t->bt_nrecs + 1) {
|
||||
if (F_ISSET(t, R_FIXLEN)) {
|
||||
if ((tdata.data =
|
||||
(void *)malloc(t->bt_reclen)) == NULL)
|
||||
if ((tdata.data = malloc(t->bt_reclen)) == NULL)
|
||||
return (RET_ERROR);
|
||||
tdata.size = t->bt_reclen;
|
||||
memset(tdata.data, t->bt_bval, tdata.size);
|
||||
@ -210,7 +209,7 @@ __rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags)
|
||||
return (RET_ERROR);
|
||||
tdata.data = db;
|
||||
tdata.size = NOVFLSIZE;
|
||||
*(pgno_t *)db = pg;
|
||||
memcpy(db, &pg, sizeof(pg));
|
||||
*(u_int32_t *)(db + sizeof(pgno_t)) = data->size;
|
||||
dflags = P_BIGDATA;
|
||||
data = &tdata;
|
||||
|
@ -98,10 +98,7 @@ _err(int eval, const char *fmt, ...)
|
||||
}
|
||||
|
||||
void
|
||||
verr(eval, fmt, ap)
|
||||
int eval;
|
||||
const char *fmt;
|
||||
va_list ap;
|
||||
verr(int eval, const char *fmt, va_list ap)
|
||||
{
|
||||
verrc(eval, errno, fmt, ap);
|
||||
}
|
||||
@ -118,7 +115,7 @@ errc(int eval, int code, const char *fmt, ...)
|
||||
void
|
||||
verrc(int eval, int code, const char *fmt, va_list ap)
|
||||
{
|
||||
if (err_file == 0)
|
||||
if (err_file == NULL)
|
||||
err_set_file((FILE *)0);
|
||||
fprintf(err_file, "%s: ", _getprogname());
|
||||
if (fmt != NULL) {
|
||||
@ -145,7 +142,7 @@ errx(int eval, const char *fmt, ...)
|
||||
void
|
||||
verrx(int eval, const char *fmt, va_list ap)
|
||||
{
|
||||
if (err_file == 0)
|
||||
if (err_file == NULL)
|
||||
err_set_file((FILE *)0);
|
||||
fprintf(err_file, "%s: ", _getprogname());
|
||||
if (fmt != NULL)
|
||||
@ -187,7 +184,7 @@ warnc(int code, const char *fmt, ...)
|
||||
void
|
||||
vwarnc(int code, const char *fmt, va_list ap)
|
||||
{
|
||||
if (err_file == 0)
|
||||
if (err_file == NULL)
|
||||
err_set_file((FILE *)0);
|
||||
fprintf(err_file, "%s: ", _getprogname());
|
||||
if (fmt != NULL) {
|
||||
@ -209,7 +206,7 @@ warnx(const char *fmt, ...)
|
||||
void
|
||||
vwarnx(const char *fmt, va_list ap)
|
||||
{
|
||||
if (err_file == 0)
|
||||
if (err_file == NULL)
|
||||
err_set_file((FILE *)0);
|
||||
fprintf(err_file, "%s: ", _getprogname());
|
||||
if (fmt != NULL)
|
||||
|
@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/sysctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/*
|
||||
* Returns true if the named feature is present in the currently
|
||||
|
@ -41,12 +41,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
getdomainname(name, namelen)
|
||||
char *name;
|
||||
#ifndef __rtems__
|
||||
int namelen;
|
||||
getdomainname(char *name, int namelen)
|
||||
#else /* __rtems__ */
|
||||
size_t namelen;
|
||||
getdomainname(char *name, size_t namelen)
|
||||
#endif /* __rtems__ */
|
||||
{
|
||||
int mib[2];
|
||||
|
@ -42,9 +42,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
gethostname(name, namelen)
|
||||
char *name;
|
||||
size_t namelen;
|
||||
gethostname(char *name, size_t namelen)
|
||||
{
|
||||
int mib[2];
|
||||
|
||||
|
@ -87,7 +87,7 @@ void _rtld_error(const char *fmt, ...);
|
||||
#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp)
|
||||
|
||||
struct _spinlock;
|
||||
extern struct _spinlock __stdio_thread_lock;
|
||||
extern struct _spinlock __stdio_thread_lock __hidden;
|
||||
#define STDIO_THREAD_LOCK() \
|
||||
do { \
|
||||
if (__isthreaded) \
|
||||
@ -99,6 +99,9 @@ do { \
|
||||
_SPINUNLOCK(&__stdio_thread_lock); \
|
||||
} while (0)
|
||||
|
||||
void __libc_spinlock_stub(struct _spinlock *);
|
||||
void __libc_spinunlock_stub(struct _spinlock *);
|
||||
|
||||
/*
|
||||
* Indexes into the pthread jump table.
|
||||
*
|
||||
@ -169,6 +172,9 @@ typedef enum {
|
||||
PJT_CLEANUP_PUSH_IMP,
|
||||
PJT_CANCEL_ENTER,
|
||||
PJT_CANCEL_LEAVE,
|
||||
PJT_MUTEX_CONSISTENT,
|
||||
PJT_MUTEXATTR_GETROBUST,
|
||||
PJT_MUTEXATTR_SETROBUST,
|
||||
PJT_MAX
|
||||
} pjt_index_t;
|
||||
|
||||
@ -177,6 +183,59 @@ typedef pthread_func_t pthread_func_entry_t[2];
|
||||
|
||||
extern pthread_func_entry_t __thr_jtable[];
|
||||
|
||||
void __set_error_selector(int *(*arg)(void));
|
||||
int _pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
|
||||
void *(calloc_cb)(__size_t, __size_t));
|
||||
|
||||
typedef int (*interpos_func_t)(void);
|
||||
interpos_func_t *__libc_interposing_slot(int interposno);
|
||||
extern interpos_func_t __libc_interposing[] __hidden;
|
||||
|
||||
enum {
|
||||
INTERPOS_accept,
|
||||
INTERPOS_accept4,
|
||||
INTERPOS_aio_suspend,
|
||||
INTERPOS_close,
|
||||
INTERPOS_connect,
|
||||
INTERPOS_fcntl,
|
||||
INTERPOS_fsync,
|
||||
INTERPOS_fork,
|
||||
INTERPOS_msync,
|
||||
INTERPOS_nanosleep,
|
||||
INTERPOS_openat,
|
||||
INTERPOS_poll,
|
||||
INTERPOS_pselect,
|
||||
INTERPOS_recvfrom,
|
||||
INTERPOS_recvmsg,
|
||||
INTERPOS_select,
|
||||
INTERPOS_sendmsg,
|
||||
INTERPOS_sendto,
|
||||
INTERPOS_setcontext,
|
||||
INTERPOS_sigaction,
|
||||
INTERPOS_sigprocmask,
|
||||
INTERPOS_sigsuspend,
|
||||
INTERPOS_sigwait,
|
||||
INTERPOS_sigtimedwait,
|
||||
INTERPOS_sigwaitinfo,
|
||||
INTERPOS_swapcontext,
|
||||
INTERPOS_system,
|
||||
INTERPOS_tcdrain,
|
||||
INTERPOS_read,
|
||||
INTERPOS_readv,
|
||||
INTERPOS_wait4,
|
||||
INTERPOS_write,
|
||||
INTERPOS_writev,
|
||||
INTERPOS__pthread_mutex_init_calloc_cb,
|
||||
INTERPOS_spinlock,
|
||||
INTERPOS_spinunlock,
|
||||
INTERPOS_kevent,
|
||||
INTERPOS_wait6,
|
||||
INTERPOS_ppoll,
|
||||
INTERPOS_map_stacks_exec,
|
||||
INTERPOS_fdatasync,
|
||||
INTERPOS_MAX
|
||||
};
|
||||
|
||||
/*
|
||||
* yplib internal interfaces
|
||||
*/
|
||||
@ -212,6 +271,12 @@ extern const char *__progname;
|
||||
*/
|
||||
void _malloc_thread_cleanup(void);
|
||||
|
||||
/*
|
||||
* This function is used by the threading libraries to notify libc that a
|
||||
* thread is exiting, so its thread-local dtors should be called.
|
||||
*/
|
||||
void __cxa_thread_call_dtors(void);
|
||||
|
||||
/*
|
||||
* These functions are used by the threading libraries in order to protect
|
||||
* malloc across fork().
|
||||
@ -219,42 +284,111 @@ void _malloc_thread_cleanup(void);
|
||||
void _malloc_prefork(void);
|
||||
void _malloc_postfork(void);
|
||||
|
||||
void _malloc_first_thread(void);
|
||||
|
||||
/*
|
||||
* Function to clean up streams, called from abort() and exit().
|
||||
*/
|
||||
extern void (*__cleanup)(void);
|
||||
extern void (*__cleanup)(void) __hidden;
|
||||
|
||||
/*
|
||||
* Get kern.osreldate to detect ABI revisions. Explicitly
|
||||
* ignores value of $OSVERSION and caches result. Prototypes
|
||||
* for the wrapped "new" pad-less syscalls are here for now.
|
||||
* ignores value of $OSVERSION and caches result.
|
||||
*/
|
||||
extern int __getosreldate(void);
|
||||
int __getosreldate(void);
|
||||
#include <sys/_types.h>
|
||||
/* Without pad */
|
||||
extern __off_t __sys_lseek(int, __off_t, int);
|
||||
extern int __sys_ftruncate(int, __off_t);
|
||||
extern int __sys_truncate(const char *, __off_t);
|
||||
extern __ssize_t __sys_pread(int, void *, __size_t, __off_t);
|
||||
extern __ssize_t __sys_pwrite(int, const void *, __size_t, __off_t);
|
||||
extern void * __sys_mmap(void *, __size_t, int, int, int, __off_t);
|
||||
|
||||
/* With pad */
|
||||
extern __off_t __sys_freebsd6_lseek(int, int, __off_t, int);
|
||||
extern int __sys_freebsd6_ftruncate(int, int, __off_t);
|
||||
extern int __sys_freebsd6_truncate(const char *, int, __off_t);
|
||||
extern __ssize_t __sys_freebsd6_pread(int, void *, __size_t, int, __off_t);
|
||||
extern __ssize_t __sys_freebsd6_pwrite(int, const void *, __size_t, int, __off_t);
|
||||
extern void * __sys_freebsd6_mmap(void *, __size_t, int, int, int, int, __off_t);
|
||||
|
||||
/* Without back-compat translation */
|
||||
extern int __sys_fcntl(int, int, ...);
|
||||
#include <sys/_sigset.h>
|
||||
|
||||
struct aiocb;
|
||||
struct fd_set;
|
||||
struct iovec;
|
||||
struct kevent;
|
||||
struct msghdr;
|
||||
struct pollfd;
|
||||
struct rusage;
|
||||
struct sigaction;
|
||||
struct sockaddr;
|
||||
struct timespec;
|
||||
struct timeval;
|
||||
struct timezone;
|
||||
int __sys_gettimeofday(struct timeval *, struct timezone *);
|
||||
struct __siginfo;
|
||||
struct __ucontext;
|
||||
struct __wrusage;
|
||||
enum idtype;
|
||||
int __sys_aio_suspend(const struct aiocb * const[], int,
|
||||
const struct timespec *);
|
||||
int __sys_accept(int, struct sockaddr *, __socklen_t *);
|
||||
int __sys_accept4(int, struct sockaddr *, __socklen_t *, int);
|
||||
int __sys_clock_gettime(__clockid_t, struct timespec *ts);
|
||||
int __sys_close(int);
|
||||
int __sys_connect(int, const struct sockaddr *, __socklen_t);
|
||||
int __sys_fcntl(int, int, ...);
|
||||
int __sys_fdatasync(int);
|
||||
int __sys_fsync(int);
|
||||
__pid_t __sys_fork(void);
|
||||
int __sys_ftruncate(int, __off_t);
|
||||
int __sys_gettimeofday(struct timeval *, struct timezone *);
|
||||
int __sys_kevent(int, const struct kevent *, int, struct kevent *,
|
||||
int, const struct timespec *);
|
||||
__off_t __sys_lseek(int, __off_t, int);
|
||||
void *__sys_mmap(void *, __size_t, int, int, int, __off_t);
|
||||
int __sys_msync(void *, __size_t, int);
|
||||
int __sys_nanosleep(const struct timespec *, struct timespec *);
|
||||
int __sys_open(const char *, int, ...);
|
||||
int __sys_openat(int, const char *, int, ...);
|
||||
int __sys_pselect(int, struct fd_set *, struct fd_set *,
|
||||
struct fd_set *, const struct timespec *,
|
||||
const __sigset_t *);
|
||||
int __sys_poll(struct pollfd *, unsigned, int);
|
||||
int __sys_ppoll(struct pollfd *, unsigned, const struct timespec *,
|
||||
const __sigset_t *);
|
||||
__ssize_t __sys_pread(int, void *, __size_t, __off_t);
|
||||
__ssize_t __sys_pwrite(int, const void *, __size_t, __off_t);
|
||||
__ssize_t __sys_read(int, void *, __size_t);
|
||||
__ssize_t __sys_readv(int, const struct iovec *, int);
|
||||
__ssize_t __sys_recv(int, void *, __size_t, int);
|
||||
__ssize_t __sys_recvfrom(int, void *, __size_t, int, struct sockaddr *,
|
||||
__socklen_t *);
|
||||
__ssize_t __sys_recvmsg(int, struct msghdr *, int);
|
||||
int __sys_select(int, struct fd_set *, struct fd_set *,
|
||||
struct fd_set *, struct timeval *);
|
||||
__ssize_t __sys_sendmsg(int, const struct msghdr *, int);
|
||||
__ssize_t __sys_sendto(int, const void *, __size_t, int,
|
||||
const struct sockaddr *, __socklen_t);
|
||||
int __sys_setcontext(const struct __ucontext *);
|
||||
int __sys_sigaction(int, const struct sigaction *,
|
||||
struct sigaction *);
|
||||
int __sys_sigprocmask(int, const __sigset_t *, __sigset_t *);
|
||||
int __sys_sigsuspend(const __sigset_t *);
|
||||
int __sys_sigtimedwait(const __sigset_t *, struct __siginfo *,
|
||||
const struct timespec *);
|
||||
int __sys_sigwait(const __sigset_t *, int *);
|
||||
int __sys_sigwaitinfo(const __sigset_t *, struct __siginfo *);
|
||||
int __sys_swapcontext(struct __ucontext *,
|
||||
const struct __ucontext *);
|
||||
int __sys_thr_kill(long, int);
|
||||
int __sys_thr_self(long *);
|
||||
int __sys_truncate(const char *, __off_t);
|
||||
__pid_t __sys_wait4(__pid_t, int *, int, struct rusage *);
|
||||
__pid_t __sys_wait6(enum idtype, __id_t, int *, int,
|
||||
struct __wrusage *, struct __siginfo *);
|
||||
__ssize_t __sys_write(int, const void *, __size_t);
|
||||
__ssize_t __sys_writev(int, const struct iovec *, int);
|
||||
|
||||
int __libc_sigaction(int, const struct sigaction *,
|
||||
struct sigaction *) __hidden;
|
||||
int __libc_sigprocmask(int, const __sigset_t *, __sigset_t *)
|
||||
__hidden;
|
||||
int __libc_sigsuspend(const __sigset_t *) __hidden;
|
||||
int __libc_sigwait(const __sigset_t * __restrict,
|
||||
int * restrict sig);
|
||||
int __libc_system(const char *);
|
||||
int __libc_tcdrain(int);
|
||||
int __fcntl_compat(int fd, int cmd, ...);
|
||||
|
||||
int __sys_futimens(int fd, const struct timespec *times) __hidden;
|
||||
int __sys_utimensat(int fd, const char *path,
|
||||
const struct timespec *times, int flag) __hidden;
|
||||
|
||||
/* execve() with PATH processing to implement posix_spawnp() */
|
||||
int _execvpe(const char *, char * const *, char * const *);
|
||||
@ -263,6 +397,7 @@ int _elf_aux_info(int aux, void *buf, int buflen);
|
||||
struct dl_phdr_info;
|
||||
int __elf_phdr_match_addr(struct dl_phdr_info *, void *);
|
||||
void __init_elf_aux_vector(void);
|
||||
void __libc_map_stacks_exec(void);
|
||||
|
||||
void _pthread_cancel_enter(int);
|
||||
void _pthread_cancel_leave(int);
|
||||
|
@ -35,16 +35,199 @@
|
||||
*/
|
||||
|
||||
|
||||
#define _pthread_getspecific pthread_getspecific
|
||||
#define _pthread_key_create pthread_key_create
|
||||
#define _pthread_main_np pthread_main_np
|
||||
#define _pthread_once pthread_once
|
||||
#define _pthread_setspecific pthread_setspecific
|
||||
#define _pthread_mutex_trylock pthread_mutex_trylock
|
||||
#define _pthread_mutex_unlock pthread_mutex_unlock
|
||||
#define _pthread_rwlock_rdlock pthread_rwlock_rdlock
|
||||
#define _pthread_rwlock_unlock pthread_rwlock_unlock
|
||||
#define _pthread_rwlock_wrlock pthread_rwlock_wrlock
|
||||
/*
|
||||
* Prototypes for syscalls/functions that need to be overridden
|
||||
* in libc_r/libpthread.
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
#define accept _accept
|
||||
#define __acl_aclcheck_fd ___acl_aclcheck_fd
|
||||
#define __acl_delete_fd ___acl_delete_fd
|
||||
#define __acl_get_fd ___acl_get_fd
|
||||
#define __acl_set_fd ___acl_set_fd
|
||||
#define bind _bind
|
||||
#define __cap_get_fd ___cap_get_fd
|
||||
#define __cap_set_fd ___cap_set_fd
|
||||
#define close _close
|
||||
#define connect _connect
|
||||
#define dup _dup
|
||||
#define dup2 _dup2
|
||||
#define execve _execve
|
||||
#define fcntl _fcntl
|
||||
/*#define flock _flock */
|
||||
#define flockfile _flockfile
|
||||
#define fpathconf _fpathconf
|
||||
#define fstat _fstat
|
||||
#define fstatfs _fstatfs
|
||||
#define fsync _fsync
|
||||
#define funlockfile _funlockfile
|
||||
#define getdirentries _getdirentries
|
||||
#define getlogin _getlogin
|
||||
#define getpeername _getpeername
|
||||
#define getprogname _getprogname
|
||||
#define getsockname _getsockname
|
||||
#define getsockopt _getsockopt
|
||||
#define ioctl _ioctl
|
||||
/* #define kevent _kevent */
|
||||
#define listen _listen
|
||||
#define nanosleep _nanosleep
|
||||
#define open _open
|
||||
#define openat _openat
|
||||
#define poll _poll
|
||||
#define pthread_atfork _pthread_atfork
|
||||
#define pthread_attr_destroy _pthread_attr_destroy
|
||||
#define pthread_attr_get_np _pthread_attr_get_np
|
||||
#define pthread_attr_getaffinity_np _pthread_attr_getaffinity_np
|
||||
#define pthread_attr_getdetachstate _pthread_attr_getdetachstate
|
||||
#define pthread_attr_getguardsize _pthread_attr_getguardsize
|
||||
#define pthread_attr_getinheritsched _pthread_attr_getinheritsched
|
||||
#define pthread_attr_getschedparam _pthread_attr_getschedparam
|
||||
#define pthread_attr_getschedpolicy _pthread_attr_getschedpolicy
|
||||
#define pthread_attr_getscope _pthread_attr_getscope
|
||||
#define pthread_attr_getstack _pthread_attr_getstack
|
||||
#define pthread_attr_getstackaddr _pthread_attr_getstackaddr
|
||||
#define pthread_attr_getstacksize _pthread_attr_getstacksize
|
||||
#define pthread_attr_init _pthread_attr_init
|
||||
#define pthread_attr_setaffinity_np _pthread_attr_setaffinity_np
|
||||
#define pthread_attr_setcreatesuspend_np _pthread_attr_setcreatesuspend_np
|
||||
#define pthread_attr_setdetachstate _pthread_attr_setdetachstate
|
||||
#define pthread_attr_setguardsize _pthread_attr_setguardsize
|
||||
#define pthread_attr_setinheritsched _pthread_attr_setinheritsched
|
||||
#define pthread_attr_setschedparam _pthread_attr_setschedparam
|
||||
#define pthread_attr_setschedpolicy _pthread_attr_setschedpolicy
|
||||
#define pthread_attr_setscope _pthread_attr_setscope
|
||||
#define pthread_attr_setstack _pthread_attr_setstack
|
||||
#define pthread_attr_setstackaddr _pthread_attr_setstackaddr
|
||||
#define pthread_attr_setstacksize _pthread_attr_setstacksize
|
||||
#define pthread_barrier_destroy _pthread_barrier_destroy
|
||||
#define pthread_barrier_init _pthread_barrier_init
|
||||
#define pthread_barrier_wait _pthread_barrier_wait
|
||||
#define pthread_barrierattr_destroy _pthread_barrierattr_destroy
|
||||
#define pthread_barrierattr_getpshared _pthread_barrierattr_getpshared
|
||||
#define pthread_barrierattr_init _pthread_barrierattr_init
|
||||
#define pthread_barrierattr_setpshared _pthread_barrierattr_setpshared
|
||||
#define pthread_cancel _pthread_cancel
|
||||
#define pthread_cond_broadcast _pthread_cond_broadcast
|
||||
#define pthread_cond_destroy _pthread_cond_destroy
|
||||
#define pthread_cond_init _pthread_cond_init
|
||||
#define pthread_cond_signal _pthread_cond_signal
|
||||
#define pthread_cond_timedwait _pthread_cond_timedwait
|
||||
#define pthread_cond_wait _pthread_cond_wait
|
||||
#define pthread_condattr_destroy _pthread_condattr_destroy
|
||||
#define pthread_condattr_getclock _pthread_condattr_getclock
|
||||
#define pthread_condattr_getpshared _pthread_condattr_getpshared
|
||||
#define pthread_condattr_init _pthread_condattr_init
|
||||
#define pthread_condattr_setclock _pthread_condattr_setclock
|
||||
#define pthread_condattr_setpshared _pthread_condattr_setpshared
|
||||
#define pthread_create _pthread_create
|
||||
#define pthread_detach _pthread_detach
|
||||
#define pthread_equal _pthread_equal
|
||||
#define pthread_exit _pthread_exit
|
||||
#define pthread_getaffinity_np _pthread_getaffinity_np
|
||||
#define pthread_getconcurrency _pthread_getconcurrency
|
||||
#define pthread_getcpuclockid _pthread_getcpuclockid
|
||||
#define pthread_getprio _pthread_getprio
|
||||
#define pthread_getschedparam _pthread_getschedparam
|
||||
#define pthread_getspecific _pthread_getspecific
|
||||
#define pthread_getthreadid_np _pthread_getthreadid_np
|
||||
#define pthread_join _pthread_join
|
||||
#define pthread_key_create _pthread_key_create
|
||||
#define pthread_key_delete _pthread_key_delete
|
||||
#define pthread_kill _pthread_kill
|
||||
#define pthread_main_np _pthread_main_np
|
||||
#define pthread_multi_np _pthread_multi_np
|
||||
#define pthread_mutex_destroy _pthread_mutex_destroy
|
||||
#define pthread_mutex_getprioceiling _pthread_mutex_getprioceiling
|
||||
#define pthread_mutex_init _pthread_mutex_init
|
||||
#define pthread_mutex_isowned_np _pthread_mutex_isowned_np
|
||||
#define pthread_mutex_lock _pthread_mutex_lock
|
||||
#define pthread_mutex_setprioceiling _pthread_mutex_setprioceiling
|
||||
#define pthread_mutex_timedlock _pthread_mutex_timedlock
|
||||
#define pthread_mutex_trylock _pthread_mutex_trylock
|
||||
#define pthread_mutex_unlock _pthread_mutex_unlock
|
||||
#define pthread_mutexattr_destroy _pthread_mutexattr_destroy
|
||||
#define pthread_mutexattr_getkind_np _pthread_mutexattr_getkind_np
|
||||
#define pthread_mutexattr_getprioceiling _pthread_mutexattr_getprioceiling
|
||||
#define pthread_mutexattr_getprotocol _pthread_mutexattr_getprotocol
|
||||
#define pthread_mutexattr_getpshared _pthread_mutexattr_getpshared
|
||||
#define pthread_mutexattr_gettype _pthread_mutexattr_gettype
|
||||
#define pthread_mutexattr_init _pthread_mutexattr_init
|
||||
#define pthread_mutexattr_setkind_np _pthread_mutexattr_setkind_np
|
||||
#define pthread_mutexattr_setprioceiling _pthread_mutexattr_setprioceiling
|
||||
#define pthread_mutexattr_setprotocol _pthread_mutexattr_setprotocol
|
||||
#define pthread_mutexattr_setpshared _pthread_mutexattr_setpshared
|
||||
#define pthread_mutexattr_settype _pthread_mutexattr_settype
|
||||
#define pthread_once _pthread_once
|
||||
#define pthread_resume_all_np _pthread_resume_all_np
|
||||
#define pthread_resume_np _pthread_resume_np
|
||||
#define pthread_rwlock_destroy _pthread_rwlock_destroy
|
||||
#define pthread_rwlock_init _pthread_rwlock_init
|
||||
#define pthread_rwlock_rdlock _pthread_rwlock_rdlock
|
||||
#define pthread_rwlock_timedrdlock _pthread_rwlock_timedrdlock
|
||||
#define pthread_rwlock_timedwrlock _pthread_rwlock_timedwrlock
|
||||
#define pthread_rwlock_tryrdlock _pthread_rwlock_tryrdlock
|
||||
#define pthread_rwlock_trywrlock _pthread_rwlock_trywrlock
|
||||
#define pthread_rwlock_unlock _pthread_rwlock_unlock
|
||||
#define pthread_rwlock_wrlock _pthread_rwlock_wrlock
|
||||
#define pthread_rwlockattr_destroy _pthread_rwlockattr_destroy
|
||||
#define pthread_rwlockattr_getpshared _pthread_rwlockattr_getpshared
|
||||
#define pthread_rwlockattr_init _pthread_rwlockattr_init
|
||||
#define pthread_rwlockattr_setpshared _pthread_rwlockattr_setpshared
|
||||
#define pthread_self _pthread_self
|
||||
#define pthread_set_name_np _pthread_set_name_np
|
||||
#define pthread_setaffinity_np _pthread_setaffinity_np
|
||||
#define pthread_setcancelstate _pthread_setcancelstate
|
||||
#define pthread_setcanceltype _pthread_setcanceltype
|
||||
#define pthread_setconcurrency _pthread_setconcurrency
|
||||
#define pthread_setprio _pthread_setprio
|
||||
#define pthread_setschedparam _pthread_setschedparam
|
||||
#define pthread_setspecific _pthread_setspecific
|
||||
#define pthread_sigmask _pthread_sigmask
|
||||
#define pthread_single_np _pthread_single_np
|
||||
#define pthread_spin_destroy _pthread_spin_destroy
|
||||
#define pthread_spin_init _pthread_spin_init
|
||||
#define pthread_spin_lock _pthread_spin_lock
|
||||
#define pthread_spin_trylock _pthread_spin_trylock
|
||||
#define pthread_spin_unlock _pthread_spin_unlock
|
||||
#define pthread_suspend_all_np _pthread_suspend_all_np
|
||||
#define pthread_suspend_np _pthread_suspend_np
|
||||
#define pthread_switch_add_np _pthread_switch_add_np
|
||||
#define pthread_switch_delete_np _pthread_switch_delete_np
|
||||
#define pthread_testcancel _pthread_testcancel
|
||||
#define pthread_timedjoin_np _pthread_timedjoin_np
|
||||
#define pthread_yield _pthread_yield
|
||||
#define read _read
|
||||
#define readv _readv
|
||||
#define recvfrom _recvfrom
|
||||
#define recvmsg _recvmsg
|
||||
#define recvmmsg _recvmmsg
|
||||
#define select _select
|
||||
#define sem_close _sem_close
|
||||
#define sem_destroy _sem_destroy
|
||||
#define sem_getvalue _sem_getvalue
|
||||
#define sem_init _sem_init
|
||||
#define sem_open _sem_open
|
||||
#define sem_post _sem_post
|
||||
#define sem_timedwait _sem_timedwait
|
||||
#define sem_trywait _sem_trywait
|
||||
#define sem_unlink _sem_unlink
|
||||
#define sem_wait _sem_wait
|
||||
#define sendmsg _sendmsg
|
||||
#define sendmmsg _sendmmsg
|
||||
#define sendto _sendto
|
||||
#define setsockopt _setsockopt
|
||||
/*#define sigaction _sigaction*/
|
||||
#define sigprocmask _sigprocmask
|
||||
#define sigsuspend _sigsuspend
|
||||
#define socket _socket
|
||||
#define socketpair _socketpair
|
||||
#define usleep _usleep
|
||||
#define wait4 _wait4
|
||||
#define wait6 _wait6
|
||||
#define waitpid _waitpid
|
||||
#define write _write
|
||||
#define writev _writev
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#define _open open
|
||||
#define _close close
|
||||
@ -68,9 +251,18 @@
|
||||
#define _getprogname getprogname
|
||||
#define _getsockname getsockname
|
||||
#ifdef __rtems__
|
||||
#define _pthread_mutex_lock pthread_mutex_lock
|
||||
#define _getsockopt getsockopt
|
||||
#define _bind bind
|
||||
#define _getsockopt getsockopt
|
||||
#define _poll poll
|
||||
#define _pthread_getspecific pthread_getspecific
|
||||
#define _pthread_key_create pthread_key_create
|
||||
#define _pthread_mutex_lock pthread_mutex_lock
|
||||
#define _pthread_mutex_unlock pthread_mutex_unlock
|
||||
#define _pthread_once pthread_once
|
||||
#define _pthread_rwlock_rdlock pthread_rwlock_rdlock
|
||||
#define _pthread_rwlock_unlock pthread_rwlock_unlock
|
||||
#define _pthread_rwlock_wrlock pthread_rwlock_wrlock
|
||||
#define _pthread_setspecific pthread_setspecific
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#endif /* _NAMESPACE_H_ */
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#define _LIBC 1
|
||||
#define DO_PTHREADS 1
|
||||
#define USE_KQUEUE 1
|
||||
#define USE_POLL 1
|
||||
#define HAVE_MD5 1
|
||||
|
||||
#define ISC_SOCKLEN_T socklen_t
|
||||
|
@ -49,7 +49,7 @@
|
||||
* One approach for thread safety is to provide discrete versions of the
|
||||
* library: one thread safe, the other not. The disadvantage of this is
|
||||
* that libc is rather large, and two copies of a library which are 99%+
|
||||
* identical is not an efficent use of resources.
|
||||
* identical is not an efficient use of resources.
|
||||
*
|
||||
* Another approach is to provide a single thread safe library. However,
|
||||
* it should not add significant run time or code size overhead to non-
|
||||
|
@ -29,4 +29,232 @@
|
||||
#ifndef _UN_NAMESPACE_H_
|
||||
#define _UN_NAMESPACE_H_
|
||||
|
||||
#ifdef __rtems__
|
||||
#undef accept
|
||||
#undef __acl_aclcheck_fd
|
||||
#undef __acl_delete_fd
|
||||
#undef __acl_get_fd
|
||||
#undef __acl_set_fd
|
||||
#undef bind
|
||||
#undef __cap_get_fd
|
||||
#undef __cap_set_fd
|
||||
#undef close
|
||||
#undef connect
|
||||
#undef dup
|
||||
#undef dup2
|
||||
#undef execve
|
||||
#undef fcntl
|
||||
#undef flock
|
||||
#undef flockfile
|
||||
#undef fpathconf
|
||||
#undef fstat
|
||||
#undef fstatfs
|
||||
#undef fsync
|
||||
#undef funlockfile
|
||||
#undef getdirentries
|
||||
#undef getlogin
|
||||
#undef getpeername
|
||||
#undef getprogname
|
||||
#undef getsockname
|
||||
#undef getsockopt
|
||||
#undef ioctl
|
||||
#undef kevent
|
||||
#undef listen
|
||||
#undef nanosleep
|
||||
#undef open
|
||||
#undef openat
|
||||
#undef poll
|
||||
#undef pthread_atfork
|
||||
#undef pthread_attr_destroy
|
||||
#undef pthread_attr_get_np
|
||||
#undef pthread_attr_getaffinity_np
|
||||
#undef pthread_attr_getdetachstate
|
||||
#undef pthread_attr_getguardsize
|
||||
#undef pthread_attr_getinheritsched
|
||||
#undef pthread_attr_getschedparam
|
||||
#undef pthread_attr_getschedpolicy
|
||||
#undef pthread_attr_getscope
|
||||
#undef pthread_attr_getstack
|
||||
#undef pthread_attr_getstackaddr
|
||||
#undef pthread_attr_getstacksize
|
||||
#undef pthread_attr_init
|
||||
#undef pthread_attr_setaffinity_np
|
||||
#undef pthread_attr_setcreatesuspend_np
|
||||
#undef pthread_attr_setdetachstate
|
||||
#undef pthread_attr_setguardsize
|
||||
#undef pthread_attr_setinheritsched
|
||||
#undef pthread_attr_setschedparam
|
||||
#undef pthread_attr_setschedpolicy
|
||||
#undef pthread_attr_setscope
|
||||
#undef pthread_attr_setstack
|
||||
#undef pthread_attr_setstackaddr
|
||||
#undef pthread_attr_setstacksize
|
||||
#undef pthread_barrier_destroy
|
||||
#undef pthread_barrier_init
|
||||
#undef pthread_barrier_wait
|
||||
#undef pthread_barrierattr_destroy
|
||||
#undef pthread_barrierattr_getpshared
|
||||
#undef pthread_barrierattr_init
|
||||
#undef pthread_barrierattr_setpshared
|
||||
#undef pthread_cancel
|
||||
#undef pthread_cond_broadcast
|
||||
#undef pthread_cond_destroy
|
||||
#undef pthread_cond_init
|
||||
#undef pthread_cond_signal
|
||||
#undef pthread_cond_timedwait
|
||||
#undef pthread_cond_wait
|
||||
#undef pthread_condattr_destroy
|
||||
#undef pthread_condattr_getclock
|
||||
#undef pthread_condattr_getpshared
|
||||
#undef pthread_condattr_init
|
||||
#undef pthread_condattr_setclock
|
||||
#undef pthread_condattr_setpshared
|
||||
#undef pthread_create
|
||||
#undef pthread_detach
|
||||
#undef pthread_equal
|
||||
#undef pthread_exit
|
||||
#undef pthread_getaffinity_np
|
||||
#undef pthread_getconcurrency
|
||||
#undef pthread_getcpuclockid
|
||||
#undef pthread_getprio
|
||||
#undef pthread_getschedparam
|
||||
#undef pthread_getspecific
|
||||
#undef pthread_getthreadid_np
|
||||
#undef pthread_join
|
||||
#undef pthread_key_create
|
||||
#undef pthread_key_delete
|
||||
#undef pthread_kill
|
||||
#undef pthread_main_np
|
||||
#undef pthread_multi_np
|
||||
#undef pthread_mutex_destroy
|
||||
#undef pthread_mutex_getprioceiling
|
||||
#undef pthread_mutex_init
|
||||
#undef pthread_mutex_isowned_np
|
||||
#undef pthread_mutex_lock
|
||||
#undef pthread_mutex_setprioceiling
|
||||
#undef pthread_mutex_timedlock
|
||||
#undef pthread_mutex_trylock
|
||||
#undef pthread_mutex_unlock
|
||||
#undef pthread_mutexattr_destroy
|
||||
#undef pthread_mutexattr_getkind_np
|
||||
#undef pthread_mutexattr_getprioceiling
|
||||
#undef pthread_mutexattr_getprotocol
|
||||
#undef pthread_mutexattr_getpshared
|
||||
#undef pthread_mutexattr_gettype
|
||||
#undef pthread_mutexattr_init
|
||||
#undef pthread_mutexattr_setkind_np
|
||||
#undef pthread_mutexattr_setprioceiling
|
||||
#undef pthread_mutexattr_setprotocol
|
||||
#undef pthread_mutexattr_setpshared
|
||||
#undef pthread_mutexattr_settype
|
||||
#undef pthread_once
|
||||
#undef pthread_resume_all_np
|
||||
#undef pthread_resume_np
|
||||
#undef pthread_rwlock_destroy
|
||||
#undef pthread_rwlock_init
|
||||
#undef pthread_rwlock_rdlock
|
||||
#undef pthread_rwlock_timedrdlock
|
||||
#undef pthread_rwlock_timedwrlock
|
||||
#undef pthread_rwlock_tryrdlock
|
||||
#undef pthread_rwlock_trywrlock
|
||||
#undef pthread_rwlock_unlock
|
||||
#undef pthread_rwlock_wrlock
|
||||
#undef pthread_rwlockattr_destroy
|
||||
#undef pthread_rwlockattr_getpshared
|
||||
#undef pthread_rwlockattr_init
|
||||
#undef pthread_rwlockattr_setpshared
|
||||
#undef pthread_self
|
||||
#undef pthread_set_name_np
|
||||
#undef pthread_setaffinity_np
|
||||
#undef pthread_setcancelstate
|
||||
#undef pthread_setcanceltype
|
||||
#undef pthread_setconcurrency
|
||||
#undef pthread_setprio
|
||||
#undef pthread_setschedparam
|
||||
#undef pthread_setspecific
|
||||
#undef pthread_sigmask
|
||||
#undef pthread_single_np
|
||||
#undef pthread_spin_destroy
|
||||
#undef pthread_spin_init
|
||||
#undef pthread_spin_lock
|
||||
#undef pthread_spin_trylock
|
||||
#undef pthread_spin_unlock
|
||||
#undef pthread_suspend_all_np
|
||||
#undef pthread_suspend_np
|
||||
#undef pthread_switch_add_np
|
||||
#undef pthread_switch_delete_np
|
||||
#undef pthread_testcancel
|
||||
#undef pthread_timedjoin_np
|
||||
#undef pthread_yield
|
||||
#undef read
|
||||
#undef readv
|
||||
#undef recvfrom
|
||||
#undef recvmsg
|
||||
#undef recvmmsg
|
||||
#undef select
|
||||
#undef sem_close
|
||||
#undef sem_destroy
|
||||
#undef sem_getvalue
|
||||
#undef sem_init
|
||||
#undef sem_open
|
||||
#undef sem_post
|
||||
#undef sem_timedwait
|
||||
#undef sem_trywait
|
||||
#undef sem_unlink
|
||||
#undef sem_wait
|
||||
#undef sendmsg
|
||||
#undef sendmmsg
|
||||
#undef sendto
|
||||
#undef setsockopt
|
||||
#undef sigaction
|
||||
#undef sigprocmask
|
||||
#undef sigsuspend
|
||||
#undef socket
|
||||
#undef socketpair
|
||||
#undef usleep
|
||||
#undef wait4
|
||||
#undef wait6
|
||||
#undef waitpid
|
||||
#undef write
|
||||
#undef writev
|
||||
|
||||
#if 0
|
||||
#undef creat
|
||||
#undef fchflags
|
||||
#undef fchmod
|
||||
#undef ftrylockfile
|
||||
#undef msync
|
||||
#undef nfssvc
|
||||
#undef pause
|
||||
#undef sched_yield
|
||||
#undef sendfile
|
||||
#undef shutdown
|
||||
#undef sigaltstack
|
||||
#undef sigpending
|
||||
#undef sigreturn
|
||||
#undef sigsetmask
|
||||
#undef sleep
|
||||
#undef system
|
||||
#undef tcdrain
|
||||
#undef wait
|
||||
#endif /* 0 */
|
||||
|
||||
#ifdef _SIGNAL_H_
|
||||
int _sigaction(int, const struct sigaction *, struct sigaction *);
|
||||
#endif
|
||||
|
||||
#ifdef _SYS_EVENT_H_
|
||||
int _kevent(int, const struct kevent *, int, struct kevent *,
|
||||
int, const struct timespec *);
|
||||
#endif
|
||||
|
||||
#ifdef _SYS_FCNTL_H_
|
||||
int _flock(int, int);
|
||||
#endif
|
||||
|
||||
#undef err
|
||||
#undef warn
|
||||
#undef nsdispatch
|
||||
#endif /* __rtems__ */
|
||||
|
||||
#endif /* _UN_NAMESPACE_H_ */
|
||||
|
@ -75,7 +75,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
@ -49,8 +49,7 @@ __FBSDID("$FreeBSD$");
|
||||
* number formats.
|
||||
*/
|
||||
in_addr_t
|
||||
inet_lnaof(in)
|
||||
struct in_addr in;
|
||||
inet_lnaof(struct in_addr in)
|
||||
{
|
||||
in_addr_t i = ntohl(in.s_addr);
|
||||
|
||||
|
@ -48,8 +48,7 @@ __FBSDID("$FreeBSD$");
|
||||
* building addresses stored in the ifnet structure.
|
||||
*/
|
||||
struct in_addr
|
||||
inet_makeaddr(net, host)
|
||||
in_addr_t net, host;
|
||||
inet_makeaddr(in_addr_t net, in_addr_t host)
|
||||
{
|
||||
struct in_addr a;
|
||||
|
||||
|
@ -59,12 +59,7 @@ static char * inet_net_ntop_ipv6(const u_char *src, int bits, char *dst,
|
||||
* Paul Vixie (ISC), July 1996
|
||||
*/
|
||||
char *
|
||||
inet_net_ntop(af, src, bits, dst, size)
|
||||
int af;
|
||||
const void *src;
|
||||
int bits;
|
||||
char *dst;
|
||||
size_t size;
|
||||
inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size)
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
@ -91,11 +86,7 @@ inet_net_ntop(af, src, bits, dst, size)
|
||||
* Paul Vixie (ISC), July 1996
|
||||
*/
|
||||
static char *
|
||||
inet_net_ntop_ipv4(src, bits, dst, size)
|
||||
const u_char *src;
|
||||
int bits;
|
||||
char *dst;
|
||||
size_t size;
|
||||
inet_net_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size)
|
||||
{
|
||||
char *odst = dst;
|
||||
char *t;
|
||||
|
@ -54,10 +54,7 @@ __FBSDID("$FreeBSD$");
|
||||
* Paul Vixie (ISC), July 1996
|
||||
*/
|
||||
char *
|
||||
inet_neta(src, dst, size)
|
||||
in_addr_t src;
|
||||
char *dst;
|
||||
size_t size;
|
||||
inet_neta(in_addr_t src, char *dst, size_t size)
|
||||
{
|
||||
char *odst = dst;
|
||||
char *tp;
|
||||
|
@ -48,8 +48,7 @@ __FBSDID("$FreeBSD$");
|
||||
* address; handles class a/b/c network #'s.
|
||||
*/
|
||||
in_addr_t
|
||||
inet_netof(in)
|
||||
struct in_addr in;
|
||||
inet_netof(struct in_addr in)
|
||||
{
|
||||
in_addr_t i = ntohl(in.s_addr);
|
||||
|
||||
|
@ -50,8 +50,7 @@ __FBSDID("$FreeBSD$");
|
||||
* network numbers.
|
||||
*/
|
||||
in_addr_t
|
||||
inet_network(cp)
|
||||
const char *cp;
|
||||
inet_network(const char *cp)
|
||||
{
|
||||
in_addr_t val, base, n;
|
||||
char c;
|
||||
|
@ -26,7 +26,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include "port_before.h"
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
@ -47,7 +46,7 @@ __FBSDID("$FreeBSD$");
|
||||
static const char *inet_ntop4(const u_char *src, char *dst, socklen_t size);
|
||||
static const char *inet_ntop6(const u_char *src, char *dst, socklen_t size);
|
||||
|
||||
/* char *
|
||||
/* const char *
|
||||
* inet_ntop(af, src, dst, size)
|
||||
* convert a network format address to presentation format.
|
||||
* return:
|
||||
@ -171,8 +170,10 @@ inet_ntop6(const u_char *src, char *dst, socklen_t size)
|
||||
if (i == 6 && best.base == 0 && (best.len == 6 ||
|
||||
(best.len == 7 && words[7] != 0x0001) ||
|
||||
(best.len == 5 && words[5] == 0xffff))) {
|
||||
if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
|
||||
if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp))) {
|
||||
errno = ENOSPC;
|
||||
return (NULL);
|
||||
}
|
||||
tp += strlen(tp);
|
||||
break;
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "port_before.h"
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
@ -25,7 +25,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
@ -119,7 +119,7 @@ evCmpTime(struct timespec a, struct timespec b) {
|
||||
}
|
||||
|
||||
struct timespec
|
||||
evNowTime() {
|
||||
evNowTime(void) {
|
||||
struct timeval now;
|
||||
#ifdef CLOCK_REALTIME
|
||||
struct timespec tsnow;
|
||||
@ -138,7 +138,7 @@ evNowTime() {
|
||||
}
|
||||
|
||||
struct timespec
|
||||
evUTCTime() {
|
||||
evUTCTime(void) {
|
||||
struct timeval now;
|
||||
#ifdef CLOCK_REALTIME
|
||||
struct timespec tsnow;
|
||||
|
@ -27,7 +27,6 @@
|
||||
#define _EVENTLIB_P_H
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/un.h>
|
||||
|
@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
|
||||
* Check whether a name belongs to a domain.
|
||||
*
|
||||
* Inputs:
|
||||
*\li a - the domain whose ancestory is being verified
|
||||
*\li a - the domain whose ancestry is being verified
|
||||
*\li b - the potential ancestor we're checking against
|
||||
*
|
||||
* Return:
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
@ -195,12 +194,10 @@ b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize) {
|
||||
*/
|
||||
|
||||
int
|
||||
b64_pton(src, target, targsize)
|
||||
char const *src;
|
||||
u_char *target;
|
||||
size_t targsize;
|
||||
b64_pton(const char *src, u_char *target, size_t targsize)
|
||||
{
|
||||
int tarindex, state, ch;
|
||||
u_char nextbyte;
|
||||
char *pos;
|
||||
|
||||
state = 0;
|
||||
@ -214,7 +211,7 @@ b64_pton(src, target, targsize)
|
||||
break;
|
||||
|
||||
pos = strchr(Base64, ch);
|
||||
if (pos == 0) /* A non-base64 character. */
|
||||
if (pos == NULL) /* A non-base64 character. */
|
||||
return (-1);
|
||||
|
||||
switch (state) {
|
||||
@ -228,22 +225,28 @@ b64_pton(src, target, targsize)
|
||||
break;
|
||||
case 1:
|
||||
if (target) {
|
||||
if ((size_t)tarindex + 1 >= targsize)
|
||||
if ((size_t)tarindex >= targsize)
|
||||
return (-1);
|
||||
target[tarindex] |= (pos - Base64) >> 4;
|
||||
target[tarindex+1] = ((pos - Base64) & 0x0f)
|
||||
<< 4 ;
|
||||
nextbyte = ((pos - Base64) & 0x0f) << 4;
|
||||
if ((size_t)tarindex + 1 < targsize)
|
||||
target[tarindex + 1] = nextbyte;
|
||||
else if (nextbyte)
|
||||
return (-1);
|
||||
}
|
||||
tarindex++;
|
||||
state = 2;
|
||||
break;
|
||||
case 2:
|
||||
if (target) {
|
||||
if ((size_t)tarindex + 1 >= targsize)
|
||||
if ((size_t)tarindex >= targsize)
|
||||
return (-1);
|
||||
target[tarindex] |= (pos - Base64) >> 2;
|
||||
target[tarindex+1] = ((pos - Base64) & 0x03)
|
||||
<< 6;
|
||||
nextbyte = ((pos - Base64) & 0x03) << 6;
|
||||
if ((size_t)tarindex + 1 < targsize)
|
||||
target[tarindex + 1] = nextbyte;
|
||||
else if (nextbyte)
|
||||
return (-1);
|
||||
}
|
||||
tarindex++;
|
||||
state = 3;
|
||||
@ -301,7 +304,8 @@ b64_pton(src, target, targsize)
|
||||
* zeros. If we don't check them, they become a
|
||||
* subliminal channel.
|
||||
*/
|
||||
if (target && target[tarindex] != 0)
|
||||
if (target && (size_t)tarindex < targsize &&
|
||||
target[tarindex] != 0)
|
||||
return (-1);
|
||||
}
|
||||
} else {
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
@ -74,11 +73,13 @@ ether_line(const char *l, struct ether_addr *e, char *hostname)
|
||||
|
||||
i = sscanf(l, "%x:%x:%x:%x:%x:%x %s", &o[0], &o[1], &o[2], &o[3],
|
||||
&o[4], &o[5], hostname);
|
||||
if (i != 7)
|
||||
return (i);
|
||||
if (i == 7) {
|
||||
for (i = 0; i < 6; i++)
|
||||
e->octet[i] = o[i];
|
||||
return (0);
|
||||
} else {
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -150,7 +151,7 @@ ether_ntohost(char *hostname, const struct ether_addr *e)
|
||||
char *yp_domain;
|
||||
#endif
|
||||
|
||||
if ((fp = fopen(_PATH_ETHERS, "r")) == NULL)
|
||||
if ((fp = fopen(_PATH_ETHERS, "re")) == NULL)
|
||||
return (1);
|
||||
while (fgets(buf,BUFSIZ,fp)) {
|
||||
if (buf[0] == '#')
|
||||
@ -199,7 +200,7 @@ ether_hostton(const char *hostname, struct ether_addr *e)
|
||||
char *yp_domain;
|
||||
#endif
|
||||
|
||||
if ((fp = fopen(_PATH_ETHERS, "r")) == NULL)
|
||||
if ((fp = fopen(_PATH_ETHERS, "re")) == NULL)
|
||||
return (1);
|
||||
while (fgets(buf,BUFSIZ,fp)) {
|
||||
if (buf[0] == '#')
|
||||
|
@ -32,8 +32,6 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator.
|
||||
*
|
||||
* Issues to be discussed:
|
||||
* - Return values. There are nonstandard return values defined and used
|
||||
* in the source code. This is because RFC2553 is silent about which error
|
||||
@ -59,7 +57,6 @@
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
@ -68,7 +65,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <ifaddrs.h>
|
||||
#include <sys/queue.h>
|
||||
#ifdef INET6
|
||||
#include <net/if_var.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet6/in6_var.h>
|
||||
@ -98,15 +94,12 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stdarg.h>
|
||||
#include <nsswitch.h>
|
||||
#include "un-namespace.h"
|
||||
#include "netdb_private.h"
|
||||
#include "libc_private.h"
|
||||
#ifdef NS_CACHING
|
||||
#include "nscache.h"
|
||||
#endif
|
||||
|
||||
#if defined(__KAME__) && defined(INET6)
|
||||
# define FAITH
|
||||
#endif
|
||||
|
||||
#define ANY 0
|
||||
#define YES 1
|
||||
#define NO 0
|
||||
@ -146,13 +139,20 @@ static const struct afd {
|
||||
offsetof(struct sockaddr_in6, sin6_addr),
|
||||
in6_addrany, in6_loopback, 1},
|
||||
#define N_INET 1
|
||||
#define N_LOCAL 2
|
||||
#else
|
||||
#define N_INET 0
|
||||
#define N_LOCAL 1
|
||||
#endif
|
||||
{PF_INET, sizeof(struct in_addr),
|
||||
sizeof(struct sockaddr_in),
|
||||
offsetof(struct sockaddr_in, sin_addr),
|
||||
in_addrany, in_loopback, 0},
|
||||
#define sizeofmember(type, member) (sizeof(((type *)0)->member))
|
||||
{PF_LOCAL, sizeofmember(struct sockaddr_un, sun_path),
|
||||
sizeof(struct sockaddr_un),
|
||||
offsetof(struct sockaddr_un, sun_path),
|
||||
NULL, NULL, 0},
|
||||
{0, 0, 0, 0, NULL, NULL, 0},
|
||||
};
|
||||
|
||||
@ -160,30 +160,49 @@ struct explore {
|
||||
int e_af;
|
||||
int e_socktype;
|
||||
int e_protocol;
|
||||
const char *e_protostr;
|
||||
int e_wild;
|
||||
#define WILD_AF(ex) ((ex)->e_wild & 0x01)
|
||||
#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02)
|
||||
#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04)
|
||||
#define AF_ANY 0x01
|
||||
#define SOCKTYPE_ANY 0x02
|
||||
#define PROTOCOL_ANY 0x04
|
||||
#define WILD_AF(ex) ((ex)->e_wild & AF_ANY)
|
||||
#define WILD_SOCKTYPE(ex) ((ex)->e_wild & SOCKTYPE_ANY)
|
||||
#define WILD_PROTOCOL(ex) ((ex)->e_wild & PROTOCOL_ANY)
|
||||
};
|
||||
|
||||
static const struct explore explore[] = {
|
||||
#if 0
|
||||
{ PF_LOCAL, ANY, ANY, NULL, 0x01 },
|
||||
#endif
|
||||
#ifdef INET6
|
||||
{ PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
|
||||
{ PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
|
||||
{ PF_INET6, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 },
|
||||
{ PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
|
||||
{ PF_INET6, SOCK_RAW, ANY, NULL, 0x05 },
|
||||
{ PF_INET6, SOCK_DGRAM, IPPROTO_UDP,
|
||||
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
|
||||
{ PF_INET6, SOCK_STREAM, IPPROTO_TCP,
|
||||
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
|
||||
{ PF_INET6, SOCK_STREAM, IPPROTO_SCTP,
|
||||
AF_ANY | SOCKTYPE_ANY },
|
||||
{ PF_INET6, SOCK_SEQPACKET, IPPROTO_SCTP,
|
||||
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
|
||||
{ PF_INET6, SOCK_DGRAM, IPPROTO_UDPLITE,
|
||||
AF_ANY | SOCKTYPE_ANY },
|
||||
{ PF_INET6, SOCK_RAW, ANY,
|
||||
AF_ANY | PROTOCOL_ANY },
|
||||
#endif
|
||||
{ PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
|
||||
{ PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
|
||||
{ PF_INET, SOCK_STREAM, IPPROTO_SCTP, "sctp", 0x03 },
|
||||
{ PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, "sctp", 0x07 },
|
||||
{ PF_INET, SOCK_RAW, ANY, NULL, 0x05 },
|
||||
{ -1, 0, 0, NULL, 0 },
|
||||
{ PF_INET, SOCK_DGRAM, IPPROTO_UDP,
|
||||
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
|
||||
{ PF_INET, SOCK_STREAM, IPPROTO_TCP,
|
||||
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
|
||||
{ PF_INET, SOCK_STREAM, IPPROTO_SCTP,
|
||||
AF_ANY | SOCKTYPE_ANY },
|
||||
{ PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP,
|
||||
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
|
||||
{ PF_INET, SOCK_DGRAM, IPPROTO_UDPLITE,
|
||||
AF_ANY | SOCKTYPE_ANY },
|
||||
{ PF_INET, SOCK_RAW, ANY,
|
||||
AF_ANY | PROTOCOL_ANY },
|
||||
{ PF_LOCAL, SOCK_DGRAM, ANY,
|
||||
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
|
||||
{ PF_LOCAL, SOCK_STREAM, ANY,
|
||||
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
|
||||
{ PF_LOCAL, SOCK_SEQPACKET, ANY,
|
||||
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
|
||||
{ -1, 0, 0, 0 },
|
||||
};
|
||||
|
||||
#ifdef INET6
|
||||
@ -380,7 +399,7 @@ getaddrinfo(const char *hostname, const char *servname,
|
||||
struct addrinfo *pai;
|
||||
const struct afd *afd;
|
||||
const struct explore *ex;
|
||||
struct addrinfo *afailist[sizeof(afdl)/sizeof(afdl[0])];
|
||||
struct addrinfo *afailist[nitems(afdl)];
|
||||
struct addrinfo *afai_unspec;
|
||||
int found;
|
||||
int numeric = 0;
|
||||
@ -416,6 +435,7 @@ getaddrinfo(const char *hostname, const char *servname,
|
||||
ERR(EAI_BADFLAGS);
|
||||
switch (hints->ai_family) {
|
||||
case PF_UNSPEC:
|
||||
case PF_LOCAL:
|
||||
case PF_INET:
|
||||
#ifdef INET6
|
||||
case PF_INET6:
|
||||
@ -451,6 +471,24 @@ getaddrinfo(const char *hostname, const char *servname,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RFC 3493: AI_ALL and AI_V4MAPPED are effective only against
|
||||
* AF_INET6 query. They need to be ignored if specified in other
|
||||
* occasions.
|
||||
*/
|
||||
switch (pai->ai_flags & (AI_ALL | AI_V4MAPPED)) {
|
||||
case AI_V4MAPPED:
|
||||
case AI_ALL | AI_V4MAPPED:
|
||||
#ifdef INET6
|
||||
if (pai->ai_family != AF_INET6)
|
||||
pai->ai_flags &= ~(AI_ALL | AI_V4MAPPED);
|
||||
break;
|
||||
#endif
|
||||
case AI_ALL:
|
||||
pai->ai_flags &= ~(AI_ALL | AI_V4MAPPED);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* check for special cases. (1) numeric servname is disallowed if
|
||||
* socktype/protocol are left unspecified. (2) servname is disallowed
|
||||
@ -699,13 +737,13 @@ get_addrselectpolicy(struct policyhead *head)
|
||||
char *buf;
|
||||
struct in6_addrpolicy *pol, *ep;
|
||||
|
||||
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0)
|
||||
if (sysctl(mib, nitems(mib), NULL, &l, NULL, 0) < 0)
|
||||
return (0);
|
||||
if (l == 0)
|
||||
return (0);
|
||||
if ((buf = malloc(l)) == NULL)
|
||||
return (0);
|
||||
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
|
||||
if (sysctl(mib, nitems(mib), buf, &l, NULL, 0) < 0) {
|
||||
free(buf);
|
||||
return (0);
|
||||
}
|
||||
@ -760,10 +798,9 @@ match_addrselectpolicy(struct sockaddr *addr, struct policyhead *head)
|
||||
memset(&key, 0, sizeof(key));
|
||||
key.sin6_family = AF_INET6;
|
||||
key.sin6_len = sizeof(key);
|
||||
key.sin6_addr.s6_addr[10] = 0xff;
|
||||
key.sin6_addr.s6_addr[11] = 0xff;
|
||||
memcpy(&key.sin6_addr.s6_addr[12],
|
||||
&((struct sockaddr_in *)addr)->sin_addr, 4);
|
||||
_map_v4v6_address(
|
||||
(char *)&((struct sockaddr_in *)addr)->sin_addr,
|
||||
(char *)&key.sin6_addr);
|
||||
break;
|
||||
default:
|
||||
return(NULL);
|
||||
@ -840,8 +877,19 @@ set_source(struct ai_order *aio, struct policyhead *ph)
|
||||
get_port(&ai, "1", 0);
|
||||
|
||||
/* open a socket to get the source address for the given dst */
|
||||
if ((s = _socket(ai.ai_family, ai.ai_socktype, ai.ai_protocol)) < 0)
|
||||
if ((s = _socket(ai.ai_family, ai.ai_socktype | SOCK_CLOEXEC,
|
||||
ai.ai_protocol)) < 0)
|
||||
return; /* give up */
|
||||
#ifdef INET6
|
||||
if (ai.ai_family == AF_INET6) {
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ai.ai_addr;
|
||||
int off = 0;
|
||||
|
||||
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
|
||||
(void)_setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
(char *)&off, sizeof(off));
|
||||
}
|
||||
#endif
|
||||
if (_connect(s, ai.ai_addr, ai.ai_addrlen) < 0)
|
||||
goto cleanup;
|
||||
srclen = ai.ai_addrlen;
|
||||
@ -1137,11 +1185,14 @@ explore_null(const struct addrinfo *pai, const char *servname,
|
||||
*res = NULL;
|
||||
ai = NULL;
|
||||
|
||||
if (pai->ai_family == PF_LOCAL)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* filter out AFs that are not supported by the kernel
|
||||
* XXX errno?
|
||||
*/
|
||||
s = _socket(pai->ai_family, SOCK_DGRAM, 0);
|
||||
s = _socket(pai->ai_family, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
if (s < 0) {
|
||||
if (errno != EMFILE)
|
||||
return 0;
|
||||
@ -1177,10 +1228,13 @@ explore_numeric(const struct addrinfo *pai, const char *hostname,
|
||||
const char *servname, struct addrinfo **res, const char *canonname)
|
||||
{
|
||||
const struct afd *afd;
|
||||
struct addrinfo *ai;
|
||||
struct addrinfo *ai, ai0;
|
||||
int error;
|
||||
char pton[PTON_MAX];
|
||||
char pton[PTON_MAX], path[PATH_MAX], *p;
|
||||
|
||||
#ifdef CTASSERT
|
||||
CTASSERT(sizeofmember(struct sockaddr_un, sun_path) <= PATH_MAX);
|
||||
#endif
|
||||
*res = NULL;
|
||||
ai = NULL;
|
||||
|
||||
@ -1189,6 +1243,15 @@ explore_numeric(const struct addrinfo *pai, const char *hostname,
|
||||
return 0;
|
||||
|
||||
switch (afd->a_af) {
|
||||
case AF_LOCAL:
|
||||
if (hostname[0] != '/')
|
||||
ERR(EAI_NONAME);
|
||||
if (strlen(hostname) > afd->a_addrlen)
|
||||
ERR(EAI_MEMORY);
|
||||
/* NUL-termination does not need to be guaranteed. */
|
||||
strncpy(path, hostname, afd->a_addrlen);
|
||||
p = &path[0];
|
||||
break;
|
||||
case AF_INET:
|
||||
/*
|
||||
* RFC3493 requires getaddrinfo() to accept AF_INET formats
|
||||
@ -1199,17 +1262,30 @@ explore_numeric(const struct addrinfo *pai, const char *hostname,
|
||||
*/
|
||||
if (inet_aton(hostname, (struct in_addr *)pton) != 1)
|
||||
return 0;
|
||||
p = pton;
|
||||
break;
|
||||
default:
|
||||
if (inet_pton(afd->a_af, hostname, pton) != 1)
|
||||
if (inet_pton(afd->a_af, hostname, pton) != 1) {
|
||||
if (pai->ai_family != AF_INET6 ||
|
||||
(pai->ai_flags & AI_V4MAPPED) != AI_V4MAPPED)
|
||||
return 0;
|
||||
if (inet_aton(hostname, (struct in_addr *)pton) != 1)
|
||||
return 0;
|
||||
afd = &afdl[N_INET];
|
||||
ai0 = *pai;
|
||||
ai0.ai_family = AF_INET;
|
||||
pai = &ai0;
|
||||
}
|
||||
p = pton;
|
||||
break;
|
||||
}
|
||||
|
||||
if (pai->ai_family == afd->a_af) {
|
||||
GET_AI(ai, afd, pton);
|
||||
GET_AI(ai, afd, p);
|
||||
GET_PORT(ai, servname);
|
||||
if ((pai->ai_flags & AI_CANONNAME)) {
|
||||
if ((pai->ai_family == AF_INET ||
|
||||
pai->ai_family == AF_INET6) &&
|
||||
(pai->ai_flags & AI_CANONNAME)) {
|
||||
/*
|
||||
* Set the numeric address itself as the canonical
|
||||
* name, based on a clarification in RFC3493.
|
||||
@ -1316,45 +1392,13 @@ get_ai(const struct addrinfo *pai, const struct afd *afd, const char *addr)
|
||||
{
|
||||
char *p;
|
||||
struct addrinfo *ai;
|
||||
#ifdef FAITH
|
||||
struct in6_addr faith_prefix;
|
||||
char *fp_str;
|
||||
int translate = 0;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
struct in6_addr mapaddr;
|
||||
|
||||
#ifdef FAITH
|
||||
/*
|
||||
* Transfrom an IPv4 addr into a special IPv6 addr format for
|
||||
* IPv6->IPv4 translation gateway. (only TCP is supported now)
|
||||
*
|
||||
* +-----------------------------------+------------+
|
||||
* | faith prefix part (12 bytes) | embedded |
|
||||
* | | IPv4 addr part (4 bytes)
|
||||
* +-----------------------------------+------------+
|
||||
*
|
||||
* faith prefix part is specified as ascii IPv6 addr format
|
||||
* in environmental variable GAI.
|
||||
* For FAITH to work correctly, routing to faith prefix must be
|
||||
* setup toward a machine where a FAITH daemon operates.
|
||||
* Also, the machine must enable some mechanizm
|
||||
* (e.g. faith interface hack) to divert those packet with
|
||||
* faith prefixed destination addr to user-land FAITH daemon.
|
||||
*/
|
||||
fp_str = getenv("GAI");
|
||||
if (fp_str && inet_pton(AF_INET6, fp_str, &faith_prefix) == 1 &&
|
||||
afd->a_af == AF_INET && pai->ai_socktype == SOCK_STREAM) {
|
||||
u_int32_t v4a;
|
||||
u_int8_t v4a_top;
|
||||
|
||||
memcpy(&v4a, addr, sizeof v4a);
|
||||
v4a_top = v4a >> IN_CLASSA_NSHIFT;
|
||||
if (!IN_MULTICAST(v4a) && !IN_EXPERIMENTAL(v4a) &&
|
||||
v4a_top != 0 && v4a != IN_LOOPBACKNET) {
|
||||
if (afd->a_af == AF_INET && (pai->ai_flags & AI_V4MAPPED) != 0) {
|
||||
afd = &afdl[N_INET6];
|
||||
memcpy(&faith_prefix.s6_addr[12], addr,
|
||||
sizeof(struct in_addr));
|
||||
translate = 1;
|
||||
}
|
||||
_map_v4v6_address(addr, (char *)&mapaddr);
|
||||
addr = (char *)&mapaddr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1368,13 +1412,14 @@ get_ai(const struct addrinfo *pai, const struct afd *afd, const char *addr)
|
||||
memset(ai->ai_addr, 0, (size_t)afd->a_socklen);
|
||||
ai->ai_addr->sa_len = afd->a_socklen;
|
||||
ai->ai_addrlen = afd->a_socklen;
|
||||
if (ai->ai_family == PF_LOCAL) {
|
||||
size_t n = strnlen(addr, afd->a_addrlen);
|
||||
|
||||
ai->ai_addrlen -= afd->a_addrlen - n;
|
||||
ai->ai_addr->sa_len -= afd->a_addrlen - n;
|
||||
}
|
||||
ai->ai_addr->sa_family = ai->ai_family = afd->a_af;
|
||||
p = (char *)(void *)(ai->ai_addr);
|
||||
#ifdef FAITH
|
||||
if (translate == 1)
|
||||
memcpy(p + afd->a_off, &faith_prefix, (size_t)afd->a_addrlen);
|
||||
else
|
||||
#endif
|
||||
memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen);
|
||||
return ai;
|
||||
}
|
||||
@ -1431,6 +1476,9 @@ get_port(struct addrinfo *ai, const char *servname, int matchonly)
|
||||
if (servname == NULL)
|
||||
return 0;
|
||||
switch (ai->ai_family) {
|
||||
case AF_LOCAL:
|
||||
/* AF_LOCAL ignores servname silently. */
|
||||
return (0);
|
||||
case AF_INET:
|
||||
#ifdef AF_INET6
|
||||
case AF_INET6:
|
||||
@ -1486,6 +1534,9 @@ get_port(struct addrinfo *ai, const char *servname, int matchonly)
|
||||
case IPPROTO_SCTP:
|
||||
proto = "sctp";
|
||||
break;
|
||||
case IPPROTO_UDPLITE:
|
||||
proto = "udplite";
|
||||
break;
|
||||
default:
|
||||
proto = NULL;
|
||||
break;
|
||||
@ -1559,7 +1610,7 @@ addrconfig(struct addrinfo *pai)
|
||||
if (seen_inet)
|
||||
continue;
|
||||
sin = (struct sockaddr_in *)(ifa->ifa_addr);
|
||||
if (IN_LOOPBACK(htonl(sin->sin_addr.s_addr)))
|
||||
if (htonl(sin->sin_addr.s_addr) == INADDR_LOOPBACK)
|
||||
continue;
|
||||
seen_inet = 1;
|
||||
break;
|
||||
@ -1603,7 +1654,7 @@ is_ifdisabled(char *name)
|
||||
struct in6_ndireq nd;
|
||||
int fd;
|
||||
|
||||
if ((fd = _socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
||||
if ((fd = _socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0)) < 0)
|
||||
return (-1);
|
||||
memset(&nd, 0, sizeof(nd));
|
||||
strlcpy(nd.ifname, name, sizeof(nd.ifname));
|
||||
@ -2114,7 +2165,11 @@ getanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
|
||||
return sentinel.ai_next;
|
||||
}
|
||||
|
||||
RES_SET_H_ERRNO(res, NO_RECOVERY);
|
||||
/*
|
||||
* We could have walked a CNAME chain, but the ultimate target
|
||||
* may not have what we looked for.
|
||||
*/
|
||||
RES_SET_H_ERRNO(res, ntohs(hp->ancount) > 0 ? NO_DATA : NO_RECOVERY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -2188,7 +2243,7 @@ addr4sort(struct addrinfo *sentinel, res_state res)
|
||||
static int
|
||||
_dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||
{
|
||||
struct addrinfo *ai;
|
||||
struct addrinfo *ai, ai0;
|
||||
querybuf *buf, *buf2;
|
||||
const char *hostname;
|
||||
const struct addrinfo *pai;
|
||||
@ -2196,6 +2251,8 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||
struct res_target q, q2;
|
||||
res_state res;
|
||||
|
||||
ai = NULL;
|
||||
|
||||
hostname = va_arg(ap, char *);
|
||||
pai = va_arg(ap, const struct addrinfo *);
|
||||
|
||||
@ -2204,6 +2261,8 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||
memset(&sentinel, 0, sizeof(sentinel));
|
||||
cur = &sentinel;
|
||||
|
||||
res = __res_state();
|
||||
|
||||
buf = malloc(sizeof(*buf));
|
||||
if (!buf) {
|
||||
RES_SET_H_ERRNO(res, NETDB_INTERNAL);
|
||||
@ -2216,6 +2275,13 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||
return NS_NOTFOUND;
|
||||
}
|
||||
|
||||
if (pai->ai_family == AF_INET6 &&
|
||||
(pai->ai_flags & AI_V4MAPPED) == AI_V4MAPPED) {
|
||||
ai0 = *pai;
|
||||
ai0.ai_family = AF_UNSPEC;
|
||||
pai = &ai0;
|
||||
}
|
||||
|
||||
switch (pai->ai_family) {
|
||||
case AF_UNSPEC:
|
||||
q.name = hostname;
|
||||
@ -2250,7 +2316,6 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||
return NS_UNAVAIL;
|
||||
}
|
||||
|
||||
res = __res_state();
|
||||
if ((res->options & RES_INIT) == 0 && res_ninit(res) == -1) {
|
||||
RES_SET_H_ERRNO(res, NETDB_INTERNAL);
|
||||
free(buf);
|
||||
@ -2266,20 +2331,24 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||
/* prefer IPv6 */
|
||||
if (q.next) {
|
||||
ai = getanswer(buf2, q2.n, q2.name, q2.qtype, pai, res);
|
||||
if (ai) {
|
||||
if (ai != NULL) {
|
||||
cur->ai_next = ai;
|
||||
while (cur && cur->ai_next)
|
||||
cur = cur->ai_next;
|
||||
}
|
||||
}
|
||||
if (ai == NULL || pai->ai_family != AF_UNSPEC ||
|
||||
(pai->ai_flags & (AI_ALL | AI_V4MAPPED)) != AI_V4MAPPED) {
|
||||
ai = getanswer(buf, q.n, q.name, q.qtype, pai, res);
|
||||
if (ai)
|
||||
if (ai != NULL)
|
||||
cur->ai_next = ai;
|
||||
}
|
||||
free(buf);
|
||||
free(buf2);
|
||||
if (sentinel.ai_next == NULL)
|
||||
switch (res->res_h_errno) {
|
||||
case HOST_NOT_FOUND:
|
||||
case NO_DATA:
|
||||
return NS_NOTFOUND;
|
||||
case TRY_AGAIN:
|
||||
return NS_TRYAGAIN;
|
||||
@ -2294,7 +2363,7 @@ static void
|
||||
_sethtent(FILE **hostf)
|
||||
{
|
||||
if (!*hostf)
|
||||
*hostf = fopen(_PATH_HOSTS, "r");
|
||||
*hostf = fopen(_PATH_HOSTS, "re");
|
||||
else
|
||||
rewind(*hostf);
|
||||
}
|
||||
@ -2318,7 +2387,7 @@ _gethtent(FILE **hostf, const char *name, const struct addrinfo *pai)
|
||||
const char *addr;
|
||||
char hostbuf[8*1024];
|
||||
|
||||
if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "r")))
|
||||
if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "re")))
|
||||
return (NULL);
|
||||
again:
|
||||
if (!(p = fgets(hostbuf, sizeof hostbuf, *hostf)))
|
||||
@ -2356,6 +2425,9 @@ found:
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_protocol = 0;
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
if (pai->ai_family == AF_INET6 &&
|
||||
(pai->ai_flags & AI_V4MAPPED) == AI_V4MAPPED)
|
||||
hints.ai_flags |= AI_V4MAPPED;
|
||||
error = getaddrinfo(addr, "0", &hints, &res0);
|
||||
if (error)
|
||||
goto again;
|
||||
@ -2383,6 +2455,20 @@ found:
|
||||
return res0;
|
||||
}
|
||||
|
||||
static struct addrinfo *
|
||||
_getht(FILE **hostf, const char *name, const struct addrinfo *pai,
|
||||
struct addrinfo *cur)
|
||||
{
|
||||
struct addrinfo *p;
|
||||
|
||||
while ((p = _gethtent(hostf, name, pai)) != NULL) {
|
||||
cur->ai_next = p;
|
||||
while (cur && cur->ai_next)
|
||||
cur = cur->ai_next;
|
||||
}
|
||||
return (cur);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
_files_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||
@ -2390,7 +2476,6 @@ _files_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||
const char *name;
|
||||
const struct addrinfo *pai;
|
||||
struct addrinfo sentinel, *cur;
|
||||
struct addrinfo *p;
|
||||
FILE *hostf = NULL;
|
||||
|
||||
name = va_arg(ap, char *);
|
||||
@ -2400,11 +2485,19 @@ _files_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||
cur = &sentinel;
|
||||
|
||||
_sethtent(&hostf);
|
||||
while ((p = _gethtent(&hostf, name, pai)) != NULL) {
|
||||
cur->ai_next = p;
|
||||
while (cur && cur->ai_next)
|
||||
cur = cur->ai_next;
|
||||
if (pai->ai_family == AF_INET6 &&
|
||||
(pai->ai_flags & (AI_ALL | AI_V4MAPPED)) == AI_V4MAPPED) {
|
||||
struct addrinfo ai0 = *pai;
|
||||
|
||||
ai0.ai_flags &= ~AI_V4MAPPED;
|
||||
cur = _getht(&hostf, name, &ai0, cur);
|
||||
if (sentinel.ai_next == NULL) {
|
||||
_sethtent(&hostf);
|
||||
ai0.ai_flags |= AI_V4MAPPED;
|
||||
cur = _getht(&hostf, name, &ai0, cur);
|
||||
}
|
||||
} else
|
||||
cur = _getht(&hostf, name, pai, cur);
|
||||
_endhtent(&hostf);
|
||||
|
||||
*((struct addrinfo **)rv) = sentinel.ai_next;
|
||||
@ -2464,6 +2557,9 @@ nextline:
|
||||
|
||||
hints = *pai;
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
if (pai->ai_family == AF_INET6 &&
|
||||
(pai->ai_flags & AI_V4MAPPED) == AI_V4MAPPED)
|
||||
hints.ai_flags |= AI_V4MAPPED;
|
||||
error = getaddrinfo(addr, NULL, &hints, &res0);
|
||||
if (error == 0) {
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
@ -2511,14 +2607,45 @@ _yp_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||
memset(&sentinel, 0, sizeof(sentinel));
|
||||
cur = &sentinel;
|
||||
|
||||
/* ipnodes.byname can hold both IPv4/v6 */
|
||||
r = yp_match(ypdomain, "ipnodes.byname", name,
|
||||
(int)strlen(name), &ypbuf, &ypbuflen);
|
||||
if (r == 0) {
|
||||
ai = _yphostent(ypbuf, pai);
|
||||
if (ai) {
|
||||
cur->ai_next = ai;
|
||||
while (cur && cur->ai_next)
|
||||
cur = cur->ai_next;
|
||||
}
|
||||
free(ypbuf);
|
||||
}
|
||||
|
||||
if (ai != NULL) {
|
||||
struct sockaddr_in6 *sin6;
|
||||
|
||||
switch (ai->ai_family) {
|
||||
case AF_INET:
|
||||
goto done;
|
||||
case AF_INET6:
|
||||
sin6 = (struct sockaddr_in6 *)ai->ai_addr;
|
||||
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* hosts.byname is only for IPv4 (Solaris8) */
|
||||
if (pai->ai_family == PF_UNSPEC || pai->ai_family == PF_INET) {
|
||||
if (pai->ai_family == AF_UNSPEC || pai->ai_family == AF_INET ||
|
||||
((pai->ai_family == AF_INET6 &&
|
||||
(pai->ai_flags & AI_V4MAPPED) == AI_V4MAPPED) &&
|
||||
(ai == NULL || (pai->ai_flags & AI_ALL) == AI_ALL))) {
|
||||
r = yp_match(ypdomain, "hosts.byname", name,
|
||||
(int)strlen(name), &ypbuf, &ypbuflen);
|
||||
if (r == 0) {
|
||||
struct addrinfo ai4;
|
||||
|
||||
ai4 = *pai;
|
||||
if (pai->ai_family == AF_UNSPEC)
|
||||
ai4.ai_family = AF_INET;
|
||||
ai = _yphostent(ypbuf, &ai4);
|
||||
if (ai) {
|
||||
@ -2530,16 +2657,7 @@ _yp_getaddrinfo(void *rv, void *cb_data, va_list ap)
|
||||
}
|
||||
}
|
||||
|
||||
/* ipnodes.byname can hold both IPv4/v6 */
|
||||
r = yp_match(ypdomain, "ipnodes.byname", name,
|
||||
(int)strlen(name), &ypbuf, &ypbuflen);
|
||||
if (r == 0) {
|
||||
ai = _yphostent(ypbuf, pai);
|
||||
if (ai)
|
||||
cur->ai_next = ai;
|
||||
free(ypbuf);
|
||||
}
|
||||
|
||||
done:
|
||||
if (sentinel.ai_next == NULL) {
|
||||
RES_SET_H_ERRNO(__res_state(), HOST_NOT_FOUND);
|
||||
return NS_NOTFOUND;
|
||||
|
@ -58,7 +58,6 @@ static char fromrcsid[] = "From: Id: gethnamaddr.c,v 8.23 1998/04/07 04:59:46 vi
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
@ -90,7 +89,7 @@ static void addrsort(char **, int, res_state);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
static void dprintf(char *, int, res_state) __printflike(1, 0);
|
||||
static void dbg_printf(char *, int, res_state) __printflike(1, 0);
|
||||
#endif
|
||||
|
||||
#define MAXPACKET (64*1024)
|
||||
@ -109,10 +108,7 @@ int _dns_ttl_;
|
||||
|
||||
#ifdef DEBUG
|
||||
static void
|
||||
dprintf(msg, num, res)
|
||||
char *msg;
|
||||
int num;
|
||||
res_state res;
|
||||
dbg_printf(char *msg, int num, res_state res)
|
||||
{
|
||||
if (res->options & RES_DEBUG) {
|
||||
int save = errno;
|
||||
@ -122,7 +118,7 @@ dprintf(msg, num, res)
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define dprintf(msg, num, res) /*nada*/
|
||||
# define dbg_printf(msg, num, res) /*nada*/
|
||||
#endif
|
||||
|
||||
#define BOUNDED_INCR(x) \
|
||||
@ -375,13 +371,13 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
|
||||
bp += sizeof(align) - ((u_long)bp % sizeof(align));
|
||||
|
||||
if (bp + n >= ep) {
|
||||
dprintf("size (%d) too big\n", n, statp);
|
||||
dbg_printf("size (%d) too big\n", n, statp);
|
||||
had_error++;
|
||||
continue;
|
||||
}
|
||||
if (hap >= &hed->h_addr_ptrs[_MAXADDRS-1]) {
|
||||
if (!toobig++)
|
||||
dprintf("Too many addresses (%d)\n",
|
||||
dbg_printf("Too many addresses (%d)\n",
|
||||
_MAXADDRS, statp);
|
||||
cp += n;
|
||||
continue;
|
||||
@ -395,7 +391,7 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
|
||||
}
|
||||
break;
|
||||
default:
|
||||
dprintf("Impossible condition (type=%d)\n", type,
|
||||
dbg_printf("Impossible condition (type=%d)\n", type,
|
||||
statp);
|
||||
RES_SET_H_ERRNO(statp, NO_RECOVERY);
|
||||
return (-1);
|
||||
@ -522,12 +518,12 @@ _dns_gethostbyname(void *rval, void *cb_data, va_list ap)
|
||||
n = res_nsearch(statp, name, C_IN, type, buf->buf, sizeof(buf->buf));
|
||||
if (n < 0) {
|
||||
free(buf);
|
||||
dprintf("res_nsearch failed (%d)\n", n, statp);
|
||||
dbg_printf("res_nsearch failed (%d)\n", n, statp);
|
||||
*h_errnop = statp->res_h_errno;
|
||||
return (NS_NOTFOUND);
|
||||
} else if (n > sizeof(buf->buf)) {
|
||||
free(buf);
|
||||
dprintf("static buffer is too small (%d)\n", n, statp);
|
||||
dbg_printf("static buffer is too small (%d)\n", n, statp);
|
||||
*h_errnop = statp->res_h_errno;
|
||||
return (NS_UNAVAIL);
|
||||
}
|
||||
@ -629,13 +625,13 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
|
||||
sizeof buf->buf);
|
||||
if (n < 0) {
|
||||
free(buf);
|
||||
dprintf("res_nquery failed (%d)\n", n, statp);
|
||||
dbg_printf("res_nquery failed (%d)\n", n, statp);
|
||||
*h_errnop = statp->res_h_errno;
|
||||
return (NS_UNAVAIL);
|
||||
}
|
||||
if (n > sizeof buf->buf) {
|
||||
free(buf);
|
||||
dprintf("static buffer is too small (%d)\n", n, statp);
|
||||
dbg_printf("static buffer is too small (%d)\n", n, statp);
|
||||
*h_errnop = statp->res_h_errno;
|
||||
return (NS_UNAVAIL);
|
||||
}
|
||||
@ -771,7 +767,7 @@ _sethostdnsent(int stayopen)
|
||||
}
|
||||
|
||||
void
|
||||
_endhostdnsent()
|
||||
_endhostdnsent(void)
|
||||
{
|
||||
res_state statp;
|
||||
|
||||
|
@ -74,7 +74,7 @@ void
|
||||
_sethosthtent(int f, struct hostent_data *hed)
|
||||
{
|
||||
if (!hed->hostf)
|
||||
hed->hostf = fopen(_PATH_HOSTS, "r");
|
||||
hed->hostf = fopen(_PATH_HOSTS, "re");
|
||||
else
|
||||
rewind(hed->hostf);
|
||||
hed->stayopen = f;
|
||||
@ -98,7 +98,7 @@ gethostent_p(struct hostent *he, struct hostent_data *hed, int mapped,
|
||||
int af, len;
|
||||
char hostbuf[BUFSIZ + 1];
|
||||
|
||||
if (!hed->hostf && !(hed->hostf = fopen(_PATH_HOSTS, "r"))) {
|
||||
if (!hed->hostf && !(hed->hostf = fopen(_PATH_HOSTS, "re"))) {
|
||||
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
|
||||
return (-1);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ _gethostbynis(const char *name, char *map, int af, struct hostent *he,
|
||||
free(result);
|
||||
result = (char *)&ypbuf;
|
||||
|
||||
if ((cp = index(result, '\n')))
|
||||
if ((cp = strchr(result, '\n')))
|
||||
*cp = '\0';
|
||||
|
||||
cp = strpbrk(result, " \t");
|
||||
@ -200,61 +200,6 @@ _gethostbynisaddr_r(const void *addr, socklen_t len, int af,
|
||||
}
|
||||
#endif /* YP */
|
||||
|
||||
/* XXX _gethostbynisname/_gethostbynisaddr only used by getipnodeby*() */
|
||||
struct hostent *
|
||||
_gethostbynisname(const char *name, int af)
|
||||
{
|
||||
#ifdef YP
|
||||
struct hostent *he;
|
||||
struct hostent_data *hed;
|
||||
u_long oresopt;
|
||||
int error;
|
||||
res_state statp;
|
||||
|
||||
statp = __res_state();
|
||||
if ((he = __hostent_init()) == NULL ||
|
||||
(hed = __hostent_data_init()) == NULL) {
|
||||
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
oresopt = statp->options;
|
||||
statp->options &= ~RES_USE_INET6;
|
||||
error = _gethostbynisname_r(name, af, he, hed);
|
||||
statp->options = oresopt;
|
||||
return (error == 0) ? he : NULL;
|
||||
#else
|
||||
return (NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct hostent *
|
||||
_gethostbynisaddr(const void *addr, socklen_t len, int af)
|
||||
{
|
||||
#ifdef YP
|
||||
struct hostent *he;
|
||||
struct hostent_data *hed;
|
||||
u_long oresopt;
|
||||
int error;
|
||||
res_state statp;
|
||||
|
||||
statp = __res_state();
|
||||
if ((he = __hostent_init()) == NULL ||
|
||||
(hed = __hostent_data_init()) == NULL) {
|
||||
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
oresopt = statp->options;
|
||||
statp->options &= ~RES_USE_INET6;
|
||||
error = _gethostbynisaddr_r(addr, len, af, he, hed);
|
||||
statp->options = oresopt;
|
||||
return (error == 0) ? he : NULL;
|
||||
#else
|
||||
return (NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
_nis_gethostbyname(void *rval, void *cb_data, va_list ap)
|
||||
{
|
||||
|
@ -50,17 +50,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include "nscache.h"
|
||||
#endif
|
||||
|
||||
extern int _ht_gethostbyname(void *, void *, va_list);
|
||||
extern int _dns_gethostbyname(void *, void *, va_list);
|
||||
extern int _nis_gethostbyname(void *, void *, va_list);
|
||||
extern int _ht_gethostbyaddr(void *, void *, va_list);
|
||||
extern int _dns_gethostbyaddr(void *, void *, va_list);
|
||||
extern int _nis_gethostbyaddr(void *, void *, va_list);
|
||||
|
||||
static int gethostbyname_internal(const char *, int, struct hostent *, char *,
|
||||
size_t, struct hostent **, int *, res_state);
|
||||
|
||||
/* Host lookup order if nsswitch.conf is broken or nonexistant */
|
||||
/* Host lookup order if nsswitch.conf is broken or nonexistent */
|
||||
static const ns_src default_src[] = {
|
||||
{ NSSRC_FILES, NS_SUCCESS },
|
||||
{ NSSRC_DNS, NS_SUCCESS },
|
||||
|
@ -74,19 +74,6 @@ __FBSDID("$FreeBSD$");
|
||||
#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES)
|
||||
#endif
|
||||
|
||||
#if _BSDI_VERSION >= 199701
|
||||
#define HAVE_IFM_DATA
|
||||
#endif
|
||||
|
||||
#if _BSDI_VERSION >= 199802
|
||||
/* ifam_data is very specific to recent versions of bsdi */
|
||||
#define HAVE_IFAM_DATA
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||
#define HAVE_IFM_DATA
|
||||
#endif
|
||||
|
||||
#define MAX_SYSCTL_TRY 5
|
||||
|
||||
int
|
||||
@ -95,39 +82,31 @@ getifaddrs(struct ifaddrs **pif)
|
||||
int icnt = 1;
|
||||
int dcnt = 0;
|
||||
int ncnt = 0;
|
||||
#ifdef NET_RT_IFLIST
|
||||
int ntry = 0;
|
||||
int mib[6];
|
||||
size_t needed;
|
||||
char *buf;
|
||||
char *next;
|
||||
struct ifaddrs *cif = 0;
|
||||
struct ifaddrs *cif;
|
||||
char *p, *p0;
|
||||
struct rt_msghdr *rtm;
|
||||
struct if_msghdr *ifm;
|
||||
struct ifa_msghdr *ifam;
|
||||
struct if_msghdrl *ifm;
|
||||
struct ifa_msghdrl *ifam;
|
||||
struct sockaddr_dl *dl;
|
||||
struct sockaddr *sa;
|
||||
struct ifaddrs *ifa, *ift;
|
||||
struct if_data *if_data;
|
||||
u_short idx = 0;
|
||||
#else /* NET_RT_IFLIST */
|
||||
char buf[1024];
|
||||
int m, sock;
|
||||
struct ifconf ifc;
|
||||
struct ifreq *ifr;
|
||||
struct ifreq *lifr;
|
||||
#endif /* NET_RT_IFLIST */
|
||||
int i;
|
||||
size_t len, alen;
|
||||
char *data;
|
||||
char *names;
|
||||
|
||||
#ifdef NET_RT_IFLIST
|
||||
mib[0] = CTL_NET;
|
||||
mib[1] = PF_ROUTE;
|
||||
mib[2] = 0; /* protocol */
|
||||
mib[3] = 0; /* wildcard address family */
|
||||
mib[4] = NET_RT_IFLIST;
|
||||
mib[4] = NET_RT_IFLISTL;/* extra fields for extensible msghdr structs */
|
||||
mib[5] = 0; /* no flags */
|
||||
do {
|
||||
/*
|
||||
@ -161,34 +140,33 @@ getifaddrs(struct ifaddrs **pif)
|
||||
continue;
|
||||
switch (rtm->rtm_type) {
|
||||
case RTM_IFINFO:
|
||||
ifm = (struct if_msghdr *)(void *)rtm;
|
||||
ifm = (struct if_msghdrl *)(void *)rtm;
|
||||
if (ifm->ifm_addrs & RTA_IFP) {
|
||||
idx = ifm->ifm_index;
|
||||
++icnt;
|
||||
dl = (struct sockaddr_dl *)(void *)(ifm + 1);
|
||||
if_data = IF_MSGHDRL_IFM_DATA(ifm);
|
||||
dcnt += if_data->ifi_datalen;
|
||||
dl = (struct sockaddr_dl *)IF_MSGHDRL_RTA(ifm);
|
||||
dcnt += SA_RLEN((struct sockaddr *)(void*)dl) +
|
||||
ALIGNBYTES;
|
||||
#ifdef HAVE_IFM_DATA
|
||||
dcnt += sizeof(ifm->ifm_data);
|
||||
#endif /* HAVE_IFM_DATA */
|
||||
ncnt += dl->sdl_nlen + 1;
|
||||
} else
|
||||
idx = 0;
|
||||
break;
|
||||
|
||||
case RTM_NEWADDR:
|
||||
ifam = (struct ifa_msghdr *)(void *)rtm;
|
||||
ifam = (struct ifa_msghdrl *)(void *)rtm;
|
||||
if (idx && ifam->ifam_index != idx)
|
||||
abort(); /* this cannot happen */
|
||||
|
||||
#define RTA_MASKS (RTA_NETMASK | RTA_IFA | RTA_BRD)
|
||||
if (idx == 0 || (ifam->ifam_addrs & RTA_MASKS) == 0)
|
||||
break;
|
||||
p = (char *)(void *)(ifam + 1);
|
||||
p = (char *)IFA_MSGHDRL_RTA(ifam);
|
||||
++icnt;
|
||||
#ifdef HAVE_IFAM_DATA
|
||||
dcnt += sizeof(ifam->ifam_data) + ALIGNBYTES;
|
||||
#endif /* HAVE_IFAM_DATA */
|
||||
if_data = IFA_MSGHDRL_IFAM_DATA(ifam);
|
||||
dcnt += if_data->ifi_datalen + ALIGNBYTES;
|
||||
|
||||
/* Scan to look for length of address */
|
||||
alen = 0;
|
||||
for (p0 = p, i = 0; i < RTAX_MAX; i++) {
|
||||
@ -218,34 +196,6 @@ getifaddrs(struct ifaddrs **pif)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else /* NET_RT_IFLIST */
|
||||
ifc.ifc_buf = buf;
|
||||
ifc.ifc_len = sizeof(buf);
|
||||
|
||||
if ((sock = _socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
return (-1);
|
||||
i = _ioctl(sock, SIOCGIFCONF, (char *)&ifc);
|
||||
_close(sock);
|
||||
if (i < 0)
|
||||
return (-1);
|
||||
|
||||
ifr = ifc.ifc_req;
|
||||
lifr = (struct ifreq *)&ifc.ifc_buf[ifc.ifc_len];
|
||||
|
||||
while (ifr < lifr) {
|
||||
struct sockaddr *sa;
|
||||
|
||||
sa = &ifr->ifr_addr;
|
||||
++icnt;
|
||||
dcnt += SA_RLEN(sa);
|
||||
ncnt += sizeof(ifr->ifr_name) + 1;
|
||||
|
||||
if (SA_LEN(sa) < sizeof(*sa))
|
||||
ifr = (struct ifreq *)(((char *)sa) + sizeof(*sa));
|
||||
else
|
||||
ifr = (struct ifreq *)(((char *)sa) + SA_LEN(sa));
|
||||
}
|
||||
#endif /* NET_RT_IFLIST */
|
||||
|
||||
if (icnt + dcnt + ncnt == 1) {
|
||||
*pif = NULL;
|
||||
@ -265,49 +215,46 @@ getifaddrs(struct ifaddrs **pif)
|
||||
memset(ifa, 0, sizeof(struct ifaddrs) * icnt);
|
||||
ift = ifa;
|
||||
|
||||
#ifdef NET_RT_IFLIST
|
||||
idx = 0;
|
||||
cif = NULL;
|
||||
for (next = buf; next < buf + needed; next += rtm->rtm_msglen) {
|
||||
rtm = (struct rt_msghdr *)(void *)next;
|
||||
if (rtm->rtm_version != RTM_VERSION)
|
||||
continue;
|
||||
switch (rtm->rtm_type) {
|
||||
case RTM_IFINFO:
|
||||
ifm = (struct if_msghdr *)(void *)rtm;
|
||||
if (ifm->ifm_addrs & RTA_IFP) {
|
||||
ifm = (struct if_msghdrl *)(void *)rtm;
|
||||
if ((ifm->ifm_addrs & RTA_IFP) == 0) {
|
||||
idx = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
idx = ifm->ifm_index;
|
||||
dl = (struct sockaddr_dl *)(void *)(ifm + 1);
|
||||
dl = (struct sockaddr_dl *)IF_MSGHDRL_RTA(ifm);
|
||||
|
||||
cif = ift;
|
||||
ift->ifa_name = names;
|
||||
ift->ifa_flags = (int)ifm->ifm_flags;
|
||||
memcpy(names, dl->sdl_data,
|
||||
(size_t)dl->sdl_nlen);
|
||||
memcpy(names, dl->sdl_data, (size_t)dl->sdl_nlen);
|
||||
names[dl->sdl_nlen] = 0;
|
||||
names += dl->sdl_nlen + 1;
|
||||
|
||||
ift->ifa_addr = (struct sockaddr *)(void *)data;
|
||||
memcpy(data, dl,
|
||||
(size_t)SA_LEN((struct sockaddr *)
|
||||
memcpy(data, dl, (size_t)SA_LEN((struct sockaddr *)
|
||||
(void *)dl));
|
||||
data += SA_RLEN((struct sockaddr *)(void *)dl);
|
||||
|
||||
#ifdef HAVE_IFM_DATA
|
||||
if_data = IF_MSGHDRL_IFM_DATA(ifm);
|
||||
/* ifm_data needs to be aligned */
|
||||
ift->ifa_data = data = (void *)ALIGN(data);
|
||||
memcpy(data, &ifm->ifm_data, sizeof(ifm->ifm_data));
|
||||
data += sizeof(ifm->ifm_data);
|
||||
#else /* HAVE_IFM_DATA */
|
||||
ift->ifa_data = NULL;
|
||||
#endif /* HAVE_IFM_DATA */
|
||||
memcpy(data, if_data, if_data->ifi_datalen);
|
||||
data += if_data->ifi_datalen;
|
||||
|
||||
ift = (ift->ifa_next = ift + 1);
|
||||
} else
|
||||
idx = 0;
|
||||
break;
|
||||
|
||||
case RTM_NEWADDR:
|
||||
ifam = (struct ifa_msghdr *)(void *)rtm;
|
||||
ifam = (struct ifa_msghdrl *)(void *)rtm;
|
||||
if (idx && ifam->ifam_index != idx)
|
||||
abort(); /* this cannot happen */
|
||||
|
||||
@ -316,7 +263,8 @@ getifaddrs(struct ifaddrs **pif)
|
||||
ift->ifa_name = cif->ifa_name;
|
||||
ift->ifa_flags = cif->ifa_flags;
|
||||
ift->ifa_data = NULL;
|
||||
p = (char *)(void *)(ifam + 1);
|
||||
|
||||
p = (char *)IFA_MSGHDRL_RTA(ifam);
|
||||
/* Scan to look for length of address */
|
||||
alen = 0;
|
||||
for (p0 = p, i = 0; i < RTAX_MAX; i++) {
|
||||
@ -367,12 +315,11 @@ getifaddrs(struct ifaddrs **pif)
|
||||
p += len;
|
||||
}
|
||||
|
||||
#ifdef HAVE_IFAM_DATA
|
||||
if_data = IFA_MSGHDRL_IFAM_DATA(ifam);
|
||||
/* ifam_data needs to be aligned */
|
||||
ift->ifa_data = data = (void *)ALIGN(data);
|
||||
memcpy(data, &ifam->ifam_data, sizeof(ifam->ifam_data));
|
||||
data += sizeof(ifam->ifam_data);
|
||||
#endif /* HAVE_IFAM_DATA */
|
||||
memcpy(data, if_data, if_data->ifi_datalen);
|
||||
data += if_data->ifi_datalen;
|
||||
|
||||
ift = (ift->ifa_next = ift + 1);
|
||||
break;
|
||||
@ -380,28 +327,7 @@ getifaddrs(struct ifaddrs **pif)
|
||||
}
|
||||
|
||||
free(buf);
|
||||
#else /* NET_RT_IFLIST */
|
||||
ifr = ifc.ifc_req;
|
||||
lifr = (struct ifreq *)&ifc.ifc_buf[ifc.ifc_len];
|
||||
|
||||
while (ifr < lifr) {
|
||||
struct sockaddr *sa;
|
||||
|
||||
ift->ifa_name = names;
|
||||
names[sizeof(ifr->ifr_name)] = 0;
|
||||
strncpy(names, ifr->ifr_name, sizeof(ifr->ifr_name));
|
||||
while (*names++)
|
||||
;
|
||||
|
||||
ift->ifa_addr = (struct sockaddr *)data;
|
||||
sa = &ifr->ifr_addr;
|
||||
memcpy(data, sa, SA_LEN(sa));
|
||||
data += SA_RLEN(sa);
|
||||
|
||||
ifr = (struct ifreq *)(((char *)sa) + SA_LEN(sa));
|
||||
ift = (ift->ifa_next = ift + 1);
|
||||
}
|
||||
#endif /* NET_RT_IFLIST */
|
||||
if (--ift >= ifa) {
|
||||
ift->ifa_next = NULL;
|
||||
*pif = ifa;
|
||||
|
@ -12,24 +12,18 @@
|
||||
* 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 Bruce M. Simpson.
|
||||
* 4. Neither the name of Bruce M. Simpson nor the names of other
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BRUCE M. SIMPSON AND AFFILIATES
|
||||
* ``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 BRUCE M. SIMPSON 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.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 <sys/cdefs.h>
|
||||
|
@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
@ -64,92 +65,123 @@ __FBSDID("$FreeBSD$");
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int getnameinfo_inet(const struct sockaddr *, socklen_t, char *,
|
||||
static const struct afd *find_afd(int);
|
||||
static int getnameinfo_inet(const struct afd *,
|
||||
const struct sockaddr *, socklen_t, char *,
|
||||
size_t, char *, size_t, int);
|
||||
#ifdef INET6
|
||||
static int ip6_parsenumeric(const struct sockaddr *, const char *, char *,
|
||||
size_t, int);
|
||||
static int ip6_sa2str(const struct sockaddr_in6 *, char *, size_t, int);
|
||||
#endif
|
||||
static int getnameinfo_link(const struct sockaddr *, socklen_t, char *,
|
||||
static int getnameinfo_link(const struct afd *,
|
||||
const struct sockaddr *, socklen_t, char *,
|
||||
size_t, char *, size_t, int);
|
||||
static int hexname(const u_int8_t *, size_t, char *, size_t);
|
||||
|
||||
int
|
||||
getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
||||
char *host, size_t hostlen, char *serv, size_t servlen,
|
||||
int flags)
|
||||
{
|
||||
|
||||
switch (sa->sa_family) {
|
||||
case AF_INET:
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
#endif
|
||||
return getnameinfo_inet(sa, salen, host, hostlen, serv,
|
||||
servlen, flags);
|
||||
case AF_LINK:
|
||||
return getnameinfo_link(sa, salen, host, hostlen, serv,
|
||||
servlen, flags);
|
||||
default:
|
||||
return EAI_FAMILY;
|
||||
}
|
||||
}
|
||||
static int getnameinfo_un(const struct afd *,
|
||||
const struct sockaddr *, socklen_t, char *,
|
||||
size_t, char *, size_t, int);
|
||||
|
||||
static const struct afd {
|
||||
int a_af;
|
||||
size_t a_addrlen;
|
||||
socklen_t a_socklen;
|
||||
int a_off;
|
||||
int (*a_func)(const struct afd *,
|
||||
const struct sockaddr *, socklen_t, char *,
|
||||
size_t, char *, size_t, int);
|
||||
} afdl [] = {
|
||||
#ifdef INET6
|
||||
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
|
||||
offsetof(struct sockaddr_in6, sin6_addr)},
|
||||
offsetof(struct sockaddr_in6, sin6_addr),
|
||||
getnameinfo_inet},
|
||||
#endif
|
||||
{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
|
||||
offsetof(struct sockaddr_in, sin_addr)},
|
||||
offsetof(struct sockaddr_in, sin_addr),
|
||||
getnameinfo_inet},
|
||||
#define sizeofmember(type, member) (sizeof(((type *)0)->member))
|
||||
{PF_LOCAL, sizeofmember(struct sockaddr_un, sun_path),
|
||||
sizeof(struct sockaddr_un),
|
||||
offsetof(struct sockaddr_un, sun_path),
|
||||
getnameinfo_un},
|
||||
{PF_LINK, sizeofmember(struct sockaddr_dl, sdl_data),
|
||||
sizeof(struct sockaddr_dl),
|
||||
offsetof(struct sockaddr_dl, sdl_data),
|
||||
getnameinfo_link},
|
||||
{0, 0, 0},
|
||||
};
|
||||
|
||||
struct sockinet {
|
||||
u_char si_len;
|
||||
u_char si_family;
|
||||
u_short si_port;
|
||||
};
|
||||
|
||||
static int
|
||||
getnameinfo_inet(const struct sockaddr *sa, socklen_t salen,
|
||||
int
|
||||
getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
||||
char *host, size_t hostlen, char *serv, size_t servlen,
|
||||
int flags)
|
||||
{
|
||||
const struct afd *afd;
|
||||
|
||||
if (sa == NULL)
|
||||
return (EAI_FAIL);
|
||||
|
||||
afd = find_afd(sa->sa_family);
|
||||
if (afd == NULL)
|
||||
return (EAI_FAMILY);
|
||||
switch (sa->sa_family) {
|
||||
case PF_LOCAL:
|
||||
/*
|
||||
* PF_LOCAL uses variable sa->sa_len depending on the
|
||||
* content length of sun_path. Require 1 byte in
|
||||
* sun_path at least.
|
||||
*/
|
||||
if (salen > afd->a_socklen ||
|
||||
salen <= afd->a_socklen -
|
||||
sizeofmember(struct sockaddr_un, sun_path))
|
||||
return (EAI_FAIL);
|
||||
break;
|
||||
case PF_LINK:
|
||||
if (salen <= afd->a_socklen -
|
||||
sizeofmember(struct sockaddr_dl, sdl_data))
|
||||
return (EAI_FAIL);
|
||||
break;
|
||||
default:
|
||||
if (salen != afd->a_socklen)
|
||||
return (EAI_FAIL);
|
||||
break;
|
||||
}
|
||||
|
||||
return ((*afd->a_func)(afd, sa, salen, host, hostlen,
|
||||
serv, servlen, flags));
|
||||
}
|
||||
|
||||
static const struct afd *
|
||||
find_afd(int af)
|
||||
{
|
||||
const struct afd *afd;
|
||||
|
||||
if (af == PF_UNSPEC)
|
||||
return (NULL);
|
||||
for (afd = &afdl[0]; afd->a_af > 0; afd++) {
|
||||
if (afd->a_af == af)
|
||||
return (afd);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
getnameinfo_inet(const struct afd *afd,
|
||||
const struct sockaddr *sa, socklen_t salen,
|
||||
char *host, size_t hostlen, char *serv, size_t servlen,
|
||||
int flags)
|
||||
{
|
||||
struct servent *sp;
|
||||
struct hostent *hp;
|
||||
u_short port;
|
||||
int family, i;
|
||||
const char *addr;
|
||||
u_int32_t v4a;
|
||||
int h_error;
|
||||
char numserv[512];
|
||||
char numaddr[512];
|
||||
|
||||
if (sa == NULL)
|
||||
return EAI_FAIL;
|
||||
|
||||
family = sa->sa_family;
|
||||
for (i = 0; afdl[i].a_af; i++)
|
||||
if (afdl[i].a_af == family) {
|
||||
afd = &afdl[i];
|
||||
goto found;
|
||||
}
|
||||
return EAI_FAMILY;
|
||||
|
||||
found:
|
||||
if (salen != afd->a_socklen)
|
||||
return EAI_FAIL;
|
||||
|
||||
/* network byte order */
|
||||
port = ((const struct sockinet *)sa)->si_port;
|
||||
port = ((const struct sockaddr_in *)sa)->sin_port;
|
||||
addr = (const char *)sa + afd->a_off;
|
||||
|
||||
if (serv == NULL || servlen == 0) {
|
||||
@ -348,7 +380,6 @@ ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags)
|
||||
ifindex = (unsigned int)sa6->sin6_scope_id;
|
||||
a6 = &sa6->sin6_addr;
|
||||
|
||||
#ifdef NI_NUMERICSCOPE
|
||||
if ((flags & NI_NUMERICSCOPE) != 0) {
|
||||
n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id);
|
||||
if (n < 0 || n >= bufsiz)
|
||||
@ -356,7 +387,6 @@ ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags)
|
||||
else
|
||||
return n;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* if_indextoname() does not take buffer size. not a good api... */
|
||||
if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6) ||
|
||||
@ -383,7 +413,8 @@ ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags)
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
getnameinfo_link(const struct sockaddr *sa, socklen_t salen,
|
||||
getnameinfo_link(const struct afd *afd,
|
||||
const struct sockaddr *sa, socklen_t salen,
|
||||
char *host, size_t hostlen, char *serv, size_t servlen, int flags)
|
||||
{
|
||||
const struct sockaddr_dl *sdl =
|
||||
@ -396,11 +427,22 @@ getnameinfo_link(const struct sockaddr *sa, socklen_t salen,
|
||||
|
||||
if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 && sdl->sdl_slen == 0) {
|
||||
n = snprintf(host, hostlen, "link#%d", sdl->sdl_index);
|
||||
if (n > hostlen) {
|
||||
if (n >= hostlen) {
|
||||
*host = '\0';
|
||||
return EAI_MEMORY;
|
||||
return (EAI_MEMORY);
|
||||
}
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (sdl->sdl_nlen > 0 && sdl->sdl_alen == 0) {
|
||||
n = sdl->sdl_nlen;
|
||||
if (n >= hostlen) {
|
||||
*host = '\0';
|
||||
return (EAI_MEMORY);
|
||||
}
|
||||
memcpy(host, sdl->sdl_data, sdl->sdl_nlen);
|
||||
host[n] = '\0';
|
||||
return (0);
|
||||
}
|
||||
|
||||
switch (sdl->sdl_type) {
|
||||
@ -416,7 +458,6 @@ getnameinfo_link(const struct sockaddr *sa, socklen_t salen,
|
||||
/*
|
||||
* The following have zero-length addresses.
|
||||
* IFT_ATM (net/if_atmsubr.c)
|
||||
* IFT_FAITH (net/if_faith.c)
|
||||
* IFT_GIF (net/if_gif.c)
|
||||
* IFT_LOOP (net/if_loop.c)
|
||||
* IFT_PPP (net/if_ppp.c, net/if_spppsubr.c)
|
||||
@ -443,10 +484,7 @@ getnameinfo_link(const struct sockaddr *sa, socklen_t salen,
|
||||
}
|
||||
|
||||
static int
|
||||
hexname(cp, len, host, hostlen)
|
||||
const u_int8_t *cp;
|
||||
char *host;
|
||||
size_t len, hostlen;
|
||||
hexname(const u_int8_t *cp, size_t len, char *host, size_t hostlen)
|
||||
{
|
||||
int i, n;
|
||||
char *outp = host;
|
||||
@ -464,3 +502,30 @@ hexname(cp, len, host, hostlen)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* getnameinfo_un():
|
||||
* Format a UNIX IPC domain address (pathname).
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
getnameinfo_un(const struct afd *afd,
|
||||
const struct sockaddr *sa, socklen_t salen,
|
||||
char *host, size_t hostlen, char *serv, size_t servlen, int flags)
|
||||
{
|
||||
size_t pathlen;
|
||||
|
||||
if (serv != NULL && servlen > 0)
|
||||
*serv = '\0';
|
||||
if (host != NULL && hostlen > 0) {
|
||||
pathlen = sa->sa_len - afd->a_off;
|
||||
|
||||
if (pathlen + 1 > hostlen) {
|
||||
*host = '\0';
|
||||
return (EAI_MEMORY);
|
||||
}
|
||||
strlcpy(host, (const char *)sa + afd->a_off, pathlen + 1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ _setnetdnsent(int stayopen)
|
||||
}
|
||||
|
||||
void
|
||||
_endnetdnsent()
|
||||
_endnetdnsent(void)
|
||||
{
|
||||
res_state statp;
|
||||
|
||||
|
@ -65,7 +65,7 @@ _setnethtent(int f, struct netent_data *ned)
|
||||
{
|
||||
|
||||
if (ned->netf == NULL)
|
||||
ned->netf = fopen(_PATH_NETWORKS, "r");
|
||||
ned->netf = fopen(_PATH_NETWORKS, "re");
|
||||
else
|
||||
rewind(ned->netf);
|
||||
ned->stayopen |= f;
|
||||
@ -91,7 +91,7 @@ getnetent_p(struct netent *ne, struct netent_data *ned)
|
||||
char line[BUFSIZ + 1];
|
||||
|
||||
if (ned->netf == NULL &&
|
||||
(ned->netf = fopen(_PATH_NETWORKS, "r")) == NULL)
|
||||
(ned->netf = fopen(_PATH_NETWORKS, "re")) == NULL)
|
||||
return (-1);
|
||||
again:
|
||||
p = fgets(line, sizeof line, ned->netf);
|
||||
|
@ -82,7 +82,7 @@ _getnetbynis(const char *name, char *map, int af, struct netent *ne,
|
||||
free(result);
|
||||
result = (char *)&ypbuf;
|
||||
|
||||
if ((cp = index(result, '\n')))
|
||||
if ((cp = strchr(result, '\n')))
|
||||
*cp = '\0';
|
||||
|
||||
cp = strpbrk(result, " \t");
|
||||
|
@ -48,14 +48,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "nscache.h"
|
||||
#endif
|
||||
|
||||
extern int _ht_getnetbyname(void *, void *, va_list);
|
||||
extern int _dns_getnetbyname(void *, void *, va_list);
|
||||
extern int _nis_getnetbyname(void *, void *, va_list);
|
||||
extern int _ht_getnetbyaddr(void *, void *, va_list);
|
||||
extern int _dns_getnetbyaddr(void *, void *, va_list);
|
||||
extern int _nis_getnetbyaddr(void *, void *, va_list);
|
||||
|
||||
/* Network lookup order if nsswitch.conf is broken or nonexistant */
|
||||
/* Network lookup order if nsswitch.conf is broken or nonexistent */
|
||||
static const ns_src default_src[] = {
|
||||
{ NSSRC_FILES, NS_SUCCESS },
|
||||
{ NSSRC_DNS, NS_SUCCESS },
|
||||
|
@ -49,12 +49,6 @@ static const ns_src defaultsrc[] = {
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
#ifdef NS_CACHING
|
||||
extern int __proto_id_func(char *, size_t *, va_list, void *);
|
||||
extern int __proto_marshal_func(char *, size_t *, void *, va_list, void *);
|
||||
extern int __proto_unmarshal_func(char *, size_t, void *, va_list, void *);
|
||||
#endif
|
||||
|
||||
static int
|
||||
files_getprotobynumber(void *retval, void *mdata, va_list ap)
|
||||
{
|
||||
|
@ -36,7 +36,6 @@ static char sccsid[] = "@(#)getprotoent.c 8.1 (Berkeley) 6/4/93";
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
@ -344,7 +343,7 @@ void
|
||||
__setprotoent_p(int f, struct protoent_data *ped)
|
||||
{
|
||||
if (ped->fp == NULL)
|
||||
ped->fp = fopen(_PATH_PROTOCOLS, "r");
|
||||
ped->fp = fopen(_PATH_PROTOCOLS, "re");
|
||||
else
|
||||
rewind(ped->fp);
|
||||
ped->stayopen |= f;
|
||||
@ -367,7 +366,7 @@ __getprotoent_p(struct protoent *pe, struct protoent_data *ped)
|
||||
char *cp, **q, *endp;
|
||||
long l;
|
||||
|
||||
if (ped->fp == NULL && (ped->fp = fopen(_PATH_PROTOCOLS, "r")) == NULL)
|
||||
if (ped->fp == NULL && (ped->fp = fopen(_PATH_PROTOCOLS, "re")) == NULL)
|
||||
return (-1);
|
||||
again:
|
||||
if ((p = fgets(ped->line, sizeof ped->line, ped->fp)) == NULL)
|
||||
|
@ -36,7 +36,6 @@ static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93";
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <db.h>
|
||||
@ -323,7 +322,7 @@ files_servent(void *retval, void *mdata, va_list ap)
|
||||
break;
|
||||
default:
|
||||
return NS_NOTFOUND;
|
||||
};
|
||||
}
|
||||
|
||||
serv = va_arg(ap, struct servent *);
|
||||
buffer = va_arg(ap, char *);
|
||||
@ -337,7 +336,7 @@ files_servent(void *retval, void *mdata, va_list ap)
|
||||
if (st->fp == NULL)
|
||||
st->compat_mode_active = 0;
|
||||
|
||||
if (st->fp == NULL && (st->fp = fopen(_PATH_SERVICES, "r")) == NULL) {
|
||||
if (st->fp == NULL && (st->fp = fopen(_PATH_SERVICES, "re")) == NULL) {
|
||||
*errnop = errno;
|
||||
return (NS_UNAVAIL);
|
||||
}
|
||||
@ -408,14 +407,14 @@ files_servent(void *retval, void *mdata, va_list ap)
|
||||
|
||||
continue;
|
||||
gotname:
|
||||
if (proto == 0 || strcmp(serv->s_proto, proto) == 0)
|
||||
if (proto == NULL || strcmp(serv->s_proto, proto) == 0)
|
||||
rv = NS_SUCCESS;
|
||||
break;
|
||||
case nss_lt_id:
|
||||
if (port != serv->s_port)
|
||||
continue;
|
||||
|
||||
if (proto == 0 || strcmp(serv->s_proto, proto) == 0)
|
||||
if (proto == NULL || strcmp(serv->s_proto, proto) == 0)
|
||||
rv = NS_SUCCESS;
|
||||
break;
|
||||
case nss_lt_all:
|
||||
@ -451,7 +450,7 @@ files_setservent(void *retval, void *mdata, va_list ap)
|
||||
case SETSERVENT:
|
||||
f = va_arg(ap,int);
|
||||
if (st->fp == NULL)
|
||||
st->fp = fopen(_PATH_SERVICES, "r");
|
||||
st->fp = fopen(_PATH_SERVICES, "re");
|
||||
else
|
||||
rewind(st->fp);
|
||||
st->stayopen |= f;
|
||||
@ -465,7 +464,7 @@ files_setservent(void *retval, void *mdata, va_list ap)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
st->compat_mode_active = 0;
|
||||
return (NS_UNAVAIL);
|
||||
@ -524,7 +523,7 @@ db_servent(void *retval, void *mdata, va_list ap)
|
||||
break;
|
||||
default:
|
||||
return NS_NOTFOUND;
|
||||
};
|
||||
}
|
||||
|
||||
serv = va_arg(ap, struct servent *);
|
||||
buffer = va_arg(ap, char *);
|
||||
@ -643,7 +642,7 @@ db_setservent(void *retval, void *mdata, va_list ap)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
return (NS_UNAVAIL);
|
||||
}
|
||||
@ -696,7 +695,7 @@ nis_servent(void *retval, void *mdata, va_list ap)
|
||||
break;
|
||||
default:
|
||||
return NS_NOTFOUND;
|
||||
};
|
||||
}
|
||||
|
||||
serv = va_arg(ap, struct servent *);
|
||||
buffer = va_arg(ap, char *);
|
||||
@ -783,7 +782,7 @@ nis_servent(void *retval, void *mdata, va_list ap)
|
||||
}
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
rv = parse_result(serv, buffer, bufsize, resultbuf,
|
||||
resultbuflen, errnop);
|
||||
@ -817,7 +816,7 @@ nis_setservent(void *result, void *mdata, va_list ap)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
return (NS_UNAVAIL);
|
||||
}
|
||||
@ -1243,7 +1242,7 @@ setservent(int stayopen)
|
||||
}
|
||||
|
||||
void
|
||||
endservent()
|
||||
endservent(void)
|
||||
{
|
||||
#ifdef NS_CACHING
|
||||
static const nss_cache_info cache_info = NS_MP_CACHE_INFO_INITIALIZER(
|
||||
@ -1364,7 +1363,7 @@ getservbyport(int port, const char *proto)
|
||||
}
|
||||
|
||||
struct servent *
|
||||
getservent()
|
||||
getservent(void)
|
||||
{
|
||||
struct key key;
|
||||
|
||||
|
@ -72,7 +72,7 @@ if_indextoname(unsigned int ifindex, char *ifname)
|
||||
for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr &&
|
||||
ifa->ifa_addr->sa_family == AF_LINK &&
|
||||
ifindex == ((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index)
|
||||
ifindex == LLINDEX((struct sockaddr_dl*)ifa->ifa_addr))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ if_nameindex(void)
|
||||
if (ifa->ifa_addr &&
|
||||
ifa->ifa_addr->sa_family == AF_LINK) {
|
||||
ifni2->if_index =
|
||||
((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index;
|
||||
LLINDEX((struct sockaddr_dl*)ifa->ifa_addr);
|
||||
ifni2->if_name = cp;
|
||||
strcpy(cp, ifa->ifa_name);
|
||||
ifni2++;
|
||||
|
@ -70,8 +70,9 @@ if_nametoindex(const char *ifname)
|
||||
struct ifaddrs *ifaddrs, *ifa;
|
||||
unsigned int ni;
|
||||
|
||||
s = _socket(AF_INET, SOCK_DGRAM, 0);
|
||||
s = _socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
if (s != -1) {
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
if (_ioctl(s, SIOCGIFINDEX, &ifr) != -1) {
|
||||
_close(s);
|
||||
@ -89,7 +90,7 @@ if_nametoindex(const char *ifname)
|
||||
if (ifa->ifa_addr &&
|
||||
ifa->ifa_addr->sa_family == AF_LINK &&
|
||||
strcmp(ifa->ifa_name, ifname) == 0) {
|
||||
ni = ((struct sockaddr_dl*)ifa->ifa_addr)->sdl_index;
|
||||
ni = LLINDEX((struct sockaddr_dl*)ifa->ifa_addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
@ -47,6 +46,18 @@ __FBSDID("$FreeBSD$");
|
||||
static int ip6optlen(u_int8_t *opt, u_int8_t *lim);
|
||||
static void inet6_insert_padopt(u_char *p, int len);
|
||||
|
||||
#ifndef IPV6_2292HOPOPTS
|
||||
#define IPV6_2292HOPOPTS 22
|
||||
#endif
|
||||
#ifndef IPV6_2292DSTOPTS
|
||||
#define IPV6_2292DSTOPTS 23
|
||||
#endif
|
||||
|
||||
#define is_ipv6_hopopts(x) \
|
||||
((x) == IPV6_HOPOPTS || (x) == IPV6_2292HOPOPTS)
|
||||
#define is_ipv6_dstopts(x) \
|
||||
((x) == IPV6_DSTOPTS || (x) == IPV6_2292DSTOPTS)
|
||||
|
||||
/*
|
||||
* This function returns the number of bytes required to hold an option
|
||||
* when it is stored as ancillary data, including the cmsghdr structure
|
||||
@ -74,7 +85,7 @@ inet6_option_init(void *bp, struct cmsghdr **cmsgp, int type)
|
||||
struct cmsghdr *ch = (struct cmsghdr *)bp;
|
||||
|
||||
/* argument validation */
|
||||
if (type != IPV6_HOPOPTS && type != IPV6_DSTOPTS)
|
||||
if (!is_ipv6_hopopts(type) && !is_ipv6_dstopts(type))
|
||||
return(-1);
|
||||
|
||||
ch->cmsg_level = IPPROTO_IPV6;
|
||||
@ -121,8 +132,7 @@ inet6_option_append(struct cmsghdr *cmsg, const u_int8_t *typep, int multx,
|
||||
|
||||
/* calculate pad length before the option. */
|
||||
off = bp - (u_char *)eh;
|
||||
padlen = (((off % multx) + (multx - 1)) & ~(multx - 1)) -
|
||||
(off % multx);
|
||||
padlen = roundup2(off % multx, multx) - (off % multx);
|
||||
padlen += plusy;
|
||||
padlen %= multx; /* keep the pad as short as possible */
|
||||
/* insert padding */
|
||||
@ -191,8 +201,7 @@ inet6_option_alloc(struct cmsghdr *cmsg, int datalen, int multx, int plusy)
|
||||
|
||||
/* calculate pad length before the option. */
|
||||
off = bp - (u_char *)eh;
|
||||
padlen = (((off % multx) + (multx - 1)) & ~(multx - 1)) -
|
||||
(off % multx);
|
||||
padlen = roundup2(off % multx, multx) - (off % multx);
|
||||
padlen += plusy;
|
||||
padlen %= multx; /* keep the pad as short as possible */
|
||||
/* insert padding */
|
||||
@ -236,8 +245,8 @@ inet6_option_next(const struct cmsghdr *cmsg, u_int8_t **tptrp)
|
||||
u_int8_t *lim;
|
||||
|
||||
if (cmsg->cmsg_level != IPPROTO_IPV6 ||
|
||||
(cmsg->cmsg_type != IPV6_HOPOPTS &&
|
||||
cmsg->cmsg_type != IPV6_DSTOPTS))
|
||||
(!is_ipv6_hopopts(cmsg->cmsg_type) &&
|
||||
!is_ipv6_dstopts(cmsg->cmsg_type)))
|
||||
return(-1);
|
||||
|
||||
/* message length validation */
|
||||
@ -292,8 +301,8 @@ inet6_option_find(const struct cmsghdr *cmsg, u_int8_t **tptrp, int type)
|
||||
u_int8_t *optp, *lim;
|
||||
|
||||
if (cmsg->cmsg_level != IPPROTO_IPV6 ||
|
||||
(cmsg->cmsg_type != IPV6_HOPOPTS &&
|
||||
cmsg->cmsg_type != IPV6_DSTOPTS))
|
||||
(!is_ipv6_hopopts(cmsg->cmsg_type) &&
|
||||
!is_ipv6_dstopts(cmsg->cmsg_type)))
|
||||
return(-1);
|
||||
|
||||
/* message length validation */
|
||||
@ -383,11 +392,8 @@ inet6_opt_init(void *extbuf, socklen_t extlen)
|
||||
{
|
||||
struct ip6_ext *ext = (struct ip6_ext *)extbuf;
|
||||
|
||||
if (extlen < 0 || (extlen % 8))
|
||||
return(-1);
|
||||
|
||||
if (ext) {
|
||||
if (extlen == 0)
|
||||
if (extlen <= 0 || (extlen % 8))
|
||||
return(-1);
|
||||
ext->ip6e_len = (extlen >> 3) - 1;
|
||||
}
|
||||
@ -412,7 +418,7 @@ inet6_opt_append(void *extbuf, socklen_t extlen, int offset, u_int8_t type,
|
||||
* The option data length must have a value between 0 and 255,
|
||||
* inclusive, and is the length of the option data that follows.
|
||||
*/
|
||||
if (len < 0 || len > 255)
|
||||
if (len > 255 || len < 0 )
|
||||
return(-1);
|
||||
|
||||
/*
|
||||
|
@ -52,9 +52,7 @@ __FBSDID("$FreeBSD$");
|
||||
#define LETTER (4*3)
|
||||
|
||||
void
|
||||
link_addr(addr, sdl)
|
||||
const char *addr;
|
||||
struct sockaddr_dl *sdl;
|
||||
link_addr(const char *addr, struct sockaddr_dl *sdl)
|
||||
{
|
||||
char *cp = sdl->sdl_data;
|
||||
char *cplim = sdl->sdl_len + (char *)sdl;
|
||||
@ -120,11 +118,10 @@ link_addr(addr, sdl)
|
||||
return;
|
||||
}
|
||||
|
||||
static char hexlist[] = "0123456789abcdef";
|
||||
static const char hexlist[] = "0123456789abcdef";
|
||||
|
||||
char *
|
||||
link_ntoa(sdl)
|
||||
const struct sockaddr_dl *sdl;
|
||||
link_ntoa(const struct sockaddr_dl *sdl)
|
||||
{
|
||||
static char obuf[64];
|
||||
char *out = obuf;
|
||||
|
@ -57,7 +57,6 @@ static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
@ -70,6 +69,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <resolv.h>
|
||||
#include <ctype.h>
|
||||
#include <syslog.h>
|
||||
#include "netdb_private.h"
|
||||
|
||||
typedef union {
|
||||
int32_t al;
|
||||
@ -79,19 +79,11 @@ typedef union {
|
||||
void
|
||||
_map_v4v6_address(const char *src, char *dst)
|
||||
{
|
||||
u_char *p = (u_char *)dst;
|
||||
char tmp[NS_INADDRSZ];
|
||||
int i;
|
||||
|
||||
/* Stash a temporary copy so our caller can update in place. */
|
||||
memcpy(tmp, src, NS_INADDRSZ);
|
||||
/* Our caller may update in place. */
|
||||
memmove(&dst[12], src, NS_INADDRSZ);
|
||||
/* Mark this ipv6 addr as a mapped ipv4. */
|
||||
for (i = 0; i < 10; i++)
|
||||
*p++ = 0x00;
|
||||
*p++ = 0xff;
|
||||
*p++ = 0xff;
|
||||
/* Retrieve the saved copy and we're done. */
|
||||
memcpy((void*)p, tmp, NS_INADDRSZ);
|
||||
memset(&dst[10], 0xff, 2);
|
||||
memset(&dst[0], 0, 10);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -44,11 +44,7 @@
|
||||
* 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
|
||||
* 3. 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.
|
||||
*
|
||||
@ -100,7 +96,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <netinet/in.h>
|
||||
#ifdef INET6
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet6/in6_var.h> /* XXX */
|
||||
@ -241,13 +236,13 @@ getipnodebyname(const char *name, int af, int flags, int *errp)
|
||||
if (flags & AI_ADDRCONFIG) {
|
||||
int s;
|
||||
|
||||
if ((s = _socket(af, SOCK_DGRAM, 0)) < 0)
|
||||
if ((s = _socket(af, SOCK_DGRAM | SOCK_CLOEXEC, 0)) < 0)
|
||||
return NULL;
|
||||
/*
|
||||
* TODO:
|
||||
* Note that implementation dependent test for address
|
||||
* configuration should be done every time called
|
||||
* (or apropriate interval),
|
||||
* (or appropriate interval),
|
||||
* because addresses will be dynamically assigned or deleted.
|
||||
*/
|
||||
_close(s);
|
||||
@ -337,7 +332,7 @@ getipnodebyaddr(const void *src, size_t len, int af, int *errp)
|
||||
*errp = NO_RECOVERY;
|
||||
return NULL;
|
||||
}
|
||||
if ((long)src & ~(sizeof(struct in_addr) - 1)) {
|
||||
if (rounddown2((long)src, sizeof(struct in_addr))) {
|
||||
memcpy(&addrbuf, src, len);
|
||||
src = &addrbuf;
|
||||
}
|
||||
@ -350,7 +345,8 @@ getipnodebyaddr(const void *src, size_t len, int af, int *errp)
|
||||
*errp = NO_RECOVERY;
|
||||
return NULL;
|
||||
}
|
||||
if ((long)src & ~(sizeof(struct in6_addr) / 2 - 1)) { /*XXX*/
|
||||
if (rounddown2((long)src, sizeof(struct in6_addr) / 2)) {
|
||||
/* XXX */
|
||||
memcpy(&addrbuf, src, len);
|
||||
src = &addrbuf;
|
||||
}
|
||||
@ -661,7 +657,6 @@ _hpreorder(struct hostent *hp)
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
free_addrselectpolicy(&policyhead);
|
||||
return hp;
|
||||
}
|
||||
|
||||
@ -742,11 +737,11 @@ get_addrselectpolicy(struct policyhead *head)
|
||||
char *buf;
|
||||
struct in6_addrpolicy *pol, *ep;
|
||||
|
||||
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0)
|
||||
if (sysctl(mib, nitems(mib), NULL, &l, NULL, 0) < 0)
|
||||
return (0);
|
||||
if ((buf = malloc(l)) == NULL)
|
||||
return (0);
|
||||
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &l, NULL, 0) < 0) {
|
||||
if (sysctl(mib, nitems(mib), buf, &l, NULL, 0) < 0) {
|
||||
free(buf);
|
||||
return (0);
|
||||
}
|
||||
@ -801,10 +796,9 @@ match_addrselectpolicy(struct sockaddr *addr, struct policyhead *head)
|
||||
memset(&key, 0, sizeof(key));
|
||||
key.sin6_family = AF_INET6;
|
||||
key.sin6_len = sizeof(key);
|
||||
key.sin6_addr.s6_addr[10] = 0xff;
|
||||
key.sin6_addr.s6_addr[11] = 0xff;
|
||||
memcpy(&key.sin6_addr.s6_addr[12],
|
||||
&((struct sockaddr_in *)addr)->sin_addr, 4);
|
||||
_map_v4v6_address(
|
||||
(char *)&((struct sockaddr_in *)addr)->sin_addr,
|
||||
(char *)&key.sin6_addr);
|
||||
break;
|
||||
default:
|
||||
return(NULL);
|
||||
@ -874,7 +868,8 @@ set_source(struct hp_order *aio, struct policyhead *ph)
|
||||
}
|
||||
|
||||
/* open a socket to get the source address for the given dst */
|
||||
if ((s = _socket(ss.ss_family, SOCK_DGRAM, IPPROTO_UDP)) < 0)
|
||||
if ((s = _socket(ss.ss_family, SOCK_DGRAM | SOCK_CLOEXEC,
|
||||
IPPROTO_UDP)) < 0)
|
||||
return; /* give up */
|
||||
if (_connect(s, (struct sockaddr *)&ss, ss.ss_len) < 0)
|
||||
goto cleanup;
|
||||
|
@ -130,8 +130,6 @@ void _endhostdnsent(void);
|
||||
void _endhosthtent(struct hostent_data *);
|
||||
void _endnetdnsent(void);
|
||||
void _endnethtent(struct netent_data *);
|
||||
struct hostent *_gethostbynisaddr(const void *, socklen_t, int);
|
||||
struct hostent *_gethostbynisname(const char *, int);
|
||||
void _map_v4v6_address(const char *, char *);
|
||||
void _map_v4v6_hostent(struct hostent *, char **, char *);
|
||||
void _sethostdnsent(int);
|
||||
@ -139,7 +137,23 @@ void _sethosthtent(int, struct hostent_data *);
|
||||
void _setnetdnsent(int);
|
||||
void _setnethtent(int, struct netent_data *);
|
||||
|
||||
int _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database,
|
||||
const char *method_name, const ns_src defaults[], ...);
|
||||
struct hostent *__dns_getanswer(const char *, int, const char *, int);
|
||||
int _dns_gethostbyaddr(void *, void *, va_list);
|
||||
int _dns_gethostbyname(void *, void *, va_list);
|
||||
int _dns_getnetbyaddr(void *, void *, va_list);
|
||||
int _dns_getnetbyname(void *, void *, va_list);
|
||||
int _ht_gethostbyaddr(void *, void *, va_list);
|
||||
int _ht_gethostbyname(void *, void *, va_list);
|
||||
int _ht_getnetbyaddr(void *, void *, va_list);
|
||||
int _ht_getnetbyname(void *, void *, va_list);
|
||||
int _nis_gethostbyaddr(void *, void *, va_list);
|
||||
int _nis_gethostbyname(void *, void *, va_list);
|
||||
int _nis_getnetbyaddr(void *, void *, va_list);
|
||||
int _nis_getnetbyname(void *, void *, va_list);
|
||||
#ifdef NS_CACHING
|
||||
int __proto_id_func(char *, size_t *, va_list, void *);
|
||||
int __proto_marshal_func(char *, size_t *, void *, va_list, void *);
|
||||
int __proto_unmarshal_func(char *, size_t, void *, va_list, void *);
|
||||
#endif
|
||||
|
||||
#endif /* _NETDB_PRIVATE_H_ */
|
||||
|
@ -17,13 +17,6 @@
|
||||
* 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
|
||||
@ -147,14 +140,17 @@ static void *nss_cache_cycle_prevention_func = NULL;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* When this is set to 1, nsdispatch won't use nsswitch.conf
|
||||
* but will consult the 'defaults' source list only.
|
||||
* NOTE: nested fallbacks (when nsdispatch calls fallback functions,
|
||||
* which in turn calls nsdispatch, which should call fallback
|
||||
* function) are not supported
|
||||
* We keep track of nsdispatch() nesting depth in dispatch_depth. When a
|
||||
* fallback method is invoked from nsdispatch(), we temporarily set
|
||||
* fallback_depth to the current dispatch depth plus one. Subsequent
|
||||
* calls at that exact depth will run in fallback mode (restricted to the
|
||||
* same source as the call that was handled by the fallback method), while
|
||||
* calls below that depth will be handled normally, allowing fallback
|
||||
* methods to perform arbitrary lookups.
|
||||
*/
|
||||
struct fb_state {
|
||||
int fb_dispatch;
|
||||
int dispatch_depth;
|
||||
int fallback_depth;
|
||||
};
|
||||
static void fb_endstate(void *);
|
||||
NSS_TLS_HANDLING(fb);
|
||||
@ -352,7 +348,6 @@ _nsdbtdump(const ns_dbt *dbt)
|
||||
static int
|
||||
nss_configure(void)
|
||||
{
|
||||
static pthread_mutex_t conf_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static time_t confmod;
|
||||
struct stat statbuf;
|
||||
int result, isthreaded;
|
||||
@ -376,15 +371,16 @@ nss_configure(void)
|
||||
if (statbuf.st_mtime <= confmod)
|
||||
return (0);
|
||||
if (isthreaded) {
|
||||
result = _pthread_mutex_trylock(&conf_lock);
|
||||
if (result != 0)
|
||||
return (0);
|
||||
(void)_pthread_rwlock_unlock(&nss_lock);
|
||||
result = _pthread_rwlock_wrlock(&nss_lock);
|
||||
if (result != 0)
|
||||
goto fin2;
|
||||
return (result);
|
||||
if (stat(path, &statbuf) != 0)
|
||||
goto fin;
|
||||
if (statbuf.st_mtime <= confmod)
|
||||
goto fin;
|
||||
}
|
||||
_nsyyin = fopen(path, "r");
|
||||
_nsyyin = fopen(path, "re");
|
||||
if (_nsyyin == NULL)
|
||||
goto fin;
|
||||
VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap),
|
||||
@ -417,9 +413,6 @@ fin:
|
||||
if (result == 0)
|
||||
result = _pthread_rwlock_rdlock(&nss_lock);
|
||||
}
|
||||
fin2:
|
||||
if (isthreaded)
|
||||
(void)_pthread_mutex_unlock(&conf_lock);
|
||||
return (result);
|
||||
}
|
||||
|
||||
@ -681,6 +674,7 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database,
|
||||
void *mdata;
|
||||
int isthreaded, serrno, i, result, srclistsize;
|
||||
struct fb_state *st;
|
||||
int saved_depth;
|
||||
|
||||
#ifdef NS_CACHING
|
||||
nss_cache_data cache_data;
|
||||
@ -712,7 +706,8 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database,
|
||||
result = NS_UNAVAIL;
|
||||
goto fin;
|
||||
}
|
||||
if (st->fb_dispatch == 0) {
|
||||
++st->dispatch_depth;
|
||||
if (st->dispatch_depth > st->fallback_depth) {
|
||||
dbt = vector_search(&database, _nsmap, _nsmapsize, sizeof(*_nsmap),
|
||||
string_compare);
|
||||
fb_method = nss_method_lookup(NSSRC_FALLBACK, database,
|
||||
@ -781,12 +776,13 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database,
|
||||
break;
|
||||
} else {
|
||||
if (fb_method != NULL) {
|
||||
st->fb_dispatch = 1;
|
||||
saved_depth = st->fallback_depth;
|
||||
st->fallback_depth = st->dispatch_depth + 1;
|
||||
va_start(ap, defaults);
|
||||
result = fb_method(retval,
|
||||
(void *)srclist[i].name, ap);
|
||||
va_end(ap);
|
||||
st->fb_dispatch = 0;
|
||||
st->fallback_depth = saved_depth;
|
||||
} else
|
||||
nss_log(LOG_DEBUG, "%s, %s, %s, not found, "
|
||||
"and no fallback provided",
|
||||
@ -818,6 +814,7 @@ _nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database,
|
||||
|
||||
if (isthreaded)
|
||||
(void)_pthread_rwlock_unlock(&nss_lock);
|
||||
--st->dispatch_depth;
|
||||
fin:
|
||||
errno = serrno;
|
||||
return (result);
|
||||
|
@ -16,13 +16,6 @@
|
||||
* 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
|
||||
@ -104,14 +97,13 @@ STRING [a-zA-Z][a-zA-Z0-9_]*
|
||||
|
||||
#undef _nsyywrap
|
||||
int
|
||||
_nsyywrap()
|
||||
_nsyywrap(void)
|
||||
{
|
||||
return 1;
|
||||
} /* _nsyywrap */
|
||||
|
||||
void
|
||||
_nsyyerror(msg)
|
||||
const char *msg;
|
||||
_nsyyerror(const char *msg)
|
||||
{
|
||||
|
||||
syslog(LOG_ERR, "NSSWITCH(nslexer): %s line %d: %s at '%s'",
|
||||
|
@ -16,13 +16,6 @@
|
||||
* 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
|
||||
@ -152,8 +145,7 @@ Action
|
||||
%%
|
||||
|
||||
static void
|
||||
_nsaddsrctomap(elem)
|
||||
const char *elem;
|
||||
_nsaddsrctomap(const char *elem)
|
||||
{
|
||||
int i, lineno;
|
||||
extern int _nsyylineno;
|
||||
|
@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
#include <arpa/nameser.h>
|
||||
#include "un-namespace.h"
|
||||
#include "libc_private.h"
|
||||
|
||||
extern int innetgr( const char *, const char *, const char *, const char * );
|
||||
|
||||
@ -74,22 +75,15 @@ static int __icheckhost(const struct sockaddr *, socklen_t, const char *);
|
||||
char paddr[NI_MAXHOST];
|
||||
|
||||
int
|
||||
rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
|
||||
char **ahost;
|
||||
u_short rport;
|
||||
const char *locuser, *remuser, *cmd;
|
||||
int *fd2p;
|
||||
rcmd(char **ahost, int rport, const char *locuser, const char *remuser,
|
||||
const char *cmd, int *fd2p)
|
||||
{
|
||||
return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET);
|
||||
}
|
||||
|
||||
int
|
||||
rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
|
||||
char **ahost;
|
||||
u_short rport;
|
||||
const char *locuser, *remuser, *cmd;
|
||||
int *fd2p;
|
||||
int af;
|
||||
rcmd_af(char **ahost, int rport, const char *locuser, const char *remuser,
|
||||
const char *cmd, int *fd2p, int af)
|
||||
{
|
||||
struct addrinfo hints, *res, *ai;
|
||||
struct sockaddr_storage from;
|
||||
@ -150,7 +144,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
|
||||
refused = 0;
|
||||
sigemptyset(&newmask);
|
||||
sigaddset(&newmask, SIGURG);
|
||||
_sigprocmask(SIG_BLOCK, (const sigset_t *)&newmask, &oldmask);
|
||||
__libc_sigprocmask(SIG_BLOCK, (const sigset_t *)&newmask, &oldmask);
|
||||
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
|
||||
s = rresvport_af(&lport, ai->ai_family);
|
||||
if (s < 0) {
|
||||
@ -165,7 +159,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
|
||||
(void)fprintf(stderr, "rcmd: socket: %s\n",
|
||||
strerror(errno));
|
||||
freeaddrinfo(res);
|
||||
_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
|
||||
__libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
|
||||
NULL);
|
||||
return (-1);
|
||||
}
|
||||
@ -183,7 +177,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
|
||||
(void)fprintf(stderr, "%s: %s\n",
|
||||
*ahost, strerror(errno));
|
||||
freeaddrinfo(res);
|
||||
_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
|
||||
__libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
|
||||
NULL);
|
||||
return (-1);
|
||||
}
|
||||
@ -215,7 +209,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
|
||||
}
|
||||
}
|
||||
lport--;
|
||||
if (fd2p == 0) {
|
||||
if (fd2p == NULL) {
|
||||
_write(s, "", 1);
|
||||
lport = 0;
|
||||
} else {
|
||||
@ -308,7 +302,7 @@ again:
|
||||
}
|
||||
goto bad2;
|
||||
}
|
||||
_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
|
||||
__libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
|
||||
freeaddrinfo(res);
|
||||
return (s);
|
||||
bad2:
|
||||
@ -316,21 +310,19 @@ bad2:
|
||||
(void)_close(*fd2p);
|
||||
bad:
|
||||
(void)_close(s);
|
||||
_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
|
||||
__libc_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
|
||||
freeaddrinfo(res);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int
|
||||
rresvport(port)
|
||||
int *port;
|
||||
rresvport(int *port)
|
||||
{
|
||||
return rresvport_af(port, AF_INET);
|
||||
}
|
||||
|
||||
int
|
||||
rresvport_af(alport, family)
|
||||
int *alport, family;
|
||||
rresvport_af(int *alport, int family)
|
||||
{
|
||||
int s;
|
||||
struct sockaddr_storage ss;
|
||||
@ -381,9 +373,7 @@ int __check_rhosts_file = 1;
|
||||
char *__rcmd_errstr;
|
||||
|
||||
int
|
||||
ruserok(rhost, superuser, ruser, luser)
|
||||
const char *rhost, *ruser, *luser;
|
||||
int superuser;
|
||||
ruserok(const char *rhost, int superuser, const char *ruser, const char *luser)
|
||||
{
|
||||
struct addrinfo hints, *res, *r;
|
||||
int error;
|
||||
@ -416,10 +406,7 @@ ruserok(rhost, superuser, ruser, luser)
|
||||
* Returns 0 if ok, -1 if not ok.
|
||||
*/
|
||||
int
|
||||
iruserok(raddr, superuser, ruser, luser)
|
||||
unsigned long raddr;
|
||||
int superuser;
|
||||
const char *ruser, *luser;
|
||||
iruserok(unsigned long raddr, int superuser, const char *ruser, const char *luser)
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
|
||||
@ -437,11 +424,8 @@ iruserok(raddr, superuser, ruser, luser)
|
||||
* Returns 0 if ok, -1 if not ok.
|
||||
*/
|
||||
int
|
||||
iruserok_sa(ra, rlen, superuser, ruser, luser)
|
||||
const void *ra;
|
||||
int rlen;
|
||||
int superuser;
|
||||
const char *ruser, *luser;
|
||||
iruserok_sa(const void *ra, int rlen, int superuser, const char *ruser,
|
||||
const char *luser)
|
||||
{
|
||||
char *cp;
|
||||
struct stat sbuf;
|
||||
@ -460,7 +444,7 @@ iruserok_sa(ra, rlen, superuser, ruser, luser)
|
||||
raddr = (struct sockaddr *)&ss;
|
||||
|
||||
first = 1;
|
||||
hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r");
|
||||
hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "re");
|
||||
again:
|
||||
if (hostf) {
|
||||
if (__ivaliduser_sa(hostf, raddr, rlen, luser, ruser) == 0) {
|
||||
@ -483,7 +467,7 @@ again:
|
||||
*/
|
||||
uid = geteuid();
|
||||
(void)seteuid(pwd->pw_uid);
|
||||
hostf = fopen(pbuf, "r");
|
||||
hostf = fopen(pbuf, "re");
|
||||
(void)seteuid(uid);
|
||||
|
||||
if (hostf == NULL)
|
||||
@ -521,10 +505,7 @@ again:
|
||||
* Returns 0 if ok, -1 if not ok.
|
||||
*/
|
||||
int
|
||||
__ivaliduser(hostf, raddr, luser, ruser)
|
||||
FILE *hostf;
|
||||
u_int32_t raddr;
|
||||
const char *luser, *ruser;
|
||||
__ivaliduser(FILE *hostf, u_int32_t raddr, const char *luser, const char *ruser)
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
|
||||
@ -542,11 +523,8 @@ __ivaliduser(hostf, raddr, luser, ruser)
|
||||
* XXX obsolete API.
|
||||
*/
|
||||
int
|
||||
__ivaliduser_af(hostf, raddr, luser, ruser, af, len)
|
||||
FILE *hostf;
|
||||
const void *raddr;
|
||||
const char *luser, *ruser;
|
||||
int af, len;
|
||||
__ivaliduser_af(FILE *hostf, const void *raddr, const char *luser,
|
||||
const char *ruser, int af, int len)
|
||||
{
|
||||
struct sockaddr *sa = NULL;
|
||||
struct sockaddr_in *sin = NULL;
|
||||
@ -585,11 +563,8 @@ __ivaliduser_af(hostf, raddr, luser, ruser, af, len)
|
||||
}
|
||||
|
||||
int
|
||||
__ivaliduser_sa(hostf, raddr, salen, luser, ruser)
|
||||
FILE *hostf;
|
||||
const struct sockaddr *raddr;
|
||||
socklen_t salen;
|
||||
const char *luser, *ruser;
|
||||
__ivaliduser_sa(FILE *hostf, const struct sockaddr *raddr, socklen_t salen,
|
||||
const char *luser, const char *ruser)
|
||||
{
|
||||
char *user, *p;
|
||||
int ch;
|
||||
@ -708,10 +683,7 @@ __ivaliduser_sa(hostf, raddr, salen, luser, ruser)
|
||||
* Returns "true" if match, 0 if no match.
|
||||
*/
|
||||
static int
|
||||
__icheckhost(raddr, salen, lhost)
|
||||
const struct sockaddr *raddr;
|
||||
socklen_t salen;
|
||||
const char *lhost;
|
||||
__icheckhost(const struct sockaddr *raddr, socklen_t salen, const char *lhost)
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in6 *sin6;
|
||||
|
@ -35,18 +35,25 @@ static char sccsid[] = "@(#)recv.c 8.2 (Berkeley) 2/21/94";
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include "libc_private.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
ssize_t
|
||||
recv(s, buf, len, flags)
|
||||
int s, flags;
|
||||
size_t len;
|
||||
void *buf;
|
||||
recv(int s, void *buf, size_t len, int flags)
|
||||
{
|
||||
return (_recvfrom(s, buf, len, flags, NULL, 0));
|
||||
/*
|
||||
* POSIX says recv() shall be a cancellation point, so call the
|
||||
* cancellation-enabled recvfrom() and not _recvfrom().
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
return (((ssize_t (*)(int, void *, size_t, int,
|
||||
struct sockaddr *, socklen_t *))
|
||||
__libc_interposing[INTERPOS_recvfrom])(s, buf, len, flags,
|
||||
NULL, NULL));
|
||||
#else /* __rtems__ */
|
||||
return (recvfrom(s, buf, len, flags, NULL, 0));
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#define DEBUG 1 /* enable debugging code (needed for dig) */
|
||||
#define RESOLVSORT /* allow sorting of addresses in gethostbyname */
|
||||
#undef SUNSECURITY /* verify gethostbyaddr() calls - WE DONT NEED IT */
|
||||
#undef SUNSECURITY /* verify gethostbyaddr() calls - WE DON'T NEED IT */
|
||||
#define MULTI_PTRS_ARE_ALIASES 1 /* fold multiple PTR records into aliases */
|
||||
#ifdef __rtems__
|
||||
#define dprintf gethostbydns_dprintf
|
||||
|
@ -35,7 +35,6 @@
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
@ -49,8 +48,7 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
|
||||
size_t
|
||||
inet6_rthdr_space(type, seg)
|
||||
int type, seg;
|
||||
inet6_rthdr_space(int type, int seg)
|
||||
{
|
||||
switch (type) {
|
||||
case IPV6_RTHDR_TYPE_0:
|
||||
@ -69,9 +67,7 @@ inet6_rthdr_space(type, seg)
|
||||
}
|
||||
|
||||
struct cmsghdr *
|
||||
inet6_rthdr_init(bp, type)
|
||||
void *bp;
|
||||
int type;
|
||||
inet6_rthdr_init(void *bp, int type)
|
||||
{
|
||||
struct cmsghdr *ch = (struct cmsghdr *)bp;
|
||||
struct ip6_rthdr *rthdr;
|
||||
@ -100,10 +96,7 @@ inet6_rthdr_init(bp, type)
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
inet6_rthdr_add(cmsg, addr, flags)
|
||||
struct cmsghdr *cmsg;
|
||||
const struct in6_addr *addr;
|
||||
u_int flags;
|
||||
inet6_rthdr_add(struct cmsghdr *cmsg, const struct in6_addr *addr, u_int flags)
|
||||
{
|
||||
struct ip6_rthdr *rthdr;
|
||||
|
||||
@ -145,9 +138,7 @@ inet6_rthdr_add(cmsg, addr, flags)
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
inet6_rthdr_lasthop(cmsg, flags)
|
||||
struct cmsghdr *cmsg;
|
||||
unsigned int flags;
|
||||
inet6_rthdr_lasthop(struct cmsghdr *cmsg, unsigned int flags)
|
||||
{
|
||||
struct ip6_rthdr *rthdr;
|
||||
|
||||
@ -185,9 +176,7 @@ inet6_rthdr_lasthop(cmsg, flags)
|
||||
|
||||
#if 0
|
||||
int
|
||||
inet6_rthdr_reverse(in, out)
|
||||
const struct cmsghdr *in;
|
||||
struct cmsghdr *out;
|
||||
inet6_rthdr_reverse(const struct cmsghdr *in, struct cmsghdr *out)
|
||||
{
|
||||
|
||||
return (-1);
|
||||
@ -195,8 +184,7 @@ inet6_rthdr_reverse(in, out)
|
||||
#endif
|
||||
|
||||
int
|
||||
inet6_rthdr_segments(cmsg)
|
||||
const struct cmsghdr *cmsg;
|
||||
inet6_rthdr_segments(const struct cmsghdr *cmsg)
|
||||
{
|
||||
struct ip6_rthdr *rthdr;
|
||||
|
||||
@ -219,9 +207,7 @@ inet6_rthdr_segments(cmsg)
|
||||
}
|
||||
|
||||
struct in6_addr *
|
||||
inet6_rthdr_getaddr(cmsg, idx)
|
||||
struct cmsghdr *cmsg;
|
||||
int idx;
|
||||
inet6_rthdr_getaddr(struct cmsghdr *cmsg, int idx)
|
||||
{
|
||||
struct ip6_rthdr *rthdr;
|
||||
|
||||
@ -251,9 +237,7 @@ inet6_rthdr_getaddr(cmsg, idx)
|
||||
}
|
||||
|
||||
int
|
||||
inet6_rthdr_getflags(cmsg, idx)
|
||||
const struct cmsghdr *cmsg;
|
||||
int idx;
|
||||
inet6_rthdr_getflags(const struct cmsghdr *cmsg, int idx)
|
||||
{
|
||||
struct ip6_rthdr *rthdr;
|
||||
|
||||
|
@ -35,18 +35,25 @@ static char sccsid[] = "@(#)send.c 8.2 (Berkeley) 2/21/94";
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include "libc_private.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
ssize_t
|
||||
send(s, msg, len, flags)
|
||||
int s, flags;
|
||||
size_t len;
|
||||
const void *msg;
|
||||
send(int s, const void *msg, size_t len, int flags)
|
||||
{
|
||||
return (_sendto(s, msg, len, flags, NULL, 0));
|
||||
/*
|
||||
* POSIX says send() shall be a cancellation point, so call the
|
||||
* cancellation-enabled sendto() and not _sendto().
|
||||
*/
|
||||
#ifndef __rtems__
|
||||
return (((ssize_t (*)(int, const void *, size_t, int,
|
||||
const struct sockaddr *, socklen_t))
|
||||
__libc_interposing[INTERPOS_sendto])(s, msg, len, flags,
|
||||
NULL, 0));
|
||||
#else /* __rtems__ */
|
||||
return (sendto(s, msg, len, flags, NULL, 0));
|
||||
#endif /* __rtems__ */
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ mac_init_internal(int ignore_errors)
|
||||
filename = getenv("MAC_CONFFILE");
|
||||
else
|
||||
filename = MAC_CONFFILE;
|
||||
file = fopen(filename, "r");
|
||||
file = fopen(filename, "re");
|
||||
if (file == NULL)
|
||||
return (0);
|
||||
|
||||
|
@ -35,6 +35,9 @@
|
||||
#undef h_errno
|
||||
extern int h_errno;
|
||||
|
||||
int *__h_errno(void);
|
||||
void __h_errno_set(res_state res, int err);
|
||||
|
||||
int *
|
||||
__h_errno(void)
|
||||
{
|
||||
|
@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include "port_before.h"
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
@ -78,7 +77,7 @@ const char *h_errlist[] = {
|
||||
"Unknown server error", /*%< 3 NO_RECOVERY */
|
||||
"No address associated with name", /*%< 4 NO_ADDRESS */
|
||||
};
|
||||
const int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] };
|
||||
const int h_nerr = { nitems(h_errlist) };
|
||||
|
||||
#undef h_errno
|
||||
int h_errno;
|
||||
|
@ -77,7 +77,7 @@ __res_init_ctx(void) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
if ((mt = malloc(sizeof (mtctxres_t))) == 0) {
|
||||
if ((mt = malloc(sizeof(mtctxres_t))) == NULL) {
|
||||
errno = ENOMEM;
|
||||
return (-1);
|
||||
}
|
||||
@ -96,10 +96,7 @@ __res_init_ctx(void) {
|
||||
static void
|
||||
__res_destroy_ctx(void *value) {
|
||||
|
||||
mtctxres_t *mt = (mtctxres_t *)value;
|
||||
|
||||
if (mt != 0)
|
||||
free(mt);
|
||||
free(value);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -134,9 +131,9 @@ ___mtctxres(void) {
|
||||
* that fails return a global context.
|
||||
*/
|
||||
if (mt_key_initialized) {
|
||||
if (((mt = pthread_getspecific(key)) != 0) ||
|
||||
if (((mt = pthread_getspecific(key)) != NULL) ||
|
||||
(__res_init_ctx() == 0 &&
|
||||
(mt = pthread_getspecific(key)) != 0)) {
|
||||
(mt = pthread_getspecific(key)) != NULL)) {
|
||||
return (mt);
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,6 @@ static const char rcsid[] = "$Id: res_comp.c,v 1.5 2005/07/28 06:51:50 marka Exp
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "port_before.h"
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
@ -88,7 +87,7 @@ __FBSDID("$FreeBSD$");
|
||||
/*%
|
||||
* Expand compressed domain name 'src' to full domain name.
|
||||
*
|
||||
* \li 'msg' is a pointer to the begining of the message,
|
||||
* \li 'msg' is a pointer to the beginning of the message,
|
||||
* \li 'eom' points to the first location after the message,
|
||||
* \li 'dst' is a pointer to a buffer of size 'dstsiz' for the result.
|
||||
* \li Return size of compressed name or -1 if there was an error.
|
||||
@ -149,12 +148,12 @@ dn_skipname(const u_char *ptr, const u_char *eom) {
|
||||
|| ((c) >= 0x61 && (c) <= 0x7a))
|
||||
#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)
|
||||
|
||||
#define borderchar(c) (alphachar(c) || digitchar(c))
|
||||
#ifdef RES_ENFORCE_RFC1034
|
||||
#define middlechar(c) (borderchar(c) || hyphenchar(c))
|
||||
#define borderchar(c) (alphachar(c) || digitchar(c))
|
||||
#else
|
||||
#define middlechar(c) (borderchar(c) || hyphenchar(c) || underscorechar(c))
|
||||
#define borderchar(c) (alphachar(c) || digitchar(c) || underscorechar(c))
|
||||
#endif
|
||||
#define middlechar(c) (borderchar(c) || hyphenchar(c))
|
||||
#define domainchar(c) ((c) > 0x20 && (c) < 0x7f)
|
||||
|
||||
int
|
||||
|
@ -25,7 +25,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
@ -79,9 +78,10 @@ const char *_res_sectioncodes[] = {
|
||||
|
||||
int res_ourserver_p(const res_state, const struct sockaddr_in *);
|
||||
|
||||
int
|
||||
__noinline int
|
||||
res_init(void) {
|
||||
extern int __res_vinit(res_state, int);
|
||||
res_state statp = &_res;
|
||||
|
||||
/*
|
||||
* These three fields used to be statically initialized. This made
|
||||
@ -102,14 +102,14 @@ res_init(void) {
|
||||
* set in RES_DEFAULT). Our solution is to declare such applications
|
||||
* "broken". They could fool us by setting RES_INIT but none do (yet).
|
||||
*/
|
||||
if (!_res.retrans)
|
||||
_res.retrans = RES_TIMEOUT;
|
||||
if (!_res.retry)
|
||||
_res.retry = RES_DFLRETRY;
|
||||
if (!(_res.options & RES_INIT))
|
||||
_res.options = RES_DEFAULT;
|
||||
if (!statp->retrans)
|
||||
statp->retrans = RES_TIMEOUT;
|
||||
if (!statp->retry)
|
||||
statp->retry = RES_DFLRETRY;
|
||||
if (!(statp->options & RES_INIT))
|
||||
statp->options = RES_DEFAULT;
|
||||
|
||||
return (__res_vinit(&_res, 1));
|
||||
return (__res_vinit(statp, 1));
|
||||
}
|
||||
|
||||
void
|
||||
@ -124,10 +124,11 @@ fp_query(const u_char *msg, FILE *file) {
|
||||
|
||||
void
|
||||
fp_nquery(const u_char *msg, int len, FILE *file) {
|
||||
if ((_res.options & RES_INIT) == 0U && res_init() == -1)
|
||||
res_state statp = &_res;
|
||||
if ((statp->options & RES_INIT) == 0U && res_init() == -1)
|
||||
return;
|
||||
|
||||
res_pquery(&_res, msg, len, file);
|
||||
res_pquery(statp, msg, len, file);
|
||||
}
|
||||
|
||||
int
|
||||
@ -140,23 +141,25 @@ res_mkquery(int op, /*!< opcode of query */
|
||||
u_char *buf, /*!< buffer to put query */
|
||||
int buflen) /*!< size of buffer */
|
||||
{
|
||||
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||
res_state statp = &_res;
|
||||
if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
|
||||
return (-1);
|
||||
}
|
||||
return (res_nmkquery(&_res, op, dname, class, type,
|
||||
return (res_nmkquery(statp, op, dname, class, type,
|
||||
data, datalen,
|
||||
newrr_in, buf, buflen));
|
||||
}
|
||||
|
||||
int
|
||||
res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
|
||||
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||
res_state statp = &_res;
|
||||
if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (res_nmkupdate(&_res, rrecp_in, buf, buflen));
|
||||
return (res_nmkupdate(statp, rrecp_in, buf, buflen));
|
||||
}
|
||||
|
||||
int
|
||||
@ -165,11 +168,12 @@ res_query(const char *name, /*!< domain name */
|
||||
u_char *answer, /*!< buffer to put answer */
|
||||
int anslen) /*!< size of answer buffer */
|
||||
{
|
||||
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||
res_state statp = &_res;
|
||||
if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
|
||||
return (-1);
|
||||
}
|
||||
return (res_nquery(&_res, name, class, type, answer, anslen));
|
||||
return (res_nquery(statp, name, class, type, answer, anslen));
|
||||
}
|
||||
|
||||
#ifndef _LIBC
|
||||
@ -191,12 +195,13 @@ res_isourserver(const struct sockaddr_in *inp) {
|
||||
|
||||
int
|
||||
res_send(const u_char *buf, int buflen, u_char *ans, int anssiz) {
|
||||
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
|
||||
res_state statp = &_res;
|
||||
if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
|
||||
/* errno should have been set by res_init() in this case. */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (res_nsend(&_res, buf, buflen, ans, anssiz));
|
||||
return (res_nsend(statp, buf, buflen, ans, anssiz));
|
||||
}
|
||||
|
||||
#ifndef _LIBC
|
||||
@ -204,12 +209,13 @@ int
|
||||
res_sendsigned(const u_char *buf, int buflen, ns_tsig_key *key,
|
||||
u_char *ans, int anssiz)
|
||||
{
|
||||
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
|
||||
res_state statp = &_res;
|
||||
if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
|
||||
/* errno should have been set by res_init() in this case. */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (res_nsendsigned(&_res, buf, buflen, key, ans, anssiz));
|
||||
return (res_nsendsigned(statp, buf, buflen, key, ans, anssiz));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -220,12 +226,13 @@ res_close(void) {
|
||||
|
||||
int
|
||||
res_update(ns_updrec *rrecp_in) {
|
||||
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||
res_state statp = &_res;
|
||||
if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (res_nupdate(&_res, rrecp_in, NULL));
|
||||
return (res_nupdate(statp, rrecp_in, NULL));
|
||||
}
|
||||
|
||||
int
|
||||
@ -234,12 +241,13 @@ res_search(const char *name, /*!< domain name */
|
||||
u_char *answer, /*!< buffer to put answer */
|
||||
int anslen) /*!< size of answer */
|
||||
{
|
||||
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||
res_state statp = &_res;
|
||||
if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (res_nsearch(&_res, name, class, type, answer, anslen));
|
||||
return (res_nsearch(statp, name, class, type, answer, anslen));
|
||||
}
|
||||
|
||||
int
|
||||
@ -249,24 +257,26 @@ res_querydomain(const char *name,
|
||||
u_char *answer, /*!< buffer to put answer */
|
||||
int anslen) /*!< size of answer */
|
||||
{
|
||||
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||
res_state statp = &_res;
|
||||
if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (res_nquerydomain(&_res, name, domain,
|
||||
return (res_nquerydomain(statp, name, domain,
|
||||
class, type,
|
||||
answer, anslen));
|
||||
}
|
||||
|
||||
u_int
|
||||
res_randomid(void) {
|
||||
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
|
||||
res_state statp = &_res;
|
||||
if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
|
||||
RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (res_nrandomid(&_res));
|
||||
return (res_nrandomid(statp));
|
||||
}
|
||||
|
||||
int
|
||||
@ -286,13 +296,15 @@ hostalias(const char *name) {
|
||||
int
|
||||
local_hostname_length(const char *hostname) {
|
||||
int len_host, len_domain;
|
||||
res_state statp;
|
||||
|
||||
if (!*_res.defdname)
|
||||
statp = &_res;
|
||||
if (!*statp->defdname)
|
||||
res_init();
|
||||
len_host = strlen(hostname);
|
||||
len_domain = strlen(_res.defdname);
|
||||
len_domain = strlen(statp->defdname);
|
||||
if (len_host > len_domain &&
|
||||
!strcasecmp(hostname + len_host - len_domain, _res.defdname) &&
|
||||
!strcasecmp(hostname + len_host - len_domain, statp->defdname) &&
|
||||
hostname[len_host - len_domain - 1] == '.')
|
||||
return (len_host - len_domain - 1);
|
||||
return (0);
|
||||
|
@ -100,7 +100,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
@ -369,11 +368,8 @@ p_cdname(const u_char *cp, const u_char *msg, FILE *file) {
|
||||
length supplied). */
|
||||
|
||||
const u_char *
|
||||
p_fqnname(cp, msg, msglen, name, namelen)
|
||||
const u_char *cp, *msg;
|
||||
int msglen;
|
||||
char *name;
|
||||
int namelen;
|
||||
p_fqnname(const u_char *cp, const u_char *msg, int msglen, char *name,
|
||||
int namelen)
|
||||
{
|
||||
int n, newlen;
|
||||
|
||||
@ -760,8 +756,7 @@ static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000,
|
||||
|
||||
/*% takes an XeY precision/size value, returns a string representation. */
|
||||
static const char *
|
||||
precsize_ntoa(prec)
|
||||
u_int8_t prec;
|
||||
precsize_ntoa(u_int8_t prec)
|
||||
{
|
||||
char *retbuf = precsize_ntoa_retbuf;
|
||||
unsigned long val;
|
||||
@ -914,9 +909,7 @@ latlon2ul(const char **latlonstrptr, int *which) {
|
||||
* converts a zone file representation in a string to an RDATA on-the-wire
|
||||
* representation. */
|
||||
int
|
||||
loc_aton(ascii, binary)
|
||||
const char *ascii;
|
||||
u_char *binary;
|
||||
loc_aton(const char *ascii, u_char *binary)
|
||||
{
|
||||
const char *cp, *maxcp;
|
||||
u_char *bcp;
|
||||
@ -1025,9 +1018,7 @@ loc_aton(ascii, binary)
|
||||
|
||||
/*% takes an on-the-wire LOC RR and formats it in a human readable format. */
|
||||
const char *
|
||||
loc_ntoa(binary, ascii)
|
||||
const u_char *binary;
|
||||
char *ascii;
|
||||
loc_ntoa(const u_char *binary, char *ascii)
|
||||
{
|
||||
static const char *error = "?";
|
||||
static char tmpbuf[sizeof
|
||||
|
@ -121,7 +121,7 @@ static void res_dprintf(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
|
||||
* notes:
|
||||
*\li this function calls res_nsend() which means it depends on correctly
|
||||
* functioning recursive nameservers (usually defined in /etc/resolv.conf
|
||||
* or its local equivilent).
|
||||
* or its local equivalent).
|
||||
*
|
||||
*\li we start by asking for an SOA<dname,class>. if we get one as an
|
||||
* answer, that just means <dname,class> is a zone top, which is fine.
|
||||
|
@ -77,9 +77,9 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
@ -117,7 +117,9 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
/*% Options. Should all be left alone. */
|
||||
#define RESOLVSORT
|
||||
#ifndef DEBUG
|
||||
#define DEBUG
|
||||
#endif
|
||||
|
||||
#ifdef SOLARIS2
|
||||
#include <sys/systeminfo.h>
|
||||
@ -144,7 +146,7 @@ static u_int32_t net_mask(struct in_addr);
|
||||
* there will have precedence. Otherwise, the server address is set to
|
||||
* INADDR_ANY and the default domain name comes from the gethostname().
|
||||
*
|
||||
* An interrim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1
|
||||
* An interim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1
|
||||
* rather than INADDR_ANY ("0.0.0.0") as the default name server address
|
||||
* since it was noted that INADDR_ANY actually meant ``the first interface
|
||||
* you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface,
|
||||
@ -167,7 +169,7 @@ res_ninit(res_state statp) {
|
||||
return (__res_vinit(statp, 0));
|
||||
}
|
||||
|
||||
/*% This function has to be reachable by res_data.c but not publically. */
|
||||
/*% This function has to be reachable by res_data.c but not publicly. */
|
||||
int
|
||||
__res_vinit(res_state statp, int preinit) {
|
||||
FILE *fp;
|
||||
@ -238,6 +240,7 @@ __res_vinit(res_state statp, int preinit) {
|
||||
statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
|
||||
strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa");
|
||||
strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int");
|
||||
statp->_u._ext.ext->reload_period = 2;
|
||||
} else {
|
||||
/*
|
||||
* Historically res_init() rarely, if at all, failed.
|
||||
@ -313,7 +316,7 @@ __res_vinit(res_state statp, int preinit) {
|
||||
while (*cp != '\0' && *cp != ' ' && *cp != '\t' && *cp != '\n')
|
||||
cp++;
|
||||
*cp = '\0';
|
||||
*pp++ = 0;
|
||||
*pp++ = NULL;
|
||||
}
|
||||
|
||||
#define MATCH(line, name) \
|
||||
@ -322,7 +325,19 @@ __res_vinit(res_state statp, int preinit) {
|
||||
line[sizeof(name) - 1] == '\t'))
|
||||
|
||||
nserv = 0;
|
||||
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
|
||||
if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) {
|
||||
struct stat sb;
|
||||
struct timespec now;
|
||||
|
||||
if (statp->_u._ext.ext != NULL) {
|
||||
if (_fstat(fileno(fp), &sb) == 0) {
|
||||
statp->_u._ext.ext->conf_mtim = sb.st_mtim;
|
||||
if (clock_gettime(CLOCK_MONOTONIC_FAST, &now) == 0) {
|
||||
statp->_u._ext.ext->conf_stat = now.tv_sec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* read the config file */
|
||||
while (fgets(buf, sizeof(buf), fp) != NULL) {
|
||||
/* skip comments */
|
||||
@ -377,7 +392,7 @@ __res_vinit(res_state statp, int preinit) {
|
||||
while (*cp != '\0' && *cp != ' ' && *cp != '\t')
|
||||
cp++;
|
||||
*cp = '\0';
|
||||
*pp++ = 0;
|
||||
*pp++ = NULL;
|
||||
havesearch = 1;
|
||||
continue;
|
||||
}
|
||||
@ -398,8 +413,8 @@ __res_vinit(res_state statp, int preinit) {
|
||||
hints.ai_socktype = SOCK_DGRAM; /*dummy*/
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
sprintf(sbuf, "%u", NAMESERVER_PORT);
|
||||
if (getaddrinfo(cp, sbuf, &hints, &ai) == 0 &&
|
||||
ai->ai_addrlen <= minsiz) {
|
||||
if (getaddrinfo(cp, sbuf, &hints, &ai) == 0) {
|
||||
if (ai->ai_addrlen <= minsiz) {
|
||||
if (statp->_u._ext.ext != NULL) {
|
||||
memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
|
||||
ai->ai_addr, ai->ai_addrlen);
|
||||
@ -410,9 +425,10 @@ __res_vinit(res_state statp, int preinit) {
|
||||
ai->ai_addr, ai->ai_addrlen);
|
||||
} else
|
||||
statp->nsaddr_list[nserv].sin_family = 0;
|
||||
freeaddrinfo(ai);
|
||||
nserv++;
|
||||
}
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -583,9 +599,7 @@ res_setoptions(res_state statp, const char *options, const char *source)
|
||||
{
|
||||
const char *cp = options;
|
||||
int i;
|
||||
#ifndef _LIBC
|
||||
struct __res_state_ext *ext = statp->_u._ext.ext;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
if (statp->options & RES_DEBUG)
|
||||
@ -668,6 +682,12 @@ res_setoptions(res_state statp, const char *options, const char *source)
|
||||
} else if (!strncmp(cp, "no-check-names",
|
||||
sizeof("no-check-names") - 1)) {
|
||||
statp->options |= RES_NOCHECKNAME;
|
||||
} else if (!strncmp(cp, "reload-period:",
|
||||
sizeof("reload-period:") - 1)) {
|
||||
if (ext != NULL) {
|
||||
ext->reload_period = (u_short)
|
||||
atoi(cp + sizeof("reload-period:") - 1);
|
||||
}
|
||||
}
|
||||
#ifdef RES_USE_EDNS0
|
||||
else if (!strncmp(cp, "edns0", sizeof("edns0") - 1)) {
|
||||
@ -720,8 +740,7 @@ res_setoptions(res_state statp, const char *options, const char *source)
|
||||
#ifdef RESOLVSORT
|
||||
/* XXX - should really support CIDR which means explicit masks always. */
|
||||
static u_int32_t
|
||||
net_mask(in) /*!< XXX - should really use system's version of this */
|
||||
struct in_addr in;
|
||||
net_mask(struct in_addr in) /*!< XXX - should really use system's version of this */
|
||||
{
|
||||
u_int32_t i = ntohl(in.s_addr);
|
||||
|
||||
|
@ -74,7 +74,6 @@ static const char rcsid[] = "$Id: res_mkquery.c,v 1.10 2008/12/11 09:59:00 marka
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "port_before.h"
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
@ -85,7 +84,9 @@ __FBSDID("$FreeBSD$");
|
||||
#include "port_after.h"
|
||||
|
||||
/* Options. Leave them on. */
|
||||
#ifndef DEBUG
|
||||
#define DEBUG
|
||||
#endif
|
||||
|
||||
extern const char *_res_opcodes[];
|
||||
|
||||
@ -133,7 +134,7 @@ res_nmkquery(res_state statp,
|
||||
dpp = dnptrs;
|
||||
*dpp++ = buf;
|
||||
*dpp++ = NULL;
|
||||
lastdnptr = dnptrs + sizeof dnptrs / sizeof dnptrs[0];
|
||||
lastdnptr = dnptrs + nitems(dnptrs);
|
||||
/*
|
||||
* perform opcode specific processing
|
||||
*/
|
||||
|
@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
@ -56,7 +55,9 @@ __FBSDID("$FreeBSD$");
|
||||
#include "port_after.h"
|
||||
|
||||
/* Options. Leave them on. */
|
||||
#ifndef DEBUG
|
||||
#define DEBUG
|
||||
#endif
|
||||
#define MAXPORT 1024
|
||||
|
||||
static int getnum_str(u_char **, u_char *);
|
||||
@ -127,7 +128,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
|
||||
dpp = dnptrs;
|
||||
*dpp++ = buf;
|
||||
*dpp++ = NULL;
|
||||
lastdnptr = dnptrs + sizeof dnptrs / sizeof dnptrs[0];
|
||||
lastdnptr = dnptrs + nitems(dnptrs);
|
||||
|
||||
if (rrecp_start == NULL)
|
||||
return (-5);
|
||||
@ -975,7 +976,7 @@ struct valuelist {
|
||||
static struct valuelist *servicelist, *protolist;
|
||||
|
||||
static void
|
||||
res_buildservicelist() {
|
||||
res_buildservicelist(void) {
|
||||
struct servent *sp;
|
||||
struct valuelist *slp;
|
||||
|
||||
@ -1175,7 +1176,7 @@ res_protocolname(int num) {
|
||||
if (protolist == (struct valuelist *)0)
|
||||
res_buildprotolist();
|
||||
pp = cgetprotobynumber(num);
|
||||
if (pp == 0) {
|
||||
if (pp == NULL) {
|
||||
(void) sprintf(number, "%d", num);
|
||||
return (number);
|
||||
}
|
||||
@ -1190,7 +1191,7 @@ res_servicename(u_int16_t port, const char *proto) { /*%< Host byte order. */
|
||||
if (servicelist == (struct valuelist *)0)
|
||||
res_buildservicelist();
|
||||
ss = cgetservbyport(htons(port), proto);
|
||||
if (ss == 0) {
|
||||
if (ss == NULL) {
|
||||
(void) sprintf(number, "%d", port);
|
||||
return (number);
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifndef res_private_h
|
||||
#define res_private_h
|
||||
|
||||
@ -12,6 +14,9 @@ struct __res_state_ext {
|
||||
} sort_list[MAXRESOLVSORT];
|
||||
char nsuffix[64];
|
||||
char nsuffix2[64];
|
||||
struct timespec conf_mtim; /* mod time of loaded resolv.conf */
|
||||
time_t conf_stat; /* time of last stat(resolv.conf) */
|
||||
u_short reload_period; /* seconds between stat(resolv.conf) */
|
||||
};
|
||||
|
||||
extern int
|
||||
|
@ -74,7 +74,6 @@ static const char rcsid[] = "$Id: res_query.c,v 1.11 2008/11/14 02:36:51 marka E
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "port_before.h"
|
||||
#include <sys/types.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
@ -90,7 +89,9 @@ __FBSDID("$FreeBSD$");
|
||||
#include "port_after.h"
|
||||
|
||||
/* Options. Leave them on. */
|
||||
#ifndef DEBUG
|
||||
#define DEBUG
|
||||
#endif
|
||||
|
||||
#if PACKETSZ > 1024
|
||||
#define MAXPACKET PACKETSZ
|
||||
@ -136,8 +137,8 @@ again:
|
||||
if (n > 0 && (statp->_flags & RES_F_EDNS0ERR) == 0 &&
|
||||
(statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC|RES_NSID))) {
|
||||
n = res_nopt(statp, n, buf, sizeof(buf), anslen);
|
||||
rdata = &buf[n];
|
||||
if (n > 0 && (statp->options & RES_NSID) != 0U) {
|
||||
rdata = &buf[n];
|
||||
n = res_nopt_rdata(statp, n, buf, sizeof(buf), rdata,
|
||||
NS_OPT_NSID, 0, NULL);
|
||||
}
|
||||
@ -459,7 +460,7 @@ res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) {
|
||||
if (issetugid())
|
||||
return (NULL);
|
||||
file = getenv("HOSTALIASES");
|
||||
if (file == NULL || (fp = fopen(file, "r")) == NULL)
|
||||
if (file == NULL || (fp = fopen(file, "re")) == NULL)
|
||||
return (NULL);
|
||||
setbuf(fp, NULL);
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user