X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Flib.c;h=a30bdfce091dab86acafc1a535dacdfba4eebd78;hb=7c5a60c8be053f65ecceb47be773ea21a050b186;hp=51dbe05843cea18e3f9cf5543297d9b16f8ae6d8;hpb=a4aa24536a1748c8ace1ef7abdc01108da417856;p=tpg%2Facess2.git diff --git a/Kernel/lib.c b/Kernel/lib.c index 51dbe058..a30bdfce 100644 --- a/Kernel/lib.c +++ b/Kernel/lib.c @@ -62,6 +62,8 @@ EXPORT(ByteSum); EXPORT(strlen); EXPORT(strcpy); EXPORT(strncpy); +EXPORT(strcat); +EXPORT(strncat); EXPORT(strcmp); EXPORT(strncmp); //EXPORT(strdup); @@ -313,22 +315,29 @@ int vsnprintf(char *__s, size_t __maxlen, const char *__format, va_list args) } itoa(tmpBuf, val, 10, minSize, pad); goto printString; - case 'u': + case 'u': // Unsigned GETVAL(); itoa(tmpBuf, val, 10, minSize, pad); goto printString; - case 'X': + case 'P': // Physical Address + PUTCH('0'); + PUTCH('x'); + if(sizeof(tPAddr) > 4) isLongLong = 1; + GETVAL(); + itoa(tmpBuf, val, 16, minSize, pad); + goto printString; + case 'X': // Hex if(BITS == 64) isLongLong = 1; // TODO: Handle non-x86 64-bit archs GETVAL(); itoa(tmpBuf, val, 16, minSize, pad); goto printString; - case 'x': + case 'x': // Lower case hex GETVAL(); itoa(tmpBuf, val, 16, minSize, pad); goto printString; - case 'o': + case 'o': // Octal GETVAL(); itoa(tmpBuf, val, 8, minSize, pad); goto printString; @@ -464,7 +473,6 @@ size_t strlen(const char *__str) } /** - * \fn char *strcpy(char *__str1, const char *__str2) * \brief Copy a string to a new location */ char *strcpy(char *__str1, const char *__str2) @@ -476,8 +484,8 @@ char *strcpy(char *__str1, const char *__str2) } /** - * \fn char *strncpy(char *__str1, const char *__str2, size_t max) * \brief Copy a string to a new location + * \note Copies at most `max` chars */ char *strncpy(char *__str1, const char *__str2, size_t max) { @@ -488,6 +496,32 @@ char *strncpy(char *__str1, const char *__str2, size_t max) return __str1; } +/** + * \brief Append a string to another + */ +char *strcat(char *__dest, const char *__src) +{ + while(*__dest++); + __dest--; + while(*__src) + *__dest++ = *__src++; + *__dest = '\0'; + return __dest; +} + +/** + * \brief Append at most \a n chars to a string from another + * \note At most n+1 chars are written (the dest is always zero terminated) + */ +char *strncat(char *__dest, const char *__src, size_t n) +{ + while(*__dest++); + while(*__src && n-- >= 1) + *__dest++ = *__src++; + *__dest = '\0'; + return __dest; +} + /** * \fn int strcmp(const char *str1, const char *str2) * \brief Compare two strings return the difference between @@ -874,7 +908,7 @@ int ModUtil_SetIdent(char *Dest, const char *Value) /** * \brief Convert a string of hexadecimal digits into a byte stream */ -int UnHex(Uint8 *Dest, size_t DestSize, const char *SourceString) +int UnHex(Uint8 *Dest, size_t DestSize, const char *SourceString) { int i;