[352] | 1 | /*
|
---|
| 2 | * TOPPERS ECHONET Lite Communication Middleware
|
---|
| 3 | *
|
---|
| 4 | * Copyright (C) 2017 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 <bits/fcntl.h>
|
---|
| 77 | #include <bits/termios.h>
|
---|
| 78 | #include <bits/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 <bits/ioctl.h>
|
---|
| 88 | #include <bits/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("brk")
|
---|
| 119 | #define DebugBreak() while (true)
|
---|
| 120 | #else
|
---|
| 121 | #ifdef _MSC_VER
|
---|
| 122 | void _stdcall DebugBreak();
|
---|
| 123 | #else
|
---|
| 124 | void __attribute__((stdcall)) DebugBreak();
|
---|
| 125 | #endif
|
---|
| 126 | #endif
|
---|
| 127 |
|
---|
[364] | 128 | #ifdef __cplusplus
|
---|
| 129 | extern "C" {
|
---|
| 130 | #endif
|
---|
| 131 |
|
---|
[352] | 132 | // time.h
|
---|
| 133 | #define CLOCK_REALTIME 0
|
---|
| 134 |
|
---|
| 135 | // dirent.h
|
---|
| 136 | typedef struct __dirstream 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
|
---|
[364] | 178 | int shell_sigprocmask(int how, const sigset_t *__restrict set, sigset_t *__restrict old);
|
---|
| 179 | int shell_sigaction(int sig, const struct sigaction *__restrict sa, struct sigaction *__restrict old);
|
---|
[352] | 180 | // socket.h
|
---|
| 181 | int shell_socket(int, int, int);
|
---|
| 182 | int shell_connect(int, const struct sockaddr *, socklen_t);
|
---|
| 183 | ssize_t shell_sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
|
---|
| 184 | ssize_t shell_sendmsg(int, const struct msghdr *, int);
|
---|
| 185 | int shell_bind(int, const struct sockaddr *, socklen_t);
|
---|
| 186 | int shell_listen(int, int);
|
---|
| 187 | int shell_accept(int, struct sockaddr *__restrict, socklen_t *__restrict);
|
---|
| 188 | ssize_t shell_recvfrom(int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
|
---|
| 189 | ssize_t shell_recvmsg(int, struct msghdr *, int);
|
---|
| 190 | int shell_getsockopt(int, int, int, void *__restrict, socklen_t *__restrict);
|
---|
| 191 | int shell_setsockopt(int, int, int, const void *, socklen_t);
|
---|
| 192 | int shell_shutdown(int, int);
|
---|
| 193 | int shell_getpeername(int fd, struct sockaddr *__restrict addr, socklen_t *__restrict len);
|
---|
| 194 | int shell_getsockname(int fd, struct sockaddr *__restrict addr, socklen_t *__restrict len);
|
---|
| 195 | // select.h
|
---|
| 196 | int shell_select(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict);
|
---|
| 197 | // syslog.h
|
---|
| 198 | void vsyslog (int, const char *, va_list);
|
---|
| 199 | // termios.h
|
---|
| 200 | int sio_tcgetattr (int, struct termios *);
|
---|
| 201 | int sio_tcsetattr(int, int, const struct termios *);
|
---|
| 202 | // fcntl.h
|
---|
| 203 | int shell_open(const char *, int, void *arg);
|
---|
| 204 | int shell_fcntl(int fd, int cmd, void *arg);
|
---|
| 205 | // stdio.h
|
---|
| 206 | int shell_rename(const char *, const char *);
|
---|
| 207 | // stat.h
|
---|
| 208 | #define S_IFDIR 0040000
|
---|
| 209 | #define S_IFCHR 0020000
|
---|
| 210 | #define S_IFREG 0100000
|
---|
| 211 |
|
---|
| 212 | #define S_IRUSR 0400
|
---|
| 213 | #define S_IWUSR 0200
|
---|
| 214 | #define S_IRGRP 0040
|
---|
| 215 | #define S_IWGRP 0020
|
---|
| 216 | #define S_IROTH 0004
|
---|
| 217 | #define S_IWOTH 0002
|
---|
| 218 |
|
---|
| 219 | int shell_chmod(const char *, mode_t);
|
---|
| 220 | int shell_mkdir(const char *, mode_t);
|
---|
| 221 | int shell_stat(const char *__restrict, struct stat *__restrict);
|
---|
| 222 | int shell_fstat(int, struct stat *);
|
---|
| 223 | int shell_lstat(const char *__restrict, struct stat *__restrict);
|
---|
| 224 |
|
---|
| 225 | int shell_clock_getres(clockid_t clk_id, struct timespec *res);
|
---|
| 226 | int shell_clock_gettime(clockid_t clk_id, struct timespec *tp);
|
---|
| 227 | int shell_clock_settime(clockid_t clk_id, const struct timespec *tp);
|
---|
| 228 | int shell_gettimeofday(struct timeval *tp, void * tzvp);
|
---|
| 229 |
|
---|
| 230 | void shell_abort();
|
---|
| 231 | void shell_exit(int exitcd);
|
---|
| 232 | void shell_exit_group(int exitcd);
|
---|
| 233 | int shell_kill(int pid, int sig);
|
---|
| 234 |
|
---|
| 235 | void *shell_brk(void *addr);
|
---|
| 236 | void *shell_mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset);
|
---|
| 237 | // sys/mman.h
|
---|
| 238 | int shell_mprotect(void *addr, size_t len, int prot);
|
---|
| 239 | // TODO
|
---|
| 240 | int shell_clone(int, int);
|
---|
| 241 | int shell_dup2(int, int);
|
---|
| 242 | int shell_execve(const char *, char *const [], char *const []);
|
---|
| 243 | int shell_faccessat(int, const char *, int, int);
|
---|
| 244 | int shell_fchmodat(int, const char *, mode_t, int);
|
---|
| 245 | int shell_flock(int, int);
|
---|
| 246 | int shell_fork();
|
---|
| 247 | int shell_futex(volatile int *, int, int, void *);
|
---|
| 248 | int shell_futimesat(int, const char *, struct timeval *);
|
---|
| 249 | int shell_getegid();
|
---|
| 250 | int shell_geteuid();
|
---|
| 251 | int shell_getgid();
|
---|
| 252 | int shell_gettid();
|
---|
| 253 | int shell_getuid();
|
---|
| 254 | int shell_madvise(void *, size_t, int);
|
---|
| 255 | int shell_mremap(void *, size_t, size_t, int, void *);
|
---|
| 256 | int shell_munmap(void *, size_t);
|
---|
| 257 | int shell_pipe(int [2]);
|
---|
| 258 | int shell_pipe2(int [2], int);
|
---|
| 259 | int shell_ppoll(struct pollfd *, nfds_t, const struct timespec *,const sigset_t *);
|
---|
[364] | 260 | int shell_pselect6(int, fd_set *__restrict, fd_set *__restrict,
|
---|
| 261 | fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
|
---|
[352] | 262 | int shell_setpgid(pid_t, pid_t);
|
---|
| 263 | int shell_setsid();
|
---|
| 264 | int shell_symlink(const char *, const char *);
|
---|
| 265 | int shell_tkill(int, int);
|
---|
| 266 | int shell_umask(mode_t);
|
---|
| 267 | int shell_uname(struct utsname *);
|
---|
| 268 | int shell_utimensat(int, const char *, const struct timespec [2], int);
|
---|
| 269 | int shell_utimes(const char *, struct timeval *);
|
---|
| 270 | // sys/resource.h
|
---|
| 271 | struct rusage;
|
---|
| 272 | int shell_wait4(pid_t, int *, int, struct rusage *);
|
---|
| 273 | // ↑↑↑musl
|
---|
| 274 |
|
---|
| 275 | // arduino.h
|
---|
| 276 | int SD_begin();
|
---|
| 277 |
|
---|
| 278 | char *basename(char *);
|
---|
| 279 |
|
---|
| 280 | struct regs_t {
|
---|
| 281 | long a;
|
---|
| 282 | long b;
|
---|
| 283 | long c;
|
---|
| 284 | long d;
|
---|
| 285 | long e;
|
---|
| 286 | long f;
|
---|
| 287 | long n;
|
---|
| 288 | };
|
---|
| 289 |
|
---|
| 290 | long no_implement(const char *text);
|
---|
| 291 | void __mbedcall_cp_asm();
|
---|
| 292 |
|
---|
| 293 | #include "ff.h"
|
---|
| 294 | WCHAR Utf8_to_Utf16(const char *, int *); /* in ff.c */
|
---|
| 295 | void Utf16_to_Utf8(unsigned char *, int *, UINT); /* in ff.c */
|
---|
| 296 |
|
---|
| 297 | #ifdef __cplusplus
|
---|
| 298 | extern "C" {
|
---|
| 299 | #endif
|
---|
| 300 | int Kernel_StartExternal(int argc, char **argv);
|
---|
| 301 | #ifdef __cplusplus
|
---|
| 302 | }
|
---|
| 303 | #endif
|
---|
| 304 |
|
---|
| 305 | struct tm *gmtime_r(const time_t *t, struct tm *tm);
|
---|
| 306 | void *malloc(size_t size);
|
---|
| 307 | void *calloc(size_t size, size_t count);
|
---|
| 308 | void *realloc(void *ptr, size_t size);
|
---|
| 309 | void free(void *ptr);
|
---|
| 310 |
|
---|
[364] | 311 | #ifdef __cplusplus
|
---|
| 312 | }
|
---|
| 313 | #endif
|
---|
| 314 |
|
---|
[352] | 315 | #endif /* SHELLIF_H */
|
---|