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