Remove mxmpp.
This commit is contained in:
parent
1a92a6991d
commit
b08455c4d3
4
Makefile
4
Makefile
|
@ -3,7 +3,7 @@ MAKEFILE_NOT_MEANT_FOR_SORTIX=1
|
||||||
include compiler.mak
|
include compiler.mak
|
||||||
include version.mak
|
include version.mak
|
||||||
|
|
||||||
MODULES=doc libc libm dispd games mkinitrd mxmpp utils bench ext mbr kernel
|
MODULES=doc libc libm dispd games mkinitrd utils bench ext mbr kernel
|
||||||
|
|
||||||
ifndef SYSROOT
|
ifndef SYSROOT
|
||||||
SYSROOT:=$(shell pwd)/sysroot
|
SYSROOT:=$(shell pwd)/sysroot
|
||||||
|
@ -35,13 +35,11 @@ all: sysroot
|
||||||
.PHONY: build-tools
|
.PHONY: build-tools
|
||||||
build-tools:
|
build-tools:
|
||||||
$(MAKE) -C mkinitrd
|
$(MAKE) -C mkinitrd
|
||||||
$(MAKE) -C mxmpp
|
|
||||||
$(MAKE) -C tix
|
$(MAKE) -C tix
|
||||||
|
|
||||||
.PHONY: install-build-tools
|
.PHONY: install-build-tools
|
||||||
install-build-tools:
|
install-build-tools:
|
||||||
$(MAKE) -C mkinitrd install
|
$(MAKE) -C mkinitrd install
|
||||||
$(MAKE) -C mxmpp install
|
|
||||||
$(MAKE) -C tix install
|
$(MAKE) -C tix install
|
||||||
|
|
||||||
.PHONY: sysroot-fsh
|
.PHONY: sysroot-fsh
|
||||||
|
|
|
@ -174,7 +174,6 @@ Sortix comes with a number of home-made programs. Here is an overview:
|
||||||
* `mkdir` - create directory
|
* `mkdir` - create directory
|
||||||
* `mkinitrd` - create an initrd
|
* `mkinitrd` - create an initrd
|
||||||
* `mv` - move a file
|
* `mv` - move a file
|
||||||
* `mxmpp` - silly preprocessor
|
|
||||||
* `mxsh` - the shell
|
* `mxsh` - the shell
|
||||||
* `pager` - display file page by page
|
* `pager` - display file page by page
|
||||||
* `pong` - remake of the classic pong game
|
* `pong` - remake of the classic pong game
|
||||||
|
@ -514,16 +513,6 @@ filesystem and mounts it at an empty directory.
|
||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
|
|
||||||
### Building mxmpp ###
|
|
||||||
|
|
||||||
The program mxmpp is a simple and hacky macro preprocessor. It supports a special
|
|
||||||
@incude(foo_t.h) directive, which is used to pre-preprocess the headers in the C
|
|
||||||
library to avoid the overhead of repeated declarations.
|
|
||||||
|
|
||||||
cd /src/mxmpp
|
|
||||||
make
|
|
||||||
make install
|
|
||||||
|
|
||||||
### Building mkinitrd ###
|
### Building mkinitrd ###
|
||||||
|
|
||||||
This program produces a Sortix compatible initrd, the file that contains the
|
This program produces a Sortix compatible initrd, the file that contains the
|
||||||
|
|
|
@ -9,7 +9,7 @@ endif
|
||||||
|
|
||||||
CPUDIR:=$(CPU)
|
CPUDIR:=$(CPU)
|
||||||
|
|
||||||
CPPINCLUDES=-I preproc
|
CPPINCLUDES=-Iinclude
|
||||||
CPPFLAGS=-D__is_sortix_libc $(CPPINCLUDES)
|
CPPFLAGS=-D__is_sortix_libc $(CPPINCLUDES)
|
||||||
FLAGS=-Wall -Wextra $(OPTLEVEL)
|
FLAGS=-Wall -Wextra $(OPTLEVEL)
|
||||||
CFLAGS=-std=gnu99
|
CFLAGS=-std=gnu99
|
||||||
|
@ -509,12 +509,7 @@ crtn.o \
|
||||||
MISCOBJ=\
|
MISCOBJ=\
|
||||||
$(CRTOBJ) \
|
$(CRTOBJ) \
|
||||||
|
|
||||||
UNPROCHEADERDIRS:=$(shell find include -type d)
|
HEADERS:=$(shell find include -type d)
|
||||||
UNPROCHEADERS:=$(shell find include -type f)
|
|
||||||
HEADERDIRS:=$(patsubst include%,preproc%,$(UNPROCHEADERDIRS))
|
|
||||||
HEADERS:=$(patsubst include%,preproc%,$(UNPROCHEADERS))
|
|
||||||
INSTALLHEADERDIRS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(HEADERDIRS)))
|
|
||||||
INSTALLHEADERS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(HEADERS)))
|
|
||||||
|
|
||||||
SORTIXOBJS:=$(addprefix sortix/,$(FREEOBJS))
|
SORTIXOBJS:=$(addprefix sortix/,$(FREEOBJS))
|
||||||
SORTIXCPPFLAGS:=$(CPPFLAGS) -D__is_sortix_kernel
|
SORTIXCPPFLAGS:=$(CPPFLAGS) -D__is_sortix_kernel
|
||||||
|
@ -571,15 +566,7 @@ crtn.o: $(CPUDIR)/crtn.o
|
||||||
# header preprocessing
|
# header preprocessing
|
||||||
$(OBJS) $(SORTIXOBJS): $(HEADERS)
|
$(OBJS) $(SORTIXOBJS): $(HEADERS)
|
||||||
|
|
||||||
$(HEADERDIRS):
|
headers:
|
||||||
mkdir -p $@
|
|
||||||
|
|
||||||
preproc/%: include/%
|
|
||||||
mxmpp -I decl $< -o $@
|
|
||||||
|
|
||||||
$(HEADERS): | $(HEADERDIRS)
|
|
||||||
|
|
||||||
headers: $(HEADERDIRS) $(HEADERS)
|
|
||||||
|
|
||||||
# standard library
|
# standard library
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
|
@ -600,19 +587,13 @@ sortix/%.o: %.cpp
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(wildcard *.o) $(wildcard */*.o) $(wildcard */*/*.o) $(wildcard *.a)
|
rm -f $(wildcard *.o) $(wildcard */*.o) $(wildcard */*/*.o) $(wildcard *.a)
|
||||||
rm -rf $(HEADERDIRS)
|
|
||||||
|
|
||||||
# Installation into sysroot
|
# Installation into sysroot
|
||||||
install: install-headers install-libs install-libs-kernel
|
install: install-headers install-libs install-libs-kernel
|
||||||
|
|
||||||
$(INSTALLHEADERDIRS) $(DESTDIR)$(LIBDIR):
|
$(DESTDIR)$(LIBDIR):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
$(DESTDIR)$(INCLUDEDIR)/%: preproc/%
|
|
||||||
cp $< $@
|
|
||||||
|
|
||||||
$(INSTALLHEADERS): | $(INSTALLHEADERDIRS)
|
|
||||||
|
|
||||||
$(DESTDIR)$(LIBDIR)/%: %
|
$(DESTDIR)$(LIBDIR)/%: %
|
||||||
cp -P $< $@
|
cp -P $< $@
|
||||||
|
|
||||||
|
@ -620,11 +601,11 @@ $(INSTALLLIBS): | $(DESTDIR)$(LIBDIR)
|
||||||
|
|
||||||
$(INSTALLLIBSKERNEL): | $(DESTDIR)$(LIBDIR)
|
$(INSTALLLIBSKERNEL): | $(DESTDIR)$(LIBDIR)
|
||||||
|
|
||||||
$(DESTDIR)$(INCLUDEDIR) $(DESTDIR)$(LIBDIR) $(INSTALLHEADERS): FORCE
|
install-include-dirs: headers
|
||||||
|
mkdir -p $(DESTDIR)$(INCLUDEDIR)
|
||||||
|
|
||||||
install-include-dirs: $(INSTALLHEADERDIRS)
|
install-headers: install-include-dirs headers
|
||||||
|
cp -RTv include $(DESTDIR)$(INCLUDEDIR)
|
||||||
install-headers: $(INSTALLHEADERDIRS) $(INSTALLHEADERS)
|
|
||||||
|
|
||||||
install-lib-dirs: $(DESTDIR)$(LIBDIR)
|
install-lib-dirs: $(DESTDIR)$(LIBDIR)
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
#ifndef _DIR_DECL
|
|
||||||
#define _DIR_DECL
|
|
||||||
struct dirent;
|
|
||||||
|
|
||||||
#define _DIR_REGISTERED (1<<0)
|
|
||||||
#define _DIR_ERROR (1<<1)
|
|
||||||
#define _DIR_EOF (1<<2)
|
|
||||||
typedef struct _DIR
|
|
||||||
{
|
|
||||||
void* user;
|
|
||||||
int (*read_func)(void* user, struct dirent* dirent, size_t* size);
|
|
||||||
int (*rewind_func)(void* user);
|
|
||||||
int (*fd_func)(void* user);
|
|
||||||
int (*close_func)(void* user);
|
|
||||||
void (*free_func)(struct _DIR* dir);
|
|
||||||
/* Application writers shouldn't use anything beyond this point. */
|
|
||||||
struct _DIR* prev;
|
|
||||||
struct _DIR* next;
|
|
||||||
struct dirent* entry;
|
|
||||||
size_t entrysize;
|
|
||||||
int flags;
|
|
||||||
} DIR;
|
|
||||||
#endif
|
|
|
@ -1,5 +0,0 @@
|
||||||
#ifndef _FILE_DECL
|
|
||||||
#define _FILE_DECL
|
|
||||||
typedef struct FILE FILE;
|
|
||||||
#define FILE FILE
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef NULL
|
|
||||||
#define __need_NULL
|
|
||||||
#include <stddef.h>
|
|
||||||
#endif
|
|
|
@ -1,3 +0,0 @@
|
||||||
#ifndef WCHAR_MAX
|
|
||||||
#define WCHAR_MAX __WCHAR_MAX
|
|
||||||
#endif
|
|
|
@ -1,3 +0,0 @@
|
||||||
#ifndef WCHAR_MIN
|
|
||||||
#define WCHAR_MIN __WCHAR_MIN
|
|
||||||
#endif
|
|
|
@ -1,3 +0,0 @@
|
||||||
#ifndef WEOF
|
|
||||||
#define WEOF (-1)
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _BLKCNT_T_DECL
|
|
||||||
#define _BLKCNT_T_DECL
|
|
||||||
typedef __blkcnt_t blkcnt_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _BLKSIZE_T_DECL
|
|
||||||
#define _BLKSIZE_T_DECL
|
|
||||||
typedef __blksize_t blksize_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _CLOCK_T_DECL
|
|
||||||
#define _CLOCK_T_DECL
|
|
||||||
typedef __clock_t clock_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _CLOCKID_T_DECL
|
|
||||||
#define _CLOCKID_T_DECL
|
|
||||||
typedef __clockid_t clockid_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _DEV_T_DECL
|
|
||||||
#define _DEV_T_DECL
|
|
||||||
typedef __dev_t dev_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _GID_T_DECL
|
|
||||||
#define _GID_T_DECL
|
|
||||||
typedef __gid_t gid_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _ID_T_DECL
|
|
||||||
#define _ID_T_DECL
|
|
||||||
typedef __id_t id_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _IN_ADDR_T_DECL
|
|
||||||
#define _IN_ADDR_T_DECL
|
|
||||||
typedef uint32_t in_addr_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _IN_PORT_T_DECL
|
|
||||||
#define _IN_PORT_T_DECL
|
|
||||||
typedef uint16_t in_port_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _INO_T_DECL
|
|
||||||
#define _INO_T_DECL
|
|
||||||
typedef __ino_t ino_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _INTPTR_T_DECL
|
|
||||||
#define _INTPTR_T_DECL
|
|
||||||
typedef __intptr_t intptr_t;
|
|
||||||
#endif
|
|
|
@ -1,7 +0,0 @@
|
||||||
#ifndef _LOCALE_T_DECL
|
|
||||||
#define _LOCALT_T_DECL
|
|
||||||
/* TODO: figure out what this does and typedef it properly. This is just a
|
|
||||||
temporary assignment. */
|
|
||||||
typedef int __locale_t;
|
|
||||||
typedef __locale_t locale_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _MODE_T_DECL
|
|
||||||
#define _MODE_T_DECL
|
|
||||||
typedef __mode_t mode_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _NLINK_T_DECL
|
|
||||||
#define _NLINK_T_DECL
|
|
||||||
typedef __nlink_t nlink_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _OFF_T_DECL
|
|
||||||
#define _OFF_T_DECL
|
|
||||||
typedef __off_t off_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _PID_T_DECL
|
|
||||||
#define _PID_T_DECL
|
|
||||||
typedef __pid_t pid_t;
|
|
||||||
#endif
|
|
|
@ -1,2 +0,0 @@
|
||||||
#define __need_ptrdiff_t
|
|
||||||
#include <stddef.h>
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _SA_FAMILY_T_DECL
|
|
||||||
#define _SA_FAMILY_T_DECL
|
|
||||||
typedef unsigned short int sa_family_t;
|
|
||||||
#endif
|
|
|
@ -1,2 +0,0 @@
|
||||||
#define __need_size_t
|
|
||||||
#include <stddef.h>
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _SOCKLEN_T_DECL
|
|
||||||
#define _SOCKLEN_T_DECL
|
|
||||||
typedef __socklen_t socklen_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _SSIZE_T_DECL
|
|
||||||
#define _SSIZE_T_DECL
|
|
||||||
typedef __ssize_t ssize_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _SUSECONDS_T_DECL
|
|
||||||
#define _SUSECONDS_T_DECL
|
|
||||||
typedef __suseconds_t suseconds_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _TIME_T_DECL
|
|
||||||
#define _TIME_T_DECL
|
|
||||||
typedef __time_t time_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _TIMER_T_DECL
|
|
||||||
#define _TIMER_T_DECL
|
|
||||||
typedef __timer_t timer_t;
|
|
||||||
#endif
|
|
|
@ -1,8 +0,0 @@
|
||||||
#ifndef _TIMEVAL_T_DECL
|
|
||||||
#define _TIMEVAL_T_DECL
|
|
||||||
struct timeval
|
|
||||||
{
|
|
||||||
time_t tv_sec;
|
|
||||||
suseconds_t tv_usec;
|
|
||||||
};
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _UID_T_DECL
|
|
||||||
#define _UID_T_DECL
|
|
||||||
typedef __uid_t uid_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _USECONDS_T_DECL
|
|
||||||
#define _USECONDS_T_DECL
|
|
||||||
typedef __useconds_t useconds_t;
|
|
||||||
#endif
|
|
|
@ -1,9 +0,0 @@
|
||||||
#ifndef _VALIST_DECL
|
|
||||||
#define _VALIST_DECL
|
|
||||||
#define va_start(v,l) __builtin_va_start(v,l)
|
|
||||||
#define va_arg(v,l) __builtin_va_arg(v,l)
|
|
||||||
#define va_end(v) __builtin_va_end(v)
|
|
||||||
#define va_copy(d,s) __builtin_va_copy(d,s)
|
|
||||||
typedef __builtin_va_list __gnuc_va_list;
|
|
||||||
typedef __gnuc_va_list va_list;
|
|
||||||
#endif
|
|
|
@ -1,2 +0,0 @@
|
||||||
#define __need_wchar_t
|
|
||||||
#include <stddef.h>
|
|
|
@ -1,7 +0,0 @@
|
||||||
#ifndef _WCTRANS_T_DECL
|
|
||||||
#define _WCTRANS_T_DECL
|
|
||||||
/* TODO: figure out what this does and typedef it properly. This is just a
|
|
||||||
temporary assignment. */
|
|
||||||
typedef unsigned int __wctrans_t;
|
|
||||||
typedef __wctrans_t wctrans_t;
|
|
||||||
#endif
|
|
|
@ -1,4 +0,0 @@
|
||||||
#ifndef _WCTYPE_T_DECL
|
|
||||||
#define _WCTYPE_T_DECL
|
|
||||||
typedef int (*wctype_t)(wint_t);
|
|
||||||
#endif
|
|
|
@ -1,5 +0,0 @@
|
||||||
#ifndef _WINT_T_DECL
|
|
||||||
#define _WINT_T_DECL
|
|
||||||
typedef int __wint_t;
|
|
||||||
typedef __wint_t wint_t;
|
|
||||||
#endif
|
|
|
@ -31,9 +31,22 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(off_t.h)
|
#ifndef __off_t_defined
|
||||||
@include(size_t.h)
|
#define __off_t_defined
|
||||||
@include(FILE.h)
|
typedef __off_t off_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __FILE_defined
|
||||||
|
#define __FILE_defined
|
||||||
|
typedef struct FILE FILE;
|
||||||
|
#define FILE FILE
|
||||||
|
#endif
|
||||||
|
|
||||||
#define _FILE_REGISTERED (1<<0)
|
#define _FILE_REGISTERED (1<<0)
|
||||||
#define _FILE_BUFFER_MODE_SET (1<<1)
|
#define _FILE_BUFFER_MODE_SET (1<<1)
|
||||||
|
|
|
@ -31,7 +31,11 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(size_t.h)
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If somehow another declaration of alloca happened. This shouldn't happen, but
|
/* If somehow another declaration of alloca happened. This shouldn't happen, but
|
||||||
glibc does this and we might as well do it also. */
|
glibc does this and we might as well do it also. */
|
||||||
|
|
|
@ -31,9 +31,40 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(ino_t.h)
|
#ifndef __ino_t_defined
|
||||||
@include(size_t.h)
|
#define __ino_t_defined
|
||||||
@include(DIR.h)
|
typedef __ino_t ino_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __DIR_defined
|
||||||
|
#define __DIR_defined
|
||||||
|
struct dirent;
|
||||||
|
|
||||||
|
#define _DIR_REGISTERED (1<<0)
|
||||||
|
#define _DIR_ERROR (1<<1)
|
||||||
|
#define _DIR_EOF (1<<2)
|
||||||
|
typedef struct _DIR
|
||||||
|
{
|
||||||
|
void* user;
|
||||||
|
int (*read_func)(void* user, struct dirent* dirent, size_t* size);
|
||||||
|
int (*rewind_func)(void* user);
|
||||||
|
int (*fd_func)(void* user);
|
||||||
|
int (*close_func)(void* user);
|
||||||
|
void (*free_func)(struct _DIR* dir);
|
||||||
|
/* Application writers shouldn't use anything beyond this point. */
|
||||||
|
struct _DIR* prev;
|
||||||
|
struct _DIR* next;
|
||||||
|
struct dirent* entry;
|
||||||
|
size_t entrysize;
|
||||||
|
int flags;
|
||||||
|
} DIR;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct dirent
|
struct dirent
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,7 +59,10 @@ __BEGIN_DECLS
|
||||||
|
|
||||||
/* TODO: POSIX_FADV_* missing here */
|
/* TODO: POSIX_FADV_* missing here */
|
||||||
|
|
||||||
@include(pid_t.h)
|
#ifndef __pid_t_defined
|
||||||
|
#define __pid_t_defined
|
||||||
|
typedef __pid_t pid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct flock
|
struct flock
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,9 +31,22 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(FILE.h)
|
#ifndef __FILE_defined
|
||||||
@include(gid_t.h)
|
#define __FILE_defined
|
||||||
@include(size_t.h)
|
typedef struct FILE FILE;
|
||||||
|
#define FILE FILE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __gid_t_defined
|
||||||
|
#define __gid_t_defined
|
||||||
|
typedef __gid_t gid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct group
|
struct group
|
||||||
{
|
{
|
||||||
|
|
|
@ -201,7 +201,11 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(wchar_t.h)
|
#ifndef __wchar_t_defined
|
||||||
|
#define __wchar_t_defined
|
||||||
|
#define __need_wchar_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,8 +34,16 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(off_t.h)
|
#ifndef __off_t_defined
|
||||||
@include(size_t.h)
|
#define __off_t_defined
|
||||||
|
typedef __off_t off_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t preadall(int fd, void* buf, size_t count, off_t off);
|
size_t preadall(int fd, void* buf, size_t count, off_t off);
|
||||||
size_t preadleast(int fd, void* buf, size_t least, size_t max, off_t off);
|
size_t preadleast(int fd, void* buf, size_t least, size_t max, off_t off);
|
||||||
|
|
|
@ -33,9 +33,20 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(in_port_t.h)
|
#ifndef __in_port_t_defined
|
||||||
@include(in_addr_t.h)
|
#define __in_port_t_defined
|
||||||
@include(socklen_t.h)
|
typedef uint16_t in_port_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __in_addr_t_defined
|
||||||
|
#define __in_addr_t_defined
|
||||||
|
typedef uint32_t in_addr_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __socklen_t_defined
|
||||||
|
#define __socklen_t_defined
|
||||||
|
typedef __socklen_t socklen_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct hostent
|
struct hostent
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,10 +34,25 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(in_port_t.h)
|
#ifndef __in_port_t_defined
|
||||||
@include(in_addr_t.h)
|
#define __in_port_t_defined
|
||||||
@include(sa_family_t.h)
|
typedef uint16_t in_port_t;
|
||||||
@include(socklen_t.h)
|
#endif
|
||||||
|
|
||||||
|
#ifndef __in_addr_t_defined
|
||||||
|
#define __in_addr_t_defined
|
||||||
|
typedef uint32_t in_addr_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __sa_family_t_defined
|
||||||
|
#define __sa_family_t_defined
|
||||||
|
typedef unsigned short int sa_family_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __socklen_t_defined
|
||||||
|
#define __socklen_t_defined
|
||||||
|
typedef __socklen_t socklen_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct in_addr
|
struct in_addr
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,10 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(time_t.h)
|
#ifndef __time_t_defined
|
||||||
|
#define __time_t_defined
|
||||||
|
typedef __time_t time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
#include <sortix/poll.h>
|
#include <sortix/poll.h>
|
||||||
|
|
|
@ -31,10 +31,27 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(FILE.h)
|
#ifndef __FILE_defined
|
||||||
@include(gid_t.h)
|
#define __FILE_defined
|
||||||
@include(size_t.h)
|
typedef struct FILE FILE;
|
||||||
@include(uid_t.h)
|
#define FILE FILE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __gid_t_defined
|
||||||
|
#define __gid_t_defined
|
||||||
|
typedef __gid_t gid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __uid_t_defined
|
||||||
|
#define __uid_t_defined
|
||||||
|
typedef __uid_t uid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct passwd
|
struct passwd
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,11 +33,28 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(uid_t.h)
|
#ifndef __uid_t_defined
|
||||||
@include(pid_t.h)
|
#define __uid_t_defined
|
||||||
@include(size_t.h)
|
typedef __uid_t uid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __pid_t_defined
|
||||||
|
#define __pid_t_defined
|
||||||
|
typedef __pid_t pid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* TODO: POSIX says this header declares struct timespec, but not time_t... */
|
/* TODO: POSIX says this header declares struct timespec, but not time_t... */
|
||||||
@include(time_t.h)
|
#ifndef __time_t_defined
|
||||||
|
#define __time_t_defined
|
||||||
|
typedef __time_t time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* TODO: pthread_t */
|
/* TODO: pthread_t */
|
||||||
/* TODO: pthread_attr_t */
|
/* TODO: pthread_attr_t */
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,32 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(off_t.h)
|
#ifndef __off_t_defined
|
||||||
@include(size_t.h)
|
#define __off_t_defined
|
||||||
@include(ssize_t.h)
|
typedef __off_t off_t;
|
||||||
@include(NULL.h)
|
#endif
|
||||||
@include(FILE.h)
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __ssize_t_defined
|
||||||
|
#define __ssize_t_defined
|
||||||
|
typedef __ssize_t ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define __need_NULL
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __FILE_defined
|
||||||
|
#define __FILE_defined
|
||||||
|
typedef struct FILE FILE;
|
||||||
|
#define FILE FILE
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef off_t fpos_t;
|
typedef off_t fpos_t;
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,22 @@ typedef struct
|
||||||
long long rem;
|
long long rem;
|
||||||
} lldiv_t;
|
} lldiv_t;
|
||||||
|
|
||||||
@include(NULL.h)
|
#ifndef NULL
|
||||||
@include(size_t.h)
|
#define __need_NULL
|
||||||
@include(wchar_t.h)
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __wchar_t_defined
|
||||||
|
#define __wchar_t_defined
|
||||||
|
#define __need_wchar_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
void abort(void) __attribute__ ((__noreturn__));
|
void abort(void) __attribute__ ((__noreturn__));
|
||||||
int abs(int value);
|
int abs(int value);
|
||||||
|
|
|
@ -33,9 +33,24 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(NULL.h)
|
#ifndef NULL
|
||||||
@include(size_t.h)
|
#define __need_NULL
|
||||||
@include(locale_t.h)
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __locale_t_defined
|
||||||
|
#define __locale_t_defined
|
||||||
|
/* TODO: figure out what this does and typedef it properly. This is just a
|
||||||
|
temporary assignment. */
|
||||||
|
typedef int __locale_t;
|
||||||
|
typedef __locale_t locale_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
int ffs(int);
|
int ffs(int);
|
||||||
int ffsl(long int);
|
int ffsl(long int);
|
||||||
|
|
|
@ -31,8 +31,16 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(size_t.h)
|
#ifndef __size_t_defined
|
||||||
@include(ssize_t.h)
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __ssize_t_defined
|
||||||
|
#define __ssize_t_defined
|
||||||
|
typedef __ssize_t ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
ssize_t kernelinfo(const char* req, char* resp, size_t resplen);
|
ssize_t kernelinfo(const char* req, char* resp, size_t resplen);
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,21 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(mode_t.h)
|
#ifndef __mode_t_defined
|
||||||
@include(off_t.h)
|
#define __mode_t_defined
|
||||||
@include(size_t.h)
|
typedef __mode_t mode_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __off_t_defined
|
||||||
|
#define __off_t_defined
|
||||||
|
typedef __off_t off_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
void* mmap(void*, size_t, int, int, int, off_t);
|
void* mmap(void*, size_t, int, int, int, off_t);
|
||||||
int mprotect(const void*, size_t, int);
|
int mprotect(const void*, size_t, int);
|
||||||
|
|
|
@ -36,7 +36,11 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(size_t.h)
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
ssize_t readdirents(int fd, struct kernel_dirent* dirent, size_t size);
|
ssize_t readdirents(int fd, struct kernel_dirent* dirent, size_t size);
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,34 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(id_t.h)
|
#ifndef __id_t_defined
|
||||||
@include(pid_t.h)
|
#define __id_t_defined
|
||||||
@include(time_t.h)
|
typedef __id_t id_t;
|
||||||
@include(suseconds_t.h)
|
#endif
|
||||||
@include(timeval.h)
|
|
||||||
|
#ifndef __pid_t_defined
|
||||||
|
#define __pid_t_defined
|
||||||
|
typedef __pid_t pid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __time_t_defined
|
||||||
|
#define __time_t_defined
|
||||||
|
typedef __time_t time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __suseconds_t_defined
|
||||||
|
#define __suseconds_t_defined
|
||||||
|
typedef __suseconds_t suseconds_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __timeval_defined
|
||||||
|
#define __timeval_defined
|
||||||
|
struct timeval
|
||||||
|
{
|
||||||
|
time_t tv_sec;
|
||||||
|
suseconds_t tv_usec;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#define RUSAGE_SELF 0
|
#define RUSAGE_SELF 0
|
||||||
#define RUSAGE_CHILDREN 1
|
#define RUSAGE_CHILDREN 1
|
||||||
|
|
|
@ -34,9 +34,24 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(time_t.h)
|
#ifndef __time_t_defined
|
||||||
@include(suseconds_t.h)
|
#define __time_t_defined
|
||||||
@include(timeval.h)
|
typedef __time_t time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __suseconds_t_defined
|
||||||
|
#define __suseconds_t_defined
|
||||||
|
typedef __suseconds_t suseconds_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __timeval_defined
|
||||||
|
#define __timeval_defined
|
||||||
|
struct timeval
|
||||||
|
{
|
||||||
|
time_t tv_sec;
|
||||||
|
suseconds_t tv_usec;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
#include <sortix/sigset.h>
|
#include <sortix/sigset.h>
|
||||||
|
|
|
@ -33,10 +33,26 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(socklen_t.h)
|
#ifndef __socklen_t_defined
|
||||||
@include(size_t.h)
|
#define __socklen_t_defined
|
||||||
@include(ssize_t.h)
|
typedef __socklen_t socklen_t;
|
||||||
@include(sa_family_t.h)
|
#endif
|
||||||
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __ssize_t_defined
|
||||||
|
#define __ssize_t_defined
|
||||||
|
typedef __ssize_t ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __sa_family_t_defined
|
||||||
|
#define __sa_family_t_defined
|
||||||
|
typedef unsigned short int sa_family_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -30,16 +30,57 @@
|
||||||
#include <sys/__/types.h>
|
#include <sys/__/types.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
@include(blkcnt_t.h)
|
|
||||||
@include(blksize_t.h)
|
#ifndef __blkcnt_t_defined
|
||||||
@include(dev_t.h)
|
#define __blkcnt_t_defined
|
||||||
@include(ino_t.h)
|
typedef __blkcnt_t blkcnt_t;
|
||||||
@include(mode_t.h)
|
#endif
|
||||||
@include(nlink_t.h)
|
|
||||||
@include(uid_t.h)
|
#ifndef __blksize_t_defined
|
||||||
@include(gid_t.h)
|
#define __blksize_t_defined
|
||||||
@include(off_t.h)
|
typedef __blksize_t blksize_t;
|
||||||
@include(time_t.h)
|
#endif
|
||||||
|
|
||||||
|
#ifndef __dev_t_defined
|
||||||
|
#define __dev_t_defined
|
||||||
|
typedef __dev_t dev_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __ino_t_defined
|
||||||
|
#define __ino_t_defined
|
||||||
|
typedef __ino_t ino_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __mode_t_defined
|
||||||
|
#define __mode_t_defined
|
||||||
|
typedef __mode_t mode_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __nlink_t_defined
|
||||||
|
#define __nlink_t_defined
|
||||||
|
typedef __nlink_t nlink_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __uid_t_defined
|
||||||
|
#define __uid_t_defined
|
||||||
|
typedef __uid_t uid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __gid_t_defined
|
||||||
|
#define __gid_t_defined
|
||||||
|
typedef __gid_t gid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __off_t_defined
|
||||||
|
#define __off_t_defined
|
||||||
|
typedef __off_t off_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __time_t_defined
|
||||||
|
#define __time_t_defined
|
||||||
|
typedef __time_t time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
#include <sortix/timespec.h>
|
#include <sortix/timespec.h>
|
||||||
|
|
|
@ -31,9 +31,24 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(time_t.h)
|
#ifndef __time_t_defined
|
||||||
@include(suseconds_t.h)
|
#define __time_t_defined
|
||||||
@include(timeval.h)
|
typedef __time_t time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __suseconds_t_defined
|
||||||
|
#define __suseconds_t_defined
|
||||||
|
typedef __suseconds_t suseconds_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __timeval_defined
|
||||||
|
#define __timeval_defined
|
||||||
|
struct timeval
|
||||||
|
{
|
||||||
|
time_t tv_sec;
|
||||||
|
suseconds_t tv_usec;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
int gettimeofday(struct timeval* __restrict tp, void* __restrict tzp);
|
int gettimeofday(struct timeval* __restrict tp, void* __restrict tzp);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,10 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(clock_t.h);
|
#ifndef __clock_t_defined
|
||||||
|
#define __clock_t_defined
|
||||||
|
typedef __clock_t clock_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct tms
|
struct tms
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,29 +33,109 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(blkcnt_t.h)
|
#ifndef __blkcnt_t_defined
|
||||||
@include(blksize_t.h)
|
#define __blkcnt_t_defined
|
||||||
@include(clock_t.h)
|
typedef __blkcnt_t blkcnt_t;
|
||||||
@include(clockid_t.h)
|
#endif
|
||||||
@include(dev_t.h)
|
|
||||||
|
#ifndef __blksize_t_defined
|
||||||
|
#define __blksize_t_defined
|
||||||
|
typedef __blksize_t blksize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __clock_t_defined
|
||||||
|
#define __clock_t_defined
|
||||||
|
typedef __clock_t clock_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __clockid_t_defined
|
||||||
|
#define __clockid_t_defined
|
||||||
|
typedef __clockid_t clockid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __dev_t_defined
|
||||||
|
#define __dev_t_defined
|
||||||
|
typedef __dev_t dev_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* TODO: fsblkcnt_t */
|
/* TODO: fsblkcnt_t */
|
||||||
|
|
||||||
/* TODO: fsfilcnt_t */
|
/* TODO: fsfilcnt_t */
|
||||||
@include(gid_t.h)
|
|
||||||
@include(id_t.h)
|
#ifndef __gid_t_defined
|
||||||
@include(ino_t.h)
|
#define __gid_t_defined
|
||||||
|
typedef __gid_t gid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __id_t_defined
|
||||||
|
#define __id_t_defined
|
||||||
|
typedef __id_t id_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __ino_t_defined
|
||||||
|
#define __ino_t_defined
|
||||||
|
typedef __ino_t ino_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* TODO: key_t */
|
/* TODO: key_t */
|
||||||
@include(mode_t.h)
|
|
||||||
@include(nlink_t.h)
|
#ifndef __mode_t_defined
|
||||||
@include(off_t.h)
|
#define __mode_t_defined
|
||||||
@include(pid_t.h)
|
typedef __mode_t mode_t;
|
||||||
@include(size_t.h)
|
#endif
|
||||||
@include(ssize_t.h)
|
|
||||||
@include(suseconds_t.h)
|
#ifndef __nlink_t_defined
|
||||||
@include(time_t.h)
|
#define __nlink_t_defined
|
||||||
@include(timer_t.h)
|
typedef __nlink_t nlink_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __off_t_defined
|
||||||
|
#define __off_t_defined
|
||||||
|
typedef __off_t off_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __pid_t_defined
|
||||||
|
#define __pid_t_defined
|
||||||
|
typedef __pid_t pid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __size_t_defined
|
||||||
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __ssize_t_defined
|
||||||
|
#define __ssize_t_defined
|
||||||
|
typedef __ssize_t ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __suseconds_t_defined
|
||||||
|
#define __suseconds_t_defined
|
||||||
|
typedef __suseconds_t suseconds_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __time_t_defined
|
||||||
|
#define __time_t_defined
|
||||||
|
typedef __time_t time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __timer_t_defined
|
||||||
|
#define __timer_t_defined
|
||||||
|
typedef __timer_t timer_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* TODO: trace*_t */
|
/* TODO: trace*_t */
|
||||||
@include(uid_t.h)
|
|
||||||
@include(useconds_t.h)
|
#ifndef __uid_t_defined
|
||||||
|
#define __uid_t_defined
|
||||||
|
typedef __uid_t uid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __useconds_t_defined
|
||||||
|
#define __useconds_t_defined
|
||||||
|
typedef __useconds_t useconds_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(__is_sortix_kernel)
|
#if !defined(__is_sortix_kernel)
|
||||||
/* TODO: pthread*_t */
|
/* TODO: pthread*_t */
|
||||||
|
|
|
@ -31,9 +31,21 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(size_t.h)
|
#ifndef __size_t_defined
|
||||||
@include(ssize_t.h)
|
#define __size_t_defined
|
||||||
@include(off_t.h)
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __ssize_t_defined
|
||||||
|
#define __ssize_t_defined
|
||||||
|
typedef __ssize_t ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __off_t_defined
|
||||||
|
#define __off_t_defined
|
||||||
|
typedef __off_t off_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,10 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(sa_family_t.h)
|
#ifndef __sa_family_t_defined
|
||||||
|
#define __sa_family_t_defined
|
||||||
|
typedef unsigned short int sa_family_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct sockaddr_un
|
struct sockaddr_un
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,10 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(pid_t.h)
|
#ifndef __pid_t_defined
|
||||||
|
#define __pid_t_defined
|
||||||
|
typedef __pid_t pid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* TODO: These are not implemented in sortix libc yet. */
|
/* TODO: These are not implemented in sortix libc yet. */
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -31,13 +31,44 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(clock_t.h)
|
#ifndef __clock_t_defined
|
||||||
@include(size_t.h)
|
#define __clock_t_defined
|
||||||
@include(time_t.h)
|
typedef __clock_t clock_t;
|
||||||
@include(clockid_t.h)
|
#endif
|
||||||
@include(timer_t.h)
|
|
||||||
@include(locale_t.h)
|
#ifndef __size_t_defined
|
||||||
@include(pid_t.h)
|
#define __size_t_defined
|
||||||
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __time_t_defined
|
||||||
|
#define __time_t_defined
|
||||||
|
typedef __time_t time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __clockid_t_defined
|
||||||
|
#define __clockid_t_defined
|
||||||
|
typedef __clockid_t clockid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __timer_t_defined
|
||||||
|
#define __timer_t_defined
|
||||||
|
typedef __timer_t timer_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __locale_t_defined
|
||||||
|
#define __locale_t_defined
|
||||||
|
/* TODO: figure out what this does and typedef it properly. This is just a
|
||||||
|
temporary assignment. */
|
||||||
|
typedef int __locale_t;
|
||||||
|
typedef __locale_t locale_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __pid_t_defined
|
||||||
|
#define __pid_t_defined
|
||||||
|
typedef __pid_t pid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct sigevent;
|
struct sigevent;
|
||||||
|
|
||||||
|
@ -62,7 +93,10 @@ __END_DECLS
|
||||||
#endif
|
#endif
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(NULL.h)
|
#ifndef NULL
|
||||||
|
#define __need_NULL
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CLOCKS_PER_SEC 1000000l
|
#define CLOCKS_PER_SEC 1000000l
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,10 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(time_t.h)
|
#ifndef __time_t_defined
|
||||||
|
#define __time_t_defined
|
||||||
|
typedef __time_t time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,10 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sortix/fork.h>
|
#include <sortix/fork.h>
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
@include(time_t.h)
|
#ifndef __time_t_defined
|
||||||
|
#define __time_t_defined
|
||||||
|
typedef __time_t time_t;
|
||||||
|
#endif
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
#include <sortix/timespec.h>
|
#include <sortix/timespec.h>
|
||||||
#include <ioleast.h>
|
#include <ioleast.h>
|
||||||
|
@ -63,7 +66,10 @@ __BEGIN_DECLS
|
||||||
|
|
||||||
/* TODO: _POSIX_*, _POSIX2_* is missing here. */
|
/* TODO: _POSIX_*, _POSIX2_* is missing here. */
|
||||||
|
|
||||||
@include(NULL.h)
|
#ifndef NULL
|
||||||
|
#define __need_NULL
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define _CS_PATH 0
|
#define _CS_PATH 0
|
||||||
#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1
|
#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1
|
||||||
|
@ -253,13 +259,41 @@ __BEGIN_DECLS
|
||||||
|
|
||||||
/* TODO: _POSIX_VDISABLE is missing here. */
|
/* TODO: _POSIX_VDISABLE is missing here. */
|
||||||
|
|
||||||
@include(size_t.h)
|
#ifndef __size_t_defined
|
||||||
@include(ssize_t.h)
|
#define __size_t_defined
|
||||||
@include(uid_t.h)
|
#define __need_size_t
|
||||||
@include(gid_t.h)
|
#include <stddef.h>
|
||||||
@include(off_t.h)
|
#endif
|
||||||
@include(pid_t.h)
|
|
||||||
@include(useconds_t.h)
|
#ifndef __ssize_t_defined
|
||||||
|
#define __ssize_t_defined
|
||||||
|
typedef __ssize_t ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __uid_t_defined
|
||||||
|
#define __uid_t_defined
|
||||||
|
typedef __uid_t uid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __gid_t_defined
|
||||||
|
#define __gid_t_defined
|
||||||
|
typedef __gid_t gid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __off_t_defined
|
||||||
|
#define __off_t_defined
|
||||||
|
typedef __off_t off_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __pid_t_defined
|
||||||
|
#define __pid_t_defined
|
||||||
|
typedef __pid_t pid_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __useconds_t_defined
|
||||||
|
#define __useconds_t_defined
|
||||||
|
typedef __useconds_t useconds_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_WANT_ENVIRON)
|
#if defined(_WANT_ENVIRON)
|
||||||
extern char** environ;
|
extern char** environ;
|
||||||
|
|
|
@ -31,7 +31,10 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(time_t.h)
|
#ifndef __time_t_defined
|
||||||
|
#define __time_t_defined
|
||||||
|
typedef __time_t time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct utimbuf
|
struct utimbuf
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,17 +35,69 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(size_t.h)
|
#ifndef __size_t_defined
|
||||||
@include(off_t.h)
|
#define __size_t_defined
|
||||||
@include(FILE.h)
|
#define __need_size_t
|
||||||
@include(locale_t.h)
|
#include <stddef.h>
|
||||||
@include(va_list.h)
|
#endif
|
||||||
@include(wchar_t.h)
|
|
||||||
@include(wint_t.h)
|
#ifndef __off_t_defined
|
||||||
@include(WCHAR_MAX.h)
|
#define __off_t_defined
|
||||||
@include(WCHAR_MIN.h)
|
typedef __off_t off_t;
|
||||||
@include(WEOF.h)
|
#endif
|
||||||
@include(NULL.h)
|
|
||||||
|
#ifndef __FILE_defined
|
||||||
|
#define __FILE_defined
|
||||||
|
typedef struct FILE FILE;
|
||||||
|
#define FILE FILE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __locale_t_defined
|
||||||
|
#define __locale_t_defined
|
||||||
|
/* TODO: figure out what this does and typedef it properly. This is just a
|
||||||
|
temporary assignment. */
|
||||||
|
typedef int __locale_t;
|
||||||
|
typedef __locale_t locale_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __valist_defined
|
||||||
|
#define __valist_defined
|
||||||
|
#define va_start(v,l) __builtin_va_start(v,l)
|
||||||
|
#define va_arg(v,l) __builtin_va_arg(v,l)
|
||||||
|
#define va_end(v) __builtin_va_end(v)
|
||||||
|
#define va_copy(d,s) __builtin_va_copy(d,s)
|
||||||
|
typedef __builtin_va_list __gnuc_va_list;
|
||||||
|
typedef __gnuc_va_list va_list;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __wchar_t_defined
|
||||||
|
#define __wchar_t_defined
|
||||||
|
#define __need_wchar_t
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __wint_t_defined
|
||||||
|
#define __wint_t_defined
|
||||||
|
typedef int __wint_t;
|
||||||
|
typedef __wint_t wint_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WCHAR_MAX
|
||||||
|
#define WCHAR_MAX __WCHAR_MAX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WCHAR_MIN
|
||||||
|
#define WCHAR_MIN __WCHAR_MIN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WEOF
|
||||||
|
#define WEOF (-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define __need_NULL
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __mbstate_t_defined
|
#ifndef __mbstate_t_defined
|
||||||
/* Conversion state information. */
|
/* Conversion state information. */
|
||||||
|
|
|
@ -31,11 +31,36 @@
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
@include(wint_t.h)
|
#ifndef __wint_t_defined
|
||||||
@include(wctrans_t.h)
|
#define __wint_t_defined
|
||||||
@include(wctype_t.h)
|
typedef int __wint_t;
|
||||||
@include(locale_t.h)
|
typedef __wint_t wint_t;
|
||||||
@include(WEOF.h)
|
#endif
|
||||||
|
|
||||||
|
#ifndef __wctrans_t_defined
|
||||||
|
#define __wctrans_t_defined
|
||||||
|
/* TODO: figure out what this does and typedef it properly. This is just a
|
||||||
|
temporary assignment. */
|
||||||
|
typedef unsigned int __wctrans_t;
|
||||||
|
typedef __wctrans_t wctrans_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __wctype_t_defined
|
||||||
|
#define __wctype_t_defined
|
||||||
|
typedef int (*wctype_t)(wint_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __locale_t_defined
|
||||||
|
#define __locale_t_defined
|
||||||
|
/* TODO: figure out what this does and typedef it properly. This is just a
|
||||||
|
temporary assignment. */
|
||||||
|
typedef int __locale_t;
|
||||||
|
typedef __locale_t locale_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WEOF
|
||||||
|
#define WEOF (-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
int iswalnum(wint_t);
|
int iswalnum(wint_t);
|
||||||
int iswalpha(wint_t);
|
int iswalpha(wint_t);
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
mxmpp
|
|
|
@ -1,35 +0,0 @@
|
||||||
include ../compiler.mak
|
|
||||||
include ../version.mak
|
|
||||||
include ../dirs.mak
|
|
||||||
|
|
||||||
ifndef OPTLEVEL
|
|
||||||
OPTLEVEL=-g -O2
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef CXXFLAGS
|
|
||||||
CXXFLAGS:=$(OPTLEVEL)
|
|
||||||
endif
|
|
||||||
|
|
||||||
CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti
|
|
||||||
|
|
||||||
BINARIES=mxmpp
|
|
||||||
|
|
||||||
INSTALLBINARIES:=$(addprefix $(DESTDIR)$(BINDIR)/,$(BINARIES))
|
|
||||||
|
|
||||||
all: $(BINARIES)
|
|
||||||
|
|
||||||
.PHONY: all install uninstall clean
|
|
||||||
|
|
||||||
%: %.cpp
|
|
||||||
$(CXX) -std=gnu++11 $(CPPFLAGS) $(CXXFLAGS) $< -o $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(BINARIES)
|
|
||||||
|
|
||||||
install: all
|
|
||||||
mkdir -p $(DESTDIR)$(BINDIR)
|
|
||||||
install $(BINARIES) $(DESTDIR)$(BINDIR)
|
|
||||||
|
|
||||||
uninstall:
|
|
||||||
rm -f $(INSTALLBINARIES)
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
This is a small stupid macro processor used for building Sortix's libc.
|
|
414
mxmpp/mxmpp.cpp
414
mxmpp/mxmpp.cpp
|
@ -1,414 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2012.
|
|
||||||
|
|
||||||
This file is part of mxmpp.
|
|
||||||
|
|
||||||
mxmpp is free software: you can redistribute it and/or modify it under the
|
|
||||||
terms of the GNU General Public License as published by the Free Software
|
|
||||||
Foundation, either version 3 of the License, or (at your option) any later
|
|
||||||
version.
|
|
||||||
|
|
||||||
mxmpp is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with
|
|
||||||
mxmpp. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
mxmpp.cpp
|
|
||||||
A simple macro preprocessor.
|
|
||||||
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#ifndef S_IRGRP
|
|
||||||
#define S_IRGRP (0)
|
|
||||||
#endif
|
|
||||||
#ifndef S_IWGRP
|
|
||||||
#define S_IWGRP (0)
|
|
||||||
#endif
|
|
||||||
#ifndef S_IROTH
|
|
||||||
#define S_IROTH (0)
|
|
||||||
#endif
|
|
||||||
#ifndef S_IWOTH
|
|
||||||
#define S_IWOTH (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define writeall mxmpp_writeall
|
|
||||||
bool writeall(int fd, const void* p, size_t size)
|
|
||||||
{
|
|
||||||
const uint8_t* buffer = (const uint8_t*) p;
|
|
||||||
|
|
||||||
size_t bytesWritten = 0;
|
|
||||||
|
|
||||||
while ( bytesWritten < size )
|
|
||||||
{
|
|
||||||
ssize_t written = write(fd, buffer + bytesWritten, size - bytesWritten);
|
|
||||||
if ( written < 0 ) { perror("write"); return false; }
|
|
||||||
bytesWritten += written;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void usage(int /*argc*/, char* argv[])
|
|
||||||
{
|
|
||||||
printf("usage: %s [OPTIONS] [FILE]...\n", argv[0]);
|
|
||||||
printf("Preprocess FILE(s), or standard input.");
|
|
||||||
printf("\n");
|
|
||||||
printf("Options:\n");
|
|
||||||
printf(" -o <file> Write output to this file\n");
|
|
||||||
printf(" Default = Standard Output\n");
|
|
||||||
printf(" -I <file> Add this directory to the include search paths\n");
|
|
||||||
printf(" If no paths are set, include from working dir\n");
|
|
||||||
printf(" -q Surpress normal output\n");
|
|
||||||
printf(" -v Be verbose\n");
|
|
||||||
printf(" --usage Display this screen\n");
|
|
||||||
printf(" --help Display this screen\n");
|
|
||||||
printf(" --version Display version information\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void version()
|
|
||||||
{
|
|
||||||
printf("The Maxsi Macro PreProcessor 0.1\n");
|
|
||||||
printf("Copyright (C) 2011 Jonas 'Sortie' Termansen\n");
|
|
||||||
printf("This is free software; see the source for copying conditions. There is NO\n");
|
|
||||||
printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
|
||||||
printf("website: http://www.maxsi.org/software/mxmpp/\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct searchpath
|
|
||||||
{
|
|
||||||
const char* path;
|
|
||||||
searchpath* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct inputfile
|
|
||||||
{
|
|
||||||
const char* path;
|
|
||||||
inputfile* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
int outfd = -1;
|
|
||||||
|
|
||||||
searchpath* firstpath = NULL;
|
|
||||||
inputfile* firstfile = NULL;
|
|
||||||
|
|
||||||
const size_t CONSTRUCT_SIZE = 511;
|
|
||||||
const size_t BUFFER_SIZE = 4096;
|
|
||||||
|
|
||||||
bool verbose = false;
|
|
||||||
|
|
||||||
char* search(const char* filename);
|
|
||||||
bool include(const char* parameter);
|
|
||||||
bool expand(const char* command, const char* parameter);
|
|
||||||
bool process(int fd);
|
|
||||||
bool process(const char* path);
|
|
||||||
|
|
||||||
char* search(const char* filename)
|
|
||||||
{
|
|
||||||
size_t filenamelen = strlen(filename);
|
|
||||||
|
|
||||||
for ( searchpath* path = firstpath; path != NULL; path = path->next )
|
|
||||||
{
|
|
||||||
size_t searchpathlen = strlen(path->path);
|
|
||||||
size_t filepathlen = searchpathlen + 1 + filenamelen;
|
|
||||||
char* filepath = new char[filepathlen + 1];
|
|
||||||
strcpy(filepath, path->path);
|
|
||||||
strcpy(filepath + searchpathlen, "/");
|
|
||||||
strcpy(filepath + searchpathlen + 1, filename);
|
|
||||||
|
|
||||||
struct stat sts;
|
|
||||||
int statrs = stat(filepath, &sts);
|
|
||||||
if ( statrs < 0 && errno != ENOENT )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "error: could not stat file '%s': %s\n", filepath, strerror(errno)); return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool found = ( statrs != -1 );
|
|
||||||
|
|
||||||
if ( verbose )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "info: searching for '%s': %s\n", filepath, ( found ) ? "found" : "not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( found )
|
|
||||||
{
|
|
||||||
return filepath;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[] filepath;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool include(const char* parameter)
|
|
||||||
{
|
|
||||||
if ( parameter[0] == '\0' )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "error: @include expects a non-empty parameter\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( parameter[0] == '/' )
|
|
||||||
{
|
|
||||||
return process(parameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* included = search(parameter);
|
|
||||||
|
|
||||||
if ( included == NULL )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "error: could not find included file '%s'\n", parameter);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool result = process(included);
|
|
||||||
delete[] included;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool expand(const char* command, const char* parameter)
|
|
||||||
{
|
|
||||||
if ( strcmp(command, "@include") == 0 )
|
|
||||||
{
|
|
||||||
return include(parameter);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "error: unknown macro command %s\n", command);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool process(int fd)
|
|
||||||
{
|
|
||||||
char construct[CONSTRUCT_SIZE+1];
|
|
||||||
char buffer[BUFFER_SIZE];
|
|
||||||
size_t constructed = 0;
|
|
||||||
int phase = 0;
|
|
||||||
|
|
||||||
const char* command = NULL;
|
|
||||||
const char* parameter = NULL;
|
|
||||||
|
|
||||||
bool quote = false;
|
|
||||||
bool backslash = false;
|
|
||||||
|
|
||||||
while ( true )
|
|
||||||
{
|
|
||||||
ssize_t numread = read(fd, buffer, BUFFER_SIZE);
|
|
||||||
if ( numread == 0 ) { break; }
|
|
||||||
if ( numread < 0 ) { perror("read"); return false; }
|
|
||||||
size_t writefrom = 0;
|
|
||||||
|
|
||||||
for ( ssize_t i = 0; i < numread; i++ )
|
|
||||||
{
|
|
||||||
if ( constructed == 0 )
|
|
||||||
{
|
|
||||||
if ( buffer[i] == '\\' ) { backslash = !backslash; continue; }
|
|
||||||
if ( buffer[i] == '"' && !backslash ) { quote = !quote; }
|
|
||||||
if ( buffer[i] == '@' && !quote )
|
|
||||||
{
|
|
||||||
if ( i - writefrom > 0 )
|
|
||||||
{
|
|
||||||
if ( !writeall(outfd, buffer + writefrom, i - writefrom) ) { return false; }
|
|
||||||
}
|
|
||||||
construct[0] = '@'; constructed++;
|
|
||||||
}
|
|
||||||
backslash = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( phase == 0 )
|
|
||||||
{
|
|
||||||
if ( ( ('a' <= buffer[i] && buffer[i] <= 'z' ) ||
|
|
||||||
('A' <= buffer[i] && buffer[i] <= 'Z' ) ) &&
|
|
||||||
( constructed < CONSTRUCT_SIZE) )
|
|
||||||
{
|
|
||||||
construct[constructed] = buffer[i]; constructed++;
|
|
||||||
}
|
|
||||||
else if ( buffer[i] == '(' )
|
|
||||||
{
|
|
||||||
construct[constructed] = '\0'; constructed++;
|
|
||||||
command = construct;
|
|
||||||
parameter = construct + constructed;
|
|
||||||
phase++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
construct[constructed] = '\0';
|
|
||||||
fprintf(stderr, "error: expected '(' after '%s'\n", construct);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( phase == 1 )
|
|
||||||
{
|
|
||||||
if ( buffer[i] == ')' )
|
|
||||||
{
|
|
||||||
construct[constructed] = '\0';
|
|
||||||
if ( !expand(command, parameter) ) { return false; }
|
|
||||||
phase = 0;
|
|
||||||
constructed = 0;
|
|
||||||
writefrom = i + 1;
|
|
||||||
}
|
|
||||||
else if ( buffer[i] != '\n' && buffer[i] != '\r' && constructed < CONSTRUCT_SIZE )
|
|
||||||
{
|
|
||||||
construct[constructed] = buffer[i]; constructed++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
construct[constructed] = '\0';
|
|
||||||
fprintf(stderr, "error: expected ')' after '%s'\n", parameter);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( constructed == 0 && numread - writefrom > 0 )
|
|
||||||
{
|
|
||||||
if ( !writeall(outfd, buffer + writefrom, numread - writefrom) ) { return false; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool process(const char* path)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
if ( strcmp(path, "-") == 0 ) { fd = 0; }
|
|
||||||
else if ( (fd = open(path, O_RDONLY) ) < 0 )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "error: couldn't open file '%s'\n", path); return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( verbose )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "info: including file '%s'\n", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool result = process(fd);
|
|
||||||
|
|
||||||
if ( verbose )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "info: end of file '%s'\n", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( close(fd) < 0 )
|
|
||||||
{
|
|
||||||
perror("close"); return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
const char* dest = NULL;
|
|
||||||
searchpath* lastpath = NULL;
|
|
||||||
inputfile* lastfile = NULL;
|
|
||||||
|
|
||||||
for ( int i = 1; i < argc; i++ )
|
|
||||||
{
|
|
||||||
if ( strcmp(argv[i], "-I") == 0 )
|
|
||||||
{
|
|
||||||
if ( 2 <= argc - i )
|
|
||||||
{
|
|
||||||
searchpath* path = new searchpath();
|
|
||||||
path->path = argv[i+1];
|
|
||||||
path->next = NULL;
|
|
||||||
if ( firstpath == NULL ) { firstpath = path; } else { lastpath->next = path; }
|
|
||||||
lastpath = path;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( strcmp(argv[i], "-o") == 0 )
|
|
||||||
{
|
|
||||||
if ( 2 <= argc - i )
|
|
||||||
{
|
|
||||||
dest = argv[i+1];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( strcmp(argv[i], "-v") == 0 )
|
|
||||||
{
|
|
||||||
verbose = true;
|
|
||||||
}
|
|
||||||
else if ( strcmp(argv[i], "-q") == 0 )
|
|
||||||
{
|
|
||||||
verbose = false;
|
|
||||||
}
|
|
||||||
else if ( strcmp(argv[i], "--help") == 0 )
|
|
||||||
{
|
|
||||||
usage(argc, argv);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if ( strcmp(argv[i], "--usage") == 0 )
|
|
||||||
{
|
|
||||||
usage(argc, argv);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if ( strcmp(argv[i], "--version") == 0 )
|
|
||||||
{
|
|
||||||
version();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
inputfile* file = new inputfile();
|
|
||||||
file->path = argv[i];
|
|
||||||
file->next = NULL;
|
|
||||||
if ( firstfile == NULL ) { firstfile = file; } else { lastfile->next = file; }
|
|
||||||
lastfile = file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( dest == NULL || strcmp(dest, "-") == 0 ) { outfd = 1; }
|
|
||||||
else if ( (outfd = open(dest, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) ) < 0 )
|
|
||||||
{
|
|
||||||
fprintf(stderr, "error: couldn't open file '%s'\n", dest); return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( firstpath == NULL )
|
|
||||||
{
|
|
||||||
firstpath = new searchpath;
|
|
||||||
firstpath->path = ".";
|
|
||||||
firstpath->next = NULL;
|
|
||||||
lastpath = firstpath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( firstfile == NULL )
|
|
||||||
{
|
|
||||||
firstfile = new inputfile;
|
|
||||||
firstfile->path = "-";
|
|
||||||
firstfile->next = NULL;
|
|
||||||
lastfile = firstfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
inputfile* tmp = firstfile;
|
|
||||||
while ( tmp != NULL )
|
|
||||||
{
|
|
||||||
if ( !process(tmp->path) ) { return 1; }
|
|
||||||
tmp = tmp->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( close(outfd) < 0 )
|
|
||||||
{
|
|
||||||
perror("close"); return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -23,7 +23,6 @@ clean:
|
||||||
$(MAKE) -B -C $(SRCDIR)/bench clean
|
$(MAKE) -B -C $(SRCDIR)/bench clean
|
||||||
$(MAKE) -B -C $(SRCDIR)/games clean
|
$(MAKE) -B -C $(SRCDIR)/games clean
|
||||||
$(MAKE) -B -C $(SRCDIR)/mkinitrd clean
|
$(MAKE) -B -C $(SRCDIR)/mkinitrd clean
|
||||||
$(MAKE) -B -C $(SRCDIR)/mxmpp clean
|
|
||||||
$(MAKE) -B -C $(SRCDIR)/utils clean
|
$(MAKE) -B -C $(SRCDIR)/utils clean
|
||||||
$(MAKE) -B -C $(SRCDIR)/ext clean
|
$(MAKE) -B -C $(SRCDIR)/ext clean
|
||||||
$(MAKE) -B -C $(SRCDIR)/mbr clean
|
$(MAKE) -B -C $(SRCDIR)/mbr clean
|
||||||
|
@ -69,7 +68,6 @@ system:
|
||||||
$(MAKE) -B -C $(SRCDIR)/dispd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
$(MAKE) -B -C $(SRCDIR)/dispd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||||
$(MAKE) -B -C $(SRCDIR)/games install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
$(MAKE) -B -C $(SRCDIR)/games install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||||
$(MAKE) -B -C $(SRCDIR)/mkinitrd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
$(MAKE) -B -C $(SRCDIR)/mkinitrd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||||
$(MAKE) -B -C $(SRCDIR)/mxmpp install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
|
||||||
$(MAKE) -B -C $(SRCDIR)/utils install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
$(MAKE) -B -C $(SRCDIR)/utils install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||||
$(MAKE) -B -C $(SRCDIR)/bench install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
$(MAKE) -B -C $(SRCDIR)/bench install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||||
$(MAKE) -B -C $(SRCDIR)/ext install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
$(MAKE) -B -C $(SRCDIR)/ext install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib
|
||||||
|
|
Loading…
Reference in New Issue