|
uid_t | fsidFromProcfs (pid_t const pid, std::string const &lineId) |
|
|
void * | calloc (size_t nmemb, size_t size) |
|
void * | malloc (size_t size) |
|
void | free (void *ptr) |
|
int | system (char const *s) |
|
char * | getenv (char const *name) |
|
void | realpath (char const *path, char *resolved_path) |
|
FILE * | fopen (char const *path, char const *mode) |
|
FILE * | freopen (char const *path, char const *mode, FILE *stream) |
|
void | fclose (FILE *fp) |
|
mode_t | umask (mode_t mask) |
|
void | chdir (char const *path) |
|
void | chown (char const *path, uid_t owner, gid_t group) |
|
void | chmod (char const *path, mode_t mode) |
|
void | stat (char const *file_name, struct stat *buf) |
|
void | fstat (int filedes, struct stat *buf) |
|
void | lstat (char const *file_name, struct stat *buf) |
|
void | statvfs (char const *path, struct statvfs *buf) |
|
void | unlink (char const *pathname) |
|
void | remove (char const *pathname) |
|
void | rename (char const *oldpath, char const *newpath) |
|
int | open (char const *pathname, int flags) |
|
int | open (char const *pathname, int flags, mode_t mode) |
|
void | close (int fd) |
|
void | mkdir (char const *pathname, mode_t mode) |
|
void | rmdir (char const *pathname) |
|
int | dup (int oldfd) |
|
int | dup2 (int oldfd, int newfd) |
|
int | fcntl (int fd, int cmd, long arg) |
|
int | fcntl (int fd, int cmd, struct flock *lock) |
|
int | flock (int fd, int operation) |
|
struct passwd * | getpwnam (char const *name) |
|
struct group * | getgrnam (char const *name) |
|
ssize_t | write (int fd, void const *buf, size_t count) |
|
ssize_t | read (int fd, void *buf, size_t count) |
|
pid_t | fork (void) |
|
pid_t | getpid () |
|
pid_t | gettid () |
|
pid_t | getppid () |
|
pid_t | getpgid (pid_t pid) |
|
pid_t | waitpid (pid_t pid, int *status, int options) |
|
pid_t | setsid () |
|
uid_t | getuid () |
|
gid_t | getgid () |
|
uid_t | geteuid () |
|
gid_t | getegid () |
|
void | seteuid (uid_t euid) |
|
void | setegid (gid_t egid) |
|
void | setuid (uid_t uid) |
|
void | setgid (gid_t gid) |
|
uid_t | getfsuid (pid_t const pid) |
|
gid_t | getfsgid (pid_t const pid) |
|
void | setfsuid (uid_t fsuid) |
|
void | setfsgid (gid_t fsgid) |
|
void | getrlimit (int resource, struct rlimit *rlim) |
|
void | getrusage (int who, struct rusage *usage) |
|
void | setrlimit (int resource, struct rlimit const *rlim) |
|
unsigned int | sleep (unsigned int seconds) |
|
int | socket (int domain, int type, int protocol) |
|
void | getaddrinfo (const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res) |
|
void | getnameinfo (const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) |
|
std::string | getnameinfo (const struct sockaddr *sa, socklen_t salen) |
|
void | getpeername (int s, struct sockaddr *name, socklen_t *namelen) |
|
void | getsockname (int s, struct sockaddr *name, socklen_t *namelen) |
|
void | setsockopt (int s, int level, int optname, void const *optval, socklen_t optlen) |
|
void | setsockopt_to (int s, int level, int optname, struct timeval const &tv) |
|
ssize_t | recv (int s, void *buf, size_t len, int flags) |
|
ssize_t | send (int s, void const *buf, size_t len, int flags) |
|
void | listen (int s, int backlog) |
|
void | bind (int sockfd, struct sockaddr *my_addr, socklen_t addrlen) |
|
void | connect (int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) |
|
int | select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) |
|
void | socketpair (int d, int type, int protocol, int sv[2]) |
|
void | gettimeofday (struct timeval *tv, struct timezone *tz) |
|
void | settimeofday (struct timeval const *tv, struct timezone const *tz) |
|
iconv_t | iconv_open (char const *tocode, char const *fromcode) |
|
void | iconv_close (iconv_t cd) |
|
void | quotactl (int cmd, char const *special, int id, caddr_t addr) |
|
size_t | confstr (int name, char *buf, size_t len) |
|
std::string | getconf (int id) |
| Loosely like the shell utility "getconf".
|
|
FILE * | fdopen (int fildes, char const *mode) |
|
Namespace for system/library calls.
Purpose
- Error handling via exceptions (so no if-err-then-throw-style code needs to be repeated).
- Automatically produce readable error strings from "errno" value in exception strings.
- Transport a copy of the "errno" value up in exception object for detailed error handling if needed.
- Configuration for different systems (linux,win32; ideally, there should be no ifdefs needed but in Sys.?pp).
If you use a call that matches any of the points above, please include a wrapper here.
Example usage
Call any of the wrapper somewhere in your code:
...
myStr = getPath();
UI::Util::Sys::remove(myStr);
// as usual, assume success
...
Somewhere in your context-specific exception handler:
...
catch (UI::Util::Sys::Exception const & e)
{
std::cerr << "System error : " << e.what() << std::endl;
std::cerr << "Errno error code was: " << e.getCode() << std::endl;
std::cerr << "Exception debug : " << e.getDebug() << std::endl;
}
...
How to add wrappers
- Use syntax & name from the man page.
- If return value is only used for error condition:yes/no: make it return void.
- Just call the system/library function. On error condition (see man page), use UI_THROW_ERRNO("MY NICE PREFIX") to throw w/ errno + errno text support in the exception.