00001 #ifndef __sh_utils_h__ 00002 #define __sh_utils_h__ 00003 00004 // Utilities that only require standard C or C++ includes in the 00005 // header. 00006 00007 #include <string.h> // memset 00008 00009 #ifdef __cplusplus 00010 #define EXTERN_C extern "C" 00011 #else 00012 #define EXTERN_C 00013 #endif 00014 00015 #define memzero(x) memset(&(x), 0, sizeof(x)) 00016 00017 #ifndef MAX 00018 #define MAX(a,b) (((a) > (b)) ? (a) : (b)) 00019 #endif 00020 00021 #define boolstr_true(x) ((x) ? "true" : "false") 00022 #define boolstr_yes(x) ((x) ? "yes" : "no") 00023 #define boolstr_on(x) ((x) ? "on" : "off") 00024 00025 // The caller must free the buffer. 00026 // Returns NULL on memory allocation failure. 00027 EXTERN_C char* get_stack_info_string(); 00028 00029 // Forms a JSON String text out of the given UTF-8 text. 00030 // The string will be quoted, and still UTF-8. 00031 EXTERN_C char* utf8ToJsonString(const char* text); 00032 00033 #ifdef __cplusplus 00034 #define DEFINE_CLEANUP_CLASS(name,type,free) \ 00035 class name \ 00036 { \ 00037 public: \ 00038 name(type aObj) : iObj(aObj) {} \ 00039 ~##name() { free; } \ 00040 private: \ 00041 type iObj; \ 00042 } 00043 #endif 00044 00045 #if defined(__SYMBIAN32__) 00046 #define IF_SYMBIAN_EXPR(x,y) (x) 00047 #define IF_SYMBIAN(x,y) { x ; } 00048 #define WHEN_SYMBIAN(stmt) { stmt ; } 00049 #define UNLESS_SYMBIAN(stmt) 00050 #define TRUE_ON_SYMBIAN 1 00051 #else 00052 #define IF_SYMBIAN_EXPR(x,y) (y) 00053 #define IF_SYMBIAN(x,y) { y ; } 00054 #define WHEN_SYMBIAN(stmt) 00055 #define UNLESS_SYMBIAN(stmt) { stmt ; } 00056 #define TRUE_ON_SYMBIAN 0 00057 #endif /* __SYMBIAN32__ */ 00058 00059 #if defined(__SYMBIAN32__) && defined(__cplusplus) 00060 #define DEFINE_FOR_SYMBIAN_CXX(def) def 00061 #define WHEN_SYMBIAN_CXX(stmt) { stmt ; } 00062 #define UNLESS_SYMBIAN_CXX(stmt) 00063 #else 00064 #define DEFINE_FOR_SYMBIAN_CXX(def) 00065 #define WHEN_SYMBIAN_CXX(stmt) 00066 #define UNLESS_SYMBIAN_CXX(stmt) { stmt ; } 00067 #endif 00068 00069 #ifdef __cplusplus 00070 #if !defined(__SYMBIAN32__) 00071 #define NONSHARABLE_CLASS(_name) class _name 00072 #endif /* __SYMBIAN32__ */ 00073 #endif 00074 00075 #endif /* __sh_utils_h__ */ 00076 00077 /** 00078 00079 sh_utils.h 00080 00081 Copyright 2009 Helsinki Institute for Information Technology (HIIT) 00082 and the authors. All rights reserved. 00083 00084 Authors: Tero Hasu <tero.hasu@hut.fi> 00085 00086 Permission is hereby granted, free of charge, to any person 00087 obtaining a copy of this software and associated documentation files 00088 (the "Software"), to deal in the Software without restriction, 00089 including without limitation the rights to use, copy, modify, merge, 00090 publish, distribute, sublicense, and/or sell copies of the Software, 00091 and to permit persons to whom the Software is furnished to do so, 00092 subject to the following conditions: 00093 00094 The above copyright notice and this permission notice shall be 00095 included in all copies or substantial portions of the Software. 00096 00097 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00098 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00099 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00100 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00101 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00102 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00103 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00104 SOFTWARE. 00105 00106 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:56 2011 by Doxygen 1.6.1