This commit is contained in:
Nishi 2026-06-19 01:31:17 +09:00
commit 145c203403
167 changed files with 77 additions and 41295 deletions

View file

@ -1,6 +0,0 @@
SUBDIRS = \
sj3common \
sj3compat \
sj3core \
sj3lib \
sj3rkcv

View file

@ -1,9 +0,0 @@
EXTRA_DIST = \
Const.h \
sj3cmd.h \
sj3err.h \
sj_const.h \
sj_euc.h \
sj_hinsi.h \
sj_string.h

View file

@ -1,2 +0,0 @@
EXTRA_DIST = sj3compat.h sys-queue.h

View file

@ -1,128 +0,0 @@
/*
* Copyright (c) 2004 Iwata <iwata@quasiquote.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef SJ3COMPAT_H
#define SJ3COMPAT_H
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/param.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 128
#endif
#ifndef MAXLOGNAME
#define MAXLOGNAME 32
#endif
#ifndef FILENAME_MAX
#define FILENAME_MAX 1024
#endif
/* bsd-asprintf.c */
#ifndef HAVE_VASPRINTF
#define vasprintf sj3_vasprintf
int sj3_vasprintf(char **ret, const char *format, va_list ap);
#endif
#ifndef HAVE_ASPRINTF
#define asprintf sj3_asprintf
int sj3_asprintf(char **ret, const char *format, ...);
#endif
/* getopt.c */
#ifndef HAVE_GETOPT_OPTRESET
# undef getopt
# undef opterr
# undef optind
# undef optopt
# undef optreset
# undef optarg
# define getopt(ac, av, o) BSDgetopt(ac, av, o)
# define opterr BSDopterr
# define optind BSDoptind
# define optopt BSDoptopt
# define optreset BSDoptreset
# define optarg BSDoptarg
#endif
/* bsd-getpeereid.c */
#ifndef HAVE_GETPEEREID
#define getpeereid sj3_getpeereid
int sj3_getpeereid(int s, uid_t *euid, gid_t *egid);
#endif
/* bsd-misc.c */
#if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR)
#define strerror sj3_strerror
const char *sj3_strerror(int e);
#endif
#ifndef HAVE_STRDUP
#define strdup sj3_strdup
char *sj3_strdup(const char *str);
#endif
/* bsd-snprintf.c */
#ifndef HAVE_VSNPRINTF
#define vsnprintf sj3_vsnprintf
int sj3_vsnprintf(char *str, size_t size, const char *format, va_list ap);
#endif
#ifndef HAVE_SNPRINTF
#define snprintf sj3_snprintf
int sj3_snprintf(char *str, size_t size, const char *format, ...);
#endif
/* daemon.c */
#ifndef HAVE_DAEMON
#define daemon sj3_daemon
int sj3_daemon(int, int);
#endif
/* #include "fake-rfc2553.h" */
/* inet_ntoa.c */
#if defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA)
#define inet_ntoa sj3_inet_ntoa
char* sj3_inet_ntoa(struct in_addr in);
#endif
/* setproctitle.c */
#ifndef HAVE_SETPROCTITLE
#define setproctitle sj3_setproctitle
void setproctitle(const char *fmt, ...);
#endif
/* strlcat.c */
#ifndef HAVE_STRLCAT
#define strlcat sj3_strlcat
size_t sj3_strlcat(char *, const char *, size_t);
#endif
/* strlcpy.c */
#ifndef HAVE_STRLCPY
#define strlcpy sj3_strlcpy
size_t sj3_strlcpy(char *, const char *, size_t);
#endif
#endif /* SJ3COMPAT_H */

View file

