1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef bbs_STRING_EM_H 18 #define bbs_STRING_EM_H 19 20 /** 21 * This file contains string related functions. 22 */ 23 24 /* ---- includes ----------------------------------------------------------- */ 25 26 #include <stdarg.h> 27 28 #include "b_BasicEm/Basic.h" 29 30 /* ---- related objects --------------------------------------------------- */ 31 32 /* ---- typedefs ----------------------------------------------------------- */ 33 34 /* ---- constants ---------------------------------------------------------- */ 35 36 /* ---- external functions ------------------------------------------------- */ 37 38 /** copies a string from srcA to dstA; returns dstA */ 39 char* bbs_strcpy( char* dstA, const char* srcA ); 40 41 /** copies sizeA caracters from from srcA to dstA; returns dstA */ 42 char* bbs_strncpy( char* dstA, const char* srcA, uint32 sizeA ); 43 44 /** adds a string srcA to string dstA; returns dstA */ 45 char* bbs_strcat( char* dstA, const char* srcA ); 46 47 /** adds sizeA characters from srcA to string dstA; returns dstA */ 48 char* bbs_strncat( char* dstA, const char* srcA, uint32 sizeA ); 49 50 /** returns number of characters in string excluding terminating 0 */ 51 uint32 bbs_strlen( const char* strA ); 52 53 /** returns true if both strings are equal */ 54 flag bbs_strequal( const char* str1A, const char* str2A ); 55 56 /** returns true if all characters of the smaller of both string are equal with the other string */ 57 flag bbs_strmatch( const char* str1A, const char* str2A ); 58 59 /** writes a formated string to buffer with size limitation; returns number of characters written 60 * Not all possible format types of stdlib function snprintf are handled in this function 61 */ 62 uint32 bbs_snprintf( char* dstA, uint32 bufSizeA, const char* formatA, ... ); 63 64 /** writes a formated string to buffer with size limitation; returns number of characters written 65 * Not all possible format types of stdlib function vsnprintf are handled in this function 66 */ 67 uint32 bbs_vsnprintf( char* dstA, uint32 bufSizeA, const char* formatA, va_list argsA ); 68 69 /** converts a string to an integer */ 70 int32 bbs_atoi( const char* strA ); 71 72 #endif /* bbs_STRING_EM_H */ 73 74