git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/include/asm/mos6502/string.h

      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 */
     20 char *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 */
     32 int 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 */
     42 void *__memcpy(void *dest, const void *src, size_t len);
     43 #define memcpy(dst, src, n) __memcpy(dst, src, n)
     44 
     45 /** Copies n bytes from memory area src to memory area dest, areas may overlap
     46  */
     47 void *memmove (void *dest, const void *src, size_t n) OLDCALL;
     48 
     49 /** Fills the memory region __s__ with __n__ bytes using value __c__
     50 
     51     @param s         Buffer to fill
     52     @param c         char value to fill with (truncated from int)
     53     @param n         Number of bytes to fill
     54 */
     55 void *memset (void *s, int c, size_t n);
     56 
     57 /** Reverses the characters in a string
     58 
     59     @param s         Pointer to string to reverse.
     60 
     61     For example 'abcdefg' will become 'gfedcba'.
     62 
     63     Banked as the string must be modifiable.
     64 
     65     Returns: Pointer to __s__
     66 */
     67 char *reverse(char *s) NONBANKED;
     68 
     69 /** Concatenate Strings. Appends string __s2__ to the end of string __s1__
     70 
     71     @param s1         String to append onto
     72     @param s2         String to copy from
     73 
     74     For example 'abc' and 'def' will become 'abcdef'.
     75 
     76     String __s1__ must be large enough to store both __s1__ and __s2__.
     77 
     78     Returns: Pointer to __s1__
     79 */
     80 char *strcat(char *s1, const char *s2) NONBANKED;
     81 
     82 /** Calculates the length of a string
     83 
     84     @param s         String to calculate length of
     85 
     86     Returns: Length of string not including the terminating `\0' character.
     87 */
     88 int strlen(const char *s) OLDCALL;
     89 
     90 /**Concatenate at most __n__ characters from string __s2__ onto the end of __s1__.
     91 
     92     @param s1         String to append onto
     93     @param s2         String to copy from
     94     @param n          Max number of characters to copy from __s2__
     95 
     96     String __s1__ must be large enough to store both __s1__ and __n__ characters of __s2__
     97 
     98     Returns: Pointer to __s1__
     99 */
    100 char *strncat(char *s1, const char *s2, int n) NONBANKED;
    101 
    102 /** Compare strings (at most n characters):
    103 
    104     @param s1         First string to compare
    105     @param s2         Second string to compare
    106     @param n          Max number of characters to compare
    107 
    108     Returns:
    109     \li > 0 if __s1__ > __s2__
    110     \li 0 if __s1__ == __s2__
    111     \li < 0 if __s1__ < __s2__
    112 */
    113 int strncmp(const char *s1, const char *s2, int n) NONBANKED;
    114 
    115 /** Copy __n__ characters from string __s2__ to __s1__
    116 
    117 
    118     @param s1         String to copy into
    119     @param s2         String to copy from
    120     @param n          Max number of characters to copy from __s2__
    121 
    122     If __s2__ is shorter than __n__, the remaining
    123     bytes in __s1__ are filled with \0.
    124 
    125     Warning: If there is no \0 in the first __n__ bytes of __s2__ then __s1__
    126     will not be null terminated.
    127 
    128     Returns: Pointer to __s1__
    129 */
    130 char *strncpy(char *s1, const char *s2, int n) NONBANKED;
    131 
    132 /** Compares buffers
    133 
    134     @param buf1         First buffer to compare
    135     @param buf2         Second buffer to compare
    136     @param count        Buffer length
    137 
    138     Returns:
    139     \li > 0 if __buf1__ > __buf2__
    140     \li 0 if __buf1__ == __buf2__
    141     \li < 0 if __buf1__ < __buf2__
    142 */
    143 int memcmp(const void *buf1, const void *buf2, size_t count);
    144 
    145 #endif

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.