@ -1,610 +0,0 @@
/* $OpenBSD: queue.h,v 1.32 2007/04/30 18:42:34 pedro Exp $ */
/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)queue.h 8.5 (Berkeley) 8/20/94
*/
#ifndef _FAKE_QUEUE_H_
#define _FAKE_QUEUE_H_
/*
* Require for OS/X and other platforms that have old/broken/incomplete
* <sys/queue.h>.
*/
#undef SLIST_HEAD
#undef SLIST_HEAD_INITIALIZER
#undef SLIST_ENTRY
#undef SLIST_FOREACH_PREVPTR
#undef SLIST_FIRST
#undef SLIST_END
#undef SLIST_EMPTY
#undef SLIST_NEXT
#undef SLIST_FOREACH
#undef SLIST_INIT
#undef SLIST_INSERT_AFTER
#undef SLIST_INSERT_HEAD
#undef SLIST_REMOVE_HEAD
#undef SLIST_REMOVE
#undef SLIST_REMOVE_NEXT
#undef LIST_HEAD
#undef LIST_HEAD_INITIALIZER
#undef LIST_ENTRY
#undef LIST_FIRST
#undef LIST_END
#undef LIST_EMPTY
#undef LIST_NEXT
#undef LIST_FOREACH
#undef LIST_INIT
#undef LIST_INSERT_AFTER
#undef LIST_INSERT_BEFORE
#undef LIST_INSERT_HEAD
#undef LIST_REMOVE
#undef LIST_REPLACE
#undef SIMPLEQ_HEAD
#undef SIMPLEQ_HEAD_INITIALIZER
#undef SIMPLEQ_ENTRY
#undef SIMPLEQ_FIRST
#undef SIMPLEQ_END
#undef SIMPLEQ_EMPTY
#undef SIMPLEQ_NEXT
#undef SIMPLEQ_FOREACH
#undef SIMPLEQ_INIT
#undef SIMPLEQ_INSERT_HEAD
#undef SIMPLEQ_INSERT_TAIL
#undef SIMPLEQ_INSERT_AFTER
#undef SIMPLEQ_REMOVE_HEAD
#undef TAILQ_HEAD
#undef TAILQ_HEAD_INITIALIZER
#undef TAILQ_ENTRY
#undef TAILQ_FIRST
#undef TAILQ_END
#undef TAILQ_NEXT
#undef TAILQ_LAST
#undef TAILQ_PREV
#undef TAILQ_EMPTY
#undef TAILQ_FOREACH
#undef TAILQ_FOREACH_REVERSE
#undef TAILQ_INIT
#undef TAILQ_INSERT_HEAD
#undef TAILQ_INSERT_TAIL
#undef TAILQ_INSERT_AFTER
#undef TAILQ_INSERT_BEFORE
#undef TAILQ_REMOVE
#undef TAILQ_REPLACE
#undef CIRCLEQ_HEAD
#undef CIRCLEQ_HEAD_INITIALIZER
#undef CIRCLEQ_ENTRY
#undef CIRCLEQ_FIRST
#undef CIRCLEQ_LAST
#undef CIRCLEQ_END
#undef CIRCLEQ_NEXT
#undef CIRCLEQ_PREV
#undef CIRCLEQ_EMPTY
#undef CIRCLEQ_FOREACH
#undef CIRCLEQ_FOREACH_REVERSE
#undef CIRCLEQ_INIT
#undef CIRCLEQ_INSERT_AFTER
#undef CIRCLEQ_INSERT_BEFORE
#undef CIRCLEQ_INSERT_HEAD
#undef CIRCLEQ_INSERT_TAIL
#undef CIRCLEQ_REMOVE
#undef CIRCLEQ_REPLACE
/*
* This file defines five types of data structures: singly-linked lists,
* lists, simple queues, tail queues, and circular queues.
*
*
* A singly-linked list is headed by a single forward pointer. The elements
* are singly linked for minimum space and pointer manipulation overhead at
* the expense of O(n) removal for arbitrary elements. New elements can be
* added to the list after an existing element or at the head of the list.
* Elements being removed from the head of the list should use the explicit
* macro for this purpose for optimum efficiency. A singly-linked list may
* only be traversed in the forward direction. Singly-linked lists are ideal
* for applications with large datasets and few or no removals or for
* implementing a LIFO queue.
*
* A list is headed by a single forward pointer (or an array of forward
* pointers for a hash table header). The elements are doubly linked
* so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before
* or after an existing element or at the head of the list. A list
* may only be traversed in the forward direction.
*
* A simple queue is headed by a pair of pointers, one the head of the
* list and the other to the tail of the list. The elements are singly
* linked to save space, so elements can only be removed from the
* head of the list. New elements can be added to the list before or after
* an existing element, at the head of the list, or at the end of the
* list. A simple queue may only be traversed in the forward direction.
*
* A tail queue is headed by a pair of pointers, one to the head of the
* list and the other to the tail of the list. The elements are doubly
* linked so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before or
* after an existing element, at the head of the list, or at the end of
* the list. A tail queue may be traversed in either direction.
*
* A circle queue is headed by a pair of pointers, one to the head of the
* list and the other to the tail of the list. The elements are doubly
* linked so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before or after
* an existing element, at the head of the list, or at the end of the list.
* A circle queue may be traversed in either direction, but has a more
* complex end of list detection.
*
* For details on the use of these macros, see the queue(3) manual page.
*/
#if defined(QUEUE_MACRO_DEBUG) || (defined(_KERNEL) && defined(DIAGNOSTIC))
#define _Q_INVALIDATE(a) (a) = ((void *)-1)
#else
#define _Q_INVALIDATE(a)
#endif
/*
* Singly-linked List definitions.
*/
#define SLIST_HEAD(name, type) \
struct name { \
struct type *slh_first; /* first element */ \
}
#define SLIST_HEAD_INITIALIZER(head) \
{ NULL }
#define SLIST_ENTRY(type) \
struct { \
struct type *sle_next; /* next element */ \
}
/*
* Singly-linked List access methods.
*/
#define SLIST_FIRST(head) ((head)->slh_first)
#define SLIST_END(head) NULL
#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head))
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
#define SLIST_FOREACH(var, head, field) \
for((var) = SLIST_FIRST(head); \
(var) != SLIST_END(head); \
(var) = SLIST_NEXT(var, field))
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
for ((varp) = &SLIST_FIRST((head)); \
((var) = *(varp)) != SLIST_END(head); \
(varp) = &SLIST_NEXT((var), field))
/*
* Singly-linked List functions.
*/
#define SLIST_INIT(head) { \
SLIST_FIRST(head) = SLIST_END(head); \
}
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
(elm)->field.sle_next = (slistelm)->field.sle_next; \
(slistelm)->field.sle_next = (elm); \
} while (0)
#define SLIST_INSERT_HEAD(head, elm, field) do { \
(elm)->field.sle_next = (head)->slh_first; \
(head)->slh_first = (elm); \
} while (0)
#define SLIST_REMOVE_NEXT(head, elm, field) do { \
(elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
} while (0)
#define SLIST_REMOVE_HEAD(head, field) do { \
(head)->slh_first = (head)->slh_first->field.sle_next; \
} while (0)
#define SLIST_REMOVE(head, elm, type, field) do { \
if ((head)->slh_first == (elm)) { \
SLIST_REMOVE_HEAD((head), field); \
} else { \
struct type *curelm = (head)->slh_first; \
\
while (curelm->field.sle_next != (elm)) \
curelm = curelm->field.sle_next; \
curelm->field.sle_next = \
curelm->field.sle_next->field.sle_next; \
_Q_INVALIDATE((elm)->field.sle_next); \
} \
} while (0)
/*
* List definitions.
*/
#define LIST_HEAD(name, type) \
struct name { \
struct type *lh_first; /* first element */ \
}
#define LIST_HEAD_INITIALIZER(head) \
{ NULL }
#define LIST_ENTRY(type) \
struct { \
struct type *le_next; /* next element */ \
struct type **le_prev; /* address of previous next element */ \
}
/*
* List access methods
*/
#define LIST_FIRST(head) ((head)->lh_first)
#define LIST_END(head) NULL
#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head))
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
#define LIST_FOREACH(var, head, field) \
for((var) = LIST_FIRST(head); \
(var)!= LIST_END(head); \
(var) = LIST_NEXT(var, field))
/*
* List functions.
*/
#define LIST_INIT(head) do { \
LIST_FIRST(head) = LIST_END(head); \
} while (0)
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
(listelm)->field.le_next->field.le_prev = \
&(elm)->field.le_next; \
(listelm)->field.le_next = (elm); \
(elm)->field.le_prev = &(listelm)->field.le_next; \
} while (0)
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
(elm)->field.le_prev = (listelm)->field.le_prev; \
(elm)->field.le_next = (listelm); \
*(listelm)->field.le_prev = (elm); \
(listelm)->field.le_prev = &(elm)->field.le_next; \
} while (0)
#define LIST_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
(head)->lh_first = (elm); \
(elm)->field.le_prev = &(head)->lh_first; \
} while (0)
#define LIST_REMOVE(elm, field) do { \
if ((elm)->field.le_next != NULL) \
(elm)->field.le_next->field.le_prev = \
(elm)->field.le_prev; \
*(elm)->field.le_prev = (elm)->field.le_next; \
_Q_INVALIDATE((elm)->field.le_prev); \
_Q_INVALIDATE((elm)->field.le_next); \
} while (0)
#define LIST_REPLACE(elm, elm2, field) do { \
if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \
(elm2)->field.le_next->field.le_prev = \
&(elm2)->field.le_next; \
(elm2)->field.le_prev = (elm)->field.le_prev; \
*(elm2)->field.le_prev = (elm2); \
_Q_INVALIDATE((elm)->field.le_prev); \
_Q_INVALIDATE((elm)->field.le_next); \
} while (0)
/*
* Simple queue definitions.
*/
#define SIMPLEQ_HEAD(name, type) \
struct name { \
struct type *sqh_first; /* first element */ \
struct type **sqh_last; /* addr of last next element */ \
}
#define SIMPLEQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).sqh_first }
#define SIMPLEQ_ENTRY(type) \
struct { \
struct type *sqe_next; /* next element */ \
}
/*
* Simple queue access methods.
*/
#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
#define SIMPLEQ_END(head) NULL
#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))
#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
#define SIMPLEQ_FOREACH(var, head, field) \
for((var) = SIMPLEQ_FIRST(head); \
(var) != SIMPLEQ_END(head); \
(var) = SIMPLEQ_NEXT(var, field))
/*
* Simple queue functions.
*/
#define SIMPLEQ_INIT(head) do { \
(head)->sqh_first = NULL; \
(head)->sqh_last = &(head)->sqh_first; \
} while (0)
#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
(head)->sqh_last = &(elm)->field.sqe_next; \
(head)->sqh_first = (elm); \
} while (0)
#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.sqe_next = NULL; \
*(head)->sqh_last = (elm); \
(head)->sqh_last = &(elm)->field.sqe_next; \
} while (0)
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
(head)->sqh_last = &(elm)->field.sqe_next; \
(listelm)->field.sqe_next = (elm); \
} while (0)
#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
(head)->sqh_last = &(head)->sqh_first; \
} while (0)
/*
* Tail queue definitions.
*/
#define TAILQ_HEAD(name, type) \
struct name { \
struct type *tqh_first; /* first element */ \
struct type **tqh_last; /* addr of last next element */ \
}
#define TAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).tqh_first }
#define TAILQ_ENTRY(type) \
struct { \
struct type *tqe_next; /* next element */ \
struct type **tqe_prev; /* address of previous next element */ \
}
/*
* tail queue access methods
*/
#define TAILQ_FIRST(head) ((head)->tqh_first)
#define TAILQ_END(head) NULL
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
#define TAILQ_LAST(head, headname) \
(*(((struct headname *)((head)->tqh_last))->tqh_last))
/* XXX */
#define TAILQ_PREV(elm, headname, field) \
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
#define TAILQ_EMPTY(head) \
(TAILQ_FIRST(head) == TAILQ_END(head))
#define TAILQ_FOREACH(var, head, field) \
for((var) = TAILQ_FIRST(head); \
(var) != TAILQ_END(head); \
(var) = TAILQ_NEXT(var, field))
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
for((var) = TAILQ_LAST(head, headname); \
(var) != TAILQ_END(head); \
(var) = TAILQ_PREV(var, headname, field))
/*
* Tail queue functions.
*/
#define TAILQ_INIT(head) do { \
(head)->tqh_first = NULL; \
(head)->tqh_last = &(head)->tqh_first; \
} while (0)
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
(head)->tqh_first->field.tqe_prev = \
&(elm)->field.tqe_next; \
else \
(head)->tqh_last = &(elm)->field.tqe_next; \
(head)->tqh_first = (elm); \
(elm)->field.tqe_prev = &(head)->tqh_first; \
} while (0)
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.tqe_next = NULL; \
(elm)->field.tqe_prev = (head)->tqh_last; \
*(head)->tqh_last = (elm); \
(head)->tqh_last = &(elm)->field.tqe_next; \
} while (0)
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
(elm)->field.tqe_next->field.tqe_prev = \
&(elm)->field.tqe_next; \
else \
(head)->tqh_last = &(elm)->field.tqe_next; \
(listelm)->field.tqe_next = (elm); \
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
} while (0)
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
(elm)->field.tqe_next = (listelm); \
*(listelm)->field.tqe_prev = (elm); \
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
} while (0)
#define TAILQ_REMOVE(head, elm, field) do { \
if (((elm)->field.tqe_next) != NULL) \
(elm)->field.tqe_next->field.tqe_prev = \
(elm)->field.tqe_prev; \
else \
(head)->tqh_last = (elm)->field.tqe_prev; \
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
_Q_INVALIDATE((elm)->field.tqe_prev); \
_Q_INVALIDATE((elm)->field.tqe_next); \
} while (0)
#define TAILQ_REPLACE(head, elm, elm2, field) do { \
if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
(elm2)->field.tqe_next->field.tqe_prev = \
&(elm2)->field.tqe_next; \
else \
(head)->tqh_last = &(elm2)->field.tqe_next; \
(elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
*(elm2)->field.tqe_prev = (elm2); \
_Q_INVALIDATE((elm)->field.tqe_prev); \
_Q_INVALIDATE((elm)->field.tqe_next); \
} while (0)
/*
* Circular queue definitions.
*/
#define CIRCLEQ_HEAD(name, type) \
struct name { \
struct type *cqh_first; /* first element */ \
struct type *cqh_last; /* last element */ \
}
#define CIRCLEQ_HEAD_INITIALIZER(head) \
{ CIRCLEQ_END(&head), CIRCLEQ_END(&head) }
#define CIRCLEQ_ENTRY(type) \
struct { \
struct type *cqe_next; /* next element */ \
struct type *cqe_prev; /* previous element */ \
}
/*
* Circular queue access methods
*/
#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
#define CIRCLEQ_LAST(head) ((head)->cqh_last)
#define CIRCLEQ_END(head) ((void *)(head))
#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
#define CIRCLEQ_EMPTY(head) \
(CIRCLEQ_FIRST(head) == CIRCLEQ_END(head))
#define CIRCLEQ_FOREACH(var, head, field) \
for((var) = CIRCLEQ_FIRST(head); \
(var) != CIRCLEQ_END(head); \
(var) = CIRCLEQ_NEXT(var, field))
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
for((var) = CIRCLEQ_LAST(head); \
(var) != CIRCLEQ_END(head); \
(var) = CIRCLEQ_PREV(var, field))
/*
* Circular queue functions.
*/
#define CIRCLEQ_INIT(head) do { \
(head)->cqh_first = CIRCLEQ_END(head); \
(head)->cqh_last = CIRCLEQ_END(head); \
} while (0)
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
(elm)->field.cqe_prev = (listelm); \
if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \
(head)->cqh_last = (elm); \
else \
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
(listelm)->field.cqe_next = (elm); \
} while (0)
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
(elm)->field.cqe_next = (listelm); \
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \
(head)->cqh_first = (elm); \
else \
(listelm)->field.cqe_prev->field.cqe_next = (elm); \
(listelm)->field.cqe_prev = (elm); \
} while (0)
#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
(elm)->field.cqe_next = (head)->cqh_first; \
(elm)->field.cqe_prev = CIRCLEQ_END(head); \
if ((head)->cqh_last == CIRCLEQ_END(head)) \
(head)->cqh_last = (elm); \
else \
(head)->cqh_first->field.cqe_prev = (elm); \
(head)->cqh_first = (elm); \
} while (0)
#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.cqe_next = CIRCLEQ_END(head); \
(elm)->field.cqe_prev = (head)->cqh_last; \
if ((head)->cqh_first == CIRCLEQ_END(head)) \
(head)->cqh_first = (elm); \
else \
(head)->cqh_last->field.cqe_next = (elm); \
(head)->cqh_last = (elm); \
} while (0)
#define CIRCLEQ_REMOVE(head, elm, field) do { \
if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \
(head)->cqh_last = (elm)->field.cqe_prev; \
else \
(elm)->field.cqe_next->field.cqe_prev = \
(elm)->field.cqe_prev; \
if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \
(head)->cqh_first = (elm)->field.cqe_next; \
else \
(elm)->field.cqe_prev->field.cqe_next = \
(elm)->field.cqe_next; \
_Q_INVALIDATE((elm)->field.cqe_prev); \
_Q_INVALIDATE((elm)->field.cqe_next); \
} while (0)
#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \
CIRCLEQ_END(head)) \
(head).cqh_last = (elm2); \
else \
(elm2)->field.cqe_next->field.cqe_prev = (elm2); \
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \
CIRCLEQ_END(head)) \
(head).cqh_first = (elm2); \
else \
(elm2)->field.cqe_prev->field.cqe_next = (elm2); \
_Q_INVALIDATE((elm)->field.cqe_prev); \
_Q_INVALIDATE((elm)->field.cqe_next); \
} while (0)
#endif /* !_SYS_QUEUE_H_ */

