1 | /*
|
---|
2 | * TOPPERS PROJECT Home Network Working Group Software
|
---|
3 | *
|
---|
4 | * Copyright (C) 2017-2019 Cores Co., Ltd. Japan
|
---|
5 | *
|
---|
6 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
7 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
8 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
9 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
10 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
11 | * スコード中に含まれていること.
|
---|
12 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
13 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
14 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
15 | * の無保証規定を掲載すること.
|
---|
16 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
17 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
18 | * と.
|
---|
19 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
20 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
21 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
22 | * 報告すること.
|
---|
23 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
24 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
25 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
26 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
27 | * 免責すること.
|
---|
28 | *
|
---|
29 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
30 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
31 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
32 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
33 | * の責任を負わない.
|
---|
34 | *
|
---|
35 | * @(#) $Id$
|
---|
36 | */
|
---|
37 | #ifndef SHELLIF_H
|
---|
38 | #define SHELLIF_H
|
---|
39 |
|
---|
40 | #ifdef _MSC_VER
|
---|
41 | #undef NULL
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #define __NEED_off_t
|
---|
45 | #define __NEED_ssize_t
|
---|
46 | #define __NEED_size_t
|
---|
47 | #define __NEED_mode_t
|
---|
48 | #define __NEED_dev_t
|
---|
49 | #define __NEED_pid_t
|
---|
50 | #define __NEED_gid_t
|
---|
51 | #define __NEED_uid_t
|
---|
52 | #define __NEED_socklen_t
|
---|
53 | #define __NEED_nlink_t
|
---|
54 | #define __NEED_blksize_t
|
---|
55 | #define __NEED_blkcnt_t
|
---|
56 | #define __NEED_ino_t
|
---|
57 | #define __NEED_time_t
|
---|
58 | #define __NEED_suseconds_t
|
---|
59 | #define __NEED_struct_timeval
|
---|
60 | #define __NEED_struct_timespec
|
---|
61 | #define __NEED_struct_iovec
|
---|
62 | #define __NEED_clockid_t
|
---|
63 | #define __NEED_socklen_t
|
---|
64 | #define __NEED_sa_family_t
|
---|
65 | #define __NEED_sigset_t
|
---|
66 |
|
---|
67 | #ifndef _MSC_VER
|
---|
68 | #include <bits/alltypes.h>
|
---|
69 |
|
---|
70 | typedef unsigned char cc_t;
|
---|
71 | typedef unsigned int speed_t;
|
---|
72 | typedef unsigned int tcflag_t;
|
---|
73 |
|
---|
74 | #define NCCS 32
|
---|
75 |
|
---|
76 | #include <fcntl.h>
|
---|
77 | #include <termios.h>
|
---|
78 | #include <sys/stat.h>
|
---|
79 | #include <sys/select.h>
|
---|
80 | #include <time.h>
|
---|
81 | #include <limits.h>
|
---|
82 | #include <fcntl.h>
|
---|
83 | #include <signal.h>
|
---|
84 | #include <stdio.h>
|
---|
85 | #include <sys/utsname.h>
|
---|
86 | #include <dirent.h>
|
---|
87 | #include <sys/ioctl.h>
|
---|
88 | #include <errno.h>
|
---|
89 | #include <sys/socket.h>
|
---|
90 | #else
|
---|
91 | #include "../musl-1.1.18/include/bits/alltypes.h"
|
---|
92 |
|
---|
93 | typedef unsigned char cc_t;
|
---|
94 | typedef unsigned int speed_t;
|
---|
95 | typedef unsigned int tcflag_t;
|
---|
96 |
|
---|
97 | #define NCCS 32
|
---|
98 |
|
---|
99 | #include "../musl-1.1.18/include/bits/fcntl.h"
|
---|
100 | #include "../musl-1.1.18/include/bits/termios.h"
|
---|
101 | #include "../musl-1.1.18/include/bits/stat.h"
|
---|
102 | #include "../musl-1.1.18/include/sys/select.h"
|
---|
103 | #include "../musl-1.1.18/include/time.h"
|
---|
104 | #include "../musl-1.1.18/include/signal.h"
|
---|
105 | #include "../musl-1.1.18/include/stdio.h"
|
---|
106 | #include "../musl-1.1.18/include/sys/utsname.h"
|
---|
107 | #include "../musl-1.1.18/include/dirent.h"
|
---|
108 | #include "../musl-1.1.18/include/bits/ioctl.h"
|
---|
109 | #include "../musl-1.1.18/include/fcntl.h"
|
---|
110 | #include "../musl-1.1.18/include/bits/errno.h"
|
---|
111 | #include "../musl-1.1.18/include/sys/socket.h"
|
---|
112 | #endif
|
---|
113 |
|
---|
114 | #include <stddef.h>
|
---|
115 | #include <stdarg.h>
|
---|
116 |
|
---|
117 | #if !defined(_MSC_VER) && !defined(__c2__)
|
---|
118 | #define DebugBreak() asm("bkpt #0")
|
---|
119 | #else
|
---|
120 | #ifdef _MSC_VER
|
---|
121 | void _stdcall DebugBreak();
|
---|
122 | #else
|
---|
123 | void __attribute__((stdcall)) DebugBreak();
|
---|
124 | #endif
|
---|
125 | #endif
|
---|
126 |
|
---|
127 | #ifdef __cplusplus
|
---|
128 | extern "C" {
|
---|
129 | #endif
|
---|
130 |
|
---|
131 | // time.h
|
---|
132 | #define CLOCK_REALTIME 0
|
---|
133 | int shell_nanosleep(const struct timespec *req, struct timespec *rem);
|
---|
134 |
|
---|
135 | // dirent.h
|
---|
136 | typedef struct __dirstream FATFS_DIR;
|
---|
137 |
|
---|
138 | int shell_getdents(int, struct dirent *, size_t);
|
---|
139 | // pool.h
|
---|
140 | typedef unsigned long nfds_t;
|
---|
141 |
|
---|
142 | struct pollfd {
|
---|
143 | int fd;
|
---|
144 | short events;
|
---|
145 | short revents;
|
---|
146 | };
|
---|
147 |
|
---|
148 | int shell_poll(struct pollfd *, nfds_t, int);
|
---|
149 |
|
---|
150 | #define POLLIN 0x001
|
---|
151 | #define POLLOUT 0x004
|
---|
152 | #define POLLERR 0x008
|
---|
153 |
|
---|
154 | // stropts.h
|
---|
155 | int shell_ioctl(int, int, void *);
|
---|
156 | // unistd.h
|
---|
157 | #define STDIN_FILENO 0
|
---|
158 | #define STDOUT_FILENO 1
|
---|
159 | #define STDERR_FILENO 2
|
---|
160 |
|
---|
161 | int shell_rmdir(const char *);
|
---|
162 | int shell_ftruncate(int, off_t);
|
---|
163 | int shell_chdir(const char *);
|
---|
164 | char *shell_getcwd(char *, size_t);
|
---|
165 | int shell_chroot(const char *);
|
---|
166 | int shell_close(int);
|
---|
167 | int shell_llseek(int, off_t, off_t *, int);
|
---|
168 | int shell_fsync(int);
|
---|
169 | ssize_t shell_read(int, void *, size_t);
|
---|
170 | int shell_readv(int fd, const struct iovec *iov, int iovcnt);
|
---|
171 | ssize_t shell_write(int, const void *, size_t);
|
---|
172 | int shell_writev(int fd, const struct iovec *iov, int iovcnt);
|
---|
173 | int shell_link(const char *, const char *);
|
---|
174 | int shell_unlink(const char *);
|
---|
175 | pid_t shell_getpid(void);
|
---|
176 | int shell_access(const char *path, int mode);
|
---|
177 | // signal.h
|
---|
178 | int shell_sigprocmask(int how, const sigset_t *__restrict set, sigset_t *__restrict old);
|
---|
179 | struct k_sigaction;
|
---|
180 | int shell_sigaction(int sig, const struct k_sigaction *__restrict sa,
|
---|
181 | struct k_sigaction *__restrict old, size_t size);
|
---|
182 | // socket.h
|
---|
183 | int shell_socket(int, int, int);
|
---|
184 | int shell_connect(int, const struct sockaddr *, socklen_t);
|
---|
185 | ssize_t shell_sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
|
---|
186 | ssize_t shell_sendmsg(int, const struct msghdr *, int);
|
---|
187 | int shell_bind(int, const struct sockaddr *, socklen_t);
|
---|
188 | int shell_listen(int, int);
|
---|
189 | int shell_accept(int, struct sockaddr *__restrict, socklen_t *__restrict);
|
---|
190 | ssize_t shell_recvfrom(int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
|
---|
191 | ssize_t shell_recvmsg(int, struct msghdr *, int);
|
---|
192 | int shell_getsockopt(int, int, int, void *__restrict, socklen_t *__restrict);
|
---|
193 | int shell_setsockopt(int, int, int, const void *, socklen_t);
|
---|
194 | int shell_shutdown(int, int);
|
---|
195 | int shell_getpeername(int fd, struct sockaddr *__restrict addr, socklen_t *__restrict len);
|
---|
196 | int shell_getsockname(int fd, struct sockaddr *__restrict addr, socklen_t *__restrict len);
|
---|
197 | // select.h
|
---|
198 | int shell_select(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict);
|
---|
199 | // syslog.h
|
---|
200 | void vsyslog (int, const char *, va_list);
|
---|
201 | // fcntl.h
|
---|
202 | int shell_open(const char *, int, void *arg);
|
---|
203 | int shell_fcntl(int fd, int cmd, void *arg);
|
---|
204 | // stdio.h
|
---|
205 | int shell_rename(const char *, const char *);
|
---|
206 | // stat.h
|
---|
207 | #define S_IFDIR 0040000
|
---|
208 | #define S_IFCHR 0020000
|
---|
209 | #define S_IFREG 0100000
|
---|
210 |
|
---|
211 | #define S_IRUSR 0400
|
---|
212 | #define S_IWUSR 0200
|
---|
213 | #define S_IRGRP 0040
|
---|
214 | #define S_IWGRP 0020
|
---|
215 | #define S_IROTH 0004
|
---|
216 | #define S_IWOTH 0002
|
---|
217 |
|
---|
218 | int shell_chmod(const char *, mode_t);
|
---|
219 | int shell_mkdir(const char *, mode_t);
|
---|
220 | int shell_stat(const char *__restrict, struct stat *__restrict);
|
---|
221 | int shell_fstat(int, struct stat *);
|
---|
222 | int shell_lstat(const char *__restrict, struct stat *__restrict);
|
---|
223 |
|
---|
224 | int shell_clock_getres(clockid_t clk_id, struct timespec *res);
|
---|
225 | int shell_clock_gettime(clockid_t clk_id, struct timespec *tp);
|
---|
226 | int shell_clock_settime(clockid_t clk_id, const struct timespec *tp);
|
---|
227 | int shell_gettimeofday(struct timeval *tp, void * tzvp);
|
---|
228 |
|
---|
229 | void shell_abort();
|
---|
230 | void shell_exit(int exitcd);
|
---|
231 | void shell_exit_group(int exitcd);
|
---|
232 | int shell_kill(int pid, int sig);
|
---|
233 |
|
---|
234 | void *shell_brk(void *addr);
|
---|
235 | void *shell_mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset);
|
---|
236 | // sys/mman.h
|
---|
237 | int shell_mprotect(void *addr, size_t len, int prot);
|
---|
238 | // TODO
|
---|
239 | int shell_clone(int, int);
|
---|
240 | int shell_dup2(int, int);
|
---|
241 | int shell_execve(const char *, char *const [], char *const []);
|
---|
242 | int shell_faccessat(int, const char *, int, int);
|
---|
243 | int shell_fchmodat(int, const char *, mode_t, int);
|
---|
244 | int shell_flock(int, int);
|
---|
245 | int shell_fork();
|
---|
246 | int shell_futex(volatile int *, int, int, void *);
|
---|
247 | int shell_futimesat(int, const char *, struct timeval *);
|
---|
248 | int shell_getegid();
|
---|
249 | int shell_geteuid();
|
---|
250 | int shell_getgid();
|
---|
251 | int shell_gettid();
|
---|
252 | int shell_getuid();
|
---|
253 | int shell_madvise(void *, size_t, int);
|
---|
254 | int shell_mremap(void *, size_t, size_t, int, void *);
|
---|
255 | int shell_munmap(void *, size_t);
|
---|
256 | int shell_pipe(int [2]);
|
---|
257 | int shell_pipe2(int [2], int);
|
---|
258 | int shell_ppoll(struct pollfd *, nfds_t, const struct timespec *,const sigset_t *);
|
---|
259 | int shell_pselect6(int, fd_set *__restrict, fd_set *__restrict,
|
---|
260 | fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
|
---|
261 | int shell_setpgid(pid_t, pid_t);
|
---|
262 | int shell_setsid();
|
---|
263 | int shell_symlink(const char *, const char *);
|
---|
264 | int shell_tkill(int, int);
|
---|
265 | int shell_umask(mode_t);
|
---|
266 | int shell_uname(struct utsname *);
|
---|
267 | int shell_utimensat(int, const char *, const struct timespec [2], int);
|
---|
268 | int shell_utimes(const char *, struct timeval *);
|
---|
269 | // sys/resource.h
|
---|
270 | struct rusage;
|
---|
271 | int shell_wait4(pid_t, int *, int, struct rusage *);
|
---|
272 | // ↑↑↑musl
|
---|
273 |
|
---|
274 | // arduino.h
|
---|
275 | int SD_begin();
|
---|
276 |
|
---|
277 | char *basename(char *);
|
---|
278 |
|
---|
279 | struct regs_t {
|
---|
280 | long a;
|
---|
281 | long b;
|
---|
282 | long c;
|
---|
283 | long d;
|
---|
284 | long e;
|
---|
285 | long f;
|
---|
286 | long n;
|
---|
287 | };
|
---|
288 |
|
---|
289 | long no_implement(const char *text);
|
---|
290 | void __mbedcall_cp_asm();
|
---|
291 |
|
---|
292 | #include "ff.h"
|
---|
293 | WCHAR Utf8_to_Utf16(const char *, int *); /* in ff.c */
|
---|
294 | void Utf16_to_Utf8(unsigned char *, int *, UINT); /* in ff.c */
|
---|
295 |
|
---|
296 | #ifdef __cplusplus
|
---|
297 | extern "C" {
|
---|
298 | #endif
|
---|
299 | int Kernel_StartExternal(int argc, char **argv);
|
---|
300 | #ifdef __cplusplus
|
---|
301 | }
|
---|
302 | #endif
|
---|
303 |
|
---|
304 | void *malloc(size_t size);
|
---|
305 | void *calloc(size_t size, size_t count);
|
---|
306 | void *realloc(void *ptr, size_t size);
|
---|
307 | void free(void *ptr);
|
---|
308 |
|
---|
309 | #ifdef __cplusplus
|
---|
310 | }
|
---|
311 | #endif
|
---|
312 |
|
---|
313 | #endif /* SHELLIF_H */
|
---|