1 | /*
|
---|
2 | * TOPPERS ECHONET Lite Communication Middleware
|
---|
3 | *
|
---|
4 | * Copyright (C) 2017 Cores Co., Ltd. Japan
|
---|
5 | *
|
---|
6 | * ä¸è¨èä½æ¨©è
|
---|
7 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
8 | * ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
9 | * å¤ã»åé
|
---|
10 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
11 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
12 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
13 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
14 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
15 | * ç¨ã§ããå½¢ã§åé
|
---|
16 | å¸ããå ´åã«ã¯ï¼åé
|
---|
17 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
18 | * è
|
---|
19 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
20 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
21 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
22 | * ç¨ã§ããªãå½¢ã§åé
|
---|
23 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
24 | * ã¨ï¼
|
---|
25 | * (a) åé
|
---|
26 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
27 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
28 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
29 | * (b) åé
|
---|
30 | å¸ã®å½¢æ
|
---|
31 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
32 | * å ±åãããã¨ï¼
|
---|
33 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
34 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
35 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
36 | 責ãããã¨ï¼
|
---|
37 | * ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
38 | * ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
39 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
40 | * å
|
---|
41 | 責ãããã¨ï¼
|
---|
42 | *
|
---|
43 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
44 | ã
|
---|
45 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
46 | * ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
47 | * ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
48 | * ã®è²¬ä»»ãè² ããªãï¼
|
---|
49 | *
|
---|
50 | * @(#) $Id: shellif.h 388 2019-05-22 11:25:18Z coas-nagasima $
|
---|
51 | */
|
---|
52 | #ifndef SHELLIF_H
|
---|
53 | #define SHELLIF_H
|
---|
54 |
|
---|
55 | #ifdef _MSC_VER
|
---|
56 | #undef NULL
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | #define __NEED_off_t
|
---|
60 | #define __NEED_ssize_t
|
---|
61 | #define __NEED_size_t
|
---|
62 | #define __NEED_mode_t
|
---|
63 | #define __NEED_dev_t
|
---|
64 | #define __NEED_pid_t
|
---|
65 | #define __NEED_gid_t
|
---|
66 | #define __NEED_uid_t
|
---|
67 | #define __NEED_socklen_t
|
---|
68 | #define __NEED_nlink_t
|
---|
69 | #define __NEED_blksize_t
|
---|
70 | #define __NEED_blkcnt_t
|
---|
71 | #define __NEED_ino_t
|
---|
72 | #define __NEED_time_t
|
---|
73 | #define __NEED_suseconds_t
|
---|
74 | #define __NEED_struct_timeval
|
---|
75 | #define __NEED_struct_timespec
|
---|
76 | #define __NEED_struct_iovec
|
---|
77 | #define __NEED_clockid_t
|
---|
78 | #define __NEED_socklen_t
|
---|
79 | #define __NEED_sa_family_t
|
---|
80 | #define __NEED_sigset_t
|
---|
81 |
|
---|
82 | #ifndef _MSC_VER
|
---|
83 | #include <bits/alltypes.h>
|
---|
84 |
|
---|
85 | typedef unsigned char cc_t;
|
---|
86 | typedef unsigned int speed_t;
|
---|
87 | typedef unsigned int tcflag_t;
|
---|
88 |
|
---|
89 | #define NCCS 32
|
---|
90 |
|
---|
91 | #include <fcntl.h>
|
---|
92 | #include <termios.h>
|
---|
93 | #include <sys/stat.h>
|
---|
94 | #include <sys/select.h>
|
---|
95 | #include <time.h>
|
---|
96 | #include <limits.h>
|
---|
97 | #include <fcntl.h>
|
---|
98 | #include <signal.h>
|
---|
99 | #include <stdio.h>
|
---|
100 | #include <sys/utsname.h>
|
---|
101 | #include <dirent.h>
|
---|
102 | #include <sys/ioctl.h>
|
---|
103 | #include <errno.h>
|
---|
104 | #include <sys/socket.h>
|
---|
105 | #else
|
---|
106 | #include "../musl-1.1.18/include/bits/alltypes.h"
|
---|
107 |
|
---|
108 | typedef unsigned char cc_t;
|
---|
109 | typedef unsigned int speed_t;
|
---|
110 | typedef unsigned int tcflag_t;
|
---|
111 |
|
---|
112 | #define NCCS 32
|
---|
113 |
|
---|
114 | #include "../musl-1.1.18/include/bits/fcntl.h"
|
---|
115 | #include "../musl-1.1.18/include/bits/termios.h"
|
---|
116 | #include "../musl-1.1.18/include/bits/stat.h"
|
---|
117 | #include "../musl-1.1.18/include/sys/select.h"
|
---|
118 | #include "../musl-1.1.18/include/time.h"
|
---|
119 | #include "../musl-1.1.18/include/signal.h"
|
---|
120 | #include "../musl-1.1.18/include/stdio.h"
|
---|
121 | #include "../musl-1.1.18/include/sys/utsname.h"
|
---|
122 | #include "../musl-1.1.18/include/dirent.h"
|
---|
123 | #include "../musl-1.1.18/include/bits/ioctl.h"
|
---|
124 | #include "../musl-1.1.18/include/fcntl.h"
|
---|
125 | #include "../musl-1.1.18/include/bits/errno.h"
|
---|
126 | #include "../musl-1.1.18/include/sys/socket.h"
|
---|
127 | #endif
|
---|
128 |
|
---|
129 | #include <stddef.h>
|
---|
130 | #include <stdarg.h>
|
---|
131 |
|
---|
132 | #if !defined(_MSC_VER) && !defined(__c2__)
|
---|
133 | //#define DebugBreak() asm("brk")
|
---|
134 | #define DebugBreak() while (true)
|
---|
135 | #else
|
---|
136 | #ifdef _MSC_VER
|
---|
137 | void _stdcall DebugBreak();
|
---|
138 | #else
|
---|
139 | void __attribute__((stdcall)) DebugBreak();
|
---|
140 | #endif
|
---|
141 | #endif
|
---|
142 |
|
---|
143 | #ifdef __cplusplus
|
---|
144 | extern "C" {
|
---|
145 | #endif
|
---|
146 |
|
---|
147 | // time.h
|
---|
148 | #define CLOCK_REALTIME 0
|
---|
149 | int shell_nanosleep(const struct timespec *req, struct timespec *rem);
|
---|
150 |
|
---|
151 | // dirent.h
|
---|
152 | typedef struct __dirstream FATFS_DIR;
|
---|
153 |
|
---|
154 | int shell_getdents(int, struct dirent *, size_t);
|
---|
155 | // pool.h
|
---|
156 | typedef unsigned long nfds_t;
|
---|
157 |
|
---|
158 | struct pollfd {
|
---|
159 | int fd;
|
---|
160 | short events;
|
---|
161 | short revents;
|
---|
162 | };
|
---|
163 |
|
---|
164 | int shell_poll(struct pollfd *, nfds_t, int);
|
---|
165 |
|
---|
166 | #define POLLIN 0x001
|
---|
167 | #define POLLOUT 0x004
|
---|
168 | #define POLLERR 0x008
|
---|
169 |
|
---|
170 | // stropts.h
|
---|
171 | int shell_ioctl(int, int, void *);
|
---|
172 | // unistd.h
|
---|
173 | #define STDIN_FILENO 0
|
---|
174 | #define STDOUT_FILENO 1
|
---|
175 | #define STDERR_FILENO 2
|
---|
176 |
|
---|
177 | int shell_rmdir(const char *);
|
---|
178 | int shell_ftruncate(int, off_t);
|
---|
179 | int shell_chdir(const char *);
|
---|
180 | char *shell_getcwd(char *, size_t);
|
---|
181 | int shell_chroot(const char *);
|
---|
182 | int shell_close(int);
|
---|
183 | int shell_llseek(int, off_t, off_t *, int);
|
---|
184 | int shell_fsync(int);
|
---|
185 | ssize_t shell_read(int, void *, size_t);
|
---|
186 | int shell_readv(int fd, const struct iovec *iov, int iovcnt);
|
---|
187 | ssize_t shell_write(int, const void *, size_t);
|
---|
188 | int shell_writev(int fd, const struct iovec *iov, int iovcnt);
|
---|
189 | int shell_link(const char *, const char *);
|
---|
190 | int shell_unlink(const char *);
|
---|
191 | pid_t shell_getpid(void);
|
---|
192 | int shell_access(const char *path, int mode);
|
---|
193 | // signal.h
|
---|
194 | int shell_sigprocmask(int how, const sigset_t *__restrict set, sigset_t *__restrict old);
|
---|
195 | struct k_sigaction;
|
---|
196 | int shell_sigaction(int sig, const struct k_sigaction *__restrict sa,
|
---|
197 | struct k_sigaction *__restrict old, size_t size);
|
---|
198 | // socket.h
|
---|
199 | int shell_socket(int, int, int);
|
---|
200 | int shell_connect(int, const struct sockaddr *, socklen_t);
|
---|
201 | ssize_t shell_sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
|
---|
202 | ssize_t shell_sendmsg(int, const struct msghdr *, int);
|
---|
203 | int shell_bind(int, const struct sockaddr *, socklen_t);
|
---|
204 | int shell_listen(int, int);
|
---|
205 | int shell_accept(int, struct sockaddr *__restrict, socklen_t *__restrict);
|
---|
206 | ssize_t shell_recvfrom(int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
|
---|
207 | ssize_t shell_recvmsg(int, struct msghdr *, int);
|
---|
208 | int shell_getsockopt(int, int, int, void *__restrict, socklen_t *__restrict);
|
---|
209 | int shell_setsockopt(int, int, int, const void *, socklen_t);
|
---|
210 | int shell_shutdown(int, int);
|
---|
211 | int shell_getpeername(int fd, struct sockaddr *__restrict addr, socklen_t *__restrict len);
|
---|
212 | int shell_getsockname(int fd, struct sockaddr *__restrict addr, socklen_t *__restrict len);
|
---|
213 | // select.h
|
---|
214 | int shell_select(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict);
|
---|
215 | // syslog.h
|
---|
216 | void vsyslog (int, const char *, va_list);
|
---|
217 | // fcntl.h
|
---|
218 | int shell_open(const char *, int, void *arg);
|
---|
219 | int shell_fcntl(int fd, int cmd, void *arg);
|
---|
220 | // stdio.h
|
---|
221 | int shell_rename(const char *, const char *);
|
---|
222 | // stat.h
|
---|
223 | #define S_IFDIR 0040000
|
---|
224 | #define S_IFCHR 0020000
|
---|
225 | #define S_IFREG 0100000
|
---|
226 |
|
---|
227 | #define S_IRUSR 0400
|
---|
228 | #define S_IWUSR 0200
|
---|
229 | #define S_IRGRP 0040
|
---|
230 | #define S_IWGRP 0020
|
---|
231 | #define S_IROTH 0004
|
---|
232 | #define S_IWOTH 0002
|
---|
233 |
|
---|
234 | int shell_chmod(const char *, mode_t);
|
---|
235 | int shell_mkdir(const char *, mode_t);
|
---|
236 | int shell_stat(const char *__restrict, struct stat *__restrict);
|
---|
237 | int shell_fstat(int, struct stat *);
|
---|
238 | int shell_lstat(const char *__restrict, struct stat *__restrict);
|
---|
239 |
|
---|
240 | int shell_clock_getres(clockid_t clk_id, struct timespec *res);
|
---|
241 | int shell_clock_gettime(clockid_t clk_id, struct timespec *tp);
|
---|
242 | int shell_clock_settime(clockid_t clk_id, const struct timespec *tp);
|
---|
243 | int shell_gettimeofday(struct timeval *tp, void * tzvp);
|
---|
244 |
|
---|
245 | void shell_abort();
|
---|
246 | void shell_exit(int exitcd);
|
---|
247 | void shell_exit_group(int exitcd);
|
---|
248 | int shell_kill(int pid, int sig);
|
---|
249 |
|
---|
250 | void *shell_brk(void *addr);
|
---|
251 | void *shell_mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset);
|
---|
252 | // sys/mman.h
|
---|
253 | int shell_mprotect(void *addr, size_t len, int prot);
|
---|
254 | // TODO
|
---|
255 | int shell_clone(int, int);
|
---|
256 | int shell_dup2(int, int);
|
---|
257 | int shell_execve(const char *, char *const [], char *const []);
|
---|
258 | int shell_faccessat(int, const char *, int, int);
|
---|
259 | int shell_fchmodat(int, const char *, mode_t, int);
|
---|
260 | int shell_flock(int, int);
|
---|
261 | int shell_fork();
|
---|
262 | int shell_futex(volatile int *, int, int, void *);
|
---|
263 | int shell_futimesat(int, const char *, struct timeval *);
|
---|
264 | int shell_getegid();
|
---|
265 | int shell_geteuid();
|
---|
266 | int shell_getgid();
|
---|
267 | int shell_gettid();
|
---|
268 | int shell_getuid();
|
---|
269 | int shell_madvise(void *, size_t, int);
|
---|
270 | int shell_mremap(void *, size_t, size_t, int, void *);
|
---|
271 | int shell_munmap(void *, size_t);
|
---|
272 | int shell_pipe(int [2]);
|
---|
273 | int shell_pipe2(int [2], int);
|
---|
274 | int shell_ppoll(struct pollfd *, nfds_t, const struct timespec *,const sigset_t *);
|
---|
275 | int shell_pselect6(int, fd_set *__restrict, fd_set *__restrict,
|
---|
276 | fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
|
---|
277 | int shell_setpgid(pid_t, pid_t);
|
---|
278 | int shell_setsid();
|
---|
279 | int shell_symlink(const char *, const char *);
|
---|
280 | int shell_tkill(int, int);
|
---|
281 | int shell_umask(mode_t);
|
---|
282 | int shell_uname(struct utsname *);
|
---|
283 | int shell_utimensat(int, const char *, const struct timespec [2], int);
|
---|
284 | int shell_utimes(const char *, struct timeval *);
|
---|
285 | // sys/resource.h
|
---|
286 | struct rusage;
|
---|
287 | int shell_wait4(pid_t, int *, int, struct rusage *);
|
---|
288 | // âââmusl
|
---|
289 |
|
---|
290 | // arduino.h
|
---|
291 | int SD_begin();
|
---|
292 |
|
---|
293 | char *basename(char *);
|
---|
294 |
|
---|
295 | struct regs_t {
|
---|
296 | long a;
|
---|
297 | long b;
|
---|
298 | long c;
|
---|
299 | long d;
|
---|
300 | long e;
|
---|
301 | long f;
|
---|
302 | long n;
|
---|
303 | };
|
---|
304 |
|
---|
305 | long no_implement(const char *text);
|
---|
306 | void __mbedcall_cp_asm();
|
---|
307 |
|
---|
308 | #include "ff.h"
|
---|
309 | WCHAR Utf8_to_Utf16(const char *, int *); /* in ff.c */
|
---|
310 | void Utf16_to_Utf8(unsigned char *, int *, UINT); /* in ff.c */
|
---|
311 |
|
---|
312 | #ifdef __cplusplus
|
---|
313 | extern "C" {
|
---|
314 | #endif
|
---|
315 | int Kernel_StartExternal(int argc, char **argv);
|
---|
316 | #ifdef __cplusplus
|
---|
317 | }
|
---|
318 | #endif
|
---|
319 |
|
---|
320 | void *malloc(size_t size);
|
---|
321 | void *calloc(size_t size, size_t count);
|
---|
322 | void *realloc(void *ptr, size_t size);
|
---|
323 | void free(void *ptr);
|
---|
324 |
|
---|
325 | #ifdef __cplusplus
|
---|
326 | }
|
---|
327 | #endif
|
---|
328 |
|
---|
329 | #endif /* SHELLIF_H */
|
---|