00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _QORE_QORELIB_H
00024
00025 #define _QORE_QORELIB_H
00026
00027 #include <qore/common.h>
00028 #include <qore/QoreThreadLock.h>
00029 #include <qore/qore_bitopts.h>
00030 #include <qore/safe_dslist>
00031
00032 #include <time.h>
00033 #include <string.h>
00034 #include <strings.h>
00035 #include <stdlib.h>
00036 #include <stdio.h>
00037 #include <ctype.h>
00038
00043
00044 DLLEXPORT char *make_class_name(const char *fn);
00045
00047 DLLEXPORT QoreStringNode *q_sprintf(const class QoreListNode *params, int field, int offset, class ExceptionSink *xsink);
00048
00050 DLLEXPORT QoreStringNode *q_vsprintf(const class QoreListNode *params, int field, int offset, class ExceptionSink *xsink);
00051
00053 DLLEXPORT struct tm *q_localtime(const time_t *clock, struct tm *tms);
00054
00056 DLLEXPORT struct tm *q_gmtime(const time_t *clock, struct tm *tms);
00057
00059 DLLEXPORT char *q_basename(const char *path);
00060
00062 DLLEXPORT char *q_basenameptr(const char *path);
00063
00065 DLLEXPORT char *q_dirname(const char *path);
00066
00068 DLLEXPORT void *q_realloc(void *ptr, size_t size);
00069
00071 DLLEXPORT void qore_setup_argv(int pos, int argc, char *argv[]);
00072
00074 DLLEXPORT qore_license_t qore_get_license();
00075
00077 DLLEXPORT void qore_exit_process(int rc);
00078
00080
00082 class FeatureList : public safe_dslist<std::string>
00083 {
00084 private:
00086 DLLLOCAL FeatureList(const FeatureList&);
00087
00089 DLLLOCAL FeatureList& operator=(const FeatureList&);
00090
00091 public:
00093 DLLLOCAL FeatureList();
00094
00096 DLLLOCAL ~FeatureList();
00097 };
00098
00100 DLLEXPORT extern FeatureList qoreFeatureList;
00101
00103 static inline char *strchrs(const char *str, const char *chars)
00104 {
00105 while (*str)
00106 {
00107 if (strchr(chars, *str))
00108 return (char *)str;
00109 str++;
00110 }
00111 return 0;
00112 }
00113
00115 static inline char *strnchr(const char *str, int len, char c)
00116 {
00117 int i = 0;
00118 while (i++ != len)
00119 {
00120 if (*str == c)
00121 return (char *)str;
00122 ++str;
00123 }
00124 return 0;
00125 }
00126
00128 static inline void strtolower(char *str)
00129 {
00130 while (*(str))
00131 {
00132 (*str) = tolower(*str);
00133 str++;
00134 }
00135 }
00136
00138 static inline char *strtoupper(char *str)
00139 {
00140 char *p = str;
00141 while (*(p))
00142 {
00143 *p = toupper(*p);
00144 p++;
00145 }
00146 return str;
00147 }
00148
00150 DLLEXPORT int getSecZeroInt(const AbstractQoreNode *a);
00151
00153 DLLEXPORT int64 getSecZeroBigInt(const AbstractQoreNode *a);
00154
00156 DLLEXPORT int getSecMinusOneInt(const AbstractQoreNode *a);
00157
00159 DLLEXPORT int64 getSecMinusOneBigInt(const AbstractQoreNode *a);
00160
00162 DLLEXPORT int getMsZeroInt(const AbstractQoreNode *a);
00163
00165 DLLEXPORT int64 getMsZeroBigInt(const AbstractQoreNode *a);
00166
00168 DLLEXPORT int getMsMinusOneInt(const AbstractQoreNode *a);
00169
00171 DLLEXPORT int64 getMsMinusOneBigInt(const AbstractQoreNode *a);
00172
00174 DLLEXPORT int getMicroSecZeroInt(const AbstractQoreNode *a);
00175
00177 static inline bool is_nothing(const AbstractQoreNode *n)
00178 {
00179 if (!n || n->getType() == NT_NOTHING)
00180 return true;
00181
00182 return false;
00183 }
00184
00186 static inline void discard(AbstractQoreNode *n, ExceptionSink *xsink)
00187 {
00188 if (n)
00189 n->deref(xsink);
00190 }
00191
00192 static inline const char *get_type_name(const AbstractQoreNode *n)
00193 {
00194 return n ? n->getTypeName() : "NOTHING";
00195 }
00196
00197 class BinaryNode;
00198 class QoreStringNode;
00199 class ExceptionSink;
00200
00202 DLLEXPORT BinaryNode *qore_deflate(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00204 DLLEXPORT QoreStringNode *qore_inflate_to_string(const BinaryNode *b, const QoreEncoding *enc, ExceptionSink *xsink);
00206 DLLEXPORT BinaryNode *qore_inflate_to_binary(const BinaryNode *b, ExceptionSink *xsink);
00208 DLLEXPORT BinaryNode *qore_gzip(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00210 DLLEXPORT QoreStringNode *qore_gunzip_to_string(const BinaryNode *bin, const QoreEncoding *enc, ExceptionSink *xsink);
00212 DLLEXPORT BinaryNode *qore_gunzip_to_binary(const BinaryNode *bin, ExceptionSink *xsink);
00214 DLLEXPORT BinaryNode *qore_bzip2(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00216 DLLEXPORT QoreStringNode *qore_bunzip2_to_string(const BinaryNode *bin, const QoreEncoding *enc, ExceptionSink *xsink);
00218 DLLEXPORT BinaryNode *qore_bunzip2_to_binary(const BinaryNode *bin, ExceptionSink *xsink);
00219
00221 #define QORE_OPT_ATOMIC_OPERATIONS "atomic operations"
00223 #define QORE_OPT_STACK_GUARD "stack guard"
00225 #define QORE_OPT_RUNTIME_STACK_TRACE "runtime stack tracing"
00227 #define QORE_OPT_LIBRARY_DEBUGGING "library debugging"
00229 #define QORE_OPT_SHA224 "openssl sha224"
00231 #define QORE_OPT_SHA256 "openssl sha256"
00233 #define QORE_OPT_SHA384 "openssl sha384"
00235 #define QORE_OPT_SHA512 "openssl sha512"
00237 #define QORE_OPT_MDC2 "openssl mdc2"
00239 #define QORE_OPT_RC5 "openssl rc5"
00241 #define QORE_OPT_FUNC_ROUND "round()"
00243 #define QORE_OPT_FUNC_TIMEGM "timegm()"
00245 #define QORE_OPT_FUNC_SETEUID "seteuid()"
00247 #define QORE_OPT_FUNC_SETEGID "setegid()"
00249 #define QORE_OPT_FUNC_PARSEXMLWITHSCHEMA "parseXMLWithSchema()"
00250
00252 #define QO_OPTION 0
00253 #define QO_ALGORITHM 1
00254 #define QO_FUNCTION 2
00255
00257 struct qore_option_s {
00258 const char *option;
00259 const char *constant;
00260 int type;
00261 bool value;
00262 };
00263
00264
00265
00267 DLLEXPORT extern const qore_option_s *qore_option_list;
00269 DLLEXPORT extern size_t qore_option_list_size;
00270
00271 #endif // _QORE_QORELIB_H