15int strcmp(
const char* a,
const char* b) {
16 while (*a && *b && *a == *b) { a++; b++; }
21void strcpy(
char* dest,
const char* src) {
22 while (*src) *dest++ = *src++;
26void strcat(
char* dest,
const char* src) {
28 while (*src) *dest++ = *src++;
49void itoa(
int num,
char* str) {
65 if (num == -2147483648) {
85 digits[i++] = (char)(
'0' + (num % 10));
97 str[idx++] = digits[--i];
120 while (*str >=
'0' && *str <=
'9') {
121 num = num * 10 + (*str -
'0');
189int pargs(
char *line,
char *args[]) {
195 if (line[0] ==
'/') i = 1;
197 while (line[i] !=
'\0' && argc <
MAX_ARGS) {
199 while (line[i] ==
' ' && !in_quote) i++;
200 if (line[i] ==
'\0')
break;
203 args[argc] = &line[i];
207 if (line[i] ==
'"') {
209 args[argc-1] = &line[i+1];
214 while (line[i] !=
'\0') {
216 if (line[i] ==
'"') {
223 if (line[i] ==
' ') {
int strcmp(const char *a, const char *b)
void strcpy(char *dest, const char *src)
void itoa(int num, char *str)
itoa converts an integer to a decimal string
int strlen(const char *s)
int pargs(char *line, char *args[])
pargs parses a command line into an argument array
static uint32_t rng_state
void strcat(char *dest, const char *src)
uint32_t rand(void)
rand returns a pseudo-random 32 bit integer
int atoi(const char *str)
atoi converts a decimal string to an integer
void srand(uint32_t seed)
srand seeds the random number generator