Skip to main content

proctor_libc/
lib.rs

1//! Safe, Rust-idiomatic equivalents of C standard library functions.
2//!
3//! Each function preserves the corresponding libc function's behavior for inputs
4//! whose behavior libc defines, with priority given to preserving its return value.
5//! C types map to fixed Rust types: `char` to `i8`, `int` to `i32`, `long` to `i64`,
6//! `float` to `f32`, `double` to `f64`, `long double` to [`struct@f128::f128`], and
7//! `size_t` to `usize`. Null-terminated strings are represented by `i8` slices
8//! containing a null byte where required by the libc interface.
9//!
10//! Function documentation is intentionally concise because behavior follows libc;
11//! it notes Rust-specific return values and error handling where needed.
12
13pub mod ctype;
14pub mod stdio;
15pub mod stdlib;
16pub mod string;
17pub mod strings;
18
19pub use ctype::{
20    isalnum, isalpha, isblank, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace,
21    isupper, isxdigit, tolower, toupper,
22};
23pub use stdio::printf;
24pub use stdio::{
25    fgetc, fgets, fputc, fputs, fread, fseek, ftell, fwrite, getchar, putchar, puts, rewind,
26};
27#[cfg(target_os = "linux")]
28pub use stdio::{remove, rename};
29pub use stdlib::{
30    atof, atoi, atol, strtod, strtod_mut, strtof, strtof_mut, strtol, strtol_mut, strtold,
31    strtold_mut, strtoul, strtoul_mut,
32};
33pub use string::{
34    memchr, memchr_mut, memcmp, strcat, strchr, strchr_mut, strcmp, strcpy, strcspn, strdup,
35    strlen, strncat, strncmp, strncpy, strndup, strrchr, strrchr_mut, strspn, strstr, strstr_mut,
36};
37pub use strings::{strcasecmp, strncasecmp};