00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _QORE_QORELIB_H
00025
00026 #define _QORE_QORELIB_H
00027
00028 #include <qore/common.h>
00029 #include <qore/QoreThreadLock.h>
00030 #include <qore/qore_bitopts.h>
00031 #include <qore/safe_dslist>
00032
00033 #include <time.h>
00034 #include <string.h>
00035 #include <strings.h>
00036 #include <stdlib.h>
00037 #include <stdio.h>
00038 #include <ctype.h>
00039 #include <sys/types.h>
00040
00045
00046 #define _QORE_HAS_QORE_XMLNODE_CLASS 1
00047
00049 #define _QORE_HAS_QORE_XMLREADER_CLASS 1
00050
00052 #define _QORE_HAS_QORE_XMLDOC_CLASS 1
00053
00055 #define _QORE_HAS_HARD_TYPING 1
00056
00058 #define _QORE_HAS_DBI_EXECRAW 1
00059
00061 #define _QORE_HAS_TIME_ZONES 1
00062
00063
00064 #define QC_NO_FLAGS 0
00065 #define QC_NOOP (1 << 0)
00066 #define QC_USES_EXTRA_ARGS (1 << 1)
00067 #define QC_CONSTANT_INTERN (1 << 2)
00068 #define QC_DEPRECATED (1 << 3)
00069 #define QC_RET_VALUE_ONLY (1 << 4)
00070 #define QC_RUNTIME_NOOP (1 << 5)
00071
00072
00073 #define QC_CONSTANT (QC_CONSTANT_INTERN | QC_RET_VALUE_ONLY)
00074
00076 DLLEXPORT char *make_class_name(const char *fn);
00077
00079 DLLEXPORT QoreStringNode *q_sprintf(const class QoreListNode *params, int field, int offset, class ExceptionSink *xsink);
00080
00082 DLLEXPORT QoreStringNode *q_vsprintf(const class QoreListNode *params, int field, int offset, class ExceptionSink *xsink);
00083
00085 DLLEXPORT struct tm *q_localtime(const time_t *clock, struct tm *tms);
00086
00088 DLLEXPORT struct tm *q_gmtime(const time_t *clock, struct tm *tms);
00089
00091 DLLEXPORT int64 q_epoch();
00092
00094 DLLEXPORT int64 q_epoch_us(int &us);
00095
00097 DLLEXPORT int64 q_epoch_ns(int &us);
00098
00100 DLLEXPORT char *q_basename(const char *path);
00101
00103 DLLEXPORT char *q_basenameptr(const char *path);
00104
00106 DLLEXPORT char *q_dirname(const char *path);
00107
00109 DLLEXPORT void *q_realloc(void *ptr, size_t size);
00110
00112 DLLEXPORT QoreHashNode *q_getpwuid(uid_t uid);
00113
00115 DLLEXPORT QoreHashNode *q_getpwnam(const char *name);
00116
00118 DLLEXPORT QoreHashNode *q_getgrgid(uid_t uid);
00119
00121 DLLEXPORT QoreHashNode *q_getgrnam(const char *name);
00122
00124
00129 int q_uname2uid(const char *name, uid_t &uid);
00130
00132
00137 int q_gname2gid(const char *name, gid_t &gid);
00138
00140 DLLEXPORT void qore_setup_argv(int pos, int argc, char *argv[]);
00141
00143 DLLEXPORT qore_license_t qore_get_license();
00144
00146 DLLEXPORT void qore_exit_process(int rc);
00147
00149
00151 class FeatureList : public safe_dslist<std::string> {
00152 private:
00154 DLLLOCAL FeatureList(const FeatureList&);
00155
00157 DLLLOCAL FeatureList& operator=(const FeatureList&);
00158
00159 public:
00161 DLLLOCAL FeatureList();
00162
00164 DLLLOCAL ~FeatureList();
00165 };
00166
00168 DLLEXPORT extern FeatureList qoreFeatureList;
00169
00171 static inline char *strchrs(const char *str, const char *chars) {
00172 while (*str) {
00173 if (strchr(chars, *str))
00174 return (char *)str;
00175 str++;
00176 }
00177 return 0;
00178 }
00179
00181 static inline char *strnchr(const char *str, int len, char c) {
00182 int i = 0;
00183 while (i++ != len) {
00184 if (*str == c)
00185 return (char *)str;
00186 ++str;
00187 }
00188 return 0;
00189 }
00190
00192 static inline void strtolower(char *str) {
00193 while (*(str)) {
00194 (*str) = tolower(*str);
00195 str++;
00196 }
00197 }
00198
00200 static inline char *strtoupper(char *str) {
00201 char *p = str;
00202 while (*(p)) {
00203 *p = toupper(*p);
00204 p++;
00205 }
00206 return str;
00207 }
00208
00210 DLLEXPORT int getSecZeroInt(const AbstractQoreNode *a);
00211
00213 DLLEXPORT int64 getSecZeroBigInt(const AbstractQoreNode *a);
00214
00216 DLLEXPORT int getSecMinusOneInt(const AbstractQoreNode *a);
00217
00219 DLLEXPORT int64 getSecMinusOneBigInt(const AbstractQoreNode *a);
00220
00222 DLLEXPORT int getMsZeroInt(const AbstractQoreNode *a);
00223
00225 DLLEXPORT int64 getMsZeroBigInt(const AbstractQoreNode *a);
00226
00228 DLLEXPORT int getMsMinusOneInt(const AbstractQoreNode *a);
00229
00231 DLLEXPORT int64 getMsMinusOneBigInt(const AbstractQoreNode *a);
00232
00234 DLLEXPORT int getMicroSecZeroInt(const AbstractQoreNode *a);
00235
00237 static inline bool is_nothing(const AbstractQoreNode *n) {
00238 if (!n || n->getType() == NT_NOTHING)
00239 return true;
00240
00241 return false;
00242 }
00243
00245 static inline void discard(AbstractQoreNode *n, ExceptionSink *xsink) {
00246 if (n)
00247 n->deref(xsink);
00248 }
00249
00250 static inline const char *get_type_name(const AbstractQoreNode *n) {
00251 return n ? n->getTypeName() : "NOTHING";
00252 }
00253
00254 static inline qore_type_t get_node_type(const AbstractQoreNode *n) {
00255 return n ? n->getType() : NT_NOTHING;
00256 }
00257
00258 class BinaryNode;
00259 class QoreStringNode;
00260 class ExceptionSink;
00261
00263 DLLEXPORT BinaryNode *qore_deflate(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00265 DLLEXPORT QoreStringNode *qore_inflate_to_string(const BinaryNode *b, const QoreEncoding *enc, ExceptionSink *xsink);
00267 DLLEXPORT BinaryNode *qore_inflate_to_binary(const BinaryNode *b, ExceptionSink *xsink);
00269 DLLEXPORT BinaryNode *qore_gzip(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00271 DLLEXPORT QoreStringNode *qore_gunzip_to_string(const BinaryNode *bin, const QoreEncoding *enc, ExceptionSink *xsink);
00273 DLLEXPORT BinaryNode *qore_gunzip_to_binary(const BinaryNode *bin, ExceptionSink *xsink);
00275 DLLEXPORT BinaryNode *qore_bzip2(void *ptr, unsigned long len, int level, ExceptionSink *xsink);
00277 DLLEXPORT QoreStringNode *qore_bunzip2_to_string(const BinaryNode *bin, const QoreEncoding *enc, ExceptionSink *xsink);
00279 DLLEXPORT BinaryNode *qore_bunzip2_to_binary(const BinaryNode *bin, ExceptionSink *xsink);
00280
00282 DLLEXPORT BinaryNode *parseBase64(const char *buf, int len, ExceptionSink *xsink);
00283
00285 DLLEXPORT BinaryNode *parseHex(const char *buf, int len, ExceptionSink *xsink);
00286
00287 class AbstractQoreZoneInfo;
00288
00290 DLLEXPORT const AbstractQoreZoneInfo *findCreateOffsetZone(int seconds_east);
00291
00293 #define QORE_OPT_ATOMIC_OPERATIONS "atomic operations"
00295 #define QORE_OPT_STACK_GUARD "stack guard"
00297 #define QORE_OPT_SIGNAL_HANDLING "signal handling"
00299 #define QORE_OPT_RUNTIME_STACK_TRACE "runtime stack tracing"
00301 #define QORE_OPT_LIBRARY_DEBUGGING "library debugging"
00303 #define QORE_OPT_SHA224 "openssl sha224"
00305 #define QORE_OPT_SHA256 "openssl sha256"
00307 #define QORE_OPT_SHA384 "openssl sha384"
00309 #define QORE_OPT_SHA512 "openssl sha512"
00311 #define QORE_OPT_MDC2 "openssl mdc2"
00313 #define QORE_OPT_RC5 "openssl rc5"
00315 #define QORE_OPT_MD2 "openssl md2"
00317 #define QORE_OPT_FUNC_ROUND "round()"
00319 #define QORE_OPT_FUNC_TIMEGM "timegm()"
00321 #define QORE_OPT_FUNC_SETEUID "seteuid()"
00323 #define QORE_OPT_FUNC_SETEGID "setegid()"
00325 #define QORE_OPT_FUNC_PARSEXMLWITHSCHEMA "parseXMLWithSchema()"
00327 #define QORE_OPT_FUNC_PARSEXMLWITHRELAXNG "parseXMLWithRelaxNG()"
00328
00330 #define QO_OPTION 0
00331 #define QO_ALGORITHM 1
00332 #define QO_FUNCTION 2
00333
00335 struct qore_option_s {
00336 const char *option;
00337 const char *constant;
00338 int type;
00339 bool value;
00340 };
00341
00342
00343
00345 DLLEXPORT QoreStringNode *q_strerror(int errnum);
00347 DLLEXPORT void q_strerror(QoreString &str, int errnum);
00348
00350 DLLEXPORT extern const qore_option_s *qore_option_list;
00352 DLLEXPORT extern size_t qore_option_list_size;
00353
00355 #define QORE_MAX(a, b) ((a) > (b) ? (a) : (b))
00356
00357 #define QORE_PARAM_NO_ARG (NULL)
00358
00359
00360 #ifndef QORE_PATH_MAX
00361 #ifdef _XOPEN_PATH_MAX
00362 #define QORE_PATH_MAX _XOPEN_PATH_MAX
00363 #else
00364 #define QORE_PATH_MAX 1024
00365 #endif
00366 #endif
00367
00368 #endif // _QORE_QORELIB_H