Deleted Added
full compact
stdio.c (98121) stdio.c (110560)
1/*
2 * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Chris Torek.
9 *
10 * By using this file, you agree to the terms and conditions set
11 * forth in the LICENSE file which can be found at the top level of
12 * the sendmail distribution.
13 */
14
15#include <sm/gen.h>
1/*
2 * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Chris Torek.
9 *
10 * By using this file, you agree to the terms and conditions set
11 * forth in the LICENSE file which can be found at the top level of
12 * the sendmail distribution.
13 */
14
15#include <sm/gen.h>
16SM_RCSID("@(#)$Id: stdio.c,v 1.56 2002/04/03 21:55:15 ca Exp $")
16SM_RCSID("@(#)$Id: stdio.c,v 1.56.2.3 2002/10/22 23:07:19 ca Exp $")
17#include <unistd.h>
18#include <errno.h>
19#include <fcntl.h>
20#include <string.h> /* FreeBSD: FD_ZERO needs <string.h> */
21#include <sys/stat.h>
22#include <sys/time.h>
23#include <sm/heap.h>
24#include <sm/assert.h>
25#include <sm/varargs.h>
26#include <sm/io.h>
17#include <unistd.h>
18#include <errno.h>
19#include <fcntl.h>
20#include <string.h> /* FreeBSD: FD_ZERO needs <string.h> */
21#include <sys/stat.h>
22#include <sys/time.h>
23#include <sm/heap.h>
24#include <sm/assert.h>
25#include <sm/varargs.h>
26#include <sm/io.h>
27#include <sm/fdset.h>
28#include <sm/setjmp.h>
29#include <sm/conf.h>
27#include <sm/setjmp.h>
28#include <sm/conf.h>
29#include <sm/fdset.h>
30#include "local.h"
31
32/*
33** Overall:
34** Small standard I/O/seek/close functions.
35** These maintain the `known seek offset' for seek optimization.
36*/
37

--- 310 unchanged lines hidden (view full) ---

348 return -1;
349 }
350
351 case SM_IO_IS_READABLE:
352 {
353 fd_set readfds;
354 struct timeval timeout;
355
30#include "local.h"
31
32/*
33** Overall:
34** Small standard I/O/seek/close functions.
35** These maintain the `known seek offset' for seek optimization.
36*/
37

--- 310 unchanged lines hidden (view full) ---

348 return -1;
349 }
350
351 case SM_IO_IS_READABLE:
352 {
353 fd_set readfds;
354 struct timeval timeout;
355
356 if (SM_FD_SETSIZE > 0 && fp->f_file >= SM_FD_SETSIZE)
357 {
358 errno = EINVAL;
359 return -1;
360 }
356 FD_ZERO(&readfds);
357 SM_FD_SET(fp->f_file, &readfds);
358 timeout.tv_sec = 0;
359 timeout.tv_usec = 0;
360 if (select(fp->f_file + 1, FDSET_CAST &readfds,
361 NULL, NULL, &timeout) > 0 &&
362 SM_FD_ISSET(fp->f_file, &readfds))
363 return 1;

--- 53 unchanged lines hidden (view full) ---

417 default:
418 errno = EINVAL;
419 return -1;
420 }
421
422 /* Make sure the mode the user wants is a subset of the actual mode. */
423 if ((fdflags = fcntl(fd, F_GETFL, 0)) < 0)
424 return -1;
361 FD_ZERO(&readfds);
362 SM_FD_SET(fp->f_file, &readfds);
363 timeout.tv_sec = 0;
364 timeout.tv_usec = 0;
365 if (select(fp->f_file + 1, FDSET_CAST &readfds,
366 NULL, NULL, &timeout) > 0 &&
367 SM_FD_ISSET(fp->f_file, &readfds))
368 return 1;

--- 53 unchanged lines hidden (view full) ---

422 default:
423 errno = EINVAL;
424 return -1;
425 }
426
427 /* Make sure the mode the user wants is a subset of the actual mode. */
428 if ((fdflags = fcntl(fd, F_GETFL, 0)) < 0)
429 return -1;
425
426 tmp = fdflags & O_ACCMODE;
427 if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE)))
428 {
429 errno = EINVAL;
430 return -1;
431 }
432 fp->f_file = fd;
433 if (oflags & O_APPEND)

--- 71 unchanged lines hidden ---
430 tmp = fdflags & O_ACCMODE;
431 if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE)))
432 {
433 errno = EINVAL;
434 return -1;
435 }
436 fp->f_file = fd;
437 if (oflags & O_APPEND)

--- 71 unchanged lines hidden ---