--- /dev/null
+/*
+ * Acess2 Dynamic Linker
+ * - By John Hodge (thePowersGang)
+ *
+ * sys/param.h
+ * - System Parameters (?)
+ */
+#ifndef _SYS__PARAM_H_
+#define _SYS__PARAM_H_
+
+#endif
+
\r
#include <sys/types.h>\r
\r
-#define O_RDONLY OPENFLAG_READ\r
-#define O_WRONLY OPENFLAG_WRITE\r
-#define O_CREAT (OPENFLAG_CREATE|OPENFLAG_WRITE)\r
-#define O_TRUNC OPENFLAG_WRITE\r
-#define O_APPEND OPENFLAG_WRITE\r
+//#define O_RDONLY OPENFLAG_READ\r
+//#define O_WRONLY OPENFLAG_WRITE\r
+//#define O_CREAT (OPENFLAG_CREATE|OPENFLAG_WRITE)\r
+//#define O_TRUNC OPENFLAG_WRITE\r
+//#define O_APPEND OPENFLAG_WRITE\r
\r
\r
#if 0\r
#define CLONE_VM 0x10
+typedef unsigned int id_t;
typedef unsigned long pid_t;
typedef unsigned long tid_t;
typedef signed long long int time_t;
#define O_RD (OPENFLAG_READ)
#define O_CREAT (OPENFLAG_CREATE)
+typedef intptr_t ssize_t;
+
#include "acess/sys.h"
--- /dev/null
+/*
+ * Acess2 POSIX Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * dirent.h
+ * - Directory Reading
+ */
+#ifndef _LIBPOSIX__SYS__DIRENT_H_
+#define _LIBPOSIX__SYS__DIRENT_H_
+
+#define NAME_MAX 255
+
+struct dirent
+{
+ ino_t d_ino;
+ char d_name[NAME_MAX+1];
+};
+
+typedef struct DIR_s DIR;
+
+extern int closedir(DIR *);
+extern DIR *opendir(const char *);
+extern struct dirent *readdir(DIR *);
+extern int readdir_r(DIR *, struct dirent *, struct dirent **);
+extern void rewinddir(DIR *);
+extern void seekdir(DIR *, long int);
+extern long int telldir(DIR *);
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 POSIX Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * grp.h
+ * - Group Management
+ */
--- /dev/null
+/*
+ * Acess2 POSIX Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * pwd.h
+ * - Password Structure
+ */
+#ifndef _LIBPOSIX__PWD_H_
+#define _LIBPOSIX__PWD_H_
+
+#include <sys/types.h> // gid_t/uid_t
+
+struct passwd
+{
+ char *pw_name;
+ uid_t pw_uid;
+ gid_t pw_gid;
+ char *pw_dir;
+ char *pw_shell;
+};
+
+extern struct passwd *getpwnam(const char *);
+extern struct passwd *getpwuid(uid_t);
+extern int getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **);
+extern int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **);
+extern void endpwent(void);
+extern struct passwd *getpwent(void);
+extern void setpwent(void);
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 POSIX Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * sys/resource.h
+ * - (XSI) Resource Operations
+ */
+#ifndef _LIBPOSIX__SYS__RESOURCE_H_
+#define _LIBPOSIX__SYS__RESOURCE_H_
+
+#include <sys/time.h> // struct timeval
+
+// (get|set)priority(which)
+enum
+{
+ PRIO_PROCESS,
+ PRIO_PGRP,
+ PRIO_USER
+};
+
+typedef unsigned int rlim_t;
+#define RLIM_INFINITY -1
+#define RLIM_SAVED_MAX -2
+#define RLIM_SAVED_CUR -3
+
+struct rlimit
+{
+ rlim_t rlim_cur;
+ rlim_t rlim_max;
+};
+
+struct rusage
+{
+ struct timeval ru_time;
+ struct timeval ru_stime;
+};
+
+extern int getpriority(int, id_t);
+extern int getrlimit(int, struct rlimit *);
+extern int getrusage(int, struct rusage *);
+extern int setpriority(int, id_t, int);
+extern int setrlimit(int, const struct rlimit *);
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 POSIX Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * sys/time.h
+ * - Timing calls
+ */
+#ifndef _LIBPOSIX__SYS__TIME_H_
+#define _LIBPOSIX__SYS__TIME_H_
+
+typedef unsigned long suseconds_t;
+
+struct timeval
+{
+ time_t tv_sec;
+ suseconds_t tv_usec;
+};
+
+struct itimerval
+{
+ struct timeval it_interval;
+ struct timeval it_value;
+};
+
+// TODO: This should also define fd_set and select()
+
+extern int getitimer(int, struct itimerval *);
+extern int setitimer(int, const struct itimerval *, struct itimerval *);
+extern int gettimeofday(struct timeval *, void *);
+// select
+extern int utimes(const char *, const struct timeval [2]);
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 POSIX Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * sys/wait.h
+ * - Waiting
+ */
+#ifndef _LIBPOSIX__SYS__WAIT_H_
+#define _LIBPOSIX__SYS__WAIT_H_
+
+// POSIX, waitpid()
+#define WNOHANG 0x01
+#define WUNTRACED 0x02
+
+// POSIX, status values
+#define WEXITSTATUS(v) v
+#define WIFCONTINUED(v) 0
+
+// POSIX/XSI, waitid(options)
+#define WEXITED 0x10
+#define WSTOPPED 0x20
+#define WCONTINUED 0x40
+#define WNOWAIT 0x80
+
+// POSIX/XSI, idtype_t
+typedef enum
+{
+ P_ALL,
+ P_PID,
+ P_PGID
+} idtype_t;
+
+// POSIX
+extern pid_t wait(int *);
+// POSIX/XSI
+//extern int waitid(idtype_t, id_t, siginfo_t *, int);
+// POSIX
+extern pid_t waitpid(pid_t, int *, int);
+
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 POSIX Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * syslog.h
+ * - Centra Loggin
+ */
+#ifndef _LIBPOSIX__SYSLOG_H_
+#define _LIBPOSIX__SYSLOG_H_
+
+// openlog(logopt)
+#define LOG_PID 0x01
+#define LOG_CONS 0x02
+#define LOG_NDELAY 0x04
+#define LOG_ODELAY 0x08
+#define LOG_NOWAIT 0x10
+
+// openlog(facility)
+enum {
+ LOG_KERN,
+ LOG_USER,
+ LOG_MAIL,
+ LOG_NEWS,
+ LOG_UUCP,
+ LOG_DAEMON,
+ LOG_AUTH,
+ LOG_CRON,
+ LOG_LPR,
+ LOG_LOCAL0,
+ LOG_LOCAL1,
+ LOG_LOCAL2,
+ LOG_LOCAL3,
+ LOG_LOCAL4,
+ LOG_LOCAL5,
+ LOG_LOCAL6,
+ LOG_LOCAL7
+};
+
+// setlogmask(maskpri)
+#define LOG_MASK(pri) pri
+
+// syslog(priority)
+enum {
+ LOG_EMERG,
+ LOG_ALERT,
+ LOG_CRIT,
+ LOG_ERR,
+ LOG_WARNING,
+ LOG_NOTICE,
+ LOG_INFO,
+ LOG_DEBUG
+};
+
+extern void closelog(void);
+extern void openlog(const char *, int, int);
+extern int setlogmask(int);
+extern void syslog(int, const char *, ...);
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 POSIX Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * termios.h
+ * - Terminal Control
+ */
+#ifndef _LIBPOSIX__TERMIOS_H_
+#define _LIBPOSIX__TERMIOS_H_
+
+typedef unsigned char cc_t;
+typedef unsigned long speed_t;
+typedef unsigned short tcflag_t;
+
+enum {
+ VEOF,
+ VEOL,
+ VERASE,
+ VINTR,
+ VKILL,
+ VMIN,
+ VQUIT,
+ VSTART,
+ VSTOP,
+ VSUSP,
+ VTIME,
+ NCCS
+};
+
+struct termios
+{
+ tcflag_t c_iflag;
+ tcflag_t c_oflag;
+ tcflag_t c_cflag;
+ tcflag_t c_lflag;
+ cc_t c_cc[NCCS];
+};
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 POSIX Sockets Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * arpa/inet.h
+ * -
+ */
+#ifndef _LIBPSOCKET__ARPA__INET_H_
+#define _LIBPSOCKET__ARPA__INET_H_
+
+#include <netinet/in.h>
+#include <stdint.h> // Should be inttypes.h?
+
+extern uint32_t htonl(uint32_t hostlong);
+extern uint16_t htons(uint16_t hostshort);
+extern uint32_t ntohl(uint32_t netlong);
+extern uint16_t ntohs(uint16_t netshort);
+
+extern in_addr_t inet_addr(const char *cp);
+extern in_addr_t inet_lnaof(struct in_addr in);
+extern struct in_addr inet_makeaddr(in_addr_t net, in_addr_t lna);
+extern in_addr_t inet_netof(struct in_addr in);
+extern in_addr_t inet_network(const char *cp);
+extern char *inet_ntoa(struct in_addr in);
+
+#endif
+
#include <stdint.h>
+typedef uint32_t in_addr_t;
+
struct in_addr
{
- unsigned long s_addr;
+ in_addr_t s_addr;
};
struct sockaddr_in
struct in_addr sin_addr;
};
+#define INADDR_ANY 0x00000000
+#define INADDR_BROADCAST 0xFFFFFFFF
+
+// getsockopt/setsockopt(level)
+enum {
+ IPPROTO_IP,
+ IPPROTO_ICMP,
+ IPPROTO_TCP,
+ IPPROTO_UDP
+};
+
struct in6_addr
{
unsigned char s6_addr[16];
/*
- * Acess2 C Library
+ * Acess2 POSIX Sockets Emulation
+ * - By John Hodge (thePowersGang)
*
* sys/sockets.h
* - POSIX Sockets
- *
- * By John Hodge (thePowersGang)
*/
#ifndef _SYS_SOCKETS_H_
#define _SYS_SOCKETS_H_
#include <sys/types.h>
#include <stddef.h> // size_t
-typedef int socklen_t;
+typedef uint32_t socklen_t;
typedef enum
{
char sa_data[16];
};
-/**
- * \brief Values for \a domain of socket()
- */
-enum eSocketDomains
+struct msghdr
{
- PF_LOCAL, //!< Machine-local comms
- PF_INET, //!< IPv4
- PF_INET6, //!< IPv6
- PF_PACKET //!< Low level packet interface
+ void *msg_name;
+ socklen_t msg_namelen;
+ struct iovec *msg_iov;
+ int msg_iovlen;
+ void *msg_control;
+ socklen_t msg_controllen;
+ int msg_flags;
+};
+
+struct cmsghdr
+{
+ socklen_t cmsg_len;
+ int cmsg_level;
+ int cmsg_type;
+};
+
+#define SCM_RIGHTS 0x1
+
+#define CMSG_DATA(cmsg) ((unsigned char*)(cmsg + 1))
+#define CMSG_NXTHDR(mhdr, cmsg) 0
+#define CMSG_FIRSTHDR(mhdr) 0
+
+struct linger
+{
+ int l_onoff;
+ int l_linger;
};
-#define PF_UNIX PF_LOCAL
enum eSocketTypes
{
SOCK_RDM //!< Reliable non-ordered datagrams
};
+/**
+ * \brief Values for \a domain of socket()
+ */
+enum eSocketDomains
+{
+ PF_LOCAL, //!< Machine-local comms
+ PF_INET, //!< IPv4
+ PF_INET6, //!< IPv6
+ PF_PACKET //!< Low level packet interface
+};
+#define PF_UNIX PF_LOCAL
+
/**
* \brief Create a new socket descriptor
* \param domain Address family
extern int sendto(int sockfd, const void *buffer, size_t length, int flags, const struct sockaddr *clientaddr, socklen_t addrlen);
extern int send(int sockfd, void *buffer, size_t length, int flags);
+extern int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len);
+extern int getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len);
+
#endif
--- /dev/null
+/*
+ * Acess2 POSIX Sockets Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * sys/un.h
+ * - UNIX Domain Sockets
+ */
+#ifndef _LIBPSOCKET__SYS__UN_H_
+#define _LIBPSOCKET__SYS__UN_H_
+
+#define _SUN_PATH_MAX 108
+
+// POSIX Defined
+struct sockaddr_un
+{
+ sa_family_t sun_family;
+ char sun_path[_SUN_PATH_MAX];
+};
+
+#endif
+