mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Separated major non mandatory libraries into their onwn modules.
Consolidated and simplified the module API system. Various other fixes and improvements.
This commit is contained in:
parent
fa12692490
commit
f4a11ef825
177
cbp/LibIRC.cbp
177
cbp/LibIRC.cbp
@ -1,177 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="LibIRC" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Win32 Debug Static">
|
||||
<Option output="../lib/mingw32-d/irclib" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Win32 Release Static">
|
||||
<Option output="../lib/mingw32/irclib" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Static">
|
||||
<Option output="../lib/mingw64-d/irclib" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Win64 Release Static">
|
||||
<Option output="../lib/mingw64/irclib" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Static">
|
||||
<Option output="../lib/gcc32-d/irclib" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Static">
|
||||
<Option output="../lib/gcc32/irclib" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Static">
|
||||
<Option output="../lib/gcc64-d/irclib" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Static">
|
||||
<Option output="../lib/gcc64/irclib" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add option="-DSQLITE_ENABLE_FTS3" />
|
||||
<Add option="-DSQLITE_ENABLE_FTS4" />
|
||||
<Add option="-DSQLITE_ENABLE_FTS5" />
|
||||
<Add option="-DSQLITE_THREADSAFE=0" />
|
||||
<Add directory="../include" />
|
||||
<Add directory="../config/common" />
|
||||
<Add directory="../external/LibIRC" />
|
||||
</Compiler>
|
||||
<Unit filename="../external/LibIRC/libircclient.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
395
cbp/ModINI.cbp
Normal file
395
cbp/ModINI.cbp
Normal file
@ -0,0 +1,395 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Mod INI" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Win32 Debug Dynamic">
|
||||
<Option output="../bin/win32-d/mod_ini32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32-d/" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/mingw32-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win32 Release Dynamic">
|
||||
<Option output="../bin/win32/mod_ini32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32/" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/mingw32" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Dynamic">
|
||||
<Option output="../bin/win64-d/mod_ini64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64-d/" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/mingw64-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Release Dynamic">
|
||||
<Option output="../bin/win64/mod_ini64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64/" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/mingw64" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Dynamic">
|
||||
<Option output="../bin/linux32-d/mod_ini32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32-d/" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/gcc32-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Dynamic">
|
||||
<Option output="../bin/linux32/mod_ini32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32/" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/gcc32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Dynamic">
|
||||
<Option output="../bin/linux64-d/mod_ini64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64-d/" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/gcc64-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Dynamic">
|
||||
<Option output="../bin/linux64/mod_ini64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64/" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/gcc64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Win32 Debug Standalone">
|
||||
<Option output="../bin/win32-d/mod_ini32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32-d/" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw32-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win32 Release Standalone">
|
||||
<Option output="../bin/win32/mod_ini32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32/" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw32" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Standalone">
|
||||
<Option output="../bin/win64-d/mod_ini64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64-d/" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw64-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Release Standalone">
|
||||
<Option output="../bin/win64/mod_ini64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64/" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw64" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Standalone">
|
||||
<Option output="../bin/linux32-d/mod_ini32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32-d/" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Standalone">
|
||||
<Option output="../bin/linux32/mod_ini32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32/" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Standalone">
|
||||
<Option output="../bin/linux64-d/mod_ini64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64-d/" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Standalone">
|
||||
<Option output="../bin/linux64/mod_ini64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64/" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-Weffc++" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-Wall" />
|
||||
<Add option="-DSQMOD_PLUGIN_API" />
|
||||
<Add directory="../modules/ini" />
|
||||
<Add directory="../shared" />
|
||||
<Add directory="../include" />
|
||||
<Add directory="../config/common" />
|
||||
</Compiler>
|
||||
<Unit filename="../modules/ini/Common.cpp" />
|
||||
<Unit filename="../modules/ini/Common.hpp" />
|
||||
<Unit filename="../modules/ini/Document.cpp" />
|
||||
<Unit filename="../modules/ini/Document.hpp" />
|
||||
<Unit filename="../modules/ini/Entries.cpp" />
|
||||
<Unit filename="../modules/ini/Entries.hpp" />
|
||||
<Unit filename="../modules/ini/Module.cpp" />
|
||||
<Unit filename="../modules/ini/Module.hpp" />
|
||||
<Unit filename="../shared/SqMod.cpp" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
398
cbp/ModIRC.cbp
Normal file
398
cbp/ModIRC.cbp
Normal file
@ -0,0 +1,398 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Mod IRC" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Win32 Debug Dynamic">
|
||||
<Option output="../bin/win32-d/mod_irc32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32-d/" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw32-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win32 Release Dynamic">
|
||||
<Option output="../bin/win32/mod_irc32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32/" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw32" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Dynamic">
|
||||
<Option output="../bin/win64-d/mod_irc64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64-d/" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw64-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Release Dynamic">
|
||||
<Option output="../bin/win64/mod_irc64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64/" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw64" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Dynamic">
|
||||
<Option output="../bin/linux32-d/mod_irc32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32-d/" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/gcc32-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Dynamic">
|
||||
<Option output="../bin/linux32/mod_irc32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32/" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/gcc32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Dynamic">
|
||||
<Option output="../bin/linux64-d/mod_irc64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64-d/" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/gcc64-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Dynamic">
|
||||
<Option output="../bin/linux64/mod_irc64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64/" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/gcc64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Win32 Debug Standalone">
|
||||
<Option output="../bin/win32-d/mod_irc32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32-d/" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw32-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win32 Release Standalone">
|
||||
<Option output="../bin/win32/mod_irc32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32/" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw32" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Standalone">
|
||||
<Option output="../bin/win64-d/mod_irc64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64-d/" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw64-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Release Standalone">
|
||||
<Option output="../bin/win64/mod_irc64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64/" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw64" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Standalone">
|
||||
<Option output="../bin/linux32-d/mod_irc32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32-d/" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Standalone">
|
||||
<Option output="../bin/linux32/mod_irc32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32/" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Standalone">
|
||||
<Option output="../bin/linux64-d/mod_irc64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64-d/" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Standalone">
|
||||
<Option output="../bin/linux64/mod_irc64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64/" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-Wall" />
|
||||
<Add option="-DSQMOD_PLUGIN_API" />
|
||||
<Add directory="../external/LibIRC" />
|
||||
<Add directory="../shared" />
|
||||
<Add directory="../include" />
|
||||
<Add directory="../config/common" />
|
||||
<Add directory="../modules/irc" />
|
||||
</Compiler>
|
||||
<Unit filename="../external/LibIRC/libircclient.c">
|
||||
<Option compilerVar="CC" />
|
||||
<Option compiler="gcc" use="1" buildCommand="$compiler -Wno-unused-parameter -Wno-sign-compare -Wno-type-limits $options $includes -c $file -o $object" />
|
||||
</Unit>
|
||||
<Unit filename="../modules/irc/Common.cpp" />
|
||||
<Unit filename="../modules/irc/Common.hpp" />
|
||||
<Unit filename="../modules/irc/Module.cpp" />
|
||||
<Unit filename="../modules/irc/Module.hpp" />
|
||||
<Unit filename="../modules/irc/Session.cpp" />
|
||||
<Unit filename="../modules/irc/Session.hpp" />
|
||||
<Unit filename="../shared/SqMod.cpp" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
383
cbp/ModSample.cbp
Normal file
383
cbp/ModSample.cbp
Normal file
@ -0,0 +1,383 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Mod Sample" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Win32 Debug Dynamic">
|
||||
<Option output="../bin/win32-d/mod_sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32-d/" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/mingw32-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win32 Release Dynamic">
|
||||
<Option output="../bin/win32/mod_sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32/" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/mingw32" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Dynamic">
|
||||
<Option output="../bin/win64-d/mod_sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64-d/" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/mingw64-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Release Dynamic">
|
||||
<Option output="../bin/win64/mod_sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64/" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/mingw64" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Dynamic">
|
||||
<Option output="../bin/linux32-d/mod_sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32-d/" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/gcc32-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Dynamic">
|
||||
<Option output="../bin/linux32/mod_sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32/" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/gcc32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Dynamic">
|
||||
<Option output="../bin/linux64-d/mod_sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64-d/" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/gcc64-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Dynamic">
|
||||
<Option output="../bin/linux64/mod_sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64/" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/gcc64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Win32 Debug Standalone">
|
||||
<Option output="../bin/win32-d/mod_sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32-d/" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw32-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win32 Release Standalone">
|
||||
<Option output="../bin/win32/mod_sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32/" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw32" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Standalone">
|
||||
<Option output="../bin/win64-d/mod_sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64-d/" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw64-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Release Standalone">
|
||||
<Option output="../bin/win64/mod_sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64/" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw64" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Standalone">
|
||||
<Option output="../bin/linux32-d/mod_sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32-d/" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Standalone">
|
||||
<Option output="../bin/linux32/mod_sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32/" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Standalone">
|
||||
<Option output="../bin/linux64-d/mod_sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64-d/" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Standalone">
|
||||
<Option output="../bin/linux64/mod_sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64/" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-Wall" />
|
||||
<Add option="-DSQMOD_PLUGIN_API" />
|
||||
<Add directory="../modules/sample" />
|
||||
<Add directory="../shared" />
|
||||
<Add directory="../include" />
|
||||
<Add directory="../config/common" />
|
||||
</Compiler>
|
||||
<Unit filename="../modules/sample/Common.cpp" />
|
||||
<Unit filename="../modules/sample/Common.hpp" />
|
||||
<Unit filename="../modules/sample/Module.cpp" />
|
||||
<Unit filename="../modules/sample/Module.hpp" />
|
||||
<Unit filename="../shared/SqMod.cpp" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
391
cbp/ModXML.cbp
Normal file
391
cbp/ModXML.cbp
Normal file
@ -0,0 +1,391 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Mod XML" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Win32 Debug Dynamic">
|
||||
<Option output="../bin/win32-d/mod_xml32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32-d/" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/mingw32-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win32 Release Dynamic">
|
||||
<Option output="../bin/win32/mod_xml32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32/" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/mingw32" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Dynamic">
|
||||
<Option output="../bin/win64-d/mod_xml64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64-d/" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/mingw64-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Release Dynamic">
|
||||
<Option output="../bin/win64/mod_xml64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64/" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/mingw64" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Dynamic">
|
||||
<Option output="../bin/linux32-d/mod_xml32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32-d/" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/gcc32-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Dynamic">
|
||||
<Option output="../bin/linux32/mod_xml32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32/" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add directory="../lib/gcc32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Dynamic">
|
||||
<Option output="../bin/linux64-d/mod_xml64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64-d/" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/gcc64-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Dynamic">
|
||||
<Option output="../bin/linux64/mod_xml64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64/" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/gcc64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Win32 Debug Standalone">
|
||||
<Option output="../bin/win32-d/mod_xml32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32-d/" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw32-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win32 Release Standalone">
|
||||
<Option output="../bin/win32/mod_xml32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32/" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw32" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Standalone">
|
||||
<Option output="../bin/win64-d/mod_xml64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64-d/" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw64-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Release Standalone">
|
||||
<Option output="../bin/win64/mod_xml64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64/" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw64" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Standalone">
|
||||
<Option output="../bin/linux32-d/mod_xml32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32-d/" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Standalone">
|
||||
<Option output="../bin/linux32/mod_xml32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32/" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Standalone">
|
||||
<Option output="../bin/linux64-d/mod_xml64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64-d/" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Standalone">
|
||||
<Option output="../bin/linux64/mod_xml64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64/" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add option="-DSQMOD_PLUGIN_API" />
|
||||
<Add directory="../modules/xml" />
|
||||
<Add directory="../shared" />
|
||||
<Add directory="../include" />
|
||||
<Add directory="../config/common" />
|
||||
</Compiler>
|
||||
<Unit filename="../external/PUGIXML/pugixml.cpp" />
|
||||
<Unit filename="../modules/xml/Attribute.cpp" />
|
||||
<Unit filename="../modules/xml/Attribute.hpp" />
|
||||
<Unit filename="../modules/xml/Common.cpp" />
|
||||
<Unit filename="../modules/xml/Common.hpp" />
|
||||
<Unit filename="../modules/xml/Document.cpp" />
|
||||
<Unit filename="../modules/xml/Document.hpp" />
|
||||
<Unit filename="../modules/xml/Module.cpp" />
|
||||
<Unit filename="../modules/xml/Module.hpp" />
|
||||
<Unit filename="../modules/xml/Node.cpp" />
|
||||
<Unit filename="../modules/xml/Node.hpp" />
|
||||
<Unit filename="../modules/xml/Text.cpp" />
|
||||
<Unit filename="../modules/xml/Text.hpp" />
|
||||
<Unit filename="../shared/SqMod.cpp" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
232
cbp/Module.cbp
232
cbp/Module.cbp
@ -7,7 +7,7 @@
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Win32 Debug Dynamic">
|
||||
<Option output="../bin/win32-d/sqmod32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option output="../bin/win32-d/mod_squirrel32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32-d/" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="3" />
|
||||
@ -20,8 +20,6 @@
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw32-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
@ -29,7 +27,7 @@
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win32 Release Dynamic">
|
||||
<Option output="../bin/win32/sqmod32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option output="../bin/win32/mod_squirrel32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32/" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="3" />
|
||||
@ -43,8 +41,6 @@
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw32" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
@ -52,7 +48,7 @@
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Dynamic">
|
||||
<Option output="../bin/win64-d/sqmod64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option output="../bin/win64-d/mod_squirrel64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64-d/" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="3" />
|
||||
@ -66,8 +62,6 @@
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw64-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
@ -75,7 +69,7 @@
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Release Dynamic">
|
||||
<Option output="../bin/win64/sqmod64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option output="../bin/win64/mod_squirrel64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64/" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="3" />
|
||||
@ -90,8 +84,6 @@
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add library="Ws2_32" />
|
||||
<Add directory="../lib/mingw64" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
@ -99,7 +91,7 @@
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Dynamic">
|
||||
<Option output="../bin/linux32-d/sqmod32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option output="../bin/linux32-d/mod_squirrel32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32-d/" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="3" />
|
||||
@ -113,12 +105,11 @@
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Dynamic">
|
||||
<Option output="../bin/linux32/sqmod32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option output="../bin/linux32/mod_squirrel32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32/" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="3" />
|
||||
@ -133,12 +124,11 @@
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Dynamic">
|
||||
<Option output="../bin/linux64-d/sqmod64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option output="../bin/linux64-d/mod_squirrel64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64-d/" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="3" />
|
||||
@ -153,12 +143,11 @@
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Dynamic">
|
||||
<Option output="../bin/linux64/sqmod64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option output="../bin/linux64/mod_squirrel64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64/" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="3" />
|
||||
@ -171,6 +160,197 @@
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add directory="../lib/gcc64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Win32 Debug Standalone">
|
||||
<Option output="../bin/win32-d/mod_squirrel32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32-d/" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw32-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win32 Release Standalone">
|
||||
<Option output="../bin/win32/mod_squirrel32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32/" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw32" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Standalone">
|
||||
<Option output="../bin/win64-d/mod_squirrel64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64-d/" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw64-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Release Standalone">
|
||||
<Option output="../bin/win64/mod_squirrel64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64/" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw64" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Standalone">
|
||||
<Option output="../bin/linux32-d/mod_squirrel32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32-d/" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Standalone">
|
||||
<Option output="../bin/linux32/mod_squirrel32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32/" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Standalone">
|
||||
<Option output="../bin/linux64-d/mod_squirrel64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64-d/" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Standalone">
|
||||
<Option output="../bin/linux64/mod_squirrel64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64/" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
@ -180,10 +360,8 @@
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-Wall" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add directory="../source" />
|
||||
<Add directory="../shared" />
|
||||
<Add directory="../include" />
|
||||
@ -193,13 +371,10 @@
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="squirrel" />
|
||||
<Add library="sqlite" />
|
||||
<Add library="irclib" />
|
||||
</Linker>
|
||||
<Unit filename="../external/Hash/crc32.cpp" />
|
||||
<Unit filename="../external/Hash/crc32.h" />
|
||||
<Unit filename="../external/Hash/digest.cpp" />
|
||||
<Unit filename="../external/Hash/endian.h" />
|
||||
<Unit filename="../external/Hash/hash.h" />
|
||||
<Unit filename="../external/Hash/hmac.h" />
|
||||
<Unit filename="../external/Hash/keccak.cpp" />
|
||||
@ -212,7 +387,6 @@
|
||||
<Unit filename="../external/Hash/sha256.h" />
|
||||
<Unit filename="../external/Hash/sha3.cpp" />
|
||||
<Unit filename="../external/Hash/sha3.h" />
|
||||
<Unit filename="../external/PUGIXML/pugixml.cpp" />
|
||||
<Unit filename="../external/RandomLib/Random.cpp" />
|
||||
<Unit filename="../source/Base/AABB.cpp" />
|
||||
<Unit filename="../source/Base/AABB.hpp" />
|
||||
@ -272,10 +446,6 @@
|
||||
<Unit filename="../source/Library/Format.hpp" />
|
||||
<Unit filename="../source/Library/Hashing.cpp" />
|
||||
<Unit filename="../source/Library/Hashing.hpp" />
|
||||
<Unit filename="../source/Library/INI.cpp" />
|
||||
<Unit filename="../source/Library/INI.hpp" />
|
||||
<Unit filename="../source/Library/IRC.cpp" />
|
||||
<Unit filename="../source/Library/IRC.hpp" />
|
||||
<Unit filename="../source/Library/Math.cpp" />
|
||||
<Unit filename="../source/Library/Math.hpp" />
|
||||
<Unit filename="../source/Library/Numeric.cpp" />
|
||||
@ -294,8 +464,6 @@
|
||||
<Unit filename="../source/Library/Time.hpp" />
|
||||
<Unit filename="../source/Library/Utils.cpp" />
|
||||
<Unit filename="../source/Library/Utils.hpp" />
|
||||
<Unit filename="../source/Library/XML.cpp" />
|
||||
<Unit filename="../source/Library/XML.hpp" />
|
||||
<Unit filename="../source/Logger.cpp" />
|
||||
<Unit filename="../source/Logger.hpp" />
|
||||
<Unit filename="../source/Main.cpp" />
|
||||
|
176
cbp/SQLite.cbp
176
cbp/SQLite.cbp
@ -1,176 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="SQLite" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Win32 Debug Static">
|
||||
<Option output="../lib/mingw32-d/sqlite" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Win32 Release Static">
|
||||
<Option output="../lib/mingw32/sqlite" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Static">
|
||||
<Option output="../lib/mingw64-d/sqlite" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Win64 Release Static">
|
||||
<Option output="../lib/mingw64/sqlite" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Static">
|
||||
<Option output="../lib/gcc32-d/sqlite" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Static">
|
||||
<Option output="../lib/gcc32/sqlite" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Static">
|
||||
<Option output="../lib/gcc64-d/sqlite" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Static">
|
||||
<Option output="../lib/gcc64/sqlite" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add option="-DSQLITE_ENABLE_FTS3" />
|
||||
<Add option="-DSQLITE_ENABLE_FTS4" />
|
||||
<Add option="-DSQLITE_ENABLE_FTS5" />
|
||||
<Add option="-DSQLITE_THREADSAFE=0" />
|
||||
<Add directory="../include" />
|
||||
<Add directory="../config/common" />
|
||||
</Compiler>
|
||||
<Unit filename="../external/SQLite/sqlite3.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
199
cbp/Sample.cbp
199
cbp/Sample.cbp
@ -1,199 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Sample" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Win32 Debug Dynamic">
|
||||
<Option output="../bin/win32-d/sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32-d/" />
|
||||
<Option object_output="../obj/mingw32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw32-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win32 Release Dynamic">
|
||||
<Option output="../bin/win32/sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win32/" />
|
||||
<Option object_output="../obj/mingw32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/mingw32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw32" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Debug Dynamic">
|
||||
<Option output="../bin/win64-d/sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64-d/" />
|
||||
<Option object_output="../obj/mingw64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw64-d" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Win64 Release Dynamic">
|
||||
<Option output="../bin/win64/sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/win64/" />
|
||||
<Option object_output="../obj/mingw64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/mingw64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-static" />
|
||||
<Add directory="../lib/mingw64" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add after='cmd /c copy /Y "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)..\bin\plugins\$(TARGET_OUTPUT_BASENAME).dll"' />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Linux32 Debug Dynamic">
|
||||
<Option output="../bin/linux32-d/sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32-d/" />
|
||||
<Option object_output="../obj/gcc32-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m32" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux32 Release Dynamic">
|
||||
<Option output="../bin/linux32/sample32" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux32/" />
|
||||
<Option object_output="../obj/gcc32/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add directory="../config/gcc32" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m32" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc32" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Debug Dynamic">
|
||||
<Option output="../bin/linux64-d/sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64-d/" />
|
||||
<Option object_output="../obj/gcc64-d/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-m64" />
|
||||
<Add option="-g" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-D_DEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64-d" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Linux64 Release Dynamic">
|
||||
<Option output="../bin/linux64/sample64" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="0" extension_auto="1" />
|
||||
<Option working_dir="../bin/linux64/" />
|
||||
<Option object_output="../obj/gcc64/" />
|
||||
<Option type="3" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O3" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-fPIC" />
|
||||
<Add option="-DNDEBUG" />
|
||||
<Add option="-D_SQ64" />
|
||||
<Add directory="../config/gcc64" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
<Add option="-m64" />
|
||||
<Add option="-Bstatic" />
|
||||
<Add directory="../lib/gcc64" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add option="-static-libgcc" />
|
||||
<Add option="-static-libstdc++" />
|
||||
<Add option="-enable-static" />
|
||||
<Add option="-DSQMOD_PLUGIN_API" />
|
||||
<Add directory="../sample" />
|
||||
<Add directory="../shared" />
|
||||
<Add directory="../include" />
|
||||
<Add directory="../config/common" />
|
||||
</Compiler>
|
||||
<Unit filename="../sample/Module.cpp" />
|
||||
<Unit filename="../sample/Module.hpp" />
|
||||
<Unit filename="../shared/sq_mod.cpp" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
@ -159,7 +159,6 @@
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="squirrel" />
|
||||
<Add library="sqlite" />
|
||||
</Linker>
|
||||
<Unit filename="../sandbox/main.cpp" />
|
||||
<Extensions>
|
||||
|
@ -4,8 +4,9 @@
|
||||
<Project filename="Module.cbp" />
|
||||
<Project filename="Sandbox.cbp" />
|
||||
<Project filename="Squirrel.cbp" />
|
||||
<Project filename="SQLite.cbp" />
|
||||
<Project filename="LibIRC.cbp" />
|
||||
<Project filename="Sample.cbp" />
|
||||
<Project filename="ModINI.cbp" />
|
||||
<Project filename="ModIRC.cbp" />
|
||||
<Project filename="ModXML.cbp" />
|
||||
<Project filename="ModSample.cbp" />
|
||||
</Workspace>
|
||||
</CodeBlocks_workspace_file>
|
||||
|
18
external/LibIRC/portable.c
vendored
18
external/LibIRC/portable.c
vendored
@ -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 <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
@ -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 <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
20
external/LibIRC/sockets.c
vendored
20
external/LibIRC/sockets.c
vendored
@ -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 <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@
|
||||
#define _SCRAT_MAIN_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define _SCRAT_ALLOCATOR_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define _SCRAT_ARRAY_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define _SCRAT_CLASS_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define _SCRAT_CLASSTYPE_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define _SCRAT_CONST_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define _SCRAT_SQFUNC_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define _SCRAT_GLOBAL_METHODS_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define _SCRAT_MEMBER_METHODS_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define _SCRAT_OBJECT_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define _SQRAT_OVERLOAD_METHODS_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define _SCRAT_SCRIPT_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#include <sqstdio.h>
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define _SCRAT_TABLE_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -34,7 +34,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define _SCRAT_UTIL_H_
|
||||
|
||||
#ifdef SQMOD_PLUGIN_API
|
||||
#include <sq_api.h>
|
||||
#include <SqAPI.h>
|
||||
#else
|
||||
#include <squirrel.h>
|
||||
#endif // SQMOD_PLUGIN_API
|
||||
|
35
modules/ini/Common.cpp
Normal file
35
modules/ini/Common.cpp
Normal file
@ -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
|
396
modules/ini/Common.hpp
Normal file
396
modules/ini/Common.hpp
Normal file
@ -0,0 +1,396 @@
|
||||
#ifndef _SQINI_COMMON_HPP_
|
||||
#define _SQINI_COMMON_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "ModBase.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <assert.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <SimpleIni.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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_
|
227
modules/ini/Document.cpp
Normal file
227
modules/ini/Document.cpp
Normal file
@ -0,0 +1,227 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Document.hpp"
|
||||
#include "Entries.hpp"
|
||||
#include "Module.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <errno.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include <sqrat.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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
|
408
modules/ini/Document.hpp
Normal file
408
modules/ini/Document.hpp
Normal file
@ -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_
|
85
modules/ini/Entries.cpp
Normal file
85
modules/ini/Entries.cpp
Normal file
@ -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
|
220
modules/ini/Entries.hpp
Normal file
220
modules/ini/Entries.hpp
Normal file
@ -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_
|
414
modules/ini/Module.cpp
Normal file
414
modules/ini/Module.cpp
Normal file
@ -0,0 +1,414 @@
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include "Module.hpp"
|
||||
#include "Common.hpp"
|
||||
#include "Entries.hpp"
|
||||
#include "Document.hpp"
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include <sqrat.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
#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;
|
||||
}
|
41
modules/ini/Module.hpp
Normal file
41
modules/ini/Module.hpp
Normal file
@ -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_
|
33
modules/irc/Common.cpp
Normal file
33
modules/irc/Common.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Common.hpp"
|
||||
#include "Module.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <libircclient.h>
|
||||
#include <libirc_rfcnumeric.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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
|
40
modules/irc/Common.hpp
Normal file
40
modules/irc/Common.hpp
Normal file
@ -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_
|
620
modules/irc/Module.cpp
Normal file
620
modules/irc/Module.cpp
Normal file
@ -0,0 +1,620 @@
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include "Module.hpp"
|
||||
#include "Common.hpp"
|
||||
#include "Session.hpp"
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include <sqrat.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
#include <Winsock2.h>
|
||||
#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;
|
||||
}
|
41
modules/irc/Module.hpp
Normal file
41
modules/irc/Module.hpp
Normal file
@ -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_
|
@ -1,18 +1,16 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/IRC.hpp"
|
||||
#include "Session.hpp"
|
||||
#include "Module.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <sqstdstring.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <algorithm>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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
|
@ -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 <vector>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <libircclient.h>
|
||||
#include <libirc_rfcnumeric.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <vector>
|
||||
#include <sqrat.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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_
|
24
modules/sample/Common.cpp
Normal file
24
modules/sample/Common.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Common.hpp"
|
||||
#include "Module.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <stdlib.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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
|
66
modules/sample/Common.hpp
Normal file
66
modules/sample/Common.hpp
Normal file
@ -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_
|
310
modules/sample/Module.cpp
Normal file
310
modules/sample/Module.cpp
Normal file
@ -0,0 +1,310 @@
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include "Module.hpp"
|
||||
#include "Common.hpp"
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include <sqrat.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
#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;
|
||||
}
|
41
modules/sample/Module.hpp
Normal file
41
modules/sample/Module.hpp
Normal file
@ -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_
|
193
modules/xml/Attribute.cpp
Normal file
193
modules/xml/Attribute.cpp
Normal file
@ -0,0 +1,193 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Attribute.hpp"
|
||||
#include "Module.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <sqrat.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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
|
427
modules/xml/Attribute.hpp
Normal file
427
modules/xml/Attribute.hpp
Normal file
@ -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_
|
25
modules/xml/Common.cpp
Normal file
25
modules/xml/Common.cpp
Normal file
@ -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
|
392
modules/xml/Common.hpp
Normal file
392
modules/xml/Common.hpp
Normal file
@ -0,0 +1,392 @@
|
||||
#ifndef _XML_COMMON_HPP_
|
||||
#define _XML_COMMON_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "ModBase.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <assert.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <pugixml.hpp>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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_
|
41
modules/xml/Document.cpp
Normal file
41
modules/xml/Document.cpp
Normal file
@ -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
|
221
modules/xml/Document.hpp
Normal file
221
modules/xml/Document.hpp
Normal file
@ -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_
|
592
modules/xml/Module.cpp
Normal file
592
modules/xml/Module.cpp
Normal file
@ -0,0 +1,592 @@
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include "Module.hpp"
|
||||
#include "Common.hpp"
|
||||
#include "Attribute.hpp"
|
||||
#include "Text.hpp"
|
||||
#include "Node.hpp"
|
||||
#include "Document.hpp"
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include <sqrat.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
#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;
|
||||
}
|
@ -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_
|
118
modules/xml/Node.cpp
Normal file
118
modules/xml/Node.cpp
Normal file
@ -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
|
580
modules/xml/Node.hpp
Normal file
580
modules/xml/Node.hpp
Normal file
@ -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_
|
198
modules/xml/Text.cpp
Normal file
198
modules/xml/Text.cpp
Normal file
@ -0,0 +1,198 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Text.hpp"
|
||||
#include "Node.hpp"
|
||||
#include "Module.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <string.h>
|
||||
#include <sqrat.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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
|
365
modules/xml/Text.hpp
Normal file
365
modules/xml/Text.hpp
Normal file
@ -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_
|
@ -1,229 +0,0 @@
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include "Module.hpp"
|
||||
#include "sq_mod.h"
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include <sqrat.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#include <Windows.h>
|
||||
#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);
|
||||
}
|
1161
shared/ModBase.hpp
Normal file
1161
shared/ModBase.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -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. */
|
@ -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. */
|
136
shared/SqMod.h
Normal file
136
shared/SqMod.h
Normal file
@ -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_*/
|
587
shared/SqMod.inl
Normal file
587
shared/SqMod.inl
Normal file
@ -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
|
||||
}
|
579
shared/sq_mod.h
579
shared/sq_mod.h
@ -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_*/
|
1968
shared/sq_mod.inl
1968
shared/sq_mod.inl
File diff suppressed because it is too large
Load Diff
@ -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();
|
||||
|
||||
|
@ -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*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/Numeric.hpp"
|
||||
#include "Library/Time.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -9,7 +13,7 @@
|
||||
#include <sqstdio.h>
|
||||
#include <sqstdblob.h>
|
||||
#include <sqstdstring.h>
|
||||
#include <sq_mod.h>
|
||||
#include <SqMod.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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;
|
||||
|
@ -1,533 +0,0 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/INI.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <errno.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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
|
@ -1,736 +0,0 @@
|
||||
#ifndef _LIBRARY_INI_HPP_
|
||||
#define _LIBRARY_INI_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Base/Shared.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <SimpleIni.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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_
|
@ -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)
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
*
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -131,6 +131,14 @@ public:
|
||||
*/
|
||||
void SetNow();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
*
|
||||
*/
|
||||
Int64 GetNum() const
|
||||
{
|
||||
return m_Timestamp;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
*
|
||||
*/
|
||||
|
@ -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_
|
@ -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
|
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
@ -2,13 +2,10 @@
|
||||
#include "Logger.hpp"
|
||||
#include "Core.hpp"
|
||||
#include "Command.hpp"
|
||||
#include "SqMod.h"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <winsock2.h>
|
||||
#endif // _WIN32
|
||||
#include <stdio.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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
|
||||
|
@ -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};
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user