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 #define _QORE_HAS_QORE_XMLNODE_CLASS 1
00045
00047 #define _QORE_HAS_QORE_XMLREADER_CLASS 1
00048
00050 #define _QORE_HAS_QORE_XMLDOC_CLASS 1
00051
00053 DLLEXPORT char *make_class_name(const char *fn);
00054
00056 DLLEXPORT QoreStringNode *q_sprintf(const class QoreListNode *params, int field, int offset, class ExceptionSink *xsink);
00057
00059 DLLEXPORT QoreStringNode *q_vsprintf(const class QoreListNode *params, int field, int offset, class ExceptionSink *xsink);
00060
00062 DLLEXPORT struct tm *q_localtime(const time_t *clock, struct tm *tms);
00063
00065 DLLEXPORT struct tm *q_gmtime(const time_t *clock, struct tm *tms);
00066
00068 DLLEXPORT char *q_basename(const char *path);
00069
00071 DLLEXPORT char *q_basenameptr(const char *path);
00072
00074 DLLEXPORT char *q_dirname(const char *path);
00075
00077 DLLEXPORT void *q_realloc(void *ptr, size_t size);
00078
00080 DLLEXPORT void qore_setup_argv(int pos, int argc, char *argv[]);
00081
00083 DLLEXPORT qore_license_t qore_get_license();
00084
00086 DLLEXPORT void qore_exit_process(int rc);
00087
00089
00091 class FeatureList : public safe_dslist<std::string> {
00092 private:
00094 DLLLOCAL FeatureList(const FeatureList&);
00095
00097 DLLLOCAL FeatureList& operator=(const FeatureList&);
00098
00099 public:
00101 DLLLOCAL FeatureList();
00102
00104 DLLLOCAL ~FeatureList();
00105 };
00106
00108 DLLEXPORT extern FeatureList qoreFeatureList;
00109
00111 static inline char *strchrs(const char *str, const char *chars) {
00112 while (*str) {
00113 if (strchr(chars, *str))
00114 return (char *)str;
00115 str++;
00116 }
00117 return 0;
00118 }
00119
00121 static inline char *strnchr(const char *str, int len, char c) {
00122 int i = 0;
00123 while (i++ != len) {
00124 if (*str == c)
00125 return (char *)str;
00126 ++str;
00127 }
00128 return 0;
00129 }
00130
00132 static inline void strtolower(char *str) {
00133 while (*(str)) {
00134 (*str) = tolower(*str);
00135 str++;
00136 }
00137 }
00138
00140 static inline char *strtoupper(char *str) {
00141 char *p = str;
00142 while (*(p)) {
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 if (!n || n->getType() == NT_NOTHING)
00179 return true;
00180
00181 return false;
00182 }
00183
00185 static inline void discard(AbstractQoreNode *n, ExceptionSink *xsink) {
00186 if (n)
00187 n->deref(xsink);
00188 }
00189
00190 static inline const char *get_type_name(const AbstractQoreNode *n) {
00191 return n ? n->getTypeName() : "NOTHING";
00192 }
00193
00194 class BinaryNode;
00195 class QoreStringNode;
00196 class ExceptionSink;
00197
00199 DLLEXPORT BinaryNode *qore_deflate(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00201 DLLEXPORT QoreStringNode *qore_inflate_to_string(const BinaryNode *b, const QoreEncoding *enc, ExceptionSink *xsink);
00203 DLLEXPORT BinaryNode *qore_inflate_to_binary(const BinaryNode *b, ExceptionSink *xsink);
00205 DLLEXPORT BinaryNode *qore_gzip(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00207 DLLEXPORT QoreStringNode *qore_gunzip_to_string(const BinaryNode *bin, const QoreEncoding *enc, ExceptionSink *xsink);
00209 DLLEXPORT BinaryNode *qore_gunzip_to_binary(const BinaryNode *bin, ExceptionSink *xsink);
00211 DLLEXPORT BinaryNode *qore_bzip2(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00213 DLLEXPORT QoreStringNode *qore_bunzip2_to_string(const BinaryNode *bin, const QoreEncoding *enc, ExceptionSink *xsink);
00215 DLLEXPORT BinaryNode *qore_bunzip2_to_binary(const BinaryNode *bin, ExceptionSink *xsink);
00216
00218 #define QORE_OPT_ATOMIC_OPERATIONS "atomic operations"
00220 #define QORE_OPT_STACK_GUARD "stack guard"
00222 #define QORE_OPT_RUNTIME_STACK_TRACE "runtime stack tracing"
00224 #define QORE_OPT_LIBRARY_DEBUGGING "library debugging"
00226 #define QORE_OPT_SHA224 "openssl sha224"
00228 #define QORE_OPT_SHA256 "openssl sha256"
00230 #define QORE_OPT_SHA384 "openssl sha384"
00232 #define QORE_OPT_SHA512 "openssl sha512"
00234 #define QORE_OPT_MDC2 "openssl mdc2"
00236 #define QORE_OPT_RC5 "openssl rc5"
00238 #define QORE_OPT_FUNC_ROUND "round()"
00240 #define QORE_OPT_FUNC_TIMEGM "timegm()"
00242 #define QORE_OPT_FUNC_SETEUID "seteuid()"
00244 #define QORE_OPT_FUNC_SETEGID "setegid()"
00246 #define QORE_OPT_FUNC_PARSEXMLWITHSCHEMA "parseXMLWithSchema()"
00248 #define QORE_OPT_FUNC_PARSEXMLWITHRELAXNG "parseXMLWithRelaxNG()"
00249
00251 #define QO_OPTION 0
00252 #define QO_ALGORITHM 1
00253 #define QO_FUNCTION 2
00254
00256 struct qore_option_s {
00257 const char *option;
00258 const char *constant;
00259 int type;
00260 bool value;
00261 };
00262
00263
00264
00266 DLLEXPORT extern const qore_option_s *qore_option_list;
00268 DLLEXPORT extern size_t qore_option_list_size;
00269
00270 #endif // _QORE_QORELIB_H