1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#![cfg_attr(not(test), no_std)]
#[cfg(test)]
#[allow(unused_imports)]
use std as core;
mod strcmp;
pub use self::strcmp::strcmp;
mod strncmp;
pub use self::strncmp::strncmp;
mod strlen;
pub use self::strlen::strlen;
mod strtol;
pub use self::strtol::strtol;
mod strstr;
pub use self::strstr::strstr;
mod strchr;
pub use self::strchr::strchr;
mod atoi;
pub use self::atoi::atoi;
mod itoa;
pub use self::itoa::itoa;
mod snprintf;
pub type CLongLong = i64;
pub type CULongLong = i64;
#[cfg(feature = "lp64")]
pub type CLong = i64;
#[cfg(feature = "lp64")]
pub type CULong = u64;
#[cfg(not(feature = "lp64"))]
pub type CLong = i32;
#[cfg(not(feature = "lp64"))]
pub type CULong = u32;
#[cfg(feature = "lp32")]
pub type CInt = i16;
#[cfg(feature = "lp32")]
pub type CUInt = u16;
#[cfg(not(feature = "lp32"))]
pub type CInt = i32;
#[cfg(not(feature = "lp32"))]
pub type CUInt = u32;
pub type CChar = u8;
pub struct CStringIter {
ptr: *const CChar,
idx: isize,
}
impl CStringIter {
pub fn new(s: *const CChar) -> CStringIter {
CStringIter { ptr: s, idx: 0 }
}
}
impl core::iter::Iterator for CStringIter {
type Item = CChar;
fn next(&mut self) -> Option<Self::Item> {
let c = unsafe { *self.ptr.offset(self.idx) };
if c == 0 {
None
} else {
self.idx += 1;
Some(c)
}
}
}