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: smstdio.c
/* * Copyright (c) 2000-2002, 2004 Proofpoint, Inc. and its suppliers. * All rights reserved. * * 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_IDSTR(id, "@(#)$Id: smstdio.c,v 1.35 2013-11-22 20:51:43 ca Exp $") #include <unistd.h> #include <stdio.h> #include <fcntl.h> #include <errno.h> #include <sys/stat.h> #include <sm/assert.h> #include <sm/io.h> #include <sm/string.h> #include "local.h" static void setup __P((SM_FILE_T *)); /* ** Overall: ** This is a file type which implements a layer on top of the system ** stdio. fp->f_cookie is the FILE* of stdio. The cookie may be ** "bound late" because of the manner which Linux implements stdio. ** When binding late (when fp->f_cookie==NULL) then the value of ** fp->f_ival is used (0, 1 or 2) to map to stdio's stdin, stdout or ** stderr. */ /* ** SM_STDIOOPEN -- open a file to system stdio implementation ** ** Parameters: ** fp -- file pointer assign for this open ** info -- info about file to open ** flags -- indicating method of opening ** rpool -- ignored ** ** Returns: ** Failure: -1 ** Success: 0 (zero) */ /* ARGSUSED3 */ int sm_stdioopen(fp, info, flags, rpool) SM_FILE_T *fp; const void *info; int flags; const void *rpool; { register FILE *s; char *stdiomode; switch (flags) { case SM_IO_RDONLY: stdiomode = "r"; break; case SM_IO_WRONLY: stdiomode = "w"; break; case SM_IO_APPEND: stdiomode = "a"; break; case SM_IO_APPENDRW: stdiomode = "a+"; break; #if SM_IO_BINARY != 0 case SM_IO_RDONLY_B: stdiomode = "rb"; break; case SM_IO_WRONLY_B: stdiomode = "wb"; break; case SM_IO_APPEND_B: stdiomode = "ab"; break; case SM_IO_APPENDRW_B: stdiomode = "a+b"; break; case SM_IO_RDWR_B: stdiomode = "r+b"; break; #endif /* SM_IO_BINARY != 0 */ case SM_IO_RDWR: default: stdiomode = "r+"; break; } if ((s = fopen((char *)info, stdiomode)) == NULL) return -1; fp->f_cookie = s; return 0; } /* ** SETUP -- assign file type cookie when not already assigned ** ** Parameters: ** fp - the file pointer to get the cookie assigned ** ** Return: ** none. */ static void setup(fp) SM_FILE_T *fp; { if (fp->f_cookie == NULL) { switch (fp->f_ival) { case 0: fp->f_cookie = stdin; break; case 1: fp->f_cookie = stdout; break; case 2: fp->f_cookie = stderr; break; default: sm_abort("fp->f_ival=%d: out of range (0...2)", fp->f_ival); break; } } } /* ** SM_STDIOREAD -- read from the file ** ** Parameters: ** fp -- the file pointer ** buf -- location to place the read data ** n - number of bytes to read ** ** Returns: ** result from fread(). */ ssize_t sm_stdioread(fp, buf, n) SM_FILE_T *fp; char *buf; size_t n; { register FILE *s; if (fp->f_cookie == NULL) setup(fp); s = fp->f_cookie; return fread(buf, 1, n, s); } /* ** SM_STDIOWRITE -- write to the file ** ** Parameters: ** fp -- the file pointer ** buf -- location of data to write ** n - number of bytes to write ** ** Returns: ** result from fwrite(). */ ssize_t sm_stdiowrite(fp, buf, n) SM_FILE_T *fp; char const *buf; size_t n; { register FILE *s; if (fp->f_cookie == NULL) setup(fp); s = fp->f_cookie; return fwrite(buf, 1, n, s); } /* ** SM_STDIOSEEK -- set position within file ** ** Parameters: ** fp -- the file pointer ** offset -- new location based on 'whence' ** whence -- indicates "base" for 'offset' ** ** Returns: ** result from fseek(). */ off_t sm_stdioseek(fp, offset, whence) SM_FILE_T *fp; off_t offset; int whence; { register FILE *s; if (fp->f_cookie == NULL) setup(fp); s = fp->f_cookie; return fseek(s, offset, whence); } /* ** SM_STDIOCLOSE -- close the file ** ** Parameters: ** fp -- close file pointer ** ** Return: ** status from fclose() */ int sm_stdioclose(fp) SM_FILE_T *fp; { register FILE *s; if (fp->f_cookie == NULL) setup(fp); s = fp->f_cookie; return fclose(s); } /* ** SM_STDIOSETINFO -- set info for this open file ** ** Parameters: ** fp -- the file pointer ** what -- type of information setting ** valp -- memory location of info to set ** ** Return: ** Failure: -1 and sets errno ** Success: none (currently). */ /* ARGSUSED2 */ int sm_stdiosetinfo(fp, what, valp) SM_FILE_T *fp; int what; void *valp; { switch (what) { case SM_IO_WHAT_MODE: default: errno = EINVAL; return -1; } } /* ** SM_STDIOGETINFO -- get info for this open file ** ** Parameters: ** fp -- the file pointer ** what -- type of information request ** valp -- memory location to place info ** ** Return: ** Failure: -1 and sets errno ** Success: none (currently). */ /* ARGSUSED2 */ int sm_stdiogetinfo(fp, what, valp) SM_FILE_T *fp; int what; void *valp; { switch (what) { case SM_IO_WHAT_SIZE: { int fd; struct stat st; if (fp->f_cookie == NULL) setup(fp); fd = fileno((FILE *) fp->f_cookie); if (fd < 0) return -1; if (fstat(fd, &st) == 0) return st.st_size; else return -1; } case SM_IO_WHAT_MODE: default: errno = EINVAL; return -1; } } /* ** SM_IO_STDIOOPEN -- create an SM_FILE which interfaces to a stdio FILE ** ** Parameters: ** stream -- an open stdio stream, as returned by fopen() ** mode -- the mode argument to fopen() which describes stream ** ** Return: ** On success, return a pointer to an SM_FILE object which ** can be used for reading and writing 'stream'. ** Abort if mode is gibberish or stream is bad. ** Raise an exception if we can't allocate memory. */ SM_FILE_T * sm_io_stdioopen(stream, mode) FILE *stream; char *mode; { int fd; bool r, w; int ioflags; SM_FILE_T *fp; fd = fileno(stream); SM_REQUIRE(fd >= 0); r = w = false; switch (mode[0]) { case 'r': r = true; break; case 'w': case 'a': w = true; break; default: sm_abort("sm_io_stdioopen: mode '%s' is bad", mode); } if (strchr(&mode[1], '+') != NULL) r = w = true; if (r && w) ioflags = SMRW; else if (r) ioflags = SMRD; else ioflags = SMWR; fp = sm_fp(SmFtRealStdio, ioflags, NULL); fp->f_file = fd; fp->f_cookie = stream; return fp; }
Upload File
Create Folder