Mercurial > freewnn
comparison Wnn/jserver/snd_rcv.c @ 0:bbc77ca4def5
initial import
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 13 Dec 2007 04:30:14 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bbc77ca4def5 |
---|---|
1 /* | |
2 * $Id: snd_rcv.c,v 1.4 2003/05/11 18:43:16 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, 2003 | |
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 #include <stdio.h> | |
33 #include "de_header.h" | |
34 | |
35 static int fmode; | |
36 /* JS_FILE_SEND (server receives) */ | |
37 int | |
38 fopen_read_cur (fn) | |
39 char *fn; | |
40 { | |
41 fmode = 'r'; | |
42 return 1; | |
43 } | |
44 | |
45 /* JS_FILE_RECEIVE (server sends) */ | |
46 int | |
47 fopen_write_cur (fn) | |
48 char *fn; | |
49 { | |
50 fmode = 'w'; | |
51 return 1; | |
52 } | |
53 | |
54 /* JS_FILE_SEND (server recieves) */ | |
55 int | |
56 fread_cur (p, size, nitems) | |
57 char *p; | |
58 register int size, nitems; | |
59 { | |
60 register int i, j, xx; | |
61 for (i = 0; i < nitems; i++) | |
62 { | |
63 for (j = 0; j < size; j++) | |
64 { | |
65 *p++ = xx = xgetc_cur (); | |
66 if (xx == -1) | |
67 return i; | |
68 } | |
69 } | |
70 return nitems; | |
71 } | |
72 | |
73 static int store = -1; | |
74 | |
75 int | |
76 xgetc_cur () | |
77 { | |
78 register int x; | |
79 if (store != -1) | |
80 { | |
81 x = store; | |
82 store = -1; | |
83 return (x); | |
84 } | |
85 if ((x = getc_cur ()) != 0xFF) | |
86 return x; | |
87 if (getc_cur () == 0xFF) | |
88 return -1; /* EOF */ | |
89 return 0xFF; | |
90 } | |
91 | |
92 void | |
93 xungetc_cur (x) /* H.T. */ | |
94 int x; | |
95 { | |
96 store = x; | |
97 } | |
98 | |
99 /* JS_FILE_SRECEIVE (server sends) */ | |
100 void | |
101 fwrite_cur (p, size, nitems) | |
102 unsigned char *p; | |
103 int size, nitems; | |
104 { | |
105 register int i, x; | |
106 x = size * nitems; | |
107 for (i = 0; i < x; i++) | |
108 { | |
109 xputc_cur (*p++); | |
110 } | |
111 } | |
112 | |
113 void | |
114 xputc_cur (x) | |
115 unsigned char x; /* H.T. */ | |
116 { | |
117 putc_cur (x); | |
118 if (x == 0xFF) | |
119 { | |
120 putc_cur (0x00); | |
121 } | |
122 } | |
123 | |
124 void | |
125 fclose_cur () | |
126 { | |
127 if (fmode != 'w') | |
128 return; | |
129 putc_cur (0xFF); | |
130 putc_cur (0xFF); /* EOF */ | |
131 } |