5 * $TOG: IO.hh /main/10 1999/01/29 14:43:20 mgreess $
7 * RESTRICTED CONFIDENTIAL INFORMATION:
9 * The information in this document is subject to special
10 * restrictions in a confidential disclosure agreement bertween
11 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
12 * document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
13 * Sun's specific written approval. This documment and all copies
14 * and derivative works thereof must be returned or destroyed at
17 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
22 #ifndef I_HAVE_NO_IDENT
28 #include <sys/types.h>
39 #include <DtMail/DtMailError.hh>
42 // The following I/O routines are wrappers for the normal routines,
43 // but they deal with EINTR, and partial read/write situations.
45 int SafeAccess(const char * path, int amode);
46 int SafeClose(int fd);
47 int SafeDup2(int fd1, int fd2);
48 int SafeExecvp(const char * file, char *const *argv);
49 int SafeFchown(int fd, uid_t owner, gid_t group);
50 int SafeFChmod(int fd, mode_t mode);
51 int SafeFStat(int fd, struct stat * buf);
52 int SafeFTruncate(int fd, off_t len);
53 int SafeGuaranteedStat(const char * path, struct stat * buf);
54 int SafeLStat(const char * path, struct stat * buf);
55 int SafeLink(const char * existingPath, const char * newPath);
56 int SafeLockf(int fd, int func, long size);
57 int SafeOpen(const char * path, int oflag, mode_t mode = 0644);
58 void SafePathIsAccessible(DtMailEnv &error, const char * path);
59 ssize_t SafeRead(int fd, void * buf, size_t bytes);
60 int SafeRename(const char * oldPath, const char * newPath);
61 int SafeRemove(const char * path);
62 int SafeStat(const char * path, struct stat * buf);
63 int SafeTruncate(const char * path, off_t len);
64 int SafeUTime(const char * path, utimbuf * ntime);
65 int SafeUnlink(const char * path);
66 ssize_t SafeWrite(int fd, const void * buf, size_t bytes);
68 SafeWritev(int fd, struct iovec *iov, int iovcnt);
69 ssize_t SafeWriteStrip(int fd, const void * buf, size_t bytes);
70 int SafeWaitpid(pid_t proc, int * status, int options);
71 int SafeWait(int * status);
73 // The time routines deal with MT and reentrant issues in a platform
76 void SafeCtime(const time_t *clock, char * buf, int buflen = 26);
77 void SafeLocaltime(const time_t *clock, tm & result);
78 time_t SafeMktime(tm * timeptr);
80 char * buf, size_t buf_size,
81 const char * format, const tm * timeptr);
84 // Interface routines to AF_INET, SOCK_STREAM sockets with line-based
87 void *SockOpen(char *host, int clientPort, char **errorstring);
88 char *SockGets(char *buf, int len, void *sockfp);
89 int SockPrintf(void *sockfp, char *format, ...);
90 int SockRead(char *buf, int size, int nels, void *sockfp);
91 int SockWrite(char *buf, int size, int nels, void *sockfp);
92 void SockClose(void *sockfp);
95 // The group and password routines will retrieve the group and
96 // password names in an MT-Safe way.
98 int FileSystemSpace(const char *file_path, size_t bytes, char **fsname);
99 void GetGroupName(char * grp_name);
100 gid_t GetIdForGroupName(char * grp_name);
101 void GetPasswordEntry(passwd & result);
102 int isSetMailGidNeeded(const char * mailboxPath);