The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2003-2012 Broadcom Corporation |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ******************************************************************************/ |
| 18 | |
| 19 | /****************************************************************************** |
| 20 | * |
| 21 | * Basic utility functions. |
| 22 | * |
| 23 | ******************************************************************************/ |
| 24 | #ifndef UTL_H |
| 25 | #define UTL_H |
| 26 | |
Chris Manton | 83e2c34 | 2014-09-29 21:37:44 -0700 | [diff] [blame] | 27 | #include "bt_types.h" |
Mike J. Chen | 60126e4 | 2014-01-31 18:13:09 -0800 | [diff] [blame] | 28 | #include "bt_utils.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 29 | |
| 30 | /***************************************************************************** |
| 31 | ** Constants |
| 32 | *****************************************************************************/ |
| 33 | /*** class of device settings ***/ |
| 34 | #define BTA_UTL_SET_COD_MAJOR_MINOR 0x01 |
| 35 | #define BTA_UTL_SET_COD_SERVICE_CLASS 0x02 /* only set the bits in the input */ |
| 36 | #define BTA_UTL_CLR_COD_SERVICE_CLASS 0x04 |
| 37 | #define BTA_UTL_SET_COD_ALL 0x08 /* take service class as the input (may clear some set bits!!) */ |
| 38 | #define BTA_UTL_INIT_COD 0x0a |
| 39 | |
| 40 | /***************************************************************************** |
| 41 | ** Type Definitions |
| 42 | *****************************************************************************/ |
| 43 | |
| 44 | /** for utl_set_device_class() **/ |
| 45 | typedef struct |
| 46 | { |
| 47 | UINT8 minor; |
| 48 | UINT8 major; |
| 49 | UINT16 service; |
| 50 | } tBTA_UTL_COD; |
| 51 | |
| 52 | |
| 53 | #ifdef __cplusplus |
| 54 | extern "C" |
| 55 | { |
| 56 | #endif |
| 57 | |
| 58 | /***************************************************************************** |
| 59 | ** External Function Declarations |
| 60 | *****************************************************************************/ |
| 61 | |
| 62 | /******************************************************************************* |
| 63 | ** |
| 64 | ** Function utl_str2int |
| 65 | ** |
| 66 | ** Description This utility function converts a character string to an |
| 67 | ** integer. Acceptable values in string are 0-9. If invalid |
| 68 | ** string or string value too large, -1 is returned. |
| 69 | ** |
| 70 | ** |
| 71 | ** Returns Integer value or -1 on error. |
| 72 | ** |
| 73 | *******************************************************************************/ |
| 74 | extern INT16 utl_str2int(const char *p_s); |
| 75 | |
| 76 | /******************************************************************************* |
| 77 | ** |
Sumit Bajpai | 840cf9b | 2015-01-09 14:49:00 +0530 | [diff] [blame] | 78 | ** Function utl_str2int32 |
| 79 | ** |
| 80 | ** Description This utility function converts a character string to an |
| 81 | ** int32. Acceptable values in string are 0-9. If |
| 82 | ** invalid string or string value too large, -1 is returned. |
| 83 | ** |
| 84 | ** |
| 85 | ** Returns int32_t value or -1 on error. |
| 86 | ** |
| 87 | *******************************************************************************/ |
| 88 | extern INT32 utl_str2int32(const char *p_s); |
| 89 | |
| 90 | /******************************************************************************* |
| 91 | ** |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 92 | ** Function utl_strucmp |
| 93 | ** |
| 94 | ** Description This utility function compares two strings in uppercase. |
| 95 | ** String p_s must be uppercase. String p_t is converted to |
| 96 | ** uppercase if lowercase. If p_s ends first, the substring |
| 97 | ** match is counted as a match. |
| 98 | ** |
| 99 | ** |
| 100 | ** Returns 0 if strings match, nonzero otherwise. |
| 101 | ** |
| 102 | *******************************************************************************/ |
| 103 | extern int utl_strucmp(const char *p_s, const char *p_t); |
| 104 | |
| 105 | /******************************************************************************* |
| 106 | ** |
| 107 | ** Function utl_itoa |
| 108 | ** |
| 109 | ** Description This utility function converts a UINT16 to a string. The |
| 110 | ** string is NULL-terminated. The length of the string is |
| 111 | ** returned. |
| 112 | ** |
| 113 | ** |
| 114 | ** Returns Length of string. |
| 115 | ** |
| 116 | *******************************************************************************/ |
| 117 | extern UINT8 utl_itoa(UINT16 i, char *p_s); |
| 118 | |
| 119 | /******************************************************************************* |
| 120 | ** |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 121 | ** Function utl_set_device_class |
| 122 | ** |
| 123 | ** Description This function updates the local Device Class. |
| 124 | ** |
| 125 | ** Parameters: |
| 126 | ** p_cod - Pointer to the device class to set to |
| 127 | ** |
| 128 | ** cmd - the fields of the device class to update. |
| 129 | ** BTA_UTL_SET_COD_MAJOR_MINOR, - overwrite major, minor class |
| 130 | ** BTA_UTL_SET_COD_SERVICE_CLASS - set the bits in the input |
| 131 | ** BTA_UTL_CLR_COD_SERVICE_CLASS - clear the bits in the input |
| 132 | ** BTA_UTL_SET_COD_ALL - overwrite major, minor, set the bits in service class |
| 133 | ** BTA_UTL_INIT_COD - overwrite major, minor, and service class |
| 134 | ** |
| 135 | ** Returns TRUE if successful, Otherwise FALSE |
| 136 | ** |
| 137 | *******************************************************************************/ |
| 138 | extern BOOLEAN utl_set_device_class(tBTA_UTL_COD *p_cod, UINT8 cmd); |
| 139 | |
| 140 | /******************************************************************************* |
| 141 | ** |
| 142 | ** Function utl_isintstr |
| 143 | ** |
| 144 | ** Description This utility function checks if the given string is an |
| 145 | ** integer string or not |
| 146 | ** |
| 147 | ** |
| 148 | ** Returns TRUE if successful, Otherwise FALSE |
| 149 | ** |
| 150 | *******************************************************************************/ |
| 151 | extern BOOLEAN utl_isintstr(const char *p_s); |
| 152 | |
| 153 | /******************************************************************************* |
| 154 | ** |
| 155 | ** Function utl_isdialstr |
| 156 | ** |
| 157 | ** Description This utility function checks if the given string contains |
| 158 | ** only dial digits or not |
| 159 | ** |
| 160 | ** |
| 161 | ** Returns TRUE if successful, Otherwise FALSE |
| 162 | ** |
| 163 | *******************************************************************************/ |
| 164 | extern BOOLEAN utl_isdialstr(const char *p_s); |
| 165 | |
| 166 | #ifdef __cplusplus |
| 167 | } |
| 168 | #endif |
| 169 | |
| 170 | #endif /* UTL_H */ |