diff --git a/cbp/LibIRC.cbp b/cbp/LibIRC.cbp
deleted file mode 100644
index a323c0d6..00000000
--- a/cbp/LibIRC.cbp
+++ /dev/null
@@ -1,177 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/ModINI.cbp b/cbp/ModINI.cbp
new file mode 100644
index 00000000..15768123
--- /dev/null
+++ b/cbp/ModINI.cbp
@@ -0,0 +1,395 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cbp/ModIRC.cbp b/cbp/ModIRC.cbp
new file mode 100644
index 00000000..dc466e07
--- /dev/null
+++ b/cbp/ModIRC.cbp
@@ -0,0 +1,398 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cbp/ModSample.cbp b/cbp/ModSample.cbp
new file mode 100644
index 00000000..4b6bd938
--- /dev/null
+++ b/cbp/ModSample.cbp
@@ -0,0 +1,383 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cbp/ModXML.cbp b/cbp/ModXML.cbp
new file mode 100644
index 00000000..68747bca
--- /dev/null
+++ b/cbp/ModXML.cbp
@@ -0,0 +1,391 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cbp/Module.cbp b/cbp/Module.cbp
index 54865251..745f74ec 100644
--- a/cbp/Module.cbp
+++ b/cbp/Module.cbp
@@ -7,7 +7,7 @@
-
+
@@ -20,8 +20,6 @@
-
-
@@ -29,7 +27,7 @@
-
+
@@ -43,8 +41,6 @@
-
-
@@ -52,7 +48,7 @@
-
+
@@ -66,8 +62,6 @@
-
-
@@ -75,7 +69,7 @@
-
+
@@ -90,8 +84,6 @@
-
-
@@ -99,7 +91,7 @@
-
+
@@ -113,12 +105,11 @@
-
-
+
@@ -133,12 +124,11 @@
-
-
+
@@ -153,12 +143,11 @@
-
-
+
@@ -171,6 +160,197 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -180,10 +360,8 @@
+
-
-
-
@@ -193,13 +371,10 @@
-
-
-
@@ -212,7 +387,6 @@
-
@@ -272,10 +446,6 @@
-
-
-
-
@@ -294,8 +464,6 @@
-
-
diff --git a/cbp/SQLite.cbp b/cbp/SQLite.cbp
deleted file mode 100644
index 12c1e541..00000000
--- a/cbp/SQLite.cbp
+++ /dev/null
@@ -1,176 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/Sample.cbp b/cbp/Sample.cbp
deleted file mode 100644
index bb4520df..00000000
--- a/cbp/Sample.cbp
+++ /dev/null
@@ -1,199 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/Sandbox.cbp b/cbp/Sandbox.cbp
index b1084fb5..0e76327d 100644
--- a/cbp/Sandbox.cbp
+++ b/cbp/Sandbox.cbp
@@ -159,7 +159,6 @@
-
diff --git a/cbp/default.workspace b/cbp/default.workspace
index a316b486..0531af86 100644
--- a/cbp/default.workspace
+++ b/cbp/default.workspace
@@ -4,8 +4,9 @@
-
-
-
+
+
+
+
diff --git a/external/LibIRC/portable.c b/external/LibIRC/portable.c
index 7b6f72bd..177fa870 100644
--- a/external/LibIRC/portable.c
+++ b/external/LibIRC/portable.c
@@ -1,14 +1,14 @@
-/*
+/*
* Copyright (C) 2004-2012 George Yunaev gyunaev@ulduzsoft.com
*
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*/
@@ -23,7 +23,7 @@
#include
#include
#include
- #include
+ #include
#include
#include
#include
@@ -37,7 +37,7 @@
#if !defined (PTHREAD_MUTEX_RECURSIVE) && defined (PTHREAD_MUTEX_RECURSIVE_NP)
#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
#endif
- #endif
+ #endif
#else
#include
#include
diff --git a/external/LibIRC/sockets.c b/external/LibIRC/sockets.c
index 83aca56f..9a2c3098 100644
--- a/external/LibIRC/sockets.c
+++ b/external/LibIRC/sockets.c
@@ -1,14 +1,14 @@
-/*
+/*
* Copyright (C) 2004-2012 George Yunaev gyunaev@ulduzsoft.com
*
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*/
@@ -18,7 +18,7 @@
#if !defined (_WIN32)
#include
#include
- #include
+ #include
#include
#include
@@ -134,7 +134,7 @@ static int socket_recv (socket_t * sock, void * buf, size_t len)
while ( (length = recv (*sock, buf, len, 0)) < 0 )
{
int err = socket_error();
-
+
if ( err != EINTR && err != EAGAIN )
break;
}
@@ -150,7 +150,7 @@ static int socket_send (socket_t * sock, const void *buf, size_t len)
while ( (length = send (*sock, buf, len, 0)) < 0 )
{
int err = socket_error();
-
+
if ( err != EINTR && err != EAGAIN )
break;
}
diff --git a/include/sqrat.h b/include/sqrat.h
index 2f964676..c892a0f6 100644
--- a/include/sqrat.h
+++ b/include/sqrat.h
@@ -57,7 +57,7 @@
#define _SCRAT_MAIN_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratAllocator.h b/include/sqrat/sqratAllocator.h
index 994a51e2..d28966da 100644
--- a/include/sqrat/sqratAllocator.h
+++ b/include/sqrat/sqratAllocator.h
@@ -29,7 +29,7 @@
#define _SCRAT_ALLOCATOR_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratArray.h b/include/sqrat/sqratArray.h
index 4d2c6ec2..e13d9790 100644
--- a/include/sqrat/sqratArray.h
+++ b/include/sqrat/sqratArray.h
@@ -29,7 +29,7 @@
#define _SCRAT_ARRAY_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratClass.h b/include/sqrat/sqratClass.h
index 9082a0ac..5c479be7 100644
--- a/include/sqrat/sqratClass.h
+++ b/include/sqrat/sqratClass.h
@@ -29,7 +29,7 @@
#define _SCRAT_CLASS_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratClassType.h b/include/sqrat/sqratClassType.h
index f2bda7a6..f7d5e787 100644
--- a/include/sqrat/sqratClassType.h
+++ b/include/sqrat/sqratClassType.h
@@ -29,7 +29,7 @@
#define _SCRAT_CLASSTYPE_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratConst.h b/include/sqrat/sqratConst.h
index 406bd7f8..22067828 100644
--- a/include/sqrat/sqratConst.h
+++ b/include/sqrat/sqratConst.h
@@ -29,7 +29,7 @@
#define _SCRAT_CONST_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratFunction.h b/include/sqrat/sqratFunction.h
index d66cdef4..b9d3f10c 100644
--- a/include/sqrat/sqratFunction.h
+++ b/include/sqrat/sqratFunction.h
@@ -30,7 +30,7 @@
#define _SCRAT_SQFUNC_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratGlobalMethods.h b/include/sqrat/sqratGlobalMethods.h
index 5fd0f9a8..7d429ba6 100644
--- a/include/sqrat/sqratGlobalMethods.h
+++ b/include/sqrat/sqratGlobalMethods.h
@@ -30,7 +30,7 @@
#define _SCRAT_GLOBAL_METHODS_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratMemberMethods.h b/include/sqrat/sqratMemberMethods.h
index b52703b5..97b9cf8a 100644
--- a/include/sqrat/sqratMemberMethods.h
+++ b/include/sqrat/sqratMemberMethods.h
@@ -30,7 +30,7 @@
#define _SCRAT_MEMBER_METHODS_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratObject.h b/include/sqrat/sqratObject.h
index 0f9197a9..bf553df2 100644
--- a/include/sqrat/sqratObject.h
+++ b/include/sqrat/sqratObject.h
@@ -29,7 +29,7 @@
#define _SCRAT_OBJECT_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratOverloadMethods.h b/include/sqrat/sqratOverloadMethods.h
index 3acfd19a..107610e9 100644
--- a/include/sqrat/sqratOverloadMethods.h
+++ b/include/sqrat/sqratOverloadMethods.h
@@ -29,7 +29,7 @@
#define _SQRAT_OVERLOAD_METHODS_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratScript.h b/include/sqrat/sqratScript.h
index 6450f1ff..75acf6b9 100644
--- a/include/sqrat/sqratScript.h
+++ b/include/sqrat/sqratScript.h
@@ -29,7 +29,7 @@
#define _SCRAT_SCRIPT_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#include
diff --git a/include/sqrat/sqratTable.h b/include/sqrat/sqratTable.h
index 3da9a435..27fe8988 100644
--- a/include/sqrat/sqratTable.h
+++ b/include/sqrat/sqratTable.h
@@ -29,7 +29,7 @@
#define _SCRAT_TABLE_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratTypes.h b/include/sqrat/sqratTypes.h
index 64942414..27ab7e2c 100644
--- a/include/sqrat/sqratTypes.h
+++ b/include/sqrat/sqratTypes.h
@@ -34,7 +34,7 @@
#endif
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/include/sqrat/sqratUtil.h b/include/sqrat/sqratUtil.h
index 5d536466..ee23e56b 100644
--- a/include/sqrat/sqratUtil.h
+++ b/include/sqrat/sqratUtil.h
@@ -29,7 +29,7 @@
#define _SCRAT_UTIL_H_
#ifdef SQMOD_PLUGIN_API
- #include
+ #include
#else
#include
#endif // SQMOD_PLUGIN_API
diff --git a/modules/ini/Common.cpp b/modules/ini/Common.cpp
new file mode 100644
index 00000000..07f8495c
--- /dev/null
+++ b/modules/ini/Common.cpp
@@ -0,0 +1,35 @@
+// ------------------------------------------------------------------------------------------------
+#include "Common.hpp"
+#include "Module.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+// ------------------------------------------------------------------------------------------------
+void IniResult::Check() const
+{
+ // Identify the error type
+ switch (m_Result)
+ {
+ case SI_FAIL:
+ _SqMod->SqThrow("Unable to %s. Probably invalid", m_Action.c_str());
+ break;
+ case SI_NOMEM:
+ _SqMod->SqThrow("Unable to %s. Ran out of memory", m_Action.c_str());
+ break;
+ case SI_FILE:
+ _SqMod->SqThrow("Unable to %s. %s", strerror(errno));
+ break;
+ case SI_BADREF:
+ _SqMod->SqThrow("Unable to %s. Invalid document reference", m_Action.c_str());
+ break;
+ case SI_OK:
+ case SI_UPDATED:
+ case SI_INSERTED:
+ break; /* These are not error messahes. */
+ default:
+ _SqMod->SqThrow("Unable to %s for some unforeseen reason", m_Action.c_str());
+ }
+}
+
+} // Namespace:: SqMod
diff --git a/modules/ini/Common.hpp b/modules/ini/Common.hpp
new file mode 100644
index 00000000..1d3e61a2
--- /dev/null
+++ b/modules/ini/Common.hpp
@@ -0,0 +1,396 @@
+#ifndef _SQINI_COMMON_HPP_
+#define _SQINI_COMMON_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "ModBase.hpp"
+
+// ------------------------------------------------------------------------------------------------
+#include
+
+// ------------------------------------------------------------------------------------------------
+#include
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * Custom Error messages.
+*/
+enum SI_Custom_Error
+{
+ SI_BADREF = -4
+};
+
+/* ------------------------------------------------------------------------------------------------
+ * SOFTWARE INFORMATION
+*/
+#define SQINI_NAME "Squirrel INI Module"
+#define SQINI_AUTHOR "Sandu Liviu Catalin (S.L.C)"
+#define SQINI_COPYRIGHT "Copyright (C) 2016 Sandu Liviu Catalin"
+#define SQINI_HOST_NAME "SqModINIHost"
+#define SQINI_VERSION 001
+#define SQINI_VERSION_STR "0.0.1"
+#define SQINI_VERSION_MAJOR 0
+#define SQINI_VERSION_MINOR 0
+#define SQINI_VERSION_PATCH 1
+
+/* ------------------------------------------------------------------------------------------------
+ * Forward declarations.
+*/
+class Entries;
+class Document;
+
+/* ------------------------------------------------------------------------------------------------
+ * Manages a reference counted INI document instance.
+*/
+class DocumentRef
+{
+ // --------------------------------------------------------------------------------------------
+ friend class Document;
+
+public:
+
+ // --------------------------------------------------------------------------------------------
+ typedef CSimpleIniA Type; /* The managed type. */
+
+ // --------------------------------------------------------------------------------------------
+ typedef Type* Pointer; /* Pointer to the managed type. */
+ typedef const Type* ConstPtr; /* Constant pointer to the managed type. */
+
+ // --------------------------------------------------------------------------------------------
+ typedef Type& Reference; /* Reference to the managed type. */
+ typedef const Type& ConstRef; /* Constant reference to the managed type. */
+
+ // --------------------------------------------------------------------------------------------
+ typedef unsigned int Counter; /* Reference counter type. */
+
+private:
+
+ // --------------------------------------------------------------------------------------------
+ Pointer m_Ptr; /* The document reader, writer and manager instance. */
+ Counter* m_Ref; /* Reference count to the managed instance. */
+
+ /* --------------------------------------------------------------------------------------------
+ * Grab a strong reference to a document instance.
+ */
+ void Grab()
+ {
+ if (m_Ptr)
+ ++(*m_Ref);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Drop a strong reference to a document instance.
+ */
+ void Drop()
+ {
+ if (m_Ptr && --(*m_Ref) == 0)
+ {
+ delete m_Ptr;
+ delete m_Ref;
+ m_Ptr = NULL;
+ m_Ref = NULL;
+ }
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Base constructor.
+ */
+ DocumentRef(bool utf8, bool multikey, bool multiline)
+ : m_Ptr(new Type(utf8, multikey, multiline)), m_Ref(new Counter(1))
+ {
+ /* ... */
+ }
+
+public:
+
+ /* --------------------------------------------------------------------------------------------
+ * Default constructor (null).
+ */
+ DocumentRef()
+ : m_Ptr(NULL), m_Ref(NULL)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy constructor.
+ */
+ DocumentRef(const DocumentRef & o)
+ : m_Ptr(o.m_Ptr), m_Ref(o.m_Ref)
+
+ {
+ Grab();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Destructor.
+ */
+ ~DocumentRef()
+ {
+ Drop();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy assignment operator.
+ */
+ DocumentRef & operator = (const DocumentRef & o)
+ {
+ if (m_Ptr != o.m_Ptr)
+ {
+ Drop();
+ m_Ptr = o.m_Ptr;
+ m_Ref = o.m_Ref;
+ Grab();
+ }
+ return *this;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Perform an equality comparison between two document instances.
+ */
+ bool operator == (const DocumentRef & o) const
+ {
+ return (m_Ptr == o.m_Ptr);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Perform an inequality comparison between two document instances.
+ */
+ bool operator != (const DocumentRef & o) const
+ {
+ return (m_Ptr != o.m_Ptr);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Implicit conversion to boolean for use in boolean operations.
+ */
+ operator bool () const
+ {
+ return m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Implicit conversion to the managed instance pointer.
+ */
+ operator Pointer ()
+ {
+ return m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Implicit conversion to the managed instance pointer.
+ */
+ operator ConstPtr () const
+ {
+ return m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Implicit conversion to the managed instance reference.
+ */
+ operator Reference ()
+ {
+ assert(m_Ptr);
+ return *m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Implicit conversion to the managed instance reference.
+ */
+ operator ConstRef () const
+ {
+ assert(m_Ptr);
+ return *m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Member operator for dereferencing the managed pointer.
+ */
+ Pointer operator -> () const
+ {
+ assert(m_Ptr != NULL);
+ return m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Indirection operator for obtaining a reference of the managed pointer.
+ */
+ Reference operator * () const
+ {
+ assert(m_Ptr != NULL);
+ return *m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the number of active references to the managed instance.
+ */
+ Counter Count() const
+ {
+ return (m_Ptr && m_Ref) ? (*m_Ref) : 0;
+ }
+};
+
+/* ------------------------------------------------------------------------------------------------
+ * Allows the user to inspect the result of certain operations and act accordingly.
+*/
+class IniResult
+{
+private:
+
+ // --------------------------------------------------------------------------------------------
+ String m_Action; /* The action that was performed. */
+ SQInteger m_Result; /* The internal result code. */
+
+public:
+
+ /* --------------------------------------------------------------------------------------------
+ * Construct with no specific action or result.
+ */
+ IniResult()
+ : m_Action("unknown action"), m_Result(SI_OK)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Construct with no specific result.
+ */
+ explicit IniResult(CSStr action)
+ : m_Action(!action ? _SC("") : action), m_Result(SI_OK)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Construct with no specific action.
+ */
+ explicit IniResult(SQInteger result)
+ : m_Action("unknown action"), m_Result(result)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Construct with specific action and result.
+ */
+ IniResult(CSStr action, SQInteger result)
+ : m_Action(!action ? _SC("") : action), m_Result(result)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy constructor.
+ */
+ IniResult(const IniResult & o)
+ : m_Action(o.m_Action), m_Result(o.m_Result)
+
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Destructor.
+ */
+ ~IniResult()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy assignment operator.
+ */
+ IniResult & operator = (const IniResult & o)
+ {
+ m_Action = o.m_Action;
+ m_Result = o.m_Result;
+ return *this;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Perform an equality comparison between two results.
+ */
+ bool operator == (const IniResult & o) const
+ {
+ return (m_Result == o.m_Result);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Perform an inequality comparison between two results.
+ */
+ bool operator != (const IniResult & o) const
+ {
+ return (m_Result != o.m_Result);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Implicit conversion to boolean for use in boolean operations.
+ */
+ operator bool () const
+ {
+ return (m_Result >= 0);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to compare two instances of this type.
+ */
+ Int32 Cmp(const IniResult & o) const
+ {
+ if (m_Result == o.m_Result)
+ return 0;
+ else if (m_Result > o.m_Result)
+ return 1;
+ else
+ return -1;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to convert an instance of this type to a string.
+ */
+ CSStr ToString() const
+ {
+ return m_Action.c_str();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to retrieve the name from instances of this type.
+ */
+ CSStr Typename() const
+ {
+ return _SC("SqIniResult");
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether this instance references a valid INI result.
+ */
+ bool IsValid() const
+ {
+ return (m_Result >= 0);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the associated action.
+ */
+ CSStr GetAction() const
+ {
+ return m_Action.c_str();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the resulted code.
+ */
+ SQInteger GetResult() const
+ {
+ return m_Result;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the resulted code.
+ */
+ void Check() const;
+};
+
+} // Namespace:: SqMod
+
+#endif // _SQINI_COMMON_HPP_
diff --git a/modules/ini/Document.cpp b/modules/ini/Document.cpp
new file mode 100644
index 00000000..e87915bc
--- /dev/null
+++ b/modules/ini/Document.cpp
@@ -0,0 +1,227 @@
+// ------------------------------------------------------------------------------------------------
+#include "Document.hpp"
+#include "Entries.hpp"
+#include "Module.hpp"
+
+// ------------------------------------------------------------------------------------------------
+#include
+
+// --------------------------------------------------------------------------------------------
+#include
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+// ------------------------------------------------------------------------------------------------
+bool Document::Validate() const
+{
+ if (m_Doc)
+ return true;
+ // No document available
+ _SqMod->SqThrow("Invalid INI document reference");
+ return false;
+}
+
+// ------------------------------------------------------------------------------------------------
+Int32 Document::Cmp(const Document & o) const
+{
+ if (m_Doc == o.m_Doc)
+ return 0;
+ else if (this > &o)
+ return 1;
+ else
+ return -1;
+}
+
+// ------------------------------------------------------------------------------------------------
+IniResult Document::LoadFile(CSStr filepath)
+{
+ if (!Validate())
+ return IniResult("load INI file", SI_BADREF); /* Unable to proceed */
+ // Attempt to load the file from disk and return the result
+ return IniResult("load INI file", m_Doc->LoadFile(filepath));
+}
+
+// ------------------------------------------------------------------------------------------------
+IniResult Document::LoadData(CSStr source, Int32 size)
+{
+ if (!Validate())
+ return IniResult("load INI file", SI_BADREF); /* Unable to proceed */
+ // Attempt to load the file from memory and return the result
+ return IniResult("load INI file", m_Doc->LoadData(source, size < 0 ? strlen(source) : size));
+}
+
+// ------------------------------------------------------------------------------------------------
+IniResult Document::SaveFile(CSStr filepath, bool signature)
+{
+ if (!Validate())
+ return IniResult("save INI file", SI_BADREF); /* Unable to proceed */
+ // Attempt to save the file to disk and return the result
+ return IniResult("save INI file", m_Doc->SaveFile(filepath, signature));
+}
+
+// ------------------------------------------------------------------------------------------------
+Object Document::SaveData(bool signature)
+{
+ if (!Validate())
+ return Object(); /* Unable to proceed */
+ // The string where the content will be saved
+ String source;
+ // Attempt to save the data to string
+ if (m_Doc->Save(source, signature) < 0)
+ return Object(); /* Unable to proceed */
+ // Transform it into a script object
+ sq_pushstring(DefaultVM::Get(), source.c_str(), source.size());
+ // Get the object from the stack
+ Var< Object > var(DefaultVM::Get(), -1);
+ // Pop the created object from the stack
+ if (!var.value.IsNull())
+ sq_pop(DefaultVM::Get(), 1);
+ // Return the script object
+ return var.value;
+}
+
+// ------------------------------------------------------------------------------------------------
+Entries Document::GetAllSections() const
+{
+ if (!Validate())
+ return Entries(); /* Unable to proceed */
+ // Prepare a container to receive the entries
+ static Container entries;
+ // Obtain all sections from the INI document
+ m_Doc->GetAllSections(entries);
+ // Return the entries and take over content
+ return Entries(m_Doc, entries);
+}
+
+// ------------------------------------------------------------------------------------------------
+Entries Document::GetAllKeys(CSStr section) const
+{
+ if (!Validate())
+ return Entries(); /* Unable to proceed */
+ // Prepare a container to receive the entries
+ static Container entries;
+ // Obtain all sections from the INI document
+ m_Doc->GetAllKeys(section, entries);
+ // Return the entries and take over content
+ return Entries(m_Doc, entries);
+}
+
+// ------------------------------------------------------------------------------------------------
+Entries Document::GetAllValues(CSStr section, CSStr key) const
+{
+ if (!Validate())
+ return Entries(); /* Unable to proceed */
+ // Prepare a container to receive the entries
+ static Container entries;
+ // Obtain all sections from the INI document
+ m_Doc->GetAllValues(section, key, entries);
+ // Return the entries and take over content
+ return Entries(m_Doc, entries);
+}
+
+// ------------------------------------------------------------------------------------------------
+Int32 Document::GetSectionSize(CSStr section) const
+{
+ if (Validate())
+ // Return the requested information
+ return m_Doc->GetSectionSize(section);
+ // Return invalid size
+ return -1;
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Document::HasMultipleKeys(CSStr section, CSStr key) const
+{
+ if (!Validate())
+ return false; /* Unable to proceed */
+ // Where to retrive whether the key has multiple instances
+ bool multiple = false;
+ // Attempt to query the information
+ if (m_Doc->GetValue(section, key, NULL, &multiple) == NULL)
+ return true; /* Doesn't exist */
+ return multiple;
+}
+
+// ------------------------------------------------------------------------------------------------
+CCStr Document::GetValue(CSStr section, CSStr key, CSStr def) const
+{
+ if (!Validate())
+ return _SC(""); /* Unable to proceed */
+ // Attempt to query the information and return it
+ return m_Doc->GetValue(section, key, def, NULL);
+}
+
+// ------------------------------------------------------------------------------------------------
+SQInteger Document::GetInteger(CSStr section, CSStr key, SQInteger def) const
+{
+ if (!Validate())
+ return 0; /* Unable to proceed */
+ // Attempt to query the information and return it
+ return (SQInteger)m_Doc->GetLongValue(section, key, def, NULL);
+}
+
+// ------------------------------------------------------------------------------------------------
+SQFloat Document::GetFloat(CSStr section, CSStr key, SQFloat def) const
+{
+ if (!Validate())
+ return SQFloat(0.0); /* Unable to proceed */
+ // Attempt to query the information and return it
+ return (SQFloat)m_Doc->GetDoubleValue(section, key, def, NULL);
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Document::GetBoolean(CSStr section, CSStr key, bool def) const
+{
+ if (!Validate())
+ return false; /* Unable to proceed */
+ // Attempt to query the information and return it
+ return m_Doc->GetBoolValue(section, key, def, NULL);
+}
+
+// ------------------------------------------------------------------------------------------------
+IniResult Document::SetValue(CSStr section, CSStr key, CSStr value, bool force, CSStr comment)
+{
+ if (!Validate())
+ return IniResult("set INI value", SI_BADREF); /* Unable to proceed */
+ // Attempt to apply the specified information and return the result
+ return IniResult("set INI value", m_Doc->SetValue(section, key, value, comment, force));
+}
+
+// ------------------------------------------------------------------------------------------------
+IniResult Document::SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force, CSStr comment)
+{
+ if (!Validate())
+ return IniResult("set INI integer", SI_BADREF); /* Unable to proceed */
+ // Attempt to apply the specified information and return the result
+ return IniResult("set INI integer", m_Doc->SetLongValue(section, key, value, comment, hex, force));
+}
+
+// ------------------------------------------------------------------------------------------------
+IniResult Document::SetFloat(CSStr section, CSStr key, SQFloat value, bool force, CSStr comment)
+{
+ if (!Validate())
+ return IniResult("set INI float", SI_BADREF); /* Unable to proceed */
+ // Attempt to apply the specified information and return the result
+ return IniResult("set INI float", m_Doc->SetDoubleValue(section, key, value, comment, force));
+}
+
+// ------------------------------------------------------------------------------------------------
+IniResult Document::SetBoolean(CSStr section, CSStr key, bool value, bool force, CSStr comment)
+{
+ if (!Validate())
+ return IniResult("set INI boolean", SI_BADREF); /* Unable to proceed */
+ // Attempt to apply the specified information
+ return IniResult("set INI boolean", m_Doc->SetBoolValue(section, key, value, comment, force));
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Document::DeleteValue(CSStr section, CSStr key, CSStr value, bool empty)
+{
+ if (!Validate())
+ return false; /* Unable to proceed */
+ // Attempt to remove the specified value and return the result
+ return m_Doc->DeleteValue(section, key, value, empty);
+}
+
+} // Namespace:: SqMod
diff --git a/modules/ini/Document.hpp b/modules/ini/Document.hpp
new file mode 100644
index 00000000..f30313b6
--- /dev/null
+++ b/modules/ini/Document.hpp
@@ -0,0 +1,408 @@
+#ifndef _SQINI_DOCUMENT_HPP_
+#define _SQINI_DOCUMENT_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "Common.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * Class that can read/write and alter the contents of INI files.
+*/
+class Document
+{
+protected:
+
+ // --------------------------------------------------------------------------------------------
+ typedef DocumentRef::Type::TNamesDepend Container;
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy constructor. (disabled)
+ */
+ Document(const Document & o);
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy assignment operator. (disabled)
+ */
+ Document & operator = (const Document & o);
+
+ /* --------------------------------------------------------------------------------------------
+ * Validate the document reference and throw an error if invalid.
+ */
+ bool Validate() const;
+
+private:
+
+ // ---------------------------------------------------------------------------------------------
+ DocumentRef m_Doc; /* The main INI document instance. */
+
+public:
+
+ /* --------------------------------------------------------------------------------------------
+ * Default constructor.
+ */
+ Document()
+ : m_Doc(false, false, true)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Explicit constructor.
+ */
+ Document(bool utf8)
+ : m_Doc(utf8, false, true)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Explicit constructor.
+ */
+ Document(bool utf8, bool multikey)
+ : m_Doc(utf8, multikey, true)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Explicit constructor.
+ */
+ Document(bool utf8, bool multikey, bool multiline)
+ : m_Doc(utf8, multikey, multiline)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Destructor.
+ */
+ ~Document()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to compare two instances of this type.
+ */
+ Int32 Cmp(const Document & o) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to convert an instance of this type to a string.
+ */
+ CSStr ToString() const
+ {
+ return _SC("");
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to retrieve the name from instances of this type.
+ */
+ CSStr Typename() const
+ {
+ return _SC("SqIniDocument");
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether this instance references a valid INI document.
+ */
+ bool IsValid() const
+ {
+ return m_Doc;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether any data has been loaded into this document.
+ */
+ bool IsEmpty() const
+ {
+ return m_Doc->IsEmpty();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Return the number of active references to this document instance.
+ */
+ Uint32 GetRefCount() const
+ {
+ return m_Doc.Count();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Deallocate all memory stored by this document.
+ */
+ void Reset() const
+ {
+ m_Doc->Reset();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether the INI data is treated as unicode.
+ */
+ bool GetUnicode() const
+ {
+ return m_Doc->IsUnicode();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Set whether the INI data should be treated as unicode.
+ */
+ void SetUnicode(bool toggle)
+ {
+ m_Doc->SetUnicode(toggle);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether multiple identical keys be permitted in the file.
+ */
+ bool GetMultiKey() const
+ {
+ return m_Doc->IsMultiKey();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Set whether multiple identical keys be permitted in the file.
+ */
+ void SetMultiKey(bool toggle)
+ {
+ m_Doc->SetMultiKey(toggle);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether data values are permitted to span multiple lines in the file.
+ */
+ bool GetMultiLine() const
+ {
+ return m_Doc->IsMultiLine();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Set whether data values are permitted to span multiple lines in the file.
+ */
+ void SetMultiLine(bool toggle)
+ {
+ m_Doc->SetMultiLine(toggle);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether spaces are added around the equals sign when writing key/value pairs out.
+ */
+ bool GetSpaces() const
+ {
+ return m_Doc->UsingSpaces();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Set whether spaces are added around the equals sign when writing key/value pairs out.
+ */
+ void SetSpaces(bool toggle)
+ {
+ m_Doc->SetSpaces(toggle);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Load an INI file from disk into memory.
+ */
+ IniResult LoadFile(CSStr filepath);
+
+ /* --------------------------------------------------------------------------------------------
+ * Load INI file data direct from a string. (LoadString collides with the windows api)
+ */
+ IniResult LoadData(CSStr source)
+ {
+ return LoadData(source, -1);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Load INI file data direct from a string. (LoadString collides with the windows api)
+ */
+ IniResult LoadData(CSStr source, Int32 size);
+
+ /* --------------------------------------------------------------------------------------------
+ * Save an INI file from memory to disk.
+ */
+ IniResult SaveFile(CSStr filepath)
+ {
+ return SaveFile(filepath, true);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Save an INI file from memory to disk.
+ */
+ IniResult SaveFile(CSStr filepath, bool signature);
+
+ /* --------------------------------------------------------------------------------------------
+ * Save the INI data to a string.
+ */
+ Object SaveData(bool signature);
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve all section names.
+ */
+ Entries GetAllSections() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve all unique key names in a section.
+ */
+ Entries GetAllKeys(CSStr section) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve all values for a specific key.
+ */
+ Entries GetAllValues(CSStr section, CSStr key) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Query the number of keys in a specific section.
+ */
+ Int32 GetSectionSize(CSStr section) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether a certain key has multiple instances.
+ */
+ bool HasMultipleKeys(CSStr section, CSStr key) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value for a specific key.
+ */
+ CCStr GetValue(CSStr section, CSStr key, CSStr def) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve a numeric value for a specific key.
+ */
+ SQInteger GetInteger(CSStr section, CSStr key, SQInteger def) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve a numeric value for a specific key.
+ */
+ SQFloat GetFloat(CSStr section, CSStr key, SQFloat def) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve a boolean value for a specific key.
+ */
+ bool GetBoolean(CSStr section, CSStr key, bool def) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a section or value.
+ */
+ IniResult SetValue(CSStr section, CSStr key, CSStr value)
+ {
+ return SetValue(section, key, value, false, NULL);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a section or value.
+ */
+ IniResult SetValue(CSStr section, CSStr key, CSStr value, bool force)
+ {
+ return SetValue(section, key, value, force, NULL);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a section or value.
+ */
+ IniResult SetValue(CSStr section, CSStr key, CSStr value, bool force, CSStr comment);
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a numeric value.
+ */
+ IniResult SetInteger(CSStr section, CSStr key, SQInteger value)
+ {
+ return SetInteger(section, key, value, false, false, NULL);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a numeric value.
+ */
+ IniResult SetInteger(CSStr section, CSStr key, SQInteger value, bool hex)
+ {
+ return SetInteger(section, key, value, hex, false, NULL);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a numeric value.
+ */
+ IniResult SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force)
+ {
+ return SetInteger(section, key, value, hex, force, NULL);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a numeric value.
+ */
+ IniResult SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force, CSStr comment);
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a double value.
+ */
+ IniResult SetFloat(CSStr section, CSStr key, SQFloat value)
+ {
+ return SetFloat(section, key, value, false, NULL);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a double value.
+ */
+ IniResult SetFloat(CSStr section, CSStr key, SQFloat value, bool force)
+ {
+ return SetFloat(section, key, value, force, NULL);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a double value.
+ */
+ IniResult SetFloat(CSStr section, CSStr key, SQFloat value, bool force, CSStr comment);
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a double value.
+ */
+ IniResult SetBoolean(CSStr section, CSStr key, bool value)
+ {
+ return SetBoolean(section, key, value, false, NULL);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a double value.
+ */
+ IniResult SetBoolean(CSStr section, CSStr key, bool value, bool force)
+ {
+ return SetBoolean(section, key, value, force, NULL);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Add or update a boolean value.
+ */
+ IniResult SetBoolean(CSStr section, CSStr key, bool value, bool force, CSStr comment);
+
+ /* --------------------------------------------------------------------------------------------
+ * Delete an entire section, or a key from a section.
+ */
+ bool DeleteValue(CSStr section)
+ {
+ return DeleteValue(section, NULL, NULL, false);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Delete an entire section, or a key from a section.
+ */
+ bool DeleteValue(CSStr section, CSStr key)
+ {
+ return DeleteValue(section, key, NULL, false);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Delete an entire section, or a key from a section.
+ */
+ bool DeleteValue(CSStr section, CSStr key, CSStr value)
+ {
+ return DeleteValue(section, key, value, false);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Delete an entire section, or a key from a section.
+ */
+ bool DeleteValue(CSStr section, CSStr key, CSStr value, bool empty);
+};
+
+} // Namespace:: SqMod
+
+#endif // _SQINI_DOCUMENT_HPP_
diff --git a/modules/ini/Entries.cpp b/modules/ini/Entries.cpp
new file mode 100644
index 00000000..b6284ba0
--- /dev/null
+++ b/modules/ini/Entries.cpp
@@ -0,0 +1,85 @@
+// ------------------------------------------------------------------------------------------------
+#include "Entries.hpp"
+#include "Module.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+// ------------------------------------------------------------------------------------------------
+Int32 Entries::Cmp(const Entries & o) const
+{
+ if (m_Elem == o.m_Elem)
+ return 0;
+ else if (this > &o)
+ return 1;
+ else
+ return -1;
+}
+
+// ------------------------------------------------------------------------------------------------
+void Entries::Next()
+{
+ // Are there any other elements ahead?
+ if (!m_List.empty() && m_Elem != m_List.end())
+ ++m_Elem; /* Go ahead one element */
+}
+
+// ------------------------------------------------------------------------------------------------
+void Entries::Prev()
+{
+ // Are there any other elements behind?
+ if (!m_List.empty() && m_Elem != m_List.begin())
+ --m_Elem; /* Go back one element */
+}
+
+// ------------------------------------------------------------------------------------------------
+void Entries::Advance(Int32 n)
+{
+ // Are there any other elements ahead?
+ if (m_List.empty() || m_Elem == m_List.end())
+ return;
+ // Jump as many elements as possible within the specified distance
+ while ((--n >= 0) && m_Elem != m_List.end()) ++m_Elem;
+}
+
+// ------------------------------------------------------------------------------------------------
+void Entries::Retreat(Int32 n)
+{
+ // Are there any other elements behind?
+ if (m_List.empty() || m_Elem == m_List.begin())
+ return;
+ // Jump as many elements as possible within the specified distance
+ while ((--n >= 0) && m_Elem != m_List.begin()) --m_Elem;
+}
+
+// ------------------------------------------------------------------------------------------------
+CSStr Entries::GetItem() const
+{
+ if (m_List.empty() || m_Elem == m_List.end())
+ _SqMod->SqThrow("Invalid INI entry [item]");
+ else
+ return m_Elem->pItem;
+ return _SC("");
+}
+
+// ------------------------------------------------------------------------------------------------
+CSStr Entries::GetComment() const
+{
+ if (m_List.empty() || m_Elem == m_List.end())
+ _SqMod->SqThrow("Invalid INI entry [comment]");
+ else
+ return m_Elem->pComment;
+ return _SC("");
+}
+
+// ------------------------------------------------------------------------------------------------
+Int32 Entries::GetOrder() const
+{
+ if (m_List.empty() || m_Elem == m_List.end())
+ _SqMod->SqThrow("Invalid INI entry [order]");
+ else
+ return m_Elem->nOrder;
+ return -1;
+}
+
+} // Namespace:: SqMod
diff --git a/modules/ini/Entries.hpp b/modules/ini/Entries.hpp
new file mode 100644
index 00000000..375566b2
--- /dev/null
+++ b/modules/ini/Entries.hpp
@@ -0,0 +1,220 @@
+#ifndef _SQINI_ENTRIES_HPP_
+#define _SQINI_ENTRIES_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "Common.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * Class that can access and iterate a series of entries in the INI document.
+*/
+class Entries
+{
+ // --------------------------------------------------------------------------------------------
+ friend class Document;
+
+protected:
+
+ // --------------------------------------------------------------------------------------------
+ typedef DocumentRef::Type::TNamesDepend Container;
+
+ // --------------------------------------------------------------------------------------------
+ typedef Container::iterator Iterator;
+
+ /* --------------------------------------------------------------------------------------------
+ * Default constructor.
+ */
+ Entries(const DocumentRef & ini, Container & list)
+ : m_Doc(ini), m_List(), m_Elem()
+ {
+ m_List.swap(list);
+ Reset();
+ }
+
+private:
+
+ // ---------------------------------------------------------------------------------------------
+ DocumentRef m_Doc; /* The document that contains the elements. */
+ Container m_List; /* The list of elements to iterate. */
+ Iterator m_Elem; /* The currently processed element. */
+
+public:
+
+ /* --------------------------------------------------------------------------------------------
+ * Default constructor. (null)
+ */
+ Entries()
+ : m_Doc(), m_List(), m_Elem(m_List.end())
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy constructor.
+ */
+ Entries(const Entries & o)
+ : m_Doc(o.m_Doc), m_List(o.m_List), m_Elem()
+ {
+ Reset();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Destructor.
+ */
+ ~Entries()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy assignment operator.
+ */
+ Entries & operator = (const Entries & o)
+ {
+ m_Doc = o.m_Doc;
+ m_List = o.m_List;
+ Reset();
+ return *this;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to compare two instances of this type.
+ */
+ Int32 Cmp(const Entries & o) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to convert an instance of this type to a string.
+ */
+ CSStr ToString() const
+ {
+ return GetItem();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to retrieve the name from instances of this type.
+ */
+ CSStr Typename() const
+ {
+ return _SC("SqIniEntries");
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Return whether the current element is valid and can be accessed.
+ */
+ bool IsValid() const
+ {
+ return !(m_List.empty() || m_Elem == m_List.end());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Return whether the entry list is empty.
+ */
+ bool IsEmpty() const
+ {
+ return m_List.empty();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Return the number of active references to this document instance.
+ */
+ Uint32 GetRefCount() const
+ {
+ return m_Doc.Count();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Return the total entries in the list.
+ */
+ Int32 GetSize() const
+ {
+ return (Int32)m_List.size();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Reset the internal iterator to the first element.
+ */
+ void Reset()
+ {
+ if (m_List.empty())
+ m_Elem = m_List.end();
+ else
+ m_Elem = m_List.begin();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Go to the next element.
+ */
+ void Next();
+
+ /* --------------------------------------------------------------------------------------------
+ * Go to the previous element.
+ */
+ void Prev();
+
+ /* --------------------------------------------------------------------------------------------
+ * Advance a certain number of elements.
+ */
+ void Advance(Int32 n);
+
+ /* --------------------------------------------------------------------------------------------
+ * Retreat a certain number of elements.
+ */
+ void Retreat(Int32 n);
+
+ /* --------------------------------------------------------------------------------------------
+ * Sort the entries using the default options.
+ */
+ void Sort()
+ {
+ if (!m_List.empty())
+ m_List.sort(DocumentRef::Type::Entry::KeyOrder());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Sort the entries by name of key only.
+ */
+ void SortByKeyOrder()
+ {
+ if (!m_List.empty())
+ m_List.sort(DocumentRef::Type::Entry::KeyOrder());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Sort the entries by their load order and then name of key.
+ */
+ void SortByLoadOrder()
+ {
+ if (!m_List.empty())
+ m_List.sort(DocumentRef::Type::Entry::LoadOrder());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Sort the entries by their load order but empty name always goes first.
+ */
+ void SortByLoadOrderEmptyFirst()
+ {
+ if (!m_List.empty())
+ m_List.sort(DocumentRef::Type::Entry::LoadOrderEmptyFirst());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the string value of the current element item.
+ */
+ CSStr GetItem() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the string value of the current element comment.
+ */
+ CSStr GetComment() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the order of the current element.
+ */
+ Int32 GetOrder() const;
+};
+
+} // Namespace:: SqMod
+
+#endif // _SQINI_ENTRIES_HPP_
\ No newline at end of file
diff --git a/modules/ini/Module.cpp b/modules/ini/Module.cpp
new file mode 100644
index 00000000..f8bc473a
--- /dev/null
+++ b/modules/ini/Module.cpp
@@ -0,0 +1,414 @@
+// --------------------------------------------------------------------------------------------
+#include "Module.hpp"
+#include "Common.hpp"
+#include "Entries.hpp"
+#include "Document.hpp"
+
+// --------------------------------------------------------------------------------------------
+#include
+
+// --------------------------------------------------------------------------------------------
+#include
+#include
+#include
+
+// --------------------------------------------------------------------------------------------
+#if defined(WIN32) || defined(_WIN32)
+ #include
+#endif
+
+namespace SqMod {
+
+// --------------------------------------------------------------------------------------------
+PluginFuncs* _Func = NULL;
+PluginCallbacks* _Clbk = NULL;
+PluginInfo* _Info = NULL;
+
+// --------------------------------------------------------------------------------------------
+HSQAPI _SqAPI = NULL;
+HSQEXPORTS _SqMod = NULL;
+HSQUIRRELVM _SqVM = NULL;
+
+/* ------------------------------------------------------------------------------------------------
+ * Bind speciffic functions to certain server events.
+*/
+void BindCallbacks();
+
+/* ------------------------------------------------------------------------------------------------
+ * Undo changes made with BindCallbacks().
+*/
+void UnbindCallbacks();
+
+/* --------------------------------------------------------------------------------------------
+ * Register the module API under the specified virtual machine.
+*/
+void RegisterAPI(HSQUIRRELVM vm);
+
+/* --------------------------------------------------------------------------------------------
+ * Initialize the plugin by obtaining the API provided by the host plugin.
+*/
+void OnSquirrelInitialize()
+{
+ // Attempt to import the plugin API exported by the host plugin
+ _SqMod = sq_api_import(_Func);
+ // Did we failed to obtain the plugin exports?
+ if(!_SqMod)
+ OutputError("Failed to attach [%s] on host plugin.", SQINI_NAME);
+ else
+ {
+ // Obtain the Squirrel API
+ _SqAPI = _SqMod->GetSquirrelAPI();
+ // Expand the Squirrel API into global functions
+ sq_api_expand(_SqAPI);
+ }
+}
+
+/* --------------------------------------------------------------------------------------------
+ * Load the module on the virtual machine provided by the host module.
+*/
+void OnSquirrelLoad()
+{
+ // Make sure that we have a valid plugin API
+ if (!_SqMod)
+ return; /* Unable to proceed. */
+ // Obtain the Squirrel API and VM
+ _SqVM = _SqMod->GetSquirrelVM();
+ // Make sure that a valid virtual machine exists
+ if (!_SqVM)
+ return; /* Unable to proceed. */
+ // Set this as the default database
+ DefaultVM::Set(_SqVM);
+ // Register the module API
+ RegisterAPI(_SqVM);
+ // Notify about the current status
+ OutputMessage("Registered: %s", SQINI_NAME);
+}
+
+/* --------------------------------------------------------------------------------------------
+ * The virtual machine is about to be terminated and script resources should be released.
+*/
+void OnSquirrelTerminate()
+{
+ OutputMessage("Terminating: %s", SQINI_NAME);
+ // Release the current database (if any)
+ DefaultVM::Set(NULL);
+}
+
+/* --------------------------------------------------------------------------------------------
+ * Validate the module API to make sure we don't run into issues.
+*/
+bool CheckAPIVer(CCStr ver)
+{
+ // Obtain the numeric representation of the API version
+ long vernum = strtol(ver, NULL, 10);
+ // Check against version mismatch
+ if (vernum == SQMOD_API_VER)
+ return true;
+ // Log the incident
+ OutputError("API version mismatch on %s", SQINI_NAME);
+ OutputMessage("=> Requested: %ld Have: %ld", vernum, SQMOD_API_VER);
+ // Invoker should not attempt to communicate through the module API
+ return false;
+}
+
+/* --------------------------------------------------------------------------------------------
+ * React to command sent by other plugins.
+*/
+static int OnInternalCommand(unsigned int type, const char * text)
+{
+ switch(type)
+ {
+ case SQMOD_INITIALIZE_CMD:
+ if (CheckAPIVer(text))
+ OnSquirrelInitialize();
+ break;
+ case SQMOD_LOAD_CMD:
+ OnSquirrelLoad();
+ break;
+ case SQMOD_TERMINATE_CMD:
+ OnSquirrelTerminate();
+ break;
+ default: break;
+ }
+ return 1;
+}
+
+/* --------------------------------------------------------------------------------------------
+ * The server was initialized and this plugin was loaded successfully.
+*/
+static int OnInitServer()
+{
+ return 1;
+}
+
+static void OnShutdownServer(void)
+{
+ // The server may still send callbacks
+ UnbindCallbacks();
+}
+
+// ------------------------------------------------------------------------------------------------
+void BindCallbacks()
+{
+ _Clbk->OnInitServer = OnInitServer;
+ _Clbk->OnInternalCommand = OnInternalCommand;
+ _Clbk->OnShutdownServer = OnShutdownServer;
+}
+
+// ------------------------------------------------------------------------------------------------
+void UnbindCallbacks()
+{
+ _Clbk->OnInitServer = NULL;
+ _Clbk->OnInternalCommand = NULL;
+ _Clbk->OnShutdownServer = NULL;
+}
+
+// --------------------------------------------------------------------------------------------
+void RegisterAPI(HSQUIRRELVM vm)
+{
+ Table inins(vm);
+
+ inins.Bind(_SC("Result"), Class< IniResult >(vm, _SC("SqIniResult"))
+ /* Constructors */
+ .Ctor()
+ .Ctor< CSStr, SQInteger >()
+ .Ctor< const IniResult & >()
+ /* Core Metamethods */
+ .Func(_SC("_cmp"), &IniResult::Cmp)
+ .Func(_SC("_tostring"), &IniResult::ToString)
+ .Func(_SC("_typename"), &IniResult::Typename)
+ /* Properties */
+ .Prop(_SC("Valid"), &IniResult::IsValid)
+ .Prop(_SC("Action"), &IniResult::GetAction)
+ .Prop(_SC("Result"), &IniResult::GetResult)
+ /* Functions */
+ .Func(_SC("Check"), &IniResult::Check)
+ );
+
+ inins.Bind(_SC("Entries"), Class< Entries >(vm, _SC("SqIniEntries"))
+ /* Constructors */
+ .Ctor()
+ .Ctor< const Entries & >()
+ /* Core Metamethods */
+ .Func(_SC("_cmp"), &Entries::Cmp)
+ .Func(_SC("_typename"), &Entries::Typename)
+ .Func(_SC("_tostring"), &Entries::ToString)
+ /* Properties */
+ .Prop(_SC("Valid"), &Entries::IsValid)
+ .Prop(_SC("Empty"), &Entries::IsEmpty)
+ .Prop(_SC("References"), &Entries::GetRefCount)
+ .Prop(_SC("Size"), &Entries::GetSize)
+ .Prop(_SC("Item"), &Entries::GetItem)
+ .Prop(_SC("Comment"), &Entries::GetComment)
+ .Prop(_SC("Order"), &Entries::GetOrder)
+ /* Functions */
+ .Func(_SC("Reset"), &Entries::Reset)
+ .Func(_SC("Next"), &Entries::Next)
+ .Func(_SC("Prev"), &Entries::Prev)
+ .Func(_SC("Advance"), &Entries::Advance)
+ .Func(_SC("Retreat"), &Entries::Retreat)
+ .Func(_SC("Sort"), &Entries::Sort)
+ .Func(_SC("SortByKeyOrder"), &Entries::SortByKeyOrder)
+ .Func(_SC("SortByLoadOrder"), &Entries::SortByLoadOrder)
+ .Func(_SC("SortByLoadOrderEmptyFirst"), &Entries::SortByLoadOrderEmptyFirst)
+ );
+
+ inins.Bind(_SC("Document"), Class< Document, NoCopy< Document > >(vm, _SC("SqIniDocument"))
+ /* Constructors */
+ .Ctor()
+ .Ctor< bool >()
+ .Ctor< bool, bool >()
+ .Ctor< bool, bool, bool >()
+ /* Core Metamethods */
+ .Func(_SC("_cmp"), &Document::Cmp)
+ .Func(_SC("_typename"), &Document::Typename)
+ .Func(_SC("_tostring"), &Document::ToString)
+ /* Properties */
+ .Prop(_SC("Valid"), &Document::IsValid)
+ .Prop(_SC("Empty"), &Document::IsEmpty)
+ .Prop(_SC("References"), &Document::GetRefCount)
+ .Prop(_SC("Unicode"), &Document::GetUnicode, &Document::SetUnicode)
+ .Prop(_SC("MultiKey"), &Document::GetMultiKey, &Document::SetMultiKey)
+ .Prop(_SC("MultiLine"), &Document::GetMultiLine, &Document::SetMultiLine)
+ .Prop(_SC("Spaces"), &Document::GetSpaces, &Document::SetSpaces)
+ /* Functions */
+ .Func(_SC("Reset"), &Document::Reset)
+ .Func(_SC("LoadFile"), &Document::LoadFile)
+ .Overload< IniResult (Document::*)(CSStr) >(_SC("LoadString"), &Document::LoadData)
+ .Overload< IniResult (Document::*)(CSStr, Int32) >(_SC("LoadString"), &Document::LoadData)
+ .Overload< IniResult (Document::*)(CSStr) >(_SC("SaveFile"), &Document::SaveFile)
+ .Overload< IniResult (Document::*)(CSStr, bool) >(_SC("SaveFile"), &Document::SaveFile)
+ .Func(_SC("SaveData"), &Document::SaveData)
+ .Func(_SC("GetSections"), &Document::GetAllSections)
+ .Func(_SC("GetKeys"), &Document::GetAllKeys)
+ .Func(_SC("GetValues"), &Document::GetAllValues)
+ .Func(_SC("GetSectionSize"), &Document::GetSectionSize)
+ .Func(_SC("HasMultipleKeys"), &Document::HasMultipleKeys)
+ .Func(_SC("GetValue"), &Document::GetValue)
+ .Func(_SC("GetInteger"), &Document::GetInteger)
+ .Func(_SC("GetFloat"), &Document::GetFloat)
+ .Func(_SC("GetBoolean"), &Document::GetBoolean)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, CSStr) >(_SC("SetValue"), &Document::SetValue)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, CSStr, bool) >(_SC("SetValue"), &Document::SetValue)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, CSStr, bool, CSStr) >(_SC("SetValue"), &Document::SetValue)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, SQInteger) >(_SC("SetInteger"), &Document::SetInteger)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, SQInteger, bool) >(_SC("SetInteger"), &Document::SetInteger)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, SQInteger, bool, bool) >(_SC("SetInteger"), &Document::SetInteger)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, SQInteger, bool, bool, CSStr) >(_SC("SetInteger"), &Document::SetInteger)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, SQFloat) >(_SC("SetFloat"), &Document::SetFloat)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, SQFloat, bool) >(_SC("SetFloat"), &Document::SetFloat)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, SQFloat, bool, CSStr) >(_SC("SetFloat"), &Document::SetFloat)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, bool) >(_SC("SetBoolean"), &Document::SetBoolean)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, bool, bool) >(_SC("SetBoolean"), &Document::SetBoolean)
+ .Overload< IniResult (Document::*)(CSStr, CSStr, bool, bool, CSStr) >(_SC("SetBoolean"), &Document::SetBoolean)
+ .Overload< bool (Document::*)(CSStr) >(_SC("DeleteValue"), &Document::DeleteValue)
+ .Overload< bool (Document::*)(CSStr, CSStr) >(_SC("DeleteValue"), &Document::DeleteValue)
+ .Overload< bool (Document::*)(CSStr, CSStr, CSStr) >(_SC("DeleteValue"), &Document::DeleteValue)
+ .Overload< bool (Document::*)(CSStr, CSStr, CSStr, bool) >(_SC("DeleteValue"), &Document::DeleteValue)
+ );
+
+ RootTable(vm).Bind(_SC("SqIni"), inins);
+
+ ConstTable(vm).Enum(_SC("SqIniError"), Enumeration(vm)
+ .Const(_SC("Ok"), Int32(SI_OK))
+ .Const(_SC("Updated"), Int32(SI_UPDATED))
+ .Const(_SC("Inserted"), Int32(SI_INSERTED))
+ .Const(_SC("Fail"), Int32(SI_FAIL))
+ .Const(_SC("NoMem"), Int32(SI_NOMEM))
+ .Const(_SC("File"), Int32(SI_FILE))
+ .Const(_SC("BadRef"), Int32(SI_BADREF))
+ );
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputMessageImpl(const char * msg, va_list args)
+{
+#if defined(WIN32) || defined(_WIN32)
+ HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ CONSOLE_SCREEN_BUFFER_INFO csb_before;
+ GetConsoleScreenBufferInfo( hstdout, &csb_before);
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN);
+ printf("[SQMOD] ");
+
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
+ vprintf(msg, args);
+ puts("");
+
+ SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
+#else
+ printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27, msg);
+ vprintf(msg, args);
+ puts("");
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputErrorImpl(const char * msg, va_list args)
+{
+#if defined(WIN32) || defined(_WIN32)
+ HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ CONSOLE_SCREEN_BUFFER_INFO csb_before;
+ GetConsoleScreenBufferInfo( hstdout, &csb_before);
+ SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
+ printf("[SQMOD] ");
+
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
+ vprintf(msg, args);
+ puts("");
+
+ SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
+#else
+ printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27, msg);
+ vprintf(msg, args);
+ puts("");
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputDebug(const char * msg, ...)
+{
+#ifdef _DEBUG
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputMessageImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+#else
+ SQMOD_UNUSED_VAR(msg);
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputMessage(const char * msg, ...)
+{
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputMessageImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputError(const char * msg, ...)
+{
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputErrorImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+}
+
+} // Namespace:: SqMod
+
+// --------------------------------------------------------------------------------------------
+SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallbacks* callbacks, PluginInfo* info)
+{
+ using namespace SqMod;
+ // Output plugin header
+ puts("");
+ OutputMessage("--------------------------------------------------------------------");
+ OutputMessage("Plugin: %s", SQINI_NAME);
+ OutputMessage("Author: %s", SQINI_AUTHOR);
+ OutputMessage("Legal: %s", SQINI_COPYRIGHT);
+ OutputMessage("--------------------------------------------------------------------");
+ puts("");
+ // Attempt to find the host plugin ID
+ int host_plugin_id = functions->FindPlugin((char *)(SQMOD_HOST_NAME));
+ // See if our plugin was loaded after the host plugin
+ if (host_plugin_id < 0)
+ {
+ OutputError("%s could find the host plugin", SQINI_NAME);
+ // Don't load!
+ return SQMOD_FAILURE;
+ }
+ // Should never reach this point but just in case
+ else if (host_plugin_id > (info->nPluginId))
+ {
+ OutputError("%s loaded after the host plugin", SQINI_NAME);
+ // Don't load!
+ return SQMOD_FAILURE;
+ }
+ // Store server proxies
+ _Func = functions;
+ _Clbk = callbacks;
+ _Info = info;
+ // Assign plugin information
+ _Info->uPluginVer = SQINI_VERSION;
+ strcpy(_Info->szName, SQINI_HOST_NAME);
+ // Bind callbacks
+ BindCallbacks();
+ // Notify that the plugin was successfully loaded
+ OutputMessage("Successfully loaded %s", SQINI_NAME);
+ // Dummy spacing
+ puts("");
+ // Done!
+ return SQMOD_SUCCESS;
+}
diff --git a/modules/ini/Module.hpp b/modules/ini/Module.hpp
new file mode 100644
index 00000000..c84a379a
--- /dev/null
+++ b/modules/ini/Module.hpp
@@ -0,0 +1,41 @@
+#ifndef _SQINI_MODULE_HPP_
+#define _SQINI_MODULE_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "SqMod.h"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * Proxies to comunicate with the server.
+*/
+extern PluginFuncs* _Func;
+extern PluginCallbacks* _Clbk;
+extern PluginInfo* _Info;
+
+/* ------------------------------------------------------------------------------------------------
+ * Proxies to comunicate with the Squirrel plugin.
+*/
+extern HSQAPI _SqAPI;
+extern HSQEXPORTS _SqMod;
+extern HSQUIRRELVM _SqVM;
+
+/* ------------------------------------------------------------------------------------------------
+ * Output a message only if the _DEBUG was defined.
+*/
+void OutputDebug(const char * msg, ...);
+
+/* ------------------------------------------------------------------------------------------------
+ * Output a formatted user message to the console.
+*/
+void OutputMessage(const char * msg, ...);
+
+/* ------------------------------------------------------------------------------------------------
+ * Output a formatted error message to the console.
+*/
+void OutputError(const char * msg, ...);
+
+} // Namespace:: SqMod
+
+#endif // _SQINI_MODULE_HPP_
diff --git a/modules/irc/Common.cpp b/modules/irc/Common.cpp
new file mode 100644
index 00000000..006fe12a
--- /dev/null
+++ b/modules/irc/Common.cpp
@@ -0,0 +1,33 @@
+// ------------------------------------------------------------------------------------------------
+#include "Common.hpp"
+#include "Module.hpp"
+
+// ------------------------------------------------------------------------------------------------
+#include
+#include
+
+// ------------------------------------------------------------------------------------------------
+static SQChar g_Buffer[512];
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+// ------------------------------------------------------------------------------------------------
+CSStr GetNick(CSStr origin)
+{
+ // Attempt to retrieve the nickname
+ irc_target_get_nick(origin, g_Buffer, sizeof(g_Buffer));
+ // Return the nickname that could be retrieved
+ return g_Buffer;
+}
+
+// ------------------------------------------------------------------------------------------------
+CSStr GetHost(CSStr target)
+{
+ // Attempt to retrieve the host
+ irc_target_get_host(target, g_Buffer, sizeof(g_Buffer));
+ // Return the host that could be retrieved
+ return g_Buffer;
+}
+
+} // Namespace:: SqMod
diff --git a/modules/irc/Common.hpp b/modules/irc/Common.hpp
new file mode 100644
index 00000000..07d06155
--- /dev/null
+++ b/modules/irc/Common.hpp
@@ -0,0 +1,40 @@
+#ifndef _SQIRC_COMMON_HPP_
+#define _SQIRC_COMMON_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "ModBase.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * SOFTWARE INFORMATION
+*/
+#define SQIRC_NAME "Squirrel IRC Module"
+#define SQIRC_AUTHOR "Sandu Liviu Catalin (S.L.C)"
+#define SQIRC_COPYRIGHT "Copyright (C) 2016 Sandu Liviu Catalin"
+#define SQIRC_HOST_NAME "SqModIRCHost"
+#define SQIRC_VERSION 001
+#define SQIRC_VERSION_STR "0.0.1"
+#define SQIRC_VERSION_MAJOR 0
+#define SQIRC_VERSION_MINOR 0
+#define SQIRC_VERSION_PATCH 1
+
+/* ------------------------------------------------------------------------------------------------
+ * Forward declarations.
+*/
+class Session;
+
+/* ------------------------------------------------------------------------------------------------
+ * Extract the name from the specified origin.
+*/
+CSStr GetNick(CSStr origin);
+
+/* ------------------------------------------------------------------------------------------------
+ * Extract the host from the specified origin.
+*/
+CSStr GetHost(CSStr target);
+
+} // Namespace:: SqMod
+
+#endif // _SQIRC_COMMON_HPP_
diff --git a/modules/irc/Module.cpp b/modules/irc/Module.cpp
new file mode 100644
index 00000000..a177aec1
--- /dev/null
+++ b/modules/irc/Module.cpp
@@ -0,0 +1,620 @@
+// --------------------------------------------------------------------------------------------
+#include "Module.hpp"
+#include "Common.hpp"
+#include "Session.hpp"
+
+// --------------------------------------------------------------------------------------------
+#include
+
+// --------------------------------------------------------------------------------------------
+#include
+#include
+#include
+
+// --------------------------------------------------------------------------------------------
+#if defined(WIN32) || defined(_WIN32)
+ #include
+ #include
+#endif
+
+namespace SqMod {
+
+// --------------------------------------------------------------------------------------------
+PluginFuncs* _Func = NULL;
+PluginCallbacks* _Clbk = NULL;
+PluginInfo* _Info = NULL;
+
+// --------------------------------------------------------------------------------------------
+HSQAPI _SqAPI = NULL;
+HSQEXPORTS _SqMod = NULL;
+HSQUIRRELVM _SqVM = NULL;
+
+/* ------------------------------------------------------------------------------------------------
+ * Bind speciffic functions to certain server events.
+*/
+void BindCallbacks();
+
+/* ------------------------------------------------------------------------------------------------
+ * Undo changes made with BindCallbacks().
+*/
+void UnbindCallbacks();
+
+/* --------------------------------------------------------------------------------------------
+ * Register the module API under the specified virtual machine.
+*/
+void RegisterAPI(HSQUIRRELVM vm);
+
+/* --------------------------------------------------------------------------------------------
+ * Initialize the plugin by obtaining the API provided by the host plugin.
+*/
+void OnSquirrelInitialize()
+{
+ // Attempt to import the plugin API exported by the host plugin
+ _SqMod = sq_api_import(_Func);
+ // Did we failed to obtain the plugin exports?
+ if(!_SqMod)
+ OutputError("Failed to attach [%s] on host plugin.", SQIRC_NAME);
+ else
+ {
+ // Obtain the Squirrel API
+ _SqAPI = _SqMod->GetSquirrelAPI();
+ // Expand the Squirrel API into global functions
+ sq_api_expand(_SqAPI);
+ }
+}
+
+/* --------------------------------------------------------------------------------------------
+ * Load the module on the virtual machine provided by the host module.
+*/
+void OnSquirrelLoad()
+{
+ // Make sure that we have a valid plugin API
+ if (!_SqMod)
+ return; /* Unable to proceed. */
+ // Obtain the Squirrel API and VM
+ _SqVM = _SqMod->GetSquirrelVM();
+ // Make sure that a valid virtual machine exists
+ if (!_SqVM)
+ return; /* Unable to proceed. */
+ // Set this as the default database
+ DefaultVM::Set(_SqVM);
+ // Register the module API
+ RegisterAPI(_SqVM);
+ // Notify about the current status
+ OutputMessage("Registered: %s", SQIRC_NAME);
+}
+
+/* --------------------------------------------------------------------------------------------
+ * The virtual machine is about to be terminated and script resources should be released.
+*/
+void OnSquirrelTerminate()
+{
+ OutputMessage("Terminating: %s", SQIRC_NAME);
+ // Terminate all session and release script resources
+ Session::Terminate();
+ // Release the current database (if any)
+ DefaultVM::Set(NULL);
+}
+
+/* --------------------------------------------------------------------------------------------
+ * Update the plugin on each frame.
+*/
+static void OnFrame(float /*delta*/)
+{
+ // Update the sessions and pool for events
+ Session::Process();
+}
+
+/* --------------------------------------------------------------------------------------------
+ * Validate the module API to make sure we don't run into issues.
+*/
+bool CheckAPIVer(CCStr ver)
+{
+ // Obtain the numeric representation of the API version
+ long vernum = strtol(ver, NULL, 10);
+ // Check against version mismatch
+ if (vernum == SQMOD_API_VER)
+ return true;
+ // Log the incident
+ OutputError("API version mismatch on %s", SQIRC_NAME);
+ OutputMessage("=> Requested: %ld Have: %ld", vernum, SQMOD_API_VER);
+ // Invoker should not attempt to communicate through the module API
+ return false;
+}
+
+/* --------------------------------------------------------------------------------------------
+ * React to command sent by other plugins.
+*/
+static int OnInternalCommand(unsigned int type, const char * text)
+{
+ switch(type)
+ {
+ case SQMOD_INITIALIZE_CMD:
+ if (CheckAPIVer(text))
+ OnSquirrelInitialize();
+ break;
+ case SQMOD_LOAD_CMD:
+ OnSquirrelLoad();
+ break;
+ case SQMOD_TERMINATE_CMD:
+ OnSquirrelTerminate();
+ break;
+ default: break;
+ }
+ return 1;
+}
+
+/* --------------------------------------------------------------------------------------------
+ * The server was initialized and this plugin was loaded successfully.
+*/
+static int OnInitServer()
+{
+ return 1;
+}
+
+static void OnShutdownServer(void)
+{
+ // The server may still send callbacks
+ UnbindCallbacks();
+}
+
+// ------------------------------------------------------------------------------------------------
+void BindCallbacks()
+{
+ _Clbk->OnInitServer = OnInitServer;
+ _Clbk->OnFrame = OnFrame;
+ _Clbk->OnInternalCommand = OnInternalCommand;
+ _Clbk->OnShutdownServer = OnShutdownServer;
+}
+
+// ------------------------------------------------------------------------------------------------
+void UnbindCallbacks()
+{
+ _Clbk->OnInitServer = NULL;
+ _Clbk->OnFrame = NULL;
+ _Clbk->OnInternalCommand = NULL;
+ _Clbk->OnShutdownServer = NULL;
+}
+
+// --------------------------------------------------------------------------------------------
+void RegisterAPI(HSQUIRRELVM vm)
+{
+ Table ircns(vm);
+
+ ircns.Bind(_SC("Session"), Class< Session, NoCopy< Session > >(vm, _SC("SqIrcSession"))
+ /* Constructors */
+ .Ctor()
+ /* Core Metamethods */
+ .Func(_SC("_cmp"), &Session::Cmp)
+ .Func(_SC("_typename"), &Session::Typename)
+ .Func(_SC("_tostring"), &Session::ToString)
+ /* Properties */
+ .Prop(_SC("Valid"), &Session::IsValid)
+ .Prop(_SC("Connected"), &Session::IsConnected)
+ .Prop(_SC("Tag"), &Session::GetTag, &Session::SetTag)
+ .Prop(_SC("Data"), &Session::GetData, &Session::SetData)
+ .Prop(_SC("Server"), &Session::GetServer, &Session::SetServer)
+ .Prop(_SC("Password"), &Session::GetPassword, &Session::SetPassword)
+ .Prop(_SC("Nick"), &Session::GetNick, &Session::SetNick)
+ .Prop(_SC("User"), &Session::GetUser, &Session::SetUser)
+ .Prop(_SC("Name"), &Session::GetName, &Session::SetName)
+ .Prop(_SC("Port"), &Session::GetPort, &Session::SetPort)
+ .Prop(_SC("PoolTime"), &Session::GetPoolTime, &Session::SetPoolTime)
+ .Prop(_SC("LastCode"), &Session::GetLastCode)
+ .Prop(_SC("Tries"), &Session::GetTries, &Session::SetTries)
+ .Prop(_SC("Wait"), &Session::GetWait, &Session::SetWait)
+ .Prop(_SC("LeftTries"), &Session::GetLeftTries, &Session::SetLeftTries)
+ .Prop(_SC("NextTry"), &Session::GetNextTry, &Session::SetNextTry)
+ .Prop(_SC("SessionTime"), &Session::GetSessionTime)
+ .Prop(_SC("Reconnecting"), &Session::GetReconnect)
+ .Prop(_SC("IPv6"), &Session::GetIPv6)
+ .Prop(_SC("Server"), &Session::GetServer, &Session::SetServer)
+ .Prop(_SC("CtcpVersion"), (void (Session::*)(void))(NULL), &Session::SetCtcpVersion)
+ .Prop(_SC("ErrNo"), &Session::GetErrNo)
+ .Prop(_SC("ErrStr"), &Session::GetErrStr)
+ .Prop(_SC("OnConnect"), &Session::GetOnConnect)
+ .Prop(_SC("OnNick"), &Session::GetOnNick)
+ .Prop(_SC("OnQuit"), &Session::GetOnQuit)
+ .Prop(_SC("OnJoin"), &Session::GetOnJoin)
+ .Prop(_SC("OnPart"), &Session::GetOnPart)
+ .Prop(_SC("OnMode"), &Session::GetOnMode)
+ .Prop(_SC("OnUmode"), &Session::GetOnUmode)
+ .Prop(_SC("OnTopic"), &Session::GetOnTopic)
+ .Prop(_SC("OnKick"), &Session::GetOnKick)
+ .Prop(_SC("OnChannel"), &Session::GetOnChannel)
+ .Prop(_SC("OnPrivMsg"), &Session::GetOnPrivMsg)
+ .Prop(_SC("OnNotice"), &Session::GetOnNotice)
+ .Prop(_SC("OnChannelNotice"), &Session::GetOnChannelNotice)
+ .Prop(_SC("OnInvite"), &Session::GetOnInvite)
+ .Prop(_SC("OnCtcpReq"), &Session::GetOnCtcpReq)
+ .Prop(_SC("OnCtcpRep"), &Session::GetOnCtcpRep)
+ .Prop(_SC("OnCtcpAction"), &Session::GetOnCtcpAction)
+ .Prop(_SC("OnUnknown"), &Session::GetOnUnknown)
+ .Prop(_SC("OnNumeric"), &Session::GetOnNumeric)
+ .Prop(_SC("OnDccChatReq"), &Session::GetOnDccChatReq)
+ .Prop(_SC("OnDccSendReq"), &Session::GetOnDccSendReq)
+ /* Functions */
+ .Overload< Int32 (Session::*)(void) >(_SC("Connect"), &Session::Connect)
+ .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr) >(_SC("Connect"), &Session::Connect)
+ .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr) >(_SC("Connect"), &Session::Connect)
+ .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr, CSStr) >(_SC("Connect"), &Session::Connect)
+ .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr, CSStr, CSStr) >(_SC("Connect"), &Session::Connect)
+ .Overload< Int32 (Session::*)(void) >(_SC("Connect6"), &Session::Connect6)
+ .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr) >(_SC("Connect6"), &Session::Connect6)
+ .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr) >(_SC("Connect6"), &Session::Connect6)
+ .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr, CSStr) >(_SC("Connect6"), &Session::Connect6)
+ .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr, CSStr, CSStr) >(_SC("Connect6"), &Session::Connect6)
+ .Func(_SC("Disconnect"), &Session::Disconnect)
+ .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdJoin"), &Session::CmdJoin)
+ .Overload< Int32 (Session::*)(CSStr, CSStr) >(_SC("CmdJoin"), &Session::CmdJoin)
+ .Func(_SC("CmdPart"), &Session::CmdPart)
+ .Func(_SC("CmdInvite"), &Session::CmdInvite)
+ .Func(_SC("CmdNames"), &Session::CmdNames)
+ .Overload< Int32 (Session::*)(void) >(_SC("CmdList"), &Session::CmdList)
+ .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdList"), &Session::CmdList)
+ .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdTopic"), &Session::CmdTopic)
+ .Overload< Int32 (Session::*)(CSStr, CSStr) >(_SC("CmdTopic"), &Session::CmdTopic)
+ .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdChannelMode"), &Session::CmdChannelMode)
+ .Overload< Int32 (Session::*)(CSStr, CSStr) >(_SC("CmdChannelMode"), &Session::CmdChannelMode)
+ .Overload< Int32 (Session::*)(void) >(_SC("CmdUserMode"), &Session::CmdUserMode)
+ .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdUserMode"), &Session::CmdUserMode)
+ .Overload< Int32 (Session::*)(CSStr, CSStr) >(_SC("CmdKick"), &Session::CmdKick)
+ .Overload< Int32 (Session::*)(CSStr, CSStr, CSStr) >(_SC("CmdKick"), &Session::CmdKick)
+ .Func(_SC("CmdMsg"), &Session::CmdMsg)
+ .Func(_SC("CmdMe"), &Session::CmdMe)
+ .Func(_SC("CmdNotice"), &Session::CmdNotice)
+ .Func(_SC("CmdCtcpRequest"), &Session::CmdCtcpRequest)
+ .Func(_SC("CmdCtcpReply"), &Session::CmdCtcpReply)
+ .Func(_SC("CmdNick"), &Session::CmdNick)
+ .Func(_SC("CmdWhois"), &Session::CmdWhois)
+ .Overload< Int32 (Session::*)(void) >(_SC("CmdQuit"), &Session::CmdQuit)
+ .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdQuit"), &Session::CmdQuit)
+ .Func(_SC("SendRaw"), &Session::SendRaw)
+ .Func(_SC("DestroyDcc"), &Session::DestroyDcc)
+ .Func(_SC("SetCtcpVersion"), &Session::SetCtcpVersion)
+ .Func(_SC("SetOption"), &Session::SetOption)
+ .Func(_SC("ResetOption"), &Session::ResetOption)
+ .Func(_SC("BindConnect"), &Session::BindOnConnect)
+ .Func(_SC("BindNick"), &Session::BindOnNick)
+ .Func(_SC("BindQuit"), &Session::BindOnQuit)
+ .Func(_SC("BindJoin"), &Session::BindOnJoin)
+ .Func(_SC("BindPart"), &Session::BindOnPart)
+ .Func(_SC("BindMode"), &Session::BindOnMode)
+ .Func(_SC("BindUmode"), &Session::BindOnUmode)
+ .Func(_SC("BindTopic"), &Session::BindOnTopic)
+ .Func(_SC("BindKick"), &Session::BindOnKick)
+ .Func(_SC("BindChannel"), &Session::BindOnChannel)
+ .Func(_SC("BindPrivMsg"), &Session::BindOnPrivMsg)
+ .Func(_SC("BindNotice"), &Session::BindOnNotice)
+ .Func(_SC("BindChannelNotice"), &Session::BindOnChannelNotice)
+ .Func(_SC("BindInvite"), &Session::BindOnInvite)
+ .Func(_SC("BindCtcpReq"), &Session::BindOnCtcpReq)
+ .Func(_SC("BindCtcpRep"), &Session::BindOnCtcpRep)
+ .Func(_SC("BindCtcpAction"), &Session::BindOnCtcpAction)
+ .Func(_SC("BindUnknown"), &Session::BindOnUnknown)
+ .Func(_SC("BindNumeric"), &Session::BindOnNumeric)
+ .Func(_SC("BindDccChatReq"), &Session::BindOnDccChatReq)
+ .Func(_SC("BindDccSendReq"), &Session::BindOnDccSendReq)
+ .SquirrelFunc(_SC("CmdMsgF"), &Session::CmdMsgF)
+ .SquirrelFunc(_SC("CmdMeF"), &Session::CmdMeF)
+ .SquirrelFunc(_SC("CmdNoticeF"), &Session::CmdNoticeF)
+ );
+
+ ircns.Func(_SC("GetNick"), &GetNick);
+ ircns.Func(_SC("GetHost"), &GetHost);
+ ircns.Func(_SC("GetErrStr"), &irc_strerror);
+
+ RootTable(vm).Bind(_SC("SqIrc"), ircns);
+
+ Sqrat::ConstTable(vm).Enum(_SC("SqIrcErr"), Sqrat::Enumeration(vm)
+ .Const(_SC("Ok"), LIBIRC_ERR_OK)
+ .Const(_SC("InVal"), LIBIRC_ERR_INVAL)
+ .Const(_SC("Resolv"), LIBIRC_ERR_RESOLV)
+ .Const(_SC("Socket"), LIBIRC_ERR_SOCKET)
+ .Const(_SC("Connect"), LIBIRC_ERR_CONNECT)
+ .Const(_SC("Closed"), LIBIRC_ERR_CLOSED)
+ .Const(_SC("NoMem"), LIBIRC_ERR_NOMEM)
+ .Const(_SC("Accept"), LIBIRC_ERR_ACCEPT)
+ .Const(_SC("NoDccSend"), LIBIRC_ERR_NODCCSEND)
+ .Const(_SC("Read"), LIBIRC_ERR_READ)
+ .Const(_SC("Write"), LIBIRC_ERR_WRITE)
+ .Const(_SC("State"), LIBIRC_ERR_STATE)
+ .Const(_SC("Timeout"), LIBIRC_ERR_TIMEOUT)
+ .Const(_SC("OpenFile"), LIBIRC_ERR_OPENFILE)
+ .Const(_SC("Terminated"), LIBIRC_ERR_TERMINATED)
+ .Const(_SC("NoIPv6"), LIBIRC_ERR_NOIPV6)
+ .Const(_SC("SSLNotSupported"), LIBIRC_ERR_SSL_NOT_SUPPORTED)
+ .Const(_SC("SSLInitFailed"), LIBIRC_ERR_SSL_INIT_FAILED)
+ .Const(_SC("ConnectSSLFailed"), LIBIRC_ERR_CONNECT_SSL_FAILED)
+ .Const(_SC("SSLCertVerifyFailed"), LIBIRC_ERR_SSL_CERT_VERIFY_FAILED)
+ .Const(_SC("Max"), LIBIRC_ERR_MAX)
+ );
+
+ Sqrat::ConstTable(vm).Enum(_SC("SqIrcOpt"), Sqrat::Enumeration(vm)
+ .Const(_SC("Debug"), LIBIRC_OPTION_DEBUG)
+ .Const(_SC("StripNicks"), LIBIRC_OPTION_STRIPNICKS)
+ .Const(_SC("SSLNoVerify"), LIBIRC_OPTION_SSL_NO_VERIFY)
+ );
+
+ Sqrat::ConstTable(vm).Enum(_SC("SqIrcRFC"), Sqrat::Enumeration(vm)
+ .Const(_SC("RPL_WELCOME"), LIBIRC_RFC_RPL_WELCOME)
+ .Const(_SC("RPL_YOURHOST"), LIBIRC_RFC_RPL_YOURHOST)
+ .Const(_SC("RPL_CREATED"), LIBIRC_RFC_RPL_CREATED)
+ .Const(_SC("RPL_MYINFO"), LIBIRC_RFC_RPL_MYINFO)
+ .Const(_SC("RPL_BOUNCE"), LIBIRC_RFC_RPL_BOUNCE)
+ .Const(_SC("RPL_NONE"), LIBIRC_RFC_RPL_NONE)
+ .Const(_SC("RPL_USERHOST"), LIBIRC_RFC_RPL_USERHOST)
+ .Const(_SC("RPL_ISON"), LIBIRC_RFC_RPL_ISON)
+ .Const(_SC("RPL_AWAY"), LIBIRC_RFC_RPL_AWAY)
+ .Const(_SC("RPL_UNAWAY"), LIBIRC_RFC_RPL_UNAWAY)
+ .Const(_SC("RPL_NOWAWAY"), LIBIRC_RFC_RPL_NOWAWAY)
+ .Const(_SC("RPL_WHOISUSER"), LIBIRC_RFC_RPL_WHOISUSER)
+ .Const(_SC("RPL_WHOISSERVER"), LIBIRC_RFC_RPL_WHOISSERVER)
+ .Const(_SC("RPL_WHOISOPERATOR"), LIBIRC_RFC_RPL_WHOISOPERATOR)
+ .Const(_SC("RPL_WHOISIDLE"), LIBIRC_RFC_RPL_WHOISIDLE)
+ .Const(_SC("RPL_ENDOFWHOIS"), LIBIRC_RFC_RPL_ENDOFWHOIS)
+ .Const(_SC("RPL_WHOISCHANNELS"), LIBIRC_RFC_RPL_WHOISCHANNELS)
+ .Const(_SC("RPL_WHOWASUSER"), LIBIRC_RFC_RPL_WHOWASUSER)
+ .Const(_SC("RPL_ENDOFWHOWAS"), LIBIRC_RFC_RPL_ENDOFWHOWAS)
+ .Const(_SC("RPL_LISTSTART"), LIBIRC_RFC_RPL_LISTSTART)
+ .Const(_SC("RPL_LIST"), LIBIRC_RFC_RPL_LIST)
+ .Const(_SC("RPL_LISTEND"), LIBIRC_RFC_RPL_LISTEND)
+ .Const(_SC("RPL_UNIQOPIS"), LIBIRC_RFC_RPL_UNIQOPIS)
+ .Const(_SC("RPL_CHANNELMODEIS"), LIBIRC_RFC_RPL_CHANNELMODEIS)
+ .Const(_SC("RPL_NOTOPIC"), LIBIRC_RFC_RPL_NOTOPIC)
+ .Const(_SC("RPL_TOPIC"), LIBIRC_RFC_RPL_TOPIC)
+ .Const(_SC("RPL_INVITING"), LIBIRC_RFC_RPL_INVITING)
+ .Const(_SC("RPL_SUMMONING"), LIBIRC_RFC_RPL_SUMMONING)
+ .Const(_SC("RPL_INVITELIST"), LIBIRC_RFC_RPL_INVITELIST)
+ .Const(_SC("RPL_ENDOFINVITELIST"), LIBIRC_RFC_RPL_ENDOFINVITELIST)
+ .Const(_SC("RPL_EXCEPTLIST"), LIBIRC_RFC_RPL_EXCEPTLIST)
+ .Const(_SC("RPL_ENDOFEXCEPTLIST"), LIBIRC_RFC_RPL_ENDOFEXCEPTLIST)
+ .Const(_SC("RPL_VERSION"), LIBIRC_RFC_RPL_VERSION)
+ .Const(_SC("RPL_WHOREPLY"), LIBIRC_RFC_RPL_WHOREPLY)
+ .Const(_SC("RPL_ENDOFWHO"), LIBIRC_RFC_RPL_ENDOFWHO)
+ .Const(_SC("RPL_NAMREPLY"), LIBIRC_RFC_RPL_NAMREPLY)
+ .Const(_SC("RPL_ENDOFNAMES"), LIBIRC_RFC_RPL_ENDOFNAMES)
+ .Const(_SC("RPL_LINKS"), LIBIRC_RFC_RPL_LINKS)
+ .Const(_SC("RPL_ENDOFLINKS"), LIBIRC_RFC_RPL_ENDOFLINKS)
+ .Const(_SC("RPL_BANLIST"), LIBIRC_RFC_RPL_BANLIST)
+ .Const(_SC("RPL_ENDOFBANLIST"), LIBIRC_RFC_RPL_ENDOFBANLIST)
+ .Const(_SC("RPL_INFO"), LIBIRC_RFC_RPL_INFO)
+ .Const(_SC("RPL_ENDOFINFO"), LIBIRC_RFC_RPL_ENDOFINFO)
+ .Const(_SC("RPL_MOTDSTART"), LIBIRC_RFC_RPL_MOTDSTART)
+ .Const(_SC("RPL_MOTD"), LIBIRC_RFC_RPL_MOTD)
+ .Const(_SC("RPL_ENDOFMOTD"), LIBIRC_RFC_RPL_ENDOFMOTD)
+ .Const(_SC("RPL_YOUREOPER"), LIBIRC_RFC_RPL_YOUREOPER)
+ .Const(_SC("RPL_REHASHING"), LIBIRC_RFC_RPL_REHASHING)
+ .Const(_SC("RPL_YOURESERVICE"), LIBIRC_RFC_RPL_YOURESERVICE)
+ .Const(_SC("RPL_TIME"), LIBIRC_RFC_RPL_TIME)
+ .Const(_SC("RPL_USERSSTART"), LIBIRC_RFC_RPL_USERSSTART)
+ .Const(_SC("RPL_USERS"), LIBIRC_RFC_RPL_USERS)
+ .Const(_SC("RPL_ENDOFUSERS"), LIBIRC_RFC_RPL_ENDOFUSERS)
+ .Const(_SC("RPL_NOUSERS"), LIBIRC_RFC_RPL_NOUSERS)
+ .Const(_SC("RPL_TRACELINK"), LIBIRC_RFC_RPL_TRACELINK)
+ .Const(_SC("RPL_TRACECONNECTING"), LIBIRC_RFC_RPL_TRACECONNECTING)
+ .Const(_SC("RPL_TRACEHANDSHAKE"), LIBIRC_RFC_RPL_TRACEHANDSHAKE)
+ .Const(_SC("RPL_TRACEUNKNOWN"), LIBIRC_RFC_RPL_TRACEUNKNOWN)
+ .Const(_SC("RPL_TRACEOPERATOR"), LIBIRC_RFC_RPL_TRACEOPERATOR)
+ .Const(_SC("RPL_TRACEUSER"), LIBIRC_RFC_RPL_TRACEUSER)
+ .Const(_SC("RPL_TRACESERVER"), LIBIRC_RFC_RPL_TRACESERVER)
+ .Const(_SC("RPL_TRACESERVICE"), LIBIRC_RFC_RPL_TRACESERVICE)
+ .Const(_SC("RPL_TRACENEWTYPE"), LIBIRC_RFC_RPL_TRACENEWTYPE)
+ .Const(_SC("RPL_TRACECLASS"), LIBIRC_RFC_RPL_TRACECLASS)
+ .Const(_SC("RPL_TRACELOG"), LIBIRC_RFC_RPL_TRACELOG)
+ .Const(_SC("RPL_TRACEEND"), LIBIRC_RFC_RPL_TRACEEND)
+ .Const(_SC("RPL_STATSLINKINFO"), LIBIRC_RFC_RPL_STATSLINKINFO)
+ .Const(_SC("RPL_STATSCOMMANDS"), LIBIRC_RFC_RPL_STATSCOMMANDS)
+ .Const(_SC("RPL_ENDOFSTATS"), LIBIRC_RFC_RPL_ENDOFSTATS)
+ .Const(_SC("RPL_STATSUPTIME"), LIBIRC_RFC_RPL_STATSUPTIME)
+ .Const(_SC("RPL_STATSOLINE"), LIBIRC_RFC_RPL_STATSOLINE)
+ .Const(_SC("RPL_UMODEIS"), LIBIRC_RFC_RPL_UMODEIS)
+ .Const(_SC("RPL_SERVLIST"), LIBIRC_RFC_RPL_SERVLIST)
+ .Const(_SC("RPL_SERVLISTEND"), LIBIRC_RFC_RPL_SERVLISTEND)
+ .Const(_SC("RPL_LUSERCLIENT"), LIBIRC_RFC_RPL_LUSERCLIENT)
+ .Const(_SC("RPL_LUSEROP"), LIBIRC_RFC_RPL_LUSEROP)
+ .Const(_SC("RPL_LUSERUNKNOWN"), LIBIRC_RFC_RPL_LUSERUNKNOWN)
+ .Const(_SC("RPL_LUSERCHANNELS"), LIBIRC_RFC_RPL_LUSERCHANNELS)
+ .Const(_SC("RPL_LUSERME"), LIBIRC_RFC_RPL_LUSERME)
+ .Const(_SC("RPL_ADMINME"), LIBIRC_RFC_RPL_ADMINME)
+ .Const(_SC("RPL_ADMINLOC1"), LIBIRC_RFC_RPL_ADMINLOC1)
+ .Const(_SC("RPL_ADMINLOC2"), LIBIRC_RFC_RPL_ADMINLOC2)
+ .Const(_SC("RPL_ADMINEMAIL"), LIBIRC_RFC_RPL_ADMINEMAIL)
+ .Const(_SC("RPL_TRYAGAIN"), LIBIRC_RFC_RPL_TRYAGAIN)
+ .Const(_SC("ERR_NOSUCHNICK"), LIBIRC_RFC_ERR_NOSUCHNICK)
+ .Const(_SC("ERR_NOSUCHSERVER"), LIBIRC_RFC_ERR_NOSUCHSERVER)
+ .Const(_SC("ERR_NOSUCHCHANNEL"), LIBIRC_RFC_ERR_NOSUCHCHANNEL)
+ .Const(_SC("ERR_CANNOTSENDTOCHAN"), LIBIRC_RFC_ERR_CANNOTSENDTOCHAN)
+ .Const(_SC("ERR_TOOMANYCHANNELS"), LIBIRC_RFC_ERR_TOOMANYCHANNELS)
+ .Const(_SC("ERR_WASNOSUCHNICK"), LIBIRC_RFC_ERR_WASNOSUCHNICK)
+ .Const(_SC("ERR_TOOMANYTARGETS"), LIBIRC_RFC_ERR_TOOMANYTARGETS)
+ .Const(_SC("ERR_NOSUCHSERVICE"), LIBIRC_RFC_ERR_NOSUCHSERVICE)
+ .Const(_SC("ERR_NOORIGIN"), LIBIRC_RFC_ERR_NOORIGIN)
+ .Const(_SC("ERR_NORECIPIENT"), LIBIRC_RFC_ERR_NORECIPIENT)
+ .Const(_SC("ERR_NOTEXTTOSEND"), LIBIRC_RFC_ERR_NOTEXTTOSEND)
+ .Const(_SC("ERR_NOTOPLEVEL"), LIBIRC_RFC_ERR_NOTOPLEVEL)
+ .Const(_SC("ERR_WILDTOPLEVEL"), LIBIRC_RFC_ERR_WILDTOPLEVEL)
+ .Const(_SC("ERR_BADMASK"), LIBIRC_RFC_ERR_BADMASK)
+ .Const(_SC("ERR_UNKNOWNCOMMAND"), LIBIRC_RFC_ERR_UNKNOWNCOMMAND)
+ .Const(_SC("ERR_NOMOTD"), LIBIRC_RFC_ERR_NOMOTD)
+ .Const(_SC("ERR_NOADMININFO"), LIBIRC_RFC_ERR_NOADMININFO)
+ .Const(_SC("ERR_FILEERROR"), LIBIRC_RFC_ERR_FILEERROR)
+ .Const(_SC("ERR_NONICKNAMEGIVEN"), LIBIRC_RFC_ERR_NONICKNAMEGIVEN)
+ .Const(_SC("ERR_ERRONEUSNICKNAME"), LIBIRC_RFC_ERR_ERRONEUSNICKNAME)
+ .Const(_SC("ERR_NICKNAMEINUSE"), LIBIRC_RFC_ERR_NICKNAMEINUSE)
+ .Const(_SC("ERR_NICKCOLLISION"), LIBIRC_RFC_ERR_NICKCOLLISION)
+ .Const(_SC("ERR_UNAVAILRESOURCE"), LIBIRC_RFC_ERR_UNAVAILRESOURCE)
+ .Const(_SC("ERR_USERNOTINCHANNEL"), LIBIRC_RFC_ERR_USERNOTINCHANNEL)
+ .Const(_SC("ERR_NOTONCHANNEL"), LIBIRC_RFC_ERR_NOTONCHANNEL)
+ .Const(_SC("ERR_USERONCHANNEL"), LIBIRC_RFC_ERR_USERONCHANNEL)
+ .Const(_SC("ERR_NOLOGIN"), LIBIRC_RFC_ERR_NOLOGIN)
+ .Const(_SC("ERR_SUMMONDISABLED"), LIBIRC_RFC_ERR_SUMMONDISABLED)
+ .Const(_SC("ERR_USERSDISABLED"), LIBIRC_RFC_ERR_USERSDISABLED)
+ .Const(_SC("ERR_NOTREGISTERED"), LIBIRC_RFC_ERR_NOTREGISTERED)
+ .Const(_SC("ERR_NEEDMOREPARAMS"), LIBIRC_RFC_ERR_NEEDMOREPARAMS)
+ .Const(_SC("ERR_ALREADYREGISTRED"), LIBIRC_RFC_ERR_ALREADYREGISTRED)
+ .Const(_SC("ERR_NOPERMFORHOST"), LIBIRC_RFC_ERR_NOPERMFORHOST)
+ .Const(_SC("ERR_PASSWDMISMATCH"), LIBIRC_RFC_ERR_PASSWDMISMATCH)
+ .Const(_SC("ERR_YOUREBANNEDCREEP"), LIBIRC_RFC_ERR_YOUREBANNEDCREEP)
+ .Const(_SC("ERR_YOUWILLBEBANNED"), LIBIRC_RFC_ERR_YOUWILLBEBANNED)
+ .Const(_SC("ERR_KEYSET"), LIBIRC_RFC_ERR_KEYSET)
+ .Const(_SC("ERR_CHANNELISFULL"), LIBIRC_RFC_ERR_CHANNELISFULL)
+ .Const(_SC("ERR_UNKNOWNMODE"), LIBIRC_RFC_ERR_UNKNOWNMODE)
+ .Const(_SC("ERR_INVITEONLYCHAN"), LIBIRC_RFC_ERR_INVITEONLYCHAN)
+ .Const(_SC("ERR_BANNEDFROMCHAN"), LIBIRC_RFC_ERR_BANNEDFROMCHAN)
+ .Const(_SC("ERR_BADCHANNELKEY"), LIBIRC_RFC_ERR_BADCHANNELKEY)
+ .Const(_SC("ERR_BADCHANMASK"), LIBIRC_RFC_ERR_BADCHANMASK)
+ .Const(_SC("ERR_NOCHANMODES"), LIBIRC_RFC_ERR_NOCHANMODES)
+ .Const(_SC("ERR_BANLISTFULL"), LIBIRC_RFC_ERR_BANLISTFULL)
+ .Const(_SC("ERR_NOPRIVILEGES"), LIBIRC_RFC_ERR_NOPRIVILEGES)
+ .Const(_SC("ERR_CHANOPRIVSNEEDED"), LIBIRC_RFC_ERR_CHANOPRIVSNEEDED)
+ .Const(_SC("ERR_CANTKILLSERVER"), LIBIRC_RFC_ERR_CANTKILLSERVER)
+ .Const(_SC("ERR_RESTRICTED"), LIBIRC_RFC_ERR_RESTRICTED)
+ .Const(_SC("ERR_UNIQOPPRIVSNEEDED"), LIBIRC_RFC_ERR_UNIQOPPRIVSNEEDED)
+ .Const(_SC("ERR_NOOPERHOST"), LIBIRC_RFC_ERR_NOOPERHOST)
+ .Const(_SC("ERR_UMODEUNKNOWNFLAG"), LIBIRC_RFC_ERR_UMODEUNKNOWNFLAG)
+ .Const(_SC("ERR_USERSDONTMATCH"), LIBIRC_RFC_ERR_USERSDONTMATCH)
+ );
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputMessageImpl(const char * msg, va_list args)
+{
+#if defined(WIN32) || defined(_WIN32)
+ HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ CONSOLE_SCREEN_BUFFER_INFO csb_before;
+ GetConsoleScreenBufferInfo( hstdout, &csb_before);
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN);
+ printf("[SQMOD] ");
+
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
+ vprintf(msg, args);
+ puts("");
+
+ SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
+#else
+ printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27, msg);
+ vprintf(msg, args);
+ puts("");
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputErrorImpl(const char * msg, va_list args)
+{
+#if defined(WIN32) || defined(_WIN32)
+ HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ CONSOLE_SCREEN_BUFFER_INFO csb_before;
+ GetConsoleScreenBufferInfo( hstdout, &csb_before);
+ SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
+ printf("[SQMOD] ");
+
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
+ vprintf(msg, args);
+ puts("");
+
+ SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
+#else
+ printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27, msg);
+ vprintf(msg, args);
+ puts("");
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputDebug(const char * msg, ...)
+{
+#ifdef _DEBUG
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputMessageImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+#else
+ SQMOD_UNUSED_VAR(msg);
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputMessage(const char * msg, ...)
+{
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputMessageImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputError(const char * msg, ...)
+{
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputErrorImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+}
+
+} // Namespace:: SqMod
+
+// --------------------------------------------------------------------------------------------
+SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallbacks* callbacks, PluginInfo* info)
+{
+ using namespace SqMod;
+ // Output plugin header
+ puts("");
+ OutputMessage("--------------------------------------------------------------------");
+ OutputMessage("Plugin: %s", SQIRC_NAME);
+ OutputMessage("Author: %s", SQIRC_AUTHOR);
+ OutputMessage("Legal: %s", SQIRC_COPYRIGHT);
+ OutputMessage("--------------------------------------------------------------------");
+ puts("");
+ // Attempt to find the host plugin ID
+ int host_plugin_id = functions->FindPlugin((char *)(SQMOD_HOST_NAME));
+ // See if our plugin was loaded after the host plugin
+ if (host_plugin_id < 0)
+ {
+ OutputError("%s could find the host plugin", SQIRC_NAME);
+ // Don't load!
+ return SQMOD_FAILURE;
+ }
+ // Should never reach this point but just in case
+ else if (host_plugin_id > (info->nPluginId))
+ {
+ OutputError("%s loaded after the host plugin", SQIRC_NAME);
+ // Don't load!
+ return SQMOD_FAILURE;
+ }
+#if defined(_WIN32)
+ WSADATA wsa_data;
+ // Initialize the sockets on windows
+ if (WSAStartup(MAKEWORD(2, 2), &wsa_data) != 0)
+ {
+ OutputError("Unable to start because the windows sockets could not be initialized");
+ return SQMOD_FAILURE;
+ }
+#endif // _WIN32
+ // Store server proxies
+ _Func = functions;
+ _Clbk = callbacks;
+ _Info = info;
+ // Assign plugin information
+ _Info->uPluginVer = SQIRC_VERSION;
+ strcpy(_Info->szName, SQIRC_HOST_NAME);
+ // Bind callbacks
+ BindCallbacks();
+ // Notify that the plugin was successfully loaded
+ OutputMessage("Successfully loaded %s", SQIRC_NAME);
+ // Dummy spacing
+ puts("");
+ // Done!
+ return SQMOD_SUCCESS;
+}
diff --git a/modules/irc/Module.hpp b/modules/irc/Module.hpp
new file mode 100644
index 00000000..23edcd09
--- /dev/null
+++ b/modules/irc/Module.hpp
@@ -0,0 +1,41 @@
+#ifndef _SQIRC_MODULE_HPP_
+#define _SQIRC_MODULE_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "SqMod.h"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * Proxies to comunicate with the server.
+*/
+extern PluginFuncs* _Func;
+extern PluginCallbacks* _Clbk;
+extern PluginInfo* _Info;
+
+/* ------------------------------------------------------------------------------------------------
+ * Proxies to comunicate with the Squirrel plugin.
+*/
+extern HSQAPI _SqAPI;
+extern HSQEXPORTS _SqMod;
+extern HSQUIRRELVM _SqVM;
+
+/* ------------------------------------------------------------------------------------------------
+ * Output a message only if the _DEBUG was defined.
+*/
+void OutputDebug(const char * msg, ...);
+
+/* ------------------------------------------------------------------------------------------------
+ * Output a formatted user message to the console.
+*/
+void OutputMessage(const char * msg, ...);
+
+/* ------------------------------------------------------------------------------------------------
+ * Output a formatted error message to the console.
+*/
+void OutputError(const char * msg, ...);
+
+} // Namespace:: SqMod
+
+#endif // _SQIRC_MODULE_HPP_
diff --git a/source/Library/IRC.cpp b/modules/irc/Session.cpp
similarity index 58%
rename from source/Library/IRC.cpp
rename to modules/irc/Session.cpp
index a987bfe0..480c10e9 100644
--- a/source/Library/IRC.cpp
+++ b/modules/irc/Session.cpp
@@ -1,18 +1,16 @@
// ------------------------------------------------------------------------------------------------
-#include "Library/IRC.hpp"
+#include "Session.hpp"
+#include "Module.hpp"
// ------------------------------------------------------------------------------------------------
-#include
+#include
+#include
// ------------------------------------------------------------------------------------------------
#include
// ------------------------------------------------------------------------------------------------
namespace SqMod {
-namespace IRC {
-
-// ------------------------------------------------------------------------------------------------
-static SQChar g_Buffer[512];
// ------------------------------------------------------------------------------------------------
irc_callbacks_t Session::s_Callbacks;
@@ -99,12 +97,12 @@ void Session::Update()
else if (!irc_is_connected(m_Session))
{
// Do we meet the condition to attempt to reconnect?
- if (m_Reconnect && (m_LeftTries != 0) && (m_NextTry <= GetEpochTimeMicro()))
+ if (m_Reconnect && (m_LeftTries != 0) && (m_NextTry <= _SqMod->GetEpochTimeMicro()))
{
// Take out one try
--m_LeftTries;
// Update the time-point for the next try
- m_NextTry = (GetEpochTimeMicro() + (m_Wait * 1000LL));
+ m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
// Attempt to reconnect
if (m_IPv6)
{
@@ -143,13 +141,13 @@ void Session::Update()
// Call select()
if (select(maxfd + 1, &in_set, &out_set, 0, &tv) < 0)
{
- LogErr("Unable to select() on IRC session");
+ _SqMod->LogErr("Unable to select() on IRC session");
}
// Call irc_process_select_descriptors() for the session
if (irc_process_select_descriptors (m_Session, &in_set, &out_set))
{
// @TODO: The connection failed, or the server disconnected. Handle it!
- LogWrn("The IRC connection failed, or the server disconnected.");
+ _SqMod->LogWrn("The IRC connection failed, or the server disconnected.");
}
}
@@ -200,6 +198,47 @@ void Session::Destroy()
Release();
}
+// ------------------------------------------------------------------------------------------------
+bool Session::Validate() const
+{
+ if (m_Session)
+ return true;
+ // Invalid session instance
+ _SqMod->SqThrow("Invalid IRC session (%s)", m_Tag.c_str());
+ return false;
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Session::ConnectedThrow() const
+{
+ if (!m_Session)
+ _SqMod->SqThrow("Invalid IRC session (%s)", m_Tag.c_str());
+ else if (!irc_is_connected(m_Session))
+ _SqMod->SqThrow("Session is not connected (%s)", m_Tag.c_str());
+ else
+ return true;
+ return false;
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Session::NotConnected() const
+{
+ if (!m_Session || !irc_is_connected(m_Session) || !m_Reconnect)
+ return true;
+ _SqMod->SqThrow("Already connected or trying connect to IRC server (%s)", m_Tag.c_str());
+ return !m_Session;
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Session::ValidateEventSession(Session * ptr)
+{
+ if (ptr)
+ return true;
+ // Invalid session instance
+ _SqMod->LogErr("Cannot forward IRC event without a session container");
+ return false;
+}
+
// ------------------------------------------------------------------------------------------------
Session::Session()
: m_Session(irc_create_session(GetCallbacks()))
@@ -221,7 +260,7 @@ Session::Session()
{
if (!m_Session)
{
- SqThrow("Unable to create an IRC session");
+ _SqMod->SqThrow("Unable to create an IRC session");
// Explicitly make sure no further calls can be made to this session
m_Session = NULL;
}
@@ -261,6 +300,87 @@ Session::~Session()
s_Session = NULL;
}
+// ------------------------------------------------------------------------------------------------
+void Session::SetNick(CSStr nick)
+{
+ if (!nick || strlen(nick) <= 0)
+ _SqMod->SqThrow("Invalid IRC nickname");
+ else if (Connected())
+ irc_cmd_nick(m_Session, nick);
+ else if (Validate())
+ m_Nick.assign(nick);
+}
+
+// ------------------------------------------------------------------------------------------------
+void Session::SetPort(Uint32 num)
+{
+ if (num > 0xFFFF)
+ _SqMod->SqThrow("Port number is out of range: %u > %u", num, 0xFFFF);
+ else if (Validate() && NotConnected())
+ m_Port = num;
+}
+
+// ------------------------------------------------------------------------------------------------
+Int32 Session::CmdNick(CSStr nick)
+{
+ if (!nick || strlen(nick) <= 0)
+ _SqMod->SqThrow("Invalid IRC nickname");
+ else if (ConnectedThrow())
+ return irc_cmd_nick(m_Session, nick);
+ return -1;
+}
+
+// ------------------------------------------------------------------------------------------------
+Object Session::GetNextTry() const
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Attempt to push a time-stamp instance on the stack
+ _SqMod->PushTimestamp(_SqVM, m_NextTry);
+ // Obtain the object from the stack
+ Var< Object > inst(_SqVM, -1);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the timestamp instance
+ return inst.value;
+}
+
+// ------------------------------------------------------------------------------------------------
+void Session::SetNextTry(Object & tm)
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object >::push(_SqVM, tm);
+ // The resulted times-tamp value
+ Int64 microseconds = 0;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetTimestamp(_SqVM, -1, µseconds)))
+ _SqMod->SqThrow("Invalid time-stamp specified");
+ else
+ m_NextTry = microseconds;
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+}
+
+// ------------------------------------------------------------------------------------------------
+Object Session::GetSessionTime() const
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Attempt to push a time-stamp instance on the stack
+ if (m_SessionTime)
+ _SqMod->PushTimestamp(_SqVM, _SqMod->GetEpochTimeMicro() - m_SessionTime);
+ else
+ _SqMod->PushTimestamp(_SqVM, 0);
+ // Obtain the object from the stack
+ Var< Object > inst(_SqVM, -1);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the timestamp instance
+ return inst.value;
+}
+
// ------------------------------------------------------------------------------------------------
Int32 Session::Connect()
{
@@ -269,13 +389,13 @@ Int32 Session::Connect()
return -1; /* No point in going forward */
// Did we already try to connect?
else if (m_Reconnect)
- SqThrow("Attempting to connect IRC while connection was already issued");
+ _SqMod->SqThrow("Attempting to connect IRC while connection was already issued");
// Validate the specified server
else if (!m_Server.empty())
- SqThrow("Attempting to connect IRC without specifying a server");
+ _SqMod->SqThrow("Attempting to connect IRC without specifying a server");
// Validate the specified nickname
else if (!m_Nick.empty())
- SqThrow("Attempting to connect IRC without specifying a nickname");
+ _SqMod->SqThrow("Attempting to connect IRC without specifying a nickname");
else
{
// Enable the reconnection system
@@ -283,7 +403,7 @@ Int32 Session::Connect()
// Reset the number of tries
m_LeftTries = m_Tries;
// Set the time-point for the next try
- m_NextTry = (GetEpochTimeMicro() + (m_Wait * 1000LL));
+ m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
// This is not an IPv6 connection
m_IPv6 = false;
// Attempt to connect the session and return the result
@@ -306,16 +426,16 @@ Int32 Session::Connect(CSStr server, Uint32 port, CSStr nick, CSStr passwd, CSSt
return -1; /* No point in going forward */
// Did we already try to connect?
else if (m_Reconnect)
- SqThrow("Attempting to connect IRC while connection was already issued");
+ _SqMod->SqThrow("Attempting to connect IRC while connection was already issued");
// Validate the specified port
- else if (port > NumLimit< Uint16 >::Max)
- SqThrow("Port number is out of range: %u > %u", port, NumLimit< Uint16 >::Max);
+ else if (port > 0xFFFF)
+ _SqMod->SqThrow("Port number is out of range: %u > %u", port, 0xFFFF);
// Validate the specified server
else if (!server || strlen(server) <= 0)
- SqThrow("Attempting to connect IRC without specifying a server");
+ _SqMod->SqThrow("Attempting to connect IRC without specifying a server");
// Validate the specified nickname
else if (!nick || strlen(nick) <= 0)
- SqThrow("Attempting to connect IRC without specifying a nickname");
+ _SqMod->SqThrow("Attempting to connect IRC without specifying a nickname");
else
{
// Save the specified port
@@ -335,7 +455,7 @@ Int32 Session::Connect(CSStr server, Uint32 port, CSStr nick, CSStr passwd, CSSt
// Reset the number of tries
m_LeftTries = m_Tries;
// Set the time-point for the next connection try
- m_NextTry = (GetEpochTimeMicro() + (m_Wait * 1000LL));
+ m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
// This is not an IPv6 connection
m_IPv6 = false;
// Attempt to connect the session and return the result
@@ -358,13 +478,13 @@ Int32 Session::Connect6()
return -1; /* No point in going forward */
// Did we already try to connect?
else if (m_Reconnect)
- SqThrow("Attempting to connect IRC while connection was already issued");
+ _SqMod->SqThrow("Attempting to connect IRC while connection was already issued");
// Validate the specified server
else if (!m_Server.empty())
- SqThrow("Attempting to connect IRC without specifying a server");
+ _SqMod->SqThrow("Attempting to connect IRC without specifying a server");
// Validate the specified nickname
else if (!m_Nick.empty())
- SqThrow("Attempting to connect IRC without specifying a nickname");
+ _SqMod->SqThrow("Attempting to connect IRC without specifying a nickname");
else
{
// Enable the reconnection system
@@ -372,7 +492,7 @@ Int32 Session::Connect6()
// Reset the number of tries
m_LeftTries = m_Tries;
// Set the time-point for the next try
- m_NextTry = (GetEpochTimeMicro() + (m_Wait * 1000LL));
+ m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
// This is an IPv6 connection
m_IPv6 = true;
// Attempt to connect the session and return the result
@@ -395,16 +515,16 @@ Int32 Session::Connect6(CSStr server, Uint32 port, CSStr nick, CSStr passwd, CSS
return -1; /* No point in going forward */
// Did we already try to connect?
else if (m_Reconnect)
- SqThrow("Attempting to connect IRC while connection was already issued");
+ _SqMod->SqThrow("Attempting to connect IRC while connection was already issued");
// Validate the specified port
- else if (port > NumLimit< Uint16 >::Max)
- SqThrow("Port number is out of range: %u > %u", port, NumLimit< Uint16 >::Max);
+ else if (port > 0xFFFF)
+ _SqMod->SqThrow("Port number is out of range: %u > %u", port, 0xFFFF);
// Validate the specified server
else if (!server || strlen(server) <= 0)
- SqThrow("Attempting to connect IRC without specifying a server");
+ _SqMod->SqThrow("Attempting to connect IRC without specifying a server");
// Validate the specified nickname
else if (!nick || strlen(nick) <= 0)
- SqThrow("Attempting to connect IRC without specifying a nickname");
+ _SqMod->SqThrow("Attempting to connect IRC without specifying a nickname");
else
{
// Save the specified port
@@ -424,7 +544,7 @@ Int32 Session::Connect6(CSStr server, Uint32 port, CSStr nick, CSStr passwd, CSS
// Reset the number of tries
m_LeftTries = m_Tries;
// Set the time-point for the next connection try
- m_NextTry = (GetEpochTimeMicro() + (m_Wait * 1000LL));
+ m_NextTry = (_SqMod->GetEpochTimeMicro() + (m_Wait * 1000LL));
// This is an IPv6 connection
m_IPv6 = true;
// Attempt to connect the session and return the result
@@ -525,7 +645,7 @@ void Session::ForwardEvent(Session * /*session*/, Function & /*listener*/, CCStr
}
// ------------------------------------------------------------------------------------------------
-void Session::ForwardEvent(Session * session, Function & /*listener*/, CCStr /*nick*/,
+void Session::ForwardEvent(Session * /*session*/, Function & /*listener*/, CCStr /*nick*/,
CCStr /*addr*/, CCStr /*filename*/, Ulong /*size*/, irc_dcc_t /*dccid*/)
{
/* TODO! */
@@ -540,7 +660,7 @@ void Session::OnConnect(irc_session_t * session, CCStr event, CCStr origin, CCSt
// Prevent any attempts to reconnect now
inst->m_Reconnect = false;
// Save the connection time-stamp to calculate session uptime
- inst->m_SessionTime = GetEpochTimeMicro();
+ inst->m_SessionTime = _SqMod->GetEpochTimeMicro();
// Now forward event
ForwardEvent(inst, inst->m_OnConnect, event, origin, params, count);
}
@@ -733,6 +853,12 @@ SQInteger Session::CmdMsgF(HSQUIRRELVM vm)
// Do we have a valid session instance?
if (!inst.value)
return sq_throwerror(vm, "Invalid session instance");
+ // Do we have a valid session?
+ else if (!inst.value->m_Session)
+ return sq_throwerror(vm, "Invalid IRC session");
+ // Is the session connected?
+ else if (!inst.value->Connected())
+ return sq_throwerror(vm, "Session is not connected");
// Is the specified message value a string or something convertible to string?
else if (top == 3 && ((sq_gettype(vm, -1) == OT_STRING) || !SQ_FAILED(sq_tostring(vm, -1))))
{
@@ -741,17 +867,14 @@ SQInteger Session::CmdMsgF(HSQUIRRELVM vm)
if (SQ_FAILED(sq_getstring(vm, -1, &msg)))
{
// If the value was converted to a string then pop the string
- sq_settop(vm, top);
+ sq_pop(vm, sq_gettop(vm) - top);
// Now we can throw the error message
return sq_throwerror(vm, "Unable to retrieve the message");
}
// Forward the resulted string value
- else if (msg)
- {
- code = inst.value->CmdMsg(target.value.c_str(), msg);
- }
+ code = irc_cmd_msg(inst.value->m_Session, target.value.c_str(), msg);
// If the value was converted to a string then pop the string
- sq_settop(vm, top);
+ sq_pop(vm, sq_gettop(vm) - top);
}
// Do we have enough values to call the format function?
else if (top > 3)
@@ -765,9 +888,7 @@ SQInteger Session::CmdMsgF(HSQUIRRELVM vm)
return ret;
// Forward the resulted string value
else if (msg)
- {
- code = inst.value->CmdMsg(target.value.c_str(), msg);
- }
+ code = irc_cmd_msg(inst.value->m_Session, target.value.c_str(), msg);
}
// All methods of retrieving the message value failed
else
@@ -800,6 +921,12 @@ SQInteger Session::CmdMeF(HSQUIRRELVM vm)
// Do we have a valid session instance?
if (!inst.value)
return sq_throwerror(vm, "Invalid session instance");
+ // Do we have a valid session?
+ else if (!inst.value->m_Session)
+ return sq_throwerror(vm, "Invalid IRC session");
+ // Is the session connected?
+ else if (!inst.value->Connected())
+ return sq_throwerror(vm, "Session is not connected");
// Is the specified message value a string or something convertible to string?
else if (top == 3 && ((sq_gettype(vm, -1) == OT_STRING) || !SQ_FAILED(sq_tostring(vm, -1))))
{
@@ -808,17 +935,14 @@ SQInteger Session::CmdMeF(HSQUIRRELVM vm)
if (SQ_FAILED(sq_getstring(vm, -1, &msg)))
{
// If the value was converted to a string then pop the string
- sq_settop(vm, top);
+ sq_pop(vm, sq_gettop(vm) - top);
// Now we can throw the error message
return sq_throwerror(vm, "Unable to retrieve the message");
}
// Forward the resulted string value
- else if (msg)
- {
- code = inst.value->CmdMe(target.value.c_str(), msg);
- }
+ code = irc_cmd_me(inst.value->m_Session, target.value.c_str(), msg);
// If the value was converted to a string then pop the string
- sq_settop(vm, top);
+ sq_pop(vm, sq_gettop(vm) - top);
}
// Do we have enough values to call the format function?
else if (top > 3)
@@ -832,9 +956,7 @@ SQInteger Session::CmdMeF(HSQUIRRELVM vm)
return ret;
// Forward the resulted string value
else if (msg)
- {
- code = inst.value->CmdMe(target.value.c_str(), msg);
- }
+ code = irc_cmd_me(inst.value->m_Session, target.value.c_str(), msg);
}
// All methods of retrieving the message value failed
else
@@ -867,6 +989,12 @@ SQInteger Session::CmdNoticeF(HSQUIRRELVM vm)
// Do we have a valid session instance?
if (!inst.value)
return sq_throwerror(vm, "Invalid session instance");
+ // Do we have a valid session?
+ else if (!inst.value->m_Session)
+ return sq_throwerror(vm, "Invalid IRC session");
+ // Is the session connected?
+ else if (!inst.value->Connected())
+ return sq_throwerror(vm, "Session is not connected");
// Is the specified message value a string or something convertible to string?
else if (top == 3 && ((sq_gettype(vm, -1) == OT_STRING) || !SQ_FAILED(sq_tostring(vm, -1))))
{
@@ -875,17 +1003,14 @@ SQInteger Session::CmdNoticeF(HSQUIRRELVM vm)
if (SQ_FAILED(sq_getstring(vm, -1, &msg)))
{
// If the value was converted to a string then pop the string
- sq_settop(vm, top);
+ sq_pop(vm, sq_gettop(vm) - top);
// Now we can throw the error message
return sq_throwerror(vm, "Unable to retrieve the message");
}
// Forward the resulted string value
- else if (msg)
- {
- code = inst.value->CmdNotice(target.value.c_str(), msg);
- }
+ code = irc_cmd_notice(inst.value->m_Session, target.value.c_str(), msg);
// If the value was converted to a string then pop the string
- sq_settop(vm, top);
+ sq_pop(vm, sq_gettop(vm) - top);
}
// Do we have enough values to call the format function?
else if (top > 3)
@@ -899,9 +1024,7 @@ SQInteger Session::CmdNoticeF(HSQUIRRELVM vm)
return ret;
// Forward the resulted string value
else if (msg)
- {
- code = inst.value->CmdNotice(target.value.c_str(), msg);
- }
+ code = irc_cmd_notice(inst.value->m_Session, target.value.c_str(), msg);
}
// All methods of retrieving the message value failed
else
@@ -912,342 +1035,4 @@ SQInteger Session::CmdNoticeF(HSQUIRRELVM vm)
return 1;
}
-// ------------------------------------------------------------------------------------------------
-CSStr GetNick(CSStr origin)
-{
- // Attempt to retrieve the nickname
- irc_target_get_nick(origin, g_Buffer, sizeof(g_Buffer));
- // Return the nickname that could be retrieved
- return g_Buffer;
-}
-
-// ------------------------------------------------------------------------------------------------
-CSStr GetHost(CSStr target)
-{
- // Attempt to retrieve the host
- irc_target_get_host(target, g_Buffer, sizeof(g_Buffer));
- // Return the host that could be retrieved
- return g_Buffer;
-}
-
-} // Namespace:: IRC
-
-/* ------------------------------------------------------------------------------------------------
- * Update IRC sessions and process events.
-*/
-void ProcessIrc()
-{
- IRC::Session::Process();
-}
-
-/* ------------------------------------------------------------------------------------------------
- * Terminate IRC sessions and release their resources.
-*/
-void TerminateIrc()
-{
- IRC::Session::Terminate();
-}
-
-// ================================================================================================
-void Register_IRC(HSQUIRRELVM vm)
-{
- using namespace IRC;
-
- Table ircns(vm);
-
- ircns.Bind(_SC("Session"), Class< Session, NoCopy< Session > >(vm, _SC("SqIrcSession"))
- /* Constructors */
- .Ctor()
- /* Core Metamethods */
- .Func(_SC("_tostring"), &Session::ToString)
- .Func(_SC("_cmp"), &Session::Cmp)
- /* Properties */
- .Prop(_SC("Valid"), &Session::IsValid)
- .Prop(_SC("Connected"), &Session::IsConnected)
- .Prop(_SC("Tag"), &Session::GetTag, &Session::SetTag)
- .Prop(_SC("Data"), &Session::GetData, &Session::SetData)
- .Prop(_SC("Server"), &Session::GetServer, &Session::SetServer)
- .Prop(_SC("Password"), &Session::GetPassword, &Session::SetPassword)
- .Prop(_SC("Nick"), &Session::GetNick, &Session::SetNick)
- .Prop(_SC("User"), &Session::GetUser, &Session::SetUser)
- .Prop(_SC("Name"), &Session::GetName, &Session::SetName)
- .Prop(_SC("Port"), &Session::GetPort, &Session::SetPort)
- .Prop(_SC("PoolTime"), &Session::GetPoolTime, &Session::SetPoolTime)
- .Prop(_SC("LastCode"), &Session::GetLastCode)
- .Prop(_SC("Tries"), &Session::GetTries, &Session::SetTries)
- .Prop(_SC("Wait"), &Session::GetWait, &Session::SetWait)
- .Prop(_SC("LeftTries"), &Session::GetLeftTries, &Session::SetLeftTries)
- .Prop(_SC("NextTry"), &Session::GetNextTry, &Session::SetNextTry)
- .Prop(_SC("SessionTime"), &Session::GetSessionTime)
- .Prop(_SC("Reconnecting"), &Session::GetReconnect)
- .Prop(_SC("IPv6"), &Session::GetIPv6)
- .Prop(_SC("Server"), &Session::GetServer, &Session::SetServer)
- .Prop(_SC("CtcpVersion"), (void (Session::*)(void))(NULL), &Session::SetCtcpVersion)
- .Prop(_SC("ErrNo"), &Session::GetErrNo)
- .Prop(_SC("ErrStr"), &Session::GetErrStr)
- .Prop(_SC("OnConnect"), &Session::GetOnConnect)
- .Prop(_SC("OnNick"), &Session::GetOnNick)
- .Prop(_SC("OnQuit"), &Session::GetOnQuit)
- .Prop(_SC("OnJoin"), &Session::GetOnJoin)
- .Prop(_SC("OnPart"), &Session::GetOnPart)
- .Prop(_SC("OnMode"), &Session::GetOnMode)
- .Prop(_SC("OnUmode"), &Session::GetOnUmode)
- .Prop(_SC("OnTopic"), &Session::GetOnTopic)
- .Prop(_SC("OnKick"), &Session::GetOnKick)
- .Prop(_SC("OnChannel"), &Session::GetOnChannel)
- .Prop(_SC("OnPrivMsg"), &Session::GetOnPrivMsg)
- .Prop(_SC("OnNotice"), &Session::GetOnNotice)
- .Prop(_SC("OnChannelNotice"), &Session::GetOnChannelNotice)
- .Prop(_SC("OnInvite"), &Session::GetOnInvite)
- .Prop(_SC("OnCtcpReq"), &Session::GetOnCtcpReq)
- .Prop(_SC("OnCtcpRep"), &Session::GetOnCtcpRep)
- .Prop(_SC("OnCtcpAction"), &Session::GetOnCtcpAction)
- .Prop(_SC("OnUnknown"), &Session::GetOnUnknown)
- .Prop(_SC("OnNumeric"), &Session::GetOnNumeric)
- .Prop(_SC("OnDccChatReq"), &Session::GetOnDccChatReq)
- .Prop(_SC("OnDccSendReq"), &Session::GetOnDccSendReq)
- /* Functions */
- .Overload< Int32 (Session::*)(void) >(_SC("Connect"), &Session::Connect)
- .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr) >(_SC("Connect"), &Session::Connect)
- .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr) >(_SC("Connect"), &Session::Connect)
- .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr, CSStr) >(_SC("Connect"), &Session::Connect)
- .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr, CSStr, CSStr) >(_SC("Connect"), &Session::Connect)
- .Overload< Int32 (Session::*)(void) >(_SC("Connect6"), &Session::Connect6)
- .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr) >(_SC("Connect6"), &Session::Connect6)
- .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr) >(_SC("Connect6"), &Session::Connect6)
- .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr, CSStr) >(_SC("Connect6"), &Session::Connect6)
- .Overload< Int32 (Session::*)(CSStr, Uint32, CSStr, CSStr, CSStr, CSStr) >(_SC("Connect6"), &Session::Connect6)
- .Func(_SC("Disconnect"), &Session::Disconnect)
- .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdJoin"), &Session::CmdJoin)
- .Overload< Int32 (Session::*)(CSStr, CSStr) >(_SC("CmdJoin"), &Session::CmdJoin)
- .Func(_SC("CmdPart"), &Session::CmdPart)
- .Func(_SC("CmdInvite"), &Session::CmdInvite)
- .Func(_SC("CmdNames"), &Session::CmdNames)
- .Overload< Int32 (Session::*)(void) >(_SC("CmdList"), &Session::CmdList)
- .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdList"), &Session::CmdList)
- .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdTopic"), &Session::CmdTopic)
- .Overload< Int32 (Session::*)(CSStr, CSStr) >(_SC("CmdTopic"), &Session::CmdTopic)
- .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdChannelMode"), &Session::CmdChannelMode)
- .Overload< Int32 (Session::*)(CSStr, CSStr) >(_SC("CmdChannelMode"), &Session::CmdChannelMode)
- .Overload< Int32 (Session::*)(void) >(_SC("CmdUserMode"), &Session::CmdUserMode)
- .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdUserMode"), &Session::CmdUserMode)
- .Overload< Int32 (Session::*)(CSStr, CSStr) >(_SC("CmdKick"), &Session::CmdKick)
- .Overload< Int32 (Session::*)(CSStr, CSStr, CSStr) >(_SC("CmdKick"), &Session::CmdKick)
- .Func(_SC("CmdMsg"), &Session::CmdMsg)
- .Func(_SC("CmdMe"), &Session::CmdMe)
- .Func(_SC("CmdNotice"), &Session::CmdNotice)
- .Func(_SC("CmdCtcpRequest"), &Session::CmdCtcpRequest)
- .Func(_SC("CmdCtcpReply"), &Session::CmdCtcpReply)
- .Func(_SC("CmdNick"), &Session::CmdNick)
- .Func(_SC("CmdWhois"), &Session::CmdWhois)
- .Overload< Int32 (Session::*)(void) >(_SC("CmdQuit"), &Session::CmdQuit)
- .Overload< Int32 (Session::*)(CSStr) >(_SC("CmdQuit"), &Session::CmdQuit)
- .Func(_SC("SendRaw"), &Session::SendRaw)
- .Func(_SC("DestroyDcc"), &Session::DestroyDcc)
- .Func(_SC("SetCtcpVersion"), &Session::SetCtcpVersion)
- .Func(_SC("SetOption"), &Session::SetOption)
- .Func(_SC("ResetOption"), &Session::ResetOption)
- .Func(_SC("BindConnect"), &Session::BindOnConnect)
- .Func(_SC("BindNick"), &Session::BindOnNick)
- .Func(_SC("BindQuit"), &Session::BindOnQuit)
- .Func(_SC("BindJoin"), &Session::BindOnJoin)
- .Func(_SC("BindPart"), &Session::BindOnPart)
- .Func(_SC("BindMode"), &Session::BindOnMode)
- .Func(_SC("BindUmode"), &Session::BindOnUmode)
- .Func(_SC("BindTopic"), &Session::BindOnTopic)
- .Func(_SC("BindKick"), &Session::BindOnKick)
- .Func(_SC("BindChannel"), &Session::BindOnChannel)
- .Func(_SC("BindPrivMsg"), &Session::BindOnPrivMsg)
- .Func(_SC("BindNotice"), &Session::BindOnNotice)
- .Func(_SC("BindChannelNotice"), &Session::BindOnChannelNotice)
- .Func(_SC("BindInvite"), &Session::BindOnInvite)
- .Func(_SC("BindCtcpReq"), &Session::BindOnCtcpReq)
- .Func(_SC("BindCtcpRep"), &Session::BindOnCtcpRep)
- .Func(_SC("BindCtcpAction"), &Session::BindOnCtcpAction)
- .Func(_SC("BindUnknown"), &Session::BindOnUnknown)
- .Func(_SC("BindNumeric"), &Session::BindOnNumeric)
- .Func(_SC("BindDccChatReq"), &Session::BindOnDccChatReq)
- .Func(_SC("BindDccSendReq"), &Session::BindOnDccSendReq)
- .SquirrelFunc(_SC("CmdMsgF"), &Session::CmdMsgF)
- .SquirrelFunc(_SC("CmdMeF"), &Session::CmdMeF)
- .SquirrelFunc(_SC("CmdNoticeF"), &Session::CmdNoticeF)
- );
-
- ircns.Func(_SC("GetNick"), &GetNick);
- ircns.Func(_SC("GetHost"), &GetHost);
- ircns.Func(_SC("GetErrStr"), &irc_strerror);
-
- RootTable(vm).Bind(_SC("SqIrc"), ircns);
-
- Sqrat::ConstTable(vm).Enum(_SC("SqIrcErr"), Sqrat::Enumeration(vm)
- .Const(_SC("Ok"), LIBIRC_ERR_OK)
- .Const(_SC("InVal"), LIBIRC_ERR_INVAL)
- .Const(_SC("Resolv"), LIBIRC_ERR_RESOLV)
- .Const(_SC("Socket"), LIBIRC_ERR_SOCKET)
- .Const(_SC("Connect"), LIBIRC_ERR_CONNECT)
- .Const(_SC("Closed"), LIBIRC_ERR_CLOSED)
- .Const(_SC("NoMem"), LIBIRC_ERR_NOMEM)
- .Const(_SC("Accept"), LIBIRC_ERR_ACCEPT)
- .Const(_SC("NoDccSend"), LIBIRC_ERR_NODCCSEND)
- .Const(_SC("Read"), LIBIRC_ERR_READ)
- .Const(_SC("Write"), LIBIRC_ERR_WRITE)
- .Const(_SC("State"), LIBIRC_ERR_STATE)
- .Const(_SC("Timeout"), LIBIRC_ERR_TIMEOUT)
- .Const(_SC("OpenFile"), LIBIRC_ERR_OPENFILE)
- .Const(_SC("Terminated"), LIBIRC_ERR_TERMINATED)
- .Const(_SC("NoIPv6"), LIBIRC_ERR_NOIPV6)
- .Const(_SC("SSLNotSupported"), LIBIRC_ERR_SSL_NOT_SUPPORTED)
- .Const(_SC("SSLInitFailed"), LIBIRC_ERR_SSL_INIT_FAILED)
- .Const(_SC("ConnectSSLFailed"), LIBIRC_ERR_CONNECT_SSL_FAILED)
- .Const(_SC("SSLCertVerifyFailed"), LIBIRC_ERR_SSL_CERT_VERIFY_FAILED)
- .Const(_SC("Max"), LIBIRC_ERR_MAX)
- );
-
- Sqrat::ConstTable(vm).Enum(_SC("SqIrcOpt"), Sqrat::Enumeration(vm)
- .Const(_SC("Debug"), LIBIRC_OPTION_DEBUG)
- .Const(_SC("StripNicks"), LIBIRC_OPTION_STRIPNICKS)
- .Const(_SC("SSLNoVerify"), LIBIRC_OPTION_SSL_NO_VERIFY)
- );
-
- Sqrat::ConstTable(vm).Enum(_SC("SqIrcRFC"), Sqrat::Enumeration(vm)
- .Const(_SC("RPL_WELCOME"), LIBIRC_RFC_RPL_WELCOME)
- .Const(_SC("RPL_YOURHOST"), LIBIRC_RFC_RPL_YOURHOST)
- .Const(_SC("RPL_CREATED"), LIBIRC_RFC_RPL_CREATED)
- .Const(_SC("RPL_MYINFO"), LIBIRC_RFC_RPL_MYINFO)
- .Const(_SC("RPL_BOUNCE"), LIBIRC_RFC_RPL_BOUNCE)
- .Const(_SC("RPL_NONE"), LIBIRC_RFC_RPL_NONE)
- .Const(_SC("RPL_USERHOST"), LIBIRC_RFC_RPL_USERHOST)
- .Const(_SC("RPL_ISON"), LIBIRC_RFC_RPL_ISON)
- .Const(_SC("RPL_AWAY"), LIBIRC_RFC_RPL_AWAY)
- .Const(_SC("RPL_UNAWAY"), LIBIRC_RFC_RPL_UNAWAY)
- .Const(_SC("RPL_NOWAWAY"), LIBIRC_RFC_RPL_NOWAWAY)
- .Const(_SC("RPL_WHOISUSER"), LIBIRC_RFC_RPL_WHOISUSER)
- .Const(_SC("RPL_WHOISSERVER"), LIBIRC_RFC_RPL_WHOISSERVER)
- .Const(_SC("RPL_WHOISOPERATOR"), LIBIRC_RFC_RPL_WHOISOPERATOR)
- .Const(_SC("RPL_WHOISIDLE"), LIBIRC_RFC_RPL_WHOISIDLE)
- .Const(_SC("RPL_ENDOFWHOIS"), LIBIRC_RFC_RPL_ENDOFWHOIS)
- .Const(_SC("RPL_WHOISCHANNELS"), LIBIRC_RFC_RPL_WHOISCHANNELS)
- .Const(_SC("RPL_WHOWASUSER"), LIBIRC_RFC_RPL_WHOWASUSER)
- .Const(_SC("RPL_ENDOFWHOWAS"), LIBIRC_RFC_RPL_ENDOFWHOWAS)
- .Const(_SC("RPL_LISTSTART"), LIBIRC_RFC_RPL_LISTSTART)
- .Const(_SC("RPL_LIST"), LIBIRC_RFC_RPL_LIST)
- .Const(_SC("RPL_LISTEND"), LIBIRC_RFC_RPL_LISTEND)
- .Const(_SC("RPL_UNIQOPIS"), LIBIRC_RFC_RPL_UNIQOPIS)
- .Const(_SC("RPL_CHANNELMODEIS"), LIBIRC_RFC_RPL_CHANNELMODEIS)
- .Const(_SC("RPL_NOTOPIC"), LIBIRC_RFC_RPL_NOTOPIC)
- .Const(_SC("RPL_TOPIC"), LIBIRC_RFC_RPL_TOPIC)
- .Const(_SC("RPL_INVITING"), LIBIRC_RFC_RPL_INVITING)
- .Const(_SC("RPL_SUMMONING"), LIBIRC_RFC_RPL_SUMMONING)
- .Const(_SC("RPL_INVITELIST"), LIBIRC_RFC_RPL_INVITELIST)
- .Const(_SC("RPL_ENDOFINVITELIST"), LIBIRC_RFC_RPL_ENDOFINVITELIST)
- .Const(_SC("RPL_EXCEPTLIST"), LIBIRC_RFC_RPL_EXCEPTLIST)
- .Const(_SC("RPL_ENDOFEXCEPTLIST"), LIBIRC_RFC_RPL_ENDOFEXCEPTLIST)
- .Const(_SC("RPL_VERSION"), LIBIRC_RFC_RPL_VERSION)
- .Const(_SC("RPL_WHOREPLY"), LIBIRC_RFC_RPL_WHOREPLY)
- .Const(_SC("RPL_ENDOFWHO"), LIBIRC_RFC_RPL_ENDOFWHO)
- .Const(_SC("RPL_NAMREPLY"), LIBIRC_RFC_RPL_NAMREPLY)
- .Const(_SC("RPL_ENDOFNAMES"), LIBIRC_RFC_RPL_ENDOFNAMES)
- .Const(_SC("RPL_LINKS"), LIBIRC_RFC_RPL_LINKS)
- .Const(_SC("RPL_ENDOFLINKS"), LIBIRC_RFC_RPL_ENDOFLINKS)
- .Const(_SC("RPL_BANLIST"), LIBIRC_RFC_RPL_BANLIST)
- .Const(_SC("RPL_ENDOFBANLIST"), LIBIRC_RFC_RPL_ENDOFBANLIST)
- .Const(_SC("RPL_INFO"), LIBIRC_RFC_RPL_INFO)
- .Const(_SC("RPL_ENDOFINFO"), LIBIRC_RFC_RPL_ENDOFINFO)
- .Const(_SC("RPL_MOTDSTART"), LIBIRC_RFC_RPL_MOTDSTART)
- .Const(_SC("RPL_MOTD"), LIBIRC_RFC_RPL_MOTD)
- .Const(_SC("RPL_ENDOFMOTD"), LIBIRC_RFC_RPL_ENDOFMOTD)
- .Const(_SC("RPL_YOUREOPER"), LIBIRC_RFC_RPL_YOUREOPER)
- .Const(_SC("RPL_REHASHING"), LIBIRC_RFC_RPL_REHASHING)
- .Const(_SC("RPL_YOURESERVICE"), LIBIRC_RFC_RPL_YOURESERVICE)
- .Const(_SC("RPL_TIME"), LIBIRC_RFC_RPL_TIME)
- .Const(_SC("RPL_USERSSTART"), LIBIRC_RFC_RPL_USERSSTART)
- .Const(_SC("RPL_USERS"), LIBIRC_RFC_RPL_USERS)
- .Const(_SC("RPL_ENDOFUSERS"), LIBIRC_RFC_RPL_ENDOFUSERS)
- .Const(_SC("RPL_NOUSERS"), LIBIRC_RFC_RPL_NOUSERS)
- .Const(_SC("RPL_TRACELINK"), LIBIRC_RFC_RPL_TRACELINK)
- .Const(_SC("RPL_TRACECONNECTING"), LIBIRC_RFC_RPL_TRACECONNECTING)
- .Const(_SC("RPL_TRACEHANDSHAKE"), LIBIRC_RFC_RPL_TRACEHANDSHAKE)
- .Const(_SC("RPL_TRACEUNKNOWN"), LIBIRC_RFC_RPL_TRACEUNKNOWN)
- .Const(_SC("RPL_TRACEOPERATOR"), LIBIRC_RFC_RPL_TRACEOPERATOR)
- .Const(_SC("RPL_TRACEUSER"), LIBIRC_RFC_RPL_TRACEUSER)
- .Const(_SC("RPL_TRACESERVER"), LIBIRC_RFC_RPL_TRACESERVER)
- .Const(_SC("RPL_TRACESERVICE"), LIBIRC_RFC_RPL_TRACESERVICE)
- .Const(_SC("RPL_TRACENEWTYPE"), LIBIRC_RFC_RPL_TRACENEWTYPE)
- .Const(_SC("RPL_TRACECLASS"), LIBIRC_RFC_RPL_TRACECLASS)
- .Const(_SC("RPL_TRACELOG"), LIBIRC_RFC_RPL_TRACELOG)
- .Const(_SC("RPL_TRACEEND"), LIBIRC_RFC_RPL_TRACEEND)
- .Const(_SC("RPL_STATSLINKINFO"), LIBIRC_RFC_RPL_STATSLINKINFO)
- .Const(_SC("RPL_STATSCOMMANDS"), LIBIRC_RFC_RPL_STATSCOMMANDS)
- .Const(_SC("RPL_ENDOFSTATS"), LIBIRC_RFC_RPL_ENDOFSTATS)
- .Const(_SC("RPL_STATSUPTIME"), LIBIRC_RFC_RPL_STATSUPTIME)
- .Const(_SC("RPL_STATSOLINE"), LIBIRC_RFC_RPL_STATSOLINE)
- .Const(_SC("RPL_UMODEIS"), LIBIRC_RFC_RPL_UMODEIS)
- .Const(_SC("RPL_SERVLIST"), LIBIRC_RFC_RPL_SERVLIST)
- .Const(_SC("RPL_SERVLISTEND"), LIBIRC_RFC_RPL_SERVLISTEND)
- .Const(_SC("RPL_LUSERCLIENT"), LIBIRC_RFC_RPL_LUSERCLIENT)
- .Const(_SC("RPL_LUSEROP"), LIBIRC_RFC_RPL_LUSEROP)
- .Const(_SC("RPL_LUSERUNKNOWN"), LIBIRC_RFC_RPL_LUSERUNKNOWN)
- .Const(_SC("RPL_LUSERCHANNELS"), LIBIRC_RFC_RPL_LUSERCHANNELS)
- .Const(_SC("RPL_LUSERME"), LIBIRC_RFC_RPL_LUSERME)
- .Const(_SC("RPL_ADMINME"), LIBIRC_RFC_RPL_ADMINME)
- .Const(_SC("RPL_ADMINLOC1"), LIBIRC_RFC_RPL_ADMINLOC1)
- .Const(_SC("RPL_ADMINLOC2"), LIBIRC_RFC_RPL_ADMINLOC2)
- .Const(_SC("RPL_ADMINEMAIL"), LIBIRC_RFC_RPL_ADMINEMAIL)
- .Const(_SC("RPL_TRYAGAIN"), LIBIRC_RFC_RPL_TRYAGAIN)
- .Const(_SC("ERR_NOSUCHNICK"), LIBIRC_RFC_ERR_NOSUCHNICK)
- .Const(_SC("ERR_NOSUCHSERVER"), LIBIRC_RFC_ERR_NOSUCHSERVER)
- .Const(_SC("ERR_NOSUCHCHANNEL"), LIBIRC_RFC_ERR_NOSUCHCHANNEL)
- .Const(_SC("ERR_CANNOTSENDTOCHAN"), LIBIRC_RFC_ERR_CANNOTSENDTOCHAN)
- .Const(_SC("ERR_TOOMANYCHANNELS"), LIBIRC_RFC_ERR_TOOMANYCHANNELS)
- .Const(_SC("ERR_WASNOSUCHNICK"), LIBIRC_RFC_ERR_WASNOSUCHNICK)
- .Const(_SC("ERR_TOOMANYTARGETS"), LIBIRC_RFC_ERR_TOOMANYTARGETS)
- .Const(_SC("ERR_NOSUCHSERVICE"), LIBIRC_RFC_ERR_NOSUCHSERVICE)
- .Const(_SC("ERR_NOORIGIN"), LIBIRC_RFC_ERR_NOORIGIN)
- .Const(_SC("ERR_NORECIPIENT"), LIBIRC_RFC_ERR_NORECIPIENT)
- .Const(_SC("ERR_NOTEXTTOSEND"), LIBIRC_RFC_ERR_NOTEXTTOSEND)
- .Const(_SC("ERR_NOTOPLEVEL"), LIBIRC_RFC_ERR_NOTOPLEVEL)
- .Const(_SC("ERR_WILDTOPLEVEL"), LIBIRC_RFC_ERR_WILDTOPLEVEL)
- .Const(_SC("ERR_BADMASK"), LIBIRC_RFC_ERR_BADMASK)
- .Const(_SC("ERR_UNKNOWNCOMMAND"), LIBIRC_RFC_ERR_UNKNOWNCOMMAND)
- .Const(_SC("ERR_NOMOTD"), LIBIRC_RFC_ERR_NOMOTD)
- .Const(_SC("ERR_NOADMININFO"), LIBIRC_RFC_ERR_NOADMININFO)
- .Const(_SC("ERR_FILEERROR"), LIBIRC_RFC_ERR_FILEERROR)
- .Const(_SC("ERR_NONICKNAMEGIVEN"), LIBIRC_RFC_ERR_NONICKNAMEGIVEN)
- .Const(_SC("ERR_ERRONEUSNICKNAME"), LIBIRC_RFC_ERR_ERRONEUSNICKNAME)
- .Const(_SC("ERR_NICKNAMEINUSE"), LIBIRC_RFC_ERR_NICKNAMEINUSE)
- .Const(_SC("ERR_NICKCOLLISION"), LIBIRC_RFC_ERR_NICKCOLLISION)
- .Const(_SC("ERR_UNAVAILRESOURCE"), LIBIRC_RFC_ERR_UNAVAILRESOURCE)
- .Const(_SC("ERR_USERNOTINCHANNEL"), LIBIRC_RFC_ERR_USERNOTINCHANNEL)
- .Const(_SC("ERR_NOTONCHANNEL"), LIBIRC_RFC_ERR_NOTONCHANNEL)
- .Const(_SC("ERR_USERONCHANNEL"), LIBIRC_RFC_ERR_USERONCHANNEL)
- .Const(_SC("ERR_NOLOGIN"), LIBIRC_RFC_ERR_NOLOGIN)
- .Const(_SC("ERR_SUMMONDISABLED"), LIBIRC_RFC_ERR_SUMMONDISABLED)
- .Const(_SC("ERR_USERSDISABLED"), LIBIRC_RFC_ERR_USERSDISABLED)
- .Const(_SC("ERR_NOTREGISTERED"), LIBIRC_RFC_ERR_NOTREGISTERED)
- .Const(_SC("ERR_NEEDMOREPARAMS"), LIBIRC_RFC_ERR_NEEDMOREPARAMS)
- .Const(_SC("ERR_ALREADYREGISTRED"), LIBIRC_RFC_ERR_ALREADYREGISTRED)
- .Const(_SC("ERR_NOPERMFORHOST"), LIBIRC_RFC_ERR_NOPERMFORHOST)
- .Const(_SC("ERR_PASSWDMISMATCH"), LIBIRC_RFC_ERR_PASSWDMISMATCH)
- .Const(_SC("ERR_YOUREBANNEDCREEP"), LIBIRC_RFC_ERR_YOUREBANNEDCREEP)
- .Const(_SC("ERR_YOUWILLBEBANNED"), LIBIRC_RFC_ERR_YOUWILLBEBANNED)
- .Const(_SC("ERR_KEYSET"), LIBIRC_RFC_ERR_KEYSET)
- .Const(_SC("ERR_CHANNELISFULL"), LIBIRC_RFC_ERR_CHANNELISFULL)
- .Const(_SC("ERR_UNKNOWNMODE"), LIBIRC_RFC_ERR_UNKNOWNMODE)
- .Const(_SC("ERR_INVITEONLYCHAN"), LIBIRC_RFC_ERR_INVITEONLYCHAN)
- .Const(_SC("ERR_BANNEDFROMCHAN"), LIBIRC_RFC_ERR_BANNEDFROMCHAN)
- .Const(_SC("ERR_BADCHANNELKEY"), LIBIRC_RFC_ERR_BADCHANNELKEY)
- .Const(_SC("ERR_BADCHANMASK"), LIBIRC_RFC_ERR_BADCHANMASK)
- .Const(_SC("ERR_NOCHANMODES"), LIBIRC_RFC_ERR_NOCHANMODES)
- .Const(_SC("ERR_BANLISTFULL"), LIBIRC_RFC_ERR_BANLISTFULL)
- .Const(_SC("ERR_NOPRIVILEGES"), LIBIRC_RFC_ERR_NOPRIVILEGES)
- .Const(_SC("ERR_CHANOPRIVSNEEDED"), LIBIRC_RFC_ERR_CHANOPRIVSNEEDED)
- .Const(_SC("ERR_CANTKILLSERVER"), LIBIRC_RFC_ERR_CANTKILLSERVER)
- .Const(_SC("ERR_RESTRICTED"), LIBIRC_RFC_ERR_RESTRICTED)
- .Const(_SC("ERR_UNIQOPPRIVSNEEDED"), LIBIRC_RFC_ERR_UNIQOPPRIVSNEEDED)
- .Const(_SC("ERR_NOOPERHOST"), LIBIRC_RFC_ERR_NOOPERHOST)
- .Const(_SC("ERR_UMODEUNKNOWNFLAG"), LIBIRC_RFC_ERR_UMODEUNKNOWNFLAG)
- .Const(_SC("ERR_USERSDONTMATCH"), LIBIRC_RFC_ERR_USERSDONTMATCH)
- );
-}
-
} // Namespace:: SqMod
diff --git a/source/Library/IRC.hpp b/modules/irc/Session.hpp
similarity index 95%
rename from source/Library/IRC.hpp
rename to modules/irc/Session.hpp
index 75bd6020..ec821cdc 100644
--- a/source/Library/IRC.hpp
+++ b/modules/irc/Session.hpp
@@ -1,21 +1,21 @@
-#ifndef _LIBRARY_IRC_HPP_
-#define _LIBRARY_IRC_HPP_
+#ifndef _SQIRC_SESSION_HPP_
+#define _SQIRC_SESSION_HPP_
// ------------------------------------------------------------------------------------------------
-#include "Base/Shared.hpp"
-#include "Library/Time.hpp"
-#include "Library/Numeric.hpp"
+#include "Common.hpp"
+
+// ------------------------------------------------------------------------------------------------
+#include
// ------------------------------------------------------------------------------------------------
#include
#include
// ------------------------------------------------------------------------------------------------
-#include
+#include
// ------------------------------------------------------------------------------------------------
namespace SqMod {
-namespace IRC {
/* ------------------------------------------------------------------------------------------------
* Manages a single connection to an IRC network.
@@ -77,18 +77,17 @@ protected:
void Release();
/* --------------------------------------------------------------------------------------------
- *
+ * Completely destroy the internal session instance and release resources.
*/
- bool Validate() const
- {
- if (m_Session)
- return true;
- SqThrow("Invalid IRC session (%s)", m_Tag.c_str());
- return false;
- }
+ void Destroy();
/* --------------------------------------------------------------------------------------------
- *
+ * Make sure a valid session exists and throw an error if it doesn't.
+ */
+ bool Validate() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether this session is connected to a server or not.
*/
bool Connected() const
{
@@ -96,45 +95,19 @@ protected:
}
/* --------------------------------------------------------------------------------------------
- *
+ * See whether this session is connected to a server and throw an error if not.
*/
- void Destroy();
+ bool ConnectedThrow() const;
/* --------------------------------------------------------------------------------------------
- *
+ * See whether this session is NOT! connected to a server and throw an error if it is.
*/
- bool ConnectedThrow() const
- {
- if (!m_Session)
- SqThrow("Invalid IRC session (%s)", m_Tag.c_str());
- else if (!irc_is_connected(m_Session))
- SqThrow("Session is not connected (%s)", m_Tag.c_str());
- else
- return true;
- return false;
- }
+ bool NotConnected() const;
/* --------------------------------------------------------------------------------------------
- *
+ * Validate a session instance used by an event and log an error if it's invalid.
*/
- bool NotConnected() const
- {
- if (!m_Session || !irc_is_connected(m_Session) || !m_Reconnect)
- return true;
- SqThrow("Already connected or trying connect to IRC server (%s)", m_Tag.c_str());
- return !m_Session;
- }
-
- /* --------------------------------------------------------------------------------------------
- *
- */
- static bool ValidateEventSession(Session * ptr)
- {
- if (ptr)
- return true;
- LogErr("Cannot forward IRC event without a session container");
- return false;
- }
+ static bool ValidateEventSession(Session * ptr);
private:
@@ -242,6 +215,14 @@ public:
return m_Server.c_str();
}
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to retrieve the name from instances of this type.
+ */
+ CSStr Typename() const
+ {
+ return _SC("SqIrcSession");
+ }
+
/* --------------------------------------------------------------------------------------------
* See whether this session is valid.
*/
@@ -328,15 +309,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the nickname.
*/
- void SetNick(CSStr nick)
- {
- if (!nick || strlen(nick) <= 0)
- SqThrow("Invalid IRC nickname");
- else if (Connected())
- irc_cmd_nick(m_Session, nick);
- else if (Validate())
- m_Nick.assign(nick);
- }
+ void SetNick(CSStr nick);
/* --------------------------------------------------------------------------------------------
* Retrieve the user name.
@@ -369,7 +342,7 @@ public:
void SetName(CSStr name)
{
if (Validate() && NotConnected())
- m_Name.c_str();
+ m_Name.assign(name);
}
/* --------------------------------------------------------------------------------------------
@@ -383,13 +356,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the server port number.
*/
- void SetPort(Uint32 num)
- {
- if (num > NumLimit< Uint16 >::Max)
- SqThrow("Port number is out of range: %u > %u", num, NumLimit< Uint16 >::Max);
- else if (Validate() && NotConnected())
- m_Port = num;
- }
+ void SetPort(Uint32 num);
/* --------------------------------------------------------------------------------------------
* Retrieve the amount of time to pool for session events.
@@ -466,28 +433,17 @@ public:
/* --------------------------------------------------------------------------------------------
* Retrieve when the next connection retry should be performed.
*/
- Timestamp GetNextTry() const
- {
- return Timestamp(m_NextTry);
- }
+ Object GetNextTry() const;
/* --------------------------------------------------------------------------------------------
* Modify when the next connection retry should be performed.
*/
- void SetNextTry(const Timestamp & tm)
- {
- m_NextTry = tm.GetMicroseconds().GetNum();
- }
+ void SetNextTry(Object & tm);
/* --------------------------------------------------------------------------------------------
* Retrieve the session uptime.
*/
- Timestamp GetSessionTime() const
- {
- if (m_SessionTime)
- return Timestamp(GetEpochTimeMicro() - m_SessionTime);
- return Timestamp();
- }
+ Object GetSessionTime() const;
/* --------------------------------------------------------------------------------------------
* See whether the session is currently trying to reconnect.
@@ -789,14 +745,7 @@ public:
/* --------------------------------------------------------------------------------------------
* Change the currently used nick on the connected server.
*/
- Int32 CmdNick(CSStr nick)
- {
- if (!nick || strlen(nick) <= 0)
- SqThrow("Invalid IRC nickname");
- else if (ConnectedThrow())
- return irc_cmd_nick(m_Session, nick);
- return -1;
- }
+ Int32 CmdNick(CSStr nick);
/* --------------------------------------------------------------------------------------------
* Query various information about the specified user.
@@ -1444,7 +1393,6 @@ public:
}
};
-} // Namespace:: IRC
} // Namespace:: SqMod
-#endif // _LIBRARY_IRC_HPP_
+#endif // _SQIRC_SESSION_HPP_
diff --git a/modules/sample/Common.cpp b/modules/sample/Common.cpp
new file mode 100644
index 00000000..c669be1f
--- /dev/null
+++ b/modules/sample/Common.cpp
@@ -0,0 +1,24 @@
+// ------------------------------------------------------------------------------------------------
+#include "Common.hpp"
+#include "Module.hpp"
+
+// ------------------------------------------------------------------------------------------------
+#include
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+// ------------------------------------------------------------------------------------------------
+int SampleFunction()
+{
+ OutputMessage("Hello from the sample plugin function!");
+ return rand();
+}
+
+// ------------------------------------------------------------------------------------------------
+void SampleType::SampleMethod() const
+{
+ OutputMessage("I have the values %d and %d", m_MyVal, mMyNum);
+}
+
+} // Namespace:: SqMod
diff --git a/modules/sample/Common.hpp b/modules/sample/Common.hpp
new file mode 100644
index 00000000..8e1b6d53
--- /dev/null
+++ b/modules/sample/Common.hpp
@@ -0,0 +1,66 @@
+#ifndef _SQSAMPLE_COMMON_HPP_
+#define _SQSAMPLE_COMMON_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "ModBase.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * SOFTWARE INFORMATION
+*/
+#define SQSAMPLE_NAME "Squirrel Sample Module"
+#define SQSAMPLE_AUTHOR "Sandu Liviu Catalin (S.L.C)"
+#define SQSAMPLE_COPYRIGHT "Copyright (C) 2016 Sandu Liviu Catalin"
+#define SQSAMPLE_HOST_NAME "SqModSampleHost"
+#define SQSAMPLE_VERSION 001
+#define SQSAMPLE_VERSION_STR "0.0.1"
+#define SQSAMPLE_VERSION_MAJOR 0
+#define SQSAMPLE_VERSION_MINOR 0
+#define SQSAMPLE_VERSION_PATCH 1
+
+/* --------------------------------------------------------------------------------------------
+ * Sample Plugin API
+*/
+
+int SampleFunction();
+
+class SampleType
+{
+private:
+
+ int m_MyVal;
+
+public:
+
+ int mMyNum;
+
+ SampleType()
+ : m_MyVal(0), mMyNum(0)
+ {
+
+ }
+
+ SampleType(int num)
+ : m_MyVal(num * 2), mMyNum(num)
+ {
+
+ }
+
+ int GetMyVal() const
+ {
+ return m_MyVal;
+ }
+
+ void SetMyVal(int val)
+ {
+ m_MyVal = val;
+ }
+
+ void SampleMethod() const;
+};
+
+} // Namespace:: SqMod
+
+#endif // _SQSAMPLE_COMMON_HPP_
diff --git a/modules/sample/Module.cpp b/modules/sample/Module.cpp
new file mode 100644
index 00000000..7e926e2c
--- /dev/null
+++ b/modules/sample/Module.cpp
@@ -0,0 +1,310 @@
+// --------------------------------------------------------------------------------------------
+#include "Module.hpp"
+#include "Common.hpp"
+
+// --------------------------------------------------------------------------------------------
+#include
+
+// --------------------------------------------------------------------------------------------
+#include
+#include
+#include
+
+// --------------------------------------------------------------------------------------------
+#if defined(WIN32) || defined(_WIN32)
+ #include
+#endif
+
+namespace SqMod {
+
+// --------------------------------------------------------------------------------------------
+PluginFuncs* _Func = NULL;
+PluginCallbacks* _Clbk = NULL;
+PluginInfo* _Info = NULL;
+
+// --------------------------------------------------------------------------------------------
+HSQAPI _SqAPI = NULL;
+HSQEXPORTS _SqMod = NULL;
+HSQUIRRELVM _SqVM = NULL;
+
+/* ------------------------------------------------------------------------------------------------
+ * Bind speciffic functions to certain server events.
+*/
+void BindCallbacks();
+
+/* ------------------------------------------------------------------------------------------------
+ * Undo changes made with BindCallbacks().
+*/
+void UnbindCallbacks();
+
+/* --------------------------------------------------------------------------------------------
+ * Register the module API under the specified virtual machine.
+*/
+void RegisterAPI(HSQUIRRELVM vm);
+
+/* --------------------------------------------------------------------------------------------
+ * Initialize the plugin by obtaining the API provided by the host plugin.
+*/
+void OnSquirrelInitialize()
+{
+ // Attempt to import the plugin API exported by the host plugin
+ _SqMod = sq_api_import(_Func);
+ // Did we failed to obtain the plugin exports?
+ if(!_SqMod)
+ OutputError("Failed to attach [%s] on host plugin.", SQSAMPLE_NAME);
+ else
+ {
+ // Obtain the Squirrel API
+ _SqAPI = _SqMod->GetSquirrelAPI();
+ // Expand the Squirrel API into global functions
+ sq_api_expand(_SqAPI);
+ }
+}
+
+/* --------------------------------------------------------------------------------------------
+ * Load the module on the virtual machine provided by the host module.
+*/
+void OnSquirrelLoad()
+{
+ // Make sure that we have a valid plugin API
+ if (!_SqMod)
+ return; /* Unable to proceed. */
+ // Obtain the Squirrel API and VM
+ _SqVM = _SqMod->GetSquirrelVM();
+ // Make sure that a valid virtual machine exists
+ if (!_SqVM)
+ return; /* Unable to proceed. */
+ // Set this as the default database
+ DefaultVM::Set(_SqVM);
+ // Register the module API
+ RegisterAPI(_SqVM);
+ // Notify about the current status
+ OutputMessage("Registered: %s", SQSAMPLE_NAME);
+}
+
+/* --------------------------------------------------------------------------------------------
+ * The virtual machine is about to be terminated and script resources should be released.
+*/
+void OnSquirrelTerminate()
+{
+ OutputMessage("Terminating: %s", SQSAMPLE_NAME);
+ // Release the current database (if any)
+ DefaultVM::Set(NULL);
+ // Release script resources...
+}
+
+/* --------------------------------------------------------------------------------------------
+ * Validate the module API to make sure we don't run into issues.
+*/
+bool CheckAPIVer(CCStr ver)
+{
+ // Obtain the numeric representation of the API version
+ long vernum = strtol(ver, NULL, 10);
+ // Check against version mismatch
+ if (vernum == SQMOD_API_VER)
+ return true;
+ // Log the incident
+ OutputError("API version mismatch on %s", SQSAMPLE_NAME);
+ OutputMessage("=> Requested: %ld Have: %ld", vernum, SQMOD_API_VER);
+ // Invoker should not attempt to communicate through the module API
+ return false;
+}
+
+/* --------------------------------------------------------------------------------------------
+ * React to command sent by other plugins.
+*/
+static int OnInternalCommand(unsigned int type, const char * text)
+{
+ switch(type)
+ {
+ case SQMOD_INITIALIZE_CMD:
+ if (CheckAPIVer(text))
+ OnSquirrelInitialize();
+ break;
+ case SQMOD_LOAD_CMD:
+ OnSquirrelLoad();
+ break;
+ case SQMOD_TERMINATE_CMD:
+ OnSquirrelTerminate();
+ break;
+ default: break;
+ }
+ return 1;
+}
+
+/* --------------------------------------------------------------------------------------------
+ * The server was initialized and this plugin was loaded successfully.
+*/
+static int OnInitServer()
+{
+ return 1;
+}
+
+static void OnShutdownServer(void)
+{
+ // The server may still send callbacks
+ UnbindCallbacks();
+}
+
+// ------------------------------------------------------------------------------------------------
+void BindCallbacks()
+{
+ _Clbk->OnInitServer = OnInitServer;
+ _Clbk->OnInternalCommand = OnInternalCommand;
+ _Clbk->OnShutdownServer = OnShutdownServer;
+}
+
+// ------------------------------------------------------------------------------------------------
+void UnbindCallbacks()
+{
+ _Clbk->OnInitServer = NULL;
+ _Clbk->OnInternalCommand = NULL;
+ _Clbk->OnShutdownServer = NULL;
+}
+
+// --------------------------------------------------------------------------------------------
+void RegisterAPI(HSQUIRRELVM vm)
+{
+ RootTable(vm).Bind(_SC("SampleType"), Class< SampleType >(vm, _SC("SampleType"))
+ .Ctor()
+ .Ctor< int >()
+ .Var(_SC("MyNum"), &SampleType::mMyNum)
+ .Prop(_SC("MyVal"), &SampleType::GetMyVal, &SampleType::SetMyVal)
+ .Func(_SC("SampleMethod"), &SampleType::SampleMethod)
+ );
+
+ RootTable(vm).Func(_SC("SampleFunction"), &SampleFunction);
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputMessageImpl(const char * msg, va_list args)
+{
+#if defined(WIN32) || defined(_WIN32)
+ HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ CONSOLE_SCREEN_BUFFER_INFO csb_before;
+ GetConsoleScreenBufferInfo( hstdout, &csb_before);
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN);
+ printf("[SQMOD] ");
+
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
+ vprintf(msg, args);
+ puts("");
+
+ SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
+#else
+ printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27, msg);
+ vprintf(msg, args);
+ puts("");
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputErrorImpl(const char * msg, va_list args)
+{
+#if defined(WIN32) || defined(_WIN32)
+ HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ CONSOLE_SCREEN_BUFFER_INFO csb_before;
+ GetConsoleScreenBufferInfo( hstdout, &csb_before);
+ SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
+ printf("[SQMOD] ");
+
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
+ vprintf(msg, args);
+ puts("");
+
+ SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
+#else
+ printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27, msg);
+ vprintf(msg, args);
+ puts("");
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputDebug(const char * msg, ...)
+{
+#ifdef _DEBUG
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputMessageImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+#else
+ SQMOD_UNUSED_VAR(msg);
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputMessage(const char * msg, ...)
+{
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputMessageImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputError(const char * msg, ...)
+{
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputErrorImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+}
+
+} // Namespace:: SqMod
+
+// --------------------------------------------------------------------------------------------
+SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallbacks* callbacks, PluginInfo* info)
+{
+ using namespace SqMod;
+ // Output plugin header
+ puts("");
+ OutputMessage("--------------------------------------------------------------------");
+ OutputMessage("Plugin: %s", SQSAMPLE_NAME);
+ OutputMessage("Author: %s", SQSAMPLE_AUTHOR);
+ OutputMessage("Legal: %s", SQSAMPLE_COPYRIGHT);
+ OutputMessage("--------------------------------------------------------------------");
+ puts("");
+ // Attempt to find the host plugin ID
+ int host_plugin_id = functions->FindPlugin((char *)(SQMOD_HOST_NAME));
+ // See if our plugin was loaded after the host plugin
+ if (host_plugin_id < 0)
+ {
+ OutputError("%s could find the host plugin", SQSAMPLE_NAME);
+ // Don't load!
+ return SQMOD_FAILURE;
+ }
+ // Should never reach this point but just in case
+ else if (host_plugin_id > (info->nPluginId))
+ {
+ OutputError("%s loaded after the host plugin", SQSAMPLE_NAME);
+ // Don't load!
+ return SQMOD_FAILURE;
+ }
+ // Store server proxies
+ _Func = functions;
+ _Clbk = callbacks;
+ _Info = info;
+ // Assign plugin information
+ _Info->uPluginVer = SQSAMPLE_VERSION;
+ strcpy(_Info->szName, SQSAMPLE_HOST_NAME);
+ // Bind callbacks
+ BindCallbacks();
+ // Notify that the plugin was successfully loaded
+ OutputMessage("Successfully loaded %s", SQSAMPLE_NAME);
+ // Dummy spacing
+ puts("");
+ // Done!
+ return SQMOD_SUCCESS;
+}
diff --git a/modules/sample/Module.hpp b/modules/sample/Module.hpp
new file mode 100644
index 00000000..e62288fc
--- /dev/null
+++ b/modules/sample/Module.hpp
@@ -0,0 +1,41 @@
+#ifndef _SQSAMPLE_MODULE_HPP_
+#define _SQSAMPLE_MODULE_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "SqMod.h"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * Proxies to comunicate with the server.
+*/
+extern PluginFuncs* _Func;
+extern PluginCallbacks* _Clbk;
+extern PluginInfo* _Info;
+
+/* ------------------------------------------------------------------------------------------------
+ * Proxies to comunicate with the Squirrel plugin.
+*/
+extern HSQAPI _SqAPI;
+extern HSQEXPORTS _SqMod;
+extern HSQUIRRELVM _SqVM;
+
+/* ------------------------------------------------------------------------------------------------
+ * Output a message only if the _DEBUG was defined.
+*/
+void OutputDebug(const char * msg, ...);
+
+/* ------------------------------------------------------------------------------------------------
+ * Output a formatted user message to the console.
+*/
+void OutputMessage(const char * msg, ...);
+
+/* ------------------------------------------------------------------------------------------------
+ * Output a formatted error message to the console.
+*/
+void OutputError(const char * msg, ...);
+
+} // Namespace:: SqMod
+
+#endif // _SQSAMPLE_MODULE_HPP_
diff --git a/modules/xml/Attribute.cpp b/modules/xml/Attribute.cpp
new file mode 100644
index 00000000..3379a656
--- /dev/null
+++ b/modules/xml/Attribute.cpp
@@ -0,0 +1,193 @@
+// ------------------------------------------------------------------------------------------------
+#include "Attribute.hpp"
+#include "Module.hpp"
+
+// ------------------------------------------------------------------------------------------------
+#include
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+// ------------------------------------------------------------------------------------------------
+bool Attribute::Validate() const
+{
+ if (m_Doc)
+ return true;
+ // Invalid document reference
+ _SqMod->SqThrow("Invalid XML document reference");
+ return false;
+}
+
+// ------------------------------------------------------------------------------------------------
+void Attribute::SetName(CSStr name)
+{
+ if (!m_Attr.set_name(name))
+ _SqMod->SqThrow("Unable to set xml attribute name");
+}
+
+// ------------------------------------------------------------------------------------------------
+void Attribute::SetValue(CSStr name)
+{
+ if (!m_Attr.set_value(name))
+ _SqMod->SqThrow("Unable to set xml attribute value");
+}
+
+// ------------------------------------------------------------------------------------------------
+Object Attribute::AsLong(Object & def) const
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object >::push(_SqVM, def);
+ // The resulted long integer value
+ Int64 longint = 0;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Push a long integer instance with the requested value on the stack
+ _SqMod->PushSLongObject(_SqVM, m_Attr.as_llong(longint));
+ // Obtain the object from the stack
+ Var< Object > inst(_SqVM, -1);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the long integer instance
+ return inst.value;
+}
+
+// ------------------------------------------------------------------------------------------------
+Object Attribute::AsUlong(Object & def) const
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object >::push(_SqVM, def);
+ // The resulted long integer value
+ Uint64 longint = 0;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Push a long integer instance with the requested value on the stack
+ _SqMod->PushULongObject(_SqVM, m_Attr.as_ullong(longint));
+ // Obtain the object from the stack
+ Var< Object > inst(_SqVM, -1);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the long integer instance
+ return inst.value;
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Attribute::ApplyLong(Object & value)
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object & >::push(_SqVM, value);
+ // The resulted long integer value
+ Int64 longint = 0;
+ // Whether the operation succeeded
+ bool res = false;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Assign the obtained value
+ else
+ res = m_Attr.set_value(longint);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the result
+ return res;
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Attribute::ApplyUlong(Object & value)
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object & >::push(_SqVM, value);
+ // The resulted long integer value
+ Uint64 longint = 0;
+ // Whether the operation succeeded
+ bool res = false;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Assign the obtained value
+ else
+ res = m_Attr.set_value(longint);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the result
+ return res;
+}
+
+// ------------------------------------------------------------------------------------------------
+Object Attribute::GetLong() const
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push a long integer instance with the requested value on the stack
+ _SqMod->PushSLongObject(_SqVM, m_Attr.as_llong());
+ // Obtain the object from the stack
+ Var< Object > inst(_SqVM, -1);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the long integer instance
+ return inst.value;
+}
+
+// ------------------------------------------------------------------------------------------------
+void Attribute::SetLong(Object & value)
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object & >::push(_SqVM, value);
+ // The resulted long integer value
+ Int64 longint = 0;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Assign the obtained value
+ else
+ m_Attr = longint;
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+}
+
+// ------------------------------------------------------------------------------------------------
+Object Attribute::GetUlong() const
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push a long integer instance with the requested value on the stack
+ _SqMod->PushULongObject(_SqVM, m_Attr.as_ullong());
+ // Obtain the object from the stack
+ Var< Object > inst(_SqVM, -1);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the long integer instance
+ return inst.value;
+}
+
+// ------------------------------------------------------------------------------------------------
+void Attribute::SetUlong(Object & value)
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object & >::push(_SqVM, value);
+ // The resulted long integer value
+ Uint64 longint = 0;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Assign the obtained value
+ else
+ m_Attr = longint;
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+}
+
+} // Namespace:: SqMod
diff --git a/modules/xml/Attribute.hpp b/modules/xml/Attribute.hpp
new file mode 100644
index 00000000..746cc169
--- /dev/null
+++ b/modules/xml/Attribute.hpp
@@ -0,0 +1,427 @@
+#ifndef _XML_ATTRIBUTE_HPP_
+#define _XML_ATTRIBUTE_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "Common.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * A light-weight handle for manipulating attributes in DOM tree.
+*/
+class Attribute
+{
+ // --------------------------------------------------------------------------------------------
+ friend class Node;
+
+protected:
+
+ // --------------------------------------------------------------------------------------------
+ typedef xml_attribute Type;
+
+ /* --------------------------------------------------------------------------------------------
+ * Explicit constructor.
+ */
+ Attribute(const DocumentRef doc, const Type & attr)
+ : m_Doc(doc), m_Attr(attr)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Validate the document reference and throw an error if invalid.
+ */
+ bool Validate() const;
+
+private:
+
+ // ---------------------------------------------------------------------------------------------
+ DocumentRef m_Doc; /* The main xml document instance. */
+ Type m_Attr; /* The managed node attribute. */
+
+public:
+
+ /* --------------------------------------------------------------------------------------------
+ * Default constructor.
+ */
+ Attribute()
+ : m_Doc(), m_Attr()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy constructor. (disabled)
+ */
+ Attribute(const Attribute & o)
+ : m_Doc(o.m_Doc), m_Attr(o.m_Attr)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Destructor.
+ */
+ ~Attribute()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy assignment operator. (disabled)
+ */
+ Attribute & operator = (const Attribute & o)
+ {
+ m_Doc = o.m_Doc;
+ m_Attr = o.m_Attr;
+ return *this;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to compare two instances of this type.
+ */
+ Int32 Cmp(const Attribute & o)
+ {
+ if (m_Attr == o.m_Attr)
+ return 0;
+ else if (m_Attr > o.m_Attr)
+ return 1;
+ else
+ return -1;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to convert an instance of this type to a string.
+ */
+ CSStr ToString() const
+ {
+ return m_Attr.value();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether this instance references a valid xml document.
+ */
+ bool IsValid() const
+ {
+ return m_Doc;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Return the number of active references to this document instance.
+ */
+ Uint32 GetRefCount() const
+ {
+ return m_Doc.Count();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether the attribute is empty.
+ */
+ bool IsEmpty() const
+ {
+ return m_Attr.empty();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Get hash value (unique for handles to the same object).
+ */
+ SQInteger GetHashValue() const
+ {
+ return (SQInteger)m_Attr.hash_value();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve attribute name.
+ */
+ CSStr GetName() const
+ {
+ return m_Attr.name();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve attribute name.
+ */
+ void SetName(CSStr name);
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the attribute name.
+ */
+ bool ApplyName(CSStr name)
+ {
+ return m_Attr.set_name(name);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve attribute value.
+ */
+ CSStr GetValue() const
+ {
+ return m_Attr.value();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve attribute value.
+ */
+ void SetValue(CSStr name);
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the attribute value.
+ */
+ bool ApplyValue(CSStr value)
+ {
+ return m_Attr.set_value(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a string or the specified default value if empty.
+ */
+ CSStr AsString(CSStr def) const
+ {
+ return m_Attr.as_string(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a integer or the specified default value if empty.
+ */
+ Int32 AsInt(Int32 def) const
+ {
+ return m_Attr.as_int(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a unsigned integer or the specified default value if empty.
+ */
+ Uint32 AsUint(Uint32 def) const
+ {
+ return m_Attr.as_uint(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a floating point or the specified default value if empty.
+ */
+ SQFloat AsFloat(SQFloat def) const
+ {
+ return (SQFloat)m_Attr.as_float(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a double floating point or the specified default value if empty.
+ */
+ SQFloat AsDouble(SQFloat def) const
+ {
+ return (SQFloat)m_Attr.as_double(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a long integer or the specified default value if empty.
+ */
+ Object AsLong(Object & def) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a unsigned long integer or the specified default value if empty.
+ */
+ Object AsUlong(Object & def) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a boolean or the specified default value if empty.
+ */
+ bool AsBool(bool def) const
+ {
+ return m_Attr.as_bool(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a string.
+ */
+ bool ApplyString(CSStr value)
+ {
+ return m_Attr.set_value(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a integer.
+ */
+ bool ApplyInt(Int32 value)
+ {
+ return m_Attr.set_value(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a unsigned integer.
+ */
+ bool ApplyUint(Uint32 value)
+ {
+ return m_Attr.set_value(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a floating point.
+ */
+ bool ApplyFloat(SQFloat value)
+ {
+ return m_Attr.set_value(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a double floating point.
+ */
+ bool ApplyDouble(SQFloat value)
+ {
+ return m_Attr.set_value(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a long integer.
+ */
+ bool ApplyLong(Object & value);
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a unsigned long integer.
+ */
+ bool ApplyUlong(Object & value);
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a boolean.
+ */
+ bool ApplyBool(bool value)
+ {
+ return m_Attr.set_value(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a string.
+ */
+ CSStr GetString() const
+ {
+ return m_Attr.as_string();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a string.
+ */
+ void SetString(CSStr value)
+ {
+ m_Attr = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a integer.
+ */
+ Int32 GetInt() const
+ {
+ return m_Attr.as_int();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a integer.
+ */
+ void SetInt(Int32 value)
+ {
+ m_Attr = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a unsigned integer.
+ */
+ Uint32 GetUint() const
+ {
+ return m_Attr.as_uint();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a unsigned integer.
+ */
+ void SetUint(Uint32 value)
+ {
+ m_Attr = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a floating point.
+ */
+ SQFloat GetFloat() const
+ {
+ return (SQFloat)m_Attr.as_float();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a floating point.
+ */
+ void SetFloat(SQFloat value)
+ {
+ m_Attr = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a double floating point.
+ */
+ SQFloat GetDouble() const
+ {
+ return (SQFloat)m_Attr.as_double();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a double floating point.
+ */
+ void SetDouble(SQFloat value)
+ {
+ m_Attr = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a long integer.
+ */
+ Object GetLong() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a long integer.
+ */
+ void SetLong(Object & value);
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a unsigned long integer.
+ */
+ Object GetUlong() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a unsigned long integer.
+ */
+ void SetUlong(Object & value);
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a boolean.
+ */
+ bool GetBool() const
+ {
+ return m_Attr.as_bool();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a boolean.
+ */
+ void SetBool(bool value)
+ {
+ m_Attr = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve next attribute in the attribute list of the parent node.
+ */
+ Attribute NextAttribute() const
+ {
+ return Attribute(m_Doc, m_Attr.next_attribute());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve previous attribute in the attribute list of the parent node.
+ */
+ Attribute PrevAttribute() const
+ {
+ return Attribute(m_Doc, m_Attr.previous_attribute());
+ }
+};
+
+} // Namespace:: SqMod
+
+#endif // _XML_ATTRIBUTE_HPP_
\ No newline at end of file
diff --git a/modules/xml/Common.cpp b/modules/xml/Common.cpp
new file mode 100644
index 00000000..443ef459
--- /dev/null
+++ b/modules/xml/Common.cpp
@@ -0,0 +1,25 @@
+// ------------------------------------------------------------------------------------------------
+#include "Common.hpp"
+#include "Module.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+// ------------------------------------------------------------------------------------------------
+bool ParseResult::Validate() const
+{
+ if (m_Doc)
+ return true;
+ // Invalid document reference
+ _SqMod->SqThrow("Invalid XML document reference");
+ return false;
+}
+
+// ------------------------------------------------------------------------------------------------
+void ParseResult::Check() const
+{
+ if (m_Result.status != status_ok)
+ _SqMod->SqThrow("XML parse error [%s]", m_Result.description());
+}
+
+} // Namespace:: SqMod
diff --git a/modules/xml/Common.hpp b/modules/xml/Common.hpp
new file mode 100644
index 00000000..a46954b0
--- /dev/null
+++ b/modules/xml/Common.hpp
@@ -0,0 +1,392 @@
+#ifndef _XML_COMMON_HPP_
+#define _XML_COMMON_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "ModBase.hpp"
+
+// ------------------------------------------------------------------------------------------------
+#include
+
+// ------------------------------------------------------------------------------------------------
+#include
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * SOFTWARE INFORMATION
+*/
+#define SQXML_NAME "Squirrel XML Module"
+#define SQXML_AUTHOR "Sandu Liviu Catalin (S.L.C)"
+#define SQXML_COPYRIGHT "Copyright (C) 2016 Sandu Liviu Catalin"
+#define SQXML_HOST_NAME "SqModXMLHost"
+#define SQXML_VERSION 001
+#define SQXML_VERSION_STR "0.0.1"
+#define SQXML_VERSION_MAJOR 0
+#define SQXML_VERSION_MINOR 0
+#define SQXML_VERSION_PATCH 1
+
+// ------------------------------------------------------------------------------------------------
+using namespace pugi;
+
+// ------------------------------------------------------------------------------------------------
+class Node;
+class Text;
+class Document;
+class Attribute;
+class XPathNode;
+class XPathNodeSet;
+class XPathVariable;
+class XPathVariableSet;
+class XPathVariableQuery;
+
+/* ------------------------------------------------------------------------------------------------
+ * Manages a reference counted xml document instance.
+*/
+class DocumentRef
+{
+ // --------------------------------------------------------------------------------------------
+ friend class Document;
+
+public:
+
+ // --------------------------------------------------------------------------------------------
+ typedef xml_document Type; /* The managed type. */
+
+ // --------------------------------------------------------------------------------------------
+ typedef Type* Pointer; /* Pointer to the managed type. */
+ typedef const Type* ConstPtr; /* Constant pointer to the managed type. */
+
+ // --------------------------------------------------------------------------------------------
+ typedef Type& Reference; /* Reference to the managed type. */
+ typedef const Type& ConstRef; /* Constant reference to the managed type. */
+
+ // --------------------------------------------------------------------------------------------
+ typedef unsigned int Counter; /* Reference counter type. */
+
+private:
+
+ // --------------------------------------------------------------------------------------------
+ Pointer m_Ptr; /* The document reader, writer and manager instance. */
+ Counter* m_Ref; /* Reference count to the managed instance. */
+
+ /* --------------------------------------------------------------------------------------------
+ * Grab a strong reference to a document instance.
+ */
+ void Grab()
+ {
+ if (m_Ptr)
+ ++(*m_Ref);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Drop a strong reference to a document instance.
+ */
+ void Drop()
+ {
+ if (m_Ptr && --(*m_Ref) == 0)
+ {
+ delete m_Ptr;
+ delete m_Ref;
+ m_Ptr = NULL;
+ m_Ref = NULL;
+ }
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Base constructor.
+ */
+ DocumentRef(VoidP /* unused */)
+ : m_Ptr(new Type())
+ , m_Ref(new Counter(1))
+ {
+ /* ... */
+ }
+
+public:
+
+ /* --------------------------------------------------------------------------------------------
+ * Default constructor (null).
+ */
+ DocumentRef()
+ : m_Ptr(NULL), m_Ref(NULL)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy constructor.
+ */
+ DocumentRef(const DocumentRef & o)
+ : m_Ptr(o.m_Ptr), m_Ref(o.m_Ref)
+
+ {
+ Grab();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Destructor.
+ */
+ ~DocumentRef()
+ {
+ Drop();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy assignment operator.
+ */
+ DocumentRef & operator = (const DocumentRef & o)
+ {
+ if (m_Ptr != o.m_Ptr)
+ {
+ Drop();
+ m_Ptr = o.m_Ptr;
+ m_Ref = o.m_Ref;
+ Grab();
+ }
+ return *this;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Perform an equality comparison between two document instances.
+ */
+ bool operator == (const DocumentRef & o) const
+ {
+ return (m_Ptr == o.m_Ptr);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Perform an inequality comparison between two document instances.
+ */
+ bool operator != (const DocumentRef & o) const
+ {
+ return (m_Ptr != o.m_Ptr);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Implicit conversion to boolean for use in boolean operations.
+ */
+ operator bool () const
+ {
+ return m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Implicit conversion to the managed instance pointer.
+ */
+ operator Pointer ()
+ {
+ return m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Implicit conversion to the managed instance pointer.
+ */
+ operator ConstPtr () const
+ {
+ return m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Implicit conversion to the managed instance reference.
+ */
+ operator Reference ()
+ {
+ assert(m_Ptr);
+ return *m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Implicit conversion to the managed instance reference.
+ */
+ operator ConstRef () const
+ {
+ assert(m_Ptr);
+ return *m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Member operator for dereferencing the managed pointer.
+ */
+ Pointer operator -> () const
+ {
+ assert(m_Ptr != NULL);
+ return m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Indirection operator for obtaining a reference of the managed pointer.
+ */
+ Reference operator * () const
+ {
+ assert(m_Ptr != NULL);
+ return *m_Ptr;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the number of active references to the managed instance.
+ */
+ Counter Count() const
+ {
+ return (m_Ptr && m_Ref) ? (*m_Ref) : 0;
+ }
+};
+
+/* ------------------------------------------------------------------------------------------------
+ * Allows the user to inspect the result of certain operations and act accordingly.
+*/
+class ParseResult
+{
+ // --------------------------------------------------------------------------------------------
+ friend class Document;
+ friend class Node;
+
+protected:
+
+ // --------------------------------------------------------------------------------------------
+ typedef xml_parse_result Result;
+
+ /* --------------------------------------------------------------------------------------------
+ * Explicit constructor.
+ */
+ ParseResult(const DocumentRef doc, const Result & result)
+ : m_Doc(doc), m_Result(result)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Validate the document reference and throw an error if invalid.
+ */
+ bool Validate() const;
+
+private:
+
+ // ---------------------------------------------------------------------------------------------
+ DocumentRef m_Doc; /* The main xml document instance. */
+ Result m_Result; /* The managed parse result. */
+
+public:
+
+ /* --------------------------------------------------------------------------------------------
+ * Default constructor.
+ */
+ ParseResult()
+ : m_Doc(), m_Result()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy constructor. (disabled)
+ */
+ ParseResult(const ParseResult & o)
+ : m_Doc(o.m_Doc), m_Result(o.m_Result)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Destructor.
+ */
+ ~ParseResult()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy assignment operator. (disabled)
+ */
+ ParseResult & operator = (const ParseResult & o)
+ {
+ m_Doc = o.m_Doc;
+ m_Result = o.m_Result;
+ return *this;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to compare two instances of this type.
+ */
+ Int32 Cmp(const ParseResult & o)
+ {
+ if (m_Result.status == o.m_Result.status)
+ return 0;
+ else if (m_Result.status > o.m_Result.status)
+ return 1;
+ else
+ return -1;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to convert an instance of this type to a string.
+ */
+ CSStr ToString() const
+ {
+ return m_Result.description();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether this instance references a valid xml document.
+ */
+ bool IsValid() const
+ {
+ return m_Doc;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Return the number of active references to this document instance.
+ */
+ Uint32 GetRefCount() const
+ {
+ return m_Doc.Count();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Cast to bool operator.
+ */
+ bool IsOk() const
+ {
+ return m_Result;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Parsing status code.
+ */
+ Int32 GetStatus() const
+ {
+ return (Int32)m_Result.status;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Last parsed offset. (in char_t units from start of input data)
+ */
+ SQInteger GetOffset() const
+ {
+ return (SQInteger)m_Result.offset;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Source document encoding.
+ */
+ Int32 GetEncoding() const
+ {
+ return m_Result.encoding;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve error description as a string.
+ */
+ CSStr GetDescription() const
+ {
+ return m_Result.description();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Check the parse result and throw the necessary errors.
+ */
+ void Check() const;
+};
+
+} // Namespace:: SqMod
+
+#endif // _XML_COMMON_HPP_
diff --git a/modules/xml/Document.cpp b/modules/xml/Document.cpp
new file mode 100644
index 00000000..179a9e9a
--- /dev/null
+++ b/modules/xml/Document.cpp
@@ -0,0 +1,41 @@
+// ------------------------------------------------------------------------------------------------
+#include "Document.hpp"
+#include "Node.hpp"
+#include "Module.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+// ------------------------------------------------------------------------------------------------
+bool Document::Validate() const
+{
+ if (m_Doc)
+ return true;
+ // Invalid document reference
+ _SqMod->SqThrow("Invalid XML document reference");
+ return false;
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Document::CanLoad() const
+{
+ // Is the document even valid?
+ if (!Validate())
+ return false;
+ // Are there any other references?
+ else if (m_Doc.Count() == 1)
+ return true;
+ // To load new values now, would mean to cause undefined behavior in existing references
+ _SqMod->SqThrow("Loading is disabled while document is referenced");
+ return false;
+}
+
+// ------------------------------------------------------------------------------------------------
+Node Document::GetNode() const
+{
+ if (m_Doc)
+ return Node(m_Doc, m_Doc->document_element());
+ return Node();
+}
+
+} // Namespace:: SqMod
\ No newline at end of file
diff --git a/modules/xml/Document.hpp b/modules/xml/Document.hpp
new file mode 100644
index 00000000..d1dac15d
--- /dev/null
+++ b/modules/xml/Document.hpp
@@ -0,0 +1,221 @@
+#ifndef _XML_DOCUMENT_HPP_
+#define _XML_DOCUMENT_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "Common.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * Class that can read/write and alter the contents of XML files.
+*/
+class Document
+{
+protected:
+
+ // --------------------------------------------------------------------------------------------
+ typedef xml_document Type;
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy constructor. (disabled)
+ */
+ Document(const Document & o);
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy assignment operator. (disabled)
+ */
+ Document & operator = (const Document & o);
+
+ /* --------------------------------------------------------------------------------------------
+ * Validate the document reference and throw an error if invalid.
+ */
+ bool Validate() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * See if the document is allowed to overwrite its contents and throw an error if not.
+ */
+ bool CanLoad() const;
+
+private:
+
+ // ---------------------------------------------------------------------------------------------
+ DocumentRef m_Doc; /* The main xml document instance. */
+
+public:
+
+ /* --------------------------------------------------------------------------------------------
+ * Default constructor.
+ */
+ Document()
+ : m_Doc(NULL)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Destructor.
+ */
+ ~Document()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to compare two instances of this type.
+ */
+ Int32 Cmp(const Document & o) const
+ {
+ if (m_Doc && !o.m_Doc)
+ return 1;
+ else if (!m_Doc && o.m_Doc)
+ return -1;
+ else if (!m_Doc && !o.m_Doc)
+ return 0;
+ else if (*m_Doc == *o.m_Doc)
+ return 0;
+ else if (*m_Doc > *o.m_Doc)
+ return 1;
+ else
+ return -1;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to convert an instance of this type to a string.
+ */
+ CSStr ToString() const
+ {
+ if (m_Doc)
+ return m_Doc->name();
+ return _SC("");
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether this instance references a valid xml document.
+ */
+ bool IsValid() const
+ {
+ return m_Doc;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Return the number of active references to this document instance.
+ */
+ Uint32 GetRefCount() const
+ {
+ return m_Doc ? *(m_Doc.m_Ref) : 0;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Removes all nodes, leaving the empty document.
+ */
+ void Reset()
+ {
+ if (Validate())
+ m_Doc->reset();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Removes all nodes, then copies the entire contents of the specified document.
+ */
+ void Reset(const Document & doc)
+ {
+ if (Validate() && doc.Validate())
+ m_Doc->reset(*doc.m_Doc);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Load document from zero-terminated string. (LoadString collides with the windows api)
+ */
+ ParseResult LoadData(CSStr source)
+ {
+ if (CanLoad())
+ return ParseResult(m_Doc, m_Doc->load_string(source));
+ return ParseResult();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Load document from zero-terminated string. (LoadString collides with the windows api)
+ */
+ ParseResult LoadData(CSStr source, Uint32 options)
+ {
+ if (CanLoad())
+ return ParseResult(m_Doc, m_Doc->load_string(source, options));
+ return ParseResult();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Load document from file on disk.
+ */
+ ParseResult LoadFile(CSStr filepath)
+ {
+ if (CanLoad())
+ return ParseResult(m_Doc, m_Doc->load_file(filepath));
+ return ParseResult();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Load document from file on disk.
+ */
+ ParseResult LoadFile(CSStr filepath, Uint32 options)
+ {
+ if (CanLoad())
+ return ParseResult(m_Doc, m_Doc->load_file(filepath, options));
+ return ParseResult();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Load document from file on disk.
+ */
+ ParseResult LoadFile(CSStr filepath, Uint32 options, Int32 encoding)
+ {
+ if (CanLoad())
+ return ParseResult(m_Doc, m_Doc->load_file(filepath, options, (xml_encoding)encoding));
+ return ParseResult();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Save XML to file on disk.
+ */
+ void SaveFile(CSStr filepath)
+ {
+ if (Validate())
+ m_Doc->save_file(filepath);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Save XML to file on disk.
+ */
+ void SaveFile(CSStr filepath, CSStr indent)
+ {
+ if (Validate())
+ m_Doc->save_file(filepath, indent);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Save XML to file on disk.
+ */
+ void SaveFile(CSStr filepath, CSStr indent, Uint32 format)
+ {
+ if (Validate())
+ m_Doc->save_file(filepath, indent, format);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Save XML to file on disk.
+ */
+ void SaveFile(CSStr filepath, CSStr indent, Uint32 format, Int32 encoding)
+ {
+ if (Validate())
+ m_Doc->save_file(filepath, indent, format, (xml_encoding)encoding);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the document root node.
+ */
+ Node GetNode() const;
+};
+
+} // Namespace:: SqMod
+
+#endif // _XML_DOCUMENT_HPP_
diff --git a/modules/xml/Module.cpp b/modules/xml/Module.cpp
new file mode 100644
index 00000000..1df6078e
--- /dev/null
+++ b/modules/xml/Module.cpp
@@ -0,0 +1,592 @@
+// --------------------------------------------------------------------------------------------
+#include "Module.hpp"
+#include "Common.hpp"
+#include "Attribute.hpp"
+#include "Text.hpp"
+#include "Node.hpp"
+#include "Document.hpp"
+
+// --------------------------------------------------------------------------------------------
+#include
+
+// --------------------------------------------------------------------------------------------
+#include
+#include
+#include
+
+// --------------------------------------------------------------------------------------------
+#if defined(WIN32) || defined(_WIN32)
+ #include
+#endif
+
+namespace SqMod {
+
+// --------------------------------------------------------------------------------------------
+PluginFuncs* _Func = NULL;
+PluginCallbacks* _Clbk = NULL;
+PluginInfo* _Info = NULL;
+
+// --------------------------------------------------------------------------------------------
+HSQAPI _SqAPI = NULL;
+HSQEXPORTS _SqMod = NULL;
+HSQUIRRELVM _SqVM = NULL;
+
+/* ------------------------------------------------------------------------------------------------
+ * Bind speciffic functions to certain server events.
+*/
+void BindCallbacks();
+
+/* ------------------------------------------------------------------------------------------------
+ * Undo changes made with BindCallbacks().
+*/
+void UnbindCallbacks();
+
+/* --------------------------------------------------------------------------------------------
+ * Register the module API under the specified virtual machine.
+*/
+void RegisterAPI(HSQUIRRELVM vm);
+
+/* --------------------------------------------------------------------------------------------
+ * Initialize the plugin by obtaining the API provided by the host plugin.
+*/
+void OnSquirrelInitialize()
+{
+ // Attempt to import the plugin API exported by the host plugin
+ _SqMod = sq_api_import(_Func);
+ // Did we failed to obtain the plugin exports?
+ if(!_SqMod)
+ OutputError("Failed to attach [%s] on host plugin.", SQXML_NAME);
+ else
+ {
+ // Obtain the Squirrel API
+ _SqAPI = _SqMod->GetSquirrelAPI();
+ // Expand the Squirrel API into global functions
+ sq_api_expand(_SqAPI);
+ }
+}
+
+/* --------------------------------------------------------------------------------------------
+ * Load the module on the virtual machine provided by the host module.
+*/
+void OnSquirrelLoad()
+{
+ // Make sure that we have a valid plugin API
+ if (!_SqMod)
+ return; /* Unable to proceed. */
+ // Obtain the Squirrel API and VM
+ _SqVM = _SqMod->GetSquirrelVM();
+ // Make sure that a valid virtual machine exists
+ if (!_SqVM)
+ return; /* Unable to proceed. */
+ // Set this as the default database
+ DefaultVM::Set(_SqVM);
+ // Register the module API
+ RegisterAPI(_SqVM);
+ // Notify about the current status
+ OutputMessage("Registered: %s", SQXML_NAME);
+}
+
+/* --------------------------------------------------------------------------------------------
+ * The virtual machine is about to be terminated and script resources should be released.
+*/
+void OnSquirrelTerminate()
+{
+ OutputMessage("Terminating: %s", SQXML_NAME);
+ // Release the current database (if any)
+ DefaultVM::Set(NULL);
+}
+
+/* --------------------------------------------------------------------------------------------
+ * Validate the module API to make sure we don't run into issues.
+*/
+bool CheckAPIVer(CCStr ver)
+{
+ // Obtain the numeric representation of the API version
+ long vernum = strtol(ver, NULL, 10);
+ // Check against version mismatch
+ if (vernum == SQMOD_API_VER)
+ return true;
+ // Log the incident
+ OutputError("API version mismatch on %s", SQXML_NAME);
+ OutputMessage("=> Requested: %ld Have: %ld", vernum, SQMOD_API_VER);
+ // Invoker should not attempt to communicate through the module API
+ return false;
+}
+
+/* --------------------------------------------------------------------------------------------
+ * React to command sent by other plugins.
+*/
+static int OnInternalCommand(unsigned int type, const char * text)
+{
+ switch(type)
+ {
+ case SQMOD_INITIALIZE_CMD:
+ if (CheckAPIVer(text))
+ OnSquirrelInitialize();
+ break;
+ case SQMOD_LOAD_CMD:
+ OnSquirrelLoad();
+ break;
+ case SQMOD_TERMINATE_CMD:
+ OnSquirrelTerminate();
+ break;
+ default: break;
+ }
+ return 1;
+}
+
+/* --------------------------------------------------------------------------------------------
+ * The server was initialized and this plugin was loaded successfully.
+*/
+static int OnInitServer()
+{
+ return 1;
+}
+
+static void OnShutdownServer(void)
+{
+ // The server may still send callbacks
+ UnbindCallbacks();
+}
+
+// ------------------------------------------------------------------------------------------------
+void BindCallbacks()
+{
+ _Clbk->OnInitServer = OnInitServer;
+ _Clbk->OnInternalCommand = OnInternalCommand;
+ _Clbk->OnShutdownServer = OnShutdownServer;
+}
+
+// ------------------------------------------------------------------------------------------------
+void UnbindCallbacks()
+{
+ _Clbk->OnInitServer = NULL;
+ _Clbk->OnInternalCommand = NULL;
+ _Clbk->OnShutdownServer = NULL;
+}
+
+// --------------------------------------------------------------------------------------------
+void RegisterAPI(HSQUIRRELVM vm)
+{
+ Table xmlns(vm);
+
+ xmlns.Bind(_SC("ParseResult"), Class< ParseResult >(vm, _SC("SqXmlParseResult"))
+ /* Constructors */
+ .Ctor()
+ .Ctor< const ParseResult & >()
+ /* Core Metamethods */
+ .Func(_SC("_cmp"), &ParseResult::Cmp)
+ .Func(_SC("_tostring"), &ParseResult::ToString)
+ /* Properties */
+ .Prop(_SC("Valid"), &ParseResult::IsValid)
+ .Prop(_SC("References"), &ParseResult::GetRefCount)
+ .Prop(_SC("Ok"), &ParseResult::IsOk)
+ .Prop(_SC("Status"), &ParseResult::GetStatus)
+ .Prop(_SC("Offset"), &ParseResult::GetOffset)
+ .Prop(_SC("Encoding"), &ParseResult::GetEncoding)
+ .Prop(_SC("Description"), &ParseResult::GetDescription)
+ /* Functions */
+ .Func(_SC("Check"), &ParseResult::Check)
+ );
+
+ xmlns.Bind(_SC("Attribute"), Class< Attribute >(vm, _SC("SqXmlAttribute"))
+ /* Constructors */
+ .Ctor()
+ .Ctor< const Attribute & >()
+ /* Core Metamethods */
+ .Func(_SC("_cmp"), &Attribute::Cmp)
+ .Func(_SC("_tostring"), &Attribute::ToString)
+ /* Properties */
+ .Prop(_SC("Valid"), &Attribute::IsValid)
+ .Prop(_SC("References"), &Attribute::GetRefCount)
+ .Prop(_SC("Empty"), &Attribute::IsEmpty)
+ .Prop(_SC("Hash"), &Attribute::GetHashValue)
+ .Prop(_SC("Name"), &Attribute::GetName, &Attribute::SetName)
+ .Prop(_SC("Value"), &Attribute::GetValue, &Attribute::SetValue)
+ .Prop(_SC("Int"), &Attribute::GetInt, &Attribute::SetInt)
+ .Prop(_SC("Uint"), &Attribute::GetUint, &Attribute::SetUint)
+ .Prop(_SC("Float"), &Attribute::GetFloat, &Attribute::SetFloat)
+ .Prop(_SC("Double"), &Attribute::GetDouble, &Attribute::SetDouble)
+ .Prop(_SC("Long"), &Attribute::GetLong, &Attribute::SetLong)
+ .Prop(_SC("Ulong"), &Attribute::GetUlong, &Attribute::SetUlong)
+ .Prop(_SC("Bool"), &Attribute::GetBool, &Attribute::SetBool)
+ .Prop(_SC("Next"), &Attribute::NextAttribute)
+ .Prop(_SC("Prev"), &Attribute::PrevAttribute)
+ /* Functions */
+ .Func(_SC("SetName"), &Attribute::ApplyName)
+ .Func(_SC("SetValue"), &Attribute::ApplyValue)
+ .Func(_SC("AsString"), &Attribute::AsString)
+ .Func(_SC("AsInt"), &Attribute::AsInt)
+ .Func(_SC("AsUint"), &Attribute::AsUint)
+ .Func(_SC("AsFloat"), &Attribute::AsFloat)
+ .Func(_SC("AsDouble"), &Attribute::AsDouble)
+ .Func(_SC("AsLong"), &Attribute::AsLong)
+ .Func(_SC("AsUlong"), &Attribute::AsUlong)
+ .Func(_SC("AsBool"), &Attribute::AsBool)
+ .Func(_SC("SetString"), &Attribute::ApplyString)
+ .Func(_SC("SetInt"), &Attribute::ApplyInt)
+ .Func(_SC("SetUint"), &Attribute::ApplyUint)
+ .Func(_SC("SetFloat"), &Attribute::ApplyFloat)
+ .Func(_SC("SetDouble"), &Attribute::ApplyDouble)
+ .Func(_SC("SetLong"), &Attribute::ApplyLong)
+ .Func(_SC("SetUlong"), &Attribute::ApplyUlong)
+ .Func(_SC("SetBool"), &Attribute::ApplyBool)
+ );
+
+ xmlns.Bind(_SC("Text"), Class< Text >(vm, _SC("SqXmlText"))
+ /* Constructors */
+ .Ctor()
+ .Ctor< const Text & >()
+ /* Core Metamethods */
+ .Func(_SC("_cmp"), &Text::Cmp)
+ .Func(_SC("_tostring"), &Text::ToString)
+ /* Properties */
+ .Prop(_SC("Valid"), &Text::IsValid)
+ .Prop(_SC("References"), &Text::GetRefCount)
+ .Prop(_SC("Empty"), &Text::IsEmpty)
+ .Prop(_SC("Value"), &Text::GetValue)
+ .Prop(_SC("Int"), &Text::GetInt, &Text::SetInt)
+ .Prop(_SC("Uint"), &Text::GetUint, &Text::SetUint)
+ .Prop(_SC("Float"), &Text::GetFloat, &Text::SetFloat)
+ .Prop(_SC("Double"), &Text::GetDouble, &Text::SetDouble)
+ .Prop(_SC("Long"), &Text::GetLong, &Text::SetLong)
+ .Prop(_SC("Ulong"), &Text::GetUlong, &Text::SetUlong)
+ .Prop(_SC("Bool"), &Text::GetBool, &Text::SetBool)
+ .Prop(_SC("Data"), &Text::GetData)
+ /* Functions */
+ .Func(_SC("AsString"), &Text::AsString)
+ .Func(_SC("AsInt"), &Text::AsInt)
+ .Func(_SC("AsUint"), &Text::AsUint)
+ .Func(_SC("AsFloat"), &Text::AsFloat)
+ .Func(_SC("AsDouble"), &Text::AsDouble)
+ .Func(_SC("AsLong"), &Text::AsLong)
+ .Func(_SC("AsUlong"), &Text::AsUlong)
+ .Func(_SC("AsBool"), &Text::AsBool)
+ .Func(_SC("SetString"), &Text::ApplyString)
+ .Func(_SC("SetInt"), &Text::ApplyInt)
+ .Func(_SC("SetUint"), &Text::ApplyUint)
+ .Func(_SC("SetFloat"), &Text::ApplyFloat)
+ .Func(_SC("SetDouble"), &Text::ApplyDouble)
+ .Func(_SC("SetLong"), &Text::ApplyLong)
+ .Func(_SC("SetUlong"), &Text::ApplyUlong)
+ .Func(_SC("SetBool"), &Text::ApplyBool)
+ );
+
+ xmlns.Bind(_SC("Node"), Class< Node >(vm, _SC("SqXmlNode"))
+ /* Constructors */
+ .Ctor()
+ .Ctor< const Node & >()
+ /* Core Metamethods */
+ .Func(_SC("_cmp"), &Node::Cmp)
+ .Func(_SC("_tostring"), &Node::ToString)
+ /* Properties */
+ .Prop(_SC("Valid"), &Node::IsValid)
+ .Prop(_SC("References"), &Node::GetRefCount)
+ .Prop(_SC("Empty"), &Node::IsEmpty)
+ .Prop(_SC("Hash"), &Node::GetHashValue)
+ .Prop(_SC("OffsetDebug"), &Node::GetOffsetDebug)
+ .Prop(_SC("Type"), &Node::GetType)
+ .Prop(_SC("Name"), &Node::GetName, &Node::SetName)
+ .Prop(_SC("Value"), &Node::GetValue, &Node::SetValue)
+ .Prop(_SC("FirstAttr"), &Node::GetFirstAttr)
+ .Prop(_SC("LastAttr"), &Node::GetLastAttr)
+ .Prop(_SC("FirstChild"), &Node::GetFirstChild)
+ .Prop(_SC("LastChild"), &Node::GetLastChild)
+ .Prop(_SC("NextSibling"), &Node::GetNextSibling)
+ .Prop(_SC("PrevSibling"), &Node::GetPrevSibling)
+ .Prop(_SC("Parent"), &Node::GetParent)
+ .Prop(_SC("Root"), &Node::GetRoot)
+ .Prop(_SC("Text"), &Node::GetText)
+ .Prop(_SC("ChildValue"), &Node::GetChildValue)
+ /* Functions */
+ .Overload< ParseResult (Node::*)(CSStr) >(_SC("AppendBuffer"), &Node::AppendBuffer)
+ .Overload< ParseResult (Node::*)(CSStr, Uint32) >(_SC("AppendBuffer"), &Node::AppendBuffer)
+ .Overload< ParseResult (Node::*)(CSStr, Uint32, Int32) >(_SC("AppendBuffer"), &Node::AppendBuffer)
+ .Func(_SC("SetName"), &Node::ApplyName)
+ .Func(_SC("SetValue"), &Node::ApplyValue)
+ .Func(_SC("GetChild"), &Node::Child)
+ .Func(_SC("GetAttr"), &Node::GetAttribute)
+ .Func(_SC("GetAttribute"), &Node::GetAttribute)
+ .Func(_SC("GetAttrFrom"), &Node::AttributeFrom)
+ .Func(_SC("GetAttributeFrom"), &Node::AttributeFrom)
+ .Func(_SC("GetNextSibling"), &Node::NextSibling)
+ .Func(_SC("GetPrevSibling"), &Node::PrevSibling)
+ .Func(_SC("GetChildValue"), &Node::ChildValue)
+ .Func(_SC("AppendAttr"), &Node::AppendAttr)
+ .Func(_SC("PrependAttr"), &Node::PrependAttr)
+ .Func(_SC("InsertAttrAfter"), &Node::InsertAttrAfter)
+ .Func(_SC("InsertAttrBefore"), &Node::InsertAttrBefore)
+ .Func(_SC("AppendAttrCopy"), &Node::AppendAttrCopy)
+ .Func(_SC("PrependAttrCopy"), &Node::PrependAttrCopy)
+ .Func(_SC("InsertAttrCopyAfter"), &Node::InsertAttrCopyAfter)
+ .Func(_SC("InsertAttrCopyBefore"), &Node::InsertAttrCopyBefore)
+ .Func(_SC("AppendChild"), &Node::AppendChild)
+ .Func(_SC("PrependChild"), &Node::PrependChild)
+ .Func(_SC("AppendChildNode"), &Node::AppendChildNode)
+ .Func(_SC("PrependChildNode"), &Node::PrependChildNode)
+ .Func(_SC("AppendChildType"), &Node::AppendChildType)
+ .Func(_SC("PrependChildType"), &Node::PrependChildType)
+ .Func(_SC("InsertChildAfter"), &Node::InsertChildAfter)
+ .Func(_SC("InsertChildBefore"), &Node::InsertChildBefore)
+ .Func(_SC("InsertChildTypeAfter"), &Node::InsertChildTypeAfter)
+ .Func(_SC("InsertChildTypeBefore"), &Node::InsertChildTypeBefore)
+ .Func(_SC("AppendCopy"), &Node::AppendCopy)
+ .Func(_SC("PrependCopy"), &Node::PrependCopy)
+ .Func(_SC("InsertCopyAfter"), &Node::InsertCopyAfter)
+ .Func(_SC("InsertCopyBefore"), &Node::InsertCopyBefore)
+ .Func(_SC("AppendMove"), &Node::AppendMove)
+ .Func(_SC("PrependMove"), &Node::PrependMove)
+ .Func(_SC("InsertMoveAfter"), &Node::InsertMoveAfter)
+ .Func(_SC("InsertMoveBefore"), &Node::InsertMoveBefore)
+ .Func(_SC("RemoveAttr"), &Node::RemoveAttr)
+ .Func(_SC("RemoveAttrInst"), &Node::RemoveAttrInst)
+ .Func(_SC("RemoveChild"), &Node::RemoveChild)
+ .Func(_SC("RemoveChildInst"), &Node::RemoveChildInst)
+ .Overload< Node (Node::*)(CSStr, CSStr) const >(_SC("FindChildByAttr"), &Node::FindChildByAttr)
+ .Overload< Node (Node::*)(CSStr, CSStr, CSStr) const >(_SC("FindChildByAttr"), &Node::FindChildByAttr)
+ .Func(_SC("FindElemByPath"), &Node::FindElemByPath)
+ );
+
+ xmlns.Bind(_SC("Document"), Class< Document, NoCopy< Document > >(vm, _SC("SqXmlDocument"))
+ /* Constructors */
+ .Ctor()
+ /* Core Metamethods */
+ .Func(_SC("_cmp"), &Document::Cmp)
+ .Func(_SC("_tostring"), &Document::ToString)
+ /* Properties */
+ .Prop(_SC("Valid"), &Document::IsValid)
+ .Prop(_SC("References"), &Document::GetRefCount)
+ .Prop(_SC("Node"), &Document::GetNode)
+ /* Functions */
+ .Overload< void (Document::*)(void) >(_SC("Reset"), &Document::Reset)
+ .Overload< void (Document::*)(const Document &) >(_SC("Reset"), &Document::Reset)
+ .Overload< ParseResult (Document::*)(CSStr) >(_SC("LoadString"), &Document::LoadData)
+ .Overload< ParseResult (Document::*)(CSStr, Uint32) >(_SC("LoadString"), &Document::LoadData)
+ .Overload< ParseResult (Document::*)(CSStr) >(_SC("LoadFile"), &Document::LoadFile)
+ .Overload< ParseResult (Document::*)(CSStr, Uint32) >(_SC("LoadFile"), &Document::LoadFile)
+ .Overload< ParseResult (Document::*)(CSStr, Uint32, Int32) >(_SC("LoadFile"), &Document::LoadFile)
+ .Overload< void (Document::*)(CSStr) >(_SC("SaveFile"), &Document::SaveFile)
+ .Overload< void (Document::*)(CSStr, CSStr) >(_SC("SaveFile"), &Document::SaveFile)
+ .Overload< void (Document::*)(CSStr, CSStr, Uint32) >(_SC("SaveFile"), &Document::SaveFile)
+ .Overload< void (Document::*)(CSStr, CSStr, Uint32, Int32) >(_SC("SaveFile"), &Document::SaveFile)
+ );
+
+ RootTable(vm).Bind(_SC("SqXml"), xmlns);
+
+ ConstTable(vm).Enum(_SC("SqXmlNodeType"), Enumeration(vm)
+ .Const(_SC("Null"), Int32(node_null))
+ .Const(_SC("Document"), Int32(node_document))
+ .Const(_SC("Element"), Int32(node_element))
+ .Const(_SC("PCData"), Int32(node_pcdata))
+ .Const(_SC("CData"), Int32(node_cdata))
+ .Const(_SC("Comment"), Int32(node_comment))
+ .Const(_SC("Pi"), Int32(node_pi))
+ .Const(_SC("Declaration"), Int32(node_declaration))
+ .Const(_SC("Doctype"), Int32(node_doctype))
+ );
+
+ ConstTable(vm).Enum(_SC("SqXmlParse"), Enumeration(vm)
+ .Const(_SC("Minimal"), Int32(parse_minimal))
+ .Const(_SC("Default"), Int32(parse_default))
+ .Const(_SC("Full"), Int32(parse_full))
+ .Const(_SC("Pi"), Int32(parse_pi))
+ .Const(_SC("Comments"), Int32(parse_comments))
+ .Const(_SC("CData"), Int32(parse_cdata))
+ .Const(_SC("WSPCData"), Int32(parse_ws_pcdata))
+ .Const(_SC("Escapes"), Int32(parse_escapes))
+ .Const(_SC("EOL"), Int32(parse_eol))
+ .Const(_SC("WConvAttribute"), Int32(parse_wconv_attribute))
+ .Const(_SC("WNormAttribute"), Int32(parse_wnorm_attribute))
+ .Const(_SC("Declaration"), Int32(parse_declaration))
+ .Const(_SC("Doctype"), Int32(parse_doctype))
+ .Const(_SC("WSPCDataSingle"), Int32(parse_ws_pcdata_single))
+ .Const(_SC("TrimPCData"), Int32(parse_trim_pcdata))
+ .Const(_SC("Fragment"), Int32(parse_fragment))
+ .Const(_SC("EmbedPCData"), Int32(parse_embed_pcdata))
+ );
+
+ ConstTable(vm).Enum(_SC("SqXmlEncoding"), Enumeration(vm)
+ .Const(_SC("Auto"), Int32(encoding_auto))
+ .Const(_SC("Utf8"), Int32(encoding_utf8))
+ .Const(_SC("Utf16LE"), Int32(encoding_utf16_le))
+ .Const(_SC("Utf16BE"), Int32(encoding_utf16_be))
+ .Const(_SC("Utf16"), Int32(encoding_utf16))
+ .Const(_SC("Utf32LE"), Int32(encoding_utf32_le))
+ .Const(_SC("Utf32BE"), Int32(encoding_utf32_be))
+ .Const(_SC("Utf32"), Int32(encoding_utf32))
+ .Const(_SC("WChar"), Int32(encoding_wchar))
+ .Const(_SC("Latin1"), Int32(encoding_latin1))
+ );
+
+ ConstTable(vm).Enum(_SC("SqXmlFormat"), Enumeration(vm)
+ .Const(_SC("Indent"), Int32(format_indent))
+ .Const(_SC("WriteBOM"), Int32(format_write_bom))
+ .Const(_SC("Raw"), Int32(format_raw))
+ .Const(_SC("NoDeclaration"), Int32(format_no_declaration))
+ .Const(_SC("NoEscapes"), Int32(format_no_escapes))
+ .Const(_SC("SaveFileText"), Int32(format_save_file_text))
+ .Const(_SC("IndentAttributes"), Int32(format_indent_attributes))
+ .Const(_SC("Default"), Int32(format_default))
+ );
+
+ ConstTable(vm).Enum(_SC("SqXmlParseStatus"), Enumeration(vm)
+ .Const(_SC("Ok"), Int32(status_ok))
+ .Const(_SC("FileNotFound"), Int32(status_file_not_found))
+ .Const(_SC("IOError"), Int32(status_io_error))
+ .Const(_SC("OutOfMemory"), Int32(status_out_of_memory))
+ .Const(_SC("InternalError"), Int32(status_internal_error))
+ .Const(_SC("UnrecognizedTag"), Int32(status_unrecognized_tag))
+ .Const(_SC("BadPi"), Int32(status_bad_pi))
+ .Const(_SC("BadComment"), Int32(status_bad_comment))
+ .Const(_SC("BadCData"), Int32(status_bad_cdata))
+ .Const(_SC("BadDoctype"), Int32(status_bad_doctype))
+ .Const(_SC("BadPCData"), Int32(status_bad_pcdata))
+ .Const(_SC("BadStartElement"), Int32(status_bad_start_element))
+ .Const(_SC("BadAttribute"), Int32(status_bad_attribute))
+ .Const(_SC("BadEndElement"), Int32(status_bad_end_element))
+ .Const(_SC("EndElementMismatch"), Int32(status_end_element_mismatch))
+ .Const(_SC("AppendInvalidRoot"), Int32(status_append_invalid_root))
+ .Const(_SC("NoDocumentElement"), Int32(status_no_document_element))
+ );
+
+ ConstTable(vm).Enum(_SC("SqXmlXpathValueType"), Enumeration(vm)
+ .Const(_SC("None"), Int32(xpath_type_none))
+ .Const(_SC("NodeSet"), Int32(xpath_type_node_set))
+ .Const(_SC("Number"), Int32(xpath_type_number))
+ .Const(_SC("String"), Int32(xpath_type_string))
+ .Const(_SC("Boolean"), Int32(xpath_type_boolean))
+ );
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputMessageImpl(const char * msg, va_list args)
+{
+#if defined(WIN32) || defined(_WIN32)
+ HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ CONSOLE_SCREEN_BUFFER_INFO csb_before;
+ GetConsoleScreenBufferInfo( hstdout, &csb_before);
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN);
+ printf("[SQMOD] ");
+
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
+ vprintf(msg, args);
+ puts("");
+
+ SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
+#else
+ printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27, msg);
+ vprintf(msg, args);
+ puts("");
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputErrorImpl(const char * msg, va_list args)
+{
+#if defined(WIN32) || defined(_WIN32)
+ HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ CONSOLE_SCREEN_BUFFER_INFO csb_before;
+ GetConsoleScreenBufferInfo( hstdout, &csb_before);
+ SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
+ printf("[SQMOD] ");
+
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
+ vprintf(msg, args);
+ puts("");
+
+ SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
+#else
+ printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27, msg);
+ vprintf(msg, args);
+ puts("");
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputDebug(const char * msg, ...)
+{
+#ifdef _DEBUG
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputMessageImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+#else
+ SQMOD_UNUSED_VAR(msg);
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputMessage(const char * msg, ...)
+{
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputMessageImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputError(const char * msg, ...)
+{
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputErrorImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+}
+
+} // Namespace:: SqMod
+
+// --------------------------------------------------------------------------------------------
+SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallbacks* callbacks, PluginInfo* info)
+{
+ using namespace SqMod;
+ // Output plugin header
+ puts("");
+ OutputMessage("--------------------------------------------------------------------");
+ OutputMessage("Plugin: %s", SQXML_NAME);
+ OutputMessage("Author: %s", SQXML_AUTHOR);
+ OutputMessage("Legal: %s", SQXML_COPYRIGHT);
+ OutputMessage("--------------------------------------------------------------------");
+ puts("");
+ // Attempt to find the host plugin ID
+ int host_plugin_id = functions->FindPlugin((char *)(SQMOD_HOST_NAME));
+ // See if our plugin was loaded after the host plugin
+ if (host_plugin_id < 0)
+ {
+ OutputError("%s could find the host plugin", SQXML_NAME);
+ // Don't load!
+ return SQMOD_FAILURE;
+ }
+ // Should never reach this point but just in case
+ else if (host_plugin_id > (info->nPluginId))
+ {
+ OutputError("%s loaded after the host plugin", SQXML_NAME);
+ // Don't load!
+ return SQMOD_FAILURE;
+ }
+ // Store server proxies
+ _Func = functions;
+ _Clbk = callbacks;
+ _Info = info;
+ // Assign plugin information
+ _Info->uPluginVer = SQXML_VERSION;
+ strcpy(_Info->szName, SQXML_HOST_NAME);
+ // Bind callbacks
+ BindCallbacks();
+ // Notify that the plugin was successfully loaded
+ OutputMessage("Successfully loaded %s", SQXML_NAME);
+ // Dummy spacing
+ puts("");
+ // Done!
+ return SQMOD_SUCCESS;
+}
diff --git a/sample/Module.hpp b/modules/xml/Module.hpp
similarity index 61%
rename from sample/Module.hpp
rename to modules/xml/Module.hpp
index 41402995..93b598df 100644
--- a/sample/Module.hpp
+++ b/modules/xml/Module.hpp
@@ -1,9 +1,11 @@
-#ifndef _SQMOD_MODULE_HPP_
-#define _SQMOD_MODULE_HPP_
+#ifndef _XML_MODULE_HPP_
+#define _XML_MODULE_HPP_
// ------------------------------------------------------------------------------------------------
-#include "sq_api.h"
-#include "vcmp.h"
+#include "SqMod.h"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Proxies to comunicate with the server.
@@ -16,7 +18,8 @@ extern PluginInfo* _Info;
* Proxies to comunicate with the Squirrel plugin.
*/
extern HSQAPI _SqAPI;
-extern HSQUIRRELVM _SqVm;
+extern HSQEXPORTS _SqMod;
+extern HSQUIRRELVM _SqVM;
/* ------------------------------------------------------------------------------------------------
* Output a message only if the _DEBUG was defined.
@@ -24,8 +27,15 @@ extern HSQUIRRELVM _SqVm;
void OutputDebug(const char * msg, ...);
/* ------------------------------------------------------------------------------------------------
- * Output a formatted message to the console.
+ * Output a formatted user message to the console.
*/
void OutputMessage(const char * msg, ...);
-#endif // _SQMOD_MODULE_HPP_
+/* ------------------------------------------------------------------------------------------------
+ * Output a formatted error message to the console.
+*/
+void OutputError(const char * msg, ...);
+
+} // Namespace:: SqMod
+
+#endif // _XML_MODULE_HPP_
diff --git a/modules/xml/Node.cpp b/modules/xml/Node.cpp
new file mode 100644
index 00000000..97b4cc4c
--- /dev/null
+++ b/modules/xml/Node.cpp
@@ -0,0 +1,118 @@
+// ------------------------------------------------------------------------------------------------
+#include "Node.hpp"
+#include "Attribute.hpp"
+#include "Text.hpp"
+#include "Module.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+// ------------------------------------------------------------------------------------------------
+bool Node::Validate() const
+{
+ if (m_Doc)
+ return true;
+ // Invalid document reference
+ _SqMod->SqThrow("Invalid XML document reference");
+ return false;
+}
+
+// ------------------------------------------------------------------------------------------------
+void Node::SetName(CSStr name)
+{
+ if (!m_Node.set_name(name))
+ _SqMod->SqThrow("Unable to set XML node name");
+}
+
+// ------------------------------------------------------------------------------------------------
+void Node::SetValue(CSStr name)
+{
+ if (!m_Node.set_value(name))
+ _SqMod->SqThrow("Unable to set XML node value");
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::GetFirstAttr() const
+{
+ return Attribute(m_Doc, m_Node.first_attribute());
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::GetLastAttr() const
+{
+ return Attribute(m_Doc, m_Node.last_attribute());
+}
+
+// ------------------------------------------------------------------------------------------------
+Text Node::GetText() const
+{
+ return Text(m_Doc, m_Node.text());
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::GetAttribute(CSStr name) const
+{
+ return Attribute(m_Doc, m_Node.attribute(name));
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::AttributeFrom(CSStr name, Attribute & attr) const
+{
+ return Attribute(m_Doc, m_Node.attribute(name, attr.m_Attr));
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::AppendAttr(CSStr name)
+{
+ return Attribute(m_Doc, m_Node.append_attribute(name));
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::PrependAttr(CSStr name)
+{
+ return Attribute(m_Doc, m_Node.prepend_attribute(name));
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::InsertAttrAfter(CSStr name, const Attribute & attr)
+{
+ return Attribute(m_Doc, m_Node.insert_attribute_after(name, attr.m_Attr));
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::InsertAttrBefore(CSStr name, const Attribute & attr)
+{
+ return Attribute(m_Doc, m_Node.insert_attribute_before(name, attr.m_Attr));
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::AppendAttrCopy(const Attribute & proto)
+{
+ return Attribute(m_Doc, m_Node.append_copy(proto.m_Attr));
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::PrependAttrCopy(const Attribute & proto)
+{
+ return Attribute(m_Doc, m_Node.prepend_copy(proto.m_Attr));
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::InsertAttrCopyAfter(const Attribute & proto, const Attribute & attr)
+{
+ return Attribute(m_Doc, m_Node.insert_copy_after(proto.m_Attr, attr.m_Attr));
+}
+
+// ------------------------------------------------------------------------------------------------
+Attribute Node::InsertAttrCopyBefore(const Attribute & proto, const Attribute & attr)
+{
+ return Attribute(m_Doc, m_Node.insert_copy_before(proto.m_Attr, attr.m_Attr));
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Node::RemoveAttrInst(const Attribute & attr)
+{
+ return m_Node.remove_attribute(attr.m_Attr);
+}
+
+} // Namespace:: SqMod
diff --git a/modules/xml/Node.hpp b/modules/xml/Node.hpp
new file mode 100644
index 00000000..10117590
--- /dev/null
+++ b/modules/xml/Node.hpp
@@ -0,0 +1,580 @@
+#ifndef _XML_NODE_HPP_
+#define _XML_NODE_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "Common.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * A light-weight handle for manipulating nodes in DOM tree.
+*/
+class Node
+{
+ // --------------------------------------------------------------------------------------------
+ friend class Document;
+ friend class Text;
+
+protected:
+
+ // --------------------------------------------------------------------------------------------
+ typedef xml_node Type;
+
+ /* --------------------------------------------------------------------------------------------
+ * Explicit constructor.
+ */
+ Node(const DocumentRef doc, const Type & node)
+ : m_Doc(doc), m_Node(node)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Validate the document reference and throw an error if invalid.
+ */
+ bool Validate() const;
+
+private:
+
+ // ---------------------------------------------------------------------------------------------
+ DocumentRef m_Doc; /* The main xml document instance. */
+ Type m_Node; /* The managed document node. */
+
+public:
+
+ /* --------------------------------------------------------------------------------------------
+ * Default constructor.
+ */
+ Node()
+ : m_Doc(), m_Node()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy constructor. (disabled)
+ */
+ Node(const Node & o)
+ : m_Doc(o.m_Doc), m_Node(o.m_Node)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Destructor.
+ */
+ ~Node()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy assignment operator. (disabled)
+ */
+ Node & operator = (const Node & o)
+ {
+ m_Doc = o.m_Doc;
+ m_Node = o.m_Node;
+ return *this;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to compare two instances of this type.
+ */
+ Int32 Cmp(const Node & o)
+ {
+ if (m_Node == o.m_Node)
+ return 0;
+ else if (m_Node > o.m_Node)
+ return 1;
+ else
+ return -1;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to convert an instance of this type to a string.
+ */
+ CSStr ToString() const
+ {
+ return m_Node.value();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether this instance references a valid xml document.
+ */
+ bool IsValid() const
+ {
+ return m_Doc;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Return the number of active references to this document instance.
+ */
+ Uint32 GetRefCount() const
+ {
+ return m_Doc.Count();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether the node is empty.
+ */
+ bool IsEmpty() const
+ {
+ return m_Node.empty();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Get hash value (unique for handles to the same object).
+ */
+ SQInteger GetHashValue() const
+ {
+ return (SQInteger)m_Node.hash_value();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Get node offset in parsed file/string (in char_t units) for debugging purposes.
+ */
+ SQInteger GetOffsetDebug() const
+ {
+ return (SQInteger)m_Node.offset_debug();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve node type.
+ */
+ Int32 GetType() const
+ {
+ return (Int32)m_Node.type();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve node name.
+ */
+ CSStr GetName() const
+ {
+ return m_Node.name();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve node name.
+ */
+ void SetName(CSStr name);
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the node name.
+ */
+ bool ApplyName(CSStr name)
+ {
+ return m_Node.set_name(name);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve node value.
+ */
+ CSStr GetValue() const
+ {
+ return m_Node.value();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve node value.
+ */
+ void SetValue(CSStr name);
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the node value.
+ */
+ bool ApplyValue(CSStr value)
+ {
+ return m_Node.set_value(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Parses buffer as an XML document fragment and appends all nodes as children of this node.
+ */
+ ParseResult AppendBuffer(CSStr source)
+ {
+ if (source)
+ return ParseResult(m_Doc, m_Node.append_buffer(source,
+ std::char_traits< SQChar >::length(source) * sizeof(SQChar)));
+ return ParseResult();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Parses buffer as an XML document fragment and appends all nodes as children of this node.
+ */
+ ParseResult AppendBuffer(CSStr source, Uint32 options)
+ {
+ if (source)
+ return ParseResult(m_Doc, m_Node.append_buffer(source,
+ std::char_traits< SQChar >::length(source) * sizeof(SQChar), options));
+ return ParseResult();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Parses buffer as an XML document fragment and appends all nodes as children of this node.
+ */
+ ParseResult AppendBuffer(CSStr source, Uint32 options, Int32 encoding)
+ {
+ if (source)
+ return ParseResult(m_Doc, m_Node.append_buffer(source,
+ std::char_traits< SQChar >::length(source) * sizeof(SQChar)
+ , options, (xml_encoding)encoding));
+ return ParseResult();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the first child attribute.
+ */
+ Attribute GetFirstAttr() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the last child attribute.
+ */
+ Attribute GetLastAttr() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the first child node.
+ */
+ Node GetFirstChild() const
+ {
+ return Node(m_Doc, m_Node.first_child());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the last child node.
+ */
+ Node GetLastChild() const
+ {
+ return Node(m_Doc, m_Node.last_child());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Get next sibling in the children list of the parent node.
+ */
+ Node GetNextSibling() const
+ {
+ return Node(m_Doc, m_Node.next_sibling());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Get previous sibling in the children list of the parent node
+ */
+ Node GetPrevSibling() const
+ {
+ return Node(m_Doc, m_Node.previous_sibling());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the parent node.
+ */
+ Node GetParent() const
+ {
+ return Node(m_Doc, m_Node.parent());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the root node.
+ */
+ Node GetRoot() const
+ {
+ return Node(m_Doc, m_Node.root());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the text object for the current node.
+ */
+ Text GetText() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve child node with the specified name.
+ */
+ Node Child(CSStr name) const
+ {
+ return Node(m_Doc, m_Node.child(name));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve child attribute with the specified name.
+ */
+ Attribute GetAttribute(CSStr name) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve next sibling with the specified name.
+ */
+ Node NextSibling(CSStr name) const
+ {
+ return Node(m_Doc, m_Node.next_sibling(name));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve previous sibling with the specified name.
+ */
+ Node PrevSibling(CSStr name) const
+ {
+ return Node(m_Doc, m_Node.previous_sibling(name));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve child attribute, starting the search from a hint.
+ */
+ Attribute AttributeFrom(CSStr name, Attribute & attr) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Get child value of current node; that is, value of the first child node of type PCDATA/CDATA.
+ */
+ CSStr GetChildValue() const
+ {
+ return m_Node.child_value();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve child value of child with specified name.
+ */
+ CSStr ChildValue(CSStr name) const
+ {
+ return m_Node.child_value(name);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Append a child attribute with the specified name.
+ */
+ Attribute AppendAttr(CSStr name);
+
+ /* --------------------------------------------------------------------------------------------
+ * Prepend a child attribute with the specified name.
+ */
+ Attribute PrependAttr(CSStr name);
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert a child attribute with the specified name, after the specified node.
+ */
+ Attribute InsertAttrAfter(CSStr name, const Attribute & attr);
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert a child attribute with the specified name, before the specified node.
+ */
+ Attribute InsertAttrBefore(CSStr name, const Attribute & attr);
+
+ /* --------------------------------------------------------------------------------------------
+ * Append a copy of the specified attribute as a child.
+ */
+ Attribute AppendAttrCopy(const Attribute & proto);
+
+ /* --------------------------------------------------------------------------------------------
+ * Prepend a copy of the specified attribute as a child.
+ */
+ Attribute PrependAttrCopy(const Attribute & proto);
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert a copy of the specified attribute as a child after the specified attribute.
+ */
+ Attribute InsertAttrCopyAfter(const Attribute & proto, const Attribute & attr);
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert a copy of the specified attribute as a child before the specified attribute.
+ */
+ Attribute InsertAttrCopyBefore(const Attribute & proto, const Attribute & attr);
+
+ /* --------------------------------------------------------------------------------------------
+ * Append a basic child node with the specified name.
+ */
+ Node AppendChild(CSStr name)
+ {
+ return Node(m_Doc, m_Node.append_child(name));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Prepend a basic child node with the specified name.
+ */
+ Node PrependChild(CSStr name)
+ {
+ return Node(m_Doc, m_Node.prepend_child(name));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Append a basic child node.
+ */
+ Node AppendChildNode()
+ {
+ return Node(m_Doc, m_Node.append_child());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Prepend a basic child node.
+ */
+ Node PrependChildNode()
+ {
+ return Node(m_Doc, m_Node.prepend_child());
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Append a basic child node with the specified type.
+ */
+ Node AppendChildType(Int32 type)
+ {
+ return Node(m_Doc, m_Node.append_child((xml_node_type)type));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Prepend a basic child node with the specified type.
+ */
+ Node PrependChildType(Int32 type)
+ {
+ return Node(m_Doc, m_Node.prepend_child((xml_node_type)type));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert a basic child node with the specified name, after the specified node.
+ */
+ Node InsertChildAfter(CSStr name, const Node & node)
+ {
+ return Node(m_Doc, m_Node.insert_child_after(name, node.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert a basic child node with the specified name, before the specified node.
+ */
+ Node InsertChildBefore(CSStr name, const Node & node)
+ {
+ return Node(m_Doc, m_Node.insert_child_before(name, node.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert a basic child node with the specified type, after the specified node.
+ */
+ Node InsertChildTypeAfter(Int32 type, const Node & node)
+ {
+ return Node(m_Doc, m_Node.insert_child_after((xml_node_type)type, node.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert a basic child node with the specified type, before the specified node.
+ */
+ Node InsertChildTypeBefore(Int32 type, const Node & node)
+ {
+ return Node(m_Doc, m_Node.insert_child_before((xml_node_type)type, node.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Append a copy of the specified node as a child.
+ */
+ Node AppendCopy(const Node & proto)
+ {
+ return Node(m_Doc, m_Node.append_copy(proto.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Prepend a copy of the specified node as a child.
+ */
+ Node PrependCopy(const Node & proto)
+ {
+ return Node(m_Doc, m_Node.prepend_copy(proto.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert a copy of the specified node as a child after the specified node.
+ */
+ Node InsertCopyAfter(const Node & proto, const Node & node)
+ {
+ return Node(m_Doc, m_Node.insert_copy_after(proto.m_Node, node.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert a copy of the specified node as a child before the specified node.
+ */
+ Node InsertCopyBefore(const Node & proto, const Node & node)
+ {
+ return Node(m_Doc, m_Node.insert_copy_before(proto.m_Node, node.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Append the specified node as a child and take ownersip of it.
+ */
+ Node AppendMove(const Node & proto)
+ {
+ return Node(m_Doc, m_Node.append_copy(proto.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Prepend the specified node as a child and take ownersip of it.
+ */
+ Node PrependMove(const Node & proto)
+ {
+ return Node(m_Doc, m_Node.prepend_copy(proto.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert the specified node as a child after the specified node and take ownersip of it.
+ */
+ Node InsertMoveAfter(const Node & proto, const Node & node)
+ {
+ return Node(m_Doc, m_Node.insert_copy_after(proto.m_Node, node.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Insert the specified node as a child before the specified node and take ownersip of it.
+ */
+ Node InsertMoveBefore(const Node & proto, const Node & node)
+ {
+ return Node(m_Doc, m_Node.insert_copy_before(proto.m_Node, node.m_Node));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Remove the child attribute matching the specified name.
+ */
+ bool RemoveAttr(CSStr name)
+ {
+ return m_Node.remove_attribute(name);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Remove the specified attribute.
+ */
+ bool RemoveAttrInst(const Attribute & attr);
+
+ /* --------------------------------------------------------------------------------------------
+ * Remove the child node matching the specified name.
+ */
+ bool RemoveChild(CSStr name)
+ {
+ return m_Node.remove_child(name);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Remove the specified node.
+ */
+ bool RemoveChildInst(const Node & node)
+ {
+ return m_Node.remove_child(node.m_Node);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Find child node by attribute name/value.
+ */
+ Node FindChildByAttr(CSStr attr_name, CSStr attr_value) const
+ {
+ return Node(m_Doc, m_Node.find_child_by_attribute(attr_name, attr_value));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Find child node by attribute name/value.
+ */
+ Node FindChildByAttr(CSStr name, CSStr attr_name, CSStr attr_value) const
+ {
+ return Node(m_Doc, m_Node.find_child_by_attribute(name, attr_name, attr_value));
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Search for a node by path consisting of node names and . or .. elements.
+ */
+ Node FindElemByPath(CSStr path, SQChar delimiter) const
+ {
+ return Node(m_Doc, m_Node.first_element_by_path(path, delimiter));
+ }
+};
+
+} // Namespace:: SqMod
+
+#endif // _XML_NODE_HPP_
diff --git a/modules/xml/Text.cpp b/modules/xml/Text.cpp
new file mode 100644
index 00000000..fcf8d51b
--- /dev/null
+++ b/modules/xml/Text.cpp
@@ -0,0 +1,198 @@
+// ------------------------------------------------------------------------------------------------
+#include "Text.hpp"
+#include "Node.hpp"
+#include "Module.hpp"
+
+// ------------------------------------------------------------------------------------------------
+#include
+#include
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+// ------------------------------------------------------------------------------------------------
+bool Text::Validate() const
+{
+ if (m_Doc)
+ return true;
+ // Invalid document reference
+ _SqMod->SqThrow("Invalid XML document reference");
+ return false;
+}
+
+// ------------------------------------------------------------------------------------------------
+Int32 Text::Cmp(const Text & o)
+{
+ if (strcmp(m_Text.get(), o.m_Text.get()) == 0)
+ return 0;
+ else if (strlen(m_Text.get()) > strlen(o.m_Text.get()))
+ return 1;
+ else
+ return -1;
+}
+
+// ------------------------------------------------------------------------------------------------
+Object Text::AsLong(Object & def) const
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object >::push(_SqVM, def);
+ // The resulted long integer value
+ Int64 longint = 0;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Push a long integer instance with the requested value on the stack
+ _SqMod->PushSLongObject(_SqVM, m_Text.as_llong(longint));
+ // Obtain the object from the stack
+ Var< Object > inst(_SqVM, -1);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the long integer instance
+ return inst.value;
+}
+
+// ------------------------------------------------------------------------------------------------
+Object Text::AsUlong(Object & def) const
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object >::push(_SqVM, def);
+ // The resulted long integer value
+ Uint64 longint = 0;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Push a long integer instance with the requested value on the stack
+ _SqMod->PushULongObject(_SqVM, m_Text.as_ullong(longint));
+ // Obtain the object from the stack
+ Var< Object > inst(_SqVM, -1);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the long integer instance
+ return inst.value;
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Text::ApplyLong(Object & value)
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object & >::push(_SqVM, value);
+ // The resulted long integer value
+ Int64 longint = 0;
+ // Whether the operation succeeded
+ bool res = false;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Assign the obtained value
+ else
+ res = m_Text.set(longint);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the result
+ return res;
+}
+
+// ------------------------------------------------------------------------------------------------
+bool Text::ApplyUlong(Object & value)
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object & >::push(_SqVM, value);
+ // The resulted long integer value
+ Uint64 longint = 0;
+ // Whether the operation succeeded
+ bool res = false;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Assign the obtained value
+ else
+ res = m_Text.set(longint);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the result
+ return res;
+}
+
+// ------------------------------------------------------------------------------------------------
+Object Text::GetLong() const
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push a long integer instance with the requested value on the stack
+ _SqMod->PushSLongObject(_SqVM, m_Text.as_llong());
+ // Obtain the object from the stack
+ Var< Object > inst(_SqVM, -1);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the long integer instance
+ return inst.value;
+}
+
+// ------------------------------------------------------------------------------------------------
+void Text::SetLong(Object & value)
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object & >::push(_SqVM, value);
+ // The resulted long integer value
+ Int64 longint = 0;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Assign the obtained value
+ else
+ m_Text = longint;
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+}
+
+// ------------------------------------------------------------------------------------------------
+Object Text::GetUlong() const
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push a long integer instance with the requested value on the stack
+ _SqMod->PushULongObject(_SqVM, m_Text.as_ullong());
+ // Obtain the object from the stack
+ Var< Object > inst(_SqVM, -1);
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+ // Return the long integer instance
+ return inst.value;
+}
+
+// ------------------------------------------------------------------------------------------------
+void Text::SetUlong(Object & value)
+{
+ // Obtain the initial stack size
+ const Int32 top = sq_gettop(_SqVM);
+ // Push the specified object onto the stack
+ Var< Object & >::push(_SqVM, value);
+ // The resulted long integer value
+ Uint64 longint = 0;
+ // Attempt to get the numeric value inside the specified object
+ if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
+ _SqMod->SqThrow("Invalid long integer specified");
+ // Assign the obtained value
+ else
+ m_Text = longint;
+ // Remove an pushed values (if any) to restore the stack
+ sq_pop(_SqVM, sq_gettop(_SqVM) - top);
+}
+
+// ------------------------------------------------------------------------------------------------
+Node Text::GetData() const
+{
+ return Node(m_Doc, m_Text.data());
+}
+
+} // Namespace:: SqMod
diff --git a/modules/xml/Text.hpp b/modules/xml/Text.hpp
new file mode 100644
index 00000000..685cac40
--- /dev/null
+++ b/modules/xml/Text.hpp
@@ -0,0 +1,365 @@
+#ifndef _XML_TEXT_HPP_
+#define _XML_TEXT_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "Common.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ * A helper for working with text inside PCDATA nodes.
+*/
+class Text
+{
+ // --------------------------------------------------------------------------------------------
+ friend class Node;
+
+protected:
+
+ // --------------------------------------------------------------------------------------------
+ typedef xml_text Type;
+
+ /* --------------------------------------------------------------------------------------------
+ * Explicit constructor.
+ */
+ Text(const DocumentRef doc, const Type & text)
+ : m_Doc(doc), m_Text(text)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Validate the document reference and throw an error if invalid.
+ */
+ bool Validate() const;
+
+private:
+
+ // ---------------------------------------------------------------------------------------------
+ DocumentRef m_Doc; /* The main xml document instance. */
+ Type m_Text; /* The managed document node. */
+
+public:
+
+ /* --------------------------------------------------------------------------------------------
+ * Default constructor.
+ */
+ Text()
+ : m_Doc(), m_Text()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy constructor. (disabled)
+ */
+ Text(const Text & o)
+ : m_Doc(o.m_Doc), m_Text(o.m_Text)
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Destructor.
+ */
+ ~Text()
+ {
+ /* ... */
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Copy assignment operator. (disabled)
+ */
+ Text & operator = (const Text & o)
+ {
+ m_Doc = o.m_Doc;
+ m_Text = o.m_Text;
+ return *this;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to compare two instances of this type.
+ */
+ Int32 Cmp(const Text & o);
+ /* --------------------------------------------------------------------------------------------
+ * Used by the script engine to convert an instance of this type to a string.
+ */
+ CSStr ToString() const
+ {
+ return m_Text.get();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether this instance references a valid xml document.
+ */
+ bool IsValid() const
+ {
+ return m_Doc;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Return the number of active references to this document instance.
+ */
+ Uint32 GetRefCount() const
+ {
+ return m_Doc.Count();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * See whether the text is empty.
+ */
+ bool IsEmpty() const
+ {
+ return m_Text.empty();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the text value.
+ */
+ CSStr GetValue() const
+ {
+ return m_Text.get();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a string or the specified default value if empty.
+ */
+ CSStr AsString(CSStr def) const
+ {
+ return m_Text.as_string(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a integer or the specified default value if empty.
+ */
+ Int32 AsInt(Int32 def) const
+ {
+ return m_Text.as_int(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a unsigned integer or the specified default value if empty.
+ */
+ Uint32 AsUint(Uint32 def) const
+ {
+ return m_Text.as_uint(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a floating point or the specified default value if empty.
+ */
+ SQFloat AsFloat(SQFloat def) const
+ {
+ return (SQFloat)m_Text.as_float(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a double floating point or the specified default value if empty.
+ */
+ SQFloat AsDouble(SQFloat def) const
+ {
+ return (SQFloat)m_Text.as_double(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a long integer or the specified default value if empty.
+ */
+ Object AsLong(Object & def) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a unsigned long integer or the specified default value if empty.
+ */
+ Object AsUlong(Object & def) const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a boolean or the specified default value if empty.
+ */
+ bool AsBool(bool def) const
+ {
+ return m_Text.as_bool(def);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a string.
+ */
+ bool ApplyString(CSStr value)
+ {
+ return m_Text.set(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a integer.
+ */
+ bool ApplyInt(Int32 value)
+ {
+ return m_Text.set(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a unsigned integer.
+ */
+ bool ApplyUint(Uint32 value)
+ {
+ return m_Text.set(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a floating point.
+ */
+ bool ApplyFloat(SQFloat value)
+ {
+ return m_Text.set(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a double floating point.
+ */
+ bool ApplyDouble(SQFloat value)
+ {
+ return m_Text.set(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a long integer.
+ */
+ bool ApplyLong(Object & value);
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a unsigned long integer.
+ */
+ bool ApplyUlong(Object & value);
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a boolean.
+ */
+ bool ApplyBool(bool value)
+ {
+ return m_Text.set(value);
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a string.
+ */
+ CSStr GetString() const
+ {
+ return m_Text.as_string();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a string.
+ */
+ void SetString(CSStr value)
+ {
+ m_Text = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a integer.
+ */
+ Int32 GetInt() const
+ {
+ return m_Text.as_int();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a integer.
+ */
+ void SetInt(Int32 value)
+ {
+ m_Text = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a unsigned integer.
+ */
+ Uint32 GetUint() const
+ {
+ return m_Text.as_uint();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a unsigned integer.
+ */
+ void SetUint(Uint32 value)
+ {
+ m_Text = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a floating point.
+ */
+ SQFloat GetFloat() const
+ {
+ return (SQFloat)m_Text.as_float();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a floating point.
+ */
+ void SetFloat(SQFloat value)
+ {
+ m_Text = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a double floating point.
+ */
+ SQFloat GetDouble() const
+ {
+ return (SQFloat)m_Text.as_double();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a double floating point.
+ */
+ void SetDouble(SQFloat value)
+ {
+ m_Text = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a long integer.
+ */
+ Object GetLong() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a long integer.
+ */
+ void SetLong(Object & value);
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a unsigned long integer.
+ */
+ Object GetUlong() const;
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a unsigned long integer.
+ */
+ void SetUlong(Object & value);
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the value as a boolean.
+ */
+ bool GetBool() const
+ {
+ return m_Text.as_bool();
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Modify the value as a boolean.
+ */
+ void SetBool(bool value)
+ {
+ m_Text = value;
+ }
+
+ /* --------------------------------------------------------------------------------------------
+ * Retrieve the data node (node_pcdata or node_cdata) for this object.
+ */
+ Node GetData() const;
+};
+
+} // Namespace:: SqMod
+
+#endif // _XML_TEXT_HPP_
\ No newline at end of file
diff --git a/sample/Module.cpp b/sample/Module.cpp
deleted file mode 100644
index 3cc17dd0..00000000
--- a/sample/Module.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-// --------------------------------------------------------------------------------------------
-#include "Module.hpp"
-#include "sq_mod.h"
-
-// --------------------------------------------------------------------------------------------
-#include
-
-// --------------------------------------------------------------------------------------------
-#include
-#include
-#include
-
-// --------------------------------------------------------------------------------------------
-#if defined(WIN32) || defined(_WIN32)
- #include
-#endif
-
-// --------------------------------------------------------------------------------------------
-PluginFuncs* _Func = NULL;
-PluginCallbacks* _Clbk = NULL;
-PluginInfo* _Info = NULL;
-
-// --------------------------------------------------------------------------------------------
-HSQAPI _SqAPI = NULL;
-HSQUIRRELVM _SqVm = NULL;
-
-// ------------------------------------------------------------------------------------------------
-void BindCallbacks();
-void UnbindCallbacks();
-
-// --------------------------------------------------------------------------------------------
-void RegisterAPI(HSQUIRRELVM vm);
-
-// --------------------------------------------------------------------------------------------
-void OnSquirrelInitialize()
-{
- HSQEXPORTS exp = sq_api_import(_Func);
- // Did we failed to obtain the plugin exports?
- if(!exp)
- OutputMessage("Failed to attach to %s", SQMOD_HOST_NAME);
- else
- {
- // Obtain the Squirrel API and VM
- _SqAPI = exp->GetSquirrelAPI();
- _SqVm = exp->GetSquirrelVM();
- // Expand the API into global functions
- sq_api_expand(_SqAPI);
- // Register functions
- RegisterAPI(_SqVm);
- }
-}
-
-// --------------------------------------------------------------------------------------------
-void OnSquirrelTerminate()
-{
- OutputMessage("Terminating sample plugin...");
- // The server may still send callbacks
- UnbindCallbacks();
- // Release squirrel resources...
-}
-
-// --------------------------------------------------------------------------------------------
-int OnInternalCommand(unsigned int type, const char * text)
-{
- switch(type)
- {
- case SQMOD_INITIALIZE_CMD:
- OnSquirrelInitialize();
- break;
- case SQMOD_TERMINATE_CMD:
- OnSquirrelTerminate();
- break;
- default: break;
- }
- return 1;
-}
-
-// --------------------------------------------------------------------------------------------
-int OnInitServer()
-{
- puts("");
- OutputMessage("Loaded Sample Squirrel Plugin");
- return 1;
-}
-
-// --------------------------------------------------------------------------------------------
-SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs* functions, PluginCallbacks* callbacks, PluginInfo* info)
-{
- // Store server proxies
- _Func = functions;
- _Clbk = callbacks;
- _Info = info;
- // Assign plugin information
- _Info->uPluginVer = 0x1000; // 1.0.00
- strcpy(_Info->szName, "SampleSquirrelPlugin");
- // Expand the API into global functions
- vc_api_expand(_Func);
- // Bind callbacks
- BindCallbacks();
- // Done!
- return 1;
-}
-
-// ------------------------------------------------------------------------------------------------
-void BindCallbacks()
-{
- _Clbk->OnInitServer = OnInitServer;
- _Clbk->OnInternalCommand = OnInternalCommand;
-}
-
-// ------------------------------------------------------------------------------------------------
-void UnbindCallbacks()
-{
- _Clbk->OnInitServer = NULL;
- _Clbk->OnInternalCommand = NULL;
-}
-
-// --------------------------------------------------------------------------------------------
-void OutputMessageImpl(const char * msg, va_list args)
-{
-#if defined(WIN32) || defined(_WIN32)
- HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
-
- CONSOLE_SCREEN_BUFFER_INFO csb_before;
- GetConsoleScreenBufferInfo( hstdout, &csb_before);
- SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN);
- printf("[MODULE] ");
-
- SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
- vprintf(msg, args);
- puts("");
-
- SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
-#else
- printf("%c[0;32m[MODULE]%c[0;37m", 27, 27, msg);
- vprintf(msg, args);
- puts("");
-#endif
-}
-
-// --------------------------------------------------------------------------------------------
-void OutputDebug(const char * msg, ...)
-{
-#ifdef _DEBUG
- // Initialize the arguments list
- va_list args;
- va_start(args, msg);
- // Call the output function
- OutputMessageImpl(msg, args);
- // Finalize the arguments list
- va_end(args);
-#endif
-}
-
-// --------------------------------------------------------------------------------------------
-void OutputMessage(const char * msg, ...)
-{
- // Initialize the arguments list
- va_list args;
- va_start(args, msg);
- // Call the output function
- OutputMessageImpl(msg, args);
- // Finalize the arguments list
- va_end(args);
-}
-
-/* --------------------------------------------------------------------------------------------
- * Sample Plugin API
-*/
-
-int SampleFunction()
-{
- OutputMessage("Hello from the sample plugin function!");
- return rand();
-}
-
-class SampleType
-{
-private:
-
- int m_MyVal;
-
-public:
-
- int mMyNum;
-
- SampleType()
- : m_MyVal(0), mMyNum(0)
- {
-
- }
-
- SampleType(int num)
- : m_MyVal(num * 2), mMyNum(num)
- {
-
- }
-
- int GetMyVal() const
- {
- return m_MyVal;
- }
-
- void SetMyVal(int val)
- {
- m_MyVal = val;
- }
-
- void SampleMethod() const
- {
- OutputMessage("I have the values %d and %d", m_MyVal, mMyNum);
- }
-};
-
-// --------------------------------------------------------------------------------------------
-void RegisterAPI(HSQUIRRELVM vm)
-{
- using namespace Sqrat;
-
- RootTable(vm).Bind(_SC("SampleType"), Class< SampleType >(vm, _SC("SampleType"))
- .Ctor()
- .Ctor< int >()
- .Var(_SC("MyNum"), &SampleType::mMyNum)
- .Prop(_SC("MyVal"), &SampleType::GetMyVal, &SampleType::SetMyVal)
- .Func(_SC("SampleMethod"), &SampleType::SampleMethod)
- );
-
- RootTable(vm).Func(_SC("SampleFunction"), &SampleFunction);
-}
diff --git a/shared/ModBase.hpp b/shared/ModBase.hpp
new file mode 100644
index 00000000..7eefc366
--- /dev/null
+++ b/shared/ModBase.hpp
@@ -0,0 +1,1161 @@
+#ifndef _SQBASE_HPP_
+#define _SQBASE_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include
+
+// ------------------------------------------------------------------------------------------------
+#include
+#include
+
+/* ------------------------------------------------------------------------------------------------
+ * ARCHITECTURE IDENTIFIERS
+*/
+
+#define SQMOD_ARCH_ID_UNKNOWN 0
+#define SQMOD_ARCH_ID_32_BIT 1
+#define SQMOD_ARCH_ID_64_BIT 2
+
+/* ------------------------------------------------------------------------------------------------
+ * PLATFORM IDENTIFIERS
+*/
+
+#define SQMOD_PLAT_ID_UNKNOWN 0
+#define SQMOD_PLAT_ID_WINDOWS 1
+#define SQMOD_PLAT_ID_LINUX 2
+#define SQMOD_PLAT_ID_MACOS 3
+#define SQMOD_PLAT_ID_UNIX 4
+
+/* ------------------------------------------------------------------------------------------------
+ * OS IDENTIFICATION
+*/
+
+#if defined(_WIN32) || defined(__WIN32__) || defined(_WIN) || defined(__WIN__)
+ // Windows x32
+ #define SQMOD_OS_WINDOWS
+ #define SQMOD_OS_32
+ #define SQMOD_OS_WINDOWS32
+ #define SQMOD_ARCHITECTURE 1
+ #define SQMOD_PLATFORM 1
+#elif defined(_WIN64) || defined(__WIN64__)
+ // Windows x64
+ #define SQMOD_OS_WINDOWS
+ #define SQMOD_OS_64
+ #define SQMOD_OS_WINDOWS64
+ #define SQMOD_ARCHITECTURE 2
+ #define SQMOD_PLATFORM 1
+#elif defined(linux) || defined(__linux) || defined(__linux__)
+ // Linux
+ #define SQMOD_OS_LINUX
+ #if __GNUC__
+ #if __x86_64__ || __ppc64__
+ #define SQMOD_OS_64
+ #define SQMOD_OS_LINUX64
+ #define SQMOD_ARCHITECTURE 2
+ #define SQMOD_PLATFORM 2
+ #else
+ #define SQMOD_OS_32
+ #define SQMOD_OS_LINUX32
+ #define SQMOD_ARCHITECTURE 1
+ #define SQMOD_PLATFORM 2
+ #endif
+ #endif
+#elif defined(__APPLE__) || defined(__MACH__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)
+ // MacOS
+ #define SQMOD_OS_MACOS
+ #if __GNUC__
+ #if __x86_64__ || __ppc64__
+ #define SQMOD_OS_64
+ #define SQMOD_OS_MACOS64
+ #define SQMOD_ARCHITECTURE 2
+ #define SQMOD_PLATFORM 3
+ #else
+ #define SQMOD_OS_32
+ #define SQMOD_OS_MACOS32
+ #define SQMOD_ARCHITECTURE 1
+ #define SQMOD_PLATFORM 3
+ #endif
+ #endif
+#elif defined(__unix) || defined(__unix__)
+ // Unix
+ #define SQMOD_OS_UNIX
+ #if __GNUC__
+ #if __x86_64__ || __ppc64__
+ #define SQMOD_OS_64
+ #define SQMOD_OS_UNIX64
+ #define SQMOD_ARCHITECTURE 2
+ #define SQMOD_PLATFORM 4
+ #else
+ #define SQMOD_OS_32
+ #define SQMOD_OS_UNIX32
+ #define SQMOD_ARCHITECTURE 1
+ #define SQMOD_PLATFORM 4
+ #endif
+ #endif
+#else
+ // Unsupported system
+ #error This operating system is not supported by the Squirrel Modules
+#endif
+
+#ifndef SQMOD_ARCHITECTURE
+ #define SQMOD_ARCHITECTURE 0
+#endif
+
+#ifndef SQMOD_PLATFORM
+ #define SQMOD_PLATFORM 0
+#endif
+
+/* ------------------------------------------------------------------------------------------------
+ * SQRAT FORWARD DECLARATIONS
+*/
+namespace Sqrat {
+ class Array;
+ class Object;
+ class Table;
+ class Function;
+} // Namespace:: Sqrat
+
+/* ------------------------------------------------------------------------------------------------
+ * FUNDAMENTAL DATATYPES
+*/
+
+namespace SqMod {
+
+/**< 8 bits integer types */
+typedef char Int8, I8;
+typedef unsigned char Uint8, U8;
+
+/**< 16 bits integer types */
+typedef short Int16, I16;
+typedef unsigned short Uint16, U16;
+
+/**< 32 bits integer types */
+typedef int Int32, I32;
+typedef unsigned int Uint32, U32;
+
+/**< 64 bits integer types */
+#if defined(_MSC_VER)
+ typedef __int64 Int64, I64;
+ typedef unsigned __int64 Uint64, U64;
+#else
+ typedef long long Int64, I64;
+ typedef unsigned long long Uint64, U64;
+#endif
+
+/**< integer type */
+#ifdef SQMOD_LONG
+ typedef Int64 Int, Integer;
+ typedef Uint64 Uint, Uinteger, UnisgnedInteger;
+#else
+ typedef Int32 Int, Integer;
+ typedef Uint32 Uint, Uinteger, UnisgnedInteger;
+#endif
+
+/**< long integer type */
+typedef long LongI;
+typedef unsigned long Ulong;
+
+/**< 32 bits float types */
+typedef float Float32, Real32, F32;
+
+/**< 64 bits float types */
+typedef double Float64, Real64, F64;
+
+/**< boolean type */
+typedef Uint8 Boolean;
+
+/**< character type */
+typedef bool BoolT;
+
+/**< character types */
+typedef char CharT;
+
+/**< user type */
+typedef void * VoidP;
+
+/**< size type */
+typedef Uint32 SizeT;
+
+/* ------------------------------------------------------------------------------------------------
+ * STRING TYPE
+*/
+typedef ::std::basic_string String;
+
+typedef char * CStr;
+typedef const char * CCStr;
+
+typedef SQChar * SStr;
+typedef const SQChar * CSStr;
+
+/* ------------------------------------------------------------------------------------------------
+ * SHORT SQUIRREL TYPENAMES
+*/
+typedef SQUnsignedInteger32 SQUint32;
+typedef SQUnsignedInteger SQUint;
+typedef SQInteger SQInt;
+
+// ------------------------------------------------------------------------------------------------
+using namespace Sqrat;
+
+/* ------------------------------------------------------------------------------------------------
+ * FORWARD DECLARATIONS
+*/
+
+} // Namespace:: SqMod
+
+/* ------------------------------------------------------------------------------------------------
+ * OS SPECIFFIC OPTIONS
+*/
+
+#if defined(SQMOD_OS_WINDOWS)
+ #define SQMOD_DIRSEP_CHAR '\\'
+ #define SQMOD_DIRSEP_STR "\\"
+#else
+ #define SQMOD_DIRSEP_CHAR '/'
+ #define SQMOD_DIRSEP_STR "/"
+#endif
+
+/* ------------------------------------------------------------------------------------------------
+ * SYMBOL EXPORTING
+*/
+
+#if defined(_MSC_VER)
+ #define SQMOD_EXPORT __declspec(dllexport)
+ #define SQMOD_IMPORT __declspec(dllimport)
+#elif defined(__GNUC__)
+ #define SQMOD_EXPORT __declspec(dllexport)
+ #define SQMOD_IMPORT __declspec(dllimport)
+#endif
+
+#if defined(__cplusplus)
+ #define SQMOD_EXTERN_C extern "C"
+#else
+ #define SQMOD_EXTERN_C /* */
+#endif
+
+#if defined(_MSC_VER)
+ #define SQMOD_API_EXPORT extern "C" __declspec(dllexport)
+#elif defined(__GNUC__)
+ #define SQMOD_API_EXPORT extern "C"
+#else
+ #define SQMOD_API_EXPORT extern "C"
+#endif
+
+/* ------------------------------------------------------------------------------------------------
+ * CALLING CONVENTIONS
+*/
+
+#if defined(_MSC_VER)
+ #define SQMOD_STDCALL __stdcall
+ #define SQMOD_CDECL __cdecl
+ #define SQMOD_FASTCALL __fastcall
+#elif defined(__GNUC__)
+ #define SQMOD_STDCALL __attribute__((stdcall))
+ #define SQMOD_CDECL /* */
+ #define SQMOD_FASTCALL __attribute__((fastcall))
+#endif
+
+/* ------------------------------------------------------------------------------------------------
+ * FUNCTION INLINING
+*/
+
+#if defined(_MSC_VER)
+ #define SQMOD_FORCEINLINE __forceinline
+#elif defined(__GNUC__)
+ #define SQMOD_FORCEINLINE inline
+#endif
+
+/* ------------------------------------------------------------------------------------------------
+ * VARIOUS DEFINES
+*/
+
+#define SQMOD_DECL_UNUSED_VAR(t, n, v) t n = v; (void)(n)
+#define SQMOD_UNUSED_VAR(n) (void)(n)
+
+#define VALID_ENTITY(e) (e >= 0)
+#define INVALID_ENTITY(e) (e < 0)
+
+#define VALID_ENTITYEX(e, m) ((e >= 0) && (e < m))
+#define INVALID_ENTITYEX(e, m) ((e < 0) || (e >= m))
+
+#define VALID_ENTITYGET(e) ((e >= 0) ? e : -1)
+#define VALID_ENTITYGETEX(e, m) ((e >= 0) && (e < m) ? e : -1)
+
+#define VALID_VEHCOL(e) ((e >= 0) && (e <= 94))
+#define INVALID_VEHCOL(e) ((e < 0) && (e > 94))
+
+/* ------------------------------------------------------------------------------------------------
+ * COLOR PACKING
+*/
+
+#define SQMOD_PACK_RGB(r, g, b) (Uint32)(r << 16 | g << 8 | b)
+#define SQMOD_PACK_RGBA(r, g, b, a) (Uint32)(r << 24 | g << 16 | b << 8 | a)
+#define SQMOD_PACK_ARGB(a, r, g, b) (Uint32)(a << 24 | r << 16 | g << 8 | b)
+
+#define SQMOD_PACK_RGB_TO_RGBA(r, g, b) (Uint32)(r << 24 | g << 16 | b << 8 | 0)
+#define SQMOD_PACK_RGB_TO_ARGB(r, g, b) (Uint32)(0 << 24 | r << 16 | g << 8 | b)
+
+/* ------------------------------------------------------------------------------------------------
+ * GENERAL RESPONSES
+*/
+
+#define SQMOD_SUCCESS 1
+#define SQMOD_FAILURE 0
+#define SQMOD_UNKNOWN -1
+#define SQMOD_TRUE 1
+#define SQMOD_FALSE 0
+#define SQMOD_NULL NULL
+#define SQMOD_BLANK 0
+
+/* ------------------------------------------------------------------------------------------------
+ * GENERAL SERVER LIMITS
+*/
+
+#define SQMOD_NAMELENGTH 64
+#define SQMOD_NAMELENGTH_T 65
+#define SQMOD_UIDLENGTH 40
+#define SQMOD_UIDLENGTH_T 41
+#define SQMOD_IPADDRESS 16
+#define SQMOD_IPADDRESS_T 17
+#define SQMOD_SVNAMELENGTH 128
+#define SQMOD_PASSWDLENGTH 128
+#define SQMOD_GMNAMELENGTH 96
+#define SQMOD_MSGLENGTH 512
+#define SQMOD_CMDLENGTH 512
+
+/* ------------------------------------------------------------------------------------------------
+ * INITIAL ENTITY POOLS
+*/
+
+#define SQMOD_BLIP_POOL 128
+#define SQMOD_CHECKPOINT_POOL 2000
+#define SQMOD_FORCEFIELD_POOL 2000
+#define SQMOD_KEYBIND_POOL 256
+#define SQMOD_OBJECT_POOL 3000
+#define SQMOD_PICKUP_POOL 2000
+#define SQMOD_PLAYER_POOL 100
+#define SQMOD_SPRITE_POOL 128
+#define SQMOD_TEXTDRAW_POOL 256
+#define SQMOD_VEHICLE_POOL 1000
+
+/* ------------------------------------------------------------------------------------------------
+ * ENTITY CREATE/DESTROY
+*/
+
+#define SQMOD_CREATE_DEFAULT 0
+#define SQMOD_CREATE_MANUAL -3
+#define SQMOD_CREATE_POOL -4
+#define SQMOD_CREATE_AUTOMATIC -5
+#define SQMOD_CREATE_OVERWRITE -6
+#define SQMOD_CREATE_RESURECT -7
+
+#define SQMOD_DESTROY_DEFAULT 0
+#define SQMOD_DESTROY_MANUAL -3
+#define SQMOD_DESTROY_POOL -4
+#define SQMOD_DESTROY_AUTOMATIC -5
+#define SQMOD_DESTROY_OVERWRITE -6
+#define SQMOD_DESTROY_CLEANUP -7
+
+/* ------------------------------------------------------------------------------------------------
+ * MODEL ID LIMITS
+*/
+
+#define SQMOD_WEAPONID_MAX 71
+#define SQMOD_WEAPONID_CAP 256
+#define SQMOD_VEHICLEID_MAX 237
+#define SQMOD_VEHICLEID_CAP 512
+#define SQMOD_SKINID_MAX 160
+#define SQMOD_SKINID_CAP 256
+#define SQMOD_MODELID_MAX 640
+#define SQMOD_MODELID_CAP 2048
+
+/* ------------------------------------------------------------------------------------------------
+ * SCRIPT OPTIONS
+*/
+
+/* ------------------------------------------------------------------------------------------------
+ * PLUGIN OPTIONS
+*/
+
+#define SQMOD_STACK_SIZE 2048
+#define SQMOD_MAX_CMD_ARGS 12
+#define SQMOD_PLAYER_MSG_PREFIXES 16
+#define SQMOD_PLAYER_TMP_BUFFER 128
+
+/* ------------------------------------------------------------------------------------------------
+ * ENTITY POOL UPDATE IDENTIFIERS
+*/
+#define SQMOD_ENTITY_POOL_VEHICLE 1
+#define SQMOD_ENTITY_POOL_OBJECT 2
+#define SQMOD_ENTITY_POOL_PICKUP 3
+#define SQMOD_ENTITY_POOL_RADIO 4
+#define SQMOD_ENTITY_POOL_SPRITE 5
+#define SQMOD_ENTITY_POOL_TEXTDRAW 6
+#define SQMOD_ENTITY_POOL_BLIP 7
+#define SQMOD_ENTITY_POOL_MAX 8
+
+/* ------------------------------------------------------------------------------------------------
+ * PLAYER STATE IDENTIFIERS
+*/
+#define SQMOD_PLAYER_STATE_NONE 0
+#define SQMOD_PLAYER_STATE_NORMAL 1
+#define SQMOD_PLAYER_STATE_SHOOTING 2
+#define SQMOD_PLAYER_STATE_DRIVER 3
+#define SQMOD_PLAYER_STATE_PASSENGER 4
+#define SQMOD_PLAYER_STATE_ENTERING_AS_DRIVER 5
+#define SQMOD_PLAYER_STATE_ENTERING_AS_PASSENGER 6
+#define SQMOD_PLAYER_STATE_EXITING_VEHICLE 7
+#define SQMOD_PLAYER_STATE_UNSPAWNED 8
+#define SQMOD_PLAYER_STATE_MAX 9
+
+/* ------------------------------------------------------------------------------------------------
+ * PLAYER ACTION IDENTIFIERS
+*/
+#define SQMOD_PLAYER_ACTION_NONE 0
+#define SQMOD_PLAYER_ACTION_NORMAL 1
+#define SQMOD_PLAYER_ACTION_AIMING 12
+#define SQMOD_PLAYER_ACTION_SHOOTING 16
+#define SQMOD_PLAYER_ACTION_JUMPING 41
+#define SQMOD_PLAYER_ACTION_LYING_ON_GROUND 42
+#define SQMOD_PLAYER_ACTION_GETTING_UP 43
+#define SQMOD_PLAYER_ACTION_JUMPING_FROM_VEHICLE 44
+#define SQMOD_PLAYER_ACTION_DRIVING 50
+#define SQMOD_PLAYER_ACTION_DYING 54
+#define SQMOD_PLAYER_ACTION_WASTED 55
+#define SQMOD_PLAYER_ACTION_ENTERING_VEHICLE 58
+#define SQMOD_PLAYER_ACTION_EXITING_VEHICLE 60
+#define SQMOD_PLAYER_ACTION_MAX 61
+
+/* ------------------------------------------------------------------------------------------------
+ * VEHICLE UPDATE IDENTIFIERS
+*/
+#define SQMOD_VEHICLEUPD_DRIVER 0
+#define SQMOD_VEHICLEUPD_OTHER 1
+#define SQMOD_VEHICLEUPD_MAX 2
+
+/* ------------------------------------------------------------------------------------------------
+ * PLAYER UPDATE IDENTIFIERS
+*/
+#define SQMOD_PLAYERUPD_ONFOOT 0
+#define SQMOD_PLAYERUPD_AIM 1
+#define SQMOD_PLAYERUPD_DRIVER 2
+#define SQMOD_PLAYERUPD_PASSENGER 3
+#define SQMOD_PLAYERUPD_MAX 4
+
+/* ------------------------------------------------------------------------------------------------
+ * PART REASON IDENTIFIERS
+*/
+#define SQMOD_PARTREASON_TIMEOUT 0
+#define SQMOD_PARTREASON_DISCONNECTED 1
+#define SQMOD_PARTREASON_KICKEDBANNED 2
+#define SQMOD_PARTREASON_CRASHED 3
+#define SQMOD_PARTREASON_MAX 4
+
+/* ------------------------------------------------------------------------------------------------
+ * BODY PART IDENTIFIERS
+*/
+#define SQMOD_BODYPART_BODY 0
+#define SQMOD_BODYPART_TORSO 1
+#define SQMOD_BODYPART_LEFTARM 2
+#define SQMOD_BODYPART_RIGHTARM 3
+#define SQMOD_BODYPART_LEFTLEG 4
+#define SQMOD_BODYPART_RIGHTLEG 5
+#define SQMOD_BODYPART_HEAD 6
+#define SQMOD_BODYPART_MAX 7
+
+/* ------------------------------------------------------------------------------------------------
+ * WEATHER IDENTIFIERS
+*/
+#define SQMOD_WEATHER_MOSTLYCLEAR 0
+#define SQMOD_WEATHER_OVERCAST 1
+#define SQMOD_WEATHER_THUNDERSTORM 2
+#define SQMOD_WEATHER_STORM 2
+#define SQMOD_WEATHER_STORMY 2
+#define SQMOD_WEATHER_FOGGY 3
+#define SQMOD_WEATHER_FOG 3
+#define SQMOD_WEATHER_CLEAR 4
+#define SQMOD_WEATHER_SUNNY 4
+#define SQMOD_WEATHER_RAIN 5
+#define SQMOD_WEATHER_RAINY 5
+#define SQMOD_WEATHER_DARKCLOUDY 6
+#define SQMOD_WEATHER_LIGHTCLOUDY 7
+#define SQMOD_WEATHER_OVERCASTCLOUDY 8
+#define SQMOD_WEATHER_BLACKCLOUDS 9
+#define SQMOD_WEATHER_MAX 10
+
+
+/* ------------------------------------------------------------------------------------------------
+ * WEAPON IDENTIFIERS
+*/
+#define SQMOD_WEAPON_UNARMED 0
+#define SQMOD_WEAPON_BRASSKNUCKLES 1
+#define SQMOD_WEAPON_SCREWDRIVER 2
+#define SQMOD_WEAPON_GOLFCLUB 3
+#define SQMOD_WEAPON_NIGHTSTICK 4
+#define SQMOD_WEAPON_KNIFE 5
+#define SQMOD_WEAPON_BASEBALLBAT 6
+#define SQMOD_WEAPON_HAMMER 7
+#define SQMOD_WEAPON_MEATCLEAVER 8
+#define SQMOD_WEAPON_MACHETE 9
+#define SQMOD_WEAPON_KATANA 10
+#define SQMOD_WEAPON_CHAINSAW 11
+#define SQMOD_WEAPON_GRENADE 12
+#define SQMOD_WEAPON_REMOTE 13
+#define SQMOD_WEAPON_TEARGAS 14
+#define SQMOD_WEAPON_MOLOTOV 15
+#define SQMOD_WEAPON_ROCKET 16
+#define SQMOD_WEAPON_COLT45 17
+#define SQMOD_WEAPON_PYTHON 18
+#define SQMOD_WEAPON_SHOTGUN 19
+#define SQMOD_WEAPON_SPAS12 20
+#define SQMOD_WEAPON_STUBBY 21
+#define SQMOD_WEAPON_TEC9 22
+#define SQMOD_WEAPON_UZI 23
+#define SQMOD_WEAPON_INGRAM 24
+#define SQMOD_WEAPON_MP5 25
+#define SQMOD_WEAPON_M4 26
+#define SQMOD_WEAPON_RUGER 27
+#define SQMOD_WEAPON_SNIPER 28
+#define SQMOD_WEAPON_LASERSCOPE 29
+#define SQMOD_WEAPON_ROCKETLAUNCHER 30
+#define SQMOD_WEAPON_FLAMETHROWER 31
+#define SQMOD_WEAPON_M60 32
+#define SQMOD_WEAPON_MINIGUN 33
+#define SQMOD_WEAPON_BOMB 34
+#define SQMOD_WEAPON_HELICANNON 35
+#define SQMOD_WEAPON_CAMERA 36
+#define SQMOD_WEAPON_VEHICLE 39
+#define SQMOD_WEAPON_EXPLOSION1 41
+#define SQMOD_WEAPON_DRIVEBY 42
+#define SQMOD_WEAPON_DROWNED 43
+#define SQMOD_WEAPON_FALL 44
+#define SQMOD_WEAPON_EXPLOSION2 51
+#define SQMOD_WEAPON_SUICIDE 70
+#define SQMOD_WEAPON_MAX 71
+
+/* ------------------------------------------------------------------------------------------------
+ * VEHICLE IDENTIFIERS
+*/
+#define SQMOD_VEHICLE_LANDSTALKER 130
+#define SQMOD_VEHICLE_IDAHO 131
+#define SQMOD_VEHICLE_STINGER 132
+#define SQMOD_VEHICLE_LINERUNNER 133
+#define SQMOD_VEHICLE_PERENNIAL 134
+#define SQMOD_VEHICLE_SENTINEL 135
+#define SQMOD_VEHICLE_RIO 136
+#define SQMOD_VEHICLE_FIRETRUCK 137
+#define SQMOD_VEHICLE_TRASHMASTER 138
+#define SQMOD_VEHICLE_STRETCH 139
+#define SQMOD_VEHICLE_MANANA 140
+#define SQMOD_VEHICLE_INFERNUS 141
+#define SQMOD_VEHICLE_VOODOO 142
+#define SQMOD_VEHICLE_PONY 143
+#define SQMOD_VEHICLE_MULE 144
+#define SQMOD_VEHICLE_CHEETAH 145
+#define SQMOD_VEHICLE_AMBULANCE 146
+#define SQMOD_VEHICLE_FBIWASHINGTON 147
+#define SQMOD_VEHICLE_MOONBEAM 148
+#define SQMOD_VEHICLE_ESPERANTO 149
+#define SQMOD_VEHICLE_TAXI 150
+#define SQMOD_VEHICLE_WASHINGTON 151
+#define SQMOD_VEHICLE_BOBCAT 152
+#define SQMOD_VEHICLE_MRWHOOPEE 153
+#define SQMOD_VEHICLE_BFINJECTION 154
+#define SQMOD_VEHICLE_HUNTER 155
+#define SQMOD_VEHICLE_POLICE 156
+#define SQMOD_VEHICLE_ENFORCER 157
+#define SQMOD_VEHICLE_SECURICAR 158
+#define SQMOD_VEHICLE_BANSHEE 159
+#define SQMOD_VEHICLE_PREDATOR 160
+#define SQMOD_VEHICLE_BUS 161
+#define SQMOD_VEHICLE_RHINO 162
+#define SQMOD_VEHICLE_BARRACKSOL 163
+#define SQMOD_VEHICLE_BARRACKS 163
+#define SQMOD_VEHICLE_CUBANHERMES 164
+#define SQMOD_VEHICLE_HELICOPTER 165
+#define SQMOD_VEHICLE_ANGEL 166
+#define SQMOD_VEHICLE_COACH 167
+#define SQMOD_VEHICLE_CABBIE 168
+#define SQMOD_VEHICLE_STALLION 169
+#define SQMOD_VEHICLE_RUMPO 170
+#define SQMOD_VEHICLE_RCBANDIT 171
+#define SQMOD_VEHICLE_HEARSE 172
+#define SQMOD_VEHICLE_PACKER 173
+#define SQMOD_VEHICLE_SENTINELXS 174
+#define SQMOD_VEHICLE_ADMIRAL 175
+#define SQMOD_VEHICLE_SQUALO 176
+#define SQMOD_VEHICLE_SEASPARROW 177
+#define SQMOD_VEHICLE_PIZZABOY 178
+#define SQMOD_VEHICLE_GANGBURRITO 179
+#define SQMOD_VEHICLE_AIRTRAIN 180
+#define SQMOD_VEHICLE_DEADDODO 181
+#define SQMOD_VEHICLE_SPEEDER 182
+#define SQMOD_VEHICLE_REEFER 183
+#define SQMOD_VEHICLE_TROPIC 184
+#define SQMOD_VEHICLE_FLATBED 185
+#define SQMOD_VEHICLE_YANKEE 186
+#define SQMOD_VEHICLE_CADDY 187
+#define SQMOD_VEHICLE_ZEBRA 188
+#define SQMOD_VEHICLE_ZEBRACAB 188
+#define SQMOD_VEHICLE_TOPFUN 189
+#define SQMOD_VEHICLE_SKIMMER 190
+#define SQMOD_VEHICLE_PCJ600 191
+#define SQMOD_VEHICLE_PCJ 191
+#define SQMOD_VEHICLE_FAGGIO 192
+#define SQMOD_VEHICLE_FREEWAY 193
+#define SQMOD_VEHICLE_RCBARON 194
+#define SQMOD_VEHICLE_RCRAIDER 195
+#define SQMOD_VEHICLE_GLENDALE 196
+#define SQMOD_VEHICLE_OCEANIC 197
+#define SQMOD_VEHICLE_SANCHEZ 198
+#define SQMOD_VEHICLE_SPARROW 199
+#define SQMOD_VEHICLE_PATRIOT 200
+#define SQMOD_VEHICLE_LOVEFIST 201
+#define SQMOD_VEHICLE_COASTGUARD 202
+#define SQMOD_VEHICLE_DINGHY 203
+#define SQMOD_VEHICLE_HERMES 204
+#define SQMOD_VEHICLE_SABRE 205
+#define SQMOD_VEHICLE_SABRETURBO 206
+#define SQMOD_VEHICLE_PHOENIX 207
+#define SQMOD_VEHICLE_WALTON 208
+#define SQMOD_VEHICLE_REGINA 209
+#define SQMOD_VEHICLE_COMET 210
+#define SQMOD_VEHICLE_DELUXO 211
+#define SQMOD_VEHICLE_BURRITO 212
+#define SQMOD_VEHICLE_SPANDEX 213
+#define SQMOD_VEHICLE_SPANDEXPRESS 213
+#define SQMOD_VEHICLE_MARQUIS 214
+#define SQMOD_VEHICLE_BAGGAGE 215
+#define SQMOD_VEHICLE_BAGGAGEHANDLER 215
+#define SQMOD_VEHICLE_KAUFMAN 216
+#define SQMOD_VEHICLE_KAUFMANCAB 216
+#define SQMOD_VEHICLE_MAVERICK 217
+#define SQMOD_VEHICLE_VCNMAVERICK 218
+#define SQMOD_VEHICLE_RANCHER 219
+#define SQMOD_VEHICLE_FBIRANCHER 220
+#define SQMOD_VEHICLE_VIRGO 221
+#define SQMOD_VEHICLE_GREENWOOD 222
+#define SQMOD_VEHICLE_CUBANJETMAX 223
+#define SQMOD_VEHICLE_HOTRING1 224
+#define SQMOD_VEHICLE_HOTRINGRACER1 224
+#define SQMOD_VEHICLE_SANDKING 225
+#define SQMOD_VEHICLE_BLISTA 226
+#define SQMOD_VEHICLE_BLISTAC 226
+#define SQMOD_VEHICLE_BLISTACOMPACT 226
+#define SQMOD_VEHICLE_COMPACT 226
+#define SQMOD_VEHICLE_POLICEMAV 227
+#define SQMOD_VEHICLE_POLICEMAVERICK 227
+#define SQMOD_VEHICLE_BOXVILLE 228
+#define SQMOD_VEHICLE_BENSON 229
+#define SQMOD_VEHICLE_MESA 230
+#define SQMOD_VEHICLE_MESAGRANDE 230
+#define SQMOD_VEHICLE_RCGOBLIN 231
+#define SQMOD_VEHICLE_HOTRING2 232
+#define SQMOD_VEHICLE_HOTRINGRACER2 232
+#define SQMOD_VEHICLE_HOTRING3 233
+#define SQMOD_VEHICLE_HOTRINGRACER3 233
+#define SQMOD_VEHICLE_BLOODRING1 234
+#define SQMOD_VEHICLE_BLOODRINGBANGER1 234
+#define SQMOD_VEHICLE_BLOODRING2 235
+#define SQMOD_VEHICLE_BLOODRINGBANGER2 235
+#define SQMOD_VEHICLE_VICECHEE 236
+#define SQMOD_VEHICLE_POLICECHEETAH 236
+#define SQMOD_VEHICLE_FBICHEETAH 236
+#define SQMOD_VEHICLE_CHEETAH2 236
+#define SQMOD_VEHICLE_MAX 237
+
+/* ------------------------------------------------------------------------------------------------
+ * SKIN IDENTIFIERS
+*/
+#define SQMOD_SKIN_TOMMY_VERCETTI 0
+#define SQMOD_SKIN_COP 1
+#define SQMOD_SKIN_SWAT 2
+#define SQMOD_SKIN_FBI 3
+#define SQMOD_SKIN_ARMY 4
+#define SQMOD_SKIN_PARAMEDIC 5
+#define SQMOD_SKIN_FIREMAN 6
+#define SQMOD_SKIN_GOLF_GUY_A 7
+#define SQMOD_SKIN_BUM_LADY_A 9
+#define SQMOD_SKIN_BUM_LADY_B 10
+#define SQMOD_SKIN_PUNK_A 11
+#define SQMOD_SKIN_LAWYER 12
+#define SQMOD_SKIN_SPANISH_LADY_A 13
+#define SQMOD_SKIN_SPANISH_LADY_B 14
+#define SQMOD_SKIN_COOL_GUY_A 15
+#define SQMOD_SKIN_ARABIC_GUY 16
+#define SQMOD_SKIN_BEACH_LADY_A 17
+#define SQMOD_SKIN_BEACH_LADY_B 18
+#define SQMOD_SKIN_BEACH_GUY_A 19
+#define SQMOD_SKIN_BEACH_GUY_B 20
+#define SQMOD_SKIN_OFFICE_LADY_A 21
+#define SQMOD_SKIN_WAITRESS_A 22
+#define SQMOD_SKIN_FOOD_LADY 23
+#define SQMOD_SKIN_PROSTITUTE_A 24
+#define SQMOD_SKIN_BUM_LADY_C 25
+#define SQMOD_SKIN_BUM_GUY_A 26
+#define SQMOD_SKIN_GARBAGEMAN_A 27
+#define SQMOD_SKIN_TAXI_DRIVER_A 28
+#define SQMOD_SKIN_HATIAN_A 29
+#define SQMOD_SKIN_CRIMINAL_A 30
+#define SQMOD_SKIN_HOOD_LADY 31
+#define SQMOD_SKIN_GRANNY_A 32
+#define SQMOD_SKIN_BUSINESS_MAN_A 33
+#define SQMOD_SKIN_CHURCH_GUY 34
+#define SQMOD_SKIN_CLUB_LADY 35
+#define SQMOD_SKIN_CHURCH_LADY 36
+#define SQMOD_SKIN_PIMP 37
+#define SQMOD_SKIN_BEACH_LADY_C 38
+#define SQMOD_SKIN_BEACH_GUY_C 39
+#define SQMOD_SKIN_BEACH_LADY_D 40
+#define SQMOD_SKIN_BEACH_GUY_D 41
+#define SQMOD_SKIN_BUSINESS_MAN_B 42
+#define SQMOD_SKIN_PROSTITUTE_B 43
+#define SQMOD_SKIN_BUM_LADY_D 44
+#define SQMOD_SKIN_BUM_GUY_B 45
+#define SQMOD_SKIN_HATIAN_B 46
+#define SQMOD_SKIN_CONSTRUCTION_WORKER_A 47
+#define SQMOD_SKIN_PUNK_B 48
+#define SQMOD_SKIN_PROSTITUTE_C 49
+#define SQMOD_SKIN_GRANNY_B 50
+#define SQMOD_SKIN_PUNK_C 51
+#define SQMOD_SKIN_BUSINESS_MAN_C 52
+#define SQMOD_SKIN_SPANISH_LADY_C 53
+#define SQMOD_SKIN_SPANISH_LADY_D 54
+#define SQMOD_SKIN_COOL_GUY_B 55
+#define SQMOD_SKIN_BUSINESS_MAN_D 56
+#define SQMOD_SKIN_BEACH_LADY_E 57
+#define SQMOD_SKIN_BEACH_GUY_E 58
+#define SQMOD_SKIN_BEACH_LADY_F 59
+#define SQMOD_SKIN_BEACH_GUY_F 60
+#define SQMOD_SKIN_CONSTRUCTION_WORKER_B 61
+#define SQMOD_SKIN_GOLF_GUY_B 62
+#define SQMOD_SKIN_GOLF_LADY 63
+#define SQMOD_SKIN_GOLF_GUY_C 64
+#define SQMOD_SKIN_BEACH_LADY_G 65
+#define SQMOD_SKIN_BEACH_GUY_G 66
+#define SQMOD_SKIN_OFFICE_LADY_B 67
+#define SQMOD_SKIN_BUSINESS_MAN_E 68
+#define SQMOD_SKIN_BUSINESS_MAN_F 69
+#define SQMOD_SKIN_PROSTITUTE_D 70
+#define SQMOD_SKIN_BUM_LADY_E 71
+#define SQMOD_SKIN_BUM_GUY_C 72
+#define SQMOD_SKIN_SPANISH_GUY 73
+#define SQMOD_SKIN_TAXI_DRIVER_B 74
+#define SQMOD_SKIN_GYM_LADY 75
+#define SQMOD_SKIN_GYM_GUY 76
+#define SQMOD_SKIN_SKATE_LADY 77
+#define SQMOD_SKIN_SKATE_GUY 78
+#define SQMOD_SKIN_SHOPPER_A 79
+#define SQMOD_SKIN_SHOPPER_B 80
+#define SQMOD_SKIN_TOURIST_A 81
+#define SQMOD_SKIN_TOURIST_B 82
+#define SQMOD_SKIN_CUBAN_A 83
+#define SQMOD_SKIN_CUBAN_B 84
+#define SQMOD_SKIN_HATIAN_C 85
+#define SQMOD_SKIN_HATIAN_D 86
+#define SQMOD_SKIN_SHARK_A 87
+#define SQMOD_SKIN_SHARK_B 88
+#define SQMOD_SKIN_DIAZ_GUY_A 89
+#define SQMOD_SKIN_DIAZ_GUY_B 90
+#define SQMOD_SKIN_DBP_SECURITY_A 91
+#define SQMOD_SKIN_DBP_SECURITY_B 92
+#define SQMOD_SKIN_BIKER_A 93
+#define SQMOD_SKIN_BIKER_B 94
+#define SQMOD_SKIN_VERCETTI_GUY_A 95
+#define SQMOD_SKIN_VERCETTI_GUY_B 96
+#define SQMOD_SKIN_UNDERCOVER_COP_A 97
+#define SQMOD_SKIN_UNDERCOVER_COP_B 98
+#define SQMOD_SKIN_UNDERCOVER_COP_C 99
+#define SQMOD_SKIN_UNDERCOVER_COP_D 100
+#define SQMOD_SKIN_UNDERCOVER_COP_E 101
+#define SQMOD_SKIN_UNDERCOVER_COP_F 102
+#define SQMOD_SKIN_RICH_GUY 103
+#define SQMOD_SKIN_COOL_GUY_C 104
+#define SQMOD_SKIN_PROSTITUTE_E 105
+#define SQMOD_SKIN_PROSTITUTE_F 106
+#define SQMOD_SKIN_LOVE_FIST_A 107
+#define SQMOD_SKIN_KEN_ROSENBURG 108
+#define SQMOD_SKIN_CANDY_SUXX 109
+#define SQMOD_SKIN_HILARY 110
+#define SQMOD_SKIN_LOVE_FIST_B 111
+#define SQMOD_SKIN_PHIL 112
+#define SQMOD_SKIN_ROCKSTAR_GUY 113
+#define SQMOD_SKIN_SONNY 114
+#define SQMOD_SKIN_LANCE_A 115
+#define SQMOD_SKIN_MERCADES_A 116
+#define SQMOD_SKIN_LOVE_FIST_C 117
+#define SQMOD_SKIN_ALEX_SRUB 118
+#define SQMOD_SKIN_LANCE_COP 119
+#define SQMOD_SKIN_LANCE_B 120
+#define SQMOD_SKIN_CORTEZ 121
+#define SQMOD_SKIN_LOVE_FIST_D 122
+#define SQMOD_SKIN_COLUMBIAN_GUY_A 123
+#define SQMOD_SKIN_HILARY_ROBBER 124
+#define SQMOD_SKIN_MERCADES_B 125
+#define SQMOD_SKIN_CAM 126
+#define SQMOD_SKIN_CAM_ROBBER 127
+#define SQMOD_SKIN_PHIL_ONE_ARM 128
+#define SQMOD_SKIN_PHIL_ROBBER 129
+#define SQMOD_SKIN_COOL_GUY_D 130
+#define SQMOD_SKIN_PIZZAMAN 131
+#define SQMOD_SKIN_TAXI_DRIVER_C 132
+#define SQMOD_SKIN_TAXI_DRIVER_D 133
+#define SQMOD_SKIN_SAILOR_A 134
+#define SQMOD_SKIN_SAILOR_B 135
+#define SQMOD_SKIN_SAILOR_C 136
+#define SQMOD_SKIN_CHEF 137
+#define SQMOD_SKIN_CRIMINAL_B 138
+#define SQMOD_SKIN_FRENCH_GUY 139
+#define SQMOD_SKIN_GARBAGEMAN_B 140
+#define SQMOD_SKIN_HATIAN_E 141
+#define SQMOD_SKIN_WAITRESS_B 142
+#define SQMOD_SKIN_SONNY_GUY_A 143
+#define SQMOD_SKIN_SONNY_GUY_B 144
+#define SQMOD_SKIN_SONNY_GUY_C 145
+#define SQMOD_SKIN_COLUMBIAN_GUY_B 146
+#define SQMOD_SKIN_THUG_A 147
+#define SQMOD_SKIN_BEACH_GUY_H 148
+#define SQMOD_SKIN_GARBAGEMAN_C 149
+#define SQMOD_SKIN_GARBAGEMAN_D 150
+#define SQMOD_SKIN_GARBAGEMAN_E 151
+#define SQMOD_SKIN_TRANNY 152
+#define SQMOD_SKIN_THUG_B 153
+#define SQMOD_SKIN_SPANDEX_GUY_A 154
+#define SQMOD_SKIN_SPANDEX_GUY_B 155
+#define SQMOD_SKIN_STRIPPER_A 156
+#define SQMOD_SKIN_STRIPPER_B 157
+#define SQMOD_SKIN_STRIPPER_C 158
+#define SQMOD_SKIN_STORE_CLERK 159
+#define SQMOD_SKIN_MAX 160
+
+/* ------------------------------------------------------------------------------------------------
+ * KEYBOARD CODES
+*/
+#define SQMOD_KEYCODE_ABNT_C1 0xC1
+#define SQMOD_KEYCODE_ABNT_C2 0xC2
+#define SQMOD_KEYCODE_ADD 0x6B
+#define SQMOD_KEYCODE_ATTN 0xF6
+#define SQMOD_KEYCODE_BACK 0x08
+#define SQMOD_KEYCODE_CANCEL 0x03
+#define SQMOD_KEYCODE_CLEAR 0x0C
+#define SQMOD_KEYCODE_CRSEL 0xF7
+#define SQMOD_KEYCODE_DECIMAL 0x6E
+#define SQMOD_KEYCODE_DIVIDE 0x6F
+#define SQMOD_KEYCODE_EREOF 0xF9
+#define SQMOD_KEYCODE_ESCAPE 0x1B
+#define SQMOD_KEYCODE_EXECUTE 0x2B
+#define SQMOD_KEYCODE_EXSEL 0xF8
+#define SQMOD_KEYCODE_ICO_CLEAR 0xE6
+#define SQMOD_KEYCODE_ICO_HELP 0xE3
+#define SQMOD_KEYCODE_KEY_0 0x30
+#define SQMOD_KEYCODE_KEY_1 0x31
+#define SQMOD_KEYCODE_KEY_2 0x32
+#define SQMOD_KEYCODE_KEY_3 0x33
+#define SQMOD_KEYCODE_KEY_4 0x34
+#define SQMOD_KEYCODE_KEY_5 0x35
+#define SQMOD_KEYCODE_KEY_6 0x36
+#define SQMOD_KEYCODE_KEY_7 0x37
+#define SQMOD_KEYCODE_KEY_8 0x38
+#define SQMOD_KEYCODE_KEY_9 0x39
+#define SQMOD_KEYCODE_KEY_A 0x41
+#define SQMOD_KEYCODE_KEY_B 0x42
+#define SQMOD_KEYCODE_KEY_C 0x43
+#define SQMOD_KEYCODE_KEY_D 0x44
+#define SQMOD_KEYCODE_KEY_E 0x45
+#define SQMOD_KEYCODE_KEY_F 0x46
+#define SQMOD_KEYCODE_KEY_G 0x47
+#define SQMOD_KEYCODE_KEY_H 0x48
+#define SQMOD_KEYCODE_KEY_I 0x49
+#define SQMOD_KEYCODE_KEY_J 0x4A
+#define SQMOD_KEYCODE_KEY_K 0x4B
+#define SQMOD_KEYCODE_KEY_L 0x4C
+#define SQMOD_KEYCODE_KEY_M 0x4D
+#define SQMOD_KEYCODE_KEY_N 0x4E
+#define SQMOD_KEYCODE_KEY_O 0x4F
+#define SQMOD_KEYCODE_KEY_P 0x50
+#define SQMOD_KEYCODE_KEY_Q 0x51
+#define SQMOD_KEYCODE_KEY_R 0x52
+#define SQMOD_KEYCODE_KEY_S 0x53
+#define SQMOD_KEYCODE_KEY_T 0x54
+#define SQMOD_KEYCODE_KEY_U 0x55
+#define SQMOD_KEYCODE_KEY_V 0x56
+#define SQMOD_KEYCODE_KEY_W 0x57
+#define SQMOD_KEYCODE_KEY_X 0x58
+#define SQMOD_KEYCODE_KEY_Y 0x59
+#define SQMOD_KEYCODE_KEY_Z 0x5A
+#define SQMOD_KEYCODE_MULTIPLY 0x6A
+#define SQMOD_KEYCODE_NONAME 0xFC
+#define SQMOD_KEYCODE_NUMPAD0 0x60
+#define SQMOD_KEYCODE_NUMPAD1 0x61
+#define SQMOD_KEYCODE_NUMPAD2 0x62
+#define SQMOD_KEYCODE_NUMPAD3 0x63
+#define SQMOD_KEYCODE_NUMPAD4 0x64
+#define SQMOD_KEYCODE_NUMPAD5 0x65
+#define SQMOD_KEYCODE_NUMPAD6 0x66
+#define SQMOD_KEYCODE_NUMPAD7 0x67
+#define SQMOD_KEYCODE_NUMPAD8 0x68
+#define SQMOD_KEYCODE_NUMPAD9 0x69
+#define SQMOD_KEYCODE_OEM_1 0xBA
+#define SQMOD_KEYCODE_OEM_102 0xE2
+#define SQMOD_KEYCODE_OEM_2 0xBF
+#define SQMOD_KEYCODE_OEM_3 0xC0
+#define SQMOD_KEYCODE_OEM_4 0xDB
+#define SQMOD_KEYCODE_OEM_5 0xDC
+#define SQMOD_KEYCODE_OEM_6 0xDD
+#define SQMOD_KEYCODE_OEM_7 0xDE
+#define SQMOD_KEYCODE_OEM_8 0xDF
+#define SQMOD_KEYCODE_OEM_ATTN 0xF0
+#define SQMOD_KEYCODE_OEM_AUTO 0xF3
+#define SQMOD_KEYCODE_OEM_AX 0xE1
+#define SQMOD_KEYCODE_OEM_BACKTAB 0xF5
+#define SQMOD_KEYCODE_OEM_CLEAR 0xFE
+#define SQMOD_KEYCODE_OEM_COMMA 0xBC
+#define SQMOD_KEYCODE_OEM_COPY 0xF2
+#define SQMOD_KEYCODE_OEM_CUSEL 0xEF
+#define SQMOD_KEYCODE_OEM_ENLW 0xF4
+#define SQMOD_KEYCODE_OEM_FINISH 0xF1
+#define SQMOD_KEYCODE_OEM_FJ_LOYA 0x95
+#define SQMOD_KEYCODE_OEM_FJ_MASSHOU 0x93
+#define SQMOD_KEYCODE_OEM_FJ_ROYA 0x96
+#define SQMOD_KEYCODE_OEM_FJ_TOUROKU 0x94
+#define SQMOD_KEYCODE_OEM_JUMP 0xEA
+#define SQMOD_KEYCODE_OEM_MINUS 0xBD
+#define SQMOD_KEYCODE_OEM_PA1 0xEB
+#define SQMOD_KEYCODE_OEM_PA2 0xEC
+#define SQMOD_KEYCODE_OEM_PA3 0xED
+#define SQMOD_KEYCODE_OEM_PERIOD 0xBE
+#define SQMOD_KEYCODE_OEM_PLUS 0xBB
+#define SQMOD_KEYCODE_OEM_RESET 0xE9
+#define SQMOD_KEYCODE_OEM_WSCTRL 0xEE
+#define SQMOD_KEYCODE_PA1 0xFD
+#define SQMOD_KEYCODE_PACKET 0xE7
+#define SQMOD_KEYCODE_PLAY 0xFA
+#define SQMOD_KEYCODE_PROCESSKEY 0xE5
+#define SQMOD_KEYCODE_RETURN 0x0D
+#define SQMOD_KEYCODE_SELECT 0x29
+#define SQMOD_KEYCODE_SEPARATOR 0x6C
+#define SQMOD_KEYCODE_SPACE 0x20
+#define SQMOD_KEYCODE_SUBTRACT 0x6D
+#define SQMOD_KEYCODE_TAB 0x09
+#define SQMOD_KEYCODE_ZOOM 0xFB
+#define SQMOD_KEYCODE_ACCEPT 0x1E
+#define SQMOD_KEYCODE_APPS 0x5D
+#define SQMOD_KEYCODE_BROWSER_BACK 0xA6
+#define SQMOD_KEYCODE_BROWSER_FAVORITES 0xAB
+#define SQMOD_KEYCODE_BROWSER_FORWARD 0xA7
+#define SQMOD_KEYCODE_BROWSER_HOME 0xAC
+#define SQMOD_KEYCODE_BROWSER_REFRESH 0xA8
+#define SQMOD_KEYCODE_BROWSER_SEARCH 0xAA
+#define SQMOD_KEYCODE_BROWSER_STOP 0xA9
+#define SQMOD_KEYCODE_CAPITAL 0x14
+#define SQMOD_KEYCODE_CONVERT 0x1C
+#define SQMOD_KEYCODE_DELETE 0x2E
+#define SQMOD_KEYCODE_DOWN 0x28
+#define SQMOD_KEYCODE_END 0x23
+#define SQMOD_KEYCODE_F1 0x70
+#define SQMOD_KEYCODE_F10 0x79
+#define SQMOD_KEYCODE_F11 0x7A
+#define SQMOD_KEYCODE_F12 0x7B
+#define SQMOD_KEYCODE_F13 0x7C
+#define SQMOD_KEYCODE_F14 0x7D
+#define SQMOD_KEYCODE_F15 0x7E
+#define SQMOD_KEYCODE_F16 0x7F
+#define SQMOD_KEYCODE_F17 0x80
+#define SQMOD_KEYCODE_F18 0x81
+#define SQMOD_KEYCODE_F19 0x82
+#define SQMOD_KEYCODE_F2 0x71
+#define SQMOD_KEYCODE_F20 0x83
+#define SQMOD_KEYCODE_F21 0x84
+#define SQMOD_KEYCODE_F22 0x85
+#define SQMOD_KEYCODE_F23 0x86
+#define SQMOD_KEYCODE_F24 0x87
+#define SQMOD_KEYCODE_F3 0x72
+#define SQMOD_KEYCODE_F4 0x73
+#define SQMOD_KEYCODE_F5 0x74
+#define SQMOD_KEYCODE_F6 0x75
+#define SQMOD_KEYCODE_F7 0x76
+#define SQMOD_KEYCODE_F8 0x77
+#define SQMOD_KEYCODE_F9 0x78
+#define SQMOD_KEYCODE_FINAL 0x18
+#define SQMOD_KEYCODE_HELP 0x2F
+#define SQMOD_KEYCODE_HOME 0x24
+#define SQMOD_KEYCODE_ICO_00 0xE4
+#define SQMOD_KEYCODE_INSERT 0x2D
+#define SQMOD_KEYCODE_JUNJA 0x17
+#define SQMOD_KEYCODE_KANA 0x15
+#define SQMOD_KEYCODE_KANJI 0x19
+#define SQMOD_KEYCODE_LAUNCH_APP1 0xB6
+#define SQMOD_KEYCODE_LAUNCH_APP2 0xB7
+#define SQMOD_KEYCODE_LAUNCH_MAIL 0xB4
+#define SQMOD_KEYCODE_LAUNCH_MEDIA_SELECT 0xB5
+#define SQMOD_KEYCODE_LBUTTON 0x01
+#define SQMOD_KEYCODE_LCONTROL 0xA2
+#define SQMOD_KEYCODE_LEFT 0x25
+#define SQMOD_KEYCODE_LMENU 0xA4
+#define SQMOD_KEYCODE_LSHIFT 0xA0
+#define SQMOD_KEYCODE_LWIN 0x5B
+#define SQMOD_KEYCODE_MBUTTON 0x04
+#define SQMOD_KEYCODE_MEDIA_NEXT_TRACK 0xB0
+#define SQMOD_KEYCODE_MEDIA_PLAY_PAUSE 0xB3
+#define SQMOD_KEYCODE_MEDIA_PREV_TRACK 0xB1
+#define SQMOD_KEYCODE_MEDIA_STOP 0xB2
+#define SQMOD_KEYCODE_MODECHANGE 0x1F
+#define SQMOD_KEYCODE_NEXT 0x22
+#define SQMOD_KEYCODE_NONCONVERT 0x1D
+#define SQMOD_KEYCODE_NUMLOCK 0x90
+#define SQMOD_KEYCODE_OEM_FJ_JISHO 0x92
+#define SQMOD_KEYCODE_PAUSE 0x13
+#define SQMOD_KEYCODE_PRINT 0x2A
+#define SQMOD_KEYCODE_PRIOR 0x21
+#define SQMOD_KEYCODE_RBUTTON 0x02
+#define SQMOD_KEYCODE_RCONTROL 0xA3
+#define SQMOD_KEYCODE_RIGHT 0x27
+#define SQMOD_KEYCODE_RMENU 0xA5
+#define SQMOD_KEYCODE_RSHIFT 0xA1
+#define SQMOD_KEYCODE_RWIN 0x5C
+#define SQMOD_KEYCODE_SCROLL 0x91
+#define SQMOD_KEYCODE_SLEEP 0x5F
+#define SQMOD_KEYCODE_SNAPSHOT 0x2C
+#define SQMOD_KEYCODE_UP 0x26
+#define SQMOD_KEYCODE_VOLUME_DOWN 0xAE
+#define SQMOD_KEYCODE_VOLUME_MUTE 0xAD
+#define SQMOD_KEYCODE_VOLUME_UP 0xAF
+#define SQMOD_KEYCODE_XBUTTON1 0x05
+#define SQMOD_KEYCODE_XBUTTON2 0x06
+#define SQMOD_KEYCODE_NONE 0xFF
+#define SQMOD_KEYCODE_MAX 0x100
+
+/* ------------------------------------------------------------------------------------------------
+ * ASCII CHARACTER CODES
+*/
+#define SQMOD_ASCII_NUL 0
+#define SQMOD_ASCII_SOH 1
+#define SQMOD_ASCII_STX 2
+#define SQMOD_ASCII_ETX 3
+#define SQMOD_ASCII_EOT 4
+#define SQMOD_ASCII_ENQ 5
+#define SQMOD_ASCII_ACK 6
+#define SQMOD_ASCII_BEL 7
+#define SQMOD_ASCII_BS 8
+#define SQMOD_ASCII_TAB 9
+#define SQMOD_ASCII_LF 10
+#define SQMOD_ASCII_VT 11
+#define SQMOD_ASCII_FF 12
+#define SQMOD_ASCII_CR 13
+#define SQMOD_ASCII_SO 14
+#define SQMOD_ASCII_SI 15
+#define SQMOD_ASCII_DLE 16
+#define SQMOD_ASCII_DC1 17
+#define SQMOD_ASCII_DC2 18
+#define SQMOD_ASCII_DC3 19
+#define SQMOD_ASCII_DC4 20
+#define SQMOD_ASCII_NAK 21
+#define SQMOD_ASCII_SYN 22
+#define SQMOD_ASCII_ETB 23
+#define SQMOD_ASCII_CAN 24
+#define SQMOD_ASCII_EM 25
+#define SQMOD_ASCII_SUB 26
+#define SQMOD_ASCII_ESC 27
+#define SQMOD_ASCII_FS 28
+#define SQMOD_ASCII_GS 29
+#define SQMOD_ASCII_RS 30
+#define SQMOD_ASCII_US 31
+#define SQMOD_ASCII_SPACE 32
+#define SQMOD_ASCII_EXCLAMATION_POINT 33
+#define SQMOD_ASCII_DOUBLE_QUOTES 34
+#define SQMOD_ASCII_NUMBER_SIGN 35
+#define SQMOD_ASCII_DOLLAR_SIGN 36
+#define SQMOD_ASCII_PERCENT_SIGN 37
+#define SQMOD_ASCII_AMPERSAND 38
+#define SQMOD_ASCII_SINGLE_QUOTE 39
+#define SQMOD_ASCII_OPENING_PARENTHESIS 40
+#define SQMOD_ASCII_CLOSING_PARENTHESIS 41
+#define SQMOD_ASCII_ASTERISK 42
+#define SQMOD_ASCII_PLUS 43
+#define SQMOD_ASCII_COMMA 44
+#define SQMOD_ASCII_MINUS 45
+#define SQMOD_ASCII_PERIOD 46
+#define SQMOD_ASCII_SLASH 47
+#define SQMOD_ASCII_ZERO 48
+#define SQMOD_ASCII_ONE 49
+#define SQMOD_ASCII_TWO 50
+#define SQMOD_ASCII_THREE 51
+#define SQMOD_ASCII_FOUR 52
+#define SQMOD_ASCII_FIVE 53
+#define SQMOD_ASCII_SIX 54
+#define SQMOD_ASCII_SEVEN 55
+#define SQMOD_ASCII_EIGHT 56
+#define SQMOD_ASCII_NINE 57
+#define SQMOD_ASCII_COLON 58
+#define SQMOD_ASCII_EMICOLON 59
+#define SQMOD_ASCII_LESS_THAN_SIGN 60
+#define SQMOD_ASCII_EQUAL_SIGN 61
+#define SQMOD_ASCII_GREATER_THAN_SIGN 62
+#define SQMOD_ASCII_QUESTION_MARK 63
+#define SQMOD_ASCII_AT 64
+#define SQMOD_ASCII_UPPER_A 65
+#define SQMOD_ASCII_UPPER_B 66
+#define SQMOD_ASCII_UPPER_C 67
+#define SQMOD_ASCII_UPPER_D 68
+#define SQMOD_ASCII_UPPER_E 69
+#define SQMOD_ASCII_UPPER_F 70
+#define SQMOD_ASCII_UPPER_G 71
+#define SQMOD_ASCII_UPPER_H 72
+#define SQMOD_ASCII_UPPER_I 73
+#define SQMOD_ASCII_UPPER_J 74
+#define SQMOD_ASCII_UPPER_K 75
+#define SQMOD_ASCII_UPPER_L 76
+#define SQMOD_ASCII_UPPER_M 77
+#define SQMOD_ASCII_UPPER_N 78
+#define SQMOD_ASCII_UPPER_O 79
+#define SQMOD_ASCII_UPPER_P 80
+#define SQMOD_ASCII_UPPER_Q 81
+#define SQMOD_ASCII_UPPER_R 82
+#define SQMOD_ASCII_UPPER_S 83
+#define SQMOD_ASCII_UPPER_T 84
+#define SQMOD_ASCII_UPPER_U 85
+#define SQMOD_ASCII_UPPER_V 86
+#define SQMOD_ASCII_UPPER_W 87
+#define SQMOD_ASCII_UPPER_X 88
+#define SQMOD_ASCII_UPPER_Y 89
+#define SQMOD_ASCII_UPPER_Z 90
+#define SQMOD_ASCII_OPENING_BRACKET 91
+#define SQMOD_ASCII_BACKSLASH 92
+#define SQMOD_ASCII_CLOSING_BRACKET 93
+#define SQMOD_ASCII_CARET 94
+#define SQMOD_ASCII_UNDERSCORE 95
+#define SQMOD_ASCII_GRAVE_ACCENT 96
+#define SQMOD_ASCII_LOWER_A 97
+#define SQMOD_ASCII_LOWER_B 98
+#define SQMOD_ASCII_LOWER_C 99
+#define SQMOD_ASCII_LOWER_D 100
+#define SQMOD_ASCII_LOWER_E 101
+#define SQMOD_ASCII_LOWER_F 102
+#define SQMOD_ASCII_LOWER_G 103
+#define SQMOD_ASCII_LOWER_H 104
+#define SQMOD_ASCII_LOWER_I 105
+#define SQMOD_ASCII_LOWER_J 106
+#define SQMOD_ASCII_LOWER_K 107
+#define SQMOD_ASCII_LOWER_L 108
+#define SQMOD_ASCII_LOWER_M 109
+#define SQMOD_ASCII_LOWER_N 110
+#define SQMOD_ASCII_LOWER_O 111
+#define SQMOD_ASCII_LOWER_P 112
+#define SQMOD_ASCII_LOWER_Q 113
+#define SQMOD_ASCII_LOWER_R 114
+#define SQMOD_ASCII_LOWER_S 115
+#define SQMOD_ASCII_LOWER_T 116
+#define SQMOD_ASCII_LOWER_U 117
+#define SQMOD_ASCII_LOWER_V 118
+#define SQMOD_ASCII_LOWER_W 119
+#define SQMOD_ASCII_LOWER_X 120
+#define SQMOD_ASCII_LOWER_Y 121
+#define SQMOD_ASCII_LOWER_Z 122
+#define SQMOD_ASCII_OPENING_BRACE 123
+#define SQMOD_ASCII_VERTICAL_BAR 124
+#define SQMOD_ASCII_CLOSING_BRACE 125
+#define SQMOD_ASCII_TILDE 126
+#define SQMOD_ASCII_UNDEFINED 127
+#define SQMOD_ASCII_MAX 128
+
+#endif // _SQBASE_HPP_
diff --git a/shared/sq_api.h b/shared/SqAPI.h
similarity index 100%
rename from shared/sq_api.h
rename to shared/SqAPI.h
diff --git a/shared/sq_mod.c b/shared/SqMod.c
similarity index 69%
rename from shared/sq_mod.c
rename to shared/SqMod.c
index 00ada16c..56d818a5 100644
--- a/shared/sq_mod.c
+++ b/shared/SqMod.c
@@ -1,4 +1,4 @@
// ////////////////////////////////////////////////////////////////////////////////////////////////
-#include "sq_mod.h"
-#include "sq_mod.inl"
+#include "SqMod.h"
+#include "SqMod.inl"
/* This method is used toa void compilers warning about C++ flags on C files and viceversa. */
\ No newline at end of file
diff --git a/shared/sq_mod.cpp b/shared/SqMod.cpp
similarity index 69%
rename from shared/sq_mod.cpp
rename to shared/SqMod.cpp
index 00ada16c..56d818a5 100644
--- a/shared/sq_mod.cpp
+++ b/shared/SqMod.cpp
@@ -1,4 +1,4 @@
// ////////////////////////////////////////////////////////////////////////////////////////////////
-#include "sq_mod.h"
-#include "sq_mod.inl"
+#include "SqMod.h"
+#include "SqMod.inl"
/* This method is used toa void compilers warning about C++ flags on C files and viceversa. */
\ No newline at end of file
diff --git a/shared/SqMod.h b/shared/SqMod.h
new file mode 100644
index 00000000..f3574497
--- /dev/null
+++ b/shared/SqMod.h
@@ -0,0 +1,136 @@
+//
+// SqModule: API used to communicate with and register squirrel modules
+//
+
+//
+// Copyright (c) 2009 Sandu Liviu Catalin (aka. S.L.C)
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source
+// distribution.
+//
+
+#if !defined(_SQ_MOD_H_)
+#define _SQ_MOD_H_
+
+#include "SqAPI.h"
+#include "vcmp.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /**< 64 bits integer types */
+ #if defined(_MSC_VER)
+ typedef __int64 SqInt64;
+ typedef unsigned __int64 SqUint64;
+ #else
+ typedef long long SqInt64;
+ typedef unsigned long long SqUint64;
+ #endif
+
+ #if defined(_MSC_VER)
+ #define SQMOD_API_EXPORT extern "C" __declspec(dllexport)
+ #elif defined(__GNUC__)
+ #define SQMOD_API_EXPORT extern "C"
+ #else
+ #define SQMOD_API_EXPORT extern "C"
+ #endif
+
+ #define SQMOD_HOST_NAME "SqModHost"
+ #define SQMOD_INITIALIZE_CMD 0xDABBAD00
+ #define SQMOD_LOAD_CMD 0xDEADBABE
+ #define SQMOD_TERMINATE_CMD 0xDEADC0DE
+ #define SQMOD_API_VER 1
+
+ /*primitive functions*/
+ typedef HSQAPI (*SqEx_GetSquirrelAPI) (void);
+ typedef HSQUIRRELVM (*SqEx_GetSquirrelVM) (void);
+ /*logging utilities*/
+ typedef void (*SqEx_LogMessage) (const SQChar * fmt, ...);
+ typedef void (*SqEx_SqThrow) (const SQChar * fmt, ...);
+ /*long numbers*/
+ typedef SQRESULT (*SqEx_GetSLongValue) (HSQUIRRELVM vm, SQInteger idx, SqInt64 * num);
+ typedef void (*SqEx_PushSLongObject) (HSQUIRRELVM vm, SqInt64 num);
+ typedef SQRESULT (*SqEx_GetULongValue) (HSQUIRRELVM vm, SQInteger idx, SqUint64 * num);
+ typedef void (*SqEx_PushULongObject) (HSQUIRRELVM vm, SqUint64 num);
+ /*time utilities*/
+ typedef SqInt64 (*SqEx_GetCurrentSysTime) (void);
+ typedef SqInt64 (*SqEx_GetEpochTimeMicro) (void);
+ typedef SqInt64 (*SqEx_GetEpochTimeMilli) (void);
+ typedef SQRESULT (*SqEx_GetTimestamp) (HSQUIRRELVM vm, SQInteger idx, SqInt64 * num);
+ typedef void (*SqEx_PushTimestamp) (HSQUIRRELVM vm, SqInt64 num);
+
+ /* --------------------------------------------------------------------------------------------
+ * Allows modules to interface with the plugin API without linking of any sorts
+ */
+ typedef struct
+ {
+ unsigned int uStructSize;
+ /*primitive functions*/
+ SqEx_GetSquirrelAPI GetSquirrelAPI;
+ SqEx_GetSquirrelVM GetSquirrelVM;
+ /*logging utilities*/
+ SqEx_LogMessage LogDbg;
+ SqEx_LogMessage LogUsr;
+ SqEx_LogMessage LogScs;
+ SqEx_LogMessage LogInf;
+ SqEx_LogMessage LogWrn;
+ SqEx_LogMessage LogErr;
+ SqEx_LogMessage LogFtl;
+ SqEx_LogMessage LogSDbg;
+ SqEx_LogMessage LogSUsr;
+ SqEx_LogMessage LogSScs;
+ SqEx_LogMessage LogSInf;
+ SqEx_LogMessage LogSWrn;
+ SqEx_LogMessage LogSErr;
+ SqEx_LogMessage LogSFtl;
+ SqEx_SqThrow SqThrow;
+ /*long numbers*/
+ SqEx_GetSLongValue GetSLongValue;
+ SqEx_PushSLongObject PushSLongObject;
+ SqEx_GetULongValue GetULongValue;
+ SqEx_PushULongObject PushULongObject;
+ /*time utilities*/
+ SqEx_GetCurrentSysTime GetCurrentSysTime;
+ SqEx_GetEpochTimeMicro GetEpochTimeMicro;
+ SqEx_GetEpochTimeMilli GetEpochTimeMilli;
+ SqEx_GetTimestamp GetTimestamp;
+ SqEx_PushTimestamp PushTimestamp;
+ } sq_exports, SQEXPORTS, *HSQEXPORTS;
+
+ /* --------------------------------------------------------------------------------------------
+ * Import the functions from the main squirrel plugin.
+ */
+ SQUIRREL_API HSQEXPORTS sq_api_import(PluginFuncs * vcapi);
+
+ /* --------------------------------------------------------------------------------------------
+ * Assign the functions from the specified API structure into the global functions.
+ */
+ SQUIRREL_API SQRESULT sq_api_expand(HSQAPI sqapi);
+
+ /* --------------------------------------------------------------------------------------------
+ * Undo changes done by sq_api_expand.
+ */
+ SQUIRREL_API void sq_api_collapse();
+
+#ifdef __cplusplus
+} /*extern "C"*/
+#endif
+
+#endif /*_SQ_API_H_*/
diff --git a/shared/SqMod.inl b/shared/SqMod.inl
new file mode 100644
index 00000000..3cfb878f
--- /dev/null
+++ b/shared/SqMod.inl
@@ -0,0 +1,587 @@
+// ------------------------------------------------------------------------------------------------
+#ifdef SQMOD_PLUGIN_API
+
+/*vm*/
+sqapi_open sq_open = NULL;
+sqapi_newthread sq_newthread = NULL;
+sqapi_seterrorhandler sq_seterrorhandler = NULL;
+sqapi_close sq_close = NULL;
+sqapi_setforeignptr sq_setforeignptr = NULL;
+sqapi_getforeignptr sq_getforeignptr = NULL;
+sqapi_setsharedforeignptr sq_setsharedforeignptr = NULL;
+sqapi_getsharedforeignptr sq_getsharedforeignptr = NULL;
+sqapi_setvmreleasehook sq_setvmreleasehook = NULL;
+sqapi_getvmreleasehook sq_getvmreleasehook = NULL;
+sqapi_setsharedreleasehook sq_setsharedreleasehook = NULL;
+sqapi_getsharedreleasehook sq_getsharedreleasehook = NULL;
+sqapi_setprintfunc sq_setprintfunc = NULL;
+sqapi_getprintfunc sq_getprintfunc = NULL;
+sqapi_geterrorfunc sq_geterrorfunc = NULL;
+sqapi_suspendvm sq_suspendvm = NULL;
+sqapi_wakeupvm sq_wakeupvm = NULL;
+sqapi_getvmstate sq_getvmstate = NULL;
+sqapi_getversion sq_getversion = NULL;
+
+/*compiler*/
+sqapi_compile sq_compile = NULL;
+sqapi_compilebuffer sq_compilebuffer = NULL;
+sqapi_enabledebuginfo sq_enabledebuginfo = NULL;
+sqapi_notifyallexceptions sq_notifyallexceptions = NULL;
+sqapi_setcompilererrorhandler sq_setcompilererrorhandler = NULL;
+
+/*stack operations*/
+sqapi_push sq_push = NULL;
+sqapi_pop sq_pop = NULL;
+sqapi_poptop sq_poptop = NULL;
+sqapi_remove sq_remove = NULL;
+sqapi_gettop sq_gettop = NULL;
+sqapi_settop sq_settop = NULL;
+sqapi_reservestack sq_reservestack = NULL;
+sqapi_cmp sq_cmp = NULL;
+sqapi_move sq_move = NULL;
+
+/*object creation handling*/
+sqapi_newuserdata sq_newuserdata = NULL;
+sqapi_newtable sq_newtable = NULL;
+sqapi_newtableex sq_newtableex = NULL;
+sqapi_newarray sq_newarray = NULL;
+sqapi_newclosure sq_newclosure = NULL;
+sqapi_setparamscheck sq_setparamscheck = NULL;
+sqapi_bindenv sq_bindenv = NULL;
+sqapi_setclosureroot sq_setclosureroot = NULL;
+sqapi_getclosureroot sq_getclosureroot = NULL;
+sqapi_pushstring sq_pushstring = NULL;
+sqapi_pushfloat sq_pushfloat = NULL;
+sqapi_pushinteger sq_pushinteger = NULL;
+sqapi_pushbool sq_pushbool = NULL;
+sqapi_pushuserpointer sq_pushuserpointer = NULL;
+sqapi_pushnull sq_pushnull = NULL;
+sqapi_pushthread sq_pushthread = NULL;
+sqapi_gettype sq_gettype = NULL;
+sqapi_typeof sq_typeof = NULL;
+sqapi_getsize sq_getsize = NULL;
+sqapi_gethash sq_gethash = NULL;
+sqapi_getbase sq_getbase = NULL;
+sqapi_instanceof sq_instanceof = NULL;
+sqapi_tostring sq_tostring = NULL;
+sqapi_tobool sq_tobool = NULL;
+sqapi_getstring sq_getstring = NULL;
+sqapi_getinteger sq_getinteger = NULL;
+sqapi_getfloat sq_getfloat = NULL;
+sqapi_getbool sq_getbool = NULL;
+sqapi_getthread sq_getthread = NULL;
+sqapi_getuserpointer sq_getuserpointer = NULL;
+sqapi_getuserdata sq_getuserdata = NULL;
+sqapi_settypetag sq_settypetag = NULL;
+sqapi_gettypetag sq_gettypetag = NULL;
+sqapi_setreleasehook sq_setreleasehook = NULL;
+sqapi_getreleasehook sq_getreleasehook = NULL;
+sqapi_getscratchpad sq_getscratchpad = NULL;
+sqapi_getfunctioninfo sq_getfunctioninfo = NULL;
+sqapi_getclosureinfo sq_getclosureinfo = NULL;
+sqapi_getclosurename sq_getclosurename = NULL;
+sqapi_setnativeclosurename sq_setnativeclosurename = NULL;
+sqapi_setinstanceup sq_setinstanceup = NULL;
+sqapi_getinstanceup sq_getinstanceup = NULL;
+sqapi_setclassudsize sq_setclassudsize = NULL;
+sqapi_newclass sq_newclass = NULL;
+sqapi_createinstance sq_createinstance = NULL;
+sqapi_setattributes sq_setattributes = NULL;
+sqapi_getattributes sq_getattributes = NULL;
+sqapi_getclass sq_getclass = NULL;
+sqapi_weakref sq_weakref = NULL;
+sqapi_getdefaultdelegate sq_getdefaultdelegate = NULL;
+sqapi_getmemberhandle sq_getmemberhandle = NULL;
+sqapi_getbyhandle sq_getbyhandle = NULL;
+sqapi_setbyhandle sq_setbyhandle = NULL;
+
+/*object manipulation*/
+sqapi_pushroottable sq_pushroottable = NULL;
+sqapi_pushregistrytable sq_pushregistrytable = NULL;
+sqapi_pushconsttable sq_pushconsttable = NULL;
+sqapi_setroottable sq_setroottable = NULL;
+sqapi_setconsttable sq_setconsttable = NULL;
+sqapi_newslot sq_newslot = NULL;
+sqapi_deleteslot sq_deleteslot = NULL;
+sqapi_set sq_set = NULL;
+sqapi_get sq_get = NULL;
+sqapi_rawget sq_rawget = NULL;
+sqapi_rawset sq_rawset = NULL;
+sqapi_rawdeleteslot sq_rawdeleteslot = NULL;
+sqapi_newmember sq_newmember = NULL;
+sqapi_rawnewmember sq_rawnewmember = NULL;
+sqapi_arrayappend sq_arrayappend = NULL;
+sqapi_arraypop sq_arraypop = NULL;
+sqapi_arrayresize sq_arrayresize = NULL;
+sqapi_arrayreverse sq_arrayreverse = NULL;
+sqapi_arrayremove sq_arrayremove = NULL;
+sqapi_arrayinsert sq_arrayinsert = NULL;
+sqapi_setdelegate sq_setdelegate = NULL;
+sqapi_getdelegate sq_getdelegate = NULL;
+sqapi_clone sq_clone = NULL;
+sqapi_setfreevariable sq_setfreevariable = NULL;
+sqapi_next sq_next = NULL;
+sqapi_getweakrefval sq_getweakrefval = NULL;
+sqapi_clear sq_clear = NULL;
+
+/*calls*/
+sqapi_call sq_call = NULL;
+sqapi_resume sq_resume = NULL;
+sqapi_getlocal sq_getlocal = NULL;
+sqapi_getcallee sq_getcallee = NULL;
+sqapi_getfreevariable sq_getfreevariable = NULL;
+sqapi_throwerror sq_throwerror = NULL;
+sqapi_throwobject sq_throwobject = NULL;
+sqapi_reseterror sq_reseterror = NULL;
+sqapi_getlasterror sq_getlasterror = NULL;
+
+/*raw object handling*/
+sqapi_getstackobj sq_getstackobj = NULL;
+sqapi_pushobject sq_pushobject = NULL;
+sqapi_addref sq_addref = NULL;
+sqapi_release sq_release = NULL;
+sqapi_getrefcount sq_getrefcount = NULL;
+sqapi_resetobject sq_resetobject = NULL;
+sqapi_objtostring sq_objtostring = NULL;
+sqapi_objtobool sq_objtobool = NULL;
+sqapi_objtointeger sq_objtointeger = NULL;
+sqapi_objtofloat sq_objtofloat = NULL;
+sqapi_objtouserpointer sq_objtouserpointer = NULL;
+sqapi_getobjtypetag sq_getobjtypetag = NULL;
+sqapi_getvmrefcount sq_getvmrefcount = NULL;
+
+/*GC*/
+sqapi_collectgarbage sq_collectgarbage = NULL;
+sqapi_resurrectunreachable sq_resurrectunreachable = NULL;
+
+/*serialization*/
+sqapi_writeclosure sq_writeclosure = NULL;
+sqapi_readclosure sq_readclosure = NULL;
+
+/*mem allocation*/
+sqapi_malloc sq_malloc = NULL;
+sqapi_realloc sq_realloc = NULL;
+sqapi_free sq_free = NULL;
+
+/*debug*/
+sqapi_stackinfos sq_stackinfos = NULL;
+sqapi_setdebughook sq_setdebughook = NULL;
+sqapi_setnativedebughook sq_setnativedebughook = NULL;
+
+/*compiler helpers*/
+sqapi_loadfile sqstd_loadfile = NULL;
+sqapi_dofile sqstd_dofile = NULL;
+sqapi_writeclosuretofile sqstd_writeclosuretofile = NULL;
+
+/*blob*/
+sqapi_createblob sqstd_createblob = NULL;
+sqapi_getblob sqstd_getblob = NULL;
+sqapi_getblobsize sqstd_getblobsize = NULL;
+
+/*string*/
+sqapi_format sqstd_format = NULL;
+
+#endif // SQMOD_PLUGIN_API
+
+// ------------------------------------------------------------------------------------------------
+HSQEXPORTS sq_api_import(PluginFuncs * vcapi)
+{
+ // Make sure a valid plugin api and reference to exports structure pointer was specified
+ if (!vcapi)
+ {
+ return NULL;
+ }
+ unsigned int struct_size;
+ // Attempt to find the main plugin ID
+ int plugin_id = vcapi->FindPlugin((char *)(SQMOD_HOST_NAME));
+ // Attempt to retrieve the plugin exports
+ void ** plugin_exports = vcapi->GetPluginExports(plugin_id, &struct_size);
+ // See if we have any imports from Squirrel
+ if (plugin_exports == NULL || struct_size <= 0)
+ {
+ return NULL;
+ }
+ // Simply return the obtain poiner to the exports structure
+ return *(sq_exports **)plugin_exports;
+}
+
+// ------------------------------------------------------------------------------------------------
+SQRESULT sq_api_expand(HSQAPI sqapi)
+{
+ if (!sqapi)
+ return SQ_ERROR;
+
+#ifdef SQMOD_PLUGIN_API
+
+ /*vm*/
+ sq_open = sqapi->open;
+ sq_newthread = sqapi->newthread;
+ sq_seterrorhandler = sqapi->seterrorhandler;
+ sq_close = sqapi->close;
+ sq_setforeignptr = sqapi->setforeignptr;
+ sq_getforeignptr = sqapi->getforeignptr;
+ sq_setsharedforeignptr = sqapi->setsharedforeignptr;
+ sq_getsharedforeignptr = sqapi->getsharedforeignptr;
+ sq_setvmreleasehook = sqapi->setvmreleasehook;
+ sq_getvmreleasehook = sqapi->getvmreleasehook;
+ sq_setsharedreleasehook = sqapi->setsharedreleasehook;
+ sq_getsharedreleasehook = sqapi->getsharedreleasehook;
+ sq_setprintfunc = sqapi->setprintfunc;
+ sq_getprintfunc = sqapi->getprintfunc;
+ sq_geterrorfunc = sqapi->geterrorfunc;
+ sq_suspendvm = sqapi->suspendvm;
+ sq_wakeupvm = sqapi->wakeupvm;
+ sq_getvmstate = sqapi->getvmstate;
+ sq_getversion = sqapi->getversion;
+
+ /*compiler*/
+ sq_compile = sqapi->compile;
+ sq_compilebuffer = sqapi->compilebuffer;
+ sq_enabledebuginfo = sqapi->enabledebuginfo;
+ sq_notifyallexceptions = sqapi->notifyallexceptions;
+ sq_setcompilererrorhandler = sqapi->setcompilererrorhandler;
+
+ /*stack operations*/
+ sq_push = sqapi->push;
+ sq_pop = sqapi->pop;
+ sq_poptop = sqapi->poptop;
+ sq_remove = sqapi->remove;
+ sq_gettop = sqapi->gettop;
+ sq_settop = sqapi->settop;
+ sq_reservestack = sqapi->reservestack;
+ sq_cmp = sqapi->cmp;
+ sq_move = sqapi->move;
+
+ /*object creation handling*/
+ sq_newuserdata = sqapi->newuserdata;
+ sq_newtable = sqapi->newtable;
+ sq_newtableex = sqapi->newtableex;
+ sq_newarray = sqapi->newarray;
+ sq_newclosure = sqapi->newclosure;
+ sq_setparamscheck = sqapi->setparamscheck;
+ sq_bindenv = sqapi->bindenv;
+ sq_setclosureroot = sqapi->setclosureroot;
+ sq_getclosureroot = sqapi->getclosureroot;
+ sq_pushstring = sqapi->pushstring;
+ sq_pushfloat = sqapi->pushfloat;
+ sq_pushinteger = sqapi->pushinteger;
+ sq_pushbool = sqapi->pushbool;
+ sq_pushuserpointer = sqapi->pushuserpointer;
+ sq_pushnull = sqapi->pushnull;
+ sq_pushthread = sqapi->pushthread;
+ sq_gettype = sqapi->gettype;
+ sq_typeof = sqapi->typeof_;
+ sq_getsize = sqapi->getsize;
+ sq_gethash = sqapi->gethash;
+ sq_getbase = sqapi->getbase;
+ sq_instanceof = sqapi->instanceof;
+ sq_tostring = sqapi->tostring;
+ sq_tobool = sqapi->tobool;
+ sq_getstring = sqapi->getstring;
+ sq_getinteger = sqapi->getinteger;
+ sq_getfloat = sqapi->getfloat;
+ sq_getbool = sqapi->getbool;
+ sq_getthread = sqapi->getthread;
+ sq_getuserpointer = sqapi->getuserpointer;
+ sq_getuserdata = sqapi->getuserdata;
+ sq_settypetag = sqapi->settypetag;
+ sq_gettypetag = sqapi->gettypetag;
+ sq_setreleasehook = sqapi->setreleasehook;
+ sq_getreleasehook = sqapi->getreleasehook;
+ sq_getscratchpad = sqapi->getscratchpad;
+ sq_getfunctioninfo = sqapi->getfunctioninfo;
+ sq_getclosureinfo = sqapi->getclosureinfo;
+ sq_getclosurename = sqapi->getclosurename;
+ sq_setnativeclosurename = sqapi->setnativeclosurename;
+ sq_setinstanceup = sqapi->setinstanceup;
+ sq_getinstanceup = sqapi->getinstanceup;
+ sq_setclassudsize = sqapi->setclassudsize;
+ sq_newclass = sqapi->newclass;
+ sq_createinstance = sqapi->createinstance;
+ sq_setattributes = sqapi->setattributes;
+ sq_getattributes = sqapi->getattributes;
+ sq_getclass = sqapi->getclass;
+ sq_weakref = sqapi->weakref;
+ sq_getdefaultdelegate = sqapi->getdefaultdelegate;
+ sq_getmemberhandle = sqapi->getmemberhandle;
+ sq_getbyhandle = sqapi->getbyhandle;
+ sq_setbyhandle = sqapi->setbyhandle;
+
+ /*object manipulation*/
+ sq_pushroottable = sqapi->pushroottable;
+ sq_pushregistrytable = sqapi->pushregistrytable;
+ sq_pushconsttable = sqapi->pushconsttable;
+ sq_setroottable = sqapi->setroottable;
+ sq_setconsttable = sqapi->setconsttable;
+ sq_newslot = sqapi->newslot;
+ sq_deleteslot = sqapi->deleteslot;
+ sq_set = sqapi->set;
+ sq_get = sqapi->get;
+ sq_rawget = sqapi->rawget;
+ sq_rawset = sqapi->rawset;
+ sq_rawdeleteslot = sqapi->rawdeleteslot;
+ sq_newmember = sqapi->newmember;
+ sq_rawnewmember = sqapi->rawnewmember;
+ sq_arrayappend = sqapi->arrayappend;
+ sq_arraypop = sqapi->arraypop;
+ sq_arrayresize = sqapi->arrayresize;
+ sq_arrayreverse = sqapi->arrayreverse;
+ sq_arrayremove = sqapi->arrayremove;
+ sq_arrayinsert = sqapi->arrayinsert;
+ sq_setdelegate = sqapi->setdelegate;
+ sq_getdelegate = sqapi->getdelegate;
+ sq_clone = sqapi->clone;
+ sq_setfreevariable = sqapi->setfreevariable;
+ sq_next = sqapi->next;
+ sq_getweakrefval = sqapi->getweakrefval;
+ sq_clear = sqapi->clear;
+
+ /*calls*/
+ sq_call = sqapi->call;
+ sq_resume = sqapi->resume;
+ sq_getlocal = sqapi->getlocal;
+ sq_getcallee = sqapi->getcallee;
+ sq_getfreevariable = sqapi->getfreevariable;
+ sq_throwerror = sqapi->throwerror;
+ sq_throwobject = sqapi->throwobject;
+ sq_reseterror = sqapi->reseterror;
+ sq_getlasterror = sqapi->getlasterror;
+
+ /*raw object handling*/
+ sq_getstackobj = sqapi->getstackobj;
+ sq_pushobject = sqapi->pushobject;
+ sq_addref = sqapi->addref;
+ sq_release = sqapi->release;
+ sq_getrefcount = sqapi->getrefcount;
+ sq_resetobject = sqapi->resetobject;
+ sq_objtostring = sqapi->objtostring;
+ sq_objtobool = sqapi->objtobool;
+ sq_objtointeger = sqapi->objtointeger;
+ sq_objtofloat = sqapi->objtofloat;
+ sq_objtouserpointer = sqapi->objtouserpointer;
+ sq_getobjtypetag = sqapi->getobjtypetag;
+ sq_getvmrefcount = sqapi->getvmrefcount;
+
+ /*GC*/
+ sq_collectgarbage = sqapi->collectgarbage;
+ sq_resurrectunreachable = sqapi->resurrectunreachable;
+
+ /*serialization*/
+ sq_writeclosure = sqapi->writeclosure;
+ sq_readclosure = sqapi->readclosure;
+
+ /*mem allocation*/
+ sq_malloc = sqapi->malloc;
+ sq_realloc = sqapi->realloc;
+ sq_free = sqapi->free;
+
+ /*debug*/
+ sq_stackinfos = sqapi->stackinfos;
+ sq_setdebughook = sqapi->setdebughook;
+ sq_setnativedebughook = sqapi->setnativedebughook;
+
+ /*compiler helpers*/
+ sqstd_loadfile = sqapi->loadfile;
+ sqstd_dofile = sqapi->dofile;
+ sqstd_writeclosuretofile = sqapi->writeclosuretofile;
+
+ /*blob*/
+ sqstd_createblob = sqapi->createblob;
+ sqstd_getblob = sqapi->getblob;
+ sqstd_getblobsize = sqapi->getblobsize;
+
+ /*string*/
+ sqstd_format = sqapi->format;
+
+#endif // SQMOD_PLUGIN_API
+
+ return SQ_OK;
+}
+
+// ------------------------------------------------------------------------------------------------
+void sq_api_collapse()
+{
+#ifdef SQMOD_PLUGIN_API
+
+ /*vm*/
+ sq_open = NULL;
+ sq_newthread = NULL;
+ sq_seterrorhandler = NULL;
+ sq_close = NULL;
+ sq_setforeignptr = NULL;
+ sq_getforeignptr = NULL;
+ sq_setsharedforeignptr = NULL;
+ sq_getsharedforeignptr = NULL;
+ sq_setvmreleasehook = NULL;
+ sq_getvmreleasehook = NULL;
+ sq_setsharedreleasehook = NULL;
+ sq_getsharedreleasehook = NULL;
+ sq_setprintfunc = NULL;
+ sq_getprintfunc = NULL;
+ sq_geterrorfunc = NULL;
+ sq_suspendvm = NULL;
+ sq_wakeupvm = NULL;
+ sq_getvmstate = NULL;
+ sq_getversion = NULL;
+
+ /*compiler*/
+ sq_compile = NULL;
+ sq_compilebuffer = NULL;
+ sq_enabledebuginfo = NULL;
+ sq_notifyallexceptions = NULL;
+ sq_setcompilererrorhandler = NULL;
+
+ /*stack operations*/
+ sq_push = NULL;
+ sq_pop = NULL;
+ sq_poptop = NULL;
+ sq_remove = NULL;
+ sq_gettop = NULL;
+ sq_settop = NULL;
+ sq_reservestack = NULL;
+ sq_cmp = NULL;
+ sq_move = NULL;
+
+ /*object creation handling*/
+ sq_newuserdata = NULL;
+ sq_newtable = NULL;
+ sq_newtableex = NULL;
+ sq_newarray = NULL;
+ sq_newclosure = NULL;
+ sq_setparamscheck = NULL;
+ sq_bindenv = NULL;
+ sq_setclosureroot = NULL;
+ sq_getclosureroot = NULL;
+ sq_pushstring = NULL;
+ sq_pushfloat = NULL;
+ sq_pushinteger = NULL;
+ sq_pushbool = NULL;
+ sq_pushuserpointer = NULL;
+ sq_pushnull = NULL;
+ sq_pushthread = NULL;
+ sq_gettype = NULL;
+ sq_typeof = NULL;
+ sq_getsize = NULL;
+ sq_gethash = NULL;
+ sq_getbase = NULL;
+ sq_instanceof = NULL;
+ sq_tostring = NULL;
+ sq_tobool = NULL;
+ sq_getstring = NULL;
+ sq_getinteger = NULL;
+ sq_getfloat = NULL;
+ sq_getbool = NULL;
+ sq_getthread = NULL;
+ sq_getuserpointer = NULL;
+ sq_getuserdata = NULL;
+ sq_settypetag = NULL;
+ sq_gettypetag = NULL;
+ sq_setreleasehook = NULL;
+ sq_getreleasehook = NULL;
+ sq_getscratchpad = NULL;
+ sq_getfunctioninfo = NULL;
+ sq_getclosureinfo = NULL;
+ sq_getclosurename = NULL;
+ sq_setnativeclosurename = NULL;
+ sq_setinstanceup = NULL;
+ sq_getinstanceup = NULL;
+ sq_setclassudsize = NULL;
+ sq_newclass = NULL;
+ sq_createinstance = NULL;
+ sq_setattributes = NULL;
+ sq_getattributes = NULL;
+ sq_getclass = NULL;
+ sq_weakref = NULL;
+ sq_getdefaultdelegate = NULL;
+ sq_getmemberhandle = NULL;
+ sq_getbyhandle = NULL;
+ sq_setbyhandle = NULL;
+
+ /*object manipulation*/
+ sq_pushroottable = NULL;
+ sq_pushregistrytable = NULL;
+ sq_pushconsttable = NULL;
+ sq_setroottable = NULL;
+ sq_setconsttable = NULL;
+ sq_newslot = NULL;
+ sq_deleteslot = NULL;
+ sq_set = NULL;
+ sq_get = NULL;
+ sq_rawget = NULL;
+ sq_rawset = NULL;
+ sq_rawdeleteslot = NULL;
+ sq_newmember = NULL;
+ sq_rawnewmember = NULL;
+ sq_arrayappend = NULL;
+ sq_arraypop = NULL;
+ sq_arrayresize = NULL;
+ sq_arrayreverse = NULL;
+ sq_arrayremove = NULL;
+ sq_arrayinsert = NULL;
+ sq_setdelegate = NULL;
+ sq_getdelegate = NULL;
+ sq_clone = NULL;
+ sq_setfreevariable = NULL;
+ sq_next = NULL;
+ sq_getweakrefval = NULL;
+ sq_clear = NULL;
+
+ /*calls*/
+ sq_call = NULL;
+ sq_resume = NULL;
+ sq_getlocal = NULL;
+ sq_getcallee = NULL;
+ sq_getfreevariable = NULL;
+ sq_throwerror = NULL;
+ sq_throwobject = NULL;
+ sq_reseterror = NULL;
+ sq_getlasterror = NULL;
+
+ /*raw object handling*/
+ sq_getstackobj = NULL;
+ sq_pushobject = NULL;
+ sq_addref = NULL;
+ sq_release = NULL;
+ sq_getrefcount = NULL;
+ sq_resetobject = NULL;
+ sq_objtostring = NULL;
+ sq_objtobool = NULL;
+ sq_objtointeger = NULL;
+ sq_objtofloat = NULL;
+ sq_objtouserpointer = NULL;
+ sq_getobjtypetag = NULL;
+ sq_getvmrefcount = NULL;
+
+ /*GC*/
+ sq_collectgarbage = NULL;
+ sq_resurrectunreachable = NULL;
+
+ /*serialization*/
+ sq_writeclosure = NULL;
+ sq_readclosure = NULL;
+
+ /*mem allocation*/
+ sq_malloc = NULL;
+ sq_realloc = NULL;
+ sq_free = NULL;
+
+ /*debug*/
+ sq_stackinfos = NULL;
+ sq_setdebughook = NULL;
+ sq_setnativedebughook = NULL;
+
+ /*compiler helpers*/
+ sqstd_loadfile = NULL;
+ sqstd_dofile = NULL;
+ sqstd_writeclosuretofile = NULL;
+
+ /*blob*/
+ sqstd_createblob = NULL;
+ sqstd_getblob = NULL;
+ sqstd_getblobsize = NULL;
+
+ /*string*/
+ sqstd_format = NULL;
+
+#endif // SQMOD_PLUGIN_API
+}
diff --git a/shared/sq_mod.h b/shared/sq_mod.h
deleted file mode 100644
index 06cc96fd..00000000
--- a/shared/sq_mod.h
+++ /dev/null
@@ -1,579 +0,0 @@
-//
-// SqModule: API used to communicate with and register squirrel modules
-//
-
-//
-// Copyright (c) 2009 Sandu Liviu Catalin (aka. S.L.C)
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-// claim that you wrote the original software. If you use this software
-// in a product, an acknowledgment in the product documentation would be
-// appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not be
-// misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-// distribution.
-//
-
-#if !defined(_SQ_MOD_H_)
-#define _SQ_MOD_H_
-
-#include "sq_api.h"
-#include "vcmp.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- #if defined(_MSC_VER)
- #define SQMOD_API_EXPORT extern "C" __declspec(dllexport)
- #elif defined(__GNUC__)
- #define SQMOD_API_EXPORT extern "C"
- #else
- #define SQMOD_API_EXPORT extern "C"
- #endif
-
- #define SQMOD_HOST_NAME "SqModHost"
- #define SQMOD_INITIALIZE_CMD 0xDABBAD00
- #define SQMOD_TERMINATE_CMD 0xDEADC0DE
-
- /* --------------------------------------------------------------------------------------------
- * Allows modules to interface with the plugin API without linking of any sorts
- */
- typedef struct
- {
- unsigned int uStructSize;
- HSQAPI (*GetSquirrelAPI) ( void );
- HSQUIRRELVM (*GetSquirrelVM) (void);
- } sq_exports, SQEXPORTS, *HSQEXPORTS;
-
- /* ------------------------------------------------------------------------------------------------
- * PLUGIN SYSTEM
- */
- extern SDK_GetServerVersion SqVC_GetServerVersion;
- extern SDK_GetServerSettings SqVC_GetServerSettings;
- extern SDK_ExportFunctions SqVC_ExportFunctions;
- extern SDK_GetNumberOfPlugins SqVC_GetNumberOfPlugins;
- extern SDK_GetPluginInfo SqVC_GetPluginInfo;
- extern SDK_FindPlugin SqVC_FindPlugin;
- extern SDK_GetPluginExports SqVC_GetPluginExports;
- extern SDK_GetTime SqVC_GetTime;
-
- /* ------------------------------------------------------------------------------------------------
- * MESSAGES
- */
- extern SDK_printf SqVC_printf;
- extern SDK_SendCustomCommand SqVC_SendCustomCommand;
- extern SDK_SendClientMessage SqVC_SendClientMessage;
- extern SDK_SendGameMessage SqVC_SendGameMessage;
-
- /* ------------------------------------------------------------------------------------------------
- * SERVER SETTINGS
- */
- extern SDK_SetServerName SqVC_SetServerName;
- extern SDK_GetServerName SqVC_GetServerName;
- extern SDK_SetMaxPlayers SqVC_SetMaxPlayers;
- extern SDK_GetMaxPlayers SqVC_GetMaxPlayers;
- extern SDK_SetServerPassword SqVC_SetServerPassword;
- extern SDK_GetServerPassword SqVC_GetServerPassword;
- extern SDK_SetGameModeText SqVC_SetGameModeText;
- extern SDK_GetGameModeText SqVC_GetGameModeText;
- extern SDK_ShutdownServer SqVC_ShutdownServer;
-
- /* ------------------------------------------------------------------------------------------------
- * WORLD: settings
- */
- extern SDK_SetWorldBounds SqVC_SetWorldBounds;
- extern SDK_GetWorldBounds SqVC_GetWorldBounds;
- extern SDK_SetWastedSettings SqVC_SetWastedSettings;
- extern SDK_GetWastedSettings SqVC_GetWastedSettings;
- extern SDK_SetTimeRate SqVC_SetTimeRate;
- extern SDK_GetTimeRate SqVC_GetTimeRate;
- extern SDK_SetHour SqVC_SetHour;
- extern SDK_GetHour SqVC_GetHour;
- extern SDK_SetMinute SqVC_SetMinute;
- extern SDK_GetMinute SqVC_GetMinute;
- extern SDK_SetWeather SqVC_SetWeather;
- extern SDK_GetWeather SqVC_GetWeather;
- extern SDK_SetGravity SqVC_SetGravity;
- extern SDK_GetGravity SqVC_GetGravity;
- extern SDK_SetGamespeed SqVC_SetGamespeed;
- extern SDK_GetGamespeed SqVC_GetGamespeed;
- extern SDK_SetWaterLevel SqVC_SetWaterLevel;
- extern SDK_GetWaterLevel SqVC_GetWaterLevel;
- extern SDK_SetMaxHeight SqVC_SetMaxHeight;
- extern SDK_GetMaxHeight SqVC_GetMaxHeight;
- extern SDK_SetKillCmdDelay SqVC_SetKillCmdDelay;
- extern SDK_GetKillCmdDelay SqVC_GetKillCmdDelay;
- extern SDK_SetVehiclesForcedRespawnHeight SqVC_SetVehiclesForcedRespawnHeight;
- extern SDK_GetVehiclesForcedRespawnHeight SqVC_GetVehiclesForcedRespawnHeight;
-
- /* ------------------------------------------------------------------------------------------------
- * WORLD: toggles
- */
- extern SDK_ToggleSyncFrameLimiter SqVC_ToggleSyncFrameLimiter;
- extern SDK_EnabledSyncFrameLimiter SqVC_EnabledSyncFrameLimiter;
- extern SDK_ToggleFrameLimiter SqVC_ToggleFrameLimiter;
- extern SDK_EnabledFrameLimiter SqVC_EnabledFrameLimiter;
- extern SDK_ToggleTaxiBoostJump SqVC_ToggleTaxiBoostJump;
- extern SDK_EnabledTaxiBoostJump SqVC_EnabledTaxiBoostJump;
- extern SDK_ToggleDriveOnWater SqVC_ToggleDriveOnWater;
- extern SDK_EnabledDriveOnWater SqVC_EnabledDriveOnWater;
- extern SDK_ToggleFastSwitch SqVC_ToggleFastSwitch;
- extern SDK_EnabledFastSwitch SqVC_EnabledFastSwitch;
- extern SDK_ToggleFriendlyFire SqVC_ToggleFriendlyFire;
- extern SDK_EnabledFriendlyFire SqVC_EnabledFriendlyFire;
- extern SDK_ToggleDisableDriveby SqVC_ToggleDisableDriveby;
- extern SDK_EnabledDisableDriveby SqVC_EnabledDisableDriveby;
- extern SDK_TogglePerfectHandling SqVC_TogglePerfectHandling;
- extern SDK_EnabledPerfectHandling SqVC_EnabledPerfectHandling;
- extern SDK_ToggleFlyingCars SqVC_ToggleFlyingCars;
- extern SDK_EnabledFlyingCars SqVC_EnabledFlyingCars;
- extern SDK_ToggleJumpSwitch SqVC_ToggleJumpSwitch;
- extern SDK_EnabledJumpSwitch SqVC_EnabledJumpSwitch;
- extern SDK_ToggleShowMarkers SqVC_ToggleShowMarkers;
- extern SDK_EnabledShowMarkers SqVC_EnabledShowMarkers;
- extern SDK_ToggleOnlyShowTeamMarkers SqVC_ToggleOnlyShowTeamMarkers;
- extern SDK_EnabledOnlyShowTeamMarkers SqVC_EnabledOnlyShowTeamMarkers;
- extern SDK_ToggleStuntBike SqVC_ToggleStuntBike;
- extern SDK_EnabledStuntBike SqVC_EnabledStuntBike;
- extern SDK_ToggleShootInAir SqVC_ToggleShootInAir;
- extern SDK_EnabledShootInAir SqVC_EnabledShootInAir;
- extern SDK_ToggleShowNametags SqVC_ToggleShowNametags;
- extern SDK_EnabledShowNametags SqVC_EnabledShowNametags;
- extern SDK_ToggleJoinMessages SqVC_ToggleJoinMessages;
- extern SDK_EnabledJoinMessages SqVC_EnabledJoinMessages;
- extern SDK_ToggleDeathMessages SqVC_ToggleDeathMessages;
- extern SDK_EnabledDeathMessages SqVC_EnabledDeathMessages;
- extern SDK_ToggleChatTagsByDefaultEnabled SqVC_ToggleChatTagsByDefaultEnabled;
- extern SDK_EnabledChatTagsByDefault SqVC_EnabledChatTagsByDefault;
-
- /* ------------------------------------------------------------------------------------------------
- * MISC
- */
- extern SDK_CreateExplosion SqVC_CreateExplosion;
- extern SDK_PlaySound SqVC_PlaySound;
- extern SDK_HideMapObject SqVC_HideMapObject;
- extern SDK_ShowMapObject SqVC_ShowMapObject;
- extern SDK_ShowAllMapObjects SqVC_ShowAllMapObjects;
-
- /* ------------------------------------------------------------------------------------------------
- * WEAPONDATA
- */
- extern SDK_SetWeaponDataValue SqVC_SetWeaponDataValue;
- extern SDK_GetWeaponDataValue SqVC_GetWeaponDataValue;
- extern SDK_ResetWeaponDataValue SqVC_ResetWeaponDataValue;
- extern SDK_IsWeaponDataValueModified SqVC_IsWeaponDataValueModified;
- extern SDK_ResetWeaponData SqVC_ResetWeaponData;
- extern SDK_ResetAllWeaponData SqVC_ResetAllWeaponData;
-
- /* ------------------------------------------------------------------------------------------------
- * KEYBINDS
- */
- extern SDK_GetKeyBindUnusedSlot SqVC_GetKeyBindUnusedSlot;
- extern SDK_GetKeyBindData SqVC_GetKeyBindData;
- extern SDK_RegisterKeyBind SqVC_RegisterKeyBind;
- extern SDK_RemoveKeyBind SqVC_RemoveKeyBind;
- extern SDK_RemoveAllKeyBinds SqVC_RemoveAllKeyBinds;
-
- /* ------------------------------------------------------------------------------------------------
- * BLIPS
- */
- extern SDK_CreateCoordBlip SqVC_CreateCoordBlip;
- extern SDK_DestroyCoordBlip SqVC_DestroyCoordBlip;
- extern SDK_GetCoordBlipInfo SqVC_GetCoordBlipInfo;
-
- /* ------------------------------------------------------------------------------------------------
- * SPRITES
- */
- extern SDK_CreateSprite SqVC_CreateSprite;
- extern SDK_DestroySprite SqVC_DestroySprite;
- extern SDK_ShowSprite SqVC_ShowSprite;
- extern SDK_HideSprite SqVC_HideSprite;
- extern SDK_MoveSprite SqVC_MoveSprite;
- extern SDK_SetSpriteCenter SqVC_SetSpriteCenter;
- extern SDK_RotateSprite SqVC_RotateSprite;
- extern SDK_SetSpriteAlpha SqVC_SetSpriteAlpha;
- extern SDK_SetSpriteRelativity SqVC_SetSpriteRelativity;
-
- /* ------------------------------------------------------------------------------------------------
- * TEXTDRAWS
- */
- extern SDK_CreateTextdraw SqVC_CreateTextdraw;
- extern SDK_DestroyTextdraw SqVC_DestroyTextdraw;
- extern SDK_ShowTextdraw SqVC_ShowTextdraw;
- extern SDK_HideTextdraw SqVC_HideTextdraw;
- extern SDK_MoveTextdraw SqVC_MoveTextdraw;
- extern SDK_SetTextdrawColour SqVC_SetTextdrawColour;
- extern SDK_SetTextdrawRelativity SqVC_SetTextdrawRelativity;
-
- /* ------------------------------------------------------------------------------------------------
- * RADIOS
- */
- extern SDK_AddRadioStream SqVC_AddRadioStream;
- extern SDK_RemoveRadioStream SqVC_RemoveRadioStream;
-
- /* ------------------------------------------------------------------------------------------------
- * CLASSES
- */
- extern SDK_SetUseClasses SqVC_SetUseClasses;
- extern SDK_GetUseClasses SqVC_GetUseClasses;
- extern SDK_GetPlayerClass SqVC_GetPlayerClass;
- extern SDK_AddPlayerClass SqVC_AddPlayerClass;
- extern SDK_SetSpawnPlayerPos SqVC_SetSpawnPlayerPos;
- extern SDK_SetSpawnCameraPos SqVC_SetSpawnCameraPos;
- extern SDK_SetSpawnCameraLookAt SqVC_SetSpawnCameraLookAt;
-
- /* ------------------------------------------------------------------------------------------------
- * ADMIN
- */
- extern SDK_IsPlayerAdmin SqVC_IsPlayerAdmin;
- extern SDK_SetPlayerAdmin SqVC_SetPlayerAdmin;
- extern SDK_GetPlayerIP SqVC_GetPlayerIP;
- extern SDK_KickPlayer SqVC_KickPlayer;
- extern SDK_BanPlayer SqVC_BanPlayer;
- extern SDK_BanIP SqVC_BanIP;
- extern SDK_UnbanIP SqVC_UnbanIP;
- extern SDK_IsIPBanned SqVC_IsIPBanned;
-
- /* ------------------------------------------------------------------------------------------------
- * PLAYERS: basic
- */
- extern SDK_GetPlayerIDFromName SqVC_GetPlayerIDFromName;
- extern SDK_IsPlayerConnected SqVC_IsPlayerConnected;
- extern SDK_IsPlayerSpawned SqVC_IsPlayerSpawned;
- extern SDK_IsPlayerStreamedForPlayer SqVC_IsPlayerStreamedForPlayer;
- extern SDK_GetPlayerKey SqVC_GetPlayerKey;
- extern SDK_SetPlayerWorld SqVC_SetPlayerWorld;
- extern SDK_GetPlayerWorld SqVC_GetPlayerWorld;
- extern SDK_SetPlayerSecWorld SqVC_SetPlayerSecWorld;
- extern SDK_GetPlayerSecWorld SqVC_GetPlayerSecWorld;
- extern SDK_GetPlayerUniqueWorld SqVC_GetPlayerUniqueWorld;
- extern SDK_IsPlayerWorldCompatible SqVC_IsPlayerWorldCompatible;
- extern SDK_GetPlayerState SqVC_GetPlayerState;
- extern SDK_GetPlayerName SqVC_GetPlayerName;
- extern SDK_SetPlayerName SqVC_SetPlayerName;
- extern SDK_SetPlayerTeam SqVC_SetPlayerTeam;
- extern SDK_GetPlayerTeam SqVC_GetPlayerTeam;
- extern SDK_SetPlayerSkin SqVC_SetPlayerSkin;
- extern SDK_GetPlayerSkin SqVC_GetPlayerSkin;
- extern SDK_SetPlayerColour SqVC_SetPlayerColour;
- extern SDK_GetPlayerColour SqVC_GetPlayerColour;
- extern SDK_ForcePlayerSpawn SqVC_ForcePlayerSpawn;
- extern SDK_ForcePlayerSelect SqVC_ForcePlayerSelect;
- extern SDK_ForceAllSelect SqVC_ForceAllSelect;
-
- /* ------------------------------------------------------------------------------------------------
- * PLAYERS: score, ping, money, typing
- */
- extern SDK_GivePlayerMoney SqVC_GivePlayerMoney;
- extern SDK_SetPlayerMoney SqVC_SetPlayerMoney;
- extern SDK_GetPlayerMoney SqVC_GetPlayerMoney;
- extern SDK_SetPlayerScore SqVC_SetPlayerScore;
- extern SDK_GetPlayerScore SqVC_GetPlayerScore;
- extern SDK_GetPlayerPing SqVC_GetPlayerPing;
- extern SDK_IsPlayerTyping SqVC_IsPlayerTyping;
- extern SDK_GetPlayerFPS SqVC_GetPlayerFPS;
- extern SDK_GetPlayerUID SqVC_GetPlayerUID;
- extern SDK_GetPlayerWantedLevel SqVC_GetPlayerWantedLevel;
-
- /* ------------------------------------------------------------------------------------------------
- * PLAYERS: health and location
- */
- extern SDK_SetPlayerHealth SqVC_SetPlayerHealth;
- extern SDK_GetPlayerHealth SqVC_GetPlayerHealth;
- extern SDK_SetPlayerArmour SqVC_SetPlayerArmour;
- extern SDK_GetPlayerArmour SqVC_GetPlayerArmour;
- extern SDK_SetPlayerImmunityFlags SqVC_SetPlayerImmunityFlags;
- extern SDK_GetPlayerImmunityFlags SqVC_GetPlayerImmunityFlags;
- extern SDK_SetPlayerPos SqVC_SetPlayerPos;
- extern SDK_GetPlayerPos SqVC_GetPlayerPos;
- extern SDK_SetPlayerSpeed SqVC_SetPlayerSpeed;
- extern SDK_GetPlayerSpeed SqVC_GetPlayerSpeed;
- extern SDK_AddPlayerSpeed SqVC_AddPlayerSpeed;
- extern SDK_SetPlayerHeading SqVC_SetPlayerHeading;
- extern SDK_GetPlayerHeading SqVC_GetPlayerHeading;
- extern SDK_SetPlayerAlpha SqVC_SetPlayerAlpha;
- extern SDK_GetPlayerAlpha SqVC_GetPlayerAlpha;
- extern SDK_GetPlayerOnFireStatus SqVC_GetPlayerOnFireStatus;
- extern SDK_GetPlayerCrouchStatus SqVC_GetPlayerCrouchStatus;
- extern SDK_GetPlayerAction SqVC_GetPlayerAction;
- extern SDK_GetPlayerGameKeys SqVC_GetPlayerGameKeys;
- extern SDK_GetPlayerAimPos SqVC_GetPlayerAimPos;
- extern SDK_GetPlayerAimDir SqVC_GetPlayerAimDir;
-
- /* ------------------------------------------------------------------------------------------------
- * PLAYERS: vehicle
- */
- extern SDK_PutPlayerInVehicle SqVC_PutPlayerInVehicle;
- extern SDK_RemovePlayerFromVehicle SqVC_RemovePlayerFromVehicle;
- extern SDK_GetPlayerInVehicleStatus SqVC_GetPlayerInVehicleStatus;
- extern SDK_GetPlayerInVehicleSlot SqVC_GetPlayerInVehicleSlot;
- extern SDK_GetPlayerVehicleID SqVC_GetPlayerVehicleID;
-
- /* ------------------------------------------------------------------------------------------------
- * PLAYERS: toggles
- */
- extern SDK_TogglePlayerControllable SqVC_TogglePlayerControllable;
- extern SDK_EnabledPlayerControllable SqVC_EnabledPlayerControllable;
- extern SDK_TogglePlayerDriveby SqVC_TogglePlayerDriveby;
- extern SDK_EnabledPlayerDriveby SqVC_EnabledPlayerDriveby;
- extern SDK_TogglePlayerWhiteScanlines SqVC_TogglePlayerWhiteScanlines;
- extern SDK_EnabledPlayerWhiteScanlines SqVC_EnabledPlayerWhiteScanlines;
- extern SDK_TogglePlayerGreenScanlines SqVC_TogglePlayerGreenScanlines;
- extern SDK_EnabledPlayerGreenScanlines SqVC_EnabledPlayerGreenScanlines;
- extern SDK_TogglePlayerWidescreen SqVC_TogglePlayerWidescreen;
- extern SDK_EnabledPlayerWidescreen SqVC_EnabledPlayerWidescreen;
- extern SDK_TogglePlayerShowMarkers SqVC_TogglePlayerShowMarkers;
- extern SDK_EnabledPlayerShowMarkers SqVC_EnabledPlayerShowMarkers;
- extern SDK_TogglePlayerAttackPriv SqVC_TogglePlayerAttackPriv;
- extern SDK_EnabledPlayerAttackPriv SqVC_EnabledPlayerAttackPriv;
- extern SDK_TogglePlayerHasMarker SqVC_TogglePlayerHasMarker;
- extern SDK_EnabledPlayerHasMarker SqVC_EnabledPlayerHasMarker;
- extern SDK_TogglePlayerChatTagsEnabled SqVC_TogglePlayerChatTagsEnabled;
- extern SDK_EnabledPlayerChatTags SqVC_EnabledPlayerChatTags;
- extern SDK_TogglePlayerDrunkEffects SqVC_TogglePlayerDrunkEffects;
- extern SDK_EnabledPlayerDrunkEffects SqVC_EnabledPlayerDrunkEffects;
-
- /* ------------------------------------------------------------------------------------------------
- * PLAYERS: weapons
- */
- extern SDK_GivePlayerWeapon SqVC_GivePlayerWeapon;
- extern SDK_SetPlayerWeapon SqVC_SetPlayerWeapon;
- extern SDK_GetPlayerWeapon SqVC_GetPlayerWeapon;
- extern SDK_GetPlayerWeaponAmmo SqVC_GetPlayerWeaponAmmo;
- extern SDK_SetPlayerWeaponSlot SqVC_SetPlayerWeaponSlot;
- extern SDK_GetPlayerWeaponSlot SqVC_GetPlayerWeaponSlot;
- extern SDK_GetPlayerWeaponAtSlot SqVC_GetPlayerWeaponAtSlot;
- extern SDK_GetPlayerAmmoAtSlot SqVC_GetPlayerAmmoAtSlot;
- extern SDK_RemovePlayerWeapon SqVC_RemovePlayerWeapon;
- extern SDK_RemoveAllWeapons SqVC_RemoveAllWeapons;
-
- /* ------------------------------------------------------------------------------------------------
- * PLAYERS: camera
- */
- extern SDK_SetCameraPosition SqVC_SetCameraPosition;
- extern SDK_RestoreCamera SqVC_RestoreCamera;
- extern SDK_IsCameraLocked SqVC_IsCameraLocked;
-
- /* ------------------------------------------------------------------------------------------------
- * PLAYERS: misc
- */
- extern SDK_SetPlayerAnimation SqVC_SetPlayerAnimation;
- extern SDK_SetPlayerWantedLevel SqVC_SetPlayerWantedLevel;
- extern SDK_GetPlayerStandingOnVehicle SqVC_GetPlayerStandingOnVehicle;
- extern SDK_GetPlayerStandingOnObject SqVC_GetPlayerStandingOnObject;
- extern SDK_IsPlayerAway SqVC_IsPlayerAway;
- extern SDK_GetPlayerSpectateTarget SqVC_GetPlayerSpectateTarget;
- extern SDK_SetPlayerSpectateTarget SqVC_SetPlayerSpectateTarget;
- extern SDK_RedirectPlayerToServer SqVC_RedirectPlayerToServer;
-
- /* ------------------------------------------------------------------------------------------------
- * VEHICLES
- */
- extern SDK_CreateVehicle SqVC_CreateVehicle;
- extern SDK_DeleteVehicle SqVC_DeleteVehicle;
- extern SDK_GetVehicleSyncSource SqVC_GetVehicleSyncSource;
- extern SDK_GetVehicleSyncType SqVC_GetVehicleSyncType;
- extern SDK_IsVehicleStreamedForPlayer SqVC_IsVehicleStreamedForPlayer;
- extern SDK_SetVehicleWorld SqVC_SetVehicleWorld;
- extern SDK_GetVehicleWorld SqVC_GetVehicleWorld;
- extern SDK_GetVehicleModel SqVC_GetVehicleModel;
- extern SDK_GetVehicleOccupant SqVC_GetVehicleOccupant;
- extern SDK_RespawnVehicle SqVC_RespawnVehicle;
- extern SDK_SetVehicleImmunityFlags SqVC_SetVehicleImmunityFlags;
- extern SDK_GetVehicleImmunityFlags SqVC_GetVehicleImmunityFlags;
- extern SDK_KillVehicle SqVC_KillVehicle;
- extern SDK_IsVehicleWrecked SqVC_IsVehicleWrecked;
- extern SDK_SetVehiclePos SqVC_SetVehiclePos;
- extern SDK_GetVehiclePos SqVC_GetVehiclePos;
- extern SDK_SetVehicleRot SqVC_SetVehicleRot;
- extern SDK_SetVehicleRotEuler SqVC_SetVehicleRotEuler;
- extern SDK_GetVehicleRot SqVC_GetVehicleRot;
- extern SDK_GetVehicleRotEuler SqVC_GetVehicleRotEuler;
- extern SDK_SetVehicleSpeed SqVC_SetVehicleSpeed;
- extern SDK_GetVehicleSpeed SqVC_GetVehicleSpeed;
- extern SDK_AddVehicleSpeed SqVC_AddVehicleSpeed;
- extern SDK_SetVehicleRelSpeed SqVC_SetVehicleRelSpeed;
- extern SDK_GetVehicleRelSpeed SqVC_GetVehicleRelSpeed;
- extern SDK_AddVehicleRelSpeed SqVC_AddVehicleRelSpeed;
- extern SDK_SetVehicleTurnSpeed SqVC_SetVehicleTurnSpeed;
- extern SDK_GetVehicleTurnSpeed SqVC_GetVehicleTurnSpeed;
- extern SDK_AddVehicleTurnSpeed SqVC_AddVehicleTurnSpeed;
- extern SDK_SetVehicleRelTurnSpeed SqVC_SetVehicleRelTurnSpeed;
- extern SDK_GetVehicleRelTurnSpeed SqVC_GetVehicleRelTurnSpeed;
- extern SDK_AddVehicleRelTurnSpeed SqVC_AddVehicleRelTurnSpeed;
- extern SDK_SetVehicleSpawnPos SqVC_SetVehicleSpawnPos;
- extern SDK_GetVehicleSpawnPos SqVC_GetVehicleSpawnPos;
- extern SDK_SetVehicleSpawnRot SqVC_SetVehicleSpawnRot;
- extern SDK_SetVehicleSpawnRotEuler SqVC_SetVehicleSpawnRotEuler;
- extern SDK_GetVehicleSpawnRot SqVC_GetVehicleSpawnRot;
- extern SDK_GetVehicleSpawnRotEuler SqVC_GetVehicleSpawnRotEuler;
- extern SDK_SetVehicleIdleRespawnTimer SqVC_SetVehicleIdleRespawnTimer;
- extern SDK_GetVehicleIdleRespawnTimer SqVC_GetVehicleIdleRespawnTimer;
- extern SDK_SetVehicleHealth SqVC_SetVehicleHealth;
- extern SDK_GetVehicleHealth SqVC_GetVehicleHealth;
- extern SDK_SetVehicleColour SqVC_SetVehicleColour;
- extern SDK_GetVehicleColour SqVC_GetVehicleColour;
- extern SDK_SetVehicleDoorsLocked SqVC_SetVehicleDoorsLocked;
- extern SDK_GetVehicleDoorsLocked SqVC_GetVehicleDoorsLocked;
- extern SDK_SetVehiclePartStatus SqVC_SetVehiclePartStatus;
- extern SDK_GetVehiclePartStatus SqVC_GetVehiclePartStatus;
- extern SDK_SetVehicleTyreStatus SqVC_SetVehicleTyreStatus;
- extern SDK_GetVehicleTyreStatus SqVC_GetVehicleTyreStatus;
- extern SDK_SetVehicleDamageData SqVC_SetVehicleDamageData;
- extern SDK_GetVehicleDamageData SqVC_GetVehicleDamageData;
- extern SDK_SetVehicleAlarm SqVC_SetVehicleAlarm;
- extern SDK_GetVehicleAlarm SqVC_GetVehicleAlarm;
- extern SDK_SetVehicleLights SqVC_SetVehicleLights;
- extern SDK_GetVehicleLights SqVC_GetVehicleLights;
- extern SDK_SetVehicleRadio SqVC_SetVehicleRadio;
- extern SDK_GetVehicleRadio SqVC_GetVehicleRadio;
- extern SDK_SetVehicleRadioLocked SqVC_SetVehicleRadioLocked;
- extern SDK_IsVehicleRadioLocked SqVC_IsVehicleRadioLocked;
- extern SDK_GetVehicleGhostState SqVC_GetVehicleGhostState;
- extern SDK_SetVehicleGhostState SqVC_SetVehicleGhostState;
- extern SDK_GetVehicleTurretRotation SqVC_GetVehicleTurretRotation;
-
- /* ------------------------------------------------------------------------------------------------
- * VEHICLES: handling
- */
- extern SDK_ResetAllVehicleHandlings SqVC_ResetAllVehicleHandlings;
- extern SDK_ExistsHandlingRule SqVC_ExistsHandlingRule;
- extern SDK_SetHandlingRule SqVC_SetHandlingRule;
- extern SDK_GetHandlingRule SqVC_GetHandlingRule;
- extern SDK_ResetHandlingRule SqVC_ResetHandlingRule;
- extern SDK_ResetHandling SqVC_ResetHandling;
- extern SDK_ExistsInstHandlingRule SqVC_ExistsInstHandlingRule;
- extern SDK_SetInstHandlingRule SqVC_SetInstHandlingRule;
- extern SDK_GetInstHandlingRule SqVC_GetInstHandlingRule;
- extern SDK_ResetInstHandlingRule SqVC_ResetInstHandlingRule;
- extern SDK_ResetInstHandling SqVC_ResetInstHandling;
-
- /* ------------------------------------------------------------------------------------------------
- * PICKUPS
- */
- extern SDK_CreatePickup SqVC_CreatePickup;
- extern SDK_DeletePickup SqVC_DeletePickup;
- extern SDK_IsPickupStreamedForPlayer SqVC_IsPickupStreamedForPlayer;
- extern SDK_SetPickupWorld SqVC_SetPickupWorld;
- extern SDK_GetPickupWorld SqVC_GetPickupWorld;
- extern SDK_PickupGetAlpha SqVC_PickupGetAlpha;
- extern SDK_PickupSetAlpha SqVC_PickupSetAlpha;
- extern SDK_PickupIsAutomatic SqVC_PickupIsAutomatic;
- extern SDK_PickupSetAutomatic SqVC_PickupSetAutomatic;
- extern SDK_SetPickupAutoTimer SqVC_SetPickupAutoTimer;
- extern SDK_GetPickupAutoTimer SqVC_GetPickupAutoTimer;
- extern SDK_PickupRefresh SqVC_PickupRefresh;
- extern SDK_PickupGetPos SqVC_PickupGetPos;
- extern SDK_PickupSetPos SqVC_PickupSetPos;
- extern SDK_PickupGetModel SqVC_PickupGetModel;
- extern SDK_PickupGetQuantity SqVC_PickupGetQuantity;
-
- /* ------------------------------------------------------------------------------------------------
- * OBJECTS
- */
- extern SDK_CreateObject SqVC_CreateObject;
- extern SDK_DeleteObject SqVC_DeleteObject;
- extern SDK_IsObjectStreamedForPlayer SqVC_IsObjectStreamedForPlayer;
- extern SDK_GetObjectModel SqVC_GetObjectModel;
- extern SDK_SetObjectWorld SqVC_SetObjectWorld;
- extern SDK_GetObjectWorld SqVC_GetObjectWorld;
- extern SDK_SetObjectAlpha SqVC_SetObjectAlpha;
- extern SDK_GetObjectAlpha SqVC_GetObjectAlpha;
- extern SDK_MoveObjectTo SqVC_MoveObjectTo;
- extern SDK_MoveObjectBy SqVC_MoveObjectBy;
- extern SDK_SetObjectPos SqVC_SetObjectPos;
- extern SDK_GetObjectPos SqVC_GetObjectPos;
- extern SDK_RotObjectTo SqVC_RotObjectTo;
- extern SDK_RotObjectToEuler SqVC_RotObjectToEuler;
- extern SDK_RotObjectBy SqVC_RotObjectBy;
- extern SDK_RotObjectByEuler SqVC_RotObjectByEuler;
- extern SDK_GetObjectRot SqVC_GetObjectRot;
- extern SDK_GetObjectRotEuler SqVC_GetObjectRotEuler;
- extern SDK_SetObjectShotReport SqVC_SetObjectShotReport;
- extern SDK_IsObjectShotReport SqVC_IsObjectShotReport;
- extern SDK_SetObjectBumpReport SqVC_SetObjectBumpReport;
- extern SDK_IsObjectBumpReport SqVC_IsObjectBumpReport;
-
- /* ------------------------------------------------------------------------------------------------
- *
- */
- extern SDK_ToggleWallglitch SqVC_ToggleWallglitch;
- extern SDK_EnabledWallglitch SqVC_EnabledWallglitch;
- extern SDK_SetVehicleSiren SqVC_SetVehicleSiren;
- extern SDK_GetVehicleSiren SqVC_GetVehicleSiren;
- extern SDK_GetPlayerUID2 SqVC_GetPlayerUID2;
-
- /* ------------------------------------------------------------------------------------------------
- *
- */
- extern SDK_CreateCheckpoint SqVC_CreateCheckpoint;
- extern SDK_DeleteCheckpoint SqVC_DeleteCheckpoint;
- extern SDK_IsCheckpointStreamedForPlayer SqVC_IsCheckpointStreamedForPlayer;
- extern SDK_SetCheckpointWorld SqVC_SetCheckpointWorld;
- extern SDK_GetCheckpointWorld SqVC_GetCheckpointWorld;
- extern SDK_SetCheckpointColor SqVC_SetCheckpointColor;
- extern SDK_GetCheckpointColor SqVC_GetCheckpointColor;
- extern SDK_SetCheckpointPos SqVC_SetCheckpointPos;
- extern SDK_GetCheckpointPos SqVC_GetCheckpointPos;
- extern SDK_SetCheckpointRadius SqVC_SetCheckpointRadius;
- extern SDK_GetCheckpointRadius SqVC_GetCheckpointRadius;
- extern SDK_GetCheckpointOwner SqVC_GetCheckpointOwner;
-
- /* ------------------------------------------------------------------------------------------------
- *
- */
- extern SDK_CreateSphere SqVC_CreateSphere;
- extern SDK_DeleteSphere SqVC_DeleteSphere;
- extern SDK_IsSphereStreamedForPlayer SqVC_IsSphereStreamedForPlayer;
- extern SDK_SetSphereWorld SqVC_SetSphereWorld;
- extern SDK_GetSphereWorld SqVC_GetSphereWorld;
- extern SDK_SetSphereColor SqVC_SetSphereColor;
- extern SDK_GetSphereColor SqVC_GetSphereColor;
- extern SDK_SetSpherePos SqVC_SetSpherePos;
- extern SDK_GetSpherePos SqVC_GetSpherePos;
- extern SDK_SetSphereRadius SqVC_SetSphereRadius;
- extern SDK_GetSphereRadius SqVC_GetSphereRadius;
- extern SDK_GetSphereOwner SqVC_GetSphereOwner;
-
- /* --------------------------------------------------------------------------------------------
- * Import the functions from the main squirrel plugin.
- */
- SQUIRREL_API HSQEXPORTS sq_api_import(PluginFuncs * vcapi);
-
- /* --------------------------------------------------------------------------------------------
- * Assign the functions from the specified API structure into the global functions.
- */
- SQUIRREL_API SQRESULT sq_api_expand(HSQAPI sqapi);
-
- /* --------------------------------------------------------------------------------------------
- * Undo changes done by sq_api_expand.
- */
- SQUIRREL_API void sq_api_collapse();
-
- /* --------------------------------------------------------------------------------------------
- * Assign the functions from the specified API structure into the global functions.
- */
- SQUIRREL_API SQRESULT vc_api_expand(PluginFuncs * vcapi);
-
- /* --------------------------------------------------------------------------------------------
- * Undo changes done by vc_api_expand.
- */
- SQUIRREL_API void vc_api_collapse();
-
-#ifdef __cplusplus
-} /*extern "C"*/
-#endif
-
-#endif /*_SQ_API_H_*/
diff --git a/shared/sq_mod.inl b/shared/sq_mod.inl
deleted file mode 100644
index 7283ded0..00000000
--- a/shared/sq_mod.inl
+++ /dev/null
@@ -1,1968 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-#ifdef SQMOD_PLUGIN_API
-
-/*vm*/
-sqapi_open sq_open = NULL;
-sqapi_newthread sq_newthread = NULL;
-sqapi_seterrorhandler sq_seterrorhandler = NULL;
-sqapi_close sq_close = NULL;
-sqapi_setforeignptr sq_setforeignptr = NULL;
-sqapi_getforeignptr sq_getforeignptr = NULL;
-sqapi_setsharedforeignptr sq_setsharedforeignptr = NULL;
-sqapi_getsharedforeignptr sq_getsharedforeignptr = NULL;
-sqapi_setvmreleasehook sq_setvmreleasehook = NULL;
-sqapi_getvmreleasehook sq_getvmreleasehook = NULL;
-sqapi_setsharedreleasehook sq_setsharedreleasehook = NULL;
-sqapi_getsharedreleasehook sq_getsharedreleasehook = NULL;
-sqapi_setprintfunc sq_setprintfunc = NULL;
-sqapi_getprintfunc sq_getprintfunc = NULL;
-sqapi_geterrorfunc sq_geterrorfunc = NULL;
-sqapi_suspendvm sq_suspendvm = NULL;
-sqapi_wakeupvm sq_wakeupvm = NULL;
-sqapi_getvmstate sq_getvmstate = NULL;
-sqapi_getversion sq_getversion = NULL;
-
-/*compiler*/
-sqapi_compile sq_compile = NULL;
-sqapi_compilebuffer sq_compilebuffer = NULL;
-sqapi_enabledebuginfo sq_enabledebuginfo = NULL;
-sqapi_notifyallexceptions sq_notifyallexceptions = NULL;
-sqapi_setcompilererrorhandler sq_setcompilererrorhandler = NULL;
-
-/*stack operations*/
-sqapi_push sq_push = NULL;
-sqapi_pop sq_pop = NULL;
-sqapi_poptop sq_poptop = NULL;
-sqapi_remove sq_remove = NULL;
-sqapi_gettop sq_gettop = NULL;
-sqapi_settop sq_settop = NULL;
-sqapi_reservestack sq_reservestack = NULL;
-sqapi_cmp sq_cmp = NULL;
-sqapi_move sq_move = NULL;
-
-/*object creation handling*/
-sqapi_newuserdata sq_newuserdata = NULL;
-sqapi_newtable sq_newtable = NULL;
-sqapi_newtableex sq_newtableex = NULL;
-sqapi_newarray sq_newarray = NULL;
-sqapi_newclosure sq_newclosure = NULL;
-sqapi_setparamscheck sq_setparamscheck = NULL;
-sqapi_bindenv sq_bindenv = NULL;
-sqapi_setclosureroot sq_setclosureroot = NULL;
-sqapi_getclosureroot sq_getclosureroot = NULL;
-sqapi_pushstring sq_pushstring = NULL;
-sqapi_pushfloat sq_pushfloat = NULL;
-sqapi_pushinteger sq_pushinteger = NULL;
-sqapi_pushbool sq_pushbool = NULL;
-sqapi_pushuserpointer sq_pushuserpointer = NULL;
-sqapi_pushnull sq_pushnull = NULL;
-sqapi_pushthread sq_pushthread = NULL;
-sqapi_gettype sq_gettype = NULL;
-sqapi_typeof sq_typeof = NULL;
-sqapi_getsize sq_getsize = NULL;
-sqapi_gethash sq_gethash = NULL;
-sqapi_getbase sq_getbase = NULL;
-sqapi_instanceof sq_instanceof = NULL;
-sqapi_tostring sq_tostring = NULL;
-sqapi_tobool sq_tobool = NULL;
-sqapi_getstring sq_getstring = NULL;
-sqapi_getinteger sq_getinteger = NULL;
-sqapi_getfloat sq_getfloat = NULL;
-sqapi_getbool sq_getbool = NULL;
-sqapi_getthread sq_getthread = NULL;
-sqapi_getuserpointer sq_getuserpointer = NULL;
-sqapi_getuserdata sq_getuserdata = NULL;
-sqapi_settypetag sq_settypetag = NULL;
-sqapi_gettypetag sq_gettypetag = NULL;
-sqapi_setreleasehook sq_setreleasehook = NULL;
-sqapi_getreleasehook sq_getreleasehook = NULL;
-sqapi_getscratchpad sq_getscratchpad = NULL;
-sqapi_getfunctioninfo sq_getfunctioninfo = NULL;
-sqapi_getclosureinfo sq_getclosureinfo = NULL;
-sqapi_getclosurename sq_getclosurename = NULL;
-sqapi_setnativeclosurename sq_setnativeclosurename = NULL;
-sqapi_setinstanceup sq_setinstanceup = NULL;
-sqapi_getinstanceup sq_getinstanceup = NULL;
-sqapi_setclassudsize sq_setclassudsize = NULL;
-sqapi_newclass sq_newclass = NULL;
-sqapi_createinstance sq_createinstance = NULL;
-sqapi_setattributes sq_setattributes = NULL;
-sqapi_getattributes sq_getattributes = NULL;
-sqapi_getclass sq_getclass = NULL;
-sqapi_weakref sq_weakref = NULL;
-sqapi_getdefaultdelegate sq_getdefaultdelegate = NULL;
-sqapi_getmemberhandle sq_getmemberhandle = NULL;
-sqapi_getbyhandle sq_getbyhandle = NULL;
-sqapi_setbyhandle sq_setbyhandle = NULL;
-
-/*object manipulation*/
-sqapi_pushroottable sq_pushroottable = NULL;
-sqapi_pushregistrytable sq_pushregistrytable = NULL;
-sqapi_pushconsttable sq_pushconsttable = NULL;
-sqapi_setroottable sq_setroottable = NULL;
-sqapi_setconsttable sq_setconsttable = NULL;
-sqapi_newslot sq_newslot = NULL;
-sqapi_deleteslot sq_deleteslot = NULL;
-sqapi_set sq_set = NULL;
-sqapi_get sq_get = NULL;
-sqapi_rawget sq_rawget = NULL;
-sqapi_rawset sq_rawset = NULL;
-sqapi_rawdeleteslot sq_rawdeleteslot = NULL;
-sqapi_newmember sq_newmember = NULL;
-sqapi_rawnewmember sq_rawnewmember = NULL;
-sqapi_arrayappend sq_arrayappend = NULL;
-sqapi_arraypop sq_arraypop = NULL;
-sqapi_arrayresize sq_arrayresize = NULL;
-sqapi_arrayreverse sq_arrayreverse = NULL;
-sqapi_arrayremove sq_arrayremove = NULL;
-sqapi_arrayinsert sq_arrayinsert = NULL;
-sqapi_setdelegate sq_setdelegate = NULL;
-sqapi_getdelegate sq_getdelegate = NULL;
-sqapi_clone sq_clone = NULL;
-sqapi_setfreevariable sq_setfreevariable = NULL;
-sqapi_next sq_next = NULL;
-sqapi_getweakrefval sq_getweakrefval = NULL;
-sqapi_clear sq_clear = NULL;
-
-/*calls*/
-sqapi_call sq_call = NULL;
-sqapi_resume sq_resume = NULL;
-sqapi_getlocal sq_getlocal = NULL;
-sqapi_getcallee sq_getcallee = NULL;
-sqapi_getfreevariable sq_getfreevariable = NULL;
-sqapi_throwerror sq_throwerror = NULL;
-sqapi_throwobject sq_throwobject = NULL;
-sqapi_reseterror sq_reseterror = NULL;
-sqapi_getlasterror sq_getlasterror = NULL;
-
-/*raw object handling*/
-sqapi_getstackobj sq_getstackobj = NULL;
-sqapi_pushobject sq_pushobject = NULL;
-sqapi_addref sq_addref = NULL;
-sqapi_release sq_release = NULL;
-sqapi_getrefcount sq_getrefcount = NULL;
-sqapi_resetobject sq_resetobject = NULL;
-sqapi_objtostring sq_objtostring = NULL;
-sqapi_objtobool sq_objtobool = NULL;
-sqapi_objtointeger sq_objtointeger = NULL;
-sqapi_objtofloat sq_objtofloat = NULL;
-sqapi_objtouserpointer sq_objtouserpointer = NULL;
-sqapi_getobjtypetag sq_getobjtypetag = NULL;
-sqapi_getvmrefcount sq_getvmrefcount = NULL;
-
-/*GC*/
-sqapi_collectgarbage sq_collectgarbage = NULL;
-sqapi_resurrectunreachable sq_resurrectunreachable = NULL;
-
-/*serialization*/
-sqapi_writeclosure sq_writeclosure = NULL;
-sqapi_readclosure sq_readclosure = NULL;
-
-/*mem allocation*/
-sqapi_malloc sq_malloc = NULL;
-sqapi_realloc sq_realloc = NULL;
-sqapi_free sq_free = NULL;
-
-/*debug*/
-sqapi_stackinfos sq_stackinfos = NULL;
-sqapi_setdebughook sq_setdebughook = NULL;
-sqapi_setnativedebughook sq_setnativedebughook = NULL;
-
-/*compiler helpers*/
-sqapi_loadfile sq_loadfile = NULL;
-sqapi_dofile sq_dofile = NULL;
-sqapi_writeclosuretofile sq_writeclosuretofile = NULL;
-
-/*blob*/
-sqapi_createblob sq_createblob = NULL;
-sqapi_getblob sq_getblob = NULL;
-sqapi_getblobsize sq_getblobsize = NULL;
-
-/*string*/
-sqapi_format sq_format = NULL;
-
-#endif // SQMOD_PLUGIN_API
-
-// ------------------------------------------------------------------------------------------------
-HSQEXPORTS sq_api_import(PluginFuncs * vcapi)
-{
- // Make sure a valid plugin api and reference to exports structure pointer was specified
- if (!vcapi)
- {
- return NULL;
- }
- unsigned int struct_size;
- // Attempt to find the main plugin ID
- int plugin_id = vcapi->FindPlugin((char *)(SQMOD_HOST_NAME));
- // Attempt to retrieve the plugin exports
- void ** plugin_exports = vcapi->GetPluginExports(plugin_id, &struct_size);
- // See if we have any imports from Squirrel
- if (plugin_exports == NULL || struct_size <= 0)
- {
- return NULL;
- }
- // Simply return the obtain poiner to the exports structure
- return *(sq_exports **)plugin_exports;
-}
-
-// ------------------------------------------------------------------------------------------------
-SQRESULT sq_api_expand(HSQAPI sqapi)
-{
- if (!sqapi)
- return SQ_ERROR;
-
-#ifdef SQMOD_PLUGIN_API
-
- /*vm*/
- sq_open = sqapi->open;
- sq_newthread = sqapi->newthread;
- sq_seterrorhandler = sqapi->seterrorhandler;
- sq_close = sqapi->close;
- sq_setforeignptr = sqapi->setforeignptr;
- sq_getforeignptr = sqapi->getforeignptr;
- sq_setsharedforeignptr = sqapi->setsharedforeignptr;
- sq_getsharedforeignptr = sqapi->getsharedforeignptr;
- sq_setvmreleasehook = sqapi->setvmreleasehook;
- sq_getvmreleasehook = sqapi->getvmreleasehook;
- sq_setsharedreleasehook = sqapi->setsharedreleasehook;
- sq_getsharedreleasehook = sqapi->getsharedreleasehook;
- sq_setprintfunc = sqapi->setprintfunc;
- sq_getprintfunc = sqapi->getprintfunc;
- sq_geterrorfunc = sqapi->geterrorfunc;
- sq_suspendvm = sqapi->suspendvm;
- sq_wakeupvm = sqapi->wakeupvm;
- sq_getvmstate = sqapi->getvmstate;
- sq_getversion = sqapi->getversion;
-
- /*compiler*/
- sq_compile = sqapi->compile;
- sq_compilebuffer = sqapi->compilebuffer;
- sq_enabledebuginfo = sqapi->enabledebuginfo;
- sq_notifyallexceptions = sqapi->notifyallexceptions;
- sq_setcompilererrorhandler = sqapi->setcompilererrorhandler;
-
- /*stack operations*/
- sq_push = sqapi->push;
- sq_pop = sqapi->pop;
- sq_poptop = sqapi->poptop;
- sq_remove = sqapi->remove;
- sq_gettop = sqapi->gettop;
- sq_settop = sqapi->settop;
- sq_reservestack = sqapi->reservestack;
- sq_cmp = sqapi->cmp;
- sq_move = sqapi->move;
-
- /*object creation handling*/
- sq_newuserdata = sqapi->newuserdata;
- sq_newtable = sqapi->newtable;
- sq_newtableex = sqapi->newtableex;
- sq_newarray = sqapi->newarray;
- sq_newclosure = sqapi->newclosure;
- sq_setparamscheck = sqapi->setparamscheck;
- sq_bindenv = sqapi->bindenv;
- sq_setclosureroot = sqapi->setclosureroot;
- sq_getclosureroot = sqapi->getclosureroot;
- sq_pushstring = sqapi->pushstring;
- sq_pushfloat = sqapi->pushfloat;
- sq_pushinteger = sqapi->pushinteger;
- sq_pushbool = sqapi->pushbool;
- sq_pushuserpointer = sqapi->pushuserpointer;
- sq_pushnull = sqapi->pushnull;
- sq_pushthread = sqapi->pushthread;
- sq_gettype = sqapi->gettype;
- sq_typeof = sqapi->typeof_;
- sq_getsize = sqapi->getsize;
- sq_gethash = sqapi->gethash;
- sq_getbase = sqapi->getbase;
- sq_instanceof = sqapi->instanceof;
- sq_tostring = sqapi->tostring;
- sq_tobool = sqapi->tobool;
- sq_getstring = sqapi->getstring;
- sq_getinteger = sqapi->getinteger;
- sq_getfloat = sqapi->getfloat;
- sq_getbool = sqapi->getbool;
- sq_getthread = sqapi->getthread;
- sq_getuserpointer = sqapi->getuserpointer;
- sq_getuserdata = sqapi->getuserdata;
- sq_settypetag = sqapi->settypetag;
- sq_gettypetag = sqapi->gettypetag;
- sq_setreleasehook = sqapi->setreleasehook;
- sq_getreleasehook = sqapi->getreleasehook;
- sq_getscratchpad = sqapi->getscratchpad;
- sq_getfunctioninfo = sqapi->getfunctioninfo;
- sq_getclosureinfo = sqapi->getclosureinfo;
- sq_getclosurename = sqapi->getclosurename;
- sq_setnativeclosurename = sqapi->setnativeclosurename;
- sq_setinstanceup = sqapi->setinstanceup;
- sq_getinstanceup = sqapi->getinstanceup;
- sq_setclassudsize = sqapi->setclassudsize;
- sq_newclass = sqapi->newclass;
- sq_createinstance = sqapi->createinstance;
- sq_setattributes = sqapi->setattributes;
- sq_getattributes = sqapi->getattributes;
- sq_getclass = sqapi->getclass;
- sq_weakref = sqapi->weakref;
- sq_getdefaultdelegate = sqapi->getdefaultdelegate;
- sq_getmemberhandle = sqapi->getmemberhandle;
- sq_getbyhandle = sqapi->getbyhandle;
- sq_setbyhandle = sqapi->setbyhandle;
-
- /*object manipulation*/
- sq_pushroottable = sqapi->pushroottable;
- sq_pushregistrytable = sqapi->pushregistrytable;
- sq_pushconsttable = sqapi->pushconsttable;
- sq_setroottable = sqapi->setroottable;
- sq_setconsttable = sqapi->setconsttable;
- sq_newslot = sqapi->newslot;
- sq_deleteslot = sqapi->deleteslot;
- sq_set = sqapi->set;
- sq_get = sqapi->get;
- sq_rawget = sqapi->rawget;
- sq_rawset = sqapi->rawset;
- sq_rawdeleteslot = sqapi->rawdeleteslot;
- sq_newmember = sqapi->newmember;
- sq_rawnewmember = sqapi->rawnewmember;
- sq_arrayappend = sqapi->arrayappend;
- sq_arraypop = sqapi->arraypop;
- sq_arrayresize = sqapi->arrayresize;
- sq_arrayreverse = sqapi->arrayreverse;
- sq_arrayremove = sqapi->arrayremove;
- sq_arrayinsert = sqapi->arrayinsert;
- sq_setdelegate = sqapi->setdelegate;
- sq_getdelegate = sqapi->getdelegate;
- sq_clone = sqapi->clone;
- sq_setfreevariable = sqapi->setfreevariable;
- sq_next = sqapi->next;
- sq_getweakrefval = sqapi->getweakrefval;
- sq_clear = sqapi->clear;
-
- /*calls*/
- sq_call = sqapi->call;
- sq_resume = sqapi->resume;
- sq_getlocal = sqapi->getlocal;
- sq_getcallee = sqapi->getcallee;
- sq_getfreevariable = sqapi->getfreevariable;
- sq_throwerror = sqapi->throwerror;
- sq_throwobject = sqapi->throwobject;
- sq_reseterror = sqapi->reseterror;
- sq_getlasterror = sqapi->getlasterror;
-
- /*raw object handling*/
- sq_getstackobj = sqapi->getstackobj;
- sq_pushobject = sqapi->pushobject;
- sq_addref = sqapi->addref;
- sq_release = sqapi->release;
- sq_getrefcount = sqapi->getrefcount;
- sq_resetobject = sqapi->resetobject;
- sq_objtostring = sqapi->objtostring;
- sq_objtobool = sqapi->objtobool;
- sq_objtointeger = sqapi->objtointeger;
- sq_objtofloat = sqapi->objtofloat;
- sq_objtouserpointer = sqapi->objtouserpointer;
- sq_getobjtypetag = sqapi->getobjtypetag;
- sq_getvmrefcount = sqapi->getvmrefcount;
-
- /*GC*/
- sq_collectgarbage = sqapi->collectgarbage;
- sq_resurrectunreachable = sqapi->resurrectunreachable;
-
- /*serialization*/
- sq_writeclosure = sqapi->writeclosure;
- sq_readclosure = sqapi->readclosure;
-
- /*mem allocation*/
- sq_malloc = sqapi->malloc;
- sq_realloc = sqapi->realloc;
- sq_free = sqapi->free;
-
- /*debug*/
- sq_stackinfos = sqapi->stackinfos;
- sq_setdebughook = sqapi->setdebughook;
- sq_setnativedebughook = sqapi->setnativedebughook;
-
- /*compiler helpers*/
- sq_loadfile = sqapi->loadfile;
- sq_dofile = sqapi->dofile;
- sq_writeclosuretofile = sqapi->writeclosuretofile;
-
- /*blob*/
- sq_createblob = sqapi->createblob;
- sq_getblob = sqapi->getblob;
- sq_getblobsize = sqapi->getblobsize;
-
- /*string*/
- sq_format = sqapi->format;
-
-#endif // SQMOD_PLUGIN_API
-
- return SQ_OK;
-}
-
-// ------------------------------------------------------------------------------------------------
-void sq_api_collapse()
-{
-#ifdef SQMOD_PLUGIN_API
-
- /*vm*/
- sq_open = NULL;
- sq_newthread = NULL;
- sq_seterrorhandler = NULL;
- sq_close = NULL;
- sq_setforeignptr = NULL;
- sq_getforeignptr = NULL;
- sq_setsharedforeignptr = NULL;
- sq_getsharedforeignptr = NULL;
- sq_setvmreleasehook = NULL;
- sq_getvmreleasehook = NULL;
- sq_setsharedreleasehook = NULL;
- sq_getsharedreleasehook = NULL;
- sq_setprintfunc = NULL;
- sq_getprintfunc = NULL;
- sq_geterrorfunc = NULL;
- sq_suspendvm = NULL;
- sq_wakeupvm = NULL;
- sq_getvmstate = NULL;
- sq_getversion = NULL;
-
- /*compiler*/
- sq_compile = NULL;
- sq_compilebuffer = NULL;
- sq_enabledebuginfo = NULL;
- sq_notifyallexceptions = NULL;
- sq_setcompilererrorhandler = NULL;
-
- /*stack operations*/
- sq_push = NULL;
- sq_pop = NULL;
- sq_poptop = NULL;
- sq_remove = NULL;
- sq_gettop = NULL;
- sq_settop = NULL;
- sq_reservestack = NULL;
- sq_cmp = NULL;
- sq_move = NULL;
-
- /*object creation handling*/
- sq_newuserdata = NULL;
- sq_newtable = NULL;
- sq_newtableex = NULL;
- sq_newarray = NULL;
- sq_newclosure = NULL;
- sq_setparamscheck = NULL;
- sq_bindenv = NULL;
- sq_setclosureroot = NULL;
- sq_getclosureroot = NULL;
- sq_pushstring = NULL;
- sq_pushfloat = NULL;
- sq_pushinteger = NULL;
- sq_pushbool = NULL;
- sq_pushuserpointer = NULL;
- sq_pushnull = NULL;
- sq_pushthread = NULL;
- sq_gettype = NULL;
- sq_typeof = NULL;
- sq_getsize = NULL;
- sq_gethash = NULL;
- sq_getbase = NULL;
- sq_instanceof = NULL;
- sq_tostring = NULL;
- sq_tobool = NULL;
- sq_getstring = NULL;
- sq_getinteger = NULL;
- sq_getfloat = NULL;
- sq_getbool = NULL;
- sq_getthread = NULL;
- sq_getuserpointer = NULL;
- sq_getuserdata = NULL;
- sq_settypetag = NULL;
- sq_gettypetag = NULL;
- sq_setreleasehook = NULL;
- sq_getreleasehook = NULL;
- sq_getscratchpad = NULL;
- sq_getfunctioninfo = NULL;
- sq_getclosureinfo = NULL;
- sq_getclosurename = NULL;
- sq_setnativeclosurename = NULL;
- sq_setinstanceup = NULL;
- sq_getinstanceup = NULL;
- sq_setclassudsize = NULL;
- sq_newclass = NULL;
- sq_createinstance = NULL;
- sq_setattributes = NULL;
- sq_getattributes = NULL;
- sq_getclass = NULL;
- sq_weakref = NULL;
- sq_getdefaultdelegate = NULL;
- sq_getmemberhandle = NULL;
- sq_getbyhandle = NULL;
- sq_setbyhandle = NULL;
-
- /*object manipulation*/
- sq_pushroottable = NULL;
- sq_pushregistrytable = NULL;
- sq_pushconsttable = NULL;
- sq_setroottable = NULL;
- sq_setconsttable = NULL;
- sq_newslot = NULL;
- sq_deleteslot = NULL;
- sq_set = NULL;
- sq_get = NULL;
- sq_rawget = NULL;
- sq_rawset = NULL;
- sq_rawdeleteslot = NULL;
- sq_newmember = NULL;
- sq_rawnewmember = NULL;
- sq_arrayappend = NULL;
- sq_arraypop = NULL;
- sq_arrayresize = NULL;
- sq_arrayreverse = NULL;
- sq_arrayremove = NULL;
- sq_arrayinsert = NULL;
- sq_setdelegate = NULL;
- sq_getdelegate = NULL;
- sq_clone = NULL;
- sq_setfreevariable = NULL;
- sq_next = NULL;
- sq_getweakrefval = NULL;
- sq_clear = NULL;
-
- /*calls*/
- sq_call = NULL;
- sq_resume = NULL;
- sq_getlocal = NULL;
- sq_getcallee = NULL;
- sq_getfreevariable = NULL;
- sq_throwerror = NULL;
- sq_throwobject = NULL;
- sq_reseterror = NULL;
- sq_getlasterror = NULL;
-
- /*raw object handling*/
- sq_getstackobj = NULL;
- sq_pushobject = NULL;
- sq_addref = NULL;
- sq_release = NULL;
- sq_getrefcount = NULL;
- sq_resetobject = NULL;
- sq_objtostring = NULL;
- sq_objtobool = NULL;
- sq_objtointeger = NULL;
- sq_objtofloat = NULL;
- sq_objtouserpointer = NULL;
- sq_getobjtypetag = NULL;
- sq_getvmrefcount = NULL;
-
- /*GC*/
- sq_collectgarbage = NULL;
- sq_resurrectunreachable = NULL;
-
- /*serialization*/
- sq_writeclosure = NULL;
- sq_readclosure = NULL;
-
- /*mem allocation*/
- sq_malloc = NULL;
- sq_realloc = NULL;
- sq_free = NULL;
-
- /*debug*/
- sq_stackinfos = NULL;
- sq_setdebughook = NULL;
- sq_setnativedebughook = NULL;
-
- /*compiler helpers*/
- sq_loadfile = NULL;
- sq_dofile = NULL;
- sq_writeclosuretofile = NULL;
-
- /*blob*/
- sq_createblob = NULL;
- sq_getblob = NULL;
- sq_getblobsize = NULL;
-
- /*string*/
- sq_format = NULL;
-
-#endif // SQMOD_PLUGIN_API
-}
-
-// --------------------------------------------------------------------------------------------
-//PLUGIN SYSTEM
-SDK_GetServerVersion SqVC_GetServerVersion = NULL;
-SDK_GetServerSettings SqVC_GetServerSettings = NULL;
-SDK_ExportFunctions SqVC_ExportFunctions = NULL;
-SDK_GetNumberOfPlugins SqVC_GetNumberOfPlugins = NULL;
-SDK_GetPluginInfo SqVC_GetPluginInfo = NULL;
-SDK_FindPlugin SqVC_FindPlugin = NULL;
-SDK_GetPluginExports SqVC_GetPluginExports = NULL;
-SDK_GetTime SqVC_GetTime = NULL;
-
-// --------------------------------------------------------------------------------------------
-//MESSAGES
-SDK_printf SqVC_printf = NULL;
-SDK_SendCustomCommand SqVC_SendCustomCommand = NULL;
-SDK_SendClientMessage SqVC_SendClientMessage = NULL;
-SDK_SendGameMessage SqVC_SendGameMessage = NULL;
-
-// --------------------------------------------------------------------------------------------
-//SERVER SETTINGS
-SDK_SetServerName SqVC_SetServerName = NULL;
-SDK_GetServerName SqVC_GetServerName = NULL;
-SDK_SetMaxPlayers SqVC_SetMaxPlayers = NULL;
-SDK_GetMaxPlayers SqVC_GetMaxPlayers = NULL;
-SDK_SetServerPassword SqVC_SetServerPassword = NULL;
-SDK_GetServerPassword SqVC_GetServerPassword = NULL;
-SDK_SetGameModeText SqVC_SetGameModeText = NULL;
-SDK_GetGameModeText SqVC_GetGameModeText = NULL;
-SDK_ShutdownServer SqVC_ShutdownServer = NULL;
-
-// --------------------------------------------------------------------------------------------
-//WORLD: settings
-SDK_SetWorldBounds SqVC_SetWorldBounds = NULL;
-SDK_GetWorldBounds SqVC_GetWorldBounds = NULL;
-SDK_SetWastedSettings SqVC_SetWastedSettings = NULL;
-SDK_GetWastedSettings SqVC_GetWastedSettings = NULL;
-SDK_SetTimeRate SqVC_SetTimeRate = NULL;
-SDK_GetTimeRate SqVC_GetTimeRate = NULL;
-SDK_SetHour SqVC_SetHour = NULL;
-SDK_GetHour SqVC_GetHour = NULL;
-SDK_SetMinute SqVC_SetMinute = NULL;
-SDK_GetMinute SqVC_GetMinute = NULL;
-SDK_SetWeather SqVC_SetWeather = NULL;
-SDK_GetWeather SqVC_GetWeather = NULL;
-SDK_SetGravity SqVC_SetGravity = NULL;
-SDK_GetGravity SqVC_GetGravity = NULL;
-SDK_SetGamespeed SqVC_SetGamespeed = NULL;
-SDK_GetGamespeed SqVC_GetGamespeed = NULL;
-SDK_SetWaterLevel SqVC_SetWaterLevel = NULL;
-SDK_GetWaterLevel SqVC_GetWaterLevel = NULL;
-SDK_SetMaxHeight SqVC_SetMaxHeight = NULL;
-SDK_GetMaxHeight SqVC_GetMaxHeight = NULL;
-SDK_SetKillCmdDelay SqVC_SetKillCmdDelay = NULL;
-SDK_GetKillCmdDelay SqVC_GetKillCmdDelay = NULL;
-SDK_SetVehiclesForcedRespawnHeight SqVC_SetVehiclesForcedRespawnHeight = NULL;
-SDK_GetVehiclesForcedRespawnHeight SqVC_GetVehiclesForcedRespawnHeight = NULL;
-
-// --------------------------------------------------------------------------------------------
-//WORLD: toggles
-SDK_ToggleSyncFrameLimiter SqVC_ToggleSyncFrameLimiter = NULL;
-SDK_EnabledSyncFrameLimiter SqVC_EnabledSyncFrameLimiter = NULL;
-SDK_ToggleFrameLimiter SqVC_ToggleFrameLimiter = NULL;
-SDK_EnabledFrameLimiter SqVC_EnabledFrameLimiter = NULL;
-SDK_ToggleTaxiBoostJump SqVC_ToggleTaxiBoostJump = NULL;
-SDK_EnabledTaxiBoostJump SqVC_EnabledTaxiBoostJump = NULL;
-SDK_ToggleDriveOnWater SqVC_ToggleDriveOnWater = NULL;
-SDK_EnabledDriveOnWater SqVC_EnabledDriveOnWater = NULL;
-SDK_ToggleFastSwitch SqVC_ToggleFastSwitch = NULL;
-SDK_EnabledFastSwitch SqVC_EnabledFastSwitch = NULL;
-SDK_ToggleFriendlyFire SqVC_ToggleFriendlyFire = NULL;
-SDK_EnabledFriendlyFire SqVC_EnabledFriendlyFire = NULL;
-SDK_ToggleDisableDriveby SqVC_ToggleDisableDriveby = NULL;
-SDK_EnabledDisableDriveby SqVC_EnabledDisableDriveby = NULL;
-SDK_TogglePerfectHandling SqVC_TogglePerfectHandling = NULL;
-SDK_EnabledPerfectHandling SqVC_EnabledPerfectHandling = NULL;
-SDK_ToggleFlyingCars SqVC_ToggleFlyingCars = NULL;
-SDK_EnabledFlyingCars SqVC_EnabledFlyingCars = NULL;
-SDK_ToggleJumpSwitch SqVC_ToggleJumpSwitch = NULL;
-SDK_EnabledJumpSwitch SqVC_EnabledJumpSwitch = NULL;
-SDK_ToggleShowMarkers SqVC_ToggleShowMarkers = NULL;
-SDK_EnabledShowMarkers SqVC_EnabledShowMarkers = NULL;
-SDK_ToggleOnlyShowTeamMarkers SqVC_ToggleOnlyShowTeamMarkers = NULL;
-SDK_EnabledOnlyShowTeamMarkers SqVC_EnabledOnlyShowTeamMarkers = NULL;
-SDK_ToggleStuntBike SqVC_ToggleStuntBike = NULL;
-SDK_EnabledStuntBike SqVC_EnabledStuntBike = NULL;
-SDK_ToggleShootInAir SqVC_ToggleShootInAir = NULL;
-SDK_EnabledShootInAir SqVC_EnabledShootInAir = NULL;
-SDK_ToggleShowNametags SqVC_ToggleShowNametags = NULL;
-SDK_EnabledShowNametags SqVC_EnabledShowNametags = NULL;
-SDK_ToggleJoinMessages SqVC_ToggleJoinMessages = NULL;
-SDK_EnabledJoinMessages SqVC_EnabledJoinMessages = NULL;
-SDK_ToggleDeathMessages SqVC_ToggleDeathMessages = NULL;
-SDK_EnabledDeathMessages SqVC_EnabledDeathMessages = NULL;
-SDK_ToggleChatTagsByDefaultEnabled SqVC_ToggleChatTagsByDefaultEnabled = NULL;
-SDK_EnabledChatTagsByDefault SqVC_EnabledChatTagsByDefault = NULL;
-
-// --------------------------------------------------------------------------------------------
-//MISC
-SDK_CreateExplosion SqVC_CreateExplosion = NULL;
-SDK_PlaySound SqVC_PlaySound = NULL;
-SDK_HideMapObject SqVC_HideMapObject = NULL;
-SDK_ShowMapObject SqVC_ShowMapObject = NULL;
-SDK_ShowAllMapObjects SqVC_ShowAllMapObjects = NULL;
-
-//WEAPONDATA
-SDK_SetWeaponDataValue SqVC_SetWeaponDataValue = NULL;
-SDK_GetWeaponDataValue SqVC_GetWeaponDataValue = NULL;
-SDK_ResetWeaponDataValue SqVC_ResetWeaponDataValue = NULL;
-SDK_IsWeaponDataValueModified SqVC_IsWeaponDataValueModified = NULL;
-SDK_ResetWeaponData SqVC_ResetWeaponData = NULL;
-SDK_ResetAllWeaponData SqVC_ResetAllWeaponData = NULL;
-
-// --------------------------------------------------------------------------------------------
-//KEYBINDS
-SDK_GetKeyBindUnusedSlot SqVC_GetKeyBindUnusedSlot = NULL;
-SDK_GetKeyBindData SqVC_GetKeyBindData = NULL;
-SDK_RegisterKeyBind SqVC_RegisterKeyBind = NULL;
-SDK_RemoveKeyBind SqVC_RemoveKeyBind = NULL;
-SDK_RemoveAllKeyBinds SqVC_RemoveAllKeyBinds = NULL;
-
-//BLIPS
-SDK_CreateCoordBlip SqVC_CreateCoordBlip = NULL;
-SDK_DestroyCoordBlip SqVC_DestroyCoordBlip = NULL;
-SDK_GetCoordBlipInfo SqVC_GetCoordBlipInfo = NULL;
-
-// --------------------------------------------------------------------------------------------
-//SPRITES
-SDK_CreateSprite SqVC_CreateSprite = NULL;
-SDK_DestroySprite SqVC_DestroySprite = NULL;
-SDK_ShowSprite SqVC_ShowSprite = NULL;
-SDK_HideSprite SqVC_HideSprite = NULL;
-SDK_MoveSprite SqVC_MoveSprite = NULL;
-SDK_SetSpriteCenter SqVC_SetSpriteCenter = NULL;
-SDK_RotateSprite SqVC_RotateSprite = NULL;
-SDK_SetSpriteAlpha SqVC_SetSpriteAlpha = NULL;
-SDK_SetSpriteRelativity SqVC_SetSpriteRelativity = NULL;
-
-//TEXTDRAWS
-SDK_CreateTextdraw SqVC_CreateTextdraw = NULL;
-SDK_DestroyTextdraw SqVC_DestroyTextdraw = NULL;
-SDK_ShowTextdraw SqVC_ShowTextdraw = NULL;
-SDK_HideTextdraw SqVC_HideTextdraw = NULL;
-SDK_MoveTextdraw SqVC_MoveTextdraw = NULL;
-SDK_SetTextdrawColour SqVC_SetTextdrawColour = NULL;
-SDK_SetTextdrawRelativity SqVC_SetTextdrawRelativity = NULL;
-
-// --------------------------------------------------------------------------------------------
-//RADIOS
-SDK_AddRadioStream SqVC_AddRadioStream = NULL;
-SDK_RemoveRadioStream SqVC_RemoveRadioStream = NULL;
-
-// --------------------------------------------------------------------------------------------
-//CLASSES
-SDK_SetUseClasses SqVC_SetUseClasses = NULL;
-SDK_GetUseClasses SqVC_GetUseClasses = NULL;
-SDK_GetPlayerClass SqVC_GetPlayerClass = NULL;
-SDK_AddPlayerClass SqVC_AddPlayerClass = NULL;
-SDK_SetSpawnPlayerPos SqVC_SetSpawnPlayerPos = NULL;
-SDK_SetSpawnCameraPos SqVC_SetSpawnCameraPos = NULL;
-SDK_SetSpawnCameraLookAt SqVC_SetSpawnCameraLookAt = NULL;
-
-// --------------------------------------------------------------------------------------------
-//ADMIN
-SDK_IsPlayerAdmin SqVC_IsPlayerAdmin = NULL;
-SDK_SetPlayerAdmin SqVC_SetPlayerAdmin = NULL;
-SDK_GetPlayerIP SqVC_GetPlayerIP = NULL;
-SDK_KickPlayer SqVC_KickPlayer = NULL;
-SDK_BanPlayer SqVC_BanPlayer = NULL;
-SDK_BanIP SqVC_BanIP = NULL;
-SDK_UnbanIP SqVC_UnbanIP = NULL;
-SDK_IsIPBanned SqVC_IsIPBanned = NULL;
-
-// --------------------------------------------------------------------------------------------
-//PLAYERS: basic
-SDK_GetPlayerIDFromName SqVC_GetPlayerIDFromName = NULL;
-SDK_IsPlayerConnected SqVC_IsPlayerConnected = NULL;
-SDK_IsPlayerSpawned SqVC_IsPlayerSpawned = NULL;
-SDK_IsPlayerStreamedForPlayer SqVC_IsPlayerStreamedForPlayer = NULL;
-SDK_GetPlayerKey SqVC_GetPlayerKey = NULL;
-SDK_SetPlayerWorld SqVC_SetPlayerWorld = NULL;
-SDK_GetPlayerWorld SqVC_GetPlayerWorld = NULL;
-SDK_SetPlayerSecWorld SqVC_SetPlayerSecWorld = NULL;
-SDK_GetPlayerSecWorld SqVC_GetPlayerSecWorld = NULL;
-SDK_GetPlayerUniqueWorld SqVC_GetPlayerUniqueWorld = NULL;
-SDK_IsPlayerWorldCompatible SqVC_IsPlayerWorldCompatible = NULL;
-SDK_GetPlayerState SqVC_GetPlayerState = NULL;
-SDK_GetPlayerName SqVC_GetPlayerName = NULL;
-SDK_SetPlayerName SqVC_SetPlayerName = NULL;
-SDK_SetPlayerTeam SqVC_SetPlayerTeam = NULL;
-SDK_GetPlayerTeam SqVC_GetPlayerTeam = NULL;
-SDK_SetPlayerSkin SqVC_SetPlayerSkin = NULL;
-SDK_GetPlayerSkin SqVC_GetPlayerSkin = NULL;
-SDK_SetPlayerColour SqVC_SetPlayerColour = NULL;
-SDK_GetPlayerColour SqVC_GetPlayerColour = NULL;
-SDK_ForcePlayerSpawn SqVC_ForcePlayerSpawn = NULL;
-SDK_ForcePlayerSelect SqVC_ForcePlayerSelect = NULL;
-SDK_ForceAllSelect SqVC_ForceAllSelect = NULL;
-
-// --------------------------------------------------------------------------------------------
-//PLAYERS: score, ping, money, typing
-SDK_GivePlayerMoney SqVC_GivePlayerMoney = NULL;
-SDK_SetPlayerMoney SqVC_SetPlayerMoney = NULL;
-SDK_GetPlayerMoney SqVC_GetPlayerMoney = NULL;
-SDK_SetPlayerScore SqVC_SetPlayerScore = NULL;
-SDK_GetPlayerScore SqVC_GetPlayerScore = NULL;
-SDK_GetPlayerPing SqVC_GetPlayerPing = NULL;
-SDK_IsPlayerTyping SqVC_IsPlayerTyping = NULL;
-SDK_GetPlayerFPS SqVC_GetPlayerFPS = NULL;
-SDK_GetPlayerUID SqVC_GetPlayerUID = NULL;
-SDK_GetPlayerWantedLevel SqVC_GetPlayerWantedLevel = NULL;
-
-// --------------------------------------------------------------------------------------------
-//PLAYERS: health and location
-SDK_SetPlayerHealth SqVC_SetPlayerHealth = NULL;
-SDK_GetPlayerHealth SqVC_GetPlayerHealth = NULL;
-SDK_SetPlayerArmour SqVC_SetPlayerArmour = NULL;
-SDK_GetPlayerArmour SqVC_GetPlayerArmour = NULL;
-SDK_SetPlayerImmunityFlags SqVC_SetPlayerImmunityFlags = NULL;
-SDK_GetPlayerImmunityFlags SqVC_GetPlayerImmunityFlags = NULL;
-SDK_SetPlayerPos SqVC_SetPlayerPos = NULL;
-SDK_GetPlayerPos SqVC_GetPlayerPos = NULL;
-SDK_SetPlayerSpeed SqVC_SetPlayerSpeed = NULL;
-SDK_GetPlayerSpeed SqVC_GetPlayerSpeed = NULL;
-SDK_AddPlayerSpeed SqVC_AddPlayerSpeed = NULL;
-SDK_SetPlayerHeading SqVC_SetPlayerHeading = NULL;
-SDK_GetPlayerHeading SqVC_GetPlayerHeading = NULL;
-SDK_SetPlayerAlpha SqVC_SetPlayerAlpha = NULL;
-SDK_GetPlayerAlpha SqVC_GetPlayerAlpha = NULL;
-SDK_GetPlayerOnFireStatus SqVC_GetPlayerOnFireStatus = NULL;
-SDK_GetPlayerCrouchStatus SqVC_GetPlayerCrouchStatus = NULL;
-SDK_GetPlayerAction SqVC_GetPlayerAction = NULL;
-SDK_GetPlayerGameKeys SqVC_GetPlayerGameKeys = NULL;
-SDK_GetPlayerAimPos SqVC_GetPlayerAimPos = NULL;
-SDK_GetPlayerAimDir SqVC_GetPlayerAimDir = NULL;
-
-// --------------------------------------------------------------------------------------------
-//PLAYERS: vehicle
-SDK_PutPlayerInVehicle SqVC_PutPlayerInVehicle = NULL;
-SDK_RemovePlayerFromVehicle SqVC_RemovePlayerFromVehicle = NULL;
-SDK_GetPlayerInVehicleStatus SqVC_GetPlayerInVehicleStatus = NULL;
-SDK_GetPlayerInVehicleSlot SqVC_GetPlayerInVehicleSlot = NULL;
-SDK_GetPlayerVehicleID SqVC_GetPlayerVehicleID = NULL;
-
-// --------------------------------------------------------------------------------------------
-//PLAYERS: toggles
-SDK_TogglePlayerControllable SqVC_TogglePlayerControllable = NULL;
-SDK_EnabledPlayerControllable SqVC_EnabledPlayerControllable = NULL;
-SDK_TogglePlayerDriveby SqVC_TogglePlayerDriveby = NULL;
-SDK_EnabledPlayerDriveby SqVC_EnabledPlayerDriveby = NULL;
-SDK_TogglePlayerWhiteScanlines SqVC_TogglePlayerWhiteScanlines = NULL;
-SDK_EnabledPlayerWhiteScanlines SqVC_EnabledPlayerWhiteScanlines = NULL;
-SDK_TogglePlayerGreenScanlines SqVC_TogglePlayerGreenScanlines = NULL;
-SDK_EnabledPlayerGreenScanlines SqVC_EnabledPlayerGreenScanlines = NULL;
-SDK_TogglePlayerWidescreen SqVC_TogglePlayerWidescreen = NULL;
-SDK_EnabledPlayerWidescreen SqVC_EnabledPlayerWidescreen = NULL;
-SDK_TogglePlayerShowMarkers SqVC_TogglePlayerShowMarkers = NULL;
-SDK_EnabledPlayerShowMarkers SqVC_EnabledPlayerShowMarkers = NULL;
-SDK_TogglePlayerAttackPriv SqVC_TogglePlayerAttackPriv = NULL;
-SDK_EnabledPlayerAttackPriv SqVC_EnabledPlayerAttackPriv = NULL;
-SDK_TogglePlayerHasMarker SqVC_TogglePlayerHasMarker = NULL;
-SDK_EnabledPlayerHasMarker SqVC_EnabledPlayerHasMarker = NULL;
-SDK_TogglePlayerChatTagsEnabled SqVC_TogglePlayerChatTagsEnabled = NULL;
-SDK_EnabledPlayerChatTags SqVC_EnabledPlayerChatTags = NULL;
-SDK_TogglePlayerDrunkEffects SqVC_TogglePlayerDrunkEffects = NULL;
-SDK_EnabledPlayerDrunkEffects SqVC_EnabledPlayerDrunkEffects = NULL;
-
-// --------------------------------------------------------------------------------------------
-//PLAYERS: weapons
-SDK_GivePlayerWeapon SqVC_GivePlayerWeapon = NULL;
-SDK_SetPlayerWeapon SqVC_SetPlayerWeapon = NULL;
-SDK_GetPlayerWeapon SqVC_GetPlayerWeapon = NULL;
-SDK_GetPlayerWeaponAmmo SqVC_GetPlayerWeaponAmmo = NULL;
-SDK_SetPlayerWeaponSlot SqVC_SetPlayerWeaponSlot = NULL;
-SDK_GetPlayerWeaponSlot SqVC_GetPlayerWeaponSlot = NULL;
-SDK_GetPlayerWeaponAtSlot SqVC_GetPlayerWeaponAtSlot = NULL;
-SDK_GetPlayerAmmoAtSlot SqVC_GetPlayerAmmoAtSlot = NULL;
-SDK_RemovePlayerWeapon SqVC_RemovePlayerWeapon = NULL;
-SDK_RemoveAllWeapons SqVC_RemoveAllWeapons = NULL;
-
-// --------------------------------------------------------------------------------------------
-//PLAYERS: camera
-SDK_SetCameraPosition SqVC_SetCameraPosition = NULL;
-SDK_RestoreCamera SqVC_RestoreCamera = NULL;
-SDK_IsCameraLocked SqVC_IsCameraLocked = NULL;
-
-// --------------------------------------------------------------------------------------------
-//PLAYERS: misc
-SDK_SetPlayerAnimation SqVC_SetPlayerAnimation = NULL;
-SDK_SetPlayerWantedLevel SqVC_SetPlayerWantedLevel = NULL;
-SDK_GetPlayerStandingOnVehicle SqVC_GetPlayerStandingOnVehicle = NULL;
-SDK_GetPlayerStandingOnObject SqVC_GetPlayerStandingOnObject = NULL;
-SDK_IsPlayerAway SqVC_IsPlayerAway = NULL;
-SDK_GetPlayerSpectateTarget SqVC_GetPlayerSpectateTarget = NULL;
-SDK_SetPlayerSpectateTarget SqVC_SetPlayerSpectateTarget = NULL;
-SDK_RedirectPlayerToServer SqVC_RedirectPlayerToServer = NULL;
-
-// --------------------------------------------------------------------------------------------
-//VEHICLES
-SDK_CreateVehicle SqVC_CreateVehicle = NULL;
-SDK_DeleteVehicle SqVC_DeleteVehicle = NULL;
-SDK_GetVehicleSyncSource SqVC_GetVehicleSyncSource = NULL;
-SDK_GetVehicleSyncType SqVC_GetVehicleSyncType = NULL;
-SDK_IsVehicleStreamedForPlayer SqVC_IsVehicleStreamedForPlayer = NULL;
-SDK_SetVehicleWorld SqVC_SetVehicleWorld = NULL;
-SDK_GetVehicleWorld SqVC_GetVehicleWorld = NULL;
-SDK_GetVehicleModel SqVC_GetVehicleModel = NULL;
-SDK_GetVehicleOccupant SqVC_GetVehicleOccupant = NULL;
-SDK_RespawnVehicle SqVC_RespawnVehicle = NULL;
-SDK_SetVehicleImmunityFlags SqVC_SetVehicleImmunityFlags = NULL;
-SDK_GetVehicleImmunityFlags SqVC_GetVehicleImmunityFlags = NULL;
-SDK_KillVehicle SqVC_KillVehicle = NULL;
-SDK_IsVehicleWrecked SqVC_IsVehicleWrecked = NULL;
-SDK_SetVehiclePos SqVC_SetVehiclePos = NULL;
-SDK_GetVehiclePos SqVC_GetVehiclePos = NULL;
-SDK_SetVehicleRot SqVC_SetVehicleRot = NULL;
-SDK_SetVehicleRotEuler SqVC_SetVehicleRotEuler = NULL;
-SDK_GetVehicleRot SqVC_GetVehicleRot = NULL;
-SDK_GetVehicleRotEuler SqVC_GetVehicleRotEuler = NULL;
-SDK_SetVehicleSpeed SqVC_SetVehicleSpeed = NULL;
-SDK_GetVehicleSpeed SqVC_GetVehicleSpeed = NULL;
-SDK_AddVehicleSpeed SqVC_AddVehicleSpeed = NULL;
-SDK_SetVehicleRelSpeed SqVC_SetVehicleRelSpeed = NULL;
-SDK_GetVehicleRelSpeed SqVC_GetVehicleRelSpeed = NULL;
-SDK_AddVehicleRelSpeed SqVC_AddVehicleRelSpeed = NULL;
-SDK_SetVehicleTurnSpeed SqVC_SetVehicleTurnSpeed = NULL;
-SDK_GetVehicleTurnSpeed SqVC_GetVehicleTurnSpeed = NULL;
-SDK_AddVehicleTurnSpeed SqVC_AddVehicleTurnSpeed = NULL;
-SDK_SetVehicleRelTurnSpeed SqVC_SetVehicleRelTurnSpeed = NULL;
-SDK_GetVehicleRelTurnSpeed SqVC_GetVehicleRelTurnSpeed = NULL;
-SDK_AddVehicleRelTurnSpeed SqVC_AddVehicleRelTurnSpeed = NULL;
-SDK_SetVehicleSpawnPos SqVC_SetVehicleSpawnPos = NULL;
-SDK_GetVehicleSpawnPos SqVC_GetVehicleSpawnPos = NULL;
-SDK_SetVehicleSpawnRot SqVC_SetVehicleSpawnRot = NULL;
-SDK_SetVehicleSpawnRotEuler SqVC_SetVehicleSpawnRotEuler = NULL;
-SDK_GetVehicleSpawnRot SqVC_GetVehicleSpawnRot = NULL;
-SDK_GetVehicleSpawnRotEuler SqVC_GetVehicleSpawnRotEuler = NULL;
-SDK_SetVehicleIdleRespawnTimer SqVC_SetVehicleIdleRespawnTimer = NULL;
-SDK_GetVehicleIdleRespawnTimer SqVC_GetVehicleIdleRespawnTimer = NULL;
-SDK_SetVehicleHealth SqVC_SetVehicleHealth = NULL;
-SDK_GetVehicleHealth SqVC_GetVehicleHealth = NULL;
-SDK_SetVehicleColour SqVC_SetVehicleColour = NULL;
-SDK_GetVehicleColour SqVC_GetVehicleColour = NULL;
-SDK_SetVehicleDoorsLocked SqVC_SetVehicleDoorsLocked = NULL;
-SDK_GetVehicleDoorsLocked SqVC_GetVehicleDoorsLocked = NULL;
-SDK_SetVehiclePartStatus SqVC_SetVehiclePartStatus = NULL;
-SDK_GetVehiclePartStatus SqVC_GetVehiclePartStatus = NULL;
-SDK_SetVehicleTyreStatus SqVC_SetVehicleTyreStatus = NULL;
-SDK_GetVehicleTyreStatus SqVC_GetVehicleTyreStatus = NULL;
-SDK_SetVehicleDamageData SqVC_SetVehicleDamageData = NULL;
-SDK_GetVehicleDamageData SqVC_GetVehicleDamageData = NULL;
-SDK_SetVehicleAlarm SqVC_SetVehicleAlarm = NULL;
-SDK_GetVehicleAlarm SqVC_GetVehicleAlarm = NULL;
-SDK_SetVehicleLights SqVC_SetVehicleLights = NULL;
-SDK_GetVehicleLights SqVC_GetVehicleLights = NULL;
-SDK_SetVehicleRadio SqVC_SetVehicleRadio = NULL;
-SDK_GetVehicleRadio SqVC_GetVehicleRadio = NULL;
-SDK_SetVehicleRadioLocked SqVC_SetVehicleRadioLocked = NULL;
-SDK_IsVehicleRadioLocked SqVC_IsVehicleRadioLocked = NULL;
-SDK_GetVehicleGhostState SqVC_GetVehicleGhostState = NULL;
-SDK_SetVehicleGhostState SqVC_SetVehicleGhostState = NULL;
-SDK_GetVehicleTurretRotation SqVC_GetVehicleTurretRotation = NULL;
-
-// --------------------------------------------------------------------------------------------
-//VEHICLES: handling
-SDK_ResetAllVehicleHandlings SqVC_ResetAllVehicleHandlings = NULL;
-SDK_ExistsHandlingRule SqVC_ExistsHandlingRule = NULL;
-SDK_SetHandlingRule SqVC_SetHandlingRule = NULL;
-SDK_GetHandlingRule SqVC_GetHandlingRule = NULL;
-SDK_ResetHandlingRule SqVC_ResetHandlingRule = NULL;
-SDK_ResetHandling SqVC_ResetHandling = NULL;
-SDK_ExistsInstHandlingRule SqVC_ExistsInstHandlingRule = NULL;
-SDK_SetInstHandlingRule SqVC_SetInstHandlingRule = NULL;
-SDK_GetInstHandlingRule SqVC_GetInstHandlingRule = NULL;
-SDK_ResetInstHandlingRule SqVC_ResetInstHandlingRule = NULL;
-SDK_ResetInstHandling SqVC_ResetInstHandling = NULL;
-
-// --------------------------------------------------------------------------------------------
-//PICKUPS
-SDK_CreatePickup SqVC_CreatePickup = NULL;
-SDK_DeletePickup SqVC_DeletePickup = NULL;
-SDK_IsPickupStreamedForPlayer SqVC_IsPickupStreamedForPlayer = NULL;
-SDK_SetPickupWorld SqVC_SetPickupWorld = NULL;
-SDK_GetPickupWorld SqVC_GetPickupWorld = NULL;
-SDK_PickupGetAlpha SqVC_PickupGetAlpha = NULL;
-SDK_PickupSetAlpha SqVC_PickupSetAlpha = NULL;
-SDK_PickupIsAutomatic SqVC_PickupIsAutomatic = NULL;
-SDK_PickupSetAutomatic SqVC_PickupSetAutomatic = NULL;
-SDK_SetPickupAutoTimer SqVC_SetPickupAutoTimer = NULL;
-SDK_GetPickupAutoTimer SqVC_GetPickupAutoTimer = NULL;
-SDK_PickupRefresh SqVC_PickupRefresh = NULL;
-SDK_PickupGetPos SqVC_PickupGetPos = NULL;
-SDK_PickupSetPos SqVC_PickupSetPos = NULL;
-SDK_PickupGetModel SqVC_PickupGetModel = NULL;
-SDK_PickupGetQuantity SqVC_PickupGetQuantity = NULL;
-
-// --------------------------------------------------------------------------------------------
-//OBJECTS
-SDK_CreateObject SqVC_CreateObject = NULL;
-SDK_DeleteObject SqVC_DeleteObject = NULL;
-SDK_IsObjectStreamedForPlayer SqVC_IsObjectStreamedForPlayer = NULL;
-SDK_GetObjectModel SqVC_GetObjectModel = NULL;
-SDK_SetObjectWorld SqVC_SetObjectWorld = NULL;
-SDK_GetObjectWorld SqVC_GetObjectWorld = NULL;
-SDK_SetObjectAlpha SqVC_SetObjectAlpha = NULL;
-SDK_GetObjectAlpha SqVC_GetObjectAlpha = NULL;
-SDK_MoveObjectTo SqVC_MoveObjectTo = NULL;
-SDK_MoveObjectBy SqVC_MoveObjectBy = NULL;
-SDK_SetObjectPos SqVC_SetObjectPos = NULL;
-SDK_GetObjectPos SqVC_GetObjectPos = NULL;
-SDK_RotObjectTo SqVC_RotObjectTo = NULL;
-SDK_RotObjectToEuler SqVC_RotObjectToEuler = NULL;
-SDK_RotObjectBy SqVC_RotObjectBy = NULL;
-SDK_RotObjectByEuler SqVC_RotObjectByEuler = NULL;
-SDK_GetObjectRot SqVC_GetObjectRot = NULL;
-SDK_GetObjectRotEuler SqVC_GetObjectRotEuler = NULL;
-SDK_SetObjectShotReport SqVC_SetObjectShotReport = NULL;
-SDK_IsObjectShotReport SqVC_IsObjectShotReport = NULL;
-SDK_SetObjectBumpReport SqVC_SetObjectBumpReport = NULL;
-SDK_IsObjectBumpReport SqVC_IsObjectBumpReport = NULL;
-
-// --------------------------------------------------------------------------------------------
-// TODO: Move these functions to proper sections on major plugin update
-SDK_ToggleWallglitch SqVC_ToggleWallglitch = NULL;
-SDK_EnabledWallglitch SqVC_EnabledWallglitch = NULL;
-SDK_SetVehicleSiren SqVC_SetVehicleSiren = NULL;
-SDK_GetVehicleSiren SqVC_GetVehicleSiren = NULL;
-SDK_GetPlayerUID2 SqVC_GetPlayerUID2 = NULL;
-
-// --------------------------------------------------------------------------------------------
-SDK_CreateCheckpoint SqVC_CreateCheckpoint = NULL;
-SDK_DeleteCheckpoint SqVC_DeleteCheckpoint = NULL;
-SDK_IsCheckpointStreamedForPlayer SqVC_IsCheckpointStreamedForPlayer = NULL;
-SDK_SetCheckpointWorld SqVC_SetCheckpointWorld = NULL;
-SDK_GetCheckpointWorld SqVC_GetCheckpointWorld = NULL;
-SDK_SetCheckpointColor SqVC_SetCheckpointColor = NULL;
-SDK_GetCheckpointColor SqVC_GetCheckpointColor = NULL;
-SDK_SetCheckpointPos SqVC_SetCheckpointPos = NULL;
-SDK_GetCheckpointPos SqVC_GetCheckpointPos = NULL;
-SDK_SetCheckpointRadius SqVC_SetCheckpointRadius = NULL;
-SDK_GetCheckpointRadius SqVC_GetCheckpointRadius = NULL;
-SDK_GetCheckpointOwner SqVC_GetCheckpointOwner = NULL;
-
-// --------------------------------------------------------------------------------------------
-SDK_CreateSphere SqVC_CreateSphere = NULL;
-SDK_DeleteSphere SqVC_DeleteSphere = NULL;
-SDK_IsSphereStreamedForPlayer SqVC_IsSphereStreamedForPlayer = NULL;
-SDK_SetSphereWorld SqVC_SetSphereWorld = NULL;
-SDK_GetSphereWorld SqVC_GetSphereWorld = NULL;
-SDK_SetSphereColor SqVC_SetSphereColor = NULL;
-SDK_GetSphereColor SqVC_GetSphereColor = NULL;
-SDK_SetSpherePos SqVC_SetSpherePos = NULL;
-SDK_GetSpherePos SqVC_GetSpherePos = NULL;
-SDK_SetSphereRadius SqVC_SetSphereRadius = NULL;
-SDK_GetSphereRadius SqVC_GetSphereRadius = NULL;
-SDK_GetSphereOwner SqVC_GetSphereOwner = NULL;
-
-// ------------------------------------------------------------------------------------------------
-SQRESULT vc_api_expand(PluginFuncs * vcapi)
-{
- if (!vcapi)
- return SQ_ERROR;
-
- // --------------------------------------------------------------------------------------------
- //PLUGIN SYSTEM
- SqVC_GetServerVersion = vcapi->GetServerVersion;
- SqVC_GetServerSettings = vcapi->GetServerSettings;
- SqVC_ExportFunctions = vcapi->ExportFunctions;
- SqVC_GetNumberOfPlugins = vcapi->GetNumberOfPlugins;
- SqVC_GetPluginInfo = vcapi->GetPluginInfo;
- SqVC_FindPlugin = vcapi->FindPlugin;
- SqVC_GetPluginExports = vcapi->GetPluginExports;
- SqVC_GetTime = vcapi->GetTime;
-
- // --------------------------------------------------------------------------------------------
- //MESSAGES
- SqVC_printf = vcapi->printf;
- SqVC_SendCustomCommand = vcapi->SendCustomCommand;
- SqVC_SendClientMessage = vcapi->SendClientMessage;
- SqVC_SendGameMessage = vcapi->SendGameMessage;
-
- // --------------------------------------------------------------------------------------------
- //SERVER SETTINGS
- SqVC_SetServerName = vcapi->SetServerName;
- SqVC_GetServerName = vcapi->GetServerName;
- SqVC_SetMaxPlayers = vcapi->SetMaxPlayers;
- SqVC_GetMaxPlayers = vcapi->GetMaxPlayers;
- SqVC_SetServerPassword = vcapi->SetServerPassword;
- SqVC_GetServerPassword = vcapi->GetServerPassword;
- SqVC_SetGameModeText = vcapi->SetGameModeText;
- SqVC_GetGameModeText = vcapi->GetGameModeText;
- SqVC_ShutdownServer = vcapi->ShutdownServer;
-
- // --------------------------------------------------------------------------------------------
- //WORLD: settings
- SqVC_SetWorldBounds = vcapi->SetWorldBounds;
- SqVC_GetWorldBounds = vcapi->GetWorldBounds;
- SqVC_SetWastedSettings = vcapi->SetWastedSettings;
- SqVC_GetWastedSettings = vcapi->GetWastedSettings;
- SqVC_SetTimeRate = vcapi->SetTimeRate;
- SqVC_GetTimeRate = vcapi->GetTimeRate;
- SqVC_SetHour = vcapi->SetHour;
- SqVC_GetHour = vcapi->GetHour;
- SqVC_SetMinute = vcapi->SetMinute;
- SqVC_GetMinute = vcapi->GetMinute;
- SqVC_SetWeather = vcapi->SetWeather;
- SqVC_GetWeather = vcapi->GetWeather;
- SqVC_SetGravity = vcapi->SetGravity;
- SqVC_GetGravity = vcapi->GetGravity;
- SqVC_SetGamespeed = vcapi->SetGamespeed;
- SqVC_GetGamespeed = vcapi->GetGamespeed;
- SqVC_SetWaterLevel = vcapi->SetWaterLevel;
- SqVC_GetWaterLevel = vcapi->GetWaterLevel;
- SqVC_SetMaxHeight = vcapi->SetMaxHeight;
- SqVC_GetMaxHeight = vcapi->GetMaxHeight;
- SqVC_SetKillCmdDelay = vcapi->SetKillCmdDelay;
- SqVC_GetKillCmdDelay = vcapi->GetKillCmdDelay;
- SqVC_SetVehiclesForcedRespawnHeight = vcapi->SetVehiclesForcedRespawnHeight;
- SqVC_GetVehiclesForcedRespawnHeight = vcapi->GetVehiclesForcedRespawnHeight;
-
- // --------------------------------------------------------------------------------------------
- //WORLD: toggles
- SqVC_ToggleSyncFrameLimiter = vcapi->ToggleSyncFrameLimiter;
- SqVC_EnabledSyncFrameLimiter = vcapi->EnabledSyncFrameLimiter;
- SqVC_ToggleFrameLimiter = vcapi->ToggleFrameLimiter;
- SqVC_EnabledFrameLimiter = vcapi->EnabledFrameLimiter;
- SqVC_ToggleTaxiBoostJump = vcapi->ToggleTaxiBoostJump;
- SqVC_EnabledTaxiBoostJump = vcapi->EnabledTaxiBoostJump;
- SqVC_ToggleDriveOnWater = vcapi->ToggleDriveOnWater;
- SqVC_EnabledDriveOnWater = vcapi->EnabledDriveOnWater;
- SqVC_ToggleFastSwitch = vcapi->ToggleFastSwitch;
- SqVC_EnabledFastSwitch = vcapi->EnabledFastSwitch;
- SqVC_ToggleFriendlyFire = vcapi->ToggleFriendlyFire;
- SqVC_EnabledFriendlyFire = vcapi->EnabledFriendlyFire;
- SqVC_ToggleDisableDriveby = vcapi->ToggleDisableDriveby;
- SqVC_EnabledDisableDriveby = vcapi->EnabledDisableDriveby;
- SqVC_TogglePerfectHandling = vcapi->TogglePerfectHandling;
- SqVC_EnabledPerfectHandling = vcapi->EnabledPerfectHandling;
- SqVC_ToggleFlyingCars = vcapi->ToggleFlyingCars;
- SqVC_EnabledFlyingCars = vcapi->EnabledFlyingCars;
- SqVC_ToggleJumpSwitch = vcapi->ToggleJumpSwitch;
- SqVC_EnabledJumpSwitch = vcapi->EnabledJumpSwitch;
- SqVC_ToggleShowMarkers = vcapi->ToggleShowMarkers;
- SqVC_EnabledShowMarkers = vcapi->EnabledShowMarkers;
- SqVC_ToggleOnlyShowTeamMarkers = vcapi->ToggleOnlyShowTeamMarkers;
- SqVC_EnabledOnlyShowTeamMarkers = vcapi->EnabledOnlyShowTeamMarkers;
- SqVC_ToggleStuntBike = vcapi->ToggleStuntBike;
- SqVC_EnabledStuntBike = vcapi->EnabledStuntBike;
- SqVC_ToggleShootInAir = vcapi->ToggleShootInAir;
- SqVC_EnabledShootInAir = vcapi->EnabledShootInAir;
- SqVC_ToggleShowNametags = vcapi->ToggleShowNametags;
- SqVC_EnabledShowNametags = vcapi->EnabledShowNametags;
- SqVC_ToggleJoinMessages = vcapi->ToggleJoinMessages;
- SqVC_EnabledJoinMessages = vcapi->EnabledJoinMessages;
- SqVC_ToggleDeathMessages = vcapi->ToggleDeathMessages;
- SqVC_EnabledDeathMessages = vcapi->EnabledDeathMessages;
- SqVC_ToggleChatTagsByDefaultEnabled = vcapi->ToggleChatTagsByDefaultEnabled;
- SqVC_EnabledChatTagsByDefault = vcapi->EnabledChatTagsByDefault;
-
- // --------------------------------------------------------------------------------------------
- //MISC
- SqVC_CreateExplosion = vcapi->CreateExplosion;
- SqVC_PlaySound = vcapi->PlaySound;
- SqVC_HideMapObject = vcapi->HideMapObject;
- SqVC_ShowMapObject = vcapi->ShowMapObject;
- SqVC_ShowAllMapObjects = vcapi->ShowAllMapObjects;
-
- //WEAPONDATA
- SqVC_SetWeaponDataValue = vcapi->SetWeaponDataValue;
- SqVC_GetWeaponDataValue = vcapi->GetWeaponDataValue;
- SqVC_ResetWeaponDataValue = vcapi->ResetWeaponDataValue;
- SqVC_IsWeaponDataValueModified = vcapi->IsWeaponDataValueModified;
- SqVC_ResetWeaponData = vcapi->ResetWeaponData;
- SqVC_ResetAllWeaponData = vcapi->ResetAllWeaponData;
-
- // --------------------------------------------------------------------------------------------
- //KEYBINDS
- SqVC_GetKeyBindUnusedSlot = vcapi->GetKeyBindUnusedSlot;
- SqVC_GetKeyBindData = vcapi->GetKeyBindData;
- SqVC_RegisterKeyBind = vcapi->RegisterKeyBind;
- SqVC_RemoveKeyBind = vcapi->RemoveKeyBind;
- SqVC_RemoveAllKeyBinds = vcapi->RemoveAllKeyBinds;
-
- //BLIPS
- SqVC_CreateCoordBlip = vcapi->CreateCoordBlip;
- SqVC_DestroyCoordBlip = vcapi->DestroyCoordBlip;
- SqVC_GetCoordBlipInfo = vcapi->GetCoordBlipInfo;
-
- // --------------------------------------------------------------------------------------------
- //SPRITES
- SqVC_CreateSprite = vcapi->CreateSprite;
- SqVC_DestroySprite = vcapi->DestroySprite;
- SqVC_ShowSprite = vcapi->ShowSprite;
- SqVC_HideSprite = vcapi->HideSprite;
- SqVC_MoveSprite = vcapi->MoveSprite;
- SqVC_SetSpriteCenter = vcapi->SetSpriteCenter;
- SqVC_RotateSprite = vcapi->RotateSprite;
- SqVC_SetSpriteAlpha = vcapi->SetSpriteAlpha;
- SqVC_SetSpriteRelativity = vcapi->SetSpriteRelativity;
-
- //TEXTDRAWS
- SqVC_CreateTextdraw = vcapi->CreateTextdraw;
- SqVC_DestroyTextdraw = vcapi->DestroyTextdraw;
- SqVC_ShowTextdraw = vcapi->ShowTextdraw;
- SqVC_HideTextdraw = vcapi->HideTextdraw;
- SqVC_MoveTextdraw = vcapi->MoveTextdraw;
- SqVC_SetTextdrawColour = vcapi->SetTextdrawColour;
- SqVC_SetTextdrawRelativity = vcapi->SetTextdrawRelativity;
-
- // --------------------------------------------------------------------------------------------
- //RADIOS
- SqVC_AddRadioStream = vcapi->AddRadioStream;
- SqVC_RemoveRadioStream = vcapi->RemoveRadioStream;
-
- // --------------------------------------------------------------------------------------------
- //CLASSES
- SqVC_SetUseClasses = vcapi->SetUseClasses;
- SqVC_GetUseClasses = vcapi->GetUseClasses;
- SqVC_GetPlayerClass = vcapi->GetPlayerClass;
- SqVC_AddPlayerClass = vcapi->AddPlayerClass;
- SqVC_SetSpawnPlayerPos = vcapi->SetSpawnPlayerPos;
- SqVC_SetSpawnCameraPos = vcapi->SetSpawnCameraPos;
- SqVC_SetSpawnCameraLookAt = vcapi->SetSpawnCameraLookAt;
-
- // --------------------------------------------------------------------------------------------
- //ADMIN
- SqVC_IsPlayerAdmin = vcapi->IsPlayerAdmin;
- SqVC_SetPlayerAdmin = vcapi->SetPlayerAdmin;
- SqVC_GetPlayerIP = vcapi->GetPlayerIP;
- SqVC_KickPlayer = vcapi->KickPlayer;
- SqVC_BanPlayer = vcapi->BanPlayer;
- SqVC_BanIP = vcapi->BanIP;
- SqVC_UnbanIP = vcapi->UnbanIP;
- SqVC_IsIPBanned = vcapi->IsIPBanned;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: basic
- SqVC_GetPlayerIDFromName = vcapi->GetPlayerIDFromName;
- SqVC_IsPlayerConnected = vcapi->IsPlayerConnected;
- SqVC_IsPlayerSpawned = vcapi->IsPlayerSpawned;
- SqVC_IsPlayerStreamedForPlayer = vcapi->IsPlayerStreamedForPlayer;
- SqVC_GetPlayerKey = vcapi->GetPlayerKey;
- SqVC_SetPlayerWorld = vcapi->SetPlayerWorld;
- SqVC_GetPlayerWorld = vcapi->GetPlayerWorld;
- SqVC_SetPlayerSecWorld = vcapi->SetPlayerSecWorld;
- SqVC_GetPlayerSecWorld = vcapi->GetPlayerSecWorld;
- SqVC_GetPlayerUniqueWorld = vcapi->GetPlayerUniqueWorld;
- SqVC_IsPlayerWorldCompatible = vcapi->IsPlayerWorldCompatible;
- SqVC_GetPlayerState = vcapi->GetPlayerState;
- SqVC_GetPlayerName = vcapi->GetPlayerName;
- SqVC_SetPlayerName = vcapi->SetPlayerName;
- SqVC_SetPlayerTeam = vcapi->SetPlayerTeam;
- SqVC_GetPlayerTeam = vcapi->GetPlayerTeam;
- SqVC_SetPlayerSkin = vcapi->SetPlayerSkin;
- SqVC_GetPlayerSkin = vcapi->GetPlayerSkin;
- SqVC_SetPlayerColour = vcapi->SetPlayerColour;
- SqVC_GetPlayerColour = vcapi->GetPlayerColour;
- SqVC_ForcePlayerSpawn = vcapi->ForcePlayerSpawn;
- SqVC_ForcePlayerSelect = vcapi->ForcePlayerSelect;
- SqVC_ForceAllSelect = vcapi->ForceAllSelect;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: score, ping, money, typing
- SqVC_GivePlayerMoney = vcapi->GivePlayerMoney;
- SqVC_SetPlayerMoney = vcapi->SetPlayerMoney;
- SqVC_GetPlayerMoney = vcapi->GetPlayerMoney;
- SqVC_SetPlayerScore = vcapi->SetPlayerScore;
- SqVC_GetPlayerScore = vcapi->GetPlayerScore;
- SqVC_GetPlayerPing = vcapi->GetPlayerPing;
- SqVC_IsPlayerTyping = vcapi->IsPlayerTyping;
- SqVC_GetPlayerFPS = vcapi->GetPlayerFPS;
- SqVC_GetPlayerUID = vcapi->GetPlayerUID;
- SqVC_GetPlayerWantedLevel = vcapi->GetPlayerWantedLevel;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: health and location
- SqVC_SetPlayerHealth = vcapi->SetPlayerHealth;
- SqVC_GetPlayerHealth = vcapi->GetPlayerHealth;
- SqVC_SetPlayerArmour = vcapi->SetPlayerArmour;
- SqVC_GetPlayerArmour = vcapi->GetPlayerArmour;
- SqVC_SetPlayerImmunityFlags = vcapi->SetPlayerImmunityFlags;
- SqVC_GetPlayerImmunityFlags = vcapi->GetPlayerImmunityFlags;
- SqVC_SetPlayerPos = vcapi->SetPlayerPos;
- SqVC_GetPlayerPos = vcapi->GetPlayerPos;
- SqVC_SetPlayerSpeed = vcapi->SetPlayerSpeed;
- SqVC_GetPlayerSpeed = vcapi->GetPlayerSpeed;
- SqVC_AddPlayerSpeed = vcapi->AddPlayerSpeed;
- SqVC_SetPlayerHeading = vcapi->SetPlayerHeading;
- SqVC_GetPlayerHeading = vcapi->GetPlayerHeading;
- SqVC_SetPlayerAlpha = vcapi->SetPlayerAlpha;
- SqVC_GetPlayerAlpha = vcapi->GetPlayerAlpha;
- SqVC_GetPlayerOnFireStatus = vcapi->GetPlayerOnFireStatus;
- SqVC_GetPlayerCrouchStatus = vcapi->GetPlayerCrouchStatus;
- SqVC_GetPlayerAction = vcapi->GetPlayerAction;
- SqVC_GetPlayerGameKeys = vcapi->GetPlayerGameKeys;
- SqVC_GetPlayerAimPos = vcapi->GetPlayerAimPos;
- SqVC_GetPlayerAimDir = vcapi->GetPlayerAimDir;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: vehicle
- SqVC_PutPlayerInVehicle = vcapi->PutPlayerInVehicle;
- SqVC_RemovePlayerFromVehicle = vcapi->RemovePlayerFromVehicle;
- SqVC_GetPlayerInVehicleStatus = vcapi->GetPlayerInVehicleStatus;
- SqVC_GetPlayerInVehicleSlot = vcapi->GetPlayerInVehicleSlot;
- SqVC_GetPlayerVehicleID = vcapi->GetPlayerVehicleID;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: toggles
- SqVC_TogglePlayerControllable = vcapi->TogglePlayerControllable;
- SqVC_EnabledPlayerControllable = vcapi->EnabledPlayerControllable;
- SqVC_TogglePlayerDriveby = vcapi->TogglePlayerDriveby;
- SqVC_EnabledPlayerDriveby = vcapi->EnabledPlayerDriveby;
- SqVC_TogglePlayerWhiteScanlines = vcapi->TogglePlayerWhiteScanlines;
- SqVC_EnabledPlayerWhiteScanlines = vcapi->EnabledPlayerWhiteScanlines;
- SqVC_TogglePlayerGreenScanlines = vcapi->TogglePlayerGreenScanlines;
- SqVC_EnabledPlayerGreenScanlines = vcapi->EnabledPlayerGreenScanlines;
- SqVC_TogglePlayerWidescreen = vcapi->TogglePlayerWidescreen;
- SqVC_EnabledPlayerWidescreen = vcapi->EnabledPlayerWidescreen;
- SqVC_TogglePlayerShowMarkers = vcapi->TogglePlayerShowMarkers;
- SqVC_EnabledPlayerShowMarkers = vcapi->EnabledPlayerShowMarkers;
- SqVC_TogglePlayerAttackPriv = vcapi->TogglePlayerAttackPriv;
- SqVC_EnabledPlayerAttackPriv = vcapi->EnabledPlayerAttackPriv;
- SqVC_TogglePlayerHasMarker = vcapi->TogglePlayerHasMarker;
- SqVC_EnabledPlayerHasMarker = vcapi->EnabledPlayerHasMarker;
- SqVC_TogglePlayerChatTagsEnabled = vcapi->TogglePlayerChatTagsEnabled;
- SqVC_EnabledPlayerChatTags = vcapi->EnabledPlayerChatTags;
- SqVC_TogglePlayerDrunkEffects = vcapi->TogglePlayerDrunkEffects;
- SqVC_EnabledPlayerDrunkEffects = vcapi->EnabledPlayerDrunkEffects;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: weapons
- SqVC_GivePlayerWeapon = vcapi->GivePlayerWeapon;
- SqVC_SetPlayerWeapon = vcapi->SetPlayerWeapon;
- SqVC_GetPlayerWeapon = vcapi->GetPlayerWeapon;
- SqVC_GetPlayerWeaponAmmo = vcapi->GetPlayerWeaponAmmo;
- SqVC_SetPlayerWeaponSlot = vcapi->SetPlayerWeaponSlot;
- SqVC_GetPlayerWeaponSlot = vcapi->GetPlayerWeaponSlot;
- SqVC_GetPlayerWeaponAtSlot = vcapi->GetPlayerWeaponAtSlot;
- SqVC_GetPlayerAmmoAtSlot = vcapi->GetPlayerAmmoAtSlot;
- SqVC_RemovePlayerWeapon = vcapi->RemovePlayerWeapon;
- SqVC_RemoveAllWeapons = vcapi->RemoveAllWeapons;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: camera
- SqVC_SetCameraPosition = vcapi->SetCameraPosition;
- SqVC_RestoreCamera = vcapi->RestoreCamera;
- SqVC_IsCameraLocked = vcapi->IsCameraLocked;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: misc
- SqVC_SetPlayerAnimation = vcapi->SetPlayerAnimation;
- SqVC_SetPlayerWantedLevel = vcapi->SetPlayerWantedLevel;
- SqVC_GetPlayerStandingOnVehicle = vcapi->GetPlayerStandingOnVehicle;
- SqVC_GetPlayerStandingOnObject = vcapi->GetPlayerStandingOnObject;
- SqVC_IsPlayerAway = vcapi->IsPlayerAway;
- SqVC_GetPlayerSpectateTarget = vcapi->GetPlayerSpectateTarget;
- SqVC_SetPlayerSpectateTarget = vcapi->SetPlayerSpectateTarget;
- SqVC_RedirectPlayerToServer = vcapi->RedirectPlayerToServer;
-
- // --------------------------------------------------------------------------------------------
- //VEHICLES
- SqVC_CreateVehicle = vcapi->CreateVehicle;
- SqVC_DeleteVehicle = vcapi->DeleteVehicle;
- SqVC_GetVehicleSyncSource = vcapi->GetVehicleSyncSource;
- SqVC_GetVehicleSyncType = vcapi->GetVehicleSyncType;
- SqVC_IsVehicleStreamedForPlayer = vcapi->IsVehicleStreamedForPlayer;
- SqVC_SetVehicleWorld = vcapi->SetVehicleWorld;
- SqVC_GetVehicleWorld = vcapi->GetVehicleWorld;
- SqVC_GetVehicleModel = vcapi->GetVehicleModel;
- SqVC_GetVehicleOccupant = vcapi->GetVehicleOccupant;
- SqVC_RespawnVehicle = vcapi->RespawnVehicle;
- SqVC_SetVehicleImmunityFlags = vcapi->SetVehicleImmunityFlags;
- SqVC_GetVehicleImmunityFlags = vcapi->GetVehicleImmunityFlags;
- SqVC_KillVehicle = vcapi->KillVehicle;
- SqVC_IsVehicleWrecked = vcapi->IsVehicleWrecked;
- SqVC_SetVehiclePos = vcapi->SetVehiclePos;
- SqVC_GetVehiclePos = vcapi->GetVehiclePos;
- SqVC_SetVehicleRot = vcapi->SetVehicleRot;
- SqVC_SetVehicleRotEuler = vcapi->SetVehicleRotEuler;
- SqVC_GetVehicleRot = vcapi->GetVehicleRot;
- SqVC_GetVehicleRotEuler = vcapi->GetVehicleRotEuler;
- SqVC_SetVehicleSpeed = vcapi->SetVehicleSpeed;
- SqVC_GetVehicleSpeed = vcapi->GetVehicleSpeed;
- SqVC_AddVehicleSpeed = vcapi->AddVehicleSpeed;
- SqVC_SetVehicleRelSpeed = vcapi->SetVehicleRelSpeed;
- SqVC_GetVehicleRelSpeed = vcapi->GetVehicleRelSpeed;
- SqVC_AddVehicleRelSpeed = vcapi->AddVehicleRelSpeed;
- SqVC_SetVehicleTurnSpeed = vcapi->SetVehicleTurnSpeed;
- SqVC_GetVehicleTurnSpeed = vcapi->GetVehicleTurnSpeed;
- SqVC_AddVehicleTurnSpeed = vcapi->AddVehicleTurnSpeed;
- SqVC_SetVehicleRelTurnSpeed = vcapi->SetVehicleRelTurnSpeed;
- SqVC_GetVehicleRelTurnSpeed = vcapi->GetVehicleRelTurnSpeed;
- SqVC_AddVehicleRelTurnSpeed = vcapi->AddVehicleRelTurnSpeed;
- SqVC_SetVehicleSpawnPos = vcapi->SetVehicleSpawnPos;
- SqVC_GetVehicleSpawnPos = vcapi->GetVehicleSpawnPos;
- SqVC_SetVehicleSpawnRot = vcapi->SetVehicleSpawnRot;
- SqVC_SetVehicleSpawnRotEuler = vcapi->SetVehicleSpawnRotEuler;
- SqVC_GetVehicleSpawnRot = vcapi->GetVehicleSpawnRot;
- SqVC_GetVehicleSpawnRotEuler = vcapi->GetVehicleSpawnRotEuler;
- SqVC_SetVehicleIdleRespawnTimer = vcapi->SetVehicleIdleRespawnTimer;
- SqVC_GetVehicleIdleRespawnTimer = vcapi->GetVehicleIdleRespawnTimer;
- SqVC_SetVehicleHealth = vcapi->SetVehicleHealth;
- SqVC_GetVehicleHealth = vcapi->GetVehicleHealth;
- SqVC_SetVehicleColour = vcapi->SetVehicleColour;
- SqVC_GetVehicleColour = vcapi->GetVehicleColour;
- SqVC_SetVehicleDoorsLocked = vcapi->SetVehicleDoorsLocked;
- SqVC_GetVehicleDoorsLocked = vcapi->GetVehicleDoorsLocked;
- SqVC_SetVehiclePartStatus = vcapi->SetVehiclePartStatus;
- SqVC_GetVehiclePartStatus = vcapi->GetVehiclePartStatus;
- SqVC_SetVehicleTyreStatus = vcapi->SetVehicleTyreStatus;
- SqVC_GetVehicleTyreStatus = vcapi->GetVehicleTyreStatus;
- SqVC_SetVehicleDamageData = vcapi->SetVehicleDamageData;
- SqVC_GetVehicleDamageData = vcapi->GetVehicleDamageData;
- SqVC_SetVehicleAlarm = vcapi->SetVehicleAlarm;
- SqVC_GetVehicleAlarm = vcapi->GetVehicleAlarm;
- SqVC_SetVehicleLights = vcapi->SetVehicleLights;
- SqVC_GetVehicleLights = vcapi->GetVehicleLights;
- SqVC_SetVehicleRadio = vcapi->SetVehicleRadio;
- SqVC_GetVehicleRadio = vcapi->GetVehicleRadio;
- SqVC_SetVehicleRadioLocked = vcapi->SetVehicleRadioLocked;
- SqVC_IsVehicleRadioLocked = vcapi->IsVehicleRadioLocked;
- SqVC_GetVehicleGhostState = vcapi->GetVehicleGhostState;
- SqVC_SetVehicleGhostState = vcapi->SetVehicleGhostState;
- SqVC_GetVehicleTurretRotation = vcapi->GetVehicleTurretRotation;
-
- // --------------------------------------------------------------------------------------------
- //VEHICLES: handling
- SqVC_ResetAllVehicleHandlings = vcapi->ResetAllVehicleHandlings;
- SqVC_ExistsHandlingRule = vcapi->ExistsHandlingRule;
- SqVC_SetHandlingRule = vcapi->SetHandlingRule;
- SqVC_GetHandlingRule = vcapi->GetHandlingRule;
- SqVC_ResetHandlingRule = vcapi->ResetHandlingRule;
- SqVC_ResetHandling = vcapi->ResetHandling;
- SqVC_ExistsInstHandlingRule = vcapi->ExistsInstHandlingRule;
- SqVC_SetInstHandlingRule = vcapi->SetInstHandlingRule;
- SqVC_GetInstHandlingRule = vcapi->GetInstHandlingRule;
- SqVC_ResetInstHandlingRule = vcapi->ResetInstHandlingRule;
- SqVC_ResetInstHandling = vcapi->ResetInstHandling;
-
- // --------------------------------------------------------------------------------------------
- //PICKUPS
- SqVC_CreatePickup = vcapi->CreatePickup;
- SqVC_DeletePickup = vcapi->DeletePickup;
- SqVC_IsPickupStreamedForPlayer = vcapi->IsPickupStreamedForPlayer;
- SqVC_SetPickupWorld = vcapi->SetPickupWorld;
- SqVC_GetPickupWorld = vcapi->GetPickupWorld;
- SqVC_PickupGetAlpha = vcapi->PickupGetAlpha;
- SqVC_PickupSetAlpha = vcapi->PickupSetAlpha;
- SqVC_PickupIsAutomatic = vcapi->PickupIsAutomatic;
- SqVC_PickupSetAutomatic = vcapi->PickupSetAutomatic;
- SqVC_SetPickupAutoTimer = vcapi->SetPickupAutoTimer;
- SqVC_GetPickupAutoTimer = vcapi->GetPickupAutoTimer;
- SqVC_PickupRefresh = vcapi->PickupRefresh;
- SqVC_PickupGetPos = vcapi->PickupGetPos;
- SqVC_PickupSetPos = vcapi->PickupSetPos;
- SqVC_PickupGetModel = vcapi->PickupGetModel;
- SqVC_PickupGetQuantity = vcapi->PickupGetQuantity;
-
- // --------------------------------------------------------------------------------------------
- //OBJECTS
- SqVC_CreateObject = vcapi->CreateObject;
- SqVC_DeleteObject = vcapi->DeleteObject;
- SqVC_IsObjectStreamedForPlayer = vcapi->IsObjectStreamedForPlayer;
- SqVC_GetObjectModel = vcapi->GetObjectModel;
- SqVC_SetObjectWorld = vcapi->SetObjectWorld;
- SqVC_GetObjectWorld = vcapi->GetObjectWorld;
- SqVC_SetObjectAlpha = vcapi->SetObjectAlpha;
- SqVC_GetObjectAlpha = vcapi->GetObjectAlpha;
- SqVC_MoveObjectTo = vcapi->MoveObjectTo;
- SqVC_MoveObjectBy = vcapi->MoveObjectBy;
- SqVC_SetObjectPos = vcapi->SetObjectPos;
- SqVC_GetObjectPos = vcapi->GetObjectPos;
- SqVC_RotObjectTo = vcapi->RotObjectTo;
- SqVC_RotObjectToEuler = vcapi->RotObjectToEuler;
- SqVC_RotObjectBy = vcapi->RotObjectBy;
- SqVC_RotObjectByEuler = vcapi->RotObjectByEuler;
- SqVC_GetObjectRot = vcapi->GetObjectRot;
- SqVC_GetObjectRotEuler = vcapi->GetObjectRotEuler;
- SqVC_SetObjectShotReport = vcapi->SetObjectShotReport;
- SqVC_IsObjectShotReport = vcapi->IsObjectShotReport;
- SqVC_SetObjectBumpReport = vcapi->SetObjectBumpReport;
- SqVC_IsObjectBumpReport = vcapi->IsObjectBumpReport;
-
- // --------------------------------------------------------------------------------------------
- // TODO: Move these functions to proper sections on major plugin update
- SqVC_ToggleWallglitch = vcapi->ToggleWallglitch;
- SqVC_EnabledWallglitch = vcapi->EnabledWallglitch;
- SqVC_SetVehicleSiren = vcapi->SetVehicleSiren;
- SqVC_GetVehicleSiren = vcapi->GetVehicleSiren;
- SqVC_GetPlayerUID2 = vcapi->GetPlayerUID2;
-
- // --------------------------------------------------------------------------------------------
- SqVC_CreateCheckpoint = vcapi->CreateCheckpoint;
- SqVC_DeleteCheckpoint = vcapi->DeleteCheckpoint;
- SqVC_IsCheckpointStreamedForPlayer = vcapi->IsCheckpointStreamedForPlayer;
- SqVC_SetCheckpointWorld = vcapi->SetCheckpointWorld;
- SqVC_GetCheckpointWorld = vcapi->GetCheckpointWorld;
- SqVC_SetCheckpointColor = vcapi->SetCheckpointColor;
- SqVC_GetCheckpointColor = vcapi->GetCheckpointColor;
- SqVC_SetCheckpointPos = vcapi->SetCheckpointPos;
- SqVC_GetCheckpointPos = vcapi->GetCheckpointPos;
- SqVC_SetCheckpointRadius = vcapi->SetCheckpointRadius;
- SqVC_GetCheckpointRadius = vcapi->GetCheckpointRadius;
- SqVC_GetCheckpointOwner = vcapi->GetCheckpointOwner;
-
- // --------------------------------------------------------------------------------------------
- SqVC_CreateSphere = vcapi->CreateSphere;
- SqVC_DeleteSphere = vcapi->DeleteSphere;
- SqVC_IsSphereStreamedForPlayer = vcapi->IsSphereStreamedForPlayer;
- SqVC_SetSphereWorld = vcapi->SetSphereWorld;
- SqVC_GetSphereWorld = vcapi->GetSphereWorld;
- SqVC_SetSphereColor = vcapi->SetSphereColor;
- SqVC_GetSphereColor = vcapi->GetSphereColor;
- SqVC_SetSpherePos = vcapi->SetSpherePos;
- SqVC_GetSpherePos = vcapi->GetSpherePos;
- SqVC_SetSphereRadius = vcapi->SetSphereRadius;
- SqVC_GetSphereRadius = vcapi->GetSphereRadius;
- SqVC_GetSphereOwner = vcapi->GetSphereOwner;
-
- return SQ_OK;
-}
-
-// ------------------------------------------------------------------------------------------------
-void vc_api_collapse()
-{
- // --------------------------------------------------------------------------------------------
- //PLUGIN SYSTEM
- SqVC_GetServerVersion = NULL;
- SqVC_GetServerSettings = NULL;
- SqVC_ExportFunctions = NULL;
- SqVC_GetNumberOfPlugins = NULL;
- SqVC_GetPluginInfo = NULL;
- SqVC_FindPlugin = NULL;
- SqVC_GetPluginExports = NULL;
- SqVC_GetTime = NULL;
-
- // --------------------------------------------------------------------------------------------
- //MESSAGES
- SqVC_printf = NULL;
- SqVC_SendCustomCommand = NULL;
- SqVC_SendClientMessage = NULL;
- SqVC_SendGameMessage = NULL;
-
- // --------------------------------------------------------------------------------------------
- //SERVER SETTINGS
- SqVC_SetServerName = NULL;
- SqVC_GetServerName = NULL;
- SqVC_SetMaxPlayers = NULL;
- SqVC_GetMaxPlayers = NULL;
- SqVC_SetServerPassword = NULL;
- SqVC_GetServerPassword = NULL;
- SqVC_SetGameModeText = NULL;
- SqVC_GetGameModeText = NULL;
- SqVC_ShutdownServer = NULL;
-
- // --------------------------------------------------------------------------------------------
- //WORLD: settings
- SqVC_SetWorldBounds = NULL;
- SqVC_GetWorldBounds = NULL;
- SqVC_SetWastedSettings = NULL;
- SqVC_GetWastedSettings = NULL;
- SqVC_SetTimeRate = NULL;
- SqVC_GetTimeRate = NULL;
- SqVC_SetHour = NULL;
- SqVC_GetHour = NULL;
- SqVC_SetMinute = NULL;
- SqVC_GetMinute = NULL;
- SqVC_SetWeather = NULL;
- SqVC_GetWeather = NULL;
- SqVC_SetGravity = NULL;
- SqVC_GetGravity = NULL;
- SqVC_SetGamespeed = NULL;
- SqVC_GetGamespeed = NULL;
- SqVC_SetWaterLevel = NULL;
- SqVC_GetWaterLevel = NULL;
- SqVC_SetMaxHeight = NULL;
- SqVC_GetMaxHeight = NULL;
- SqVC_SetKillCmdDelay = NULL;
- SqVC_GetKillCmdDelay = NULL;
- SqVC_SetVehiclesForcedRespawnHeight = NULL;
- SqVC_GetVehiclesForcedRespawnHeight = NULL;
-
- // --------------------------------------------------------------------------------------------
- //WORLD: toggles
- SqVC_ToggleSyncFrameLimiter = NULL;
- SqVC_EnabledSyncFrameLimiter = NULL;
- SqVC_ToggleFrameLimiter = NULL;
- SqVC_EnabledFrameLimiter = NULL;
- SqVC_ToggleTaxiBoostJump = NULL;
- SqVC_EnabledTaxiBoostJump = NULL;
- SqVC_ToggleDriveOnWater = NULL;
- SqVC_EnabledDriveOnWater = NULL;
- SqVC_ToggleFastSwitch = NULL;
- SqVC_EnabledFastSwitch = NULL;
- SqVC_ToggleFriendlyFire = NULL;
- SqVC_EnabledFriendlyFire = NULL;
- SqVC_ToggleDisableDriveby = NULL;
- SqVC_EnabledDisableDriveby = NULL;
- SqVC_TogglePerfectHandling = NULL;
- SqVC_EnabledPerfectHandling = NULL;
- SqVC_ToggleFlyingCars = NULL;
- SqVC_EnabledFlyingCars = NULL;
- SqVC_ToggleJumpSwitch = NULL;
- SqVC_EnabledJumpSwitch = NULL;
- SqVC_ToggleShowMarkers = NULL;
- SqVC_EnabledShowMarkers = NULL;
- SqVC_ToggleOnlyShowTeamMarkers = NULL;
- SqVC_EnabledOnlyShowTeamMarkers = NULL;
- SqVC_ToggleStuntBike = NULL;
- SqVC_EnabledStuntBike = NULL;
- SqVC_ToggleShootInAir = NULL;
- SqVC_EnabledShootInAir = NULL;
- SqVC_ToggleShowNametags = NULL;
- SqVC_EnabledShowNametags = NULL;
- SqVC_ToggleJoinMessages = NULL;
- SqVC_EnabledJoinMessages = NULL;
- SqVC_ToggleDeathMessages = NULL;
- SqVC_EnabledDeathMessages = NULL;
- SqVC_ToggleChatTagsByDefaultEnabled = NULL;
- SqVC_EnabledChatTagsByDefault = NULL;
-
- // --------------------------------------------------------------------------------------------
- //MISC
- SqVC_CreateExplosion = NULL;
- SqVC_PlaySound = NULL;
- SqVC_HideMapObject = NULL;
- SqVC_ShowMapObject = NULL;
- SqVC_ShowAllMapObjects = NULL;
-
- //WEAPONDATA
- SqVC_SetWeaponDataValue = NULL;
- SqVC_GetWeaponDataValue = NULL;
- SqVC_ResetWeaponDataValue = NULL;
- SqVC_IsWeaponDataValueModified = NULL;
- SqVC_ResetWeaponData = NULL;
- SqVC_ResetAllWeaponData = NULL;
-
- // --------------------------------------------------------------------------------------------
- //KEYBINDS
- SqVC_GetKeyBindUnusedSlot = NULL;
- SqVC_GetKeyBindData = NULL;
- SqVC_RegisterKeyBind = NULL;
- SqVC_RemoveKeyBind = NULL;
- SqVC_RemoveAllKeyBinds = NULL;
-
- //BLIPS
- SqVC_CreateCoordBlip = NULL;
- SqVC_DestroyCoordBlip = NULL;
- SqVC_GetCoordBlipInfo = NULL;
-
- // --------------------------------------------------------------------------------------------
- //SPRITES
- SqVC_CreateSprite = NULL;
- SqVC_DestroySprite = NULL;
- SqVC_ShowSprite = NULL;
- SqVC_HideSprite = NULL;
- SqVC_MoveSprite = NULL;
- SqVC_SetSpriteCenter = NULL;
- SqVC_RotateSprite = NULL;
- SqVC_SetSpriteAlpha = NULL;
- SqVC_SetSpriteRelativity = NULL;
-
- //TEXTDRAWS
- SqVC_CreateTextdraw = NULL;
- SqVC_DestroyTextdraw = NULL;
- SqVC_ShowTextdraw = NULL;
- SqVC_HideTextdraw = NULL;
- SqVC_MoveTextdraw = NULL;
- SqVC_SetTextdrawColour = NULL;
- SqVC_SetTextdrawRelativity = NULL;
-
- // --------------------------------------------------------------------------------------------
- //RADIOS
- SqVC_AddRadioStream = NULL;
- SqVC_RemoveRadioStream = NULL;
-
- // --------------------------------------------------------------------------------------------
- //CLASSES
- SqVC_SetUseClasses = NULL;
- SqVC_GetUseClasses = NULL;
- SqVC_GetPlayerClass = NULL;
- SqVC_AddPlayerClass = NULL;
- SqVC_SetSpawnPlayerPos = NULL;
- SqVC_SetSpawnCameraPos = NULL;
- SqVC_SetSpawnCameraLookAt = NULL;
-
- // --------------------------------------------------------------------------------------------
- //ADMIN
- SqVC_IsPlayerAdmin = NULL;
- SqVC_SetPlayerAdmin = NULL;
- SqVC_GetPlayerIP = NULL;
- SqVC_KickPlayer = NULL;
- SqVC_BanPlayer = NULL;
- SqVC_BanIP = NULL;
- SqVC_UnbanIP = NULL;
- SqVC_IsIPBanned = NULL;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: basic
- SqVC_GetPlayerIDFromName = NULL;
- SqVC_IsPlayerConnected = NULL;
- SqVC_IsPlayerSpawned = NULL;
- SqVC_IsPlayerStreamedForPlayer = NULL;
- SqVC_GetPlayerKey = NULL;
- SqVC_SetPlayerWorld = NULL;
- SqVC_GetPlayerWorld = NULL;
- SqVC_SetPlayerSecWorld = NULL;
- SqVC_GetPlayerSecWorld = NULL;
- SqVC_GetPlayerUniqueWorld = NULL;
- SqVC_IsPlayerWorldCompatible = NULL;
- SqVC_GetPlayerState = NULL;
- SqVC_GetPlayerName = NULL;
- SqVC_SetPlayerName = NULL;
- SqVC_SetPlayerTeam = NULL;
- SqVC_GetPlayerTeam = NULL;
- SqVC_SetPlayerSkin = NULL;
- SqVC_GetPlayerSkin = NULL;
- SqVC_SetPlayerColour = NULL;
- SqVC_GetPlayerColour = NULL;
- SqVC_ForcePlayerSpawn = NULL;
- SqVC_ForcePlayerSelect = NULL;
- SqVC_ForceAllSelect = NULL;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: score, ping, money, typing
- SqVC_GivePlayerMoney = NULL;
- SqVC_SetPlayerMoney = NULL;
- SqVC_GetPlayerMoney = NULL;
- SqVC_SetPlayerScore = NULL;
- SqVC_GetPlayerScore = NULL;
- SqVC_GetPlayerPing = NULL;
- SqVC_IsPlayerTyping = NULL;
- SqVC_GetPlayerFPS = NULL;
- SqVC_GetPlayerUID = NULL;
- SqVC_GetPlayerWantedLevel = NULL;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: health and location
- SqVC_SetPlayerHealth = NULL;
- SqVC_GetPlayerHealth = NULL;
- SqVC_SetPlayerArmour = NULL;
- SqVC_GetPlayerArmour = NULL;
- SqVC_SetPlayerImmunityFlags = NULL;
- SqVC_GetPlayerImmunityFlags = NULL;
- SqVC_SetPlayerPos = NULL;
- SqVC_GetPlayerPos = NULL;
- SqVC_SetPlayerSpeed = NULL;
- SqVC_GetPlayerSpeed = NULL;
- SqVC_AddPlayerSpeed = NULL;
- SqVC_SetPlayerHeading = NULL;
- SqVC_GetPlayerHeading = NULL;
- SqVC_SetPlayerAlpha = NULL;
- SqVC_GetPlayerAlpha = NULL;
- SqVC_GetPlayerOnFireStatus = NULL;
- SqVC_GetPlayerCrouchStatus = NULL;
- SqVC_GetPlayerAction = NULL;
- SqVC_GetPlayerGameKeys = NULL;
- SqVC_GetPlayerAimPos = NULL;
- SqVC_GetPlayerAimDir = NULL;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: vehicle
- SqVC_PutPlayerInVehicle = NULL;
- SqVC_RemovePlayerFromVehicle = NULL;
- SqVC_GetPlayerInVehicleStatus = NULL;
- SqVC_GetPlayerInVehicleSlot = NULL;
- SqVC_GetPlayerVehicleID = NULL;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: toggles
- SqVC_TogglePlayerControllable = NULL;
- SqVC_EnabledPlayerControllable = NULL;
- SqVC_TogglePlayerDriveby = NULL;
- SqVC_EnabledPlayerDriveby = NULL;
- SqVC_TogglePlayerWhiteScanlines = NULL;
- SqVC_EnabledPlayerWhiteScanlines = NULL;
- SqVC_TogglePlayerGreenScanlines = NULL;
- SqVC_EnabledPlayerGreenScanlines = NULL;
- SqVC_TogglePlayerWidescreen = NULL;
- SqVC_EnabledPlayerWidescreen = NULL;
- SqVC_TogglePlayerShowMarkers = NULL;
- SqVC_EnabledPlayerShowMarkers = NULL;
- SqVC_TogglePlayerAttackPriv = NULL;
- SqVC_EnabledPlayerAttackPriv = NULL;
- SqVC_TogglePlayerHasMarker = NULL;
- SqVC_EnabledPlayerHasMarker = NULL;
- SqVC_TogglePlayerChatTagsEnabled = NULL;
- SqVC_EnabledPlayerChatTags = NULL;
- SqVC_TogglePlayerDrunkEffects = NULL;
- SqVC_EnabledPlayerDrunkEffects = NULL;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: weapons
- SqVC_GivePlayerWeapon = NULL;
- SqVC_SetPlayerWeapon = NULL;
- SqVC_GetPlayerWeapon = NULL;
- SqVC_GetPlayerWeaponAmmo = NULL;
- SqVC_SetPlayerWeaponSlot = NULL;
- SqVC_GetPlayerWeaponSlot = NULL;
- SqVC_GetPlayerWeaponAtSlot = NULL;
- SqVC_GetPlayerAmmoAtSlot = NULL;
- SqVC_RemovePlayerWeapon = NULL;
- SqVC_RemoveAllWeapons = NULL;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: camera
- SqVC_SetCameraPosition = NULL;
- SqVC_RestoreCamera = NULL;
- SqVC_IsCameraLocked = NULL;
-
- // --------------------------------------------------------------------------------------------
- //PLAYERS: misc
- SqVC_SetPlayerAnimation = NULL;
- SqVC_SetPlayerWantedLevel = NULL;
- SqVC_GetPlayerStandingOnVehicle = NULL;
- SqVC_GetPlayerStandingOnObject = NULL;
- SqVC_IsPlayerAway = NULL;
- SqVC_GetPlayerSpectateTarget = NULL;
- SqVC_SetPlayerSpectateTarget = NULL;
- SqVC_RedirectPlayerToServer = NULL;
-
- // --------------------------------------------------------------------------------------------
- //VEHICLES
- SqVC_CreateVehicle = NULL;
- SqVC_DeleteVehicle = NULL;
- SqVC_GetVehicleSyncSource = NULL;
- SqVC_GetVehicleSyncType = NULL;
- SqVC_IsVehicleStreamedForPlayer = NULL;
- SqVC_SetVehicleWorld = NULL;
- SqVC_GetVehicleWorld = NULL;
- SqVC_GetVehicleModel = NULL;
- SqVC_GetVehicleOccupant = NULL;
- SqVC_RespawnVehicle = NULL;
- SqVC_SetVehicleImmunityFlags = NULL;
- SqVC_GetVehicleImmunityFlags = NULL;
- SqVC_KillVehicle = NULL;
- SqVC_IsVehicleWrecked = NULL;
- SqVC_SetVehiclePos = NULL;
- SqVC_GetVehiclePos = NULL;
- SqVC_SetVehicleRot = NULL;
- SqVC_SetVehicleRotEuler = NULL;
- SqVC_GetVehicleRot = NULL;
- SqVC_GetVehicleRotEuler = NULL;
- SqVC_SetVehicleSpeed = NULL;
- SqVC_GetVehicleSpeed = NULL;
- SqVC_AddVehicleSpeed = NULL;
- SqVC_SetVehicleRelSpeed = NULL;
- SqVC_GetVehicleRelSpeed = NULL;
- SqVC_AddVehicleRelSpeed = NULL;
- SqVC_SetVehicleTurnSpeed = NULL;
- SqVC_GetVehicleTurnSpeed = NULL;
- SqVC_AddVehicleTurnSpeed = NULL;
- SqVC_SetVehicleRelTurnSpeed = NULL;
- SqVC_GetVehicleRelTurnSpeed = NULL;
- SqVC_AddVehicleRelTurnSpeed = NULL;
- SqVC_SetVehicleSpawnPos = NULL;
- SqVC_GetVehicleSpawnPos = NULL;
- SqVC_SetVehicleSpawnRot = NULL;
- SqVC_SetVehicleSpawnRotEuler = NULL;
- SqVC_GetVehicleSpawnRot = NULL;
- SqVC_GetVehicleSpawnRotEuler = NULL;
- SqVC_SetVehicleIdleRespawnTimer = NULL;
- SqVC_GetVehicleIdleRespawnTimer = NULL;
- SqVC_SetVehicleHealth = NULL;
- SqVC_GetVehicleHealth = NULL;
- SqVC_SetVehicleColour = NULL;
- SqVC_GetVehicleColour = NULL;
- SqVC_SetVehicleDoorsLocked = NULL;
- SqVC_GetVehicleDoorsLocked = NULL;
- SqVC_SetVehiclePartStatus = NULL;
- SqVC_GetVehiclePartStatus = NULL;
- SqVC_SetVehicleTyreStatus = NULL;
- SqVC_GetVehicleTyreStatus = NULL;
- SqVC_SetVehicleDamageData = NULL;
- SqVC_GetVehicleDamageData = NULL;
- SqVC_SetVehicleAlarm = NULL;
- SqVC_GetVehicleAlarm = NULL;
- SqVC_SetVehicleLights = NULL;
- SqVC_GetVehicleLights = NULL;
- SqVC_SetVehicleRadio = NULL;
- SqVC_GetVehicleRadio = NULL;
- SqVC_SetVehicleRadioLocked = NULL;
- SqVC_IsVehicleRadioLocked = NULL;
- SqVC_GetVehicleGhostState = NULL;
- SqVC_SetVehicleGhostState = NULL;
- SqVC_GetVehicleTurretRotation = NULL;
-
- // --------------------------------------------------------------------------------------------
- //VEHICLES: handling
- SqVC_ResetAllVehicleHandlings = NULL;
- SqVC_ExistsHandlingRule = NULL;
- SqVC_SetHandlingRule = NULL;
- SqVC_GetHandlingRule = NULL;
- SqVC_ResetHandlingRule = NULL;
- SqVC_ResetHandling = NULL;
- SqVC_ExistsInstHandlingRule = NULL;
- SqVC_SetInstHandlingRule = NULL;
- SqVC_GetInstHandlingRule = NULL;
- SqVC_ResetInstHandlingRule = NULL;
- SqVC_ResetInstHandling = NULL;
-
- // --------------------------------------------------------------------------------------------
- //PICKUPS
- SqVC_CreatePickup = NULL;
- SqVC_DeletePickup = NULL;
- SqVC_IsPickupStreamedForPlayer = NULL;
- SqVC_SetPickupWorld = NULL;
- SqVC_GetPickupWorld = NULL;
- SqVC_PickupGetAlpha = NULL;
- SqVC_PickupSetAlpha = NULL;
- SqVC_PickupIsAutomatic = NULL;
- SqVC_PickupSetAutomatic = NULL;
- SqVC_SetPickupAutoTimer = NULL;
- SqVC_GetPickupAutoTimer = NULL;
- SqVC_PickupRefresh = NULL;
- SqVC_PickupGetPos = NULL;
- SqVC_PickupSetPos = NULL;
- SqVC_PickupGetModel = NULL;
- SqVC_PickupGetQuantity = NULL;
-
- // --------------------------------------------------------------------------------------------
- //OBJECTS
- SqVC_CreateObject = NULL;
- SqVC_DeleteObject = NULL;
- SqVC_IsObjectStreamedForPlayer = NULL;
- SqVC_GetObjectModel = NULL;
- SqVC_SetObjectWorld = NULL;
- SqVC_GetObjectWorld = NULL;
- SqVC_SetObjectAlpha = NULL;
- SqVC_GetObjectAlpha = NULL;
- SqVC_MoveObjectTo = NULL;
- SqVC_MoveObjectBy = NULL;
- SqVC_SetObjectPos = NULL;
- SqVC_GetObjectPos = NULL;
- SqVC_RotObjectTo = NULL;
- SqVC_RotObjectToEuler = NULL;
- SqVC_RotObjectBy = NULL;
- SqVC_RotObjectByEuler = NULL;
- SqVC_GetObjectRot = NULL;
- SqVC_GetObjectRotEuler = NULL;
- SqVC_SetObjectShotReport = NULL;
- SqVC_IsObjectShotReport = NULL;
- SqVC_SetObjectBumpReport = NULL;
- SqVC_IsObjectBumpReport = NULL;
-
- // --------------------------------------------------------------------------------------------
- // TODO: Move these functions to proper sections on major plugin update
- SqVC_ToggleWallglitch = NULL;
- SqVC_EnabledWallglitch = NULL;
- SqVC_SetVehicleSiren = NULL;
- SqVC_GetVehicleSiren = NULL;
- SqVC_GetPlayerUID2 = NULL;
-
- // --------------------------------------------------------------------------------------------
- SqVC_CreateCheckpoint = NULL;
- SqVC_DeleteCheckpoint = NULL;
- SqVC_IsCheckpointStreamedForPlayer = NULL;
- SqVC_SetCheckpointWorld = NULL;
- SqVC_GetCheckpointWorld = NULL;
- SqVC_SetCheckpointColor = NULL;
- SqVC_GetCheckpointColor = NULL;
- SqVC_SetCheckpointPos = NULL;
- SqVC_GetCheckpointPos = NULL;
- SqVC_SetCheckpointRadius = NULL;
- SqVC_GetCheckpointRadius = NULL;
- SqVC_GetCheckpointOwner = NULL;
-
- // --------------------------------------------------------------------------------------------
- SqVC_CreateSphere = NULL;
- SqVC_DeleteSphere = NULL;
- SqVC_IsSphereStreamedForPlayer = NULL;
- SqVC_SetSphereWorld = NULL;
- SqVC_GetSphereWorld = NULL;
- SqVC_SetSphereColor = NULL;
- SqVC_GetSphereColor = NULL;
- SqVC_SetSpherePos = NULL;
- SqVC_GetSpherePos = NULL;
- SqVC_SetSphereRadius = NULL;
- SqVC_GetSphereRadius = NULL;
- SqVC_GetSphereOwner = NULL;
-}
\ No newline at end of file
diff --git a/source/Base/Shared.hpp b/source/Base/Shared.hpp
index e5f2e595..3233f3d7 100644
--- a/source/Base/Shared.hpp
+++ b/source/Base/Shared.hpp
@@ -183,6 +183,21 @@ bool cLogSFtl(bool cond, CCStr fmt, ...);
// ------------------------------------------------------------------------------------------------
void SqThrow(CCStr fmt, ...);
+/* ------------------------------------------------------------------------------------------------
+ * Output a message only if the _DEBUG was defined.
+*/
+void OutputDebug(const char * msg, ...);
+
+/* ------------------------------------------------------------------------------------------------
+ * Output a formatted user message to the console.
+*/
+void OutputMessage(const char * msg, ...);
+
+/* ------------------------------------------------------------------------------------------------
+ * Output a formatted error message to the console.
+*/
+void OutputError(const char * msg, ...);
+
// ------------------------------------------------------------------------------------------------
Object & NullObject();
diff --git a/source/Core.cpp b/source/Core.cpp
index a06885f7..12f5b49c 100644
--- a/source/Core.cpp
+++ b/source/Core.cpp
@@ -37,10 +37,6 @@ namespace SqMod {
// ------------------------------------------------------------------------------------------------
extern bool RegisterAPI(HSQUIRRELVM vm);
-// ------------------------------------------------------------------------------------------------
-extern void ProcessIrc();
-extern void TerminateIrc();
-
// ------------------------------------------------------------------------------------------------
extern void ProcessRoutine();
extern void TerminateRoutine();
@@ -313,7 +309,8 @@ bool Core::Load()
return false;
LogDbg("Signaling outside plugins to register their API");
// Signal outside plugins to do their monkey business
- _Func->SendCustomCommand(0xDABBAD00, "");
+ _Func->SendCustomCommand(0xDEADBABE, "");
+
LogDbg("Attempting to execute the specified scripts");
// Go through each specified script
for (Scripts::iterator itr = m_Scripts.begin(); itr != m_Scripts.end(); ++itr)
@@ -339,6 +336,9 @@ bool Core::Load()
// ------------------------------------------------------------------------------------------------
void Core::Terminate()
{
+ LogDbg("Signaling outside plugins to release their resources");
+ // Signal outside plugins to do their monkey business
+ _Func->SendCustomCommand(0xDEADC0DE, "");
// Release all entity resources by clearing the containers
m_Blips.clear();
m_Checkpoints.clear();
@@ -355,8 +355,6 @@ void Core::Terminate()
TerminateRoutine();
// Release all resources from command manager
TerminateCommand();
- // Release all resources from irc sessions
- TerminateIrc();
// Is there a VM to close?
if (m_VM)
{
@@ -1242,8 +1240,9 @@ void Core::EmitPlayerCommand(Int32 player, CCStr command)
void Core::EmitPlayerMessage(Int32 player, Int32 receiver, CCStr message)
{
PlayerInst & _player = m_Players.at(player);
- Emit(_player.mOnMessage, message);
- Emit(mOnPlayerMessage, _player.mObj, message);
+ PlayerInst & _receiver = m_Players.at(receiver);
+ Emit(_player.mOnMessage,_receiver.mObj, message);
+ Emit(mOnPlayerMessage, _player.mObj, _receiver.mObj, message);
}
void Core::EmitPlayerHealth(Int32 player, Float32 previous, Float32 current)
@@ -1651,8 +1650,6 @@ void Core::EmitServerFrame(Float32 delta)
Emit(mOnServerFrame, delta);
// Update routines
ProcessRoutine();
- // Update IRC sessions
- ProcessIrc();
}
void Core::EmitServerStartup()
@@ -1700,17 +1697,17 @@ void Core::EmitScriptUnload()
Emit(mOnScriptUnload);
}
-void Core::EmitPlayerUpdate(Int32 player, Int32 type)
+void Core::EmitPlayerUpdate(Int32 /*player*/, Int32 /*type*/)
{
}
-void Core::EmitVehicleUpdate(Int32 vehicle, Int32 type)
+void Core::EmitVehicleUpdate(Int32 /*vehicle*/, Int32 /*type*/)
{
}
-void Core::EmitEntityPool(Int32 type, Int32 id, bool deleted)
+void Core::EmitEntityPool(Int32 /*type*/, Int32 /*id*/, bool /*deleted*/)
{
}
diff --git a/source/Exports.cpp b/source/Exports.cpp
index 2ededa29..8cbb5456 100644
--- a/source/Exports.cpp
+++ b/source/Exports.cpp
@@ -1,6 +1,10 @@
// ------------------------------------------------------------------------------------------------
#include "Core.hpp"
+// ------------------------------------------------------------------------------------------------
+#include "Library/Numeric.hpp"
+#include "Library/Time.hpp"
+
// ------------------------------------------------------------------------------------------------
#include
#include
@@ -9,7 +13,7 @@
#include
#include
#include
-#include
+#include
// ------------------------------------------------------------------------------------------------
namespace SqMod {
@@ -32,6 +36,174 @@ static HSQUIRRELVM GetSquirrelVM()
return NULL;
}
+// ------------------------------------------------------------------------------------------------
+static SQRESULT SqEx_GetSLongValue(HSQUIRRELVM vm, SQInteger idx, Int64 * num)
+{
+ // Validate the specified number pointer and value type
+ if (!num)
+ return SQ_ERROR; /* Nowhere to save */
+ else if (sq_gettype(vm, idx) == OT_INSTANCE)
+ {
+ // Attempt to obtain the long instance from the stack
+ Var< SLongInt * > inst(vm, idx);
+ // Validate the instance
+ if (!inst.value)
+ return SQ_ERROR; /* Invalid instance */
+ else
+ *num = (Int64)inst.value->GetNum();
+ }
+ // Is this a pure integer value?
+ else if(sq_gettype(vm, idx) == OT_INTEGER)
+ {
+ SQInteger val = 0;
+ // Attempt to get the value from the stack
+ sq_getinteger(vm, idx, &val);
+ // Save it into the specified memory location
+ *num = (Int64)val;
+ }
+ // Is this a pure floating point value?
+ else if(sq_gettype(vm, idx) == OT_FLOAT)
+ {
+ SQFloat val = 0.0;
+ // Attempt to get the value from the stack
+ sq_getfloat(vm, idx, &val);
+ // Save it into the specified memory location
+ *num = (Int64)val;
+ }
+ // Is this a pure boolean value?
+ else if(sq_gettype(vm, idx) == OT_BOOL)
+ {
+ SQBool val = SQFalse;
+ // Attempt to get the value from the stack
+ sq_getbool(vm, idx, &val);
+ // Save it into the specified memory location
+ *num = (Int64)val;
+ }
+ // Unrecognized value
+ else
+ return SQ_ERROR;
+ // Value retrieved
+ return SQ_OK;
+}
+
+// ------------------------------------------------------------------------------------------------
+static void SqEx_PushSLongObject(HSQUIRRELVM vm, Int64 num)
+{
+ Var< const SLongInt & >::push(vm, SLongInt(num));
+}
+
+// ------------------------------------------------------------------------------------------------
+static SQRESULT SqEx_GetULongValue(HSQUIRRELVM vm, SQInteger idx, Uint64 * num)
+{
+ // Validate the specified number pointer and value type
+ if (!num)
+ return SQ_ERROR; /* Nowhere to save */
+ else if (sq_gettype(vm, idx) == OT_INSTANCE)
+ {
+ // Attempt to obtain the long instance from the stack
+ Var< ULongInt * > inst(vm, idx);
+ // Validate the instance
+ if (!inst.value)
+ return SQ_ERROR; /* Invalid instance */
+ else
+ *num = (Uint64)inst.value->GetNum();
+ }
+ // Is this a pure integer value?
+ else if(sq_gettype(vm, idx) == OT_INTEGER)
+ {
+ SQInteger val = 0;
+ // Attempt to get the value from the stack
+ sq_getinteger(vm, idx, &val);
+ // Save it into the specified memory location
+ *num = val < 0 ? 0L : (Uint64)val;
+ }
+ // Is this a pure floating point value?
+ else if(sq_gettype(vm, idx) == OT_FLOAT)
+ {
+ SQFloat val = 0.0;
+ // Attempt to get the value from the stack
+ sq_getfloat(vm, idx, &val);
+ // Save it into the specified memory location
+ *num = EpsLt(val, SQFloat(0.0)) ? 0L : (Uint64)val;
+ }
+ // Is this a pure boolean value?
+ else if(sq_gettype(vm, idx) == OT_BOOL)
+ {
+ SQBool val = SQFalse;
+ // Attempt to get the value from the stack
+ sq_getbool(vm, idx, &val);
+ // Save it into the specified memory location
+ *num = (Uint64)val;
+ }
+ // Unrecognized value
+ else
+ return SQ_ERROR;
+ // Value retrieved
+ return SQ_OK;
+}
+
+// ------------------------------------------------------------------------------------------------
+static void SqEx_PushULongObject(HSQUIRRELVM vm, Uint64 num)
+{
+ Var< const ULongInt & >::push(vm, ULongInt(num));
+}
+
+// ------------------------------------------------------------------------------------------------
+static SQRESULT SqEx_GetTimestamp(HSQUIRRELVM vm, SQInteger idx, Int64 * num)
+{
+ // Validate the specified number pointer and value type
+ if (!num)
+ return SQ_ERROR; /* Nowhere to save */
+ else if (sq_gettype(vm, idx) == OT_INSTANCE)
+ {
+ // Attempt to obtain the long instance from the stack
+ Var< Timestamp * > inst(vm, idx);
+ // Validate the instance
+ if (!inst.value)
+ return SQ_ERROR; /* Invalid instance */
+ else
+ *num = (Int64)inst.value->GetNum();
+ }
+ // Is this a pure integer value?
+ else if(sq_gettype(vm, idx) == OT_INTEGER)
+ {
+ SQInteger val = 0;
+ // Attempt to get the value from the stack
+ sq_getinteger(vm, idx, &val);
+ // Save it into the specified memory location
+ *num = (Int64)val;
+ }
+ // Is this a pure floating point value?
+ else if(sq_gettype(vm, idx) == OT_FLOAT)
+ {
+ SQFloat val = 0.0;
+ // Attempt to get the value from the stack
+ sq_getfloat(vm, idx, &val);
+ // Save it into the specified memory location
+ *num = (Int64)val;
+ }
+ // Is this a pure boolean value?
+ else if(sq_gettype(vm, idx) == OT_BOOL)
+ {
+ SQBool val = SQFalse;
+ // Attempt to get the value from the stack
+ sq_getbool(vm, idx, &val);
+ // Save it into the specified memory location
+ *num = (Int64)val;
+ }
+ // Unrecognized value
+ else
+ return SQ_ERROR;
+ // Value retrieved
+ return SQ_OK;
+}
+
+// ------------------------------------------------------------------------------------------------
+static void SqEx_PushTimestamp(HSQUIRRELVM vm, Int64 num)
+{
+ Var< const Timestamp & >::push(vm, Timestamp(num));
+}
+
// ------------------------------------------------------------------------------------------------
void InitExports()
{
@@ -39,10 +211,42 @@ void InitExports()
// Assign the functions that should be exported
g_SqExports.uStructSize = sizeof(SQEXPORTS);
- g_SqExports.GetSquirrelAPI = GetSquirrelAPI;
- g_SqExports.GetSquirrelVM = GetSquirrelVM;
+ g_SqExports.GetSquirrelAPI = GetSquirrelAPI;
+ g_SqExports.GetSquirrelVM = GetSquirrelVM;
+
+ /*logging utilities*/
+ g_SqExports.LogDbg = LogDbg;
+ g_SqExports.LogUsr = LogUsr;
+ g_SqExports.LogScs = LogScs;
+ g_SqExports.LogInf = LogInf;
+ g_SqExports.LogWrn = LogWrn;
+ g_SqExports.LogErr = LogErr;
+ g_SqExports.LogFtl = LogFtl;
+ g_SqExports.LogSDbg = LogSDbg;
+ g_SqExports.LogSUsr = LogSUsr;
+ g_SqExports.LogSScs = LogSScs;
+ g_SqExports.LogSInf = LogSInf;
+ g_SqExports.LogSWrn = LogSWrn;
+ g_SqExports.LogSErr = LogSErr;
+ g_SqExports.LogSFtl = LogSFtl;
+ g_SqExports.SqThrow = SqThrow;
+
+ /*long numbers*/
+ g_SqExports.GetSLongValue = SqEx_GetSLongValue;
+ g_SqExports.PushSLongObject = SqEx_PushSLongObject;
+ g_SqExports.GetULongValue = SqEx_GetULongValue;
+ g_SqExports.PushULongObject = SqEx_PushULongObject;
+
+ /*time utilities*/
+ g_SqExports.GetCurrentSysTime = GetCurrentSysTime;
+ g_SqExports.GetEpochTimeMicro = GetEpochTimeMicro;
+ g_SqExports.GetEpochTimeMilli = GetEpochTimeMilli;
+ g_SqExports.GetTimestamp = SqEx_GetTimestamp;
+ g_SqExports.PushTimestamp = SqEx_PushTimestamp;
+
// Export them to the server
_Func->ExportFunctions(_Info->nPluginId, (void **)(&sqexports), sizeof(SQEXPORTS));
+
/*vm*/
g_SqAPI.open = sq_open;
g_SqAPI.newthread = sq_newthread;
diff --git a/source/Library/INI.cpp b/source/Library/INI.cpp
deleted file mode 100644
index 36fe06ee..00000000
--- a/source/Library/INI.cpp
+++ /dev/null
@@ -1,533 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-#include "Library/INI.hpp"
-
-// ------------------------------------------------------------------------------------------------
-#include
-
-// ------------------------------------------------------------------------------------------------
-namespace SqMod {
-namespace INI {
-
-// ------------------------------------------------------------------------------------------------
-Int32 Entries::Cmp(const Entries & o) const
-{
- if (m_Elem == o.m_Elem)
- return 0;
- else if (this > &o)
- return 1;
- else
- return -1;
-}
-
-// ------------------------------------------------------------------------------------------------
-CSStr Entries::ToString() const
-{
- return GetItem();
-}
-
-// ------------------------------------------------------------------------------------------------
-void Entries::Next()
-{
- // Are there any other elements ahead?
- if (!m_List.empty() && m_Elem != m_List.end())
- ++m_Elem; /* Go ahead one element */
-}
-
-// ------------------------------------------------------------------------------------------------
-void Entries::Prev()
-{
- // Are there any other elements behind?
- if (!m_List.empty() && m_Elem != m_List.begin())
- --m_Elem; /* Go back one element */
-}
-
-// ------------------------------------------------------------------------------------------------
-void Entries::Advance(Int32 n)
-{
- // Are there any other elements ahead?
- if (m_List.empty() || m_Elem == m_List.end())
- return;
- // Jump as many elements as possible
- while ((--n >= 0) && m_Elem != m_List.end()) ++m_Elem;
-}
-
-// ------------------------------------------------------------------------------------------------
-void Entries::Retreat(Int32 n)
-{
- // Are there any other elements behind?
- if (m_List.empty() || m_Elem == m_List.begin())
- return;
- // Jump as many elements as possible
- while ((--n >= 0) && m_Elem != m_List.begin()) --m_Elem;
-}
-
-// ------------------------------------------------------------------------------------------------
-CSStr Entries::GetItem() const
-{
- if (m_List.empty() || m_Elem == m_List.end())
- SqThrow("Invalid INI entry [item]");
- else
- return m_Elem->pItem;
- return _SC("");
-}
-
-// ------------------------------------------------------------------------------------------------
-CSStr Entries::GetComment() const
-{
- if (m_List.empty() || m_Elem == m_List.end())
- SqThrow("Invalid INI entry [comment]");
- else
- return m_Elem->pComment;
- return _SC("");
-}
-
-// ------------------------------------------------------------------------------------------------
-Int32 Entries::GetOrder() const
-{
- if (m_List.empty() || m_Elem == m_List.end())
- SqThrow("Invalid INI entry [order]");
- else
- return m_Elem->nOrder;
- return -1;
-}
-
-// ------------------------------------------------------------------------------------------------
-Document::Document()
- : m_Doc(false, false, true)
-{
- /* ... */
-}
-
-// ------------------------------------------------------------------------------------------------
-Document::Document(bool utf8, bool multikey, bool multiline)
- : m_Doc(utf8, multikey, multiline)
-{
- /* ... */
-}
-
-// ------------------------------------------------------------------------------------------------
-Document::~Document()
-{
- /* ... */
-}
-
-// ------------------------------------------------------------------------------------------------
-Int32 Document::Cmp(const Document & o) const
-{
- if (m_Doc == o.m_Doc)
- return 0;
- else if (this > &o)
- return 1;
- else
- return -1;
-}
-
-// ------------------------------------------------------------------------------------------------
-CSStr Document::ToString() const
-{
- return _SC("");
-}
-
-// ------------------------------------------------------------------------------------------------
-void Document::LoadFile(CSStr filepath)
-{
- if (!Validate())
- return; /* Unable to proceed */
- // Attempt to load the file from disk
- const SI_Error ret = m_Doc->LoadFile(filepath);
- // See if the file could be loaded
- if (ret < 0)
- {
- // Identify the error type
- switch (ret)
- {
- case SI_FAIL:
- SqThrow("Failed to load the INI file. Probably invalid");
- break;
- case SI_NOMEM:
- SqThrow("Ran out of memory while loading the INI file");
- break;
- case SI_FILE:
- SqThrow("Failed to load the INI file. %s", strerror(errno));
- break;
- default:
- SqThrow("Failed to load the INI file for some unforeseen reason");
- }
- }
-}
-
-// ------------------------------------------------------------------------------------------------
-void Document::LoadData(CSStr source, Int32 size)
-{
- if (!Validate())
- return; /* Unable to proceed */
- // Attempt to load the source from memory
- const SI_Error ret = m_Doc->LoadData(source, size < 0 ? strlen(source) : size);
- // See if the source could be loaded
- if (ret < 0)
- {
- // Identify the error type
- switch (ret)
- {
- case SI_FAIL:
- SqThrow("Failed to load the INI data. Probably invalid");
- break;
- case SI_NOMEM:
- SqThrow("Ran out of memory while loading the INI data");
- break;
- default:
- SqThrow("Failed to load the INI data for some unforeseen reason");
- }
- }
-}
-
-// ------------------------------------------------------------------------------------------------
-void Document::SaveFile(CSStr filepath, bool signature)
-{
- if (!Validate())
- return; /* Unable to proceed */
- // Attempt to save the file to disk
- const SI_Error ret = m_Doc->SaveFile(filepath, signature);
- // See if the file could be saved
- if (ret == SI_FAIL)
- {
- SqThrow("Failed to save the INI file. Probably invalid");
- }
-}
-
-// ------------------------------------------------------------------------------------------------
-Object Document::SaveData(bool signature)
-{
- if (!Validate())
- return NullObject(); /* Unable to proceed */
- // The string where the content will be saved
- String source;
- // Attempt to save the data to string
- const SI_Error ret = m_Doc->Save(source, signature);
- // See if the data could be saved
- if (ret == SI_FAIL)
- {
- SqThrow("Failed to save the INI data. Probably invalid");
- return NullObject(); /* Unable to proceed */
- }
- // Transform it into a script object
- sq_pushstring(DefaultVM::Get(), source.c_str(), source.size());
- // Get the object from the stack
- Var< Object & > var(DefaultVM::Get(), -1);
- // Pop the created object from the stack
- if (!var.value.IsNull())
- {
- sq_pop(DefaultVM::Get(), 1);
- }
- // Return the script object
- return var.value;
-}
-
-// ------------------------------------------------------------------------------------------------
-Entries Document::GetAllSections() const
-{
- if (!Validate())
- return Entries(); /* Unable to proceed */
- // Prepare a container to receive the entries
- static Container entries;
- // Obtain all sections from the INI document
- m_Doc->GetAllSections(entries);
- // Return the entries and take over content
- return Entries(m_Doc, entries);
-}
-
-// ------------------------------------------------------------------------------------------------
-Entries Document::GetAllKeys(CSStr section) const
-{
- if (!Validate())
- return Entries(); /* Unable to proceed */
- // Prepare a container to receive the entries
- static Container entries;
- // Obtain all sections from the INI document
- m_Doc->GetAllKeys(section, entries);
- // Return the entries and take over content
- return Entries(m_Doc, entries);
-}
-
-// ------------------------------------------------------------------------------------------------
-Entries Document::GetAllValues(CSStr section, CSStr key) const
-{
- if (!Validate())
- return Entries(); /* Unable to proceed */
- // Prepare a container to receive the entries
- static Container entries;
- // Obtain all sections from the INI document
- m_Doc->GetAllValues(section, key, entries);
- // Return the entries and take over content
- return Entries(m_Doc, entries);
-}
-
-// ------------------------------------------------------------------------------------------------
-Int32 Document::GetSectionSize(CSStr section) const
-{
- if (Validate())
- // Return the requested information
- return m_Doc->GetSectionSize(section);
- // Return invalid size
- return -1;
-}
-
-// ------------------------------------------------------------------------------------------------
-bool Document::HasMultipleKeys(CSStr section, CSStr key) const
-{
- if (!Validate())
- return false; /* Unable to proceed */
- // Where to retrive whether the key has multiple instances
- bool multiple = false;
- // Attempt to query the information
- if (m_Doc->GetValue(section, key, NULL, &multiple) == NULL)
- return true; /* Doesn't exist */
- return multiple;
-}
-
-// ------------------------------------------------------------------------------------------------
-CCStr Document::GetValue(CSStr section, CSStr key, CSStr def) const
-{
- if (!Validate())
- return _SC(""); /* Unable to proceed */
- // Attempt to query the information and return it
- return m_Doc->GetValue(section, key, def, NULL);
-}
-
-// ------------------------------------------------------------------------------------------------
-SQInteger Document::GetInteger(CSStr section, CSStr key, SQInteger def) const
-{
- if (!Validate())
- return 0; /* Unable to proceed */
- // Attempt to query the information and return it
- return (SQInteger)m_Doc->GetLongValue(section, key, def, NULL);
-}
-
-// ------------------------------------------------------------------------------------------------
-SQFloat Document::GetFloat(CSStr section, CSStr key, SQFloat def) const
-{
- if (!Validate())
- return 0.0; /* Unable to proceed */
- // Attempt to query the information and return it
- return (SQFloat)m_Doc->GetDoubleValue(section, key, def, NULL);
-}
-
-// ------------------------------------------------------------------------------------------------
-bool Document::GetBoolean(CSStr section, CSStr key, bool def) const
-{
- if (!Validate())
- return false; /* Unable to proceed */
- // Attempt to query the information and return it
- return m_Doc->GetBoolValue(section, key, def, NULL);
-}
-
-// ------------------------------------------------------------------------------------------------
-void Document::SetValue(CSStr section, CSStr key, CSStr value, bool force, CSStr comment)
-{
- if (!Validate())
- return; /* Unable to proceed */
- // Attempt to apply the specified information
- const SI_Error ret = m_Doc->SetValue(section, key, value, comment, force);
- // See if the information could be applied
- if (ret < 0)
- {
- // Identify the error type
- switch (ret)
- {
- case SI_FAIL:
- SqThrow("Failed to set the INI value. Probably invalid");
- break;
- case SI_NOMEM:
- SqThrow("Ran out of memory while setting INI value");
- break;
- default:
- SqThrow("Failed to set the INI value for some unforeseen reason");
- }
- }
-}
-
-// ------------------------------------------------------------------------------------------------
-void Document::SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force, CSStr comment)
-{
- if (!Validate())
- return; /* Unable to proceed */
- // Attempt to apply the specified information
- const SI_Error ret = m_Doc->SetLongValue(section, key, value, comment, hex, force);
- // See if the information could be applied
- if (ret < 0)
- {
- // Identify the error type
- switch (ret)
- {
- case SI_FAIL:
- SqThrow("Failed to set the INI integer. Probably invalid");
- break;
- case SI_NOMEM:
- SqThrow("Ran out of memory while setting INI integer");
- break;
- default:
- SqThrow("Failed to set the INI integer for some unforeseen reason");
- }
- }
-}
-
-// ------------------------------------------------------------------------------------------------
-void Document::SetFloat(CSStr section, CSStr key, SQFloat value, bool force, CSStr comment)
-{
- if (!Validate())
- return; /* Unable to proceed */
- // Attempt to apply the specified information
- const SI_Error ret = m_Doc->SetDoubleValue(section, key, value, comment, force);
- // See if the information could be applied
- if (ret < 0)
- {
- // Identify the error type
- switch (ret)
- {
- case SI_FAIL:
- SqThrow("Failed to set the INI float. Probably invalid");
- break;
- case SI_NOMEM:
- SqThrow("Ran out of memory while setting INI float");
- break;
- default:
- SqThrow("Failed to set the INI float for some unforeseen reason");
- }
- }
-}
-
-// ------------------------------------------------------------------------------------------------
-void Document::SetBoolean(CSStr section, CSStr key, bool value, bool force, CSStr comment)
-{
- if (!Validate())
- return; /* Unable to proceed */
- // Attempt to apply the specified information
- const SI_Error ret = m_Doc->SetBoolValue(section, key, value, comment, force);
- // See if the information could be applied
- if (ret < 0)
- {
- // Identify the error type
- switch (ret)
- {
- case SI_FAIL:
- SqThrow("Failed to set the INI boolean. Probably invalid");
- break;
- case SI_NOMEM:
- SqThrow("Ran out of memory while setting INI boolean");
- break;
- default:
- SqThrow("Failed to set the INI boolean for some unforeseen reason");
- }
- }
-}
-
-// ------------------------------------------------------------------------------------------------
-bool Document::DeleteValue(CSStr section, CSStr key, CSStr value, bool empty)
-{
- if (!Validate())
- return false; /* Unable to proceed */
- else if (!section)
- {
- SqThrow("Invalid INI section");
- return false; /* Unable to proceed */
- }
- else if (!key)
- {
- SqThrow("Invalid INI key");
- return false; /* Unable to proceed */
- }
- // Attempt to remove the specified value
- return m_Doc->DeleteValue(section, key, value, empty);
-}
-
-} // Namespace:: INI
-
-// ================================================================================================
-void Register_INI(HSQUIRRELVM vm)
-{
- using namespace INI;
-
- Table inins(vm);
-
- inins.Bind(_SC("Entries"), Class< Entries >(vm, _SC("SqIniEntries"))
- /* Constructors */
- .Ctor()
- .Ctor< const Entries & >()
- /* Core Metamethods */
- .Func(_SC("_tostring"), &Entries::ToString)
- .Func(_SC("_cmp"), &Entries::Cmp)
- /* Properties */
- .Prop(_SC("Valid"), &Entries::IsValid)
- .Prop(_SC("Empty"), &Entries::IsEmpty)
- .Prop(_SC("References"), &Entries::GetRefCount)
- .Prop(_SC("Size"), &Entries::GetSize)
- .Prop(_SC("Item"), &Entries::GetItem)
- .Prop(_SC("Comment"), &Entries::GetComment)
- .Prop(_SC("Order"), &Entries::GetOrder)
- /* Functions */
- .Func(_SC("Reset"), &Entries::Reset)
- .Func(_SC("Next"), &Entries::Next)
- .Func(_SC("Prev"), &Entries::Prev)
- .Func(_SC("Advance"), &Entries::Advance)
- .Func(_SC("Retreat"), &Entries::Retreat)
- .Func(_SC("Sort"), &Entries::Sort)
- .Func(_SC("SortByKeyOrder"), &Entries::SortByKeyOrder)
- .Func(_SC("SortByLoadOrder"), &Entries::SortByLoadOrder)
- .Func(_SC("SortByLoadOrderEmptyFirst"), &Entries::SortByLoadOrderEmptyFirst)
- );
-
- inins.Bind(_SC("Document"), Class< Document, NoCopy< Document > >(vm, _SC("SqIniDocument"))
- /* Constructors */
- .Ctor()
- .Ctor< bool, bool, bool >()
- /* Core Metamethods */
- .Func(_SC("_tostring"), &Document::ToString)
- .Func(_SC("_cmp"), &Document::Cmp)
- /* Properties */
- .Prop(_SC("Valid"), &Document::IsValid)
- .Prop(_SC("Empty"), &Document::IsEmpty)
- .Prop(_SC("References"), &Document::GetRefCount)
- .Prop(_SC("Unicode"), &Document::GetUnicode, &Document::SetUnicode)
- .Prop(_SC("MultiKey"), &Document::GetMultiKey, &Document::SetMultiKey)
- .Prop(_SC("MultiLine"), &Document::GetMultiLine, &Document::SetMultiLine)
- .Prop(_SC("Spaces"), &Document::GetSpaces, &Document::SetSpaces)
- /* Functions */
- .Func(_SC("Reset"), &Document::Reset)
- .Func(_SC("LoadFile"), &Document::LoadFile)
- .Overload< void (Document::*)(CSStr) >(_SC("LoadData"), &Document::LoadData)
- .Overload< void (Document::*)(CSStr, Int32) >(_SC("LoadData"), &Document::LoadData)
- .Overload< void (Document::*)(CSStr) >(_SC("SaveFile"), &Document::SaveFile)
- .Overload< void (Document::*)(CSStr, bool) >(_SC("SaveFile"), &Document::SaveFile)
- .Func(_SC("SaveData"), &Document::SaveData)
- .Func(_SC("GetSections"), &Document::GetAllSections)
- .Func(_SC("GetKeys"), &Document::GetAllKeys)
- .Func(_SC("GetValues"), &Document::GetAllValues)
- .Func(_SC("GetSectionSize"), &Document::GetSectionSize)
- .Func(_SC("HasMultipleKeys"), &Document::HasMultipleKeys)
- .Func(_SC("GetValue"), &Document::GetValue)
- .Func(_SC("GetInteger"), &Document::GetInteger)
- .Func(_SC("GetFloat"), &Document::GetFloat)
- .Func(_SC("GetBoolean"), &Document::GetBoolean)
- .Overload< void (Document::*)(CSStr, CSStr, CSStr) >(_SC("SetValue"), &Document::SetValue)
- .Overload< void (Document::*)(CSStr, CSStr, CSStr, bool) >(_SC("SetValue"), &Document::SetValue)
- .Overload< void (Document::*)(CSStr, CSStr, CSStr, bool, CSStr) >(_SC("SetValue"), &Document::SetValue)
- .Overload< void (Document::*)(CSStr, CSStr, SQInteger) >(_SC("SetInteger"), &Document::SetInteger)
- .Overload< void (Document::*)(CSStr, CSStr, SQInteger, bool) >(_SC("SetInteger"), &Document::SetInteger)
- .Overload< void (Document::*)(CSStr, CSStr, SQInteger, bool, bool) >(_SC("SetInteger"), &Document::SetInteger)
- .Overload< void (Document::*)(CSStr, CSStr, SQInteger, bool, bool, CSStr) >(_SC("SetInteger"), &Document::SetInteger)
- .Overload< void (Document::*)(CSStr, CSStr, SQFloat) >(_SC("SetFloat"), &Document::SetFloat)
- .Overload< void (Document::*)(CSStr, CSStr, SQFloat, bool) >(_SC("SetFloat"), &Document::SetFloat)
- .Overload< void (Document::*)(CSStr, CSStr, SQFloat, bool, CSStr) >(_SC("SetFloat"), &Document::SetFloat)
- .Overload< void (Document::*)(CSStr, CSStr, bool) >(_SC("SetBoolean"), &Document::SetBoolean)
- .Overload< void (Document::*)(CSStr, CSStr, bool, bool) >(_SC("SetBoolean"), &Document::SetBoolean)
- .Overload< void (Document::*)(CSStr, CSStr, bool, bool, CSStr) >(_SC("SetBoolean"), &Document::SetBoolean)
- .Overload< bool (Document::*)(CSStr) >(_SC("DeleteValue"), &Document::DeleteValue)
- .Overload< bool (Document::*)(CSStr, CSStr) >(_SC("DeleteValue"), &Document::DeleteValue)
- .Overload< bool (Document::*)(CSStr, CSStr, CSStr) >(_SC("DeleteValue"), &Document::DeleteValue)
- .Overload< bool (Document::*)(CSStr, CSStr, CSStr, bool) >(_SC("DeleteValue"), &Document::DeleteValue)
- );
-
- RootTable(vm).Bind(_SC("SqIni"), inins);
-}
-
-} // Namespace:: SqMod
diff --git a/source/Library/INI.hpp b/source/Library/INI.hpp
deleted file mode 100644
index 12e31eaa..00000000
--- a/source/Library/INI.hpp
+++ /dev/null
@@ -1,736 +0,0 @@
-#ifndef _LIBRARY_INI_HPP_
-#define _LIBRARY_INI_HPP_
-
-// ------------------------------------------------------------------------------------------------
-#include "Base/Shared.hpp"
-
-// ------------------------------------------------------------------------------------------------
-#include
-
-// ------------------------------------------------------------------------------------------------
-namespace SqMod {
-namespace INI {
-
-// ------------------------------------------------------------------------------------------------
-class Entries;
-class Document;
-
-/* ------------------------------------------------------------------------------------------------
- * Manages a reference counted INI document instance.
-*/
-class DocumentRef
-{
- // --------------------------------------------------------------------------------------------
- friend class Document;
-
-private:
-
- // --------------------------------------------------------------------------------------------
- typedef CSimpleIniA IrcDocument;
-
- // --------------------------------------------------------------------------------------------
- typedef unsigned int Counter;
-
- // --------------------------------------------------------------------------------------------
- IrcDocument* m_Ptr; /* The document reader, writer and manager instance. */
- Counter* m_Ref; /* Reference count to the managed instance. */
-
- /* --------------------------------------------------------------------------------------------
- * Grab a strong reference to a document instance.
- */
- void Grab()
- {
- if (m_Ptr)
- {
- ++(*m_Ref);
- }
- }
-
- /* --------------------------------------------------------------------------------------------
- * Drop a strong reference to a document instance.
- */
- void Drop()
- {
- if (m_Ptr && --(*m_Ref) == 0)
- {
- delete m_Ptr;
- delete m_Ref;
- m_Ptr = NULL;
- m_Ref = NULL;
- }
- }
-
- /* --------------------------------------------------------------------------------------------
- * Base constructor.
- */
- DocumentRef(bool utf8, bool multikey, bool multiline)
- : m_Ptr(new IrcDocument(utf8, multikey, multiline)), m_Ref(new Counter(1))
- {
- /* ... */
- }
-
-public:
-
- /* --------------------------------------------------------------------------------------------
- * Default constructor (null).
- */
- DocumentRef()
- : m_Ptr(NULL), m_Ref(NULL)
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy constructor.
- */
- DocumentRef(const DocumentRef & o)
- : m_Ptr(o.m_Ptr), m_Ref(o.m_Ref)
-
- {
- Grab();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Destructor.
- */
- ~DocumentRef()
- {
- Drop();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy assignment operator.
- */
- DocumentRef & operator = (const DocumentRef & o)
- {
- if (m_Ptr != o.m_Ptr)
- {
- Drop();
- m_Ptr = o.m_Ptr;
- m_Ref = o.m_Ref;
- Grab();
- }
- return *this;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Perform an equality comparison between two document instances.
- */
- bool operator == (const DocumentRef & o) const
- {
- return (m_Ptr == o.m_Ptr);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Perform an inequality comparison between two document instances.
- */
- bool operator != (const DocumentRef & o) const
- {
- return (m_Ptr != o.m_Ptr);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Implicit conversion to boolean for use in boolean operations.
- */
- operator bool () const
- {
- return m_Ptr;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Member operator for dereferencing the managed pointer.
- */
- IrcDocument * operator -> () const
- {
- assert(m_Ptr != NULL);
- return m_Ptr;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Indirection operator for obtaining a reference of the managed pointer.
- */
- IrcDocument & operator * () const
- {
- assert(m_Ptr != NULL);
- return *m_Ptr;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the number of active references to the managed instance.
- */
- Counter Count() const
- {
- return (m_Ptr && m_Ref) ? (*m_Ref) : 0;
- }
-
-};
-
-/* ------------------------------------------------------------------------------------------------
- * Class that can access and iterate a series of entries in the INI document.
-*/
-class Entries
-{
- // --------------------------------------------------------------------------------------------
- friend class Document;
-
-protected:
-
- // --------------------------------------------------------------------------------------------
- typedef CSimpleIniA IrcDocument;
-
- // --------------------------------------------------------------------------------------------
- typedef IrcDocument::TNamesDepend Container;
-
- // --------------------------------------------------------------------------------------------
- typedef Container::iterator Iterator;
-
- /* --------------------------------------------------------------------------------------------
- * Default constructor.
- */
- Entries(const DocumentRef & ini, Container & list)
- : m_Doc(ini), m_List(), m_Elem()
- {
- m_List.swap(list);
- Reset();
- }
-
-private:
-
- // ---------------------------------------------------------------------------------------------
- DocumentRef m_Doc; /* The document that contains the elements. */
- Container m_List; /* The list of elements to iterate. */
- Iterator m_Elem; /* The currently processed element. */
-
-public:
-
- /* --------------------------------------------------------------------------------------------
- * Default constructor. (null)
- */
- Entries()
- : m_Doc(), m_List(), m_Elem(m_List.end())
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy constructor.
- */
- Entries(const Entries & o)
- : m_Doc(o.m_Doc), m_List(o.m_List), m_Elem()
- {
- Reset();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Destructor.
- */
- ~Entries()
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy assignment operator.
- */
- Entries & operator = (const Entries & o)
- {
- m_Doc = o.m_Doc;
- m_List = o.m_List;
- Reset();
- return *this;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to compare two instances of this type.
- */
- Int32 Cmp(const Entries & o) const;
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to convert an instance of this type to a string.
- */
- CSStr ToString() const;
-
- /* --------------------------------------------------------------------------------------------
- * Return whether the current element is valid and can be accessed.
- */
- bool IsValid() const
- {
- return !(m_List.empty() || m_Elem == m_List.end());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Return whether the entry list is empty.
- */
- bool IsEmpty() const
- {
- return m_List.empty();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Return the number of active references to this document instance.
- */
- Uint32 GetRefCount() const
- {
- return m_Doc.Count();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Return the total entries in the list.
- */
- Int32 GetSize() const
- {
- return (Int32)m_List.size();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Reset the internal iterator to the first element.
- */
- void Reset()
- {
- if (m_List.empty())
- m_Elem = m_List.end();
- else
- m_Elem = m_List.begin();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Go to the next element.
- */
- void Next();
-
- /* --------------------------------------------------------------------------------------------
- * Go to the previous element.
- */
- void Prev();
-
- /* --------------------------------------------------------------------------------------------
- * Advance a certain number of elements.
- */
- void Advance(Int32 n);
-
- /* --------------------------------------------------------------------------------------------
- * Retreat a certain number of elements.
- */
- void Retreat(Int32 n);
-
- /* --------------------------------------------------------------------------------------------
- * Sort the entries using the default options.
- */
- void Sort()
- {
- if (!m_List.empty())
- m_List.sort(IrcDocument::Entry::KeyOrder());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Sort the entries by name of key only.
- */
- void SortByKeyOrder()
- {
- if (!m_List.empty())
- m_List.sort(IrcDocument::Entry::KeyOrder());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Sort the entries by their load order and then name of key.
- */
- void SortByLoadOrder()
- {
- if (!m_List.empty())
- m_List.sort(IrcDocument::Entry::LoadOrder());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Sort the entries by their load order but empty name always goes first.
- */
- void SortByLoadOrderEmptyFirst()
- {
- if (!m_List.empty())
- m_List.sort(IrcDocument::Entry::LoadOrderEmptyFirst());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the string value of the current element item.
- */
- CSStr GetItem() const;
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the string value of the current element comment.
- */
- CSStr GetComment() const;
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the order of the current element.
- */
- Int32 GetOrder() const;
-};
-
-/* ------------------------------------------------------------------------------------------------
- * Class that can read/write and alter the contents of INI files.
-*/
-class Document
-{
-protected:
-
- // --------------------------------------------------------------------------------------------
- typedef CSimpleIniA IrcDocument;
-
- // --------------------------------------------------------------------------------------------
- typedef IrcDocument::TNamesDepend Container;
-
- /* --------------------------------------------------------------------------------------------
- * Copy constructor. (disabled)
- */
- Document(const Document & o);
-
- /* --------------------------------------------------------------------------------------------
- * Copy assignment operator. (disabled)
- */
- Document & operator = (const Document & o);
-
- /* --------------------------------------------------------------------------------------------
- * Validate the document reference.
- */
- bool Validate() const
- {
- if (m_Doc)
- return true;
- SqThrow("Invalid INI document reference");
- return false;
- }
-
-private:
-
- // ---------------------------------------------------------------------------------------------
- DocumentRef m_Doc; /* The main INI document instance. */
-
-public:
-
- /* --------------------------------------------------------------------------------------------
- * Default constructor.
- */
- Document();
-
- /* --------------------------------------------------------------------------------------------
- * Explicit constructor.
- */
- Document(bool utf8, bool multikey, bool multiline);
-
- /* --------------------------------------------------------------------------------------------
- * Destructor.
- */
- ~Document();
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to compare two instances of this type.
- */
- Int32 Cmp(const Document & o) const;
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to convert an instance of this type to a string.
- */
- CSStr ToString() const;
-
- /* --------------------------------------------------------------------------------------------
- * See whether this instance references a valid INI document.
- */
- bool IsValid() const
- {
- return m_Doc;
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether any data has been loaded into this document.
- */
- bool IsEmpty() const
- {
- return m_Doc->IsEmpty();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Return the number of active references to this document instance.
- */
- Uint32 GetRefCount() const
- {
- return m_Doc.Count();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Deallocate all memory stored by this document.
- */
- void Reset() const
- {
- m_Doc->Reset();
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether the INI data is treated as unicode.
- */
- bool GetUnicode() const
- {
- return m_Doc->IsUnicode();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Set whether the INI data should be treated as unicode.
- */
- void SetUnicode(bool toggle)
- {
- m_Doc->SetUnicode(toggle);
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether multiple identical keys be permitted in the file.
- */
- bool GetMultiKey() const
- {
- return m_Doc->IsMultiKey();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Set whether multiple identical keys be permitted in the file.
- */
- void SetMultiKey(bool toggle)
- {
- m_Doc->SetMultiKey(toggle);
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether data values are permitted to span multiple lines in the file.
- */
- bool GetMultiLine() const
- {
- return m_Doc->IsMultiLine();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Set whether data values are permitted to span multiple lines in the file.
- */
- void SetMultiLine(bool toggle)
- {
- m_Doc->SetMultiLine(toggle);
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether spaces are added around the equals sign when writing key/value pairs out.
- */
- bool GetSpaces() const
- {
- return m_Doc->UsingSpaces();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Set whether spaces are added around the equals sign when writing key/value pairs out.
- */
- void SetSpaces(bool toggle)
- {
- m_Doc->SetSpaces(toggle);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Load an INI file from disk into memory.
- */
- void LoadFile(CSStr filepath);
-
- /* --------------------------------------------------------------------------------------------
- * Load INI file data direct from a string.
- */
- void LoadData(CSStr source)
- {
- LoadData(source, -1);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Load INI file data direct from a string.
- */
- void LoadData(CSStr source, Int32 size);
-
- /* --------------------------------------------------------------------------------------------
- * Save an INI file from memory to disk.
- */
- void SaveFile(CSStr filepath)
- {
- SaveFile(filepath, true);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Save an INI file from memory to disk.
- */
- void SaveFile(CSStr filepath, bool signature);
-
- /* --------------------------------------------------------------------------------------------
- * Save the INI data to a string.
- */
- Object SaveData(bool signature);
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve all section names.
- */
- Entries GetAllSections() const;
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve all unique key names in a section.
- */
- Entries GetAllKeys(CSStr section) const;
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve all values for a specific key.
- */
- Entries GetAllValues(CSStr section, CSStr key) const;
-
- /* --------------------------------------------------------------------------------------------
- * Query the number of keys in a specific section.
- */
- Int32 GetSectionSize(CSStr section) const;
-
- /* --------------------------------------------------------------------------------------------
- * See whether a certain key has multiple instances.
- */
- bool HasMultipleKeys(CSStr section, CSStr key) const;
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value for a specific key.
- */
- CCStr GetValue(CSStr section, CSStr key, CSStr def) const;
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve a numeric value for a specific key.
- */
- SQInteger GetInteger(CSStr section, CSStr key, SQInteger def) const;
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve a numeric value for a specific key.
- */
- SQFloat GetFloat(CSStr section, CSStr key, SQFloat def) const;
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve a boolean value for a specific key.
- */
- bool GetBoolean(CSStr section, CSStr key, bool def) const;
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a section or value.
- */
- void SetValue(CSStr section, CSStr key, CSStr value)
- {
- SetValue(section, key, value, false, NULL);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a section or value.
- */
- void SetValue(CSStr section, CSStr key, CSStr value, bool force)
- {
- SetValue(section, key, value, force, NULL);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a section or value.
- */
- void SetValue(CSStr section, CSStr key, CSStr value, bool force, CSStr comment);
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a numeric value.
- */
- void SetInteger(CSStr section, CSStr key, SQInteger value)
- {
- SetInteger(section, key, value, false, false, NULL);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a numeric value.
- */
- void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex)
- {
- SetInteger(section, key, value, hex, false, NULL);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a numeric value.
- */
- void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force)
- {
- SetInteger(section, key, value, hex, force, NULL);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a numeric value.
- */
- void SetInteger(CSStr section, CSStr key, SQInteger value, bool hex, bool force, CSStr comment);
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a double value.
- */
- void SetFloat(CSStr section, CSStr key, SQFloat value)
- {
- SetFloat(section, key, value, false, NULL);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a double value.
- */
- void SetFloat(CSStr section, CSStr key, SQFloat value, bool force)
- {
- SetFloat(section, key, value, force, NULL);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a double value.
- */
- void SetFloat(CSStr section, CSStr key, SQFloat value, bool force, CSStr comment);
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a double value.
- */
- void SetBoolean(CSStr section, CSStr key, bool value)
- {
- SetBoolean(section, key, value, false, NULL);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a double value.
- */
- void SetBoolean(CSStr section, CSStr key, bool value, bool force)
- {
- SetBoolean(section, key, value, force, NULL);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Add or update a boolean value.
- */
- void SetBoolean(CSStr section, CSStr key, bool value, bool force, CSStr comment);
-
- /* --------------------------------------------------------------------------------------------
- * Delete an entire section, or a key from a section.
- */
- bool DeleteValue(CSStr section)
- {
- return DeleteValue(section, NULL, NULL, false);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Delete an entire section, or a key from a section.
- */
- bool DeleteValue(CSStr section, CSStr key)
- {
- return DeleteValue(section, key, NULL, false);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Delete an entire section, or a key from a section.
- */
- bool DeleteValue(CSStr section, CSStr key, CSStr value)
- {
- return DeleteValue(section, key, value, false);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Delete an entire section, or a key from a section.
- */
- bool DeleteValue(CSStr section, CSStr key, CSStr value, bool empty);
-};
-
-} // Namespace:: INI
-} // Namespace:: SqMod
-
-#endif // _LIBRARY_INI_HPP_
diff --git a/source/Library/Numeric.cpp b/source/Library/Numeric.cpp
index 02e552bb..1491fdc8 100644
--- a/source/Library/Numeric.cpp
+++ b/source/Library/Numeric.cpp
@@ -78,15 +78,22 @@ void Register_Numeric(HSQUIRRELVM vm)
/* Properties */
.Prop(_SC("Str"), &SLongInt::GetCStr, &SLongInt::SetStr)
.Prop(_SC("Num"), &SLongInt::GetSNum, &SLongInt::SetNum)
- /* Metamethods */
+ /* Core Metamethods */
.Func(_SC("_tostring"), &SLongInt::ToString)
+ .Func(_SC("_typename"), &SLongInt::Typename)
.Func(_SC("_cmp"), &SLongInt::Cmp)
+ /* Metamethods */
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_add"), &SLongInt::operator +)
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_sub"), &SLongInt::operator -)
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_mul"), &SLongInt::operator *)
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_div"), &SLongInt::operator /)
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_modulo"), &SLongInt::operator %)
.Func< SLongInt (SLongInt::*)(void) const >(_SC("_unm"), &SLongInt::operator -)
+ /* Functions */
+ .Func(_SC("GetStr"), &SLongInt::GetCStr)
+ .Func(_SC("SetStr"), &SLongInt::SetStr)
+ .Func(_SC("GetNum"), &SLongInt::GetSNum)
+ .Func(_SC("SetNum"), &SLongInt::SetNum)
/* Overloads */
.Overload< void (SLongInt::*)(void) >(_SC("Random"), &SLongInt::Random)
.Overload< void (SLongInt::*)(SLongInt::Type) >(_SC("Random"), &SLongInt::Random)
@@ -101,15 +108,22 @@ void Register_Numeric(HSQUIRRELVM vm)
/* Properties */
.Prop(_SC("Str"), &ULongInt::GetCStr, &ULongInt::SetStr)
.Prop(_SC("Num"), &ULongInt::GetSNum, &ULongInt::SetNum)
- /* Metamethods */
+ /* Core Metamethods */
.Func(_SC("_tostring"), &ULongInt::ToString)
+ .Func(_SC("_typename"), &ULongInt::Typename)
.Func(_SC("_cmp"), &ULongInt::Cmp)
+ /* Metamethods */
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_add"), &ULongInt::operator +)
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_sub"), &ULongInt::operator -)
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_mul"), &ULongInt::operator *)
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_div"), &ULongInt::operator /)
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_modulo"), &ULongInt::operator %)
.Func< ULongInt (ULongInt::*)(void) const >(_SC("_unm"), &ULongInt::operator -)
+ /* Functions */
+ .Func(_SC("GetStr"), &ULongInt::GetCStr)
+ .Func(_SC("SetStr"), &ULongInt::SetStr)
+ .Func(_SC("GetNum"), &ULongInt::GetSNum)
+ .Func(_SC("SetNum"), &ULongInt::SetNum)
/* Overloads */
.Overload< void (ULongInt::*)(void) >(_SC("Random"), &ULongInt::Random)
.Overload< void (ULongInt::*)(ULongInt::Type) >(_SC("Random"), &ULongInt::Random)
diff --git a/source/Library/Numeric.hpp b/source/Library/Numeric.hpp
index 1da83af6..68c3cbe1 100644
--- a/source/Library/Numeric.hpp
+++ b/source/Library/Numeric.hpp
@@ -173,6 +173,14 @@ public:
*/
CSStr ToString();
+ /* --------------------------------------------------------------------------------------------
+ *
+ */
+ CSStr Typename() const
+ {
+ return _SC("SLongInt");
+ }
+
/* --------------------------------------------------------------------------------------------
*
*/
@@ -384,6 +392,14 @@ public:
*/
CSStr ToString();
+ /* --------------------------------------------------------------------------------------------
+ *
+ */
+ CSStr Typename() const
+ {
+ return _SC("ULongInt");
+ }
+
/* --------------------------------------------------------------------------------------------
*
*/
diff --git a/source/Library/Random.cpp b/source/Library/Random.cpp
index e812addf..298773e6 100644
--- a/source/Library/Random.cpp
+++ b/source/Library/Random.cpp
@@ -307,7 +307,7 @@ static CSStr RandomString(Int32 len, SQChar n)
}
Buffer b(len+1);
SStr s = b.Get< SQChar >();
- for (Int32 n = 0; n <= len; ++n, ++s)
+ for (Int32 i = 0; i <= len; ++i, ++s)
{
*s = g_RGen.Integer< SQChar >(n);
}
@@ -324,7 +324,7 @@ static CSStr RandomString(Int32 len, SQChar m, SQChar n)
}
Buffer b(len+1);
SStr s = b.Get< SQChar >();
- for (Int32 n = 0; n <= len; ++n, ++s)
+ for (Int32 i = 0; i <= len; ++i, ++s)
{
*s = g_RGen.IntegerC< SQChar >(m, n);
}
diff --git a/source/Library/Time.hpp b/source/Library/Time.hpp
index 32d75592..a7a4ff16 100644
--- a/source/Library/Time.hpp
+++ b/source/Library/Time.hpp
@@ -131,6 +131,14 @@ public:
*/
void SetNow();
+ /* --------------------------------------------------------------------------------------------
+ *
+ */
+ Int64 GetNum() const
+ {
+ return m_Timestamp;
+ }
+
/* --------------------------------------------------------------------------------------------
*
*/
diff --git a/source/Library/Utils.hpp b/source/Library/Utils.hpp
index e69de29b..df106feb 100644
--- a/source/Library/Utils.hpp
+++ b/source/Library/Utils.hpp
@@ -0,0 +1,41 @@
+#ifndef _LIBRARY_UTILS_HPP_
+#define _LIBRARY_UTILS_HPP_
+
+// ------------------------------------------------------------------------------------------------
+#include "Base/Shared.hpp"
+
+// ------------------------------------------------------------------------------------------------
+namespace SqMod {
+
+/* ------------------------------------------------------------------------------------------------
+ *
+*/
+class Blob
+{
+ /* --------------------------------------------------------------------------------------------
+ *
+ */
+ Blob(const Blob &);
+
+ /* --------------------------------------------------------------------------------------------
+ *
+ */
+ Blob & operator = (const Blob &);
+
+public:
+
+ /* --------------------------------------------------------------------------------------------
+ *
+ */
+ Blob();
+
+ /* --------------------------------------------------------------------------------------------
+ *
+ */
+ ~Blob();
+
+};
+
+} // Namespace:: SqMod
+
+#endif // _LIBRARY_UTILS_HPP_
\ No newline at end of file
diff --git a/source/Library/XML.cpp b/source/Library/XML.cpp
deleted file mode 100644
index 4212b0d7..00000000
--- a/source/Library/XML.cpp
+++ /dev/null
@@ -1,325 +0,0 @@
-// ------------------------------------------------------------------------------------------------
-#include "Library/XML.hpp"
-
-// ------------------------------------------------------------------------------------------------
-namespace SqMod {
-namespace XML {
-
-// ------------------------------------------------------------------------------------------------
-void XmlParseResult::Check() const
-{
- if (m_Result.status != status_ok)
- SqThrow("Xml parse error [%s]", m_Result.description());
-}
-
-// ------------------------------------------------------------------------------------------------
-XmlNode XmlText::GetData() const
-{
- return XmlNode(m_Doc, m_Text.data());
-}
-
-// ------------------------------------------------------------------------------------------------
-XmlNode XmlDocument::GetNode() const
-{
- if (m_Doc)
- return XmlNode(m_Doc, m_Doc->document_element());
- return XmlNode();
-}
-
-} // Namespace:: XML
-
-// ================================================================================================
-void Register_XML(HSQUIRRELVM vm)
-{
- using namespace XML;
-
- Table xmlns(vm);
-
- xmlns.Bind(_SC("ParseResult"), Class< XmlParseResult >(vm, _SC("SqXmlParseResult"))
- /* Constructors */
- .Ctor()
- .Ctor< const XmlParseResult & >()
- /* Core Metamethods */
- .Func(_SC("_cmp"), &XmlParseResult::Cmp)
- .Func(_SC("_tostring"), &XmlParseResult::ToString)
- /* Properties */
- .Prop(_SC("Valid"), &XmlParseResult::IsValid)
- .Prop(_SC("References"), &XmlParseResult::GetRefCount)
- .Prop(_SC("Ok"), &XmlParseResult::IsOk)
- .Prop(_SC("Status"), &XmlParseResult::GetStatus)
- .Prop(_SC("Offset"), &XmlParseResult::GetOffset)
- .Prop(_SC("Encoding"), &XmlParseResult::GetEncoding)
- .Prop(_SC("Description"), &XmlParseResult::GetDescription)
- /* Functions */
- .Func(_SC("Check"), &XmlParseResult::Check)
- );
-
- xmlns.Bind(_SC("Attribute"), Class< XmlAttribute >(vm, _SC("SqXmlAttribute"))
- /* Constructors */
- .Ctor()
- .Ctor< const XmlAttribute & >()
- /* Core Metamethods */
- .Func(_SC("_cmp"), &XmlAttribute::Cmp)
- .Func(_SC("_tostring"), &XmlAttribute::ToString)
- /* Properties */
- .Prop(_SC("Valid"), &XmlAttribute::IsValid)
- .Prop(_SC("References"), &XmlAttribute::GetRefCount)
- .Prop(_SC("Empty"), &XmlAttribute::IsEmpty)
- .Prop(_SC("Hash"), &XmlAttribute::GetHashValue)
- .Prop(_SC("Name"), &XmlAttribute::GetName, &XmlAttribute::SetName)
- .Prop(_SC("Value"), &XmlAttribute::GetValue, &XmlAttribute::SetValue)
- .Prop(_SC("Int"), &XmlAttribute::GetInt, &XmlAttribute::SetInt)
- .Prop(_SC("Uint"), &XmlAttribute::GetUint, &XmlAttribute::SetUint)
- .Prop(_SC("Float"), &XmlAttribute::GetFloat, &XmlAttribute::SetFloat)
- .Prop(_SC("Double"), &XmlAttribute::GetDouble, &XmlAttribute::SetDouble)
- .Prop(_SC("Long"), &XmlAttribute::GetLong, &XmlAttribute::SetLong)
- .Prop(_SC("Ulong"), &XmlAttribute::GetUlong, &XmlAttribute::SetUlong)
- .Prop(_SC("Bool"), &XmlAttribute::GetBool, &XmlAttribute::SetBool)
- .Prop(_SC("Next"), &XmlAttribute::NextAttribute)
- .Prop(_SC("Prev"), &XmlAttribute::PrevAttribute)
- /* Functions */
- .Func(_SC("SetName"), &XmlAttribute::ApplyName)
- .Func(_SC("SetValue"), &XmlAttribute::ApplyValue)
- .Func(_SC("AsString"), &XmlAttribute::AsString)
- .Func(_SC("AsInt"), &XmlAttribute::AsInt)
- .Func(_SC("AsUint"), &XmlAttribute::AsUint)
- .Func(_SC("AsFloat"), &XmlAttribute::AsFloat)
- .Func(_SC("AsDouble"), &XmlAttribute::AsDouble)
- .Func(_SC("AsLong"), &XmlAttribute::AsLong)
- .Func(_SC("AsUlong"), &XmlAttribute::AsUlong)
- .Func(_SC("AsBool"), &XmlAttribute::AsBool)
- .Func(_SC("SetString"), &XmlAttribute::ApplyString)
- .Func(_SC("SetInt"), &XmlAttribute::ApplyInt)
- .Func(_SC("SetUint"), &XmlAttribute::ApplyUint)
- .Func(_SC("SetFloat"), &XmlAttribute::ApplyFloat)
- .Func(_SC("SetDouble"), &XmlAttribute::ApplyDouble)
- .Func(_SC("SetLong"), &XmlAttribute::ApplyLong)
- .Func(_SC("SetUlong"), &XmlAttribute::ApplyUlong)
- .Func(_SC("SetBool"), &XmlAttribute::ApplyBool)
- );
-
- xmlns.Bind(_SC("Text"), Class< XmlText >(vm, _SC("SqXmlText"))
- /* Constructors */
- .Ctor()
- .Ctor< const XmlText & >()
- /* Core Metamethods */
- .Func(_SC("_cmp"), &XmlText::Cmp)
- .Func(_SC("_tostring"), &XmlText::ToString)
- /* Properties */
- .Prop(_SC("Valid"), &XmlText::IsValid)
- .Prop(_SC("References"), &XmlText::GetRefCount)
- .Prop(_SC("Empty"), &XmlText::IsEmpty)
- .Prop(_SC("Value"), &XmlText::GetValue)
- .Prop(_SC("Int"), &XmlText::GetInt, &XmlText::SetInt)
- .Prop(_SC("Uint"), &XmlText::GetUint, &XmlText::SetUint)
- .Prop(_SC("Float"), &XmlText::GetFloat, &XmlText::SetFloat)
- .Prop(_SC("Double"), &XmlText::GetDouble, &XmlText::SetDouble)
- .Prop(_SC("Long"), &XmlText::GetLong, &XmlText::SetLong)
- .Prop(_SC("Ulong"), &XmlText::GetUlong, &XmlText::SetUlong)
- .Prop(_SC("Bool"), &XmlText::GetBool, &XmlText::SetBool)
- .Prop(_SC("Data"), &XmlText::GetData)
- /* Functions */
- .Func(_SC("AsString"), &XmlText::AsString)
- .Func(_SC("AsInt"), &XmlText::AsInt)
- .Func(_SC("AsUint"), &XmlText::AsUint)
- .Func(_SC("AsFloat"), &XmlText::AsFloat)
- .Func(_SC("AsDouble"), &XmlText::AsDouble)
- .Func(_SC("AsLong"), &XmlText::AsLong)
- .Func(_SC("AsUlong"), &XmlText::AsUlong)
- .Func(_SC("AsBool"), &XmlText::AsBool)
- .Func(_SC("SetString"), &XmlText::ApplyString)
- .Func(_SC("SetInt"), &XmlText::ApplyInt)
- .Func(_SC("SetUint"), &XmlText::ApplyUint)
- .Func(_SC("SetFloat"), &XmlText::ApplyFloat)
- .Func(_SC("SetDouble"), &XmlText::ApplyDouble)
- .Func(_SC("SetLong"), &XmlText::ApplyLong)
- .Func(_SC("SetUlong"), &XmlText::ApplyUlong)
- .Func(_SC("SetBool"), &XmlText::ApplyBool)
- );
-
- xmlns.Bind(_SC("Node"), Class< XmlNode >(vm, _SC("SqXmlNode"))
- /* Constructors */
- .Ctor()
- .Ctor< const XmlNode & >()
- /* Core Metamethods */
- .Func(_SC("_cmp"), &XmlNode::Cmp)
- .Func(_SC("_tostring"), &XmlNode::ToString)
- /* Properties */
- .Prop(_SC("Valid"), &XmlNode::IsValid)
- .Prop(_SC("References"), &XmlNode::GetRefCount)
- .Prop(_SC("Empty"), &XmlNode::IsEmpty)
- .Prop(_SC("Hash"), &XmlNode::GetHashValue)
- .Prop(_SC("OffsetDebug"), &XmlNode::GetOffsetDebug)
- .Prop(_SC("Type"), &XmlNode::GetType)
- .Prop(_SC("Name"), &XmlNode::GetName, &XmlNode::SetName)
- .Prop(_SC("Value"), &XmlNode::GetValue, &XmlNode::SetValue)
- .Prop(_SC("FirstAttr"), &XmlNode::GetFirstAttr)
- .Prop(_SC("LastAttr"), &XmlNode::GetLastAttr)
- .Prop(_SC("FirstChild"), &XmlNode::GetFirstChild)
- .Prop(_SC("LastChild"), &XmlNode::GetLastChild)
- .Prop(_SC("NextSibling"), &XmlNode::GetNextSibling)
- .Prop(_SC("PrevSibling"), &XmlNode::GetPrevSibling)
- .Prop(_SC("Parent"), &XmlNode::GetParent)
- .Prop(_SC("Root"), &XmlNode::GetRoot)
- .Prop(_SC("Text"), &XmlNode::GetText)
- .Prop(_SC("ChildValue"), &XmlNode::GetChildValue)
- /* Functions */
- .Overload< XmlParseResult (XmlNode::*)(CSStr) >(_SC("AppendBuffer"), &XmlNode::AppendBuffer)
- .Overload< XmlParseResult (XmlNode::*)(CSStr, Uint32) >(_SC("AppendBuffer"), &XmlNode::AppendBuffer)
- .Overload< XmlParseResult (XmlNode::*)(CSStr, Uint32, Int32) >(_SC("AppendBuffer"), &XmlNode::AppendBuffer)
- .Func(_SC("SetName"), &XmlNode::ApplyName)
- .Func(_SC("SetValue"), &XmlNode::ApplyValue)
- .Func(_SC("GetChild"), &XmlNode::Child)
- .Func(_SC("GetAttr"), &XmlNode::Attribute)
- .Func(_SC("GetAttribute"), &XmlNode::Attribute)
- .Func(_SC("GetAttrFrom"), &XmlNode::AttributeFrom)
- .Func(_SC("GetAttributeFrom"), &XmlNode::AttributeFrom)
- .Func(_SC("GetNextSibling"), &XmlNode::NextSibling)
- .Func(_SC("GetPrevSibling"), &XmlNode::PrevSibling)
- .Func(_SC("GetChildValue"), &XmlNode::ChildValue)
- .Func(_SC("AppendAttr"), &XmlNode::AppendAttr)
- .Func(_SC("PrependAttr"), &XmlNode::PrependAttr)
- .Func(_SC("InsertAttrAfter"), &XmlNode::InsertAttrAfter)
- .Func(_SC("InsertAttrBefore"), &XmlNode::InsertAttrBefore)
- .Func(_SC("AppendAttrCopy"), &XmlNode::AppendAttrCopy)
- .Func(_SC("PrependAttrCopy"), &XmlNode::PrependAttrCopy)
- .Func(_SC("InsertAttrCopyAfter"), &XmlNode::InsertAttrCopyAfter)
- .Func(_SC("InsertAttrCopyBefore"), &XmlNode::InsertAttrCopyBefore)
- .Func(_SC("AppendChild"), &XmlNode::AppendChild)
- .Func(_SC("PrependChild"), &XmlNode::PrependChild)
- .Func(_SC("AppendChildNode"), &XmlNode::AppendChildNode)
- .Func(_SC("PrependChildNode"), &XmlNode::PrependChildNode)
- .Func(_SC("AppendChildType"), &XmlNode::AppendChildType)
- .Func(_SC("PrependChildType"), &XmlNode::PrependChildType)
- .Func(_SC("InsertChildAfter"), &XmlNode::InsertChildAfter)
- .Func(_SC("InsertChildBefore"), &XmlNode::InsertChildBefore)
- .Func(_SC("InsertChildTypeAfter"), &XmlNode::InsertChildTypeAfter)
- .Func(_SC("InsertChildTypeBefore"), &XmlNode::InsertChildTypeBefore)
- .Func(_SC("AppendCopy"), &XmlNode::AppendCopy)
- .Func(_SC("PrependCopy"), &XmlNode::PrependCopy)
- .Func(_SC("InsertCopyAfter"), &XmlNode::InsertCopyAfter)
- .Func(_SC("InsertCopyBefore"), &XmlNode::InsertCopyBefore)
- .Func(_SC("AppendMove"), &XmlNode::AppendMove)
- .Func(_SC("PrependMove"), &XmlNode::PrependMove)
- .Func(_SC("InsertMoveAfter"), &XmlNode::InsertMoveAfter)
- .Func(_SC("InsertMoveBefore"), &XmlNode::InsertMoveBefore)
- .Func(_SC("RemoveAttr"), &XmlNode::RemoveAttr)
- .Func(_SC("RemoveAttrInst"), &XmlNode::RemoveAttrInst)
- .Func(_SC("RemoveChild"), &XmlNode::RemoveChild)
- .Func(_SC("RemoveChildInst"), &XmlNode::RemoveChildInst)
- .Overload< XmlNode (XmlNode::*)(CSStr, CSStr) const >(_SC("FindChildByAttr"), &XmlNode::FindChildByAttr)
- .Overload< XmlNode (XmlNode::*)(CSStr, CSStr, CSStr) const >(_SC("FindChildByAttr"), &XmlNode::FindChildByAttr)
- .Func(_SC("FindElemByPath"), &XmlNode::FindElemByPath)
- );
-
- xmlns.Bind(_SC("Document"), Class< XmlDocument, NoCopy< XmlDocument > >(vm, _SC("SqXmlDocument"))
- /* Constructors */
- .Ctor()
- /* Core Metamethods */
- .Func(_SC("_cmp"), &XmlDocument::Cmp)
- .Func(_SC("_tostring"), &XmlDocument::ToString)
- /* Properties */
- .Prop(_SC("Valid"), &XmlDocument::IsValid)
- .Prop(_SC("References"), &XmlDocument::GetRefCount)
- .Prop(_SC("Node"), &XmlDocument::GetNode)
- /* Functions */
- .Overload< void (XmlDocument::*)(void) >(_SC("Reset"), &XmlDocument::Reset)
- .Overload< void (XmlDocument::*)(const XmlDocument &) >(_SC("Reset"), &XmlDocument::Reset)
- .Overload< XmlParseResult (XmlDocument::*)(CSStr) >(_SC("LoadString"), &XmlDocument::LoadString)
- .Overload< XmlParseResult (XmlDocument::*)(CSStr, Uint32) >(_SC("LoadString"), &XmlDocument::LoadString)
- .Overload< XmlParseResult (XmlDocument::*)(CSStr) >(_SC("LoadFile"), &XmlDocument::LoadFile)
- .Overload< XmlParseResult (XmlDocument::*)(CSStr, Uint32) >(_SC("LoadFile"), &XmlDocument::LoadFile)
- .Overload< XmlParseResult (XmlDocument::*)(CSStr, Uint32, Int32) >(_SC("LoadFile"), &XmlDocument::LoadFile)
- .Overload< void (XmlDocument::*)(CSStr) >(_SC("SaveFile"), &XmlDocument::SaveFile)
- .Overload< void (XmlDocument::*)(CSStr, CSStr) >(_SC("SaveFile"), &XmlDocument::SaveFile)
- .Overload< void (XmlDocument::*)(CSStr, CSStr, Uint32) >(_SC("SaveFile"), &XmlDocument::SaveFile)
- .Overload< void (XmlDocument::*)(CSStr, CSStr, Uint32, Int32) >(_SC("SaveFile"), &XmlDocument::SaveFile)
- );
-
- RootTable(vm).Bind(_SC("SqXml"), xmlns);
-
- ConstTable(vm).Enum(_SC("SqXmlNodeType"), Enumeration(vm)
- .Const(_SC("Null"), Int32(node_null))
- .Const(_SC("Document"), Int32(node_document))
- .Const(_SC("Element"), Int32(node_element))
- .Const(_SC("PCData"), Int32(node_pcdata))
- .Const(_SC("CData"), Int32(node_cdata))
- .Const(_SC("Comment"), Int32(node_comment))
- .Const(_SC("Pi"), Int32(node_pi))
- .Const(_SC("Declaration"), Int32(node_declaration))
- .Const(_SC("Doctype"), Int32(node_doctype))
- );
-
- ConstTable(vm).Enum(_SC("SqXmlParse"), Enumeration(vm)
- .Const(_SC("Minimal"), Int32(parse_minimal))
- .Const(_SC("Default"), Int32(parse_default))
- .Const(_SC("Full"), Int32(parse_full))
- .Const(_SC("Pi"), Int32(parse_pi))
- .Const(_SC("Comments"), Int32(parse_comments))
- .Const(_SC("CData"), Int32(parse_cdata))
- .Const(_SC("WSPCData"), Int32(parse_ws_pcdata))
- .Const(_SC("Escapes"), Int32(parse_escapes))
- .Const(_SC("EOL"), Int32(parse_eol))
- .Const(_SC("WConvAttribute"), Int32(parse_wconv_attribute))
- .Const(_SC("WNormAttribute"), Int32(parse_wnorm_attribute))
- .Const(_SC("Declaration"), Int32(parse_declaration))
- .Const(_SC("Doctype"), Int32(parse_doctype))
- .Const(_SC("WSPCDataSingle"), Int32(parse_ws_pcdata_single))
- .Const(_SC("TrimPCData"), Int32(parse_trim_pcdata))
- .Const(_SC("Fragment"), Int32(parse_fragment))
- .Const(_SC("EmbedPCData"), Int32(parse_embed_pcdata))
- );
-
- ConstTable(vm).Enum(_SC("SqXmlEncoding"), Enumeration(vm)
- .Const(_SC("Auto"), Int32(encoding_auto))
- .Const(_SC("Utf8"), Int32(encoding_utf8))
- .Const(_SC("Utf16LE"), Int32(encoding_utf16_le))
- .Const(_SC("Utf16BE"), Int32(encoding_utf16_be))
- .Const(_SC("Utf16"), Int32(encoding_utf16))
- .Const(_SC("Utf32LE"), Int32(encoding_utf32_le))
- .Const(_SC("Utf32BE"), Int32(encoding_utf32_be))
- .Const(_SC("Utf32"), Int32(encoding_utf32))
- .Const(_SC("WChar"), Int32(encoding_wchar))
- .Const(_SC("Latin1"), Int32(encoding_latin1))
- );
-
- ConstTable(vm).Enum(_SC("SqXmlFormat"), Enumeration(vm)
- .Const(_SC("Indent"), Int32(format_indent))
- .Const(_SC("WriteBOM"), Int32(format_write_bom))
- .Const(_SC("Raw"), Int32(format_raw))
- .Const(_SC("NoDeclaration"), Int32(format_no_declaration))
- .Const(_SC("NoEscapes"), Int32(format_no_escapes))
- .Const(_SC("SaveFileText"), Int32(format_save_file_text))
- .Const(_SC("IndentAttributes"), Int32(format_indent_attributes))
- .Const(_SC("Default"), Int32(format_default))
- );
-
- ConstTable(vm).Enum(_SC("SqXmlParseStatus"), Enumeration(vm)
- .Const(_SC("Ok"), Int32(status_ok))
- .Const(_SC("FileNotFound"), Int32(status_file_not_found))
- .Const(_SC("IOError"), Int32(status_io_error))
- .Const(_SC("OutOfMemory"), Int32(status_out_of_memory))
- .Const(_SC("InternalError"), Int32(status_internal_error))
- .Const(_SC("UnrecognizedTag"), Int32(status_unrecognized_tag))
- .Const(_SC("BadPi"), Int32(status_bad_pi))
- .Const(_SC("BadComment"), Int32(status_bad_comment))
- .Const(_SC("BadCData"), Int32(status_bad_cdata))
- .Const(_SC("BadDoctype"), Int32(status_bad_doctype))
- .Const(_SC("BadPCData"), Int32(status_bad_pcdata))
- .Const(_SC("BadStartElement"), Int32(status_bad_start_element))
- .Const(_SC("BadAttribute"), Int32(status_bad_attribute))
- .Const(_SC("BadEndElement"), Int32(status_bad_end_element))
- .Const(_SC("EndElementMismatch"), Int32(status_end_element_mismatch))
- .Const(_SC("AppendInvalidRoot"), Int32(status_append_invalid_root))
- .Const(_SC("NoDocumentElement"), Int32(status_no_document_element))
- );
- ConstTable(vm).Enum(_SC("SqXmlXpathValueType"), Enumeration(vm)
- .Const(_SC("None"), Int32(xpath_type_none))
- .Const(_SC("NodeSet"), Int32(xpath_type_node_set))
- .Const(_SC("Number"), Int32(xpath_type_number))
- .Const(_SC("String"), Int32(xpath_type_string))
- .Const(_SC("Boolean"), Int32(xpath_type_boolean))
- );
-}
-
-} // Namespace:: SqMod
diff --git a/source/Library/XML.hpp b/source/Library/XML.hpp
deleted file mode 100644
index a3315dea..00000000
--- a/source/Library/XML.hpp
+++ /dev/null
@@ -1,2037 +0,0 @@
-#ifndef _LIBRARY_XML_HPP_
-#define _LIBRARY_XML_HPP_
-
-// ------------------------------------------------------------------------------------------------
-#include "Base/Shared.hpp"
-#include "Library/Numeric.hpp"
-
-// ------------------------------------------------------------------------------------------------
-#include
-
-// ------------------------------------------------------------------------------------------------
-namespace SqMod {
-namespace XML {
-
-// ------------------------------------------------------------------------------------------------
-using namespace pugi;
-
-// ------------------------------------------------------------------------------------------------
-class XmlNode;
-class XmlText;
-class XmlDocument;
-class XmlAttribute;
-class XmlXpathNode;
-class XmlXpathNodeSet;
-class XmlXpathVariable;
-class XmlXpathVariableSet;
-class XmlXpathVariableQuery;
-
-/* ------------------------------------------------------------------------------------------------
- * Manages a reference counted xml document instance.
-*/
-class XmlDocumentRef
-{
- // --------------------------------------------------------------------------------------------
- friend class XmlDocument;
-
-private:
-
- // --------------------------------------------------------------------------------------------
- typedef xml_document Document;
-
- // --------------------------------------------------------------------------------------------
- typedef unsigned int Counter;
-
- // --------------------------------------------------------------------------------------------
- Document* m_Ptr; /* The document reader, writer and manager instance. */
- Counter* m_Ref; /* Reference count to the managed instance. */
-
- /* --------------------------------------------------------------------------------------------
- * Grab a strong reference to a document instance.
- */
- void Grab()
- {
- if (m_Ptr)
- {
- ++(*m_Ref);
- }
- }
-
- /* --------------------------------------------------------------------------------------------
- * Drop a strong reference to a document instance.
- */
- void Drop()
- {
- if (m_Ptr && --(*m_Ref) == 0)
- {
- delete m_Ptr;
- delete m_Ref;
- m_Ptr = NULL;
- m_Ref = NULL;
- }
- }
-
- /* --------------------------------------------------------------------------------------------
- * Base constructor.
- */
- XmlDocumentRef(VoidP /* unused */)
- : m_Ptr(new Document())
- , m_Ref(new Counter(1))
- {
- /* ... */
- }
-
-public:
-
- /* --------------------------------------------------------------------------------------------
- * Default constructor (null).
- */
- XmlDocumentRef()
- : m_Ptr(NULL), m_Ref(NULL)
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy constructor.
- */
- XmlDocumentRef(const XmlDocumentRef & o)
- : m_Ptr(o.m_Ptr), m_Ref(o.m_Ref)
-
- {
- Grab();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Destructor.
- */
- ~XmlDocumentRef()
- {
- Drop();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy assignment operator.
- */
- XmlDocumentRef & operator = (const XmlDocumentRef & o)
- {
- if (m_Ptr != o.m_Ptr)
- {
- Drop();
- m_Ptr = o.m_Ptr;
- m_Ref = o.m_Ref;
- Grab();
- }
- return *this;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Perform an equality comparison between two document instances.
- */
- bool operator == (const XmlDocumentRef & o) const
- {
- return (m_Ptr == o.m_Ptr);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Perform an inequality comparison between two document instances.
- */
- bool operator != (const XmlDocumentRef & o) const
- {
- return (m_Ptr != o.m_Ptr);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Implicit conversion to boolean for use in boolean operations.
- */
- operator bool () const
- {
- return m_Ptr;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Member operator for dereferencing the managed pointer.
- */
- Document * operator -> () const
- {
- assert(m_Ptr != NULL);
- return m_Ptr;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Indirection operator for obtaining a reference of the managed pointer.
- */
- Document & operator * () const
- {
- assert(m_Ptr != NULL);
- return *m_Ptr;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the number of active references to the managed instance.
- */
- Counter Count() const
- {
- return (m_Ptr && m_Ref) ? (*m_Ref) : 0;
- }
-
-};
-
-/* ------------------------------------------------------------------------------------------------
- * Parsing result.
-*/
-class XmlParseResult
-{
- // --------------------------------------------------------------------------------------------
- friend class XmlDocument;
- friend class XmlNode;
-
-protected:
-
- // --------------------------------------------------------------------------------------------
- typedef xml_parse_result Result;
-
- /* --------------------------------------------------------------------------------------------
- * Explicit constructor.
- */
- XmlParseResult(const XmlDocumentRef doc, const Result & result)
- : m_Doc(doc), m_Result(result)
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Validate the document reference.
- */
- bool Validate() const
- {
- if (m_Doc)
- return true;
- SqThrow("Invalid xml document reference");
- return false;
- }
-
-private:
-
- // ---------------------------------------------------------------------------------------------
- XmlDocumentRef m_Doc; /* The main xml document instance. */
- Result m_Result; /* The managed parse result. */
-
-public:
-
- /* --------------------------------------------------------------------------------------------
- * Default constructor.
- */
- XmlParseResult()
- : m_Doc(), m_Result()
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy constructor. (disabled)
- */
- XmlParseResult(const XmlParseResult & o)
- : m_Doc(o.m_Doc), m_Result(o.m_Result)
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Destructor.
- */
- ~XmlParseResult()
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy assignment operator. (disabled)
- */
- XmlParseResult & operator = (const XmlParseResult & o)
- {
- m_Doc = o.m_Doc;
- m_Result = o.m_Result;
- return *this;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to compare two instances of this type.
- */
- Int32 Cmp(const XmlParseResult & o)
- {
- if (m_Result.status == o.m_Result.status)
- return 0;
- else if (m_Result.status > o.m_Result.status)
- return 1;
- else
- return -1;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to convert an instance of this type to a string.
- */
- CSStr ToString() const
- {
- return m_Result.description();
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether this instance references a valid xml document.
- */
- bool IsValid() const
- {
- return m_Doc;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Return the number of active references to this document instance.
- */
- Uint32 GetRefCount() const
- {
- return m_Doc.Count();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Cast to bool operator.
- */
- bool IsOk() const
- {
- return m_Result;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Parsing status code.
- */
- Int32 GetStatus() const
- {
- return m_Result.status;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Last parsed offset. (in char_t units from start of input data)
- */
- SQInteger GetOffset() const
- {
- return SQInteger(m_Result.offset);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Source document encoding.
- */
- Int32 GetEncoding() const
- {
- return m_Result.encoding;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve error description as a string.
- */
- CSStr GetDescription() const
- {
- return m_Result.description();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Check the parse result and throw the necessary errors.
- */
- void Check() const;
-};
-
-/* ------------------------------------------------------------------------------------------------
- * A light-weight handle for manipulating attributes in DOM tree.
-*/
-class XmlAttribute
-{
- // --------------------------------------------------------------------------------------------
- friend class XmlNode;
-
-protected:
-
- // --------------------------------------------------------------------------------------------
- typedef xml_attribute Attribute;
-
- /* --------------------------------------------------------------------------------------------
- * Explicit constructor.
- */
- XmlAttribute(const XmlDocumentRef doc, const Attribute & attr)
- : m_Doc(doc), m_Attr(attr)
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Validate the document reference.
- */
- bool Validate() const
- {
- if (m_Doc)
- return true;
- SqThrow("Invalid xml document reference");
- return false;
- }
-
-private:
-
- // ---------------------------------------------------------------------------------------------
- XmlDocumentRef m_Doc; /* The main xml document instance. */
- Attribute m_Attr; /* The managed node attribute. */
-
-public:
-
- /* --------------------------------------------------------------------------------------------
- * Default constructor.
- */
- XmlAttribute()
- : m_Doc(), m_Attr()
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy constructor. (disabled)
- */
- XmlAttribute(const XmlAttribute & o)
- : m_Doc(o.m_Doc), m_Attr(o.m_Attr)
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Destructor.
- */
- ~XmlAttribute()
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy assignment operator. (disabled)
- */
- XmlAttribute & operator = (const XmlAttribute & o)
- {
- m_Doc = o.m_Doc;
- m_Attr = o.m_Attr;
- return *this;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to compare two instances of this type.
- */
- Int32 Cmp(const XmlAttribute & o)
- {
- if (m_Attr == o.m_Attr)
- return 0;
- else if (m_Attr > o.m_Attr)
- return 1;
- else
- return -1;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to convert an instance of this type to a string.
- */
- CSStr ToString() const
- {
- return m_Attr.value();
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether this instance references a valid xml document.
- */
- bool IsValid() const
- {
- return m_Doc;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Return the number of active references to this document instance.
- */
- Uint32 GetRefCount() const
- {
- return m_Doc.Count();
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether the attribute is empty.
- */
- bool IsEmpty() const
- {
- return m_Attr.empty();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Get hash value (unique for handles to the same object).
- */
- SQInteger GetHashValue() const
- {
- return (SQInteger)m_Attr.hash_value();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve attribute name.
- */
- CSStr GetName() const
- {
- return m_Attr.name();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve attribute name.
- */
- void SetName(CSStr name)
- {
- if (!m_Attr.set_name(name))
- SqThrow("Unable to set xml attribute name");
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the attribute name.
- */
- bool ApplyName(CSStr name)
- {
- return m_Attr.set_name(name);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve attribute value.
- */
- CSStr GetValue() const
- {
- return m_Attr.value();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve attribute value.
- */
- void SetValue(CSStr name)
- {
- if (!m_Attr.set_value(name))
- SqThrow("Unable to set xml attribute value");
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the attribute value.
- */
- bool ApplyValue(CSStr value)
- {
- return m_Attr.set_value(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a string or the specified default value if empty.
- */
- CSStr AsString(CSStr def) const
- {
- return m_Attr.as_string(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a integer or the specified default value if empty.
- */
- Int32 AsInt(Int32 def) const
- {
- return m_Attr.as_int(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a unsigned integer or the specified default value if empty.
- */
- Uint32 AsUint(Uint32 def) const
- {
- return m_Attr.as_uint(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a floating point or the specified default value if empty.
- */
- SQFloat AsFloat(SQFloat def) const
- {
- return (SQFloat)m_Attr.as_float(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a double floating point or the specified default value if empty.
- */
- SQFloat AsDouble(SQFloat def) const
- {
- return (SQFloat)m_Attr.as_double(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a long integer or the specified default value if empty.
- */
- SLongInt AsLong(const SLongInt & def) const
- {
- return SLongInt(m_Attr.as_llong(def.GetNum()));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a unsigned long integer or the specified default value if empty.
- */
- ULongInt AsUlong(const ULongInt & def) const
- {
- return ULongInt(m_Attr.as_ullong(def.GetNum()));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a boolean or the specified default value if empty.
- */
- bool AsBool(bool def) const
- {
- return m_Attr.as_bool(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a string.
- */
- bool ApplyString(CSStr value)
- {
- return m_Attr.set_value(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a integer.
- */
- bool ApplyInt(Int32 value)
- {
- return m_Attr.set_value(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a unsigned integer.
- */
- bool ApplyUint(Uint32 value)
- {
- return m_Attr.set_value(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a floating point.
- */
- bool ApplyFloat(SQFloat value)
- {
- return m_Attr.set_value(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a double floating point.
- */
- bool ApplyDouble(SQFloat value)
- {
- return m_Attr.set_value(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a long integer.
- */
- bool ApplyLong(const SLongInt & value)
- {
- return m_Attr.set_value(value.GetNum());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a unsigned long integer.
- */
- bool ApplyUlong(const ULongInt & value)
- {
- return m_Attr.set_value(value.GetNum());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a boolean.
- */
- bool ApplyBool(bool value)
- {
- return m_Attr.set_value(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a string.
- */
- CSStr GetString() const
- {
- return m_Attr.as_string();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a string.
- */
- void SetString(CSStr value)
- {
- m_Attr = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a integer.
- */
- Int32 GetInt() const
- {
- return m_Attr.as_int();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a integer.
- */
- void SetInt(Int32 value)
- {
- m_Attr = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a unsigned integer.
- */
- Uint32 GetUint() const
- {
- return m_Attr.as_uint();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a unsigned integer.
- */
- void SetUint(Uint32 value)
- {
- m_Attr = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a floating point.
- */
- SQFloat GetFloat() const
- {
- return (SQFloat)m_Attr.as_float();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a floating point.
- */
- void SetFloat(SQFloat value)
- {
- m_Attr = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a double floating point.
- */
- SQFloat GetDouble() const
- {
- return (SQFloat)m_Attr.as_double();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a double floating point.
- */
- void SetDouble(SQFloat value)
- {
- m_Attr = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a long integer.
- */
- SLongInt GetLong() const
- {
- return SLongInt(m_Attr.as_llong());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a long integer.
- */
- void SetLong(const SLongInt & value)
- {
- m_Attr = value.GetNum();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a unsigned long integer.
- */
- ULongInt GetUlong() const
- {
- return ULongInt(m_Attr.as_ullong());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a unsigned long integer.
- */
- void SetUlong(const ULongInt & value)
- {
- m_Attr = value.GetNum();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a boolean.
- */
- bool GetBool() const
- {
- return m_Attr.as_bool();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a boolean.
- */
- void SetBool(bool value)
- {
- m_Attr = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve next attribute in the attribute list of the parent node.
- */
- XmlAttribute NextAttribute() const
- {
- return XmlAttribute(m_Doc, m_Attr.next_attribute());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve previous attribute in the attribute list of the parent node.
- */
- XmlAttribute PrevAttribute() const
- {
- return XmlAttribute(m_Doc, m_Attr.previous_attribute());
- }
-};
-
-/* ------------------------------------------------------------------------------------------------
- * A helper for working with text inside PCDATA nodes.
-*/
-class XmlText
-{
- // --------------------------------------------------------------------------------------------
- friend class XmlNode;
-
-protected:
-
- // --------------------------------------------------------------------------------------------
- typedef xml_text Text;
-
- /* --------------------------------------------------------------------------------------------
- * Explicit constructor.
- */
- XmlText(const XmlDocumentRef doc, const Text & text)
- : m_Doc(doc), m_Text(text)
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Validate the document reference.
- */
- bool Validate() const
- {
- if (m_Doc)
- return true;
- SqThrow("Invalid xml document reference");
- return false;
- }
-
-private:
-
- // ---------------------------------------------------------------------------------------------
- XmlDocumentRef m_Doc; /* The main xml document instance. */
- Text m_Text; /* The managed document node. */
-
-public:
-
- /* --------------------------------------------------------------------------------------------
- * Default constructor.
- */
- XmlText()
- : m_Doc(), m_Text()
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy constructor. (disabled)
- */
- XmlText(const XmlText & o)
- : m_Doc(o.m_Doc), m_Text(o.m_Text)
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Destructor.
- */
- ~XmlText()
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy assignment operator. (disabled)
- */
- XmlText & operator = (const XmlText & o)
- {
- m_Doc = o.m_Doc;
- m_Text = o.m_Text;
- return *this;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to compare two instances of this type.
- */
- Int32 Cmp(const XmlText & o)
- {
- if (strcmp(m_Text.get(), o.m_Text.get()) == 0)
- return 0;
- else if (strlen(m_Text.get()) > strlen(o.m_Text.get()))
- return 1;
- else
- return -1;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to convert an instance of this type to a string.
- */
- CSStr ToString() const
- {
- return m_Text.get();
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether this instance references a valid xml document.
- */
- bool IsValid() const
- {
- return m_Doc;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Return the number of active references to this document instance.
- */
- Uint32 GetRefCount() const
- {
- return m_Doc.Count();
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether the text is empty.
- */
- bool IsEmpty() const
- {
- return m_Text.empty();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the text value.
- */
- CSStr GetValue() const
- {
- return m_Text.get();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a string or the specified default value if empty.
- */
- CSStr AsString(CSStr def) const
- {
- return m_Text.as_string(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a integer or the specified default value if empty.
- */
- Int32 AsInt(Int32 def) const
- {
- return m_Text.as_int(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a unsigned integer or the specified default value if empty.
- */
- Uint32 AsUint(Uint32 def) const
- {
- return m_Text.as_uint(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a floating point or the specified default value if empty.
- */
- SQFloat AsFloat(SQFloat def) const
- {
- return (SQFloat)m_Text.as_float(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a double floating point or the specified default value if empty.
- */
- SQFloat AsDouble(SQFloat def) const
- {
- return (SQFloat)m_Text.as_double(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a long integer or the specified default value if empty.
- */
- SLongInt AsLong(const SLongInt & def) const
- {
- return SLongInt(m_Text.as_llong(def.GetNum()));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a unsigned long integer or the specified default value if empty.
- */
- ULongInt AsUlong(const ULongInt & def) const
- {
- return ULongInt(m_Text.as_ullong(def.GetNum()));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a boolean or the specified default value if empty.
- */
- bool AsBool(bool def) const
- {
- return m_Text.as_bool(def);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a string.
- */
- bool ApplyString(CSStr value)
- {
- return m_Text.set(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a integer.
- */
- bool ApplyInt(Int32 value)
- {
- return m_Text.set(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a unsigned integer.
- */
- bool ApplyUint(Uint32 value)
- {
- return m_Text.set(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a floating point.
- */
- bool ApplyFloat(SQFloat value)
- {
- return m_Text.set(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a double floating point.
- */
- bool ApplyDouble(SQFloat value)
- {
- return m_Text.set(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a long integer.
- */
- bool ApplyLong(const SLongInt & value)
- {
- return m_Text.set(value.GetNum());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a unsigned long integer.
- */
- bool ApplyUlong(const ULongInt & value)
- {
- return m_Text.set(value.GetNum());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a boolean.
- */
- bool ApplyBool(bool value)
- {
- return m_Text.set(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a string.
- */
- CSStr GetString() const
- {
- return m_Text.as_string();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a string.
- */
- void SetString(CSStr value)
- {
- m_Text = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a integer.
- */
- Int32 GetInt() const
- {
- return m_Text.as_int();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a integer.
- */
- void SetInt(Int32 value)
- {
- m_Text = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a unsigned integer.
- */
- Uint32 GetUint() const
- {
- return m_Text.as_uint();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a unsigned integer.
- */
- void SetUint(Uint32 value)
- {
- m_Text = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a floating point.
- */
- SQFloat GetFloat() const
- {
- return (SQFloat)m_Text.as_float();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a floating point.
- */
- void SetFloat(SQFloat value)
- {
- m_Text = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a double floating point.
- */
- SQFloat GetDouble() const
- {
- return (SQFloat)m_Text.as_double();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a double floating point.
- */
- void SetDouble(SQFloat value)
- {
- m_Text = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a long integer.
- */
- SLongInt GetLong() const
- {
- return SLongInt(m_Text.as_llong());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a long integer.
- */
- void SetLong(const SLongInt & value)
- {
- m_Text = value.GetNum();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a unsigned long integer.
- */
- ULongInt GetUlong() const
- {
- return ULongInt(m_Text.as_ullong());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a unsigned long integer.
- */
- void SetUlong(const ULongInt & value)
- {
- m_Text = value.GetNum();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the value as a boolean.
- */
- bool GetBool() const
- {
- return m_Text.as_bool();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the value as a boolean.
- */
- void SetBool(bool value)
- {
- m_Text = value;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the data node (node_pcdata or node_cdata) for this object.
- */
- XmlNode GetData() const;
-};
-
-/* ------------------------------------------------------------------------------------------------
- * Class that can read/write and alter the contents of xml files.
-*/
-class XmlDocument
-{
-protected:
-
- // --------------------------------------------------------------------------------------------
- typedef xml_document Document;
-
- /* --------------------------------------------------------------------------------------------
- * Copy constructor. (disabled)
- */
- XmlDocument(const XmlDocument & o);
-
- /* --------------------------------------------------------------------------------------------
- * Copy assignment operator. (disabled)
- */
- XmlDocument & operator = (const XmlDocument & o);
-
- /* --------------------------------------------------------------------------------------------
- * Validate the document reference.
- */
- bool Validate() const
- {
- if (m_Doc)
- return true;
- SqThrow("Invalid xml document reference");
- return false;
- }
-
- /* --------------------------------------------------------------------------------------------
- * See if the document can overwrite its contents.
- */
- bool CanLoad() const
- {
- if (!Validate())
- return false;
- else if (m_Doc.Count() == 1)
- return true;
- SqThrow("Loading is disabled while document is referenced");
- return false;
- }
-
-private:
-
- // ---------------------------------------------------------------------------------------------
- XmlDocumentRef m_Doc; /* The main xml document instance. */
-
-public:
-
- /* --------------------------------------------------------------------------------------------
- * Default constructor.
- */
- XmlDocument()
- : m_Doc(NULL)
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Destructor.
- */
- ~XmlDocument()
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to compare two instances of this type.
- */
- Int32 Cmp(const XmlDocument & o) const
- {
- if (m_Doc && !o.m_Doc)
- return 1;
- else if (!m_Doc && o.m_Doc)
- return -1;
- else if (!m_Doc && !o.m_Doc)
- return 0;
- else if (*m_Doc == *o.m_Doc)
- return 0;
- else if (*m_Doc > *o.m_Doc)
- return 1;
- else
- return -1;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to convert an instance of this type to a string.
- */
- CSStr ToString() const
- {
- if (m_Doc)
- return m_Doc->name();
- return _SC("");
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether this instance references a valid xml document.
- */
- bool IsValid() const
- {
- return m_Doc;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Return the number of active references to this document instance.
- */
- Uint32 GetRefCount() const
- {
- return m_Doc ? *(m_Doc.m_Ref) : 0;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Removes all nodes, leaving the empty document.
- */
- void Reset()
- {
- if (Validate())
- m_Doc->reset();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Removes all nodes, then copies the entire contents of the specified document.
- */
- void Reset(const XmlDocument & doc)
- {
- if (Validate() && doc.Validate())
- m_Doc->reset(*doc.m_Doc);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Load document from zero-terminated string.
- */
- XmlParseResult LoadString(CSStr source)
- {
- if (CanLoad())
- return XmlParseResult(m_Doc, m_Doc->load_string(source));
- return XmlParseResult();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Load document from zero-terminated string.
- */
- XmlParseResult LoadString(CSStr source, Uint32 options)
- {
- if (CanLoad())
- return XmlParseResult(m_Doc, m_Doc->load_string(source, options));
- return XmlParseResult();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Load document from file on disk.
- */
- XmlParseResult LoadFile(CSStr filepath)
- {
- if (CanLoad())
- return XmlParseResult(m_Doc, m_Doc->load_file(filepath));
- return XmlParseResult();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Load document from file on disk.
- */
- XmlParseResult LoadFile(CSStr filepath, Uint32 options)
- {
- if (CanLoad())
- return XmlParseResult(m_Doc, m_Doc->load_file(filepath, options));
- return XmlParseResult();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Load document from file on disk.
- */
- XmlParseResult LoadFile(CSStr filepath, Uint32 options, Int32 encoding)
- {
- if (CanLoad())
- return XmlParseResult(m_Doc, m_Doc->load_file(filepath, options, (xml_encoding)encoding));
- return XmlParseResult();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Save XML to file on disk.
- */
- void SaveFile(CSStr filepath)
- {
- if (Validate())
- m_Doc->save_file(filepath);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Save XML to file on disk.
- */
- void SaveFile(CSStr filepath, CSStr indent)
- {
- if (Validate())
- m_Doc->save_file(filepath, indent);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Save XML to file on disk.
- */
- void SaveFile(CSStr filepath, CSStr indent, Uint32 format)
- {
- if (Validate())
- m_Doc->save_file(filepath, indent, format);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Save XML to file on disk.
- */
- void SaveFile(CSStr filepath, CSStr indent, Uint32 format, Int32 encoding)
- {
- if (Validate())
- m_Doc->save_file(filepath, indent, format, (xml_encoding)encoding);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the document root node.
- */
- XmlNode GetNode() const;
-};
-
-/* ------------------------------------------------------------------------------------------------
- * A light-weight handle for manipulating nodes in DOM tree.
-*/
-class XmlNode
-{
- // --------------------------------------------------------------------------------------------
- friend class XmlDocument;
- friend class XmlText;
-
-protected:
-
- // --------------------------------------------------------------------------------------------
- typedef xml_node Node;
-
- /* --------------------------------------------------------------------------------------------
- * Explicit constructor.
- */
- XmlNode(const XmlDocumentRef doc, const Node & node)
- : m_Doc(doc), m_Node(node)
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Validate the document reference.
- */
- bool Validate() const
- {
- if (m_Doc)
- return true;
- SqThrow("Invalid xml document reference");
- return false;
- }
-
-private:
-
- // ---------------------------------------------------------------------------------------------
- XmlDocumentRef m_Doc; /* The main xml document instance. */
- Node m_Node; /* The managed document node. */
-
-public:
-
- /* --------------------------------------------------------------------------------------------
- * Default constructor.
- */
- XmlNode()
- : m_Doc(), m_Node()
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy constructor. (disabled)
- */
- XmlNode(const XmlNode & o)
- : m_Doc(o.m_Doc), m_Node(o.m_Node)
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Destructor.
- */
- ~XmlNode()
- {
- /* ... */
- }
-
- /* --------------------------------------------------------------------------------------------
- * Copy assignment operator. (disabled)
- */
- XmlNode & operator = (const XmlNode & o)
- {
- m_Doc = o.m_Doc;
- m_Node = o.m_Node;
- return *this;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to compare two instances of this type.
- */
- Int32 Cmp(const XmlNode & o)
- {
- if (m_Node == o.m_Node)
- return 0;
- else if (m_Node > o.m_Node)
- return 1;
- else
- return -1;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Used by the script engine to convert an instance of this type to a string.
- */
- CSStr ToString() const
- {
- return m_Node.value();
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether this instance references a valid xml document.
- */
- bool IsValid() const
- {
- return m_Doc;
- }
-
- /* --------------------------------------------------------------------------------------------
- * Return the number of active references to this document instance.
- */
- Uint32 GetRefCount() const
- {
- return m_Doc.Count();
- }
-
- /* --------------------------------------------------------------------------------------------
- * See whether the node is empty.
- */
- bool IsEmpty() const
- {
- return m_Node.empty();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Get hash value (unique for handles to the same object).
- */
- SQInteger GetHashValue() const
- {
- return (SQInteger)m_Node.hash_value();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Get node offset in parsed file/string (in char_t units) for debugging purposes.
- */
- SQInteger GetOffsetDebug() const
- {
- return (SQInteger)m_Node.offset_debug();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve node type.
- */
- Int32 GetType() const
- {
- return (Int32)m_Node.type();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve node name.
- */
- CSStr GetName() const
- {
- return m_Node.name();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve node name.
- */
- void SetName(CSStr name)
- {
- if (!m_Node.set_name(name))
- SqThrow("Unable to set xml node name");
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the node name.
- */
- bool ApplyName(CSStr name)
- {
- return m_Node.set_name(name);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve node value.
- */
- CSStr GetValue() const
- {
- return m_Node.value();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve node value.
- */
- void SetValue(CSStr name)
- {
- if (!m_Node.set_value(name))
- SqThrow("Unable to set xml node value");
- }
-
- /* --------------------------------------------------------------------------------------------
- * Modify the node value.
- */
- bool ApplyValue(CSStr value)
- {
- return m_Node.set_value(value);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Parses buffer as an XML document fragment and appends all nodes as children of this node.
- */
- XmlParseResult AppendBuffer(CSStr source)
- {
- if (source)
- return XmlParseResult(m_Doc, m_Node.append_buffer(source,
- std::char_traits< SQChar >::length(source) * sizeof(SQChar)));
- return XmlParseResult();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Parses buffer as an XML document fragment and appends all nodes as children of this node.
- */
- XmlParseResult AppendBuffer(CSStr source, Uint32 options)
- {
- if (source)
- return XmlParseResult(m_Doc, m_Node.append_buffer(source,
- std::char_traits< SQChar >::length(source) * sizeof(SQChar), options));
- return XmlParseResult();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Parses buffer as an XML document fragment and appends all nodes as children of this node.
- */
- XmlParseResult AppendBuffer(CSStr source, Uint32 options, Int32 encoding)
- {
- if (source)
- return XmlParseResult(m_Doc, m_Node.append_buffer(source,
- std::char_traits< SQChar >::length(source) * sizeof(SQChar)
- , options, (xml_encoding)encoding));
- return XmlParseResult();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the first child attribute.
- */
- XmlAttribute GetFirstAttr() const
- {
- return XmlAttribute(m_Doc, m_Node.first_attribute());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the last child attribute.
- */
- XmlAttribute GetLastAttr() const
- {
- return XmlAttribute(m_Doc, m_Node.last_attribute());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the first child node.
- */
- XmlNode GetFirstChild() const
- {
- return XmlNode(m_Doc, m_Node.first_child());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the last child node.
- */
- XmlNode GetLastChild() const
- {
- return XmlNode(m_Doc, m_Node.last_child());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Get next sibling in the children list of the parent node.
- */
- XmlNode GetNextSibling() const
- {
- return XmlNode(m_Doc, m_Node.next_sibling());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Get previous sibling in the children list of the parent node
- */
- XmlNode GetPrevSibling() const
- {
- return XmlNode(m_Doc, m_Node.previous_sibling());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the parent node.
- */
- XmlNode GetParent() const
- {
- return XmlNode(m_Doc, m_Node.parent());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the root node.
- */
- XmlNode GetRoot() const
- {
- return XmlNode(m_Doc, m_Node.root());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve the text object for the current node.
- */
- XmlText GetText() const
- {
- return XmlText(m_Doc, m_Node.text());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve child node with the specified name.
- */
- XmlNode Child(CSStr name) const
- {
- return XmlNode(m_Doc, m_Node.child(name));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve child attribute with the specified name.
- */
- XmlAttribute Attribute(CSStr name) const
- {
- return XmlAttribute(m_Doc, m_Node.attribute(name));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve next sibling with the specified name.
- */
- XmlNode NextSibling(CSStr name) const
- {
- return XmlNode(m_Doc, m_Node.next_sibling(name));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve previous sibling with the specified name.
- */
- XmlNode PrevSibling(CSStr name) const
- {
- return XmlNode(m_Doc, m_Node.previous_sibling(name));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve child attribute, starting the search from a hint.
- */
- XmlAttribute AttributeFrom(CSStr name, XmlAttribute & attr) const
- {
- return XmlAttribute(m_Doc, m_Node.attribute(name, attr.m_Attr));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Get child value of current node; that is, value of the first child node of type PCDATA/CDATA.
- */
- CSStr GetChildValue() const
- {
- return m_Node.child_value();
- }
-
- /* --------------------------------------------------------------------------------------------
- * Retrieve child value of child with specified name.
- */
- CSStr ChildValue(CSStr name) const
- {
- return m_Node.child_value(name);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Append a child attribute with the specified name.
- */
- XmlAttribute AppendAttr(CSStr name)
- {
- return XmlAttribute(m_Doc, m_Node.append_attribute(name));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Prepend a child attribute with the specified name.
- */
- XmlAttribute PrependAttr(CSStr name)
- {
- return XmlAttribute(m_Doc, m_Node.prepend_attribute(name));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert a child attribute with the specified name, after the specified node.
- */
- XmlAttribute InsertAttrAfter(CSStr name, const XmlAttribute & attr)
- {
- return XmlAttribute(m_Doc, m_Node.insert_attribute_after(name, attr.m_Attr));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert a child attribute with the specified name, before the specified node.
- */
- XmlAttribute InsertAttrBefore(CSStr name, const XmlAttribute & attr)
- {
- return XmlAttribute(m_Doc, m_Node.insert_attribute_before(name, attr.m_Attr));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Append a copy of the specified attribute as a child.
- */
- XmlAttribute AppendAttrCopy(const XmlAttribute & proto)
- {
- return XmlAttribute(m_Doc, m_Node.append_copy(proto.m_Attr));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Prepend a copy of the specified attribute as a child.
- */
- XmlAttribute PrependAttrCopy(const XmlAttribute & proto)
- {
- return XmlAttribute(m_Doc, m_Node.prepend_copy(proto.m_Attr));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert a copy of the specified attribute as a child after the specified attribute.
- */
- XmlAttribute InsertAttrCopyAfter(const XmlAttribute & proto, const XmlAttribute & attr)
- {
- return XmlAttribute(m_Doc, m_Node.insert_copy_after(proto.m_Attr, attr.m_Attr));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert a copy of the specified attribute as a child before the specified attribute.
- */
- XmlAttribute InsertAttrCopyBefore(const XmlAttribute & proto, const XmlAttribute & attr)
- {
- return XmlAttribute(m_Doc, m_Node.insert_copy_before(proto.m_Attr, attr.m_Attr));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Append a basic child node with the specified name.
- */
- XmlNode AppendChild(CSStr name)
- {
- return XmlNode(m_Doc, m_Node.append_child(name));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Prepend a basic child node with the specified name.
- */
- XmlNode PrependChild(CSStr name)
- {
- return XmlNode(m_Doc, m_Node.prepend_child(name));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Append a basic child node.
- */
- XmlNode AppendChildNode()
- {
- return XmlNode(m_Doc, m_Node.append_child());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Prepend a basic child node.
- */
- XmlNode PrependChildNode()
- {
- return XmlNode(m_Doc, m_Node.prepend_child());
- }
-
- /* --------------------------------------------------------------------------------------------
- * Append a basic child node with the specified type.
- */
- XmlNode AppendChildType(Int32 type)
- {
- return XmlNode(m_Doc, m_Node.append_child((xml_node_type)type));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Prepend a basic child node with the specified type.
- */
- XmlNode PrependChildType(Int32 type)
- {
- return XmlNode(m_Doc, m_Node.prepend_child((xml_node_type)type));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert a basic child node with the specified name, after the specified node.
- */
- XmlNode InsertChildAfter(CSStr name, const XmlNode & node)
- {
- return XmlNode(m_Doc, m_Node.insert_child_after(name, node.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert a basic child node with the specified name, before the specified node.
- */
- XmlNode InsertChildBefore(CSStr name, const XmlNode & node)
- {
- return XmlNode(m_Doc, m_Node.insert_child_before(name, node.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert a basic child node with the specified type, after the specified node.
- */
- XmlNode InsertChildTypeAfter(Int32 type, const XmlNode & node)
- {
- return XmlNode(m_Doc, m_Node.insert_child_after((xml_node_type)type, node.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert a basic child node with the specified type, before the specified node.
- */
- XmlNode InsertChildTypeBefore(Int32 type, const XmlNode & node)
- {
- return XmlNode(m_Doc, m_Node.insert_child_before((xml_node_type)type, node.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Append a copy of the specified node as a child.
- */
- XmlNode AppendCopy(const XmlNode & proto)
- {
- return XmlNode(m_Doc, m_Node.append_copy(proto.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Prepend a copy of the specified node as a child.
- */
- XmlNode PrependCopy(const XmlNode & proto)
- {
- return XmlNode(m_Doc, m_Node.prepend_copy(proto.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert a copy of the specified node as a child after the specified node.
- */
- XmlNode InsertCopyAfter(const XmlNode & proto, const XmlNode & node)
- {
- return XmlNode(m_Doc, m_Node.insert_copy_after(proto.m_Node, node.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert a copy of the specified node as a child before the specified node.
- */
- XmlNode InsertCopyBefore(const XmlNode & proto, const XmlNode & node)
- {
- return XmlNode(m_Doc, m_Node.insert_copy_before(proto.m_Node, node.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Append the specified node as a child and take ownersip of it.
- */
- XmlNode AppendMove(const XmlNode & proto)
- {
- return XmlNode(m_Doc, m_Node.append_copy(proto.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Prepend the specified node as a child and take ownersip of it.
- */
- XmlNode PrependMove(const XmlNode & proto)
- {
- return XmlNode(m_Doc, m_Node.prepend_copy(proto.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert the specified node as a child after the specified node and take ownersip of it.
- */
- XmlNode InsertMoveAfter(const XmlNode & proto, const XmlNode & node)
- {
- return XmlNode(m_Doc, m_Node.insert_copy_after(proto.m_Node, node.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Insert the specified node as a child before the specified node and take ownersip of it.
- */
- XmlNode InsertMoveBefore(const XmlNode & proto, const XmlNode & node)
- {
- return XmlNode(m_Doc, m_Node.insert_copy_before(proto.m_Node, node.m_Node));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Remove the child attribute matching the specified name.
- */
- bool RemoveAttr(CSStr name)
- {
- return m_Node.remove_attribute(name);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Remove the specified attribute.
- */
- bool RemoveAttrInst(const XmlAttribute & attr)
- {
- return m_Node.remove_attribute(attr.m_Attr);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Remove the child node matching the specified name.
- */
- bool RemoveChild(CSStr name)
- {
- return m_Node.remove_child(name);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Remove the specified node.
- */
- bool RemoveChildInst(const XmlNode & node)
- {
- return m_Node.remove_child(node.m_Node);
- }
-
- /* --------------------------------------------------------------------------------------------
- * Find child node by attribute name/value.
- */
- XmlNode FindChildByAttr(CSStr attr_name, CSStr attr_value) const
- {
- return XmlNode(m_Doc, m_Node.find_child_by_attribute(attr_name, attr_value));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Find child node by attribute name/value.
- */
- XmlNode FindChildByAttr(CSStr name, CSStr attr_name, CSStr attr_value) const
- {
- return XmlNode(m_Doc, m_Node.find_child_by_attribute(name, attr_name, attr_value));
- }
-
- /* --------------------------------------------------------------------------------------------
- * Search for a node by path consisting of node names and . or .. elements.
- */
- XmlNode FindElemByPath(CSStr path, SQChar delimiter) const
- {
- return XmlNode(m_Doc, m_Node.first_element_by_path(path, delimiter));
- }
-
-};
-
-} // Namespace:: XML
-} // Namespace:: SqMod
-
-#endif // _LIBRARY_XML_HPP_
diff --git a/source/Logger.cpp b/source/Logger.cpp
index 69ecef5a..001355c8 100644
--- a/source/Logger.cpp
+++ b/source/Logger.cpp
@@ -394,4 +394,90 @@ void SqThrow(CCStr fmt, ...)
va_end(args);
}
+// --------------------------------------------------------------------------------------------
+void OutputMessageImpl(const char * msg, va_list args)
+{
+#if defined(WIN32) || defined(_WIN32)
+ HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ CONSOLE_SCREEN_BUFFER_INFO csb_before;
+ GetConsoleScreenBufferInfo( hstdout, &csb_before);
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN);
+ printf("[SQMOD] ");
+
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
+ vprintf(msg, args);
+ puts("");
+
+ SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
+#else
+ printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27, msg);
+ vprintf(msg, args);
+ puts("");
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputErrorImpl(const char * msg, va_list args)
+{
+#if defined(WIN32) || defined(_WIN32)
+ HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
+
+ CONSOLE_SCREEN_BUFFER_INFO csb_before;
+ GetConsoleScreenBufferInfo( hstdout, &csb_before);
+ SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
+ printf("[SQMOD] ");
+
+ SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
+ vprintf(msg, args);
+ puts("");
+
+ SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
+#else
+ printf("%c[0;32m[SQMOD]%c[0;37m", 27, 27, msg);
+ vprintf(msg, args);
+ puts("");
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputDebug(const char * msg, ...)
+{
+#ifdef _DEBUG
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputMessageImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+#else
+ SQMOD_UNUSED_VAR(msg);
+#endif
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputMessage(const char * msg, ...)
+{
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputMessageImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+}
+
+// --------------------------------------------------------------------------------------------
+void OutputError(const char * msg, ...)
+{
+ // Initialize the arguments list
+ va_list args;
+ va_start(args, msg);
+ // Call the output function
+ OutputErrorImpl(msg, args);
+ // Finalize the arguments list
+ va_end(args);
+}
+
} // Namespace:: SqMod
diff --git a/source/Main.cpp b/source/Main.cpp
index e4f453a2..1faa9a6f 100644
--- a/source/Main.cpp
+++ b/source/Main.cpp
@@ -2,13 +2,10 @@
#include "Logger.hpp"
#include "Core.hpp"
#include "Command.hpp"
+#include "SqMod.h"
// ------------------------------------------------------------------------------------------------
-#include
-
-#if defined(_WIN32)
-#include
-#endif // _WIN32
+#include
// ------------------------------------------------------------------------------------------------
namespace SqMod {
@@ -48,9 +45,15 @@ void DestroyComponents()
// ------------------------------------------------------------------------------------------------
SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallbacks * calls, PluginInfo * info)
{
-#if defined(_WIN32)
- WSADATA wsaData;
-#endif // _WIN32
+ // Output plugin header
+ puts("");
+ OutputMessage("--------------------------------------------------------------------");
+ OutputMessage("Plugin: %s", SQMOD_NAME);
+ OutputMessage("Author: %s", SQMOD_AUTHOR);
+ OutputMessage("Legal: %s", SQMOD_COPYRIGHT);
+ OutputMessage("--------------------------------------------------------------------");
+ puts("");
+
_Log = Logger::Get();
// Verify that core components are working
if (!_Log)
@@ -72,23 +75,14 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallback
puts("[SQMOD] Unable to start because the command class could not be instantiated");
return SQMOD_FAILURE;
}
-#if defined(_WIN32)
- // Initialize the sockets on windows
- if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
- {
- DestroyComponents();
- puts("[SQMOD] Unable to start because the windows sockets could not be initialized");
- return SQMOD_FAILURE;
- }
-#endif // _WIN32
-
+ // Store server proxies
_Func = funcs;
_Clbk = calls;
_Info = info;
-
+ // Assign plugin information
_Info->uPluginVer = SQMOD_VERSION;
strcpy(_Info->szName, SQMOD_HOST_NAME);
-
+ // Attempt to initialize the plugin
if (!_Core->Init())
{
LogFtl("The plugin failed to initialize");
@@ -97,9 +91,7 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallback
return SQMOD_FAILURE;
}
else if (_Clbk)
- {
BindCallbacks();
- }
else
{
_Core->Terminate();
@@ -109,6 +101,10 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallback
}
// Attempt to initialize the plugin exports
InitExports();
+ // Notify that the plugin was successfully loaded
+ OutputMessage("Successfully loaded %s", SQMOD_NAME);
+ // Dummy spacing
+ puts("");
// Initialization was successful
return SQMOD_SUCCESS;
}
@@ -120,7 +116,11 @@ static int VC_InitServer(void)
return SQMOD_FAILURE;
_Core->SetState(1);
-
+ // Obtain the API version as a string
+ String apiver(ToStrF("%d", SQMOD_API_VER));
+ // Signal outside plugins to do fetch our proxies
+ _Func->SendCustomCommand(0xDABBAD00, apiver.c_str());
+ // Attempt to load the module core
if (_Core->Load())
_Core->EmitServerStartup();
else
diff --git a/source/Misc/Functions.cpp b/source/Misc/Functions.cpp
index 8a696ced..926b5e26 100644
--- a/source/Misc/Functions.cpp
+++ b/source/Misc/Functions.cpp
@@ -11,7 +11,7 @@
namespace SqMod {
// ------------------------------------------------------------------------------------------------
-static ServerSettings g_SvSettings = {0};
+static ServerSettings g_SvSettings;
static SQChar g_SvNameBuff[SQMOD_SVNAMELENGTH] = {0};
static SQChar g_PasswdBuff[SQMOD_PASSWDLENGTH] = {0};
static SQChar g_GmNameBuff[SQMOD_GMNAMELENGTH] = {0};
diff --git a/source/Register.cpp b/source/Register.cpp
index ea2107a3..304e654a 100644
--- a/source/Register.cpp
+++ b/source/Register.cpp
@@ -35,14 +35,10 @@ extern void Register_Entity(HSQUIRRELVM vm);
// ------------------------------------------------------------------------------------------------
extern void Register_Hash(HSQUIRRELVM vm);
-extern void Register_INI(HSQUIRRELVM vm);
-extern void Register_IRC(HSQUIRRELVM vm);
extern void Register_Numeric(HSQUIRRELVM vm);
extern void Register_Random(HSQUIRRELVM vm);
-extern void Register_SQLite(HSQUIRRELVM vm);
extern void Register_String(HSQUIRRELVM vm);
extern void Register_Time(HSQUIRRELVM vm);
-extern void Register_XML(HSQUIRRELVM vm);
// ------------------------------------------------------------------------------------------------
extern void Register_Constants(HSQUIRRELVM vm);
@@ -81,14 +77,10 @@ bool RegisterAPI(HSQUIRRELVM vm)
Register_CVehicle(vm);
Register_Hash(vm);
- Register_INI(vm);
- Register_IRC(vm);
Register_Random(vm);
Register_Numeric(vm);
- //Register_SQLite(vm);
Register_String(vm);
Register_Time(vm);
- Register_XML(vm);
Register_Constants(vm);
Register_Log(vm);