diff options
author | Miguel de Icaza <miguel@gnome.org> | 2004-03-16 19:54:13 +0300 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2004-03-16 19:54:13 +0300 |
commit | 4d27ce68225474f04edfcfb11ed3b21ede395464 (patch) | |
tree | 81900538e81d352a6db24f2b88cc45cef819c0a3 /support | |
parent | 0cbd91bc9752308c1c205b945076800441d803f0 (diff) |
Move the platform dependent code here; Temporary solution until I get time to redo it like Paolo suggested
svn path=/trunk/mono/; revision=24137
Diffstat (limited to 'support')
-rw-r--r-- | support/Makefile.am | 6 | ||||
-rw-r--r-- | support/macros.c | 89 | ||||
-rw-r--r-- | support/map.c | 153 | ||||
-rw-r--r-- | support/map.h | 64 |
4 files changed, 312 insertions, 0 deletions
diff --git a/support/Makefile.am b/support/Makefile.am new file mode 100644 index 00000000000..1ab3f49053b --- /dev/null +++ b/support/Makefile.am @@ -0,0 +1,6 @@ +lib_LTLIBRARIES = libMonoPosixHelper.la + +libMonoPosixHelper_la_SOURCES = \ + map.c map.h macros.c + + diff --git a/support/macros.c b/support/macros.c new file mode 100644 index 00000000000..27d7065014a --- /dev/null +++ b/support/macros.c @@ -0,0 +1,89 @@ +#include <sys/types.h> +#include <sys/wait.h> +#include <sys/stat.h> +#include <unistd.h> +#include <pwd.h> +#include <grp.h> + +int wifexited (int status) +{ + return WIFEXITED (status); +} + +int wexitstatus (int status) +{ + return WEXITSTATUS (status); +} + +int wifsignaled (int status) +{ + return WIFSIGNALED (status); +} + +int wtermsig (int status) +{ + return WTERMSIG (status); +} + +int wifstopped (int status) +{ + return WIFSTOPPED (status); +} + +int wstopsig (int status) +{ + return WSTOPSIG (status); +} + +int helper_Mono_Posix_Stat(char *filename, int dereference, + int *device, + int *inode, + int *mode, + int *nlinks, + int *uid, + int *gid, + int *rdev, + long *size, + long *blksize, + long *blocks, + long *atime, + long *mtime, + long *ctime + ) { + int ret; + struct stat buf; + + if (!dereference) + ret = stat(filename, &buf); + else + ret = lstat(filename, &buf); + + if (ret) return ret; + + *device = buf.st_dev; + *inode = buf.st_ino; + *mode = buf.st_mode; + *nlinks = buf.st_nlink; + *uid = buf.st_uid; + *gid = buf.st_gid; + *rdev = buf.st_rdev; + *size = buf.st_size; + *blksize = buf.st_blksize; + *blocks = buf.st_blocks; + *atime = buf.st_atime; + *mtime = buf.st_mtime; + *ctime = buf.st_ctime; + return 0; +} + +char *helper_Mono_Posix_GetUserName(int uid) { + struct passwd *p = getpwuid(uid); + if (p == NULL) return NULL; + return p->pw_name; +} +char *helper_Mono_Posix_GetGroupName(int gid) { + struct group *p = getgrgid(gid); + if (p == NULL) return NULL; + return p->gr_name; +} + diff --git a/support/map.c b/support/map.c new file mode 100644 index 00000000000..f0e84a76048 --- /dev/null +++ b/support/map.c @@ -0,0 +1,153 @@ +/* This file was automatically generated by make-map from ../lib/Mono.Posix.dll */ + +#define _GNU_SOURCE +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/wait.h> +#include <unistd.h> +#include <fcntl.h> +#include <signal.h> +#include "map.h" +int map_Mono_Posix_OpenFlags (int x) +{ + int r = 0; + if ((x & Mono_Posix_OpenFlags_O_RDONLY) != 0) + r |= O_RDONLY; + if ((x & Mono_Posix_OpenFlags_O_WRONLY) != 0) + r |= O_WRONLY; + if ((x & Mono_Posix_OpenFlags_O_RDWR) != 0) + r |= O_RDWR; + if ((x & Mono_Posix_OpenFlags_O_CREAT) != 0) + r |= O_CREAT; + if ((x & Mono_Posix_OpenFlags_O_EXCL) != 0) + r |= O_EXCL; + if ((x & Mono_Posix_OpenFlags_O_NOCTTY) != 0) + r |= O_NOCTTY; + if ((x & Mono_Posix_OpenFlags_O_TRUNC) != 0) + r |= O_TRUNC; + if ((x & Mono_Posix_OpenFlags_O_APPEND) != 0) + r |= O_APPEND; + if ((x & Mono_Posix_OpenFlags_O_NONBLOCK) != 0) + r |= O_NONBLOCK; + if ((x & Mono_Posix_OpenFlags_O_SYNC) != 0) + r |= O_SYNC; + return r; +} + +int map_Mono_Posix_FileMode (int x) +{ + int r = 0; + if ((x & Mono_Posix_FileMode_S_ISUID) != 0) + r |= S_ISUID; + if ((x & Mono_Posix_FileMode_S_ISGID) != 0) + r |= S_ISGID; + if ((x & Mono_Posix_FileMode_S_ISVTX) != 0) + r |= S_ISVTX; + if ((x & Mono_Posix_FileMode_S_IRUSR) != 0) + r |= S_IRUSR; + if ((x & Mono_Posix_FileMode_S_IWUSR) != 0) + r |= S_IWUSR; + if ((x & Mono_Posix_FileMode_S_IXUSR) != 0) + r |= S_IXUSR; + if ((x & Mono_Posix_FileMode_S_IRGRP) != 0) + r |= S_IRGRP; + if ((x & Mono_Posix_FileMode_S_IWGRP) != 0) + r |= S_IWGRP; + if ((x & Mono_Posix_FileMode_S_IXGRP) != 0) + r |= S_IXGRP; + if ((x & Mono_Posix_FileMode_S_IROTH) != 0) + r |= S_IROTH; + if ((x & Mono_Posix_FileMode_S_IWOTH) != 0) + r |= S_IWOTH; + if ((x & Mono_Posix_FileMode_S_IXOTH) != 0) + r |= S_IXOTH; + return r; +} + +int map_Mono_Posix_WaitOptions (int x) +{ + int r = 0; + if ((x & Mono_Posix_WaitOptions_WNOHANG) != 0) + r |= WNOHANG; + if ((x & Mono_Posix_WaitOptions_WUNTRACED) != 0) + r |= WUNTRACED; + return r; +} + +int map_Mono_Posix_AccessMode (int x) +{ + int r = 0; + if ((x & Mono_Posix_AccessMode_R_OK) != 0) + r |= R_OK; + if ((x & Mono_Posix_AccessMode_W_OK) != 0) + r |= W_OK; + if ((x & Mono_Posix_AccessMode_X_OK) != 0) + r |= X_OK; + if ((x & Mono_Posix_AccessMode_F_OK) != 0) + r |= F_OK; + return r; +} + +int map_Mono_Posix_Signals (int x) +{ + if (x == Mono_Posix_Signals_SIGHUP) + return SIGHUP; + if (x == Mono_Posix_Signals_SIGINT) + return SIGINT; + if (x == Mono_Posix_Signals_SIGQUIT) + return SIGQUIT; + if (x == Mono_Posix_Signals_SIGILL) + return SIGILL; + if (x == Mono_Posix_Signals_SIGTRAP) + return SIGTRAP; + if (x == Mono_Posix_Signals_SIGABRT) + return SIGABRT; + if (x == Mono_Posix_Signals_SIGBUS) + return SIGBUS; + if (x == Mono_Posix_Signals_SIGFPE) + return SIGFPE; + if (x == Mono_Posix_Signals_SIGKILL) + return SIGKILL; + if (x == Mono_Posix_Signals_SIGUSR1) + return SIGUSR1; + if (x == Mono_Posix_Signals_SIGSEGV) + return SIGSEGV; + if (x == Mono_Posix_Signals_SIGUSR2) + return SIGUSR2; + if (x == Mono_Posix_Signals_SIGPIPE) + return SIGPIPE; + if (x == Mono_Posix_Signals_SIGALRM) + return SIGALRM; + if (x == Mono_Posix_Signals_SIGTERM) + return SIGTERM; + if (x == Mono_Posix_Signals_SIGCHLD) + return SIGCHLD; + if (x == Mono_Posix_Signals_SIGCONT) + return SIGCONT; + if (x == Mono_Posix_Signals_SIGSTOP) + return SIGSTOP; + if (x == Mono_Posix_Signals_SIGTSTP) + return SIGTSTP; + if (x == Mono_Posix_Signals_SIGTTIN) + return SIGTTIN; + if (x == Mono_Posix_Signals_SIGTTOU) + return SIGTTOU; + if (x == Mono_Posix_Signals_SIGURG) + return SIGURG; + if (x == Mono_Posix_Signals_SIGXCPU) + return SIGXCPU; + if (x == Mono_Posix_Signals_SIGXFSZ) + return SIGXFSZ; + if (x == Mono_Posix_Signals_SIGVTALRM) + return SIGVTALRM; + if (x == Mono_Posix_Signals_SIGPROF) + return SIGPROF; + if (x == Mono_Posix_Signals_SIGWINCH) + return SIGWINCH; + if (x == Mono_Posix_Signals_SIGIO) + return SIGIO; + if (x == Mono_Posix_Signals_SIGSYS) + return SIGSYS; + return -1; +} + diff --git a/support/map.h b/support/map.h new file mode 100644 index 00000000000..92e02801d45 --- /dev/null +++ b/support/map.h @@ -0,0 +1,64 @@ +/* This file was automatically generated by make-map from ../lib/Mono.Posix.dll */ + +#define Mono_Posix_OpenFlags_O_RDONLY O_RDONLY +#define Mono_Posix_OpenFlags_O_WRONLY O_WRONLY +#define Mono_Posix_OpenFlags_O_RDWR O_RDWR +#define Mono_Posix_OpenFlags_O_CREAT O_CREAT +#define Mono_Posix_OpenFlags_O_EXCL O_EXCL +#define Mono_Posix_OpenFlags_O_NOCTTY O_NOCTTY +#define Mono_Posix_OpenFlags_O_TRUNC O_TRUNC +#define Mono_Posix_OpenFlags_O_APPEND O_APPEND +#define Mono_Posix_OpenFlags_O_NONBLOCK O_NONBLOCK +#define Mono_Posix_OpenFlags_O_SYNC O_SYNC + +#define Mono_Posix_FileMode_S_ISUID S_ISUID +#define Mono_Posix_FileMode_S_ISGID S_ISGID +#define Mono_Posix_FileMode_S_ISVTX S_ISVTX +#define Mono_Posix_FileMode_S_IRUSR S_IRUSR +#define Mono_Posix_FileMode_S_IWUSR S_IWUSR +#define Mono_Posix_FileMode_S_IXUSR S_IXUSR +#define Mono_Posix_FileMode_S_IRGRP S_IRGRP +#define Mono_Posix_FileMode_S_IWGRP S_IWGRP +#define Mono_Posix_FileMode_S_IXGRP S_IXGRP +#define Mono_Posix_FileMode_S_IROTH S_IROTH +#define Mono_Posix_FileMode_S_IWOTH S_IWOTH +#define Mono_Posix_FileMode_S_IXOTH S_IXOTH + +#define Mono_Posix_WaitOptions_WNOHANG WNOHANG +#define Mono_Posix_WaitOptions_WUNTRACED WUNTRACED + +#define Mono_Posix_AccessMode_R_OK R_OK +#define Mono_Posix_AccessMode_W_OK W_OK +#define Mono_Posix_AccessMode_X_OK X_OK +#define Mono_Posix_AccessMode_F_OK F_OK + +#define Mono_Posix_Signals_SIGHUP SIGHUP +#define Mono_Posix_Signals_SIGINT SIGINT +#define Mono_Posix_Signals_SIGQUIT SIGQUIT +#define Mono_Posix_Signals_SIGILL SIGILL +#define Mono_Posix_Signals_SIGTRAP SIGTRAP +#define Mono_Posix_Signals_SIGABRT SIGABRT +#define Mono_Posix_Signals_SIGBUS SIGBUS +#define Mono_Posix_Signals_SIGFPE SIGFPE +#define Mono_Posix_Signals_SIGKILL SIGKILL +#define Mono_Posix_Signals_SIGUSR1 SIGUSR1 +#define Mono_Posix_Signals_SIGSEGV SIGSEGV +#define Mono_Posix_Signals_SIGUSR2 SIGUSR2 +#define Mono_Posix_Signals_SIGPIPE SIGPIPE +#define Mono_Posix_Signals_SIGALRM SIGALRM +#define Mono_Posix_Signals_SIGTERM SIGTERM +#define Mono_Posix_Signals_SIGCHLD SIGCHLD +#define Mono_Posix_Signals_SIGCONT SIGCONT +#define Mono_Posix_Signals_SIGSTOP SIGSTOP +#define Mono_Posix_Signals_SIGTSTP SIGTSTP +#define Mono_Posix_Signals_SIGTTIN SIGTTIN +#define Mono_Posix_Signals_SIGTTOU SIGTTOU +#define Mono_Posix_Signals_SIGURG SIGURG +#define Mono_Posix_Signals_SIGXCPU SIGXCPU +#define Mono_Posix_Signals_SIGXFSZ SIGXFSZ +#define Mono_Posix_Signals_SIGVTALRM SIGVTALRM +#define Mono_Posix_Signals_SIGPROF SIGPROF +#define Mono_Posix_Signals_SIGWINCH SIGWINCH +#define Mono_Posix_Signals_SIGIO SIGIO +#define Mono_Posix_Signals_SIGSYS SIGSYS + |