00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __CLASSAD_COMMON_H__
00023 #define __CLASSAD_COMMON_H__
00024
00025 #ifndef WIN32
00026 #include <strings.h>
00027 #endif
00028
00029 #if defined( WANT_CLASSAD_NAMESPACE ) && defined(__cplusplus)
00030 #define BEGIN_NAMESPACE( x ) namespace x {
00031 #define END_NAMESPACE }
00032 #else
00033 #define BEGIN_NAMESPACE( x )
00034 #define END_NAMESPACE
00035 #endif
00036
00037 #ifndef _GNU_SOURCE
00038 #define _GNU_SOURCE
00039 #endif
00040
00041 #ifndef __EXTENSIONS__
00042 #define __EXTENSIONS__
00043 #endif
00044
00045 #ifdef WIN32
00046
00047
00048 #define _STLP_NEW_PLATFORM_SDK
00049 #define _STLP_NO_OWN_IOSTREAMS 1
00050
00051
00052
00053 #define _CRT_NONSTDC_NO_WARNINGS
00054
00055
00056
00057
00058 #pragma warning( disable : 4244 )
00059
00060 #endif
00061
00062 #include <stdio.h>
00063 #include <stdlib.h>
00064 #include <time.h>
00065 #include <limits.h>
00066 #include <math.h>
00067 #ifndef WIN32
00068 #include <unistd.h>
00069 #define DLL_IMPORT_MAGIC
00070 #endif
00071 #include <errno.h>
00072 #include <ctype.h>
00073
00074
00075
00076
00077 #ifdef WIN32
00078
00079
00080 #ifndef DLL_IMPORT_MAGIC
00081 #define DLL_IMPORT_MAGIC __declspec(dllimport)
00082 #endif
00083 #include <windows.h>
00084 #include <float.h>
00085 #include <io.h>
00086 #define fsync _commit
00087 #define strcasecmp _stricmp
00088 #ifndef rint
00089 #define rint(num) floor(num + .5)
00090 #endif
00091 #define isnan _isnan
00092
00093
00094 #include <hash_map>
00095
00096 #define snprintf _snprintf
00097
00098
00099
00100 #pragma warning( disable : 4660 )
00101
00102 #pragma warning( disable : 4800 )
00103
00104 #pragma warning( disable : 4786 )
00105
00106 #endif // WIN32
00107
00108
00109 #include "classad/debug.h"
00110
00111 #ifdef __cplusplus
00112 #include <string>
00113 #endif
00114 #include <cstring>
00115 #include <string.h>
00116
00117 BEGIN_NAMESPACE( classad )
00118
00119 extern const char * const ATTR_AD;
00120 extern const char * const ATTR_CONTEXT;
00121 extern const char * const ATTR_DEEP_MODS;
00122 extern const char * const ATTR_DELETE_AD;
00123 extern const char * const ATTR_DELETES;
00124 extern const char * const ATTR_KEY;
00125 extern const char * const ATTR_NEW_AD;
00126 extern const char * const ATTR_OP_TYPE;
00127 extern const char * const ATTR_PARENT_VIEW_NAME;
00128 extern const char * const ATTR_PARTITION_EXPRS;
00129 extern const char * const ATTR_PARTITIONED_VIEWS;
00130 extern const char * const ATTR_PROJECT_THROUGH;
00131 extern const char * const ATTR_RANK_HINTS;
00132 extern const char * const ATTR_REPLACE;
00133 extern const char * const ATTR_SUBORDINATE_VIEWS;
00134 extern const char * const ATTR_UPDATES;
00135 extern const char * const ATTR_WANT_LIST;
00136 extern const char * const ATTR_WANT_PRELUDE;
00137 extern const char * const ATTR_WANT_RESULTS;
00138 extern const char * const ATTR_WANT_POSTLUDE;
00139 extern const char * const ATTR_VIEW_INFO;
00140 extern const char * const ATTR_VIEW_NAME;
00141 extern const char * const ATTR_XACTION_NAME;
00142
00143 extern const char * const ATTR_REQUIREMENTS;
00144 extern const char * const ATTR_RANK;
00145
00146 #if defined(__cplusplus)
00147 struct CaseIgnLTStr {
00148 bool operator( )( const std::string &s1, const std::string &s2 ) const {
00149 return( strcasecmp( s1.c_str( ), s2.c_str( ) ) < 0 );
00150 }
00151 };
00152
00153 struct CaseIgnEqStr {
00154 bool operator( )( const std::string &s1, const std::string &s2 ) const {
00155 return( strcasecmp( s1.c_str( ), s2.c_str( ) ) == 0 );
00156 }
00157 };
00158
00159 class ExprTree;
00160 struct ExprHash {
00161 size_t operator()( const ExprTree *const &x ) const {
00162 return( (size_t)x );
00163 }
00164 };
00165
00166 struct StringHash {
00167 size_t operator()( const std::string &s ) const {
00168 unsigned long h = 0;
00169 char const *ch;
00170 for( ch = s.c_str(); *ch; ch++ ) {
00171 h = 5*h + (unsigned char)*ch;
00172 }
00173 return (size_t)h;
00174 }
00175 };
00176
00177 struct StringCaseIgnHash
00178 #ifdef WIN32
00179 : public stdext::hash_compare <std::string>
00180 #endif
00181 {
00182 size_t operator()( const std::string &s ) const {
00183 unsigned long h = 0;
00184 char const *ch;
00185 for( ch = s.c_str(); *ch; ch++ ) {
00186 h = 5*h + (unsigned char)tolower(*ch);
00187 }
00188 return (size_t)h;
00189 }
00190 #ifdef WIN32
00191
00192
00193 bool operator( )( const std::string &s1, const std::string &s2 ) const {
00194 return( strcasecmp( s1.c_str( ), s2.c_str( ) ) < 0 );
00195 }
00196 #endif
00197 };
00198 extern std::string CondorErrMsg;
00199 #endif
00200
00201 extern int CondorErrno;
00202
00203 END_NAMESPACE
00204
00205 char* strnewp( const char* );
00206
00207 #include "classad/classadErrno.h"
00208
00209 #endif//__CLASSAD_COMMON_H__