View file

@ -1,21 +0,0 @@
EXTRA_DIST = \
Dict.h \
Struct.h \
sj3lowlib.h \
sj_connect.h \
sj_const.h \
sj_dict.h \
sj_global.h \
sj_kanakan.h \
sj_kcnv.h \
sj_left.h \
sj_prty.h \
sj_rename.h \
sj_right.h \
sj_struct.h \
sj_study.h \
sj_suuji.h \
sj_table.h \
sj_typedef.h \
sj_var.h \
sj_yomi.h

View file

@ -117,7 +117,9 @@ typedef struct global {
typedef struct dictfile {
DICT dict;
int refcnt;
#ifdef SJ3_LOCK
fd_set lock;
#endif
FILE *fp;
int fd;
@ -153,21 +155,4 @@ typedef struct workarea {
Global global;
} WorkArea;
typedef struct client {
int fd;
char host[MAXHOSTNAMELEN];
char user[MAXLOGNAME];
char prog[FILENAME_MAX];
WorkArea *work;
StdyFile *stdy;
short version;
unsigned char def_char[2];
#if (defined(TLI) && defined(SOCK_UNIX))
int unix_flag;
#endif
uid_t uid;
struct client *next;
} Client;
#endif

View file

@ -17,6 +17,17 @@
#ifndef KANAKAN_H
#define KANAKAN_H
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <errno.h>
#include <sys/stat.h>
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#include "sj_kcnv.h"
#include "sj_struct.h"

View file

@ -34,7 +34,6 @@
*/
#include <stdio.h>
#include <sys/param.h>
#include "sj_typedef.h"
#include "sj_rename.h"
#include "sj_const.h"

View file

@ -38,8 +38,6 @@
#define _SJ_RENAME
#include <config.h>
#define adddic Jadddic
#define checksub Jchecksub
#define checkdict Jcheckdict

View file

@ -43,13 +43,15 @@
#define RECURS
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef void (*VFunc)();
typedef u_char *(*UCPFunc)();
typedef int (*IFunc)();
#include <sys/types.h>
typedef u_char TypeGroup;
typedef u_char TypeGram;
typedef u_short TypeIdxOfs;

View file

@ -1,6 +0,0 @@
EXTRA_DIST = \
sj3intern.h \
sj3lowlib.h
include_HEADERS = sj3lib.h

View file

@ -1,55 +0,0 @@
/*
* Copyright (c) 2004 Iwata <iwata@quasiquote.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef SJ3INTERN_H
#define SJ3INTERN_H
#include "sj3lowlib.h"
/* level1.c */
void sj3_set_timeout(int);
int sj3_make_connection(SJ3_CLIENT_ENV *, char *, char *, char *);
int sj3_erase_connection(SJ3_CLIENT_ENV *);
long sj3_open_dictionary(SJ3_CLIENT_ENV *, char *, char *);
int sj3_close_dictionary(SJ3_CLIENT_ENV *, long);
int sj3_open_study_file(SJ3_CLIENT_ENV *, char *, char *);
int sj3_close_study_file(SJ3_CLIENT_ENV *);
int sj3_get_id_size(SJ3_CLIENT_ENV *);
int sj3_lock_server(SJ3_CLIENT_ENV *);
int sj3_unlock_server(SJ3_CLIENT_ENV *);
int sj3_ikkatu_henkan(SJ3_CLIENT_ENV *, u_char *, u_char *, int, int);
int sj3_bunsetu_henkan(SJ3_CLIENT_ENV *, u_char *, int, u_char *, int);
int sj3_bunsetu_jikouho(SJ3_CLIENT_ENV *, u_char *, int, int);
int sj3_bunsetu_maekouho(SJ3_CLIENT_ENV *, u_char *, int, int);
int sj3_bunsetu_kouhosuu(SJ3_CLIENT_ENV *, u_char *, int, int);
int sj3_bunsetu_zenkouho(SJ3_CLIENT_ENV *, u_char *, int, SJ3_DOUON *, int);
int sj3_tango_gakusyuu(SJ3_CLIENT_ENV *, SJ3_STUDYREC *);
int sj3_bunsetu_gakusyuu(SJ3_CLIENT_ENV *, u_char *, u_char *, SJ3_STUDYREC *, int);
int sj3_tango_touroku(SJ3_CLIENT_ENV *, long, u_char *, u_char *, int, int);
int sj3_tango_sakujo(SJ3_CLIENT_ENV *, long, u_char *, u_char *, int, int);
int sj3_tango_syutoku(SJ3_CLIENT_ENV *, int, u_char *, int);
int sj3_tango_jikouho(SJ3_CLIENT_ENV *, int, u_char *, int);
int sj3_tango_maekouho(SJ3_CLIENT_ENV *, int, u_char *, int);
int sj3_make_dict_file(SJ3_CLIENT_ENV *, char *, int, int, int);
int sj3_make_study_file(SJ3_CLIENT_ENV *, char *, int, int, int);
int sj3_make_directory(SJ3_CLIENT_ENV *, char *);
int sj3_access(SJ3_CLIENT_ENV *, char *, int);
int sj3_who(SJ3_CLIENT_ENV *, SJ3_WHO_STRUCT *, int);
int sj3_quit(SJ3_CLIENT_ENV *);
int sj3_kill(SJ3_CLIENT_ENV *);
int sj3_version(SJ3_CLIENT_ENV *, char *, int);
#endif /* SJ3INTERN_H */

View file

@ -1,207 +0,0 @@
/*
* Copyright (c) 1991-1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*
*/
/*
* $SonyRCSfile: sj3lib.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:03:57 $
*/
#ifndef SJ3LIB_H
#define SJ3LIB_H
#include <sys/types.h>
#define SJ3_NORMAL_END 0
#define SJ3_SERVER_DEAD (1 << 0)
#define SJ3_CONNECT_ERROR (1 << 1)
#define SJ3_ALREADY_CONNECTED (1 << 2)
#define SJ3_CANNOT_OPEN_MDICT (1 << 3)
#define SJ3_CANNOT_OPEN_UDICT (1 << 4)
#define SJ3_CANNOT_OPEN_STUDY (1 << 5)
#define SJ3_CANNOT_MAKE_UDIR (1 << 6)
#define SJ3_CANNOT_MAKE_UDICT (1 << 7)
#define SJ3_CANNOT_MAKE_STUDY (1 << 8)
#define SJ3_DISCONNECT_ERROR (1 << 1)
#define SJ3_NOT_CONNECTED (1 << 2)
#define SJ3_NOT_OPENED_MDICT (1 << 3)
#define SJ3_NOT_OPENED_UDICT (1 << 4)
#define SJ3_NOT_OPENED_STUDY (1 << 5)
#define SJ3_CLOSE_MDICT_ERROR (1 << 6)
#define SJ3_CLOSE_UDICT_ERROR (1 << 7)
#define SJ3_CLOSE_STUDY_ERROR (1 << 8)
#define SJ3_DICT_ERROR 1
#define SJ3_DICT_LOCKED 2
#define SJ3_BAD_YOMI_STR 3
#define SJ3_BAD_KANJI_STR 4
#define SJ3_BAD_HINSI_CODE 5
#define SJ3_WORD_EXIST 6
#define SJ3_DOUON_FULL 7
#define SJ3_DICT_FULL 8
#define SJ3_INDEX_FULL 9
#define SJ3_TOUROKU_FAILED 10
#define SJ3_WORD_NOT_EXIST 6
#define SJ3_SYOUKYO_FAILED 10
#define SJ3_IKKATU_YOMI 512
#define SJ3_BUNSETU_YOMI 128
#define SJ3_BUNSETU_KANJI 512
#ifndef SJ3_WORD_ID_SIZE
# define SJ3_WORD_ID_SIZE 32
#endif
typedef struct studyrec {
unsigned char dummy[SJ3_WORD_ID_SIZE];
} SJ3_STUDYREC;
typedef struct bunsetu {
int srclen;
int destlen;
unsigned char *srcstr;
unsigned char *deststr;
struct studyrec dcid;
} SJ3_BUNSETU;
typedef struct douon {
unsigned char ddata[SJ3_BUNSETU_KANJI];
int dlen;
SJ3_STUDYREC dcid;
} SJ3_DOUON;
#define SJ3_H_NRMNOUN 1
#define SJ3_H_PRONOUN 12
#define SJ3_H_LNAME 21
#define SJ3_H_FNAME 22
#define SJ3_H_LOCNAME 24
#define SJ3_H_PREFIC 25
#define SJ3_H_RENTAI 26
#define SJ3_H_CONJUNC 27
#define SJ3_H_SUBNUM 29
#define SJ3_H_NUMERAL 30
#define SJ3_H_PREFIX 31
#define SJ3_H_POSTFIX 36
#define SJ3_H_ADVERB 45
#define SJ3_H_ADJECT 60
#define SJ3_H_ADJVERB 71
#define SJ3_H_SILVERB 80
#define SJ3_H_ZILVERB 81
#define SJ3_H_ONEVERB 90
#define SJ3_H_KAVERB 91
#define SJ3_H_GAVERB 92
#define SJ3_H_SAVERB 93
#define SJ3_H_TAVERB 94
#define SJ3_H_NAVERB 95
#define SJ3_H_BAVERB 96
#define SJ3_H_MAVERB 97
#define SJ3_H_RAVERB 98
#define SJ3_H_WAVERB 99
#define SJ3_H_SINGLE 189
/* sj3.c */
int sj3_open(char *, char *);
int sj3_open_with_list(char *, char *, int, char **, int *, int **);
int sj3_close();
int sj3_getkan(u_char *, SJ3_BUNSETU *, u_char *, int);
int sj3_getkan_euc(u_char *, SJ3_BUNSETU *, u_char *, int);
int sj3_getkan_mb(u_char *, SJ3_BUNSETU *, u_char *, int);
int sj3_douoncnt(u_char *);
int sj3_douoncnt_euc(u_char *);
int sj3_douoncnt_mb(u_char *);
int sj3_getdouon(u_char *, SJ3_DOUON *);
int sj3_getdouon_euc(u_char *, SJ3_DOUON *);
int sj3_getdouon_mb(u_char *, SJ3_DOUON *);
int sj3_gakusyuu(SJ3_STUDYREC *);
int sj3_gakusyuu2(u_char *, u_char *, SJ3_STUDYREC *);
int sj3_gakusyuu2_euc(u_char *, u_char *, SJ3_STUDYREC *);
int sj3_gakusyuu2_mb(u_char *, u_char *, SJ3_STUDYREC *);
int sj3_touroku(u_char *, u_char *, int);
int sj3_touroku_euc(u_char *, u_char *, int);
int sj3_touroku_mb(u_char *, u_char *, int);
int sj3_syoukyo(u_char *, u_char *, int);
int sj3_syoukyo_euc(u_char *, u_char *, int);
int sj3_syoukyo_mb(u_char *, u_char *, int);
int sj3_getdict(u_char *);
int sj3_getdict_euc(u_char *);
int sj3_getdict_mb(u_char *);
int sj3_nextdict(u_char *);
int sj3_nextdict_euc(u_char *);
int sj3_nextdict_mb(u_char *);
int sj3_prevdict(u_char *);
int sj3_prevdict_euc(u_char *);
int sj3_prevdict_mb(u_char *);
int sj3_lockserv();
int sj3_unlockserv();
extern int sj3_error_number;
#endif /* SJ3LIB_H */

View file

@ -1,69 +0,0 @@
/*
* Copyright (c) 1991-1994 Sony Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* from Sony Corporation.
*
*/
/*
* $SonyRCSfile: sj3lowlib.h,v $
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:59 $
*/
#ifndef SJ3LOWLIB_H
#define SJ3LOWLIB_H
typedef struct sj3_client_env {
int fd;
int serv_dead_flg;
int stdy_size;
short svr_version;
short cli_version;
char default_char[2];
} SJ3_CLIENT_ENV;
#ifndef SJ3_NAME_LENGTH
# define SJ3_NAME_LENGTH 128
#endif
typedef struct sj3_who_struct {
int fd;
char hostname[SJ3_NAME_LENGTH];
char username[SJ3_NAME_LENGTH];
char progname[SJ3_NAME_LENGTH];
} SJ3_WHO_STRUCT;
#define MBCODE_SJIS 1
#define MBCODE_EUC 2
#endif /* SJ3LOWLIB_H */

View file

@ -1,8 +0,0 @@
EXTRA_DIST = \
kana.h \
kctype.h \
key.h \
rk.h \
wchar16.h
include_HEADERS = sj3rkcv.h