Print this page
5218 posix definition of NULL
correct unistd.h and iso/stddef_iso.h
update gate source affected
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/bnu/gio.c
+++ new/usr/src/cmd/bnu/gio.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 28 /* All Rights Reserved */
29 29
30 30
31 31 #pragma ident "%Z%%M% %I% %E% SMI"
32 32
33 33 #include "uucp.h"
34 34
35 35 #include "pk.h"
36 36
37 37 struct pack *Pk;
38 38 extern int pkread(), pkwrite();
39 39 extern void pkclose();
40 40
41 41 static int grdblk(char *, int);
42 42 static int gwrblk(char *, int);
43 43
44 44 extern int packsize, xpacksize;
45 45
46 46 jmp_buf Getjbuf, Gfailbuf;
47 47
48 48 static void (*gsig)();
49 49
50 50 /* ARGSUSED */
51 51 static void
52 52 galarm(sig)
53 53 int sig;
54 54 {
55 55 signal(SIGALRM, galarm);
56 56 longjmp(Getjbuf, 1);
57 57 }
58 58
59 59 void
60 60 pkfail()
61 61 {
62 62 longjmp(Gfailbuf, 1);
63 63 }
64 64
↓ open down ↓ |
64 lines elided |
↑ open up ↑ |
65 65 int
66 66 gturnon()
67 67 {
68 68 struct pack *pkopen();
69 69 if (setjmp(Gfailbuf))
70 70 return(FAIL);
71 71 gsig=signal(SIGALRM, galarm);
72 72 if (Debug > 4)
73 73 pkdebug = 1;
74 74 Pk = pkopen(Ifn, Ofn);
75 - if ((int) Pk == NULL)
75 + if ( Pk == NULL)
76 76 return(FAIL);
77 77 return(0);
78 78 }
79 79
80 80 int
81 81 gturnoff()
82 82 {
83 83 if(setjmp(Gfailbuf))
84 84 return(FAIL);
85 85 pkclose();
86 86 (void) signal(SIGALRM, gsig);
87 87 return(0);
88 88 }
89 89
90 90 /*ARGSUSED*/
91 91 int
92 92 gwrmsg(type, str, fn)
93 93 char type, *str;
94 94 {
95 95 char bufr[BUFSIZ], *s;
96 96 int len, i;
97 97
98 98 if(setjmp(Gfailbuf))
99 99 return(FAIL);
100 100 bufr[0] = type;
101 101 s = &bufr[1];
102 102 while (*str)
103 103 *s++ = *str++;
104 104 *s = '\0';
105 105 if (*(--s) == '\n')
106 106 *s = '\0';
107 107 len = strlen(bufr) + 1;
108 108 if ((i = len % xpacksize) != 0) {
109 109 len = len + xpacksize - i;
110 110 bufr[len - 1] = '\0';
111 111 }
112 112 gwrblk(bufr, len);
113 113 return(0);
114 114 }
115 115
116 116
117 117 /*ARGSUSED*/
118 118 int
119 119 grdmsg(str, fn)
120 120 char *str;
121 121 {
122 122 unsigned len;
123 123
124 124 if(setjmp(Gfailbuf))
125 125 return(FAIL);
126 126 for (;;) {
127 127 len = pkread(str, packsize);
128 128 if (len == 0)
129 129 continue;
130 130 str += len;
131 131 if (*(str - 1) == '\0')
132 132 break;
133 133 }
134 134 return(0);
135 135 }
136 136
137 137
138 138 /*ARGSUSED*/
139 139 int
140 140 gwrdata(fp1, fn)
141 141 FILE *fp1;
142 142 {
143 143 char bufr[BUFSIZ];
144 144 int fd1;
145 145 int len;
146 146 int ret;
147 147 unsigned long bytes;
148 148
149 149 if(setjmp(Gfailbuf))
150 150 return(FAIL);
151 151 bytes = 0L;
152 152 fd1 = fileno( fp1 );
153 153 while ((len = read( fd1, bufr, BUFSIZ )) > 0) {
154 154 bytes += len;
155 155 putfilesize(bytes);
156 156 ret = gwrblk(bufr, len);
157 157 if (ret != len) {
158 158 return(FAIL);
159 159 }
160 160 if (len != BUFSIZ)
161 161 break;
162 162 }
163 163 ret = gwrblk(bufr, 0);
164 164 return(0);
165 165 }
166 166
167 167 /*ARGSUSED*/
168 168 int
169 169 grddata(fn, fp2)
170 170 FILE *fp2;
171 171 {
172 172 int ret = SUCCESS;
173 173 int fd2;
174 174 int len;
175 175 char bufr[BUFSIZ];
176 176 unsigned long bytes;
177 177
178 178 if(setjmp(Gfailbuf))
179 179 return(FAIL);
180 180 bytes = 0L;
181 181 fd2 = fileno( fp2 );
182 182 for (;;) {
183 183 len = grdblk(bufr, BUFSIZ);
184 184 if (len < 0) {
185 185 return(FAIL);
186 186 }
187 187 bytes += len;
188 188 putfilesize(bytes);
189 189 if ( ret == SUCCESS && write( fd2, bufr, len ) != len) {
190 190 ret = errno;
191 191 DEBUG(7, "grddata: write to file failed, errno %d\n", errno);
192 192 }
193 193 if (len < BUFSIZ)
194 194 break;
195 195 }
196 196 return(ret);
197 197 }
198 198
199 199
200 200 static
201 201 int
202 202 grdblk(blk, len)
203 203 char *blk;
204 204 {
205 205 int i, ret;
206 206
207 207 for (i = 0; i < len; i += ret) {
208 208 ret = pkread(blk, len - i);
209 209 if (ret < 0)
210 210 return(FAIL);
211 211 blk += ret;
212 212 if (ret == 0)
213 213 return(i);
214 214 }
215 215 return(i);
216 216 }
217 217
218 218
219 219 static int
220 220 gwrblk(blk, len)
221 221 char *blk;
222 222 {
223 223 return(pkwrite(blk, len));
224 224 }
↓ open down ↓ |
139 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX