285 register int i, ret;
286 static int n_writ, got_info;
287 static struct t_info info;
288
289 if (got_info == 0) {
290 if (t_getinfo(fd, &info) != 0) {
291 tfaillog(fd, "twrite: t_getinfo\n");
292 return (FAIL);
293 }
294 got_info = 1;
295 }
296
297 /* on every N_CHECKth call, check that are still in DATAXFER state */
298 if (++n_writ == N_CHECK) {
299 n_writ = 0;
300 if (t_getstate(fd) != T_DATAXFER)
301 return (FAIL);
302 }
303
304 if (info.tsdu <= 0 || nbytes <= info.tsdu)
305 return (t_snd(fd, buf, nbytes, NULL));
306
307 /* if get here, then there is a limit on transmit size */
308 /* (info.tsdu > 0) and buf exceeds it */
309 i = ret = 0;
310 while (nbytes >= info.tsdu) {
311 if ((ret = t_snd(fd, &buf[i], info.tsdu, NULL)) != info.tsdu)
312 return ((ret >= 0 ? (i + ret) : ret));
313 i += info.tsdu;
314 nbytes -= info.tsdu;
315 }
316 if (nbytes != 0) {
317 if ((ret = t_snd(fd, &buf[i], nbytes, NULL)) != nbytes)
318 return ((ssize_t)(ret >= 0 ? (i + ret) : ret));
319 i += nbytes;
320 }
321 return ((ssize_t)i);
322 }
323
324
325 /*
326 * tioctl - stub for tli ioctl routine
327 */
328 /*ARGSUSED*/
329 static int
330 #ifdef __STDC__
331 tioctl(int fd, int request, ...)
332 #else
333 tioctl(fd, request, arg)
334 int fd, request;
335 #endif
336 {
337 return (SUCCESS);
|
285 register int i, ret;
286 static int n_writ, got_info;
287 static struct t_info info;
288
289 if (got_info == 0) {
290 if (t_getinfo(fd, &info) != 0) {
291 tfaillog(fd, "twrite: t_getinfo\n");
292 return (FAIL);
293 }
294 got_info = 1;
295 }
296
297 /* on every N_CHECKth call, check that are still in DATAXFER state */
298 if (++n_writ == N_CHECK) {
299 n_writ = 0;
300 if (t_getstate(fd) != T_DATAXFER)
301 return (FAIL);
302 }
303
304 if (info.tsdu <= 0 || nbytes <= info.tsdu)
305 return (t_snd(fd, buf, nbytes, 0));
306
307 /* if get here, then there is a limit on transmit size */
308 /* (info.tsdu > 0) and buf exceeds it */
309 i = ret = 0;
310 while (nbytes >= info.tsdu) {
311 if ((ret = t_snd(fd, &buf[i], info.tsdu, 0)) != info.tsdu)
312 return ((ret >= 0 ? (i + ret) : ret));
313 i += info.tsdu;
314 nbytes -= info.tsdu;
315 }
316 if (nbytes != 0) {
317 if ((ret = t_snd(fd, &buf[i], nbytes, 0)) != nbytes)
318 return ((ssize_t)(ret >= 0 ? (i + ret) : ret));
319 i += nbytes;
320 }
321 return ((ssize_t)i);
322 }
323
324
325 /*
326 * tioctl - stub for tli ioctl routine
327 */
328 /*ARGSUSED*/
329 static int
330 #ifdef __STDC__
331 tioctl(int fd, int request, ...)
332 #else
333 tioctl(fd, request, arg)
334 int fd, request;
335 #endif
336 {
337 return (SUCCESS);
|