string.h (3987B)
1/** @file string.h 2 Generic string functions. 3 */ 4#ifndef STRING_INCLUDE 5#define STRING_INCLUDE 6 7#include <types.h> 8 9/** Copies the string pointed to by __src__ (including the terminating 10 `\0' character) to the array pointed to by __dest__. 11 12 The strings may not overlap, and the destination string dest must 13 be large enough to receive the copy. 14 15 @param dest Array to copy into 16 @param src Array to copy from 17 18 @return A pointer to dest 19*/ 20char *strcpy(char *dest, const char *src) OLDCALL; 21 22/** Compares strings 23 24 @param s1 First string to compare 25 @param s2 Second string to compare 26 27 Returns: 28 \li > 0 if __s1__ > __s2__ 29 \li 0 if __s1__ == __s2__ 30 \li < 0 if __s1__ < __s2__ 31*/ 32int strcmp(const char *s1, const char *s2); 33 34/** Copies n bytes from memory area src to memory area dest. 35 36 The memory areas may not overlap. 37 38 @param dest Buffer to copy into 39 @param src Buffer to copy from 40 @param len Number of Bytes to copy 41*/ 42void *memcpy(void *dest, const void *src, size_t len); 43 44/** Copies n bytes from memory area src to memory area dest, areas may overlap 45 */ 46void *memmove (void *dest, const void *src, size_t n) OLDCALL; 47 48/** Fills the memory region __s__ with __n__ bytes using value __c__ 49 50 @param s Buffer to fill 51 @param c char value to fill with (truncated from int) 52 @param n Number of bytes to fill 53*/ 54void *memset (void *s, int c, size_t n) Z88DK_CALLEE; 55 56/** Reverses the characters in a string 57 58 @param s Pointer to string to reverse. 59 60 For example 'abcdefg' will become 'gfedcba'. 61 62 Banked as the string must be modifiable. 63 64 Returns: Pointer to __s__ 65*/ 66char *reverse(char *s) NONBANKED; 67 68/** Concatenate Strings. Appends string __s2__ to the end of string __s1__ 69 70 @param s1 String to append onto 71 @param s2 String to copy from 72 73 For example 'abc' and 'def' will become 'abcdef'. 74 75 String __s1__ must be large enough to store both __s1__ and __s2__. 76 77 Returns: Pointer to __s1__ 78*/ 79char *strcat(char *s1, const char *s2) NONBANKED; 80 81/** Calculates the length of a string 82 83 @param s String to calculate length of 84 85 Returns: Length of string not including the terminating `\0' character. 86*/ 87int strlen(const char *s) OLDCALL; 88 89/**Concatenate at most __n__ characters from string __s2__ onto the end of __s1__. 90 91 @param s1 String to append onto 92 @param s2 String to copy from 93 @param n Max number of characters to copy from __s2__ 94 95 String __s1__ must be large enough to store both __s1__ and __n__ characters of __s2__ 96 97 Returns: Pointer to __s1__ 98*/ 99char *strncat(char *s1, const char *s2, int n) NONBANKED; 100 101/** Compare strings (at most n characters): 102 103 @param s1 First string to compare 104 @param s2 Second string to compare 105 @param n Max number of characters to compare 106 107 Returns: 108 \li > 0 if __s1__ > __s2__ 109 \li 0 if __s1__ == __s2__ 110 \li < 0 if __s1__ < __s2__ 111*/ 112int strncmp(const char *s1, const char *s2, int n) NONBANKED; 113 114/** Copy __n__ characters from string __s2__ to __s1__ 115 116 117 @param s1 String to copy into 118 @param s2 String to copy from 119 @param n Max number of characters to copy from __s2__ 120 121 If __s2__ is shorter than __n__, the remaining 122 bytes in __s1__ are filled with \0. 123 124 Warning: If there is no \0 in the first __n__ bytes of __s2__ then __s1__ 125 will not be null terminated. 126 127 Returns: Pointer to __s1__ 128*/ 129char *strncpy(char *s1, const char *s2, int n) NONBANKED; 130 131/** Compares buffers 132 133 @param buf1 First buffer to compare 134 @param buf2 Second buffer to compare 135 @param count Buffer length 136 137 Returns: 138 \li > 0 if __buf1__ > __buf2__ 139 \li 0 if __buf1__ == __buf2__ 140 \li < 0 if __buf1__ < __buf2__ 141*/ 142int memcmp(const void *buf1, const void *buf2, size_t count) Z88DK_CALLEE; 143 144#endif