Fix typo in license headers
[oweals/cde.git] / cde / programs / dtmail / include / DtMail / IO.hh
1 /*
2  *+SNOTICE
3  *
4  *
5  *      $TOG: IO.hh /main/10 1999/01/29 14:43:20 mgreess $
6  *
7  *      RESTRICTED CONFIDENTIAL INFORMATION:
8  *      
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
15  *      Sun's request.
16  *
17  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
18  *
19  *+ENOTICE
20  */
21
22 #ifndef I_HAVE_NO_IDENT
23 #endif
24
25 #ifndef _IO_HH
26 #define _IO_HH
27
28 #include <sys/types.h>
29 #include <unistd.h>
30 #include <fcntl.h>
31 #include <time.h>
32 #include <utime.h>
33 #include <pwd.h>
34 #include <grp.h>
35 #include <sys/stat.h>
36 #include <sys/uio.h>
37 #include <stdio.h>
38
39 #include <DtMail/DtMailError.hh>
40
41 //
42 // The following I/O routines are wrappers for the normal routines,
43 // but they deal with EINTR, and partial read/write situations.
44 //
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);
67 unsigned long
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);
72
73 // The time routines deal with MT and reentrant issues in a platform
74 // independent way.
75 //
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);
79 size_t  SafeStrftime(
80                 char * buf, size_t buf_size,
81                 const char * format, const tm * timeptr);
82
83 //
84 // Interface routines to AF_INET, SOCK_STREAM sockets with line-based
85 // buffering.
86 //
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);
93
94 //
95 // The group and password routines will retrieve the group and
96 // password names in an MT-Safe way.
97 //
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);
103
104 #endif