Last change
on this file since 459 was 453, checked in by coas-nagasima, 4 years ago |
ファイルを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
1.5 KB
|
Line | |
---|
1 | #include <stdint.h>
|
---|
2 | #include <stdlib.h>
|
---|
3 | #include <ctype.h>
|
---|
4 | #include <errno.h>
|
---|
5 | #include <sys/time.h>
|
---|
6 | #include <kernel.h>
|
---|
7 | #include <t_syslog.h>
|
---|
8 | #include <t_stdlib.h>
|
---|
9 | #include "main.h"
|
---|
10 | #include "kernel_cfg.h"
|
---|
11 | #include "esp_at_socket.h"
|
---|
12 |
|
---|
13 | void __wrap_exit(int status)
|
---|
14 | {
|
---|
15 | ext_ker();
|
---|
16 | }
|
---|
17 |
|
---|
18 | int _kill(int pid, int sig)
|
---|
19 | {
|
---|
20 | return 0;
|
---|
21 | }
|
---|
22 |
|
---|
23 | int _getpid(int n)
|
---|
24 | {
|
---|
25 | return 1;
|
---|
26 | }
|
---|
27 |
|
---|
28 | int custom_rand_generate_seed(uint8_t *output, uint32_t sz)
|
---|
29 | {
|
---|
30 | SYSTIM now;
|
---|
31 | int32_t i;
|
---|
32 |
|
---|
33 | get_tim(&now);
|
---|
34 | srand(now);
|
---|
35 |
|
---|
36 | for (i = 0; i < sz; i++)
|
---|
37 | output[i] = rand();
|
---|
38 |
|
---|
39 | return 0;
|
---|
40 | }
|
---|
41 |
|
---|
42 | // musl-libc
|
---|
43 |
|
---|
44 | int inet_aton(const char *s0, struct in_addr *dest)
|
---|
45 | {
|
---|
46 | const char *s = s0;
|
---|
47 | unsigned char *d = (unsigned char *)dest;
|
---|
48 | unsigned long a[4] = { 0 };
|
---|
49 | char *z;
|
---|
50 | int i;
|
---|
51 |
|
---|
52 | for (i = 0; i < 4; i++) {
|
---|
53 | a[i] = strtoul(s, &z, 0);
|
---|
54 | if (z == s || (*z && *z != '.') || !isdigit(*s))
|
---|
55 | return 0;
|
---|
56 | if (!*z) break;
|
---|
57 | s = z + 1;
|
---|
58 | }
|
---|
59 | if (i == 4) return 0;
|
---|
60 | switch (i) {
|
---|
61 | case 0:
|
---|
62 | a[1] = a[0] & 0xffffff;
|
---|
63 | a[0] >>= 24;
|
---|
64 | case 1:
|
---|
65 | a[2] = a[1] & 0xffff;
|
---|
66 | a[1] >>= 16;
|
---|
67 | case 2:
|
---|
68 | a[3] = a[2] & 0xff;
|
---|
69 | a[2] >>= 8;
|
---|
70 | }
|
---|
71 | for (i = 0; i < 4; i++) {
|
---|
72 | if (a[i] > 255) return 0;
|
---|
73 | d[i] = a[i];
|
---|
74 | }
|
---|
75 | return 1;
|
---|
76 | }
|
---|
77 |
|
---|
78 | struct ether_addr *ether_aton_r(const char *x, struct ether_addr *p_a)
|
---|
79 | {
|
---|
80 | struct ether_addr a;
|
---|
81 | char *y;
|
---|
82 | for (int ii = 0; ii < 6; ii++) {
|
---|
83 | unsigned long int n;
|
---|
84 | if (ii != 0) {
|
---|
85 | if (x[0] != ':') return 0; /* bad format */
|
---|
86 | else x++;
|
---|
87 | }
|
---|
88 | n = strtoul(x, &y, 16);
|
---|
89 | x = y;
|
---|
90 | if (n > 0xFF) return 0; /* bad byte */
|
---|
91 | a.ether_addr_octet[ii] = n;
|
---|
92 | }
|
---|
93 | if (x[0] != 0) return 0; /* bad format */
|
---|
94 | *p_a = a;
|
---|
95 | return p_a;
|
---|
96 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.