003 File Manager
Current Path:
/usr/src/contrib/sendmail/libsm
usr
/
src
/
contrib
/
sendmail
/
libsm
/
📁
..
📄
Makefile
(346 B)
📄
Makefile.m4
(1.92 KB)
📄
README
(4.42 KB)
📄
assert.c
(4.13 KB)
📄
assert.html
(13.86 KB)
📄
b-strcmp.c
(3.4 KB)
📄
b-strl.c
(5 KB)
📄
cdefs.html
(2.39 KB)
📄
cf.c
(1.97 KB)
📄
clock.c
(13.89 KB)
📄
clrerr.c
(872 B)
📄
config.c
(4.47 KB)
📄
debug.c
(8.91 KB)
📄
debug.html
(7.68 KB)
📄
errstring.c
(6.03 KB)
📄
exc.c
(13.05 KB)
📄
exc.html
(23.27 KB)
📄
fclose.c
(3.13 KB)
📄
feof.c
(961 B)
📄
ferror.c
(932 B)
📄
fflush.c
(3.1 KB)
📄
fget.c
(2.37 KB)
📄
findfp.c
(10.65 KB)
📄
flags.c
(1.27 KB)
📄
fopen.c
(8.3 KB)
📄
fpos.c
(3.12 KB)
📄
fprintf.c
(1.35 KB)
📄
fpurge.c
(1.15 KB)
📄
fput.c
(1.25 KB)
📄
fread.c
(2.28 KB)
📄
fscanf.c
(1.34 KB)
📄
fseek.c
(7.25 KB)
📄
fvwrite.c
(6.24 KB)
📄
fvwrite.h
(740 B)
📄
fwalk.c
(1.41 KB)
📄
fwrite.c
(1.54 KB)
📄
gen.html
(910 B)
📄
get.c
(1.12 KB)
📄
glue.h
(731 B)
📄
heap.c
(17.29 KB)
📄
heap.html
(13.07 KB)
📄
index.html
(5.95 KB)
📄
inet6_ntop.c
(1.1 KB)
📄
io.html
(26.6 KB)
📄
ldap.c
(35.72 KB)
📄
local.h
(9.42 KB)
📄
makebuf.c
(3.36 KB)
📄
match.c
(2.77 KB)
📄
mbdb.c
(16.61 KB)
📄
memstat.c
(5.13 KB)
📄
mpeix.c
(13.84 KB)
📄
niprop.c
(4.64 KB)
📄
notify.c
(3.32 KB)
📄
put.c
(1.61 KB)
📄
refill.c
(7.09 KB)
📄
rewind.c
(1.08 KB)
📄
rpool.c
(11.54 KB)
📄
rpool.html
(6.08 KB)
📄
sem.c
(4.41 KB)
📄
setvbuf.c
(4.2 KB)
📄
shm.c
(2.62 KB)
📄
signal.c
(6.75 KB)
📄
smstdio.c
(6.14 KB)
📄
snprintf.c
(2.29 KB)
📄
sscanf.c
(2.26 KB)
📄
stdio.c
(9.7 KB)
📄
strcasecmp.c
(3.14 KB)
📄
strdup.c
(2.79 KB)
📄
strerror.c
(1.27 KB)
📄
strexit.c
(2.76 KB)
📄
string.c
(1.29 KB)
📄
stringf.c
(1.77 KB)
📄
strio.c
(9.18 KB)
📄
strl.c
(7.52 KB)
📄
strrevcmp.c
(1.61 KB)
📄
strto.c
(5.45 KB)
📄
syslogio.c
(4.11 KB)
📄
t-cf.c
(934 B)
📄
t-event.c
(1.79 KB)
📄
t-exc.c
(2.75 KB)
📄
t-fget.c
(1.71 KB)
📄
t-float.c
(1.78 KB)
📄
t-fopen.c
(875 B)
📄
t-heap.c
(1.3 KB)
📄
t-inet6_ntop.c
(1.4 KB)
📄
t-match.c
(1.1 KB)
📄
t-memstat.c
(2.17 KB)
📄
t-notify.c
(1.81 KB)
📄
t-path.c
(742 B)
📄
t-qic.c
(5.43 KB)
📄
t-rpool.c
(1.5 KB)
📄
t-scanf.c
(1.38 KB)
📄
t-sem.c
(5.85 KB)
📄
t-shm.c
(4.42 KB)
📄
t-smstdio.c
(1.55 KB)
📄
t-string.c
(968 B)
📄
t-strio.c
(775 B)
📄
t-strl.c
(3.53 KB)
📄
t-strrevcmp.c
(994 B)
📄
t-types.c
(2.7 KB)
📄
test.c
(2.73 KB)
📄
ungetc.c
(3.93 KB)
📄
util.c
(4.46 KB)
📄
vasprintf.c
(2.91 KB)
📄
vfprintf.c
(24.09 KB)
📄
vfscanf.c
(18.76 KB)
📄
vprintf.c
(999 B)
📄
vsnprintf.c
(1.87 KB)
📄
wbuf.c
(2.51 KB)
📄
wsetup.c
(1.88 KB)
📄
xtrap.c
(653 B)
Editing: fvwrite.c
/* * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers. * All rights reserved. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * By using this file, you agree to the terms and conditions set * forth in the LICENSE file which can be found at the top level of * the sendmail distribution. */ #include <sm/gen.h> SM_RCSID("@(#)$Id: fvwrite.c,v 1.50 2013-11-22 20:51:42 ca Exp $") #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <signal.h> #include <fcntl.h> #include <sm/io.h> #include <sm/setjmp.h> #include <sm/conf.h> #include "local.h" #include "fvwrite.h" /* ** SM_FVWRITE -- write memory regions and buffer for file pointer ** ** Parameters: ** fp -- the file pointer to write to ** timeout -- time length for function to return by ** uio -- the memory regions to write ** ** Returns: ** Failure: returns SM_IO_EOF and sets errno ** Success: returns 0 (zero) ** ** This routine is large and unsightly, but most of the ugliness due ** to the different kinds of output buffering handled here. */ #define COPY(n) (void)memcpy((void *)fp->f_p, (void *)p, (size_t)(n)) #define GETIOV(extra_work) \ while (len == 0) \ { \ extra_work; \ p = iov->iov_base; \ len = iov->iov_len; \ iov++; \ } int sm_fvwrite(fp, timeout, uio) register SM_FILE_T *fp; int timeout; register struct sm_uio *uio; { register size_t len; register char *p; register struct sm_iov *iov; register int w, s; char *nl; int nlknown, nldist; int fd; struct timeval to; if (uio->uio_resid == 0) return 0; /* make sure we can write */ if (cantwrite(fp)) { errno = EBADF; return SM_IO_EOF; } SM_CONVERT_TIME(fp, fd, timeout, &to); iov = uio->uio_iov; p = iov->iov_base; len = iov->iov_len; iov++; if (fp->f_flags & SMNBF) { /* Unbuffered: write up to BUFSIZ bytes at a time. */ do { GETIOV(;); errno = 0; /* needed to ensure EOF correctly found */ w = (*fp->f_write)(fp, p, SM_MIN(len, SM_IO_BUFSIZ)); if (w <= 0) { if (w == 0 && errno == 0) break; /* EOF found */ if (IS_IO_ERROR(fd, w, timeout)) goto err; /* errno set */ /* write would block */ SM_IO_WR_TIMEOUT(fp, fd, timeout); w = 0; } else { p += w; len -= w; } } while ((uio->uio_resid -= w) != 0); } else if ((fp->f_flags & SMLBF) == 0) { /* ** Not SMLBF (line-buffered). Either SMFBF or SMNOW ** buffered: fill partially full buffer, if any, ** and then flush. If there is no partial buffer, write ** one bf._size byte chunk directly (without copying). ** ** String output is a special case: write as many bytes ** as fit, but pretend we wrote everything. This makes ** snprintf() return the number of bytes needed, rather ** than the number used, and avoids its write function ** (so that the write function can be invalid). */ do { GETIOV(;); if ((((fp->f_flags & (SMALC | SMSTR)) == (SMALC | SMSTR)) || ((fp->f_flags & SMNOW) != 0)) && (size_t) fp->f_w < len) { size_t blen = fp->f_p - fp->f_bf.smb_base; unsigned char *tbase; int tsize; /* Allocate space exponentially. */ tsize = fp->f_bf.smb_size; do { tsize = (tsize << 1) + 1; } while ((size_t) tsize < blen + len); tbase = (unsigned char *) sm_realloc(fp->f_bf.smb_base, tsize + 1); if (tbase == NULL) { errno = ENOMEM; goto err; /* errno set */ } fp->f_w += tsize - fp->f_bf.smb_size; fp->f_bf.smb_base = tbase; fp->f_bf.smb_size = tsize; fp->f_p = tbase + blen; } w = fp->f_w; errno = 0; /* needed to ensure EOF correctly found */ if (fp->f_flags & SMSTR) { if (len < (size_t) w) w = len; COPY(w); /* copy SM_MIN(fp->f_w,len), */ fp->f_w -= w; fp->f_p += w; w = len; /* but pretend copied all */ } else if (fp->f_p > fp->f_bf.smb_base && len > (size_t) w) { /* fill and flush */ COPY(w); fp->f_p += w; if (sm_flush(fp, &timeout)) goto err; /* errno set */ } else if (len >= (size_t) (w = fp->f_bf.smb_size)) { /* write directly */ w = (*fp->f_write)(fp, p, w); if (w <= 0) { if (w == 0 && errno == 0) break; /* EOF found */ if (IS_IO_ERROR(fd, w, timeout)) goto err; /* errno set */ /* write would block */ SM_IO_WR_TIMEOUT(fp, fd, timeout); w = 0; } } else { /* fill and done */ w = len; COPY(w); fp->f_w -= w; fp->f_p += w; } p += w; len -= w; } while ((uio->uio_resid -= w) != 0); if ((fp->f_flags & SMNOW) != 0 && sm_flush(fp, &timeout)) goto err; /* errno set */ } else { /* ** Line buffered: like fully buffered, but we ** must check for newlines. Compute the distance ** to the first newline (including the newline), ** or `infinity' if there is none, then pretend ** that the amount to write is SM_MIN(len,nldist). */ nlknown = 0; nldist = 0; /* XXX just to keep gcc happy */ do { GETIOV(nlknown = 0); if (!nlknown) { nl = memchr((void *)p, '\n', len); nldist = nl != NULL ? nl + 1 - p : len + 1; nlknown = 1; } s = SM_MIN(len, ((size_t) nldist)); w = fp->f_w + fp->f_bf.smb_size; errno = 0; /* needed to ensure EOF correctly found */ if (fp->f_p > fp->f_bf.smb_base && s > w) { COPY(w); /* fp->f_w -= w; */ fp->f_p += w; if (sm_flush(fp, &timeout)) goto err; /* errno set */ } else if (s >= (w = fp->f_bf.smb_size)) { w = (*fp->f_write)(fp, p, w); if (w <= 0) { if (w == 0 && errno == 0) break; /* EOF found */ if (IS_IO_ERROR(fd, w, timeout)) goto err; /* errno set */ /* write would block */ SM_IO_WR_TIMEOUT(fp, fd, timeout); w = 0; } } else { w = s; COPY(w); fp->f_w -= w; fp->f_p += w; } if ((nldist -= w) == 0) { /* copied the newline: flush and forget */ if (sm_flush(fp, &timeout)) goto err; /* errno set */ nlknown = 0; } p += w; len -= w; } while ((uio->uio_resid -= w) != 0); } return 0; err: /* errno set before goto places us here */ fp->f_flags |= SMERR; return SM_IO_EOF; }
Upload File
Create Folder