From b2ee9feb0c6006af651a428555e7fcc52fa38761 Mon Sep 17 00:00:00 2001 From: Masanori Ogino Date: Thu, 30 Nov 2023 05:56:57 +0900 Subject: [PATCH] sj3lib: Add function prototypes to string.c Signed-off-by: Masanori Ogino --- sj3lib/sj.c | 1 + sj3lib/sj_string.h | 47 ++++++++++++++++++++++++++++++++++++++++ sj3lib/string.c | 53 ++++++++++++++-------------------------------- 3 files changed, 64 insertions(+), 37 deletions(-) create mode 100644 sj3lib/sj_string.h diff --git a/sj3lib/sj.c b/sj3lib/sj.c index e951889..bad4718 100644 --- a/sj3lib/sj.c +++ b/sj3lib/sj.c @@ -45,6 +45,7 @@ #include "sj3lib.h" #include "sj_const.h" #include "sj_hinsi.h" +#include "sj_string.h" extern int sj3_error_number; #define SYS_SJIS 0 diff --git a/sj3lib/sj_string.h b/sj3lib/sj_string.h new file mode 100644 index 0000000..0f07192 --- /dev/null +++ b/sj3lib/sj_string.h @@ -0,0 +1,47 @@ +/*- + * 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. + */ + +#ifndef SJ3_SJ_STRING_H_ +#define SJ3_SJ_STRING_H_ + +int sj3_str_sjistoeuc(unsigned char *, int, unsigned char *, unsigned char *, int *); +int sj3_str_euctosjis(unsigned char *, int, unsigned char *, unsigned char *, int *); + +int sj3_sjistoeuclen(unsigned char *, int); + +int sj3_sjistoeuc(unsigned char *, int, unsigned char *, int); +int sj3_euctosjis(unsigned char *, int, unsigned char *, int); + +void sj_euc2sjis (unsigned char *); +void sj_jis2sjis (unsigned char *); +void sj_sjis2euc (unsigned char *); +void sj_sjis2jis (unsigned char *); + +unsigned short sj3_jis2sjis(unsigned short); +unsigned short sj3_jis2euc(unsigned short); +unsigned short sj3_sjis2jis(unsigned short); +unsigned short sj3_euc2sjis(unsigned short); +unsigned short sj3_sjis2euc(unsigned short); + +#endif diff --git a/sj3lib/string.c b/sj3lib/string.c index 458d7e1..a61fa11 100644 --- a/sj3lib/string.c +++ b/sj3lib/string.c @@ -35,6 +35,8 @@ #include "sj_euc.h" +#include "sj_string.h" + #ifndef TRUE #define TRUE (1) #define FALSE (0) @@ -48,14 +50,8 @@ #define iseuc(c) ((0xa1 <= (c)) && ((c) <= 0xfe)) #define iskana(c) ((0xa1 <= (c)) && ((c) <= 0xdf)) -unsigned short sjis2euc(), euc2sjis(); - -void sj_sjis2jis(), sj_jis2sjis(); - int -sj3_str_sjistoeuc(out, outlen, in, sjis_default, useflag) -unsigned char *out, *in, *sjis_default; -int outlen, *useflag; +sj3_str_sjistoeuc(unsigned char *out, int outlen, unsigned char *in, unsigned char *sjis_default, int *useflag) { unsigned char *sjis = in, *euc = out; int n = 0; @@ -99,9 +95,7 @@ int outlen, *useflag; int -sj3_str_euctosjis(out, outlen, in, sjis_default, useflag) -unsigned char *out, *in, *sjis_default; -int outlen, *useflag; +sj3_str_euctosjis(unsigned char *out, int outlen, unsigned char *in, unsigned char *sjis_default, int *useflag) { unsigned char *euc = in, *sjis = out; int n = 0; @@ -146,9 +140,7 @@ int outlen, *useflag; } int -sj3_sjistoeuclen(str, max) -unsigned char *str; -int max; +sj3_sjistoeuclen(unsigned char *str, int max) { register int len = 0, bytes = 1; @@ -176,9 +168,7 @@ int max; static unsigned char def_char[] = {0x81, 0x40}; int -sj3_sjistoeuc(e, elen, s, slen) -unsigned char *s, *e; -int slen, elen; +sj3_sjistoeuc(unsigned char *e, int elen, unsigned char *s, int slen) { int dummy; @@ -186,9 +176,7 @@ int slen, elen; } int -sj3_euctosjis(s, slen, e, elen) -unsigned char *s, *e; -int slen, elen; +sj3_euctosjis(unsigned char *s, int slen, unsigned char *e, int elen) { int dummy; @@ -196,8 +184,7 @@ int slen, elen; } void -sj_euc2sjis (s) -unsigned char *s; +sj_euc2sjis (unsigned char *s) { s[0] &= MASK; s[1] &= MASK; @@ -205,8 +192,7 @@ unsigned char *s; } void -sj_jis2sjis (s) -unsigned char *s; +sj_jis2sjis (unsigned char *s) { register int high, low; register int nh, nl; @@ -228,8 +214,7 @@ unsigned char *s; } void -sj_sjis2euc (s) -unsigned char *s; +sj_sjis2euc (unsigned char *s) { sj_sjis2jis (s); s[0] |= MSB; @@ -237,8 +222,7 @@ unsigned char *s; } void -sj_sjis2jis (s) -unsigned char *s; +sj_sjis2jis (unsigned char *s) { register int byte1, byte2; register unsigned char *sp; @@ -265,8 +249,7 @@ unsigned char *s; } unsigned short -sj3_jis2sjis(code) -unsigned short code; +sj3_jis2sjis(unsigned short code) { unsigned char tmp[3]; @@ -282,8 +265,7 @@ unsigned short code; } unsigned short -sj3_jis2euc(code) -unsigned short code; +sj3_jis2euc(unsigned short code) { unsigned char tmp[3]; @@ -297,8 +279,7 @@ unsigned short code; } unsigned short -sj3_sjis2jis(code) -unsigned short code; +sj3_sjis2jis(unsigned short code) { unsigned char tmp[3]; @@ -314,8 +295,7 @@ unsigned short code; } unsigned short -sj3_euc2sjis(code) -unsigned short code; +sj3_euc2sjis(unsigned short code) { unsigned char tmp[3]; @@ -331,8 +311,7 @@ unsigned short code; } unsigned short -sj3_sjis2euc(code) -unsigned short code; +sj3_sjis2euc(unsigned short code) { unsigned char tmp[3];