KNF, SPDX and some other cleanups

Signed-off-by: Masanori Ogino <mogino@acm.org>
This commit is contained in:
Masanori Ogino 2023-12-07 20:24:34 +09:00
commit 6fa42826a9
4 changed files with 152 additions and 175 deletions

22
.gitmodules vendored
View file

@ -1,3 +1,25 @@
# SPDX-License-Identifier: MIT
#
# Copyright (c) 2023 Masanori Ogino
#
# 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 THE
# AUTHORS OR COPYRIGHT HOLDERS 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.
[submodule "dict"] [submodule "dict"]
path = dict path = dict
url = ../sj3-dict url = ../sj3-dict

42
Const.h
View file

@ -1,6 +1,8 @@
/* /*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1991-1994 Sony Corporation * Copyright (c) 1991-1994 Sony Corporation
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including * "Software"), to deal in the Software without restriction, including
@ -8,10 +10,10 @@
* distribute, sublicense, and/or sell copies of the Software, and to * distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to * permit persons to whom the Software is furnished to do so, subject to
* the following conditions: * the following conditions:
* *
* The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@ -19,29 +21,15 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* Except as contained in this notice, the name of Sony Corporation * Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use * shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization * or other dealings in this Software without prior written authorization
* from Sony Corporation. * from Sony Corporation.
*
*/ */
/* #ifndef SJ3_CONST_H_
* $SonyRCSfile: Const.h,v $ #define SJ3_CONST_H_
* $SonyRevision: 1.4 $
* $SonyDate: 1997/01/23 11:20:52 $
*
* $Id$
*/
/*
* Change some default values.
* Patched by Hidekazu Kuroki(hidekazu@cs.titech.ac.jp) 1996/8/10
*/
#ifndef _Const_H_
#define _Const_H_ 1
#include "Paths.h" #include "Paths.h"
@ -70,17 +58,7 @@
#define MaxClientNum 512 #define MaxClientNum 512
#define LogOutFile ErrorOutFile #define LogOutFile ErrorOutFile
#define PortName "sj3" #define PortName "sj3"
#ifdef TLI
#define LocalHost "localhost"
#define ProtoName "tcp"
#define PortNumber "3000"
#else
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
#define PortNumber 3086 #define PortNumber 3086
#else /* ! __FreeBSD__ __NetBSD__ __OpenBSD__ __DragonFly__ */
#define PortNumber 3000
#endif /* ! __FreeBSD__ __NetBSD__ __OpenBSD__ __DragonFly__ */
#endif
#define DirectryMode 0755 #define DirectryMode 0755
#define DictFileMode 0644 #define DictFileMode 0644
#define MODE_MASK 0777 #define MODE_MASK 0777
@ -101,4 +79,4 @@
# define FALSE (!TRUE) # define FALSE (!TRUE)
#endif #endif
#endif /* _Const_H_ */ #endif /* SJ3_Const_H_ */

29
Dict.h
View file

@ -1,6 +1,8 @@
/* /*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1991-1994 Sony Corporation * Copyright (c) 1991-1994 Sony Corporation
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including * "Software"), to deal in the Software without restriction, including
@ -8,10 +10,10 @@
* distribute, sublicense, and/or sell copies of the Software, and to * distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to * permit persons to whom the Software is furnished to do so, subject to
* the following conditions: * the following conditions:
* *
* The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@ -19,29 +21,21 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* Except as contained in this notice, the name of Sony Corporation * Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use * shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization * or other dealings in this Software without prior written authorization
* from Sony Corporation. * from Sony Corporation.
*
*/ */
/* #ifndef SJ3_DICT_H_
* $SonyRCSfile: Dict.h,v $ #define SJ3_DICT_H_
* $SonyRevision: 1.1 $
* $SonyDate: 1994/06/03 08:00:55 $
*/
#define VersionPos 0 #define VersionPos 0
#define PasswdPos 16 #define PasswdPos 16
#define PasswdLen 16 #define PasswdLen 16
#define StdyNormPos 32 #define StdyNormPos 32
#define StdyNormLen 36 #define StdyNormLen 36
#define StdyNormNum 40 #define StdyNormNum 40
@ -54,7 +48,6 @@
#define StdyClSegPos 64 #define StdyClSegPos 64
#define StdyClSegLen 68 #define StdyClSegLen 68
#define DictIdxPos 32 #define DictIdxPos 32
#define DictIdxLen 36 #define DictIdxLen 36
@ -69,14 +62,14 @@
#define DictASegPos 80 #define DictASegPos 80
#define DictASegLen 84 #define DictASegLen 84
#define HeaderPos 0 #define HeaderPos 0
#define HeaderLength 128 #define HeaderLength 128
#define CommentPos 128 #define CommentPos 128
#define CommentLength 128 #define CommentLength 128
#define Byte2Long(c3,c2,c1,c0) (((c3) << (8*3)) | ((c2) << (8*2)) | \ #define Byte2Long(c3,c2,c1,c0) (((c3) << (8*3)) | ((c2) << (8*2)) | \
((c1) << (8*1)) | ((c0) << (8*0))) ((c1) << (8*1)) | ((c0) << (8*0)))
#define StdyVersion Byte2Long('S', 2, 0, 0) #define StdyVersion Byte2Long('S', 2, 0, 0)
#define DictVersion Byte2Long('D', 2, 0, 0) #define DictVersion Byte2Long('D', 2, 0, 0)
#endif /* SJ3_DICT_H_ */

