diff options
| author | Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com> | 2015-05-06 09:49:41 -0400 |
|---|---|---|
| committer | Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com> | 2015-05-06 09:49:41 -0400 |
| commit | a14921c5944c340056312f2f5b1728d698f628b1 (patch) | |
| tree | 110242b91b3ade02e586bd65b9aedb05511bd34a /include/str.h | |
| parent | 72bb39c0237f8bcc3afa8b623e8b097eec6d69cd (diff) | |
| parent | 7361f67dbd7f7fe98a807d3d12f90a87262124d6 (diff) | |
| download | efi-boot-shim-a14921c5944c340056312f2f5b1728d698f628b1.tar.gz efi-boot-shim-a14921c5944c340056312f2f5b1728d698f628b1.zip | |
Import upstream version 0.8
Diffstat (limited to 'include/str.h')
| -rw-r--r-- | include/str.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/str.h b/include/str.h new file mode 100644 index 00000000..0f3e003a --- /dev/null +++ b/include/str.h @@ -0,0 +1,45 @@ +#ifndef SHIM_STR_H +#define SHIM_STR_H + +static inline +__attribute__((unused)) +unsigned long strnlena(const CHAR8 *s, unsigned long n) +{ + unsigned long i; + for (i = 0; i <= n; i++) + if (s[i] == '\0') + break; + return i; +} + +static inline +__attribute__((unused)) +CHAR8 * +strncpya(CHAR8 *dest, const CHAR8 *src, unsigned long n) +{ + unsigned long i; + + for (i = 0; i < n && src[i] != '\0'; i++) + dest[i] = src[i]; + for (; i < n; i++) + dest[i] = '\0'; + + return dest; +} + +static inline +__attribute__((unused)) +CHAR8 * +strcata(CHAR8 *dest, const CHAR8 *src) +{ + unsigned long dest_len = strlena(dest); + unsigned long i; + + for (i = 0; src[i] != '\0'; i++) + dest[dest_len + i] = src[i]; + dest[dest_len + i] = '\0'; + + return dest; +} + +#endif /* SHIM_STR_H */ |
