blob: d3f09ff1021976eed1e808342f63b872380db85a [file] [log] [blame]
Eric Biederman8ca8d762003-04-22 19:02:15 +00001#ifndef STRING_H
2#define STRING_H
3
4#include <stddef.h>
Greg Watson16247822004-03-13 03:34:52 +00005#include <stdlib.h>
6
David Hendricks6053a9c2018-01-28 18:01:10 -08007#if !defined(__ROMCC__)
8#include <console/vtxprintf.h>
9#endif
10
Aaron Durbinac4b00e2013-04-26 11:58:35 -050011/* Stringify a token */
12#ifndef STRINGIFY
13#define _STRINGIFY(x) #x
14#define STRINGIFY(x) _STRINGIFY(x)
15#endif
16
Stefan Reinauera91e0fe2008-08-01 11:39:35 +000017void *memcpy(void *dest, const void *src, size_t n);
18void *memmove(void *dest, const void *src, size_t n);
19void *memset(void *s, int c, size_t n);
20int memcmp(const void *s1, const void *s2, size_t n);
Gabe Black1025f3a2011-09-16 02:18:56 -070021void *memchr(const void *s, int c, size_t n);
Aaron Durbin5577a472016-11-08 09:42:13 -060022#if !defined(__ROMCC__)
Lee Leahy6d71a432017-03-07 15:24:16 -080023int snprintf(char *buf, size_t size, const char *fmt, ...);
David Hendricks6053a9c2018-01-28 18:01:10 -080024int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
Stefan Reinauer6bd571e2009-09-25 21:59:57 +000025#endif
Thomas Heijligen92043552019-01-29 12:48:01 +010026char *strdup(const char *s);
27char *strconcat(const char *s1, const char *s2);
Julius Wernera66c9b82019-05-20 14:53:47 -070028size_t strnlen(const char *src, size_t max);
29size_t strlen(const char *src);
30char *strchr(const char *s, int c);
31char *strncpy(char *to, const char *from, int count);
32char *strcpy(char *dst, const char *src);
33int strcmp(const char *s1, const char *s2);
34int strncmp(const char *s1, const char *s2, int maxlen);
Yuji Sasaki6b212d82019-06-12 17:42:19 -070035int strspn(const char *str, const char *spn);
36int strcspn(const char *str, const char *spn);
37long atol(const char *str);
Eric Biederman8ca8d762003-04-22 19:02:15 +000038
Patrick Rudolph03c7b052018-03-29 10:05:34 +020039/**
40 * Find a character in a string.
41 *
42 * @param s The string.
43 * @param c The character.
44 * @return A pointer to the last occurrence of the character in the
45 * string, or NULL if the character was not encountered within the string.
46 */
Julius Wernera66c9b82019-05-20 14:53:47 -070047char *strrchr(const char *s, int c);
Patrick Rudolph03c7b052018-03-29 10:05:34 +020048
Julius Wernera66c9b82019-05-20 14:53:47 -070049/*
50 * Parses an unsigned integer and moves the input pointer forward to the first
51 * character that's not a valid digit. s and *s must not be NULL. Result
52 * undefined if it overruns the return type size.
53 */
54unsigned int skip_atoi(char **s);
Stefan Reinauer36c83402009-03-01 10:16:01 +000055
Eric Biederman8ca8d762003-04-22 19:02:15 +000056#endif /* STRING_H */