212
Struct.h
View file

@ -1,6 +1,8 @@
/* /*-
* SPDX-License-Identifier: MIT-open-group
*
* Copyright (c) 1991-1994 Sony Corporation * Copyright (c) 1991-1994 Sony Corporation
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including * "Software"), to deal in the Software without restriction, including
@ -8,10 +10,10 @@
* distribute, sublicense, and/or sell copies of the Software, and to * distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to * permit persons to whom the Software is furnished to do so, subject to
* the following conditions: * the following conditions:
* *
* The above copyright notice and this permission notice shall be * The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software. * included in all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@ -19,24 +21,15 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* Except as contained in this notice, the name of Sony Corporation * Except as contained in this notice, the name of Sony Corporation
* shall not be used in advertising or otherwise to promote the sale, use * shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization * or other dealings in this Software without prior written authorization
* from Sony Corporation. * from Sony Corporation.
*
*/ */
/* #ifndef SJ3_STRUCT_H_
* $SonyRCSfile: Struct.h,v $ #define SJ3_STRUCT_H_
* $SonyRevision: 1.3 $
* $SonyDate: 1994/10/21 05:13:34 $
*
* $Id$
*/
#ifndef _Struct_H_
#define _Struct_H_ 1
#include <sys/select.h> #include <sys/select.h>
#include <sys/types.h> #include <sys/types.h>
@ -48,142 +41,133 @@
#include "Const.h" #include "Const.h"
typedef struct global { typedef struct global {
JREC *Jmaxjptr; JREC *Jmaxjptr;
CLREC *Jmaxclptr; CLREC *Jmaxclptr;
JREC *Jjrt1st; JREC *Jjrt1st;
CLREC *Jclt1st; CLREC *Jclt1st;
JREC *Jjrt2nd; JREC *Jjrt2nd;
CLREC *Jclt2nd; CLREC *Jclt2nd;
CLREC *Jselcl; CLREC *Jselcl;
short Jselectid; short Jselectid;
short Jtrank; short Jtrank;
short Jnrank; short Jnrank;
u_char *Jinputyomi; u_char *Jinputyomi;
u_char *Jcnvstart; u_char *Jcnvstart;
short Jcnvlen; short Jcnvlen;
u_char *Jystart; u_char *Jystart;
u_char Jhyomi[MaxPhInputLen+1]; u_char Jhyomi[MaxPhInputLen + 1];
u_char Jorgyomi[MaxClInputLen*2+1]; u_char Jorgyomi[MaxClInputLen*2 + 1];
u_char Jkanjibuf[MinPhOutputLen]; u_char Jkanjibuf[MinPhOutputLen];
u_char *Jkanjipos; u_char *Jkanjipos;
u_char *Jkanjitmp; u_char *Jkanjitmp;
short Jkanjilen; short Jkanjilen;
u_char Jdicinl; u_char Jdicinl;
u_char Jdicsaml; u_char Jdicsaml;
TypeDicSeg Jprevseg; TypeDicSeg Jprevseg;
u_char Jfzkcount; u_char Jfzkcount;
u_char Jfzk_ka_flg; u_char Jfzk_ka_flg;
FREC Jfzktbl[MAXFREC]; FREC Jfzktbl[MAXFREC];
u_char Jheadcode; u_char Jheadcode;
u_char Jheadlen; u_char Jheadlen;
u_char Jgobilen; u_char Jgobilen;
TypeGram Jprevclgrm; TypeGram Jprevclgrm;
TypeCnct Jprevclrow; TypeCnct Jprevclrow;
u_char Jnextcllen; u_char Jnextcllen;
short Jkhcount; short Jkhcount;
short Jnkhcount; short Jnkhcount;
KHREC Jkouhotbl[MaxKouhoNumber]; KHREC Jkouhotbl[MaxKouhoNumber];
STDYIN *Jstdytop; STDYIN *Jstdytop;
DICT *Jcurdict; DICT *Jcurdict;
DICTL *Jdictlist; DICTL *Jdictlist;
u_char *Jdicbuf; u_char *Jdicbuf;
u_char *Jidxbuf; u_char *Jidxbuf;
TypeIdxOfs *Jidxofs; TypeIdxOfs *Jidxofs;
u_char *Jaskknj[MaxKnjAskNumber]; u_char *Jaskknj[MaxKnjAskNumber];
u_char *Jaskknj_k[MaxKnjAskNumber]; u_char *Jaskknj_k[MaxKnjAskNumber];
STDY *Jcurstdy; STDY *Jcurstdy;
u_short Jsuuji_wbuf[NumWordBuf]; u_short Jsuuji_wbuf[NumWordBuf];
u_char Jsuuji_ubuf[NumKetaLength]; u_char Jsuuji_ubuf[NumKetaLength];
TypeClass Jsuuji_class; TypeClass Jsuuji_class;
u_char Jsuuji_comma; u_char Jsuuji_comma;
u_char Jsuuji_keta; u_char Jsuuji_keta;
u_char *Jsuuji_yptr; u_char *Jsuuji_yptr;
u_char Jsuuji_len; u_char Jsuuji_len;
u_char Jsuuji_exit; u_char Jsuuji_exit;
u_short *Jsuuji_wkeep; u_short *Jsuuji_wkeep;
u_char *Jsuuji_ukeep; u_char *Jsuuji_ukeep;
u_char Jpeepyomi[MaxWdYomiLen * 2 + 1]; u_char Jpeepyomi[MaxWdYomiLen * 2 + 1];
u_char Jpeepknj[MaxWdKanjiLen + 1]; u_char Jpeepknj[MaxWdKanjiLen + 1];
TypeGram Jpeepgrm; TypeGram Jpeepgrm;
u_char *Jpeepdptr; u_char *Jpeepdptr;
u_char *Jpeephptr; u_char *Jpeephptr;
u_char *Jpeepkptr; u_char *Jpeepkptr;
TypeDicSeg Jpeepidx; TypeDicSeg Jpeepidx;
} Global; } Global;
typedef struct dictfile {
DICT dict;
int refcnt;
fd_set lock;
FILE *fp;
int fd;
typedef struct dictfile { u_char *buffer;
DICT dict; long bufsiz;
int refcnt;
fd_set lock;
FILE *fp;
int fd;
u_char *buffer; long idxstrt;
long bufsiz; long segstrt;
long idxstrt; TypeIdxOfs *ofsptr;
long segstrt;
TypeIdxOfs *ofsptr; struct dictfile *link;
struct dictfile *link;
} DictFile; } DictFile;
typedef struct stdyfile {
STDY stdy;
int refcnt;
ino_t inode;
FILE *fp;
int fd;
typedef struct stdyfile { u_char *header;
STDY stdy;
int refcnt;
ino_t inode;
FILE *fp;
int fd;
u_char *header; struct stdyfile *link;
struct stdyfile *link;
} StdyFile; } StdyFile;
typedef struct workarea {
int refcnt;
int lock;
typedef struct workarea { struct workarea *link;
int refcnt;
int lock;
struct workarea *link; Global global;
Global global;
} WorkArea; } WorkArea;
typedef struct client {
int fd;
char host[HostNameLen];
char user[UserNameLen];
char prog[ProgNameLen];
typedef struct client { WorkArea *work;
int fd; StdyFile *stdy;
char host[HostNameLen]; short version;
char user[UserNameLen]; u_char def_char[2];
char prog[ProgNameLen]; uid_t uid;
struct client *next;
WorkArea *work;
StdyFile *stdy;
short version;
u_char def_char[2];
#if (defined(TLI) && defined(SOCK_UNIX))
int unix_flag;
#endif
uid_t uid;
struct client *next;
} Client; } Client;
#endif /* _Struct_H_ */ #endif /* SJ3_STRUCT_H_ */