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 #include <sys/types.h>
00039
00044
00045 #define _QORE_HAS_QORE_XMLNODE_CLASS 1
00046
00048 #define _QORE_HAS_QORE_XMLREADER_CLASS 1
00049
00051 #define _QORE_HAS_QORE_XMLDOC_CLASS 1
00052
00054 DLLEXPORT char *make_class_name(const char *fn);
00055
00057 DLLEXPORT QoreStringNode *q_sprintf(const class QoreListNode *params, int field, int offset, class ExceptionSink *xsink);
00058
00060 DLLEXPORT QoreStringNode *q_vsprintf(const class QoreListNode *params, int field, int offset, class ExceptionSink *xsink);
00061
00063 DLLEXPORT struct tm *q_localtime(const time_t *clock, struct tm *tms);
00064
00066 DLLEXPORT struct tm *q_gmtime(const time_t *clock, struct tm *tms);
00067
00069 DLLEXPORT char *q_basename(const char *path);
00070
00072 DLLEXPORT char *q_basenameptr(const char *path);
00073
00075 DLLEXPORT char *q_dirname(const char *path);
00076
00078 DLLEXPORT void *q_realloc(void *ptr, size_t size);
00079
00081 DLLEXPORT QoreHashNode *q_getpwuid(uid_t uid);
00082
00084 DLLEXPORT QoreHashNode *q_getpwnam(const char *name);
00085
00087 DLLEXPORT QoreHashNode *q_getgrgid(uid_t uid);
00088
00090 DLLEXPORT QoreHashNode *q_getgrnam(const char *name);
00091
00093
00098 int q_uname2uid(const char *name, uid_t &uid);
00099
00101
00106 int q_gname2gid(const char *name, gid_t &gid);
00107
00109 DLLEXPORT void qore_setup_argv(int pos, int argc, char *argv[]);
00110
00112 DLLEXPORT qore_license_t qore_get_license();
00113
00115 DLLEXPORT void qore_exit_process(int rc);
00116
00118
00120 class FeatureList : public safe_dslist<std::string> {
00121 private:
00123 DLLLOCAL FeatureList(const FeatureList&);
00124
00126 DLLLOCAL FeatureList& operator=(const FeatureList&);
00127
00128 public:
00130 DLLLOCAL FeatureList();
00131
00133 DLLLOCAL ~FeatureList();
00134 };
00135
00137 DLLEXPORT extern FeatureList qoreFeatureList;
00138
00140 static inline char *strchrs(const char *str, const char *chars) {
00141 while (*str) {
00142 if (strchr(chars, *str))
00143 return (char *)str;
00144 str++;
00145 }
00146 return 0;
00147 }
00148
00150 static inline char *strnchr(const char *str, int len, char c) {
00151 int i = 0;
00152 while (i++ != len) {
00153 if (*str == c)
00154 return (char *)str;
00155 ++str;
00156 }
00157 return 0;
00158 }
00159
00161 static inline void strtolower(char *str) {
00162 while (*(str)) {
00163 (*str) = tolower(*str);
00164 str++;
00165 }
00166 }
00167
00169 static inline char *strtoupper(char *str) {
00170 char *p = str;
00171 while (*(p)) {
00172 *p = toupper(*p);
00173 p++;
00174 }
00175 return str;
00176 }
00177
00179 DLLEXPORT int getSecZeroInt(const AbstractQoreNode *a);
00180
00182 DLLEXPORT int64 getSecZeroBigInt(const AbstractQoreNode *a);
00183
00185 DLLEXPORT int getSecMinusOneInt(const AbstractQoreNode *a);
00186
00188 DLLEXPORT int64 getSecMinusOneBigInt(const AbstractQoreNode *a);
00189
00191 DLLEXPORT int getMsZeroInt(const AbstractQoreNode *a);
00192
00194 DLLEXPORT int64 getMsZeroBigInt(const AbstractQoreNode *a);
00195
00197 DLLEXPORT int getMsMinusOneInt(const AbstractQoreNode *a);
00198
00200 DLLEXPORT int64 getMsMinusOneBigInt(const AbstractQoreNode *a);
00201
00203 DLLEXPORT int getMicroSecZeroInt(const AbstractQoreNode *a);
00204
00206 static inline bool is_nothing(const AbstractQoreNode *n) {
00207 if (!n || n->getType() == NT_NOTHING)
00208 return true;
00209
00210 return false;
00211 }
00212
00214 static inline void discard(AbstractQoreNode *n, ExceptionSink *xsink) {
00215 if (n)
00216 n->deref(xsink);
00217 }
00218
00219 static inline const char *get_type_name(const AbstractQoreNode *n) {
00220 return n ? n->getTypeName() : "NOTHING";
00221 }
00222
00223 class BinaryNode;
00224 class QoreStringNode;
00225 class ExceptionSink;
00226
00228 DLLEXPORT BinaryNode *qore_deflate(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00230 DLLEXPORT QoreStringNode *qore_inflate_to_string(const BinaryNode *b, const QoreEncoding *enc, ExceptionSink *xsink);
00232 DLLEXPORT BinaryNode *qore_inflate_to_binary(const BinaryNode *b, ExceptionSink *xsink);
00234 DLLEXPORT BinaryNode *qore_gzip(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00236 DLLEXPORT QoreStringNode *qore_gunzip_to_string(const BinaryNode *bin, const QoreEncoding *enc, ExceptionSink *xsink);
00238 DLLEXPORT BinaryNode *qore_gunzip_to_binary(const BinaryNode *bin, ExceptionSink *xsink);
00240 DLLEXPORT BinaryNode *qore_bzip2(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00242 DLLEXPORT QoreStringNode *qore_bunzip2_to_string(const BinaryNode *bin, const QoreEncoding *enc, ExceptionSink *xsink);
00244 DLLEXPORT BinaryNode *qore_bunzip2_to_binary(const BinaryNode *bin, ExceptionSink *xsink);
00245
00247 #define QORE_OPT_ATOMIC_OPERATIONS "atomic operations"
00249 #define QORE_OPT_STACK_GUARD "stack guard"
00251 #define QORE_OPT_RUNTIME_STACK_TRACE "runtime stack tracing"
00253 #define QORE_OPT_LIBRARY_DEBUGGING "library debugging"
00255 #define QORE_OPT_SHA224 "openssl sha224"
00257 #define QORE_OPT_SHA256 "openssl sha256"
00259 #define QORE_OPT_SHA384 "openssl sha384"
00261 #define QORE_OPT_SHA512 "openssl sha512"
00263 #define QORE_OPT_MDC2 "openssl mdc2"
00265 #define QORE_OPT_RC5 "openssl rc5"
00267 #define QORE_OPT_FUNC_ROUND "round()"
00269 #define QORE_OPT_FUNC_TIMEGM "timegm()"
00271 #define QORE_OPT_FUNC_SETEUID "seteuid()"
00273 #define QORE_OPT_FUNC_SETEGID "setegid()"
00275 #define QORE_OPT_FUNC_PARSEXMLWITHSCHEMA "parseXMLWithSchema()"
00277 #define QORE_OPT_FUNC_PARSEXMLWITHRELAXNG "parseXMLWithRelaxNG()"
00278
00280 #define QO_OPTION 0
00281 #define QO_ALGORITHM 1
00282 #define QO_FUNCTION 2
00283
00285 struct qore_option_s {
00286 const char *option;
00287 const char *constant;
00288 int type;
00289 bool value;
00290 };
00291
00292
00293
00295 DLLEXPORT extern const qore_option_s *qore_option_list;
00297 DLLEXPORT extern size_t qore_option_list_size;
00298
00299 #endif // _QORE_QORELIB_H