• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (C) 2007-2008 The Android Open Source Project
2 **
3 ** This software is licensed under the terms of the GNU General Public
4 ** License version 2, as published by the Free Software Foundation, and
5 ** may be copied, distributed, and modified under those terms.
6 **
7 ** This program is distributed in the hope that it will be useful,
8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 ** GNU General Public License for more details.
11 */
12 #ifndef _ANDROID_UTILS_MISC_H
13 #define _ANDROID_UTILS_MISC_H
14 
15 #include <stdint.h>
16 
17 /** TABULAR OUTPUT
18  **
19  ** prints a list of strings in row/column format
20  **
21  **/
22 
23 extern void   print_tabular( const char** strings, int  count,
24                              const char*  prefix,  int  width );
25 
26 /** CHARACTER TRANSLATION
27  **
28  ** converts one character into another in strings
29  **/
30 
31 extern void   buffer_translate_char( char*        buff,
32                                      unsigned     buffLen,
33                                      const char*  src,
34                                      char         fromChar,
35                                      char         toChar );
36 
37 extern void   string_translate_char( char*  str, char from, char to );
38 
39 /** TEMP CHAR STRINGS
40  **
41  ** implement a circular ring of temporary string buffers
42  **/
43 
44 extern char*  tempstr_get( int   size );
45 extern char*  tempstr_format( const char*  fmt, ... );
46 
47 /** QUOTING
48  **
49  ** dumps a human-readable version of a string. this replaces
50  ** newlines with \n, etc...
51  **/
52 
53 extern const char*   quote_bytes( const char*  str, int  len );
54 extern const char*   quote_str( const char*  str );
55 
56 /** DECIMAL AND HEXADECIMAL CHARACTER SEQUENCES
57  **/
58 
59 /* decodes a sequence of 'len' hexadecimal chars from 'hex' into
60  * an integer. returns -1 in case of error (i.e. badly formed chars)
61  */
62 extern int    hex2int( const uint8_t*  hex, int  len );
63 
64 /* encodes an integer 'val' into 'len' hexadecimal charaters into 'hex' */
65 extern void   int2hex( uint8_t*  hex, int  len, int  val );
66 
67 #endif /* _ANDROID_UTILS_MISC_H */
68