kb_machblue_core_string.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:3k
- //*****************************************************************************
- //File Name: kb_machblue_core_string.c
- //
- //Description: string function
- //
- // used by Machblue to access the platform's string formatting
- //
- //Author: steven
- //
- //Date: 2006.12.29
- //
- //Version: v1.0
- //*****************************************************************************
- #include "ctype.h"
- #include <stdio.h>
- #include "machblue_customer.h"
- #include "machblue_porting_core.h"
- /**
- * Converts letter to upper case.
- * @return upper case letter (locale dependent).
- */
- int mb_toupper(int c)
- {
- return toupper(c);
- }
- /**
- * Converts letter to lower case.
- * @return lower case letter (locale dependent).
- */
- int mb_tolower(int c)
- {
- return tolower(c);
- }
- /**
- * Prints a formated string based on the specified format. The output
- * is stored in the provided string.
- * @return the number of characters printed.
- */
- int mb_sprintf(mb_char_t *str,const mb_char_t *format,...)
- {
- int numChars;
- va_list args;
- va_start( args, format);
- numChars = mb_vsprintf(str, format, args) ;
- va_end(args);
-
- return numChars ;
- }
- /**
- * Prints a formated string based on the specified format. The intended output
- * is stdout. It may be redirected at the customer discretion.
- * @return the number of characters printed.
- */
- int mb_printf(const mb_char_t *format,...)
- {
- int numChars;
- va_list args;
- va_start( args, format);
- numChars = mb_vprintf(format, args) ;
- va_end(args);
- fflush(stdout) ;
-
- return numChars ;
- }
- /**
- * Prints a formated string based on the specified format (variable argument
- * list version). The output is stored in the provided string.
- * @return the number of characters printed.
- */
- int mb_vsprintf(mb_char_t *str,const mb_char_t *format,va_list args)
- {
- return vsprintf(str, format, args) ;
- }
- /**
- * Prints a formated string based on the specified format(variable argument
- * list version). The intended output is stdout. It may be redirected at the
- * customer discretion.
- * @return the number of characters printed.
- */
- int mb_vprintf(const mb_char_t *format,va_list args)
- {
- int numChars = vprintf(format, args) ;
-
- fflush(stdout) ;
-
- return numChars ;
- }
- /**
- * Compare two string.
- * @return 0 as success,or other value as failure.
- */
- int mb_strcmp(mb_char_t *s0,mb_char_t *s1)
- {
- while(*s0!=' '&&*s1!=' ')
- {
- if(*s0!=*s1)
- return (*s0>*s1)?1:-1;
-
- s0++;
- s1++;
- }
-
- if(*s0==*s1)
- return 0;
-
- return (*s0>*s1)?1:-1;
- }