From: John Hodge Date: Sat, 1 Sep 2012 14:18:06 +0000 (+0800) Subject: Usermode - Heaps more headers in libposix/psocket/libc X-Git-Tag: rel0.15~706^2~18 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=793101e78d857adf31301025173debecf4bd2a62;p=tpg%2Facess2.git Usermode - Heaps more headers in libposix/psocket/libc --- diff --git a/Usermode/Libraries/ld-acess.so_src/include_exp/sys/param.h b/Usermode/Libraries/ld-acess.so_src/include_exp/sys/param.h new file mode 100644 index 00000000..b9b50e2c --- /dev/null +++ b/Usermode/Libraries/ld-acess.so_src/include_exp/sys/param.h @@ -0,0 +1,12 @@ +/* + * Acess2 Dynamic Linker + * - By John Hodge (thePowersGang) + * + * sys/param.h + * - System Parameters (?) + */ +#ifndef _SYS__PARAM_H_ +#define _SYS__PARAM_H_ + +#endif + diff --git a/Usermode/Libraries/ld-acess.so_src/include_exp/sys/sys.h b/Usermode/Libraries/ld-acess.so_src/include_exp/sys/sys.h index 08bf31e9..7666d9a7 100644 --- a/Usermode/Libraries/ld-acess.so_src/include_exp/sys/sys.h +++ b/Usermode/Libraries/ld-acess.so_src/include_exp/sys/sys.h @@ -8,11 +8,11 @@ #include -#define O_RDONLY OPENFLAG_READ -#define O_WRONLY OPENFLAG_WRITE -#define O_CREAT (OPENFLAG_CREATE|OPENFLAG_WRITE) -#define O_TRUNC OPENFLAG_WRITE -#define O_APPEND OPENFLAG_WRITE +//#define O_RDONLY OPENFLAG_READ +//#define O_WRONLY OPENFLAG_WRITE +//#define O_CREAT (OPENFLAG_CREATE|OPENFLAG_WRITE) +//#define O_TRUNC OPENFLAG_WRITE +//#define O_APPEND OPENFLAG_WRITE #if 0 diff --git a/Usermode/Libraries/ld-acess.so_src/include_exp/sys/types.h b/Usermode/Libraries/ld-acess.so_src/include_exp/sys/types.h index ef4c24dc..7c584d20 100644 --- a/Usermode/Libraries/ld-acess.so_src/include_exp/sys/types.h +++ b/Usermode/Libraries/ld-acess.so_src/include_exp/sys/types.h @@ -12,6 +12,7 @@ typedef struct stat t_fstat; #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; diff --git a/Usermode/Libraries/ld-acess.so_src/include_exp/unistd.h b/Usermode/Libraries/ld-acess.so_src/include_exp/unistd.h index 3dc523a1..36ed5345 100644 --- a/Usermode/Libraries/ld-acess.so_src/include_exp/unistd.h +++ b/Usermode/Libraries/ld-acess.so_src/include_exp/unistd.h @@ -6,6 +6,8 @@ #define O_RD (OPENFLAG_READ) #define O_CREAT (OPENFLAG_CREATE) +typedef intptr_t ssize_t; + #include "acess/sys.h" diff --git a/Usermode/Libraries/libposix.so_src/include_exp/dirent.h b/Usermode/Libraries/libposix.so_src/include_exp/dirent.h new file mode 100644 index 00000000..4f2c0b30 --- /dev/null +++ b/Usermode/Libraries/libposix.so_src/include_exp/dirent.h @@ -0,0 +1,30 @@ +/* + * 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 + diff --git a/Usermode/Libraries/libposix.so_src/include_exp/grp.h b/Usermode/Libraries/libposix.so_src/include_exp/grp.h new file mode 100644 index 00000000..b3d42bf7 --- /dev/null +++ b/Usermode/Libraries/libposix.so_src/include_exp/grp.h @@ -0,0 +1,7 @@ +/* + * Acess2 POSIX Emulation + * - By John Hodge (thePowersGang) + * + * grp.h + * - Group Management + */ diff --git a/Usermode/Libraries/libposix.so_src/include_exp/pwd.h b/Usermode/Libraries/libposix.so_src/include_exp/pwd.h new file mode 100644 index 00000000..66b157f9 --- /dev/null +++ b/Usermode/Libraries/libposix.so_src/include_exp/pwd.h @@ -0,0 +1,31 @@ +/* + * Acess2 POSIX Emulation + * - By John Hodge (thePowersGang) + * + * pwd.h + * - Password Structure + */ +#ifndef _LIBPOSIX__PWD_H_ +#define _LIBPOSIX__PWD_H_ + +#include // 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 + diff --git a/Usermode/Libraries/libposix.so_src/include_exp/sys/resource.h b/Usermode/Libraries/libposix.so_src/include_exp/sys/resource.h new file mode 100644 index 00000000..f9a64cb2 --- /dev/null +++ b/Usermode/Libraries/libposix.so_src/include_exp/sys/resource.h @@ -0,0 +1,45 @@ +/* + * Acess2 POSIX Emulation + * - By John Hodge (thePowersGang) + * + * sys/resource.h + * - (XSI) Resource Operations + */ +#ifndef _LIBPOSIX__SYS__RESOURCE_H_ +#define _LIBPOSIX__SYS__RESOURCE_H_ + +#include // 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 + diff --git a/Usermode/Libraries/libposix.so_src/include_exp/sys/time.h b/Usermode/Libraries/libposix.so_src/include_exp/sys/time.h new file mode 100644 index 00000000..5cd28762 --- /dev/null +++ b/Usermode/Libraries/libposix.so_src/include_exp/sys/time.h @@ -0,0 +1,34 @@ +/* + * 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 + diff --git a/Usermode/Libraries/libposix.so_src/include_exp/sys/wait.h b/Usermode/Libraries/libposix.so_src/include_exp/sys/wait.h new file mode 100644 index 00000000..d37f5e5d --- /dev/null +++ b/Usermode/Libraries/libposix.so_src/include_exp/sys/wait.h @@ -0,0 +1,42 @@ +/* + * 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 + diff --git a/Usermode/Libraries/libposix.so_src/include_exp/syslog.h b/Usermode/Libraries/libposix.so_src/include_exp/syslog.h new file mode 100644 index 00000000..ae891b7f --- /dev/null +++ b/Usermode/Libraries/libposix.so_src/include_exp/syslog.h @@ -0,0 +1,60 @@ +/* + * 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 + diff --git a/Usermode/Libraries/libposix.so_src/include_exp/termios.h b/Usermode/Libraries/libposix.so_src/include_exp/termios.h new file mode 100644 index 00000000..e29ff4cf --- /dev/null +++ b/Usermode/Libraries/libposix.so_src/include_exp/termios.h @@ -0,0 +1,40 @@ +/* + * 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 + diff --git a/Usermode/Libraries/libpsocket.so_src/include_exp/arpa/inet.h b/Usermode/Libraries/libpsocket.so_src/include_exp/arpa/inet.h new file mode 100644 index 00000000..effc2883 --- /dev/null +++ b/Usermode/Libraries/libpsocket.so_src/include_exp/arpa/inet.h @@ -0,0 +1,27 @@ +/* + * Acess2 POSIX Sockets Emulation + * - By John Hodge (thePowersGang) + * + * arpa/inet.h + * - + */ +#ifndef _LIBPSOCKET__ARPA__INET_H_ +#define _LIBPSOCKET__ARPA__INET_H_ + +#include +#include // 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 + diff --git a/Usermode/Libraries/libpsocket.so_src/include_exp/netinet/in.h b/Usermode/Libraries/libpsocket.so_src/include_exp/netinet/in.h index 4bde06db..8abf7664 100644 --- a/Usermode/Libraries/libpsocket.so_src/include_exp/netinet/in.h +++ b/Usermode/Libraries/libpsocket.so_src/include_exp/netinet/in.h @@ -3,9 +3,11 @@ #include +typedef uint32_t in_addr_t; + struct in_addr { - unsigned long s_addr; + in_addr_t s_addr; }; struct sockaddr_in @@ -15,6 +17,17 @@ 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]; diff --git a/Usermode/Libraries/libpsocket.so_src/include_exp/sys/socket.h b/Usermode/Libraries/libpsocket.so_src/include_exp/sys/socket.h index d53b94aa..adc5a871 100644 --- a/Usermode/Libraries/libpsocket.so_src/include_exp/sys/socket.h +++ b/Usermode/Libraries/libpsocket.so_src/include_exp/sys/socket.h @@ -1,10 +1,9 @@ /* - * 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_ @@ -12,7 +11,7 @@ #include #include // size_t -typedef int socklen_t; +typedef uint32_t socklen_t; typedef enum { @@ -28,17 +27,35 @@ struct sockaddr 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 { @@ -49,6 +66,18 @@ 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 @@ -80,5 +109,8 @@ extern int recv(int sockfd, void *buffer, size_t length, int flags); 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 diff --git a/Usermode/Libraries/libpsocket.so_src/include_exp/sys/un.h b/Usermode/Libraries/libpsocket.so_src/include_exp/sys/un.h new file mode 100644 index 00000000..e932016b --- /dev/null +++ b/Usermode/Libraries/libpsocket.so_src/include_exp/sys/un.h @@ -0,0 +1,21 @@ +/* + * 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 +