0
|
1 /*
|
|
2 * $Id: sstrings.c,v 1.4 2002/07/14 04:26:57 hiroo Exp $
|
|
3 */
|
|
4
|
|
5 /*
|
|
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
|
|
7 * This file is part of FreeWnn.
|
|
8 *
|
|
9 * Copyright Kyoto University Research Institute for Mathematical Sciences
|
|
10 * 1987, 1988, 1989, 1990, 1991, 1992
|
|
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
|
|
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
|
|
13 * Copyright FreeWnn Project 1999, 2000, 2002
|
|
14 *
|
|
15 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp>
|
|
16 *
|
|
17 * This program is free software; you can redistribute it and/or modify
|
|
18 * it under the terms of the GNU General Public License as published by
|
|
19 * the Free Software Foundation; either version 2 of the License, or
|
|
20 * (at your option) any later version.
|
|
21 *
|
|
22 * This program is distributed in the hope that it will be useful,
|
|
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25 * GNU General Public License for more details.
|
|
26 *
|
|
27 * You should have received a copy of the GNU General Public License
|
|
28 * along with this program; if not, write to the Free Software
|
|
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
30 */
|
|
31
|
|
32 #ifdef HAVE_CONFIG_H
|
|
33 # include <config.h>
|
|
34 #endif
|
|
35
|
|
36 #include "commonhd.h"
|
|
37 #include <stdio.h>
|
|
38 #if STDC_HEADERS
|
|
39 # include <string.h>
|
|
40 #else
|
|
41 # if HAVE_STRINGS_H
|
|
42 # include <strings.h>
|
|
43 # endif
|
|
44 #endif /* STDC_HEADERS */
|
|
45 #include "wnn_os.h"
|
|
46 #include "wnn_string.h"
|
|
47
|
|
48 extern int eeuc_to_ieuc ();
|
|
49 extern int ieuc_to_eeuc ();
|
|
50
|
|
51 int
|
|
52 wnn_sStrcpy (c, w)
|
|
53 register char *c;
|
|
54 register w_char *w;
|
|
55 {
|
|
56 register int ret;
|
|
57
|
|
58 ret = ieuc_to_eeuc (c, w, -1);
|
|
59 c[ret] = '\0';
|
|
60 return (ret);
|
|
61 }
|
|
62
|
|
63
|
|
64 int
|
|
65 wnn_Sstrcpy (w, c)
|
|
66 w_char *w;
|
|
67 unsigned char *c;
|
|
68 {
|
|
69 register int ret;
|
|
70
|
|
71 ret = eeuc_to_ieuc (w, c, -1) / sizeof (w_char);
|
|
72 w[ret] = (w_char) 0;
|
|
73 return (ret);
|
|
74 }
|
|
75
|
|
76 #ifdef nodef
|
|
77 char *
|
|
78 wnn_Stos (c)
|
|
79 w_char *c;
|
|
80 {
|
|
81 char *c1 = (char *) c;
|
|
82 for (; *c; c++)
|
|
83 {
|
|
84 if (ASCIIP (*c))
|
|
85 {
|
|
86 *c1++ = *c;
|
|
87 }
|
|
88 else
|
|
89 {
|
|
90 *c1++ = (*c << 8);
|
|
91 *c1++ = *c;
|
|
92 }
|
|
93 }
|
|
94 return ((char *) c);
|
|
95 }
|
|
96 #endif
|
|
97
|
|
98 char *
|
|
99 wnn_sStrncpy (s1, s2, n)
|
|
100 register char *s1;
|
|
101 register w_char *s2;
|
|
102 register int n;
|
|
103 {
|
|
104 eeuc_to_ieuc (s1, s2, n / sizeof (w_char));
|
|
105 return s1;
|
|
106 }
|
|
107
|
|
108 #ifdef CHINESE
|
|
109 int
|
|
110 wnn_Sstrcat (w, c)
|
|
111 w_char *w;
|
|
112 unsigned char *c;
|
|
113 {
|
|
114 w_char *w0 = w;
|
|
115 register int ret;
|
|
116
|
|
117 if (!c || !*c)
|
|
118 return (0);
|
|
119 for (; *w; w++);
|
|
120 ret = eeuc_to_ieuc (w, c, strlen (c)) / sizeof (w_char);
|
|
121 w[ret] = (w_char) 0;
|
|
122 ret += (w - w0);
|
|
123 return (ret);
|
|
124 }
|
|
125 #endif
|