mirror of
				https://github.com/VCMP-SqMod/SqMod.git
				synced 2025-11-04 00:07:19 +01:00 
			
		
		
		
	Various changes to the modules.
Also commited the remaining incomplete modules.
This commit is contained in:
		@@ -1 +1 @@
 | 
				
			|||||||
print("Hello World");
 | 
					SqRoutine.Create(this, print, 100, 3, "HELLO WORLD");
 | 
				
			||||||
							
								
								
									
										410
									
								
								cbp/ModJSON.cbp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										410
									
								
								cbp/ModJSON.cbp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,410 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
 | 
				
			||||||
 | 
					<CodeBlocks_project_file>
 | 
				
			||||||
 | 
						<FileVersion major="1" minor="6" />
 | 
				
			||||||
 | 
						<Project>
 | 
				
			||||||
 | 
							<Option title="Mod JSON" />
 | 
				
			||||||
 | 
							<Option pch_mode="2" />
 | 
				
			||||||
 | 
							<Option compiler="gcc" />
 | 
				
			||||||
 | 
							<Build>
 | 
				
			||||||
 | 
								<Target title="Win32 Debug Dynamic">
 | 
				
			||||||
 | 
									<Option output="../bin/win32-d/mod_json32" 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_json32" 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_json64" 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_json64" 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_json32" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux32 Release Dynamic">
 | 
				
			||||||
 | 
									<Option output="../bin/linux32/mod_json32" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux64 Debug Dynamic">
 | 
				
			||||||
 | 
									<Option output="../bin/linux64-d/mod_json64" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux64 Release Dynamic">
 | 
				
			||||||
 | 
									<Option output="../bin/linux64/mod_json64" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Win32 Debug Standalone">
 | 
				
			||||||
 | 
									<Option output="../bin/win32-d/mod_json32" 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_json32" 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_json64" 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_json64" 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_json32" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux32 Release Standalone">
 | 
				
			||||||
 | 
									<Option output="../bin/linux32/mod_json32" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux64 Debug Standalone">
 | 
				
			||||||
 | 
									<Option output="../bin/linux64-d/mod_json64" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux64 Release Standalone">
 | 
				
			||||||
 | 
									<Option output="../bin/linux64/mod_json64" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
							</Build>
 | 
				
			||||||
 | 
							<Compiler>
 | 
				
			||||||
 | 
								<Add option="-Wextra" />
 | 
				
			||||||
 | 
								<Add option="-Wall" />
 | 
				
			||||||
 | 
								<Add option="-std=c++14" />
 | 
				
			||||||
 | 
								<Add option="-DSQMOD_PLUGIN_API" />
 | 
				
			||||||
 | 
								<Add option="-DSCRAT_USE_EXCEPTIONS" />
 | 
				
			||||||
 | 
								<Add option="-DSCRAT_USE_CXX11_OPTIMIZATIONS" />
 | 
				
			||||||
 | 
								<Add directory="../modules/json" />
 | 
				
			||||||
 | 
								<Add directory="../shared" />
 | 
				
			||||||
 | 
								<Add directory="../include" />
 | 
				
			||||||
 | 
								<Add directory="../config/common" />
 | 
				
			||||||
 | 
							</Compiler>
 | 
				
			||||||
 | 
							<Unit filename="../modules/json/Common.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/json/Common.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/json/Module.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/json/Module.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../shared/SqMod.cpp" />
 | 
				
			||||||
 | 
							<Extensions>
 | 
				
			||||||
 | 
								<code_completion />
 | 
				
			||||||
 | 
								<envvars />
 | 
				
			||||||
 | 
								<debugger />
 | 
				
			||||||
 | 
								<lib_finder disable_auto="1" />
 | 
				
			||||||
 | 
							</Extensions>
 | 
				
			||||||
 | 
						</Project>
 | 
				
			||||||
 | 
					</CodeBlocks_project_file>
 | 
				
			||||||
							
								
								
									
										443
									
								
								cbp/ModMongoose.cbp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										443
									
								
								cbp/ModMongoose.cbp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,443 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
 | 
				
			||||||
 | 
					<CodeBlocks_project_file>
 | 
				
			||||||
 | 
						<FileVersion major="1" minor="6" />
 | 
				
			||||||
 | 
						<Project>
 | 
				
			||||||
 | 
							<Option title="Mod Mongoose" />
 | 
				
			||||||
 | 
							<Option pch_mode="2" />
 | 
				
			||||||
 | 
							<Option compiler="gcc" />
 | 
				
			||||||
 | 
							<Build>
 | 
				
			||||||
 | 
								<Target title="Win32 Debug Dynamic">
 | 
				
			||||||
 | 
									<Option output="../bin/win32-d/mod_mg32" 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_mg32" 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_mg64" 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_mg64" 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_mg32" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux32 Release Dynamic">
 | 
				
			||||||
 | 
									<Option output="../bin/linux32/mod_mg32" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux64 Debug Dynamic">
 | 
				
			||||||
 | 
									<Option output="../bin/linux64-d/mod_mg64" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux64 Release Dynamic">
 | 
				
			||||||
 | 
									<Option output="../bin/linux64/mod_mg64" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Win32 Debug Standalone">
 | 
				
			||||||
 | 
									<Option output="../bin/win32-d/mod_mg32" 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_mg32" 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_mg64" 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_mg64" 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_mg32" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux32 Release Standalone">
 | 
				
			||||||
 | 
									<Option output="../bin/linux32/mod_mg32" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux64 Debug Standalone">
 | 
				
			||||||
 | 
									<Option output="../bin/linux64-d/mod_mg64" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
								<Target title="Linux64 Release Standalone">
 | 
				
			||||||
 | 
									<Option output="../bin/linux64/mod_mg64" 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>
 | 
				
			||||||
 | 
									<ExtraCommands>
 | 
				
			||||||
 | 
										<Add after='/bin/cp -rf "$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)" "$(PROJECT_DIR)../bin/plugins/$(TARGET_OUTPUT_BASENAME).so"' />
 | 
				
			||||||
 | 
									</ExtraCommands>
 | 
				
			||||||
 | 
								</Target>
 | 
				
			||||||
 | 
							</Build>
 | 
				
			||||||
 | 
							<Compiler>
 | 
				
			||||||
 | 
								<Add option="-Wextra" />
 | 
				
			||||||
 | 
								<Add option="-Wall" />
 | 
				
			||||||
 | 
								<Add option="-std=c++14" />
 | 
				
			||||||
 | 
								<Add option="-DSQMOD_PLUGIN_API" />
 | 
				
			||||||
 | 
								<Add option="-DSCRAT_USE_EXCEPTIONS" />
 | 
				
			||||||
 | 
								<Add option="-DSCRAT_USE_CXX11_OPTIMIZATIONS" />
 | 
				
			||||||
 | 
								<Add option="-DMG_ENABLE_THREADS" />
 | 
				
			||||||
 | 
								<Add option="-DMG_ENABLE_DNS_SERVER" />
 | 
				
			||||||
 | 
								<Add option="-DMG_DISABLE_DAV" />
 | 
				
			||||||
 | 
								<Add option="-DCS_DISABLE_STDIO" />
 | 
				
			||||||
 | 
								<Add directory="../modules/mg" />
 | 
				
			||||||
 | 
								<Add directory="../shared" />
 | 
				
			||||||
 | 
								<Add directory="../include" />
 | 
				
			||||||
 | 
								<Add directory="../config/common" />
 | 
				
			||||||
 | 
							</Compiler>
 | 
				
			||||||
 | 
							<Unit filename="../external/Mongoose/mongoose.c">
 | 
				
			||||||
 | 
								<Option compilerVar="CC" />
 | 
				
			||||||
 | 
								<Option compiler="gcc" use="1" buildCommand="$compiler -Wno-type-limits -Wno-unused-parameter -Wno-format $options $includes -c $file -o $object\n" />
 | 
				
			||||||
 | 
							</Unit>
 | 
				
			||||||
 | 
							<Unit filename="../include/mongoose.h" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Common.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Common.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Connection.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Connection.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/HTTP.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/HTTP.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Handles.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Handles.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Manager.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Manager.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Message.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Message.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Module.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Module.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Options.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/Options.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/String.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/String.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/WebSocket.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mg/WebSocket.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../shared/SqMod.cpp" />
 | 
				
			||||||
 | 
							<Extensions>
 | 
				
			||||||
 | 
								<code_completion />
 | 
				
			||||||
 | 
								<envvars />
 | 
				
			||||||
 | 
								<debugger />
 | 
				
			||||||
 | 
								<lib_finder disable_auto="1" />
 | 
				
			||||||
 | 
							</Extensions>
 | 
				
			||||||
 | 
						</Project>
 | 
				
			||||||
 | 
					</CodeBlocks_project_file>
 | 
				
			||||||
							
								
								
									
										386
									
								
								cbp/ModMySQL.cbp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										386
									
								
								cbp/ModMySQL.cbp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,386 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
 | 
				
			||||||
 | 
					<CodeBlocks_project_file>
 | 
				
			||||||
 | 
						<FileVersion major="1" minor="6" />
 | 
				
			||||||
 | 
						<Project>
 | 
				
			||||||
 | 
							<Option title="Mod MySQL" />
 | 
				
			||||||
 | 
							<Option pch_mode="2" />
 | 
				
			||||||
 | 
							<Option compiler="gcc" />
 | 
				
			||||||
 | 
							<Build>
 | 
				
			||||||
 | 
								<Target title="Win32 Debug Dynamic">
 | 
				
			||||||
 | 
									<Option output="../bin/win32-d/mod_mysql32" 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_mysql32" 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_mysql64" 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_mysql64" 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_mysql32" 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_mysql32" 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_mysql64" 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_mysql64" 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_mysql32" 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_mysql32" 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_mysql64" 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_mysql64" 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_mysql32" 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_mysql32" 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_mysql64" 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_mysql64" 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="-std=c++14" />
 | 
				
			||||||
 | 
								<Add option="-DSQMOD_PLUGIN_API" />
 | 
				
			||||||
 | 
								<Add option="-DSCRAT_USE_EXCEPTIONS" />
 | 
				
			||||||
 | 
								<Add option="-DSCRAT_USE_CXX11_OPTIMIZATIONS" />
 | 
				
			||||||
 | 
								<Add directory="../modules/mysql" />
 | 
				
			||||||
 | 
								<Add directory="../shared" />
 | 
				
			||||||
 | 
								<Add directory="../include" />
 | 
				
			||||||
 | 
								<Add directory="../config/common" />
 | 
				
			||||||
 | 
							</Compiler>
 | 
				
			||||||
 | 
							<Unit filename="../modules/mysql/Common.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mysql/Common.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mysql/Module.cpp" />
 | 
				
			||||||
 | 
							<Unit filename="../modules/mysql/Module.hpp" />
 | 
				
			||||||
 | 
							<Unit filename="../shared/SqMod.cpp" />
 | 
				
			||||||
 | 
							<Extensions>
 | 
				
			||||||
 | 
								<code_completion />
 | 
				
			||||||
 | 
								<envvars />
 | 
				
			||||||
 | 
								<debugger />
 | 
				
			||||||
 | 
								<lib_finder disable_auto="1" />
 | 
				
			||||||
 | 
							</Extensions>
 | 
				
			||||||
 | 
						</Project>
 | 
				
			||||||
 | 
					</CodeBlocks_project_file>
 | 
				
			||||||
@@ -7,6 +7,7 @@
 | 
				
			|||||||
		<Project filename="ModINI.cbp" />
 | 
							<Project filename="ModINI.cbp" />
 | 
				
			||||||
		<Project filename="ModIRC.cbp" />
 | 
							<Project filename="ModIRC.cbp" />
 | 
				
			||||||
		<Project filename="ModXML.cbp" />
 | 
							<Project filename="ModXML.cbp" />
 | 
				
			||||||
 | 
							<Project filename="ModJSON.cbp" />
 | 
				
			||||||
		<Project filename="ModSQLite.cbp" />
 | 
							<Project filename="ModSQLite.cbp" />
 | 
				
			||||||
		<Project filename="ModMMDB.cbp" />
 | 
							<Project filename="ModMMDB.cbp" />
 | 
				
			||||||
		<Project filename="ModSample.cbp" />
 | 
							<Project filename="ModSample.cbp" />
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										16
									
								
								external/Mongoose/LICENSE
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								external/Mongoose/LICENSE
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					Copyright (c) 2004-2013 Sergey Lyubka <valenok@gmail.com>
 | 
				
			||||||
 | 
					Copyright (c) 2013-2016 Cesanta Software Limited
 | 
				
			||||||
 | 
					All rights reserved
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					This software is dual-licensed: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					it under the terms of the GNU General Public License version 2 as
 | 
				
			||||||
 | 
					published by the Free Software Foundation. For the terms of this
 | 
				
			||||||
 | 
					license, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You are free to use this software under the terms of the GNU General
 | 
				
			||||||
 | 
					Public License, but WITHOUT ANY WARRANTY; without even the implied
 | 
				
			||||||
 | 
					warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 | 
				
			||||||
 | 
					See the GNU General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Alternatively, you can license this software under a commercial
 | 
				
			||||||
 | 
					license, as set out in <https://www.cesanta.com/license>.
 | 
				
			||||||
							
								
								
									
										11074
									
								
								external/Mongoose/mongoose.c
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11074
									
								
								external/Mongoose/mongoose.c
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										3650
									
								
								include/mongoose.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3650
									
								
								include/mongoose.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -94,7 +94,7 @@ void DocumentRef::Validate() const
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
SQInteger IniResult::Typename(HSQUIRRELVM vm)
 | 
					SQInteger IniResult::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SQChar name[] = _SC("SqIniResult");
 | 
					    static const SQChar name[] = _SC("SqIniResult");
 | 
				
			||||||
    sq_pushstring(vm, name, sizeof(name));
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ namespace SqMod {
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
SQInteger Document::Typename(HSQUIRRELVM vm)
 | 
					SQInteger Document::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SQChar name[] = _SC("SqIniDocument");
 | 
					    static const SQChar name[] = _SC("SqIniDocument");
 | 
				
			||||||
    sq_pushstring(vm, name, sizeof(name));
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@ namespace SqMod {
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
SQInteger Entries::Typename(HSQUIRRELVM vm)
 | 
					SQInteger Entries::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SQChar name[] = _SC("SqIniEntries");
 | 
					    static const SQChar name[] = _SC("SqIniEntries");
 | 
				
			||||||
    sq_pushstring(vm, name, sizeof(name));
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -96,7 +96,7 @@ void OnSquirrelLoad()
 | 
				
			|||||||
void OnSquirrelTerminate()
 | 
					void OnSquirrelTerminate()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    OutputMessage("Terminating: %s", SQINI_NAME);
 | 
					    OutputMessage("Terminating: %s", SQINI_NAME);
 | 
				
			||||||
    // Release the current database (if any)
 | 
					    // Release the current virtual machine, if any
 | 
				
			||||||
    DefaultVM::Set(nullptr);
 | 
					    DefaultVM::Set(nullptr);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -98,7 +98,7 @@ void OnSquirrelTerminate()
 | 
				
			|||||||
    OutputMessage("Terminating: %s", SQIRC_NAME);
 | 
					    OutputMessage("Terminating: %s", SQIRC_NAME);
 | 
				
			||||||
    // Terminate all session and release script resources
 | 
					    // Terminate all session and release script resources
 | 
				
			||||||
    Session::Terminate();
 | 
					    Session::Terminate();
 | 
				
			||||||
    // Release the current database (if any)
 | 
					    // Release the current virtual machine, if any
 | 
				
			||||||
    DefaultVM::Set(nullptr);
 | 
					    DefaultVM::Set(nullptr);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,7 +26,7 @@ Session::Sessions   Session::s_Sessions;
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
SQInteger Session::Typename(HSQUIRRELVM vm)
 | 
					SQInteger Session::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SQChar name[] = _SC("SqIrcSession");
 | 
					    static const SQChar name[] = _SC("SqIrcSession");
 | 
				
			||||||
    sq_pushstring(vm, name, sizeof(name));
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										175
									
								
								modules/json/Common.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										175
									
								
								modules/json/Common.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,175 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					#include "Module.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <cstdlib>
 | 
				
			||||||
 | 
					#include <cstring>
 | 
				
			||||||
 | 
					#include <cstdarg>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <sqrat.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					static SQChar g_Buffer[4096]; // Common buffer to reduce memory allocations.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					SStr GetTempBuff()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return g_Buffer;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Uint32 GetTempBuffSize()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return sizeof(g_Buffer);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void SqThrowF(CSStr str, ...)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialize the argument list
 | 
				
			||||||
 | 
					    va_list args;
 | 
				
			||||||
 | 
					    va_start (args, str);
 | 
				
			||||||
 | 
					    // Write the requested contents
 | 
				
			||||||
 | 
					    if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        std::strcpy(g_Buffer, "Unknown error has occurred");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Release the argument list
 | 
				
			||||||
 | 
					    va_end(args);
 | 
				
			||||||
 | 
					    // Throw the exception with the resulted message
 | 
				
			||||||
 | 
					    throw Sqrat::Exception(g_Buffer);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					CSStr FmtStr(CSStr str, ...)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialize the argument list
 | 
				
			||||||
 | 
					    va_list args;
 | 
				
			||||||
 | 
					    va_start (args, str);
 | 
				
			||||||
 | 
					    // Write the requested contents
 | 
				
			||||||
 | 
					    if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        g_Buffer[0] = '\0'; // Make sure the string is terminated
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Release the argument list
 | 
				
			||||||
 | 
					    va_end(args);
 | 
				
			||||||
 | 
					    // Return the data from the buffer
 | 
				
			||||||
 | 
					    return g_Buffer;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					StackGuard::StackGuard()
 | 
				
			||||||
 | 
					    : m_VM(_SqVM), m_Top(sq_gettop(m_VM))
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* ... */
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					StackGuard::StackGuard(HSQUIRRELVM vm)
 | 
				
			||||||
 | 
					    : m_VM(vm), m_Top(sq_gettop(vm))
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* ... */
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					StackGuard::~StackGuard()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    sq_pop(m_VM, sq_gettop(m_VM) - m_Top);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					StackStrF::StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt)
 | 
				
			||||||
 | 
					    : mPtr(nullptr)
 | 
				
			||||||
 | 
					    , mLen(-1)
 | 
				
			||||||
 | 
					    , mRes(SQ_OK)
 | 
				
			||||||
 | 
					    , mObj()
 | 
				
			||||||
 | 
					    , mVM(vm)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const Int32 top = sq_gettop(vm);
 | 
				
			||||||
 | 
					    // Reset the converted value object
 | 
				
			||||||
 | 
					    sq_resetobject(&mObj);
 | 
				
			||||||
 | 
					    // Was the string or value specified?
 | 
				
			||||||
 | 
					    if (top <= (idx - 1))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        mRes = sq_throwerror(vm, "Missing string or value");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Do we have enough values to call the format function and are we allowed to?
 | 
				
			||||||
 | 
					    else if (top > idx && fmt)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Pointer to the generated string
 | 
				
			||||||
 | 
					        SStr str = nullptr;
 | 
				
			||||||
 | 
					        // Attempt to generate the specified string format
 | 
				
			||||||
 | 
					        mRes = sqstd_format(vm, idx, &mLen, &str);
 | 
				
			||||||
 | 
					        // Did the format succeeded but ended up with a null string pointer?
 | 
				
			||||||
 | 
					        if (SQ_SUCCEEDED(mRes) && !str)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            mRes = sq_throwerror(vm, "Unable to generate the string");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            mPtr = const_cast< CSStr >(str);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Is the value on the stack an actual string?
 | 
				
			||||||
 | 
					    else if (sq_gettype(vm, idx) == OT_STRING)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Obtain a reference to the string object
 | 
				
			||||||
 | 
					        mRes = sq_getstackobj(vm, idx, &mObj);
 | 
				
			||||||
 | 
					        // Could we retrieve the object from the stack?
 | 
				
			||||||
 | 
					        if (SQ_SUCCEEDED(mRes))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // Keep a strong reference to the object
 | 
				
			||||||
 | 
					            sq_addref(vm, &mObj);
 | 
				
			||||||
 | 
					            // Attempt to retrieve the string value from the stack
 | 
				
			||||||
 | 
					            mRes = sq_getstring(vm, idx, &mPtr);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        // Did the retrieval succeeded but ended up with a null string pointer?
 | 
				
			||||||
 | 
					        if (SQ_SUCCEEDED(mRes) && !mPtr)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            mRes = sq_throwerror(vm, "Unable to retrieve the string");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // We have to try and convert it to string
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Attempt to convert the value from the stack to a string
 | 
				
			||||||
 | 
					        mRes = sq_tostring(vm, idx);
 | 
				
			||||||
 | 
					        // Could we convert the specified value to string?
 | 
				
			||||||
 | 
					        if (SQ_SUCCEEDED(mRes))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // Obtain a reference to the resulted object
 | 
				
			||||||
 | 
					            mRes = sq_getstackobj(vm, -1, &mObj);
 | 
				
			||||||
 | 
					            // Could we retrieve the object from the stack?
 | 
				
			||||||
 | 
					            if (SQ_SUCCEEDED(mRes))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // Keep a strong reference to the object
 | 
				
			||||||
 | 
					                sq_addref(vm, &mObj);
 | 
				
			||||||
 | 
					                // Attempt to obtain the string pointer
 | 
				
			||||||
 | 
					                mRes = sq_getstring(vm, -1, &mPtr);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        // Pop a value from the stack regardless of the result
 | 
				
			||||||
 | 
					        sq_pop(vm, 1);
 | 
				
			||||||
 | 
					        // Did the retrieval succeeded but ended up with a null string pointer?
 | 
				
			||||||
 | 
					        if (SQ_SUCCEEDED(mRes) && !mPtr)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            mRes = sq_throwerror(vm, "Unable to retrieve the value");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					StackStrF::~StackStrF()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (mVM && !sq_isnull(mObj))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        sq_release(mVM, &mObj);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										140
									
								
								modules/json/Common.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								modules/json/Common.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,140 @@
 | 
				
			|||||||
 | 
					#ifndef _SQJSON_COMMON_HPP_
 | 
				
			||||||
 | 
					#define _SQJSON_COMMON_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "ModBase.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <squirrel.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * SOFTWARE INFORMATION
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					#define SQJSON_NAME "Squirrel JSON Module"
 | 
				
			||||||
 | 
					#define SQJSON_AUTHOR "Sandu Liviu Catalin (S.L.C)"
 | 
				
			||||||
 | 
					#define SQJSON_COPYRIGHT "Copyright (C) 2016 Sandu Liviu Catalin"
 | 
				
			||||||
 | 
					#define SQJSON_HOST_NAME "SqModJSONHost"
 | 
				
			||||||
 | 
					#define SQJSON_VERSION 001
 | 
				
			||||||
 | 
					#define SQJSON_VERSION_STR "0.0.1"
 | 
				
			||||||
 | 
					#define SQJSON_VERSION_MAJOR 0
 | 
				
			||||||
 | 
					#define SQJSON_VERSION_MINOR 0
 | 
				
			||||||
 | 
					#define SQJSON_VERSION_PATCH 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Retrieve the temporary buffer.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					SStr GetTempBuff();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Retrieve the size of the temporary buffer.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					Uint32 GetTempBuffSize();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Throw a formatted exception.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					void SqThrowF(CSStr str, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Generate a formatted string.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					CSStr FmtStr(CSStr str, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Implements RAII to restore the VM stack to it's initial size on function exit.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					struct StackGuard
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Default constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard(HSQUIRRELVM vm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~StackGuard();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard(const StackGuard &);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard(StackGuard &&);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard & operator = (const StackGuard &);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard & operator = (StackGuard &&);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    HSQUIRRELVM m_VM; // The VM where the stack should be restored.
 | 
				
			||||||
 | 
					    Int32       m_Top; // The top of the stack when this instance was created.
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Helper structure for retrieving a value from the stack as a string or a formatted string.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					struct StackStrF
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    CSStr       mPtr; // Pointer to the C string that was retrieved.
 | 
				
			||||||
 | 
					    SQInteger   mLen; // The string length if it could be retrieved.
 | 
				
			||||||
 | 
					    SQRESULT    mRes; // The result of the retrieval attempts.
 | 
				
			||||||
 | 
					    HSQOBJECT   mObj; // Strong reference to the string object.
 | 
				
			||||||
 | 
					    HSQUIRRELVM mVM; // The associated virtual machine.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt = true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF(const StackStrF & o) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF(StackStrF && o) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~StackStrF();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF & operator = (const StackStrF & o) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF & operator = (StackStrF && o) = delete;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQJSON_COMMON_HPP_
 | 
				
			||||||
							
								
								
									
										316
									
								
								modules/json/Module.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										316
									
								
								modules/json/Module.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,316 @@
 | 
				
			|||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Module.hpp"
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <cstdio>
 | 
				
			||||||
 | 
					#include <cstdlib>
 | 
				
			||||||
 | 
					#include <cstring>
 | 
				
			||||||
 | 
					#include <cstdarg>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <sqrat.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#if defined(WIN32) || defined(_WIN32)
 | 
				
			||||||
 | 
					    #include <Windows.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					PluginFuncs*        _Func = nullptr;
 | 
				
			||||||
 | 
					PluginCallbacks*    _Clbk = nullptr;
 | 
				
			||||||
 | 
					PluginInfo*         _Info = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					HSQAPI              _SqAPI = nullptr;
 | 
				
			||||||
 | 
					HSQEXPORTS          _SqMod = nullptr;
 | 
				
			||||||
 | 
					HSQUIRRELVM         _SqVM = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * 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.", SQJSON_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", SQJSON_NAME);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * The virtual machine is about to be terminated and script resources should be released.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					void OnSquirrelTerminate()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    OutputMessage("Terminating: %s", SQJSON_NAME);
 | 
				
			||||||
 | 
					    // Release the current virtual machine, if any
 | 
				
			||||||
 | 
					    DefaultVM::Set(nullptr);
 | 
				
			||||||
 | 
					    // 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 = std::strtol(ver, nullptr, 10);
 | 
				
			||||||
 | 
					    // Check against version mismatch
 | 
				
			||||||
 | 
					    if (vernum == SQMOD_API_VER)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Log the incident
 | 
				
			||||||
 | 
					    OutputError("API version mismatch on %s", SQJSON_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 uint8_t OnPluginCommand(uint32_t command_identifier, CCStr message)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    switch(command_identifier)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        case SQMOD_INITIALIZE_CMD:
 | 
				
			||||||
 | 
					            if (CheckAPIVer(message))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                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 uint8_t OnServerInitialise()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void OnServerShutdown(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // The server may still send callbacks
 | 
				
			||||||
 | 
					    UnbindCallbacks();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void BindCallbacks()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    _Clbk->OnServerInitialise       = OnServerInitialise;
 | 
				
			||||||
 | 
					    _Clbk->OnServerShutdown         = OnServerShutdown;
 | 
				
			||||||
 | 
					    _Clbk->OnPluginCommand          = OnPluginCommand;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void UnbindCallbacks()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    _Clbk->OnServerInitialise       = nullptr;
 | 
				
			||||||
 | 
					    _Clbk->OnServerShutdown         = nullptr;
 | 
				
			||||||
 | 
					    _Clbk->OnPluginCommand          = nullptr;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void RegisterAPI(HSQUIRRELVM vm)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					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);
 | 
				
			||||||
 | 
					    std::printf("[SQMOD] ");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::puts("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    std::printf("%c[0;32m[SQMOD]%c[0m", 27, 27);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::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);
 | 
				
			||||||
 | 
					    std::printf("[SQMOD] ");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::puts("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    std::printf("%c[0;91m[SQMOD]%c[0m", 27, 27);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::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
 | 
				
			||||||
 | 
					    std::puts("");
 | 
				
			||||||
 | 
					    OutputMessage("--------------------------------------------------------------------");
 | 
				
			||||||
 | 
					    OutputMessage("Plugin: %s", SQJSON_NAME);
 | 
				
			||||||
 | 
					    OutputMessage("Author: %s", SQJSON_AUTHOR);
 | 
				
			||||||
 | 
					    OutputMessage("Legal: %s", SQJSON_COPYRIGHT);
 | 
				
			||||||
 | 
					    OutputMessage("--------------------------------------------------------------------");
 | 
				
			||||||
 | 
					    std::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", SQJSON_NAME);
 | 
				
			||||||
 | 
					        // Don't load!
 | 
				
			||||||
 | 
					        return SQMOD_FAILURE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Should never reach this point but just in case
 | 
				
			||||||
 | 
					    else if (static_cast< Uint32 >(host_plugin_id) > info->pluginId)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        OutputError("%s loaded after the host plugin", SQJSON_NAME);
 | 
				
			||||||
 | 
					        // Don't load!
 | 
				
			||||||
 | 
					        return SQMOD_FAILURE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Store server proxies
 | 
				
			||||||
 | 
					    _Func = functions;
 | 
				
			||||||
 | 
					    _Clbk = callbacks;
 | 
				
			||||||
 | 
					    _Info = info;
 | 
				
			||||||
 | 
					    // Assign plugin version
 | 
				
			||||||
 | 
					    _Info->pluginVersion = SQJSON_VERSION;
 | 
				
			||||||
 | 
					    _Info->apiMajorVersion = PLUGIN_API_MAJOR;
 | 
				
			||||||
 | 
					    _Info->apiMinorVersion = PLUGIN_API_MINOR;
 | 
				
			||||||
 | 
					    // Assign the plugin name
 | 
				
			||||||
 | 
					    std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQJSON_HOST_NAME);
 | 
				
			||||||
 | 
					    // Bind callbacks
 | 
				
			||||||
 | 
					    BindCallbacks();
 | 
				
			||||||
 | 
					    // Notify that the plugin was successfully loaded
 | 
				
			||||||
 | 
					    OutputMessage("Successfully loaded %s", SQJSON_NAME);
 | 
				
			||||||
 | 
					    // Dummy spacing
 | 
				
			||||||
 | 
					    std::puts("");
 | 
				
			||||||
 | 
					    // Done!
 | 
				
			||||||
 | 
					    return SQMOD_SUCCESS;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										41
									
								
								modules/json/Module.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								modules/json/Module.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					#ifndef _SQJSON_MODULE_HPP_
 | 
				
			||||||
 | 
					#define _SQJSON_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 // _SQJSON_MODULE_HPP_
 | 
				
			||||||
							
								
								
									
										198
									
								
								modules/mg/Common.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										198
									
								
								modules/mg/Common.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,198 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					#include "Module.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <cstdio>
 | 
				
			||||||
 | 
					#include <cstring>
 | 
				
			||||||
 | 
					#include <cstdlib>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <sqrat.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					static SQChar g_Buffer[4096]; // Common buffer to reduce memory allocations.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					SStr GetTempBuff()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return g_Buffer;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Uint32 GetTempBuffSize()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return sizeof(g_Buffer);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void SqThrowF(CSStr str, ...)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialize the argument list
 | 
				
			||||||
 | 
					    va_list args;
 | 
				
			||||||
 | 
					    va_start (args, str);
 | 
				
			||||||
 | 
					    // Write the requested contents
 | 
				
			||||||
 | 
					    if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        std::strcpy(g_Buffer, "Unknown error has occurred");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Release the argument list
 | 
				
			||||||
 | 
					    va_end(args);
 | 
				
			||||||
 | 
					    // Throw the exception with the resulted message
 | 
				
			||||||
 | 
					    throw Sqrat::Exception(g_Buffer);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					CSStr FmtStr(CSStr str, ...)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialize the argument list
 | 
				
			||||||
 | 
					    va_list args;
 | 
				
			||||||
 | 
					    va_start (args, str);
 | 
				
			||||||
 | 
					    // Write the requested contents
 | 
				
			||||||
 | 
					    if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        g_Buffer[0] = '\0'; // Make sure the string is terminated
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Release the argument list
 | 
				
			||||||
 | 
					    va_end(args);
 | 
				
			||||||
 | 
					    // Return the data from the buffer
 | 
				
			||||||
 | 
					    return g_Buffer;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					StackGuard::StackGuard()
 | 
				
			||||||
 | 
					    : m_VM(_SqVM), m_Top(sq_gettop(m_VM))
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* ... */
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					StackGuard::StackGuard(HSQUIRRELVM vm)
 | 
				
			||||||
 | 
					    : m_VM(vm), m_Top(sq_gettop(vm))
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* ... */
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					StackGuard::~StackGuard()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    sq_pop(m_VM, sq_gettop(m_VM) - m_Top);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					StackStrF::StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt)
 | 
				
			||||||
 | 
					    : mPtr(nullptr)
 | 
				
			||||||
 | 
					    , mLen(-1)
 | 
				
			||||||
 | 
					    , mRes(SQ_OK)
 | 
				
			||||||
 | 
					    , mObj()
 | 
				
			||||||
 | 
					    , mVM(vm)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const Int32 top = sq_gettop(vm);
 | 
				
			||||||
 | 
					    // Reset the converted value object
 | 
				
			||||||
 | 
					    sq_resetobject(&mObj);
 | 
				
			||||||
 | 
					    // Was the string or value specified?
 | 
				
			||||||
 | 
					    if (top <= (idx - 1))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        mRes = sq_throwerror(vm, "Missing string or value");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Do we have enough values to call the format function and are we allowed to?
 | 
				
			||||||
 | 
					    else if (top > idx && fmt)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Pointer to the generated string
 | 
				
			||||||
 | 
					        SStr str = nullptr;
 | 
				
			||||||
 | 
					        // Attempt to generate the specified string format
 | 
				
			||||||
 | 
					        mRes = sqstd_format(vm, idx, &mLen, &str);
 | 
				
			||||||
 | 
					        // Did the format succeeded but ended up with a null string pointer?
 | 
				
			||||||
 | 
					        if (SQ_SUCCEEDED(mRes) && !str)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            mRes = sq_throwerror(vm, "Unable to generate the string");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            mPtr = const_cast< CSStr >(str);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Is the value on the stack an actual string?
 | 
				
			||||||
 | 
					    else if (sq_gettype(vm, idx) == OT_STRING)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Obtain a reference to the string object
 | 
				
			||||||
 | 
					        mRes = sq_getstackobj(vm, idx, &mObj);
 | 
				
			||||||
 | 
					        // Could we retrieve the object from the stack?
 | 
				
			||||||
 | 
					        if (SQ_SUCCEEDED(mRes))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // Keep a strong reference to the object
 | 
				
			||||||
 | 
					            sq_addref(vm, &mObj);
 | 
				
			||||||
 | 
					            // Attempt to retrieve the string value from the stack
 | 
				
			||||||
 | 
					            mRes = sq_getstring(vm, idx, &mPtr);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        // Did the retrieval succeeded but ended up with a null string pointer?
 | 
				
			||||||
 | 
					        if (SQ_SUCCEEDED(mRes) && !mPtr)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            mRes = sq_throwerror(vm, "Unable to retrieve the string");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // We have to try and convert it to string
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Attempt to convert the value from the stack to a string
 | 
				
			||||||
 | 
					        mRes = sq_tostring(vm, idx);
 | 
				
			||||||
 | 
					        // Could we convert the specified value to string?
 | 
				
			||||||
 | 
					        if (SQ_SUCCEEDED(mRes))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // Obtain a reference to the resulted object
 | 
				
			||||||
 | 
					            mRes = sq_getstackobj(vm, -1, &mObj);
 | 
				
			||||||
 | 
					            // Could we retrieve the object from the stack?
 | 
				
			||||||
 | 
					            if (SQ_SUCCEEDED(mRes))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // Keep a strong reference to the object
 | 
				
			||||||
 | 
					                sq_addref(vm, &mObj);
 | 
				
			||||||
 | 
					                // Attempt to obtain the string pointer
 | 
				
			||||||
 | 
					                mRes = sq_getstring(vm, -1, &mPtr);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        // Pop a value from the stack regardless of the result
 | 
				
			||||||
 | 
					        sq_pop(vm, 1);
 | 
				
			||||||
 | 
					        // Did the retrieval succeeded but ended up with a null string pointer?
 | 
				
			||||||
 | 
					        if (SQ_SUCCEEDED(mRes) && !mPtr)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            mRes = sq_throwerror(vm, "Unable to retrieve the value");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Object & NullObject()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static Object o;
 | 
				
			||||||
 | 
					    o.Release();
 | 
				
			||||||
 | 
					    return o;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Table & NullTable()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static Table t;
 | 
				
			||||||
 | 
					    t.Release();
 | 
				
			||||||
 | 
					    return t;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Array & NullArray()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static Array a;
 | 
				
			||||||
 | 
					    a.Release();
 | 
				
			||||||
 | 
					    return a;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Function & NullFunction()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static Function f;
 | 
				
			||||||
 | 
					    f.Release();
 | 
				
			||||||
 | 
					    return f;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										229
									
								
								modules/mg/Common.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										229
									
								
								modules/mg/Common.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,229 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMG_COMMON_HPP_
 | 
				
			||||||
 | 
					#define _SQMG_COMMON_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "ModBase.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <cstdio>
 | 
				
			||||||
 | 
					#include <cstdlib>
 | 
				
			||||||
 | 
					#include <cstring>
 | 
				
			||||||
 | 
					#include <cstdarg>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <squirrel.h>
 | 
				
			||||||
 | 
					#include <mongoose.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * SOFTWARE INFORMATION
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					#define SQMG_NAME "Squirrel Mongoose Module"
 | 
				
			||||||
 | 
					#define SQMG_AUTHOR "Sandu Liviu Catalin (S.L.C)"
 | 
				
			||||||
 | 
					#define SQMG_COPYRIGHT "Copyright (C) 2016 Sandu Liviu Catalin"
 | 
				
			||||||
 | 
					#define SQMG_HOST_NAME "SqModMongooseHost"
 | 
				
			||||||
 | 
					#define SQMG_VERSION 001
 | 
				
			||||||
 | 
					#define SQMG_VERSION_STR "0.0.1"
 | 
				
			||||||
 | 
					#define SQMG_VERSION_MAJOR 0
 | 
				
			||||||
 | 
					#define SQMG_VERSION_MINOR 0
 | 
				
			||||||
 | 
					#define SQMG_VERSION_PATCH 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Retrieve the temporary buffer.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					SStr GetTempBuff();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Retrieve the size of the temporary buffer.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					Uint32 GetTempBuffSize();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Throw a formatted exception.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					void SqThrowF(CSStr str, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Generate a formatted string.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					CSStr FmtStr(CSStr str, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Implements RAII to restore the VM stack to it's initial size on function exit.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					struct StackGuard
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Default constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard(HSQUIRRELVM vm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~StackGuard();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard(const StackGuard &);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard(StackGuard &&);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard & operator = (const StackGuard &);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard & operator = (StackGuard &&);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    HSQUIRRELVM m_VM; // The VM where the stack should be restored.
 | 
				
			||||||
 | 
					    Int32       m_Top; // The top of the stack when this instance was created.
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Helper structure for retrieving a value from the stack as a string or a formatted string.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					struct StackStrF
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    CSStr       mPtr; // Pointer to the C string that was retrieved.
 | 
				
			||||||
 | 
					    SQInteger   mLen; // The string length if it could be retrieved.
 | 
				
			||||||
 | 
					    SQRESULT    mRes; // The result of the retrieval attempts.
 | 
				
			||||||
 | 
					    HSQOBJECT   mObj; // Strong reference to the string object.
 | 
				
			||||||
 | 
					    HSQUIRRELVM mVM; // The associated virtual machine.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt = true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF(const StackStrF & o) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF(StackStrF && o) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~StackStrF();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF & operator = (const StackStrF & o) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF & operator = (StackStrF && o) = delete;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Retrieve a reference to a null script object.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					Object & NullObject();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Retrieve a reference to a null/empty script table.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					Table & NullTable();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Retrieve a reference to a null/empty script array.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					Array & NullArray();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Retrieve a reference to a null script function.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					Function & NullFunction();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					enum struct HndInit
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    InitHnd = 0
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					class Manager;
 | 
				
			||||||
 | 
					class Connection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Types of events supported by a connection.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					enum ConnectionEvents
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    MGEV_UNKNOWN = SQMOD_UNKNOWN,
 | 
				
			||||||
 | 
					    MGCE_POLL,
 | 
				
			||||||
 | 
					    MGCE_ACCEPT,
 | 
				
			||||||
 | 
					    MGCE_CONNECT,
 | 
				
			||||||
 | 
					    MGCE_RECV,
 | 
				
			||||||
 | 
					    MGCE_SEND,
 | 
				
			||||||
 | 
					    MGCE_CLOSE,
 | 
				
			||||||
 | 
					    MGCE_TIMER,
 | 
				
			||||||
 | 
					    MGCE_HTTP_REQUEST,
 | 
				
			||||||
 | 
					    MGCE_HTTP_REPLY,
 | 
				
			||||||
 | 
					    MGCE_HTTP_CHUNK,
 | 
				
			||||||
 | 
					    MGCE_SSI_CALL,
 | 
				
			||||||
 | 
					    MGCE_WEBSOCKET_HANDSHAKE_REQUEST,
 | 
				
			||||||
 | 
					    MGCE_WEBSOCKET_HANDSHAKE_DONE,
 | 
				
			||||||
 | 
					    MGCE_WEBSOCKET_FRAME,
 | 
				
			||||||
 | 
					    MGCE_WEBSOCKET_CONTROL_FRAME,
 | 
				
			||||||
 | 
					    MGCE_HTTP_MULTIPART_REQUEST,
 | 
				
			||||||
 | 
					    MGCE_HTTP_PART_BEGIN,
 | 
				
			||||||
 | 
					    MGCE_HTTP_PART_DATA,
 | 
				
			||||||
 | 
					    MGCE_HTTP_PART_END,
 | 
				
			||||||
 | 
					    MGCE_MQTT_CONNECT,
 | 
				
			||||||
 | 
					    MGCE_MQTT_CONNACK,
 | 
				
			||||||
 | 
					    MGCE_MQTT_PUBLISH,
 | 
				
			||||||
 | 
					    MGCE_MQTT_PUBACK,
 | 
				
			||||||
 | 
					    MGCE_MQTT_PUBREC,
 | 
				
			||||||
 | 
					    MGCE_MQTT_PUBREL,
 | 
				
			||||||
 | 
					    MGCE_MQTT_PUBCOMP,
 | 
				
			||||||
 | 
					    MGCE_MQTT_SUBSCRIBE,
 | 
				
			||||||
 | 
					    MGCE_MQTT_SUBACK,
 | 
				
			||||||
 | 
					    MGCE_MQTT_UNSUBSCRIBE,
 | 
				
			||||||
 | 
					    MGCE_MQTT_UNSUBACK,
 | 
				
			||||||
 | 
					    MGCE_MQTT_PINGREQ,
 | 
				
			||||||
 | 
					    MGCE_MQTT_PINGRESP,
 | 
				
			||||||
 | 
					    MGCE_MQTT_DISCONNECT,
 | 
				
			||||||
 | 
					    MGCE_MQTT_CONNACK_ACCEPTED,
 | 
				
			||||||
 | 
					    MGCE_MQTT_CONNACK_UNACCEPTABLE_VERSION,
 | 
				
			||||||
 | 
					    MGCE_MQTT_CONNACK_IDENTIFIER_REJECTED,
 | 
				
			||||||
 | 
					    MGCE_MQTT_CONNACK_SERVER_UNAVAILABLE,
 | 
				
			||||||
 | 
					    MGCE_MQTT_CONNACK_BAD_AUTH,
 | 
				
			||||||
 | 
					    MGCE_MQTT_CONNACK_NOT_AUTHORIZED,
 | 
				
			||||||
 | 
					    MGCE_COAP_CON,
 | 
				
			||||||
 | 
					    MGCE_COAP_NOC,
 | 
				
			||||||
 | 
					    MGCE_COAP_ACK,
 | 
				
			||||||
 | 
					    MGCE_COAP_RST,
 | 
				
			||||||
 | 
					    MGCE_MAX
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMG_COMMON_HPP_
 | 
				
			||||||
							
								
								
									
										45
									
								
								modules/mg/Connection.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								modules/mg/Connection.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Connection.hpp"
 | 
				
			||||||
 | 
					#include "Manager.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <sqrat.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					SQInteger Connection::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static const SQChar name[] = _SC("SqMgConnection");
 | 
				
			||||||
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Int32 Connection::Cmp(const Connection & o) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (m_Handle == o.m_Handle)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else if (m_Handle.HndPtr() > o.m_Handle.HndPtr())
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void Connection::Bind(Int32 ev, Object & env, Function & func) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										94
									
								
								modules/mg/Connection.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								modules/mg/Connection.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMG_CONNECTION_HPP_
 | 
				
			||||||
 | 
					#define _SQMG_CONNECTION_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Handles.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Allows management of the connection handle.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class Connection
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    ConnectionHnd   m_Handle; // Reference to the connection instance.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Default constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection()
 | 
				
			||||||
 | 
					        : m_Handle()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Handle constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection(const ConnectionHnd & c)
 | 
				
			||||||
 | 
					        : m_Handle(c)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection(const Connection & o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection(Connection && o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~Connection()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Let the reference handle the deallocation!
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection & operator = (const Connection & o);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection & operator = (Connection && o);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Used by the script engine to compare two instances of this type.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Int32 Cmp(const Connection & 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.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    static SQInteger Typename(HSQUIRRELVM vm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Bind to an event emitted by this connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Bind(Int32 ev, Object & env, Function & func) const;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMG_CONNECTION_HPP_
 | 
				
			||||||
							
								
								
									
										42
									
								
								modules/mg/HTTP.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								modules/mg/HTTP.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "HTTP.hpp"
 | 
				
			||||||
 | 
					#include "Manager.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <sqrat.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					SQInteger HTTP::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static const SQChar name[] = _SC("SqMgHTTP");
 | 
				
			||||||
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Int32 HTTP::Cmp(const HTTP & o) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (m_Handle == o.m_Handle)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else if (m_Handle.HndPtr() > o.m_Handle.HndPtr())
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										94
									
								
								modules/mg/HTTP.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								modules/mg/HTTP.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMG_HTTP_HPP_
 | 
				
			||||||
 | 
					#define _SQMG_HTTP_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Handles.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Allows management of the connection handle.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class HTTP
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    ConnectionHnd   m_Handle; // Reference to the connection instance.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Default constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    HTTP()
 | 
				
			||||||
 | 
					        : m_Handle()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Handle constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    HTTP(const ConnectionHnd & c)
 | 
				
			||||||
 | 
					        : m_Handle(c)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    HTTP(const HTTP & o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    HTTP(HTTP && o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~HTTP()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Let the reference handle the deallocation!
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    HTTP & operator = (const HTTP & o);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    HTTP & operator = (HTTP && o);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Used by the script engine to compare two instances of this type.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Int32 Cmp(const HTTP & 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.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    static SQInteger Typename(HSQUIRRELVM vm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMG_HTTP_HPP_
 | 
				
			||||||
							
								
								
									
										249
									
								
								modules/mg/Handles.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										249
									
								
								modules/mg/Handles.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,249 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Handles.hpp"
 | 
				
			||||||
 | 
					#include "Module.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <ctime>
 | 
				
			||||||
 | 
					#include <algorithm>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					ManagerHnd::Managers ManagerHnd::s_Managers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void ManagerHnd::Validate() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Is the handle valid?
 | 
				
			||||||
 | 
					    if ((m_Hnd == nullptr))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        STHROWF("Invalid Mongoose manager reference");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void ManagerHnd::Validate(CSStr act) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Is the handle valid?
 | 
				
			||||||
 | 
					    if ((m_Hnd == nullptr))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        STHROWF("Invalid Mongoose manager reference while: %s", act);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					ManagerHnd::Handle::Handle()
 | 
				
			||||||
 | 
					    : mMgr()
 | 
				
			||||||
 | 
					    , mRef(1)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialize event manager object
 | 
				
			||||||
 | 
					    mg_mgr_init(&mMgr, this);
 | 
				
			||||||
 | 
					    // Add this instance to the pool
 | 
				
			||||||
 | 
					    s_Managers.push_back(this);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					ManagerHnd::Handle::~Handle()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Attempt to release manager resources
 | 
				
			||||||
 | 
					    mg_mgr_free(&mMgr);
 | 
				
			||||||
 | 
					    // Remove this from the pool
 | 
				
			||||||
 | 
					    s_Managers.erase(std::remove(s_Managers.begin(), s_Managers.end(), this), s_Managers.end());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Int64 ManagerHnd::Handle::Pool(Int32 milli)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Pool the manager for events and store the returned timestamp
 | 
				
			||||||
 | 
					    std::time_t timestamp = mg_mgr_poll(&mMgr, milli);
 | 
				
			||||||
 | 
					    // Create a tm structure pointing to the unix epoch time
 | 
				
			||||||
 | 
					    std::tm epoch_strt;
 | 
				
			||||||
 | 
					    epoch_strt.tm_sec = 0;
 | 
				
			||||||
 | 
					    epoch_strt.tm_min = 0;
 | 
				
			||||||
 | 
					    epoch_strt.tm_hour = 0;
 | 
				
			||||||
 | 
					    epoch_strt.tm_mday = 1;
 | 
				
			||||||
 | 
					    epoch_strt.tm_mon = 0;
 | 
				
			||||||
 | 
					    epoch_strt.tm_year = 70;
 | 
				
			||||||
 | 
					    epoch_strt.tm_isdst = -1;
 | 
				
			||||||
 | 
					    // Convert it to a time structure
 | 
				
			||||||
 | 
					    std::time_t basetime = std::mktime(&epoch_strt);
 | 
				
			||||||
 | 
					    // Return obtained timestamp
 | 
				
			||||||
 | 
					    return  static_cast< Int64 >(std::difftime(timestamp, basetime));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void ConnectionHnd::Validate() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Is the handle valid?
 | 
				
			||||||
 | 
					    if ((m_Hnd == nullptr))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        STHROWF("Invalid Mongoose connection reference");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void ConnectionHnd::Validate(CSStr act) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Is the handle valid?
 | 
				
			||||||
 | 
					    if ((m_Hnd == nullptr))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        STHROWF("Invalid Mongoose connection reference while: %s", act);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void ConnectionHnd::EvFwd(Pointer nc, Int32 ev_type, void * ev_data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (!nc->user_data)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        _SqMod->LogErr("Event dispatched without valid instance");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        static_cast< Handle * >(nc->user_data)->Event(ev_type, ev_data);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					ConnectionHnd::Handle::Handle(Pointer con)
 | 
				
			||||||
 | 
					    : mCon(con)
 | 
				
			||||||
 | 
					    , mRef(1)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Validate the connection handle
 | 
				
			||||||
 | 
					    if (!mCon)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        STHROWF("Invalid Mongoose connection handle");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Associate with the connection instance
 | 
				
			||||||
 | 
					    mCon->user_data = this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					ConnectionHnd::Handle::~Handle()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Tell the manager to close this connection as soon as possible
 | 
				
			||||||
 | 
					    mCon->flags |= MG_F_CLOSE_IMMEDIATELY;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void ConnectionHnd::Handle::Event(Int32 ev_type, void * ev_data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    switch (ev_type)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        case MG_EV_POLL:
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!mOnPOLL.IsNull())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                mOnPOLL.Execute();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case MG_EV_ACCEPT:
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!mOnACCEPT.IsNull())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                mOnACCEPT.Execute();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case MG_EV_CONNECT:
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!mOnCONNECT.IsNull())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                mOnCONNECT.Execute(*static_cast< Int32 * >(ev_data));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case MG_EV_RECV:
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!mOnRECV.IsNull())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                mOnRECV.Execute(*static_cast< Int32 * >(ev_data));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case MG_EV_SEND:
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!mOnSEND.IsNull())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                mOnSEND.Execute(*static_cast< Int32 * >(ev_data));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case MG_EV_CLOSE:
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!mOnCLOSE.IsNull())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                mOnCLOSE.Execute();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        case MG_EV_TIMER:
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!mOnTIMER.IsNull())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                mOnTIMER.Execute();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!mOnUNKNOWN.IsNull())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                mOnUNKNOWN.Execute();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Function & ConnectionHnd::Handle::GetEvent(Int32 ev_type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Identify the requested event type
 | 
				
			||||||
 | 
					    switch (ev_type)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        case MGCE_POLL:                                 return mOnPOLL;
 | 
				
			||||||
 | 
					        case MGCE_ACCEPT:                               return mOnACCEPT;
 | 
				
			||||||
 | 
					        case MGCE_CONNECT:                              return mOnCONNECT;
 | 
				
			||||||
 | 
					        case MGCE_RECV:                                 return mOnRECV;
 | 
				
			||||||
 | 
					        case MGCE_SEND:                                 return mOnSEND;
 | 
				
			||||||
 | 
					        case MGCE_CLOSE:                                return mOnCLOSE;
 | 
				
			||||||
 | 
					        case MGCE_TIMER:                                return mOnTIMER;
 | 
				
			||||||
 | 
					        case MGCE_HTTP_REQUEST:                         return mOnHTTP_REQUEST;
 | 
				
			||||||
 | 
					        case MGCE_HTTP_REPLY:                           return mOnHTTP_REPLY;
 | 
				
			||||||
 | 
					        case MGCE_HTTP_CHUNK:                           return mOnHTTP_CHUNK;
 | 
				
			||||||
 | 
					        case MGCE_SSI_CALL:                             return mOnSSI_CALL;
 | 
				
			||||||
 | 
					        case MGCE_WEBSOCKET_HANDSHAKE_REQUEST:          return mOnWEBSOCKET_HANDSHAKE_REQUEST;
 | 
				
			||||||
 | 
					        case MGCE_WEBSOCKET_HANDSHAKE_DONE:             return mOnWEBSOCKET_HANDSHAKE_DONE;
 | 
				
			||||||
 | 
					        case MGCE_WEBSOCKET_FRAME:                      return mOnWEBSOCKET_FRAME;
 | 
				
			||||||
 | 
					        case MGCE_WEBSOCKET_CONTROL_FRAME:              return mOnWEBSOCKET_CONTROL_FRAME;
 | 
				
			||||||
 | 
					        case MGCE_HTTP_MULTIPART_REQUEST:               return mOnHTTP_MULTIPART_REQUEST;
 | 
				
			||||||
 | 
					        case MGCE_HTTP_PART_BEGIN:                      return mOnHTTP_PART_BEGIN;
 | 
				
			||||||
 | 
					        case MGCE_HTTP_PART_DATA:                       return mOnHTTP_PART_DATA;
 | 
				
			||||||
 | 
					        case MGCE_HTTP_PART_END:                        return mOnHTTP_PART_END;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_CONNECT:                         return mOnMQTT_CONNECT;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_CONNACK:                         return mOnMQTT_CONNACK;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_PUBLISH:                         return mOnMQTT_PUBLISH;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_PUBACK:                          return mOnMQTT_PUBACK;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_PUBREC:                          return mOnMQTT_PUBREC;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_PUBREL:                          return mOnMQTT_PUBREL;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_PUBCOMP:                         return mOnMQTT_PUBCOMP;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_SUBSCRIBE:                       return mOnMQTT_SUBSCRIBE;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_SUBACK:                          return mOnMQTT_SUBACK;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_UNSUBSCRIBE:                     return mOnMQTT_UNSUBSCRIBE;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_UNSUBACK:                        return mOnMQTT_UNSUBACK;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_PINGREQ:                         return mOnMQTT_PINGREQ;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_PINGRESP:                        return mOnMQTT_PINGRESP;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_DISCONNECT:                      return mOnMQTT_DISCONNECT;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_CONNACK_ACCEPTED:                return mOnMQTT_CONNACK_ACCEPTED;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_CONNACK_UNACCEPTABLE_VERSION:    return mOnMQTT_CONNACK_UNACCEPTABLE_VERSION;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_CONNACK_IDENTIFIER_REJECTED:     return mOnMQTT_CONNACK_IDENTIFIER_REJECTED;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_CONNACK_SERVER_UNAVAILABLE:      return mOnMQTT_CONNACK_SERVER_UNAVAILABLE;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_CONNACK_BAD_AUTH:                return mOnMQTT_CONNACK_BAD_AUTH;
 | 
				
			||||||
 | 
					        case MGCE_MQTT_CONNACK_NOT_AUTHORIZED:          return mOnMQTT_CONNACK_NOT_AUTHORIZED;
 | 
				
			||||||
 | 
					        case MGCE_COAP_CON:                             return mOnCOAP_CON;
 | 
				
			||||||
 | 
					        case MGCE_COAP_NOC:                             return mOnCOAP_NOC;
 | 
				
			||||||
 | 
					        case MGCE_COAP_ACK:                             return mOnCOAP_ACK;
 | 
				
			||||||
 | 
					        case MGCE_COAP_RST:                             return mOnCOAP_RST;
 | 
				
			||||||
 | 
					        case MGEV_UNKNOWN:                              return mOnUNKNOWN;
 | 
				
			||||||
 | 
					        default: break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Default to a null function
 | 
				
			||||||
 | 
					    return NullFunction();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										626
									
								
								modules/mg/Handles.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										626
									
								
								modules/mg/Handles.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,626 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMG_HANDLES_HPP_
 | 
				
			||||||
 | 
					#define _SQMG_HANDLES_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <sqrat.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Manages a reference counted manager and its associated resources.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class ManagerHnd
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    friend class Manager;
 | 
				
			||||||
 | 
					    friend class Connection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    typedef mg_mgr                  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.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Validate the manager handle and throw an error if invalid.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Validate() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Validate the manager handle and throw an error if invalid.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Validate(CSStr act) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * The structure that holds the data associated with a physically simulated world.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    struct Handle
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        Type                    mMgr; // The managed manager structure.
 | 
				
			||||||
 | 
					        Counter                 mRef; // Reference count to the managed handles.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Base constructor.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        Handle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Destructor.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        ~Handle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Pool the managed connections for events.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        Int64 Pool(Int32 milli);
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    typedef std::vector< Handle * > Managers; // List of created managers.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    static Managers s_Managers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    Handle* m_Hnd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Grab a strong reference to a connection handle.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Grab()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ++(m_Hnd->mRef);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Drop a strong reference to a connection handle.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Drop()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd && --(m_Hnd->mRef) == 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            delete m_Hnd; // Let the destructor take care of cleaning up (if necessary)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ManagerHnd(HndInit init)
 | 
				
			||||||
 | 
					        : m_Hnd(init == HndInit::InitHnd ? new Handle() : nullptr)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Default constructor (null).
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ManagerHnd()
 | 
				
			||||||
 | 
					        : m_Hnd(nullptr)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Handle constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ManagerHnd(Handle * hnd)
 | 
				
			||||||
 | 
					        : m_Hnd(hnd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Grab();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ManagerHnd(const ManagerHnd & o)
 | 
				
			||||||
 | 
					        : m_Hnd(o.m_Hnd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Grab();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ManagerHnd(ManagerHnd && o)
 | 
				
			||||||
 | 
					        : m_Hnd(o.m_Hnd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        o.m_Hnd = nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~ManagerHnd()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Drop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ManagerHnd & operator = (const ManagerHnd & o)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd != o.m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Drop();
 | 
				
			||||||
 | 
					            m_Hnd = o.m_Hnd;
 | 
				
			||||||
 | 
					            Grab();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ManagerHnd & operator = (ManagerHnd && o)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd != o.m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            m_Hnd = o.m_Hnd;
 | 
				
			||||||
 | 
					            o.m_Hnd = nullptr;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an equality comparison between two connection handles.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator == (const ManagerHnd & o) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd == o.m_Hnd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an inequality comparison between two connection handles.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator != (const ManagerHnd & o) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != o.m_Hnd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to boolean for use in boolean operations.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator bool () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != nullptr);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Pointer ()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != nullptr) ? &(m_Hnd->mMgr) : nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Pointer () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != nullptr) ? &(m_Hnd->mMgr) : nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Reference ()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert((m_Hnd != nullptr));
 | 
				
			||||||
 | 
					        return (m_Hnd->mMgr);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator ConstRef () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert((m_Hnd != nullptr));
 | 
				
			||||||
 | 
					        return (m_Hnd->mMgr);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Member operator for dereferencing the managed pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * operator -> () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd != nullptr);
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Indirection operator for obtaining a reference of the managed pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle & operator * () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd != nullptr);
 | 
				
			||||||
 | 
					        return *m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the raw handle structure pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * HndPtr()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the raw handle structure pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * HndPtr() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the number of active references to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Counter Count() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != nullptr) ? m_Hnd->mRef : 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Manages a reference counted connection and its associated resources.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class ConnectionHnd
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    friend class Manager;
 | 
				
			||||||
 | 
					    friend class Connection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    typedef mg_connection           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.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Validate the connection handle and throw an error if invalid.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Validate() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Validate the connection handle and throw an error if invalid.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Validate(CSStr act) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Forward connection events to the associated instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    static void EvFwd(Pointer nc, Int32 ev_type, void * ev_data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * The structure that holds the data associated with a physically simulated world.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    struct Handle
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        Pointer                 mCon; // The managed connection structure.
 | 
				
			||||||
 | 
					        Counter                 mRef; // Reference count to the managed handles.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        Function                mOnPOLL;
 | 
				
			||||||
 | 
					        Function                mOnACCEPT;
 | 
				
			||||||
 | 
					        Function                mOnCONNECT;
 | 
				
			||||||
 | 
					        Function                mOnRECV;
 | 
				
			||||||
 | 
					        Function                mOnSEND;
 | 
				
			||||||
 | 
					        Function                mOnCLOSE;
 | 
				
			||||||
 | 
					        Function                mOnTIMER;
 | 
				
			||||||
 | 
					        Function                mOnHTTP_REQUEST;
 | 
				
			||||||
 | 
					        Function                mOnHTTP_REPLY;
 | 
				
			||||||
 | 
					        Function                mOnHTTP_CHUNK;
 | 
				
			||||||
 | 
					        Function                mOnSSI_CALL;
 | 
				
			||||||
 | 
					        Function                mOnWEBSOCKET_HANDSHAKE_REQUEST;
 | 
				
			||||||
 | 
					        Function                mOnWEBSOCKET_HANDSHAKE_DONE;
 | 
				
			||||||
 | 
					        Function                mOnWEBSOCKET_FRAME;
 | 
				
			||||||
 | 
					        Function                mOnWEBSOCKET_CONTROL_FRAME;
 | 
				
			||||||
 | 
					        Function                mOnHTTP_MULTIPART_REQUEST;
 | 
				
			||||||
 | 
					        Function                mOnHTTP_PART_BEGIN;
 | 
				
			||||||
 | 
					        Function                mOnHTTP_PART_DATA;
 | 
				
			||||||
 | 
					        Function                mOnHTTP_PART_END;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_CONNECT;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_CONNACK;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_PUBLISH;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_PUBACK;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_PUBREC;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_PUBREL;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_PUBCOMP;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_SUBSCRIBE;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_SUBACK;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_UNSUBSCRIBE;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_UNSUBACK;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_PINGREQ;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_PINGRESP;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_DISCONNECT;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_CONNACK_ACCEPTED;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_CONNACK_UNACCEPTABLE_VERSION;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_CONNACK_IDENTIFIER_REJECTED;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_CONNACK_SERVER_UNAVAILABLE;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_CONNACK_BAD_AUTH;
 | 
				
			||||||
 | 
					        Function                mOnMQTT_CONNACK_NOT_AUTHORIZED;
 | 
				
			||||||
 | 
					        Function                mOnCOAP_CON;
 | 
				
			||||||
 | 
					        Function                mOnCOAP_NOC;
 | 
				
			||||||
 | 
					        Function                mOnCOAP_ACK;
 | 
				
			||||||
 | 
					        Function                mOnCOAP_RST;
 | 
				
			||||||
 | 
					        Function                mOnUNKNOWN;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Base constructor.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        Handle(Pointer con);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Destructor.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        ~Handle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Handle a certain event for this connection.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        void Event(Int32 ev_type, void * ev_data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Retrieve the sript callback associated with a certain identifier.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        Function & GetEvent(Int32 ev_type);
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    Handle* m_Hnd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Grab a strong reference to a connection handle.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Grab()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ++(m_Hnd->mRef);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Drop a strong reference to a connection handle.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Drop()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd && --(m_Hnd->mRef) == 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            delete m_Hnd; // Let the destructor take care of cleaning up (if necessary)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnectionHnd(Pointer con)
 | 
				
			||||||
 | 
					        : m_Hnd(new Handle(con))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Default constructor (null).
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnectionHnd()
 | 
				
			||||||
 | 
					        : m_Hnd(nullptr)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Handle constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnectionHnd(Handle * hnd)
 | 
				
			||||||
 | 
					        : m_Hnd(hnd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Grab();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnectionHnd(const ConnectionHnd & o)
 | 
				
			||||||
 | 
					        : m_Hnd(o.m_Hnd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Grab();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnectionHnd(ConnectionHnd && o)
 | 
				
			||||||
 | 
					        : m_Hnd(o.m_Hnd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        o.m_Hnd = nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~ConnectionHnd()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Drop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnectionHnd & operator = (const ConnectionHnd & o)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd != o.m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Drop();
 | 
				
			||||||
 | 
					            m_Hnd = o.m_Hnd;
 | 
				
			||||||
 | 
					            Grab();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnectionHnd & operator = (ConnectionHnd && o)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd != o.m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            m_Hnd = o.m_Hnd;
 | 
				
			||||||
 | 
					            o.m_Hnd = nullptr;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an equality comparison between two connection handles.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator == (const ConnectionHnd & o) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd == o.m_Hnd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an inequality comparison between two connection handles.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator != (const ConnectionHnd & o) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != o.m_Hnd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to boolean for use in boolean operations.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator bool () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != nullptr);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Pointer ()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != nullptr) ? (m_Hnd->mCon) : nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Pointer () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != nullptr) ? (m_Hnd->mCon) : nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Reference ()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert((m_Hnd != nullptr));
 | 
				
			||||||
 | 
					        return *(m_Hnd->mCon);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator ConstRef () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert((m_Hnd != nullptr));
 | 
				
			||||||
 | 
					        return *(m_Hnd->mCon);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Member operator for dereferencing the managed pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * operator -> () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd != nullptr);
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Indirection operator for obtaining a reference of the managed pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle & operator * () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd != nullptr);
 | 
				
			||||||
 | 
					        return *m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the raw handle structure pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * HndPtr()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the raw handle structure pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * HndPtr() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the number of active references to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Counter Count() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != nullptr) ? m_Hnd->mRef : 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMG_HANDLES_HPP_
 | 
				
			||||||
							
								
								
									
										155
									
								
								modules/mg/Manager.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										155
									
								
								modules/mg/Manager.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,155 @@
 | 
				
			|||||||
 | 
					// -----------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Manager.hpp"
 | 
				
			||||||
 | 
					#include "Connection.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <cstdio>
 | 
				
			||||||
 | 
					#include <cstring>
 | 
				
			||||||
 | 
					#include <cstdlib>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <sqrat.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					SQInteger Manager::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static const SQChar name[] = _SC("SqMgManager");
 | 
				
			||||||
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Int32 Manager::Cmp(const Manager & o) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (m_Handle == o.m_Handle)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else if (m_Handle.HndPtr() > o.m_Handle.HndPtr())
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::Bind(CSStr addr) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return Bind(addr, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::Bind(CSStr addr, Uint32 flags) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Validate the managed handle
 | 
				
			||||||
 | 
					    m_Handle.Validate();
 | 
				
			||||||
 | 
					    // Validate the specified address
 | 
				
			||||||
 | 
					    if (!addr)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        STHROWF("Invalid bind address: null");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Create a binding options structure
 | 
				
			||||||
 | 
					    mg_bind_opts opts;
 | 
				
			||||||
 | 
					    // Initialize the structure to 0
 | 
				
			||||||
 | 
					    std::memset(&opts, 0, sizeof(mg_bind_opts));
 | 
				
			||||||
 | 
					    // Assign the specified flags
 | 
				
			||||||
 | 
					    opts.flags = flags;
 | 
				
			||||||
 | 
					    // Attemmt to create the connection handle
 | 
				
			||||||
 | 
					    mg_connection * connection = mg_bind_opt(m_Handle, addr, ConnectionHnd::EvFwd, opts);
 | 
				
			||||||
 | 
					    // Validate the obtained connection handle
 | 
				
			||||||
 | 
					    if (!connection)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        STHROWF("Unable to create listening connection [%s]", *opts.error_string);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Return the obtained connection
 | 
				
			||||||
 | 
					    return Connection(ConnectionHnd(connection));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::Connect(CSStr addr) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return Connect(addr, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::Connect(CSStr addr, Uint32 flags) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Validate the managed handle
 | 
				
			||||||
 | 
					    m_Handle.Validate();
 | 
				
			||||||
 | 
					    // Validate the specified address
 | 
				
			||||||
 | 
					    if (!addr)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        STHROWF("Invalid bind address: null");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Create a binding options structure
 | 
				
			||||||
 | 
					    mg_connect_opts opts;
 | 
				
			||||||
 | 
					    // Initialize the structure to 0
 | 
				
			||||||
 | 
					    std::memset(&opts, 0, sizeof(mg_connect_opts));
 | 
				
			||||||
 | 
					    // Assign the specified flags
 | 
				
			||||||
 | 
					    opts.flags = flags;
 | 
				
			||||||
 | 
					    // Attemmt to create the connection handle
 | 
				
			||||||
 | 
					    mg_connection * connection = mg_connect_opt(m_Handle, addr, ConnectionHnd::EvFwd, opts);
 | 
				
			||||||
 | 
					    // Validate the obtained connection handle
 | 
				
			||||||
 | 
					    if (!connection)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        STHROWF("Unable to create listening connection [%s]", *opts.error_string);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Return the obtained connection
 | 
				
			||||||
 | 
					    return Connection(ConnectionHnd(connection));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::ConnectWS(CSStr url) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return ConnectWS(url, nullptr, nullptr, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::ConnectWS(CSStr url, CSStr protocol) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return ConnectWS(url, protocol, nullptr, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::ConnectWS(CSStr url, CSStr protocol, CSStr headers) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return ConnectWS(url, protocol, headers, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::ConnectWS(CSStr url, CSStr protocol, CSStr headers, Uint32 flags) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return Connection();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::ConnectHTTP(CSStr url) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return ConnectHTTP(url, nullptr, nullptr, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::ConnectHTTP(CSStr url, CSStr headers) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return ConnectHTTP(url, headers, nullptr, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::ConnectHTTP(CSStr url, CSStr headers, CSStr post) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return ConnectHTTP(url, headers, post, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Connection Manager::ConnectHTTP(CSStr url, CSStr headers, CSStr post, Uint32 flags) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return Connection();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										149
									
								
								modules/mg/Manager.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										149
									
								
								modules/mg/Manager.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,149 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMG_MANAGER_HPP_
 | 
				
			||||||
 | 
					#define _SQMG_MANAGER_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Handles.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Allows management of the connection manager.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class Manager
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    ManagerHnd  m_Handle; // Reference to the manager instance.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Default constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Manager()
 | 
				
			||||||
 | 
					        : m_Handle(HndInit::InitHnd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Handle constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Manager(const ManagerHnd & m)
 | 
				
			||||||
 | 
					        : m_Handle(m)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Manager(const Manager & o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Manager(Manager && o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~Manager()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Let the reference handle the deallocation!
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Manager & operator = (const Manager & o);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Manager & operator = (Manager && o);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Used by the script engine to compare two instances of this type.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Int32 Cmp(const Manager & 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.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    static SQInteger Typename(HSQUIRRELVM vm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Create listening connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection Bind(CSStr addr) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Create listening connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection Bind(CSStr addr, Uint32 flags) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Connect to a remote host.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection Connect(CSStr addr) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Connect to a remote host.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection Connect(CSStr addr, Uint32 flags) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Creates an outbound WebSocket connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection ConnectWS(CSStr url) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Creates an outbound WebSocket connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection ConnectWS(CSStr url, CSStr protocol) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Creates an outbound WebSocket connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection ConnectWS(CSStr url, CSStr protocol, CSStr headers) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Creates an outbound WebSocket connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection ConnectWS(CSStr url, CSStr protocol, CSStr headers, Uint32 flags) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Creates outbound HTTP connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection ConnectHTTP(CSStr url) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Creates outbound HTTP connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection ConnectHTTP(CSStr url, CSStr headers) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Creates outbound HTTP connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection ConnectHTTP(CSStr url, CSStr headers, CSStr post) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Creates outbound HTTP connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection ConnectHTTP(CSStr url, CSStr headers, CSStr post, Uint32 flags) const;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMG_MANAGER_HPP_
 | 
				
			||||||
							
								
								
									
										0
									
								
								modules/mg/Message.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								modules/mg/Message.cpp
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								modules/mg/Message.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								modules/mg/Message.hpp
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										427
									
								
								modules/mg/Module.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										427
									
								
								modules/mg/Module.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,427 @@
 | 
				
			|||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Module.hpp"
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					#include "Manager.hpp"
 | 
				
			||||||
 | 
					#include "Connection.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <cstdio>
 | 
				
			||||||
 | 
					#include <cstdlib>
 | 
				
			||||||
 | 
					#include <cstring>
 | 
				
			||||||
 | 
					#include <cstdarg>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <sqrat.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#if defined(WIN32) || defined(_WIN32)
 | 
				
			||||||
 | 
					    #include <Windows.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					PluginFuncs*        _Func = nullptr;
 | 
				
			||||||
 | 
					PluginCallbacks*    _Clbk = nullptr;
 | 
				
			||||||
 | 
					PluginInfo*         _Info = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					HSQAPI              _SqAPI = nullptr;
 | 
				
			||||||
 | 
					HSQEXPORTS          _SqMod = nullptr;
 | 
				
			||||||
 | 
					HSQUIRRELVM         _SqVM = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * 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.", SQMG_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", SQMG_NAME);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * The virtual machine is about to be terminated and script resources should be released.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					void OnSquirrelTerminate()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    OutputMessage("Terminating: %s", SQMG_NAME);
 | 
				
			||||||
 | 
					    // Release null objects just in case
 | 
				
			||||||
 | 
					    NullObject().Release();
 | 
				
			||||||
 | 
					    NullTable().Release();
 | 
				
			||||||
 | 
					    NullArray().Release();
 | 
				
			||||||
 | 
					    NullFunction().ReleaseGently();
 | 
				
			||||||
 | 
					    // Release the current virtual machine, if any
 | 
				
			||||||
 | 
					    DefaultVM::Set(nullptr);
 | 
				
			||||||
 | 
					    // 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 = std::strtol(ver, nullptr, 10);
 | 
				
			||||||
 | 
					    // Check against version mismatch
 | 
				
			||||||
 | 
					    if (vernum == SQMOD_API_VER)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Log the incident
 | 
				
			||||||
 | 
					    OutputError("API version mismatch on %s", SQMG_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 uint8_t OnPluginCommand(uint32_t command_identifier, CCStr message)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    switch(command_identifier)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        case SQMOD_INITIALIZE_CMD:
 | 
				
			||||||
 | 
					            if (CheckAPIVer(message))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                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 uint8_t OnServerInitialise()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void OnServerShutdown(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // The server may still send callbacks
 | 
				
			||||||
 | 
					    UnbindCallbacks();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void BindCallbacks()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    _Clbk->OnServerInitialise       = OnServerInitialise;
 | 
				
			||||||
 | 
					    _Clbk->OnServerShutdown         = OnServerShutdown;
 | 
				
			||||||
 | 
					    _Clbk->OnPluginCommand          = OnPluginCommand;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void UnbindCallbacks()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    _Clbk->OnServerInitialise       = nullptr;
 | 
				
			||||||
 | 
					    _Clbk->OnServerShutdown         = nullptr;
 | 
				
			||||||
 | 
					    _Clbk->OnPluginCommand          = nullptr;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void RegisterAPI(HSQUIRRELVM vm)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    Table mgns(vm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mgns.Bind(_SC("Manager"), Class< Manager >(vm, _SC("SqMgManager"))
 | 
				
			||||||
 | 
					        // Constructors
 | 
				
			||||||
 | 
					        .Ctor()
 | 
				
			||||||
 | 
					        .Ctor< const Manager & >()
 | 
				
			||||||
 | 
					        // Core Metamethods
 | 
				
			||||||
 | 
					        .Func(_SC("_cmp"), &Manager::Cmp)
 | 
				
			||||||
 | 
					        .SquirrelFunc(_SC("_typename"), &Manager::Typename)
 | 
				
			||||||
 | 
					        .Func(_SC("_tostring"), &Manager::ToString)
 | 
				
			||||||
 | 
					        // Properties
 | 
				
			||||||
 | 
					        //.Prop(_SC("Valid"), &Manager::IsValid)
 | 
				
			||||||
 | 
					        // Member Methods
 | 
				
			||||||
 | 
					        //.Func(_SC("Check"), &Manager::Check)
 | 
				
			||||||
 | 
					        // Overloaded Methods
 | 
				
			||||||
 | 
					        .Overload< Connection (Manager::*)(CSStr) const >(_SC("Bind"), &Manager::Bind)
 | 
				
			||||||
 | 
					        .Overload< Connection (Manager::*)(CSStr, Uint32) const >(_SC("Bind"), &Manager::Bind)
 | 
				
			||||||
 | 
					        .Overload< Connection (Manager::*)(CSStr) const >(_SC("Connect"), &Manager::Connect)
 | 
				
			||||||
 | 
					        .Overload< Connection (Manager::*)(CSStr, Uint32) const >(_SC("Connect"), &Manager::Connect)
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mgns.Bind(_SC("Connection"), Class< Connection >(vm, _SC("SqMgConnection"))
 | 
				
			||||||
 | 
					        // Constructors
 | 
				
			||||||
 | 
					        .Ctor()
 | 
				
			||||||
 | 
					        .Ctor< const Connection & >()
 | 
				
			||||||
 | 
					        // Core Metamethods
 | 
				
			||||||
 | 
					        .Func(_SC("_cmp"), &Connection::Cmp)
 | 
				
			||||||
 | 
					        .SquirrelFunc(_SC("_typename"), &Connection::Typename)
 | 
				
			||||||
 | 
					        .Func(_SC("_tostring"), &Connection::ToString)
 | 
				
			||||||
 | 
					        // Properties
 | 
				
			||||||
 | 
					        //.Prop(_SC("Valid"), &Connection::IsValid)
 | 
				
			||||||
 | 
					        // Member Methods
 | 
				
			||||||
 | 
					        //.Func(_SC("Check"), &Connection::Check)
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RootTable(vm).Bind(_SC("SqMg"), mgns);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ConstTable(vm).Enum(_SC("EMgF"), Enumeration(vm)
 | 
				
			||||||
 | 
					        .Const(_SC("LISTENING"),                MG_F_LISTENING)
 | 
				
			||||||
 | 
					        .Const(_SC("UDP"),                      MG_F_UDP)
 | 
				
			||||||
 | 
					        .Const(_SC("RESOLVING"),                MG_F_RESOLVING)
 | 
				
			||||||
 | 
					        .Const(_SC("CONNECTING"),               MG_F_CONNECTING)
 | 
				
			||||||
 | 
					        .Const(_SC("SSL_HANDSHAKE_DONE"),       MG_F_SSL_HANDSHAKE_DONE)
 | 
				
			||||||
 | 
					        .Const(_SC("WANT_READ"),                MG_F_WANT_READ)
 | 
				
			||||||
 | 
					        .Const(_SC("WANT_WRITE"),               MG_F_WANT_WRITE)
 | 
				
			||||||
 | 
					        .Const(_SC("IS_WEBSOCKET"),             MG_F_IS_WEBSOCKET)
 | 
				
			||||||
 | 
					        .Const(_SC("SEND_AND_CLOSE"),           MG_F_SEND_AND_CLOSE)
 | 
				
			||||||
 | 
					        .Const(_SC("CLOSE_IMMEDIATELY"),        MG_F_CLOSE_IMMEDIATELY)
 | 
				
			||||||
 | 
					        .Const(_SC("WEBSOCKET_NO_DEFRAG"),      MG_F_WEBSOCKET_NO_DEFRAG)
 | 
				
			||||||
 | 
					        .Const(_SC("DELETE_CHUNK"),             MG_F_DELETE_CHUNK)
 | 
				
			||||||
 | 
					        .Const(_SC("USER_1"),                   MG_F_USER_1)
 | 
				
			||||||
 | 
					        .Const(_SC("USER_2"),                   MG_F_USER_2)
 | 
				
			||||||
 | 
					        .Const(_SC("USER_3"),                   MG_F_USER_3)
 | 
				
			||||||
 | 
					        .Const(_SC("USER_4"),                   MG_F_USER_4)
 | 
				
			||||||
 | 
					        .Const(_SC("USER_5"),                   MG_F_USER_5)
 | 
				
			||||||
 | 
					        .Const(_SC("USER_6"),                   MG_F_USER_6)
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ConstTable(vm).Enum(_SC("MgEv"), Enumeration(vm)
 | 
				
			||||||
 | 
					        .Const(_SC("UNKNOWN"),                              static_cast< Int32 >(MGEV_UNKNOWN))
 | 
				
			||||||
 | 
					        .Const(_SC("POLL"),                                 static_cast< Int32 >(MGCE_POLL))
 | 
				
			||||||
 | 
					        .Const(_SC("ACCEPT"),                               static_cast< Int32 >(MGCE_ACCEPT))
 | 
				
			||||||
 | 
					        .Const(_SC("CONNECT"),                              static_cast< Int32 >(MGCE_CONNECT))
 | 
				
			||||||
 | 
					        .Const(_SC("RECV"),                                 static_cast< Int32 >(MGCE_RECV))
 | 
				
			||||||
 | 
					        .Const(_SC("SEND"),                                 static_cast< Int32 >(MGCE_SEND))
 | 
				
			||||||
 | 
					        .Const(_SC("CLOSE"),                                static_cast< Int32 >(MGCE_CLOSE))
 | 
				
			||||||
 | 
					        .Const(_SC("TIMER"),                                static_cast< Int32 >(MGCE_TIMER))
 | 
				
			||||||
 | 
					        .Const(_SC("HTTP_REQUEST"),                         static_cast< Int32 >(MGCE_HTTP_REQUEST))
 | 
				
			||||||
 | 
					        .Const(_SC("HTTP_REPLY"),                           static_cast< Int32 >(MGCE_HTTP_REPLY))
 | 
				
			||||||
 | 
					        .Const(_SC("HTTP_CHUNK"),                           static_cast< Int32 >(MGCE_HTTP_CHUNK))
 | 
				
			||||||
 | 
					        .Const(_SC("SSI_CALL"),                             static_cast< Int32 >(MGCE_SSI_CALL))
 | 
				
			||||||
 | 
					        .Const(_SC("WEBSOCKET_HANDSHAKE_REQUEST"),          static_cast< Int32 >(MGCE_WEBSOCKET_HANDSHAKE_REQUEST))
 | 
				
			||||||
 | 
					        .Const(_SC("WEBSOCKET_HANDSHAKE_DONE"),             static_cast< Int32 >(MGCE_WEBSOCKET_HANDSHAKE_DONE))
 | 
				
			||||||
 | 
					        .Const(_SC("WEBSOCKET_FRAME"),                      static_cast< Int32 >(MGCE_WEBSOCKET_FRAME))
 | 
				
			||||||
 | 
					        .Const(_SC("WEBSOCKET_CONTROL_FRAME"),              static_cast< Int32 >(MGCE_WEBSOCKET_CONTROL_FRAME))
 | 
				
			||||||
 | 
					        .Const(_SC("HTTP_MULTIPART_REQUEST"),               static_cast< Int32 >(MGCE_HTTP_MULTIPART_REQUEST))
 | 
				
			||||||
 | 
					        .Const(_SC("HTTP_PART_BEGIN"),                      static_cast< Int32 >(MGCE_HTTP_PART_BEGIN))
 | 
				
			||||||
 | 
					        .Const(_SC("HTTP_PART_DATA"),                       static_cast< Int32 >(MGCE_HTTP_PART_DATA))
 | 
				
			||||||
 | 
					        .Const(_SC("HTTP_PART_END"),                        static_cast< Int32 >(MGCE_HTTP_PART_END))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_CONNECT"),                         static_cast< Int32 >(MGCE_MQTT_CONNECT))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_CONNACK"),                         static_cast< Int32 >(MGCE_MQTT_CONNACK))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_PUBLISH"),                         static_cast< Int32 >(MGCE_MQTT_PUBLISH))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_PUBACK"),                          static_cast< Int32 >(MGCE_MQTT_PUBACK))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_PUBREC"),                          static_cast< Int32 >(MGCE_MQTT_PUBREC))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_PUBREL"),                          static_cast< Int32 >(MGCE_MQTT_PUBREL))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_PUBCOMP"),                         static_cast< Int32 >(MGCE_MQTT_PUBCOMP))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_SUBSCRIBE"),                       static_cast< Int32 >(MGCE_MQTT_SUBSCRIBE))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_SUBACK"),                          static_cast< Int32 >(MGCE_MQTT_SUBACK))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_UNSUBSCRIBE"),                     static_cast< Int32 >(MGCE_MQTT_UNSUBSCRIBE))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_UNSUBACK"),                        static_cast< Int32 >(MGCE_MQTT_UNSUBACK))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_PINGREQ"),                         static_cast< Int32 >(MGCE_MQTT_PINGREQ))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_PINGRESP"),                        static_cast< Int32 >(MGCE_MQTT_PINGRESP))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_DISCONNECT"),                      static_cast< Int32 >(MGCE_MQTT_DISCONNECT))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_CONNACK_ACCEPTED"),                static_cast< Int32 >(MGCE_MQTT_CONNACK_ACCEPTED))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_CONNACK_UNACCEPTABLE_VERSION"),    static_cast< Int32 >(MGCE_MQTT_CONNACK_UNACCEPTABLE_VERSION))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_CONNACK_IDENTIFIER_REJECTED"),     static_cast< Int32 >(MGCE_MQTT_CONNACK_IDENTIFIER_REJECTED))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_CONNACK_SERVER_UNAVAILABLE"),      static_cast< Int32 >(MGCE_MQTT_CONNACK_SERVER_UNAVAILABLE))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_CONNACK_BAD_AUTH"),                static_cast< Int32 >(MGCE_MQTT_CONNACK_BAD_AUTH))
 | 
				
			||||||
 | 
					        .Const(_SC("MQTT_CONNACK_NOT_AUTHORIZED"),          static_cast< Int32 >(MGCE_MQTT_CONNACK_NOT_AUTHORIZED))
 | 
				
			||||||
 | 
					        .Const(_SC("COAP_CON"),                             static_cast< Int32 >(MGCE_COAP_CON))
 | 
				
			||||||
 | 
					        .Const(_SC("COAP_NOC"),                             static_cast< Int32 >(MGCE_COAP_NOC))
 | 
				
			||||||
 | 
					        .Const(_SC("COAP_ACK"),                             static_cast< Int32 >(MGCE_COAP_ACK))
 | 
				
			||||||
 | 
					        .Const(_SC("COAP_RST"),                             static_cast< Int32 >(MGCE_COAP_RST))
 | 
				
			||||||
 | 
					        .Const(_SC("MAX"),                                  static_cast< Int32 >(MGCE_MAX))
 | 
				
			||||||
 | 
					    );              
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					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);
 | 
				
			||||||
 | 
					    std::printf("[SQMOD] ");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::puts("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    std::printf("%c[0;32m[SQMOD]%c[0m", 27, 27);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::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);
 | 
				
			||||||
 | 
					    std::printf("[SQMOD] ");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::puts("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    std::printf("%c[0;91m[SQMOD]%c[0m", 27, 27);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::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
 | 
				
			||||||
 | 
					    std::puts("");
 | 
				
			||||||
 | 
					    OutputMessage("--------------------------------------------------------------------");
 | 
				
			||||||
 | 
					    OutputMessage("Plugin: %s", SQMG_NAME);
 | 
				
			||||||
 | 
					    OutputMessage("Author: %s", SQMG_AUTHOR);
 | 
				
			||||||
 | 
					    OutputMessage("Legal: %s", SQMG_COPYRIGHT);
 | 
				
			||||||
 | 
					    OutputMessage("--------------------------------------------------------------------");
 | 
				
			||||||
 | 
					    std::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", SQMG_NAME);
 | 
				
			||||||
 | 
					        // Don't load!
 | 
				
			||||||
 | 
					        return SQMOD_FAILURE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Should never reach this point but just in case
 | 
				
			||||||
 | 
					    else if (static_cast< Uint32 >(host_plugin_id) > info->pluginId)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        OutputError("%s loaded after the host plugin", SQMG_NAME);
 | 
				
			||||||
 | 
					        // Don't load!
 | 
				
			||||||
 | 
					        return SQMOD_FAILURE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Store server proxies
 | 
				
			||||||
 | 
					    _Func = functions;
 | 
				
			||||||
 | 
					    _Clbk = callbacks;
 | 
				
			||||||
 | 
					    _Info = info;
 | 
				
			||||||
 | 
					    // Assign plugin version
 | 
				
			||||||
 | 
					    _Info->pluginVersion = SQMG_VERSION;
 | 
				
			||||||
 | 
					    _Info->apiMajorVersion = PLUGIN_API_MAJOR;
 | 
				
			||||||
 | 
					    _Info->apiMinorVersion = PLUGIN_API_MINOR;
 | 
				
			||||||
 | 
					    // Assign the plugin name
 | 
				
			||||||
 | 
					    std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQMG_HOST_NAME);
 | 
				
			||||||
 | 
					    // Bind callbacks
 | 
				
			||||||
 | 
					    BindCallbacks();
 | 
				
			||||||
 | 
					    // Notify that the plugin was successfully loaded
 | 
				
			||||||
 | 
					    OutputMessage("Successfully loaded %s", SQMG_NAME);
 | 
				
			||||||
 | 
					    // Dummy spacing
 | 
				
			||||||
 | 
					    std::puts("");
 | 
				
			||||||
 | 
					    // Done!
 | 
				
			||||||
 | 
					    return SQMOD_SUCCESS;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										41
									
								
								modules/mg/Module.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								modules/mg/Module.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMG_MODULE_HPP_
 | 
				
			||||||
 | 
					#define _SQMG_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 // _SQMG_MODULE_HPP_
 | 
				
			||||||
							
								
								
									
										9
									
								
								modules/mg/Options.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								modules/mg/Options.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Options.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										12
									
								
								modules/mg/Options.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								modules/mg/Options.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					#ifndef _OPTIONS_HPP_
 | 
				
			||||||
 | 
					#define _OPTIONS_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _OPTIONS_HPP_
 | 
				
			||||||
							
								
								
									
										0
									
								
								modules/mg/String.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								modules/mg/String.cpp
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								modules/mg/String.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								modules/mg/String.hpp
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										42
									
								
								modules/mg/WebSocket.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								modules/mg/WebSocket.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "WebSocket.hpp"
 | 
				
			||||||
 | 
					#include "Manager.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <sqrat.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					SQInteger WebSocket::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    static const SQChar name[] = _SC("SqMgWebSocket");
 | 
				
			||||||
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Int32 WebSocket::Cmp(const WebSocket & o) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (m_Handle == o.m_Handle)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else if (m_Handle.HndPtr() > o.m_Handle.HndPtr())
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										94
									
								
								modules/mg/WebSocket.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								modules/mg/WebSocket.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMG_WEBSOCKET_HPP_
 | 
				
			||||||
 | 
					#define _SQMG_WEBSOCKET_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Handles.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Allows management of the connection handle.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class WebSocket
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    ConnectionHnd   m_Handle; // Reference to the connection instance.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Default constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    WebSocket()
 | 
				
			||||||
 | 
					        : m_Handle()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Handle constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    WebSocket(const ConnectionHnd & c)
 | 
				
			||||||
 | 
					        : m_Handle(c)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    WebSocket(const WebSocket & o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    WebSocket(WebSocket && o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~WebSocket()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Let the reference handle the deallocation!
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    WebSocket & operator = (const WebSocket & o);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    WebSocket & operator = (WebSocket && o);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Used by the script engine to compare two instances of this type.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Int32 Cmp(const WebSocket & 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.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    static SQInteger Typename(HSQUIRRELVM vm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMG_WEBSOCKET_HPP_
 | 
				
			||||||
@@ -51,7 +51,9 @@ void OnSquirrelInitialize()
 | 
				
			|||||||
    _SqMod = sq_api_import(_Func);
 | 
					    _SqMod = sq_api_import(_Func);
 | 
				
			||||||
    // Did we failed to obtain the plugin exports?
 | 
					    // Did we failed to obtain the plugin exports?
 | 
				
			||||||
    if(!_SqMod)
 | 
					    if(!_SqMod)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        OutputError("Failed to attach [%s] on host plugin.", SQMMDB_NAME);
 | 
					        OutputError("Failed to attach [%s] on host plugin.", SQMMDB_NAME);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // Obtain the Squirrel API
 | 
					        // Obtain the Squirrel API
 | 
				
			||||||
@@ -68,12 +70,16 @@ void OnSquirrelLoad()
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    // Make sure that we have a valid plugin API
 | 
					    // Make sure that we have a valid plugin API
 | 
				
			||||||
    if (!_SqMod)
 | 
					    if (!_SqMod)
 | 
				
			||||||
        return; /* Unable to proceed. */
 | 
					    {
 | 
				
			||||||
 | 
					        return; // Unable to proceed.
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    // Obtain the Squirrel API and VM
 | 
					    // Obtain the Squirrel API and VM
 | 
				
			||||||
    _SqVM = _SqMod->GetSquirrelVM();
 | 
					    _SqVM = _SqMod->GetSquirrelVM();
 | 
				
			||||||
    // Make sure that a valid virtual machine exists
 | 
					    // Make sure that a valid virtual machine exists
 | 
				
			||||||
    if (!_SqVM)
 | 
					    if (!_SqVM)
 | 
				
			||||||
        return; /* Unable to proceed. */
 | 
					    {
 | 
				
			||||||
 | 
					        return; // Unable to proceed.
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    // Set this as the default database
 | 
					    // Set this as the default database
 | 
				
			||||||
    DefaultVM::Set(_SqVM);
 | 
					    DefaultVM::Set(_SqVM);
 | 
				
			||||||
    // Register the module API
 | 
					    // Register the module API
 | 
				
			||||||
@@ -88,7 +94,7 @@ void OnSquirrelLoad()
 | 
				
			|||||||
void OnSquirrelTerminate()
 | 
					void OnSquirrelTerminate()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    OutputMessage("Terminating: %s", SQMMDB_NAME);
 | 
					    OutputMessage("Terminating: %s", SQMMDB_NAME);
 | 
				
			||||||
    // Release the current database (if any)
 | 
					    // Release the current virtual machine, if any
 | 
				
			||||||
    DefaultVM::Set(nullptr);
 | 
					    DefaultVM::Set(nullptr);
 | 
				
			||||||
    // Release script resources...
 | 
					    // Release script resources...
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -102,7 +108,9 @@ bool CheckAPIVer(CCStr ver)
 | 
				
			|||||||
    long vernum = strtol(ver, nullptr, 10);
 | 
					    long vernum = strtol(ver, nullptr, 10);
 | 
				
			||||||
    // Check against version mismatch
 | 
					    // Check against version mismatch
 | 
				
			||||||
    if (vernum == SQMOD_API_VER)
 | 
					    if (vernum == SQMOD_API_VER)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    // Log the incident
 | 
					    // Log the incident
 | 
				
			||||||
    OutputError("API version mismatch on %s", SQMMDB_NAME);
 | 
					    OutputError("API version mismatch on %s", SQMMDB_NAME);
 | 
				
			||||||
    OutputMessage("=> Requested: %ld Have: %ld", vernum, SQMOD_API_VER);
 | 
					    OutputMessage("=> Requested: %ld Have: %ld", vernum, SQMOD_API_VER);
 | 
				
			||||||
@@ -119,7 +127,9 @@ static uint8_t OnPluginCommand(uint32_t command_identifier, CCStr message)
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        case SQMOD_INITIALIZE_CMD:
 | 
					        case SQMOD_INITIALIZE_CMD:
 | 
				
			||||||
            if (CheckAPIVer(message))
 | 
					            if (CheckAPIVer(message))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
                OnSquirrelInitialize();
 | 
					                OnSquirrelInitialize();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
        case SQMOD_LOAD_CMD:
 | 
					        case SQMOD_LOAD_CMD:
 | 
				
			||||||
            OnSquirrelLoad();
 | 
					            OnSquirrelLoad();
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										122
									
								
								modules/mysql/Account.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										122
									
								
								modules/mysql/Account.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,122 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Account.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Account::Account(CSStr host, CSStr user, CSStr pass, CSStr schema, Uint16 port, CSStr socket)
 | 
				
			||||||
 | 
					    : m_Host(host ? host : _SC(""))
 | 
				
			||||||
 | 
					    , m_User(user ? user : _SC(""))
 | 
				
			||||||
 | 
					    , m_Pass(pass ? pass : _SC(""))
 | 
				
			||||||
 | 
					    , m_Port(port)
 | 
				
			||||||
 | 
					    , m_Schema(schema ? schema : _SC(""))
 | 
				
			||||||
 | 
					    , m_Socket(socket ? socket : _SC(""))
 | 
				
			||||||
 | 
					    , m_SSL_Key()
 | 
				
			||||||
 | 
					    , m_SSL_Cert()
 | 
				
			||||||
 | 
					    , m_SSL_CA()
 | 
				
			||||||
 | 
					    , m_SSL_CA_Path()
 | 
				
			||||||
 | 
					    , m_SSL_Cipher()
 | 
				
			||||||
 | 
					    , m_Autocommit()
 | 
				
			||||||
 | 
					    , m_Options()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Attempt to extract the port number from the host
 | 
				
			||||||
 | 
					    String::size_type pos = m_Host.find(':');
 | 
				
			||||||
 | 
					    // Was it specified in the host
 | 
				
			||||||
 | 
					    if (pos != String::npos)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // Attempt to extract the numeric value
 | 
				
			||||||
 | 
					            ULong num = std::stol(m_Host.substr(pos + 1));
 | 
				
			||||||
 | 
					            // Is the port number withing range?
 | 
				
			||||||
 | 
					            if (num > 0xFFFF)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SHROWF("Port number out of range: %lu");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            // Assign the extracted port number
 | 
				
			||||||
 | 
					            m_Port = static_cast< Uint16 >(num);
 | 
				
			||||||
 | 
					            // Remove everything after the port number
 | 
				
			||||||
 | 
					            m_Host = m_Host.substr(0, pos);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (const std::exception & e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            SHROWF("Cannot extract the port number [%s]", e.what());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void Account::SetSSL(CSStr key, CSStr cert, CSStr ca, CSStr ca_path, CSStr cipher)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if (!key || *key == '\0')
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        m_SSL_Key.clear();
 | 
				
			||||||
 | 
					        m_SSL_Cert.clear();
 | 
				
			||||||
 | 
					        m_SSL_CA.clear();
 | 
				
			||||||
 | 
					        m_SSL_CA_Path.clear();
 | 
				
			||||||
 | 
					        m_SSL_Cipher.clear();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        m_SSL_Key.assign(key ? key : _SC(""));
 | 
				
			||||||
 | 
					        m_SSL_Cert.assign(cert ? cert : _SC(""));
 | 
				
			||||||
 | 
					        m_SSL_CA.assign(ca ? ca : _SC(""));
 | 
				
			||||||
 | 
					        m_SSL_CA_Path.assign(ca_path ? ca_path : _SC(""));
 | 
				
			||||||
 | 
					        m_SSL_Cipher.assign(cipher ? cipher : _SC(""));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Table Account::GetOptions() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Allocate an empty table
 | 
				
			||||||
 | 
					    Table tbl(DefaultVM::Get());
 | 
				
			||||||
 | 
					    // Insert every option into the table
 | 
				
			||||||
 | 
					    for (const auto & opt : m_Options)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        tbl.SetValue(opt.first.c_str(), opt.second);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Return the resulted table
 | 
				
			||||||
 | 
					    return tbl;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					const String & Account::GetOption(CSStr name) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Make sure the specified name is valid
 | 
				
			||||||
 | 
					    if (!name || *name == '\0')
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        SHROWF("Invalid or empty option name");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Attempt to find the requested option
 | 
				
			||||||
 | 
					    const Options::const_iterator itr = m_Options.find(name);
 | 
				
			||||||
 | 
					    // Return the result
 | 
				
			||||||
 | 
					    return (itr == m_Options.cend()) ? s_String : itr->second;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void Account::SetOption(CSStr name, CSStr value)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Make sure the specified name is valid
 | 
				
			||||||
 | 
					    if (!name || *name == '\0')
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        SHROWF("Invalid or empty option name");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Assign the specified value
 | 
				
			||||||
 | 
					    m_Options[name] = value ? value : _SC("");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void Account::RemoveOption(CSStr name) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Make sure the specified name is valid
 | 
				
			||||||
 | 
					    if (!name || *name == '\0')
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        SHROWF("Invalid or empty option name");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Erase the specified value
 | 
				
			||||||
 | 
					    m_Options.erase(name);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										272
									
								
								modules/mysql/Account.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										272
									
								
								modules/mysql/Account.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,272 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Helper class containing shared connection information to avoid repetition.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class Account
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    typedef std::unordered_map< String, String > Options;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base Constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Account(CSStr host, CSStr user)
 | 
				
			||||||
 | 
					        : Account(host, user, _SC(""), _SC(""), 3306, _SC(""))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base Constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Account(CSStr host, CSStr user, CSStr pass)
 | 
				
			||||||
 | 
					        : Account(host, user, pass, _SC(""), 3306, _SC(""))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base Constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Account(CSStr host, CSStr user, CSStr pass, CSStr schema)
 | 
				
			||||||
 | 
					        : Account(host, user, pass, schema, 3306, _SC(""))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base Constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Account(CSStr host, CSStr user, CSStr pass, CSStr schema, Uint16 port)
 | 
				
			||||||
 | 
					        : Account(host, user, pass, schema, 3306, _SC(""))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base Constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Account(CSStr host, CSStr user, CSStr pass, CSStr schema, Uint16 port, CSStr socket);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor (disabled).
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Account(const Account & o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor (disabled).
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Account(Account && o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~Account() = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator (disabled).
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Account & operator = (const Account & o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator (disabled).
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Account & operator = (Account && o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    String      m_Host; // Host address.
 | 
				
			||||||
 | 
					    String      m_User; // User name.
 | 
				
			||||||
 | 
					    String      m_Pass; // User password.
 | 
				
			||||||
 | 
					    Uint16      m_Port; // Server port.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    String      m_Schema; // Server schema.
 | 
				
			||||||
 | 
					    String      m_Socket; // Unix socket.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    String      m_SSL_Key; // SSL key.
 | 
				
			||||||
 | 
					    String      m_SSL_Cert; // SSL certificate.
 | 
				
			||||||
 | 
					    String      m_SSL_CA; // SSL certificate authority.
 | 
				
			||||||
 | 
					    String      m_SSL_CA_Path; // SSL certificate authority path.
 | 
				
			||||||
 | 
					    String      m_SSL_Cipher; // SSL Cipher.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    bool        m_Autocommit; // Toggle autocommit.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    Options     m_Options; // Option container.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    static const String s_String; // Dummy used to return a reference to a null string.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the host address specified during creation.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetHost() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Host;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the user name specified during creation.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetUser() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_User;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the password specified during creation.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetPass() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Pass;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the server port specified during creation.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const Uint16 GetPort() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Port;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the server schema.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetSchema() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Schema;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Set the server schema.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetSocket() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Socket;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the SSL key.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetSSL_Key() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_SSL_Key;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the SSL certificate.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetSSL_Cert() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_SSL_Cipher;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the SSL certificate authority.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetSSL_CA() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_SSL_CA;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the SSL certificate authority path.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetSSL_CA_Path() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_SSL_CA_Path;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the SSL cipher.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetSSL_Cipher() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_SSL_Cipher;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Set the SSL information.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void SetSSL(CSStr key, CSStr cert, CSStr ca, CSStr ca_path, CSStr cipher);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * See whether autocommit is enabled or not.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool GetAutocommit() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Autocommit;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Set whether autocommit should be enabled or not.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void SetAutocommit(bool toggle)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        m_Autocommit = toggle;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the entire options container.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Table GetOptions() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get a value from the options container.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetOption(CSStr name) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Set a value in the options container.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void SetOption(CSStr name, CSStr value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Remove a value from the options container.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void RemoveOption(CSStr name) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the number of values in the options container.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Uint32 OptionsCount() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return static_cast< Uint32 >(m_Options.size());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * See whether the options container is empty or not.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool OptionsEmpty() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Options.empty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Remove all the options from the options container.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void OptionsClear()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        m_Options.clear();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
							
								
								
									
										10
									
								
								modules/mysql/Bind.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/mysql/Bind.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Account.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										17
									
								
								modules/mysql/Bind.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								modules/mysql/Bind.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
							
								
								
									
										10
									
								
								modules/mysql/Column.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/mysql/Column.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Account.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										17
									
								
								modules/mysql/Column.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								modules/mysql/Column.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
							
								
								
									
										73
									
								
								modules/mysql/Common.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								modules/mysql/Common.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					#include "Module.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					#include <stdarg.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <sqrat.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					static SQChar g_Buffer[4096]; // Common buffer to reduce memory allocations.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					SStr GetTempBuff()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return g_Buffer;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Uint32 GetTempBuffSize()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return sizeof(g_Buffer);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void SqThrowF(CSStr str, ...)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialize the argument list
 | 
				
			||||||
 | 
					    va_list args;
 | 
				
			||||||
 | 
					    va_start (args, str);
 | 
				
			||||||
 | 
					    // Write the requested contents
 | 
				
			||||||
 | 
					    if (snprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
 | 
				
			||||||
 | 
					        strcpy(g_Buffer, "Unknown error has occurred");
 | 
				
			||||||
 | 
					    // Release the argument list
 | 
				
			||||||
 | 
					    va_end(args);
 | 
				
			||||||
 | 
					    // Throw the exception with the resulted message
 | 
				
			||||||
 | 
					    throw Sqrat::Exception(g_Buffer);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					CSStr FmtStr(CSStr str, ...)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // Initialize the argument list
 | 
				
			||||||
 | 
					    va_list args;
 | 
				
			||||||
 | 
					    va_start (args, str);
 | 
				
			||||||
 | 
					    // Write the requested contents
 | 
				
			||||||
 | 
					    if (snprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
 | 
				
			||||||
 | 
					        g_Buffer[0] = 0; /* make sure the string is terminated */
 | 
				
			||||||
 | 
					    // Release the argument list
 | 
				
			||||||
 | 
					    va_end(args);
 | 
				
			||||||
 | 
					    // Return the data from the buffer
 | 
				
			||||||
 | 
					    return g_Buffer;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					StackGuard::StackGuard(HSQUIRRELVM vm)
 | 
				
			||||||
 | 
					    : m_Top(sq_gettop(vm)), m_VM(vm)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* ... */
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					StackGuard::~StackGuard()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    sq_pop(m_VM, sq_gettop(m_VM) - m_Top);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										153
									
								
								modules/mysql/Common.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								modules/mysql/Common.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,153 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_COMMON_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_COMMON_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "ModBase.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Forward declaration of various MySQL types to avoid including the header where not necessary.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef struct st_mysql MYSQL;
 | 
				
			||||||
 | 
					typedef struct st_mysql_stmt MYSQL_STMT;
 | 
				
			||||||
 | 
					typedef struct st_mysql_bind MYSQL_BIND;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					} // extern "C"
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * SOFTWARE INFORMATION
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					#define SQMYSQL_NAME "Squirrel MySQL Module"
 | 
				
			||||||
 | 
					#define SQMYSQL_AUTHOR "Sandu Liviu Catalin (S.L.C)"
 | 
				
			||||||
 | 
					#define SQMYSQL_COPYRIGHT "Copyright (C) 2016 Sandu Liviu Catalin"
 | 
				
			||||||
 | 
					#define SQMYSQL_HOST_NAME "SqModMySQLHost"
 | 
				
			||||||
 | 
					#define SQMYSQL_VERSION 001
 | 
				
			||||||
 | 
					#define SQMYSQL_VERSION_STR "0.0.1"
 | 
				
			||||||
 | 
					#define SQMYSQL_VERSION_MAJOR 0
 | 
				
			||||||
 | 
					#define SQMYSQL_VERSION_MINOR 0
 | 
				
			||||||
 | 
					#define SQMYSQL_VERSION_PATCH 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Retrieve the temporary buffer.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					SStr GetTempBuff();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Retrieve the size of the temporary buffer.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					Uint32 GetTempBuffSize();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Throw a formatted exception.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					void SqThrowF(CSStr str, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Generate a formatted string.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					CSStr FmtStr(CSStr str, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Implements RAII to restore the VM stack to it's initial size on function exit.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					struct StackGuard
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Default constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard(HSQUIRRELVM vm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~StackGuard();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard(const StackGuard &);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard(StackGuard &&);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard & operator = (const StackGuard &);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackGuard & operator = (StackGuard &&);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    HSQUIRRELVM m_VM; // The VM where the stack should be restored.
 | 
				
			||||||
 | 
					    Int32       m_Top; // The top of the stack when this instance was created.
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Helper structure for retrieving a value from the stack as a string or a formatted string.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					struct StackStrF
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    CSStr       mPtr; // Pointer to the C string that was retrieved.
 | 
				
			||||||
 | 
					    SQInteger   mLen; // The string length if it could be retrieved.
 | 
				
			||||||
 | 
					    SQRESULT    mRes; // The result of the retrieval attempts.
 | 
				
			||||||
 | 
					    HSQOBJECT   mObj; // Strong reference to the string object.
 | 
				
			||||||
 | 
					    HSQUIRRELVM mVM; // The associated virtual machine.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt = true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF(const StackStrF & o) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF(StackStrF && o) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~StackStrF();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF & operator = (const StackStrF & o) = delete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor. (disabled)
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StackStrF & operator = (StackStrF && o) = delete;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_COMMON_HPP_
 | 
				
			||||||
							
								
								
									
										10
									
								
								modules/mysql/Connection.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/mysql/Connection.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Account.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										164
									
								
								modules/mysql/Connection.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										164
									
								
								modules/mysql/Connection.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,164 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * ...
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class Connection
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection(const Account & acc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection(const Connection & o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection(Connection && o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~Connection() = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection & operator = (const Connection & o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Connection & operator = (Connection && o) = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Validate the managed connection handle and throw exception if it doesn't exist.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Validate() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    ConnHnd         m_Handle; // Handle to the actual database connection.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the hosted connection handle.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator ConnHnd ()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Handle;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the hosted connection handle.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator const ConnHnd & () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Handle;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Attempt to connect to the database.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool Connect();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Disconnect from the currently connected database.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Disconnect();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * See whether a successful connection was made or not.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool Connected() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Handle != nullptr);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the account used to make the connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const Account::Ref & GetAccount() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Account;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the server schema.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetSchema() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Schema;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Set the server schema.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void SetSchema(const String & schema);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Get the character set.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    const String & GetCharset() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Charset;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Set the character set.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void SetCharset(const String & charset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * See whether auto-commit is enabled or not.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool GetAutocommit() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Autocommit;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Set whether auto-commit should be enabled or not.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void SetAutocommit(bool toggle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Execute a query on the server.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Uint64 Execute(const String & query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Execute a query on the server.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Uint64 Insert(const String & query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Execute a query on the server.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Uint64 Query(const String & query);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * 
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StatementRef GetStatement(const String & query);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
							
								
								
									
										10
									
								
								modules/mysql/Datetime.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/mysql/Datetime.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Account.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										17
									
								
								modules/mysql/Datetime.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								modules/mysql/Datetime.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
							
								
								
									
										10
									
								
								modules/mysql/Decimal.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/mysql/Decimal.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Account.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										17
									
								
								modules/mysql/Decimal.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								modules/mysql/Decimal.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
							
								
								
									
										25
									
								
								modules/mysql/Handles.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								modules/mysql/Handles.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Handles.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					ConnHnd::Handle::~Handle()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void ConnHnd::Handle::Create(CSStr host, CSStr user, CSStr pass, CSStr schema, Uint16 port, CSStr socket)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Int32 ConnHnd::Handle::Flush(Uint32 num, Object & env, Function & func)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										691
									
								
								modules/mysql/Handles.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										691
									
								
								modules/mysql/Handles.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,691 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_HANDLES_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_HANDLES_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include <mysql.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Forward declarations.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class Connection;
 | 
				
			||||||
 | 
					class Statement;
 | 
				
			||||||
 | 
					class Column;
 | 
				
			||||||
 | 
					class Transaction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Manages a reference counted database connection handle.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class ConnHnd
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    friend class Connection;
 | 
				
			||||||
 | 
					    friend class Statement;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    typedef MYSQL           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.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    typedef std::vector< String > QueryList; // Container used to queue queries.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * The structure that holds the data associated with a certain connection.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    struct Handle
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        Pointer     mPtr; // The connection handle resource.
 | 
				
			||||||
 | 
					        Counter     mRef; // Reference count to the managed handle.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        Uint32      mErrNo; // Last received error string.
 | 
				
			||||||
 | 
					        String      mErrStr; // Last received error message.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        String      mHost; // Host address.
 | 
				
			||||||
 | 
					        String      mUser; // User name user.
 | 
				
			||||||
 | 
					        String      mPass; // User password.
 | 
				
			||||||
 | 
					        Uint16      mPort; // Server port.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        String      mSchema; // Server schema.
 | 
				
			||||||
 | 
					        String      mSocket; // Unix socket.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        String      mSSL_Key; // SSL key.
 | 
				
			||||||
 | 
					        String      mSSL_Cert; // SSL certificate.
 | 
				
			||||||
 | 
					        String      mSSL_CA; // SSL certificate authority.
 | 
				
			||||||
 | 
					        String      mSSL_CA_Path; // SSL certificate authority path.
 | 
				
			||||||
 | 
					        String      mSSL_Cipher; // SSL Cipher.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        Options     mOptions; // Option container.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        QueryList   mQueue; // A queue of queries to be executed in groups.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        bool        mAutocommit; // Whether autocommit is enabled on this connection.
 | 
				
			||||||
 | 
					        bool        mInTransaction; // Whether the connection is in the middle of a transaction.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Base constructor.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        Handle(Counter counter)
 | 
				
			||||||
 | 
					            : mPtr(nullptr)
 | 
				
			||||||
 | 
					            , mRef(counter)
 | 
				
			||||||
 | 
					            , mErrNo(0)
 | 
				
			||||||
 | 
					            , mErrStr(_SC(""))
 | 
				
			||||||
 | 
					            , mHost(_SC(""))
 | 
				
			||||||
 | 
					            , mUser(_SC(""))
 | 
				
			||||||
 | 
					            , mPass(_SC(""))
 | 
				
			||||||
 | 
					            , mPort(3306)
 | 
				
			||||||
 | 
					            , mSchema(_SC(""))
 | 
				
			||||||
 | 
					            , mSocket(_SC(""))
 | 
				
			||||||
 | 
					            , mSSL_Key(_SC(""))
 | 
				
			||||||
 | 
					            , mSSL_Cert(_SC(""))
 | 
				
			||||||
 | 
					            , mSSL_CA(_SC(""))
 | 
				
			||||||
 | 
					            , mSSL_CA_Path(_SC(""))
 | 
				
			||||||
 | 
					            , mSSL_Cipher(_SC(""))
 | 
				
			||||||
 | 
					            , mOptions(_SC(""))
 | 
				
			||||||
 | 
					            , mQueue()
 | 
				
			||||||
 | 
					            , mAutocommit(false)
 | 
				
			||||||
 | 
					            , mInTransaction(false)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            /* ... */
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Destructor.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        ~Handle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Create the database connection resource.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        void Create(CSStr host, CSStr user, CSStr pass, CSStr schema, Uint16 port, CSStr socket);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Execute a specific amount of queries from the queue.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        Int32 Flush(Uint32 num, Object & env, Function & func);
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    Handle* m_Hnd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Grab a strong reference to a connection handle.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Grab()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ++(m_Hnd->mRef);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Drop a strong reference to a connection handle.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Drop()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd && --(m_Hnd->mRef) == 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            delete m_Hnd; // Let the destructor take care of cleaning up (if necessary)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnHnd(CSStr name)
 | 
				
			||||||
 | 
					        : m_Hnd(name ? new Handle(1) : nullptr)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Default constructor (null).
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnHnd()
 | 
				
			||||||
 | 
					        : m_Hnd(nullptr)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnHnd(const ConnHnd & o)
 | 
				
			||||||
 | 
					        : m_Hnd(o.m_Hnd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Grab();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnHnd(ConnHnd && o)
 | 
				
			||||||
 | 
					        : m_Hnd(o.m_Hnd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        o.m_Hnd = nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~ConnHnd()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Drop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnHnd & operator = (const ConnHnd & o)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd != o.m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Drop();
 | 
				
			||||||
 | 
					            m_Hnd = o.m_Hnd;
 | 
				
			||||||
 | 
					            Grab();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnHnd & operator = (ConnHnd && o)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd != o.m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            m_Hnd = o.m_Hnd;
 | 
				
			||||||
 | 
					            o.m_Hnd = nullptr;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Status assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ConnHnd & operator = (Int32 status)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            m_Hnd->mErrNo = status;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an equality comparison between two connection handles.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator == (const ConnHnd & o) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd == o.m_Hnd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an inequality comparison between two connection handles.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator != (const ConnHnd & o) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != o.m_Hnd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an equality comparison with an integer value status.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator == (Int32 status) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return (m_Hnd->mErrNo == status);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an inequality comparison with an integer value status.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator != (Int32 status) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return (m_Hnd->mErrNo != status);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to boolean for use in boolean operations.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator bool () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd && m_Hnd->mPtr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Pointer ()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd ? m_Hnd->mPtr : nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Pointer () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd ? m_Hnd->mPtr : nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Reference ()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd && m_Hnd->mPtr);
 | 
				
			||||||
 | 
					        return *(m_Hnd->mPtr);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator ConstRef () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd && m_Hnd->mPtr);
 | 
				
			||||||
 | 
					        return *(m_Hnd->mPtr);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Member operator for dereferencing the managed pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * operator -> () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd);
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Indirection operator for obtaining a reference of the managed pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle & operator * () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd);
 | 
				
			||||||
 | 
					        return *m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the raw handle structure pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * HndPtr()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the raw handle structure pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * HndPtr() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the number of active references to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Counter Count() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd ? m_Hnd->mRef : 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Manages a reference counted database statement handle.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class StmtHnd
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    friend class Connection;
 | 
				
			||||||
 | 
					    friend class Statement;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    typedef MYSQL_STMT      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 MYSQL_BIND      BindType; // The managed type.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    typedef BindType*       BindPointer; // Pointer to the managed type.
 | 
				
			||||||
 | 
					    typedef const BindType* BindConstPtr; // Constant pointer to the managed type.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    typedef BindType&       BindReference; // Reference to the managed type.
 | 
				
			||||||
 | 
					    typedef const BindType& BindConstRef; // Constant reference to the managed type.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    typedef unsigned int    Counter; // Reference counter type.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    typedef std::map< String, int > Indexes; // Container used to identify column indexes.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * The structure that holds the data associated with a certain statement.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    struct Handle
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        Pointer     mPtr; // The statement handle resource.
 | 
				
			||||||
 | 
					        Counter     mRef; // Reference count to the managed handle.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        Int32       mErrNo; // The last status code of this connection handle.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					        MYSQL_BIND* mBinds;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* ----------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Base constructor.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        Handle(const ConnHnd & conn, Counter counter)
 | 
				
			||||||
 | 
					            : mPtr(nullptr)
 | 
				
			||||||
 | 
					            , mRef(counter)
 | 
				
			||||||
 | 
					            , mErrNo(0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            /* ... */
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Destructor.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        ~Handle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					         * Create the database statement resource.
 | 
				
			||||||
 | 
					        */
 | 
				
			||||||
 | 
					        void Create(CSStr query);
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					    Handle* m_Hnd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Grab a strong reference to a statement handle.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Grab()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ++(m_Hnd->mRef);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Drop a strong reference to a statement handle.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    void Drop()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd && --(m_Hnd->mRef) == 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            delete m_Hnd; // Let the destructor take care of cleaning up (if necessary)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Base constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StmtHnd(const ConnHnd & db)
 | 
				
			||||||
 | 
					        : m_Hnd(new Handle(db, 1))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Default constructor (null).
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StmtHnd()
 | 
				
			||||||
 | 
					        : m_Hnd(nullptr)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        /* ... */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StmtHnd(const StmtHnd & o)
 | 
				
			||||||
 | 
					        : m_Hnd(o.m_Hnd)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Grab();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move constructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StmtHnd(StmtHnd && o)
 | 
				
			||||||
 | 
					        : m_Hnd(o.m_Hnd)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        o.m_Hnd = nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Destructor.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    ~StmtHnd()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Drop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Copy assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StmtHnd & operator = (const StmtHnd & o)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd != o.m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            Drop();
 | 
				
			||||||
 | 
					            m_Hnd = o.m_Hnd;
 | 
				
			||||||
 | 
					            Grab();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Move assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StmtHnd & operator = (StmtHnd && o)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd != o.m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            m_Hnd = o.m_Hnd;
 | 
				
			||||||
 | 
					            o.m_Hnd = nullptr;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Status assignment operator.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    StmtHnd & operator = (Int32 status)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            m_Hnd->mErrNo = status;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return *this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an equality comparison between two statement handles.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator == (const StmtHnd & o) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd == o.m_Hnd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an inequality comparison between two statement handles.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator != (const StmtHnd & o) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return (m_Hnd != o.m_Hnd);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an equality comparison with an integer value status.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator == (Int32 status) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return (m_Hnd->mErrNo == status);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Perform an inequality comparison with an integer status value.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    bool operator != (Int32 status) const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (m_Hnd)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return (m_Hnd->mErrNo != status);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to boolean for use in boolean operations.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator bool () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd && m_Hnd->mPtr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Pointer ()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd ? m_Hnd->mPtr : nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Pointer () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd ? m_Hnd->mPtr : nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator Reference ()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd && m_Hnd->mPtr);
 | 
				
			||||||
 | 
					        return *(m_Hnd->mPtr);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Implicit conversion to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    operator ConstRef () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd && m_Hnd->mPtr);
 | 
				
			||||||
 | 
					        return *(m_Hnd->mPtr);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Member operator for dereferencing the managed pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * operator -> () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd);
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Indirection operator for obtaining a reference of the managed pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle & operator * () const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        assert(m_Hnd);
 | 
				
			||||||
 | 
					        return *m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the raw handle structure pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * HndPtr()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the raw handle structure pointer.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Handle * HndPtr() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					     * Retrieve the number of active references to the managed instance.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Counter Count() const
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return m_Hnd ? m_Hnd->mRef : 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_HANDLES_HPP_
 | 
				
			||||||
							
								
								
									
										305
									
								
								modules/mysql/Module.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										305
									
								
								modules/mysql/Module.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,305 @@
 | 
				
			|||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#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 = nullptr;
 | 
				
			||||||
 | 
					PluginCallbacks*    _Clbk = nullptr;
 | 
				
			||||||
 | 
					PluginInfo*         _Info = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					HSQAPI              _SqAPI = nullptr;
 | 
				
			||||||
 | 
					HSQEXPORTS          _SqMod = nullptr;
 | 
				
			||||||
 | 
					HSQUIRRELVM         _SqVM = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * 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.", SQMYSQL_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", SQMYSQL_NAME);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * The virtual machine is about to be terminated and script resources should be released.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					void OnSquirrelTerminate()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    OutputMessage("Terminating: %s", SQMYSQL_NAME);
 | 
				
			||||||
 | 
					    // Release the current virtual machine, if any
 | 
				
			||||||
 | 
					    DefaultVM::Set(nullptr);
 | 
				
			||||||
 | 
					    // 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, nullptr, 10);
 | 
				
			||||||
 | 
					    // Check against version mismatch
 | 
				
			||||||
 | 
					    if (vernum == SQMOD_API_VER)
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    // Log the incident
 | 
				
			||||||
 | 
					    OutputError("API version mismatch on %s", SQMYSQL_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 uint8_t OnPluginCommand(uint32_t command_identifier, CCStr message)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    switch(command_identifier)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        case SQMOD_INITIALIZE_CMD:
 | 
				
			||||||
 | 
					            if (CheckAPIVer(message))
 | 
				
			||||||
 | 
					                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 uint8_t OnServerInitialise()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void OnServerShutdown(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // The server may still send callbacks
 | 
				
			||||||
 | 
					    UnbindCallbacks();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void BindCallbacks()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    _Clbk->OnServerInitialise       = OnServerInitialise;
 | 
				
			||||||
 | 
					    _Clbk->OnServerShutdown         = OnServerShutdown;
 | 
				
			||||||
 | 
					    _Clbk->OnPluginCommand          = OnPluginCommand;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void UnbindCallbacks()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    _Clbk->OnServerInitialise       = nullptr;
 | 
				
			||||||
 | 
					    _Clbk->OnServerShutdown         = nullptr;
 | 
				
			||||||
 | 
					    _Clbk->OnPluginCommand          = nullptr;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void RegisterAPI(HSQUIRRELVM vm)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    SQMOD_UNUSED_VAR(vm);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					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);
 | 
				
			||||||
 | 
					    std::printf("[SQMOD] ");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::puts("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    std::printf("%c[0;32m[SQMOD]%c[0m", 27, 27);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::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);
 | 
				
			||||||
 | 
					    std::printf("[SQMOD] ");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::puts("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SetConsoleTextAttribute(hstdout, csb_before.wAttributes);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    std::printf("%c[0;91m[SQMOD]%c[0m", 27, 27);
 | 
				
			||||||
 | 
					    std::vprintf(msg, args);
 | 
				
			||||||
 | 
					    std::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", SQMYSQL_NAME);
 | 
				
			||||||
 | 
					    OutputMessage("Author: %s", SQMYSQL_AUTHOR);
 | 
				
			||||||
 | 
					    OutputMessage("Legal: %s", SQMYSQL_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", SQMYSQL_NAME);
 | 
				
			||||||
 | 
					        // Don't load!
 | 
				
			||||||
 | 
					        return SQMOD_FAILURE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Should never reach this point but just in case
 | 
				
			||||||
 | 
					    else if (static_cast< Uint32 >(host_plugin_id) > info->pluginId)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        OutputError("%s loaded after the host plugin", SQMYSQL_NAME);
 | 
				
			||||||
 | 
					        // Don't load!
 | 
				
			||||||
 | 
					        return SQMOD_FAILURE;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    // Store server proxies
 | 
				
			||||||
 | 
					    _Func = functions;
 | 
				
			||||||
 | 
					    _Clbk = callbacks;
 | 
				
			||||||
 | 
					    _Info = info;
 | 
				
			||||||
 | 
					    // Assign plugin version
 | 
				
			||||||
 | 
					    _Info->pluginVersion = SQMYSQL_VERSION;
 | 
				
			||||||
 | 
					    _Info->apiMajorVersion = PLUGIN_API_MAJOR;
 | 
				
			||||||
 | 
					    _Info->apiMinorVersion = PLUGIN_API_MINOR;
 | 
				
			||||||
 | 
					    // Assign the plugin name
 | 
				
			||||||
 | 
					    std::snprintf(_Info->name, sizeof(_Info->name), "%s", SQMYSQL_HOST_NAME);
 | 
				
			||||||
 | 
					    // Bind callbacks
 | 
				
			||||||
 | 
					    BindCallbacks();
 | 
				
			||||||
 | 
					    // Notify that the plugin was successfully loaded
 | 
				
			||||||
 | 
					    OutputMessage("Successfully loaded %s", SQMYSQL_NAME);
 | 
				
			||||||
 | 
					    // Dummy spacing
 | 
				
			||||||
 | 
					    puts("");
 | 
				
			||||||
 | 
					    // Done!
 | 
				
			||||||
 | 
					    return SQMOD_SUCCESS;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										41
									
								
								modules/mysql/Module.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								modules/mysql/Module.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_MODULE_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_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 // _SQMYSQL_MODULE_HPP_
 | 
				
			||||||
							
								
								
									
										10
									
								
								modules/mysql/Result.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/mysql/Result.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Account.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										17
									
								
								modules/mysql/Result.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								modules/mysql/Result.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
							
								
								
									
										10
									
								
								modules/mysql/Savepoint.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/mysql/Savepoint.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Account.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										17
									
								
								modules/mysql/Savepoint.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								modules/mysql/Savepoint.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
							
								
								
									
										10
									
								
								modules/mysql/Statement.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/mysql/Statement.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Account.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										23
									
								
								modules/mysql/Statement.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								modules/mysql/Statement.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					class Statement
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    Statement();
 | 
				
			||||||
 | 
					    ~Statement();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
							
								
								
									
										10
									
								
								modules/mysql/Transaction.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								modules/mysql/Transaction.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Account.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
							
								
								
									
										17
									
								
								modules/mysql/Transaction.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								modules/mysql/Transaction.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					#ifndef _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					#define _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#include "Common.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					namespace SqMod {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // Namespace:: SqMod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // _SQMYSQL_ACCOUNT_HPP_
 | 
				
			||||||
@@ -95,7 +95,7 @@ void OnSquirrelLoad()
 | 
				
			|||||||
void OnSquirrelTerminate()
 | 
					void OnSquirrelTerminate()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    OutputMessage("Terminating: %s", SQSAMPLE_NAME);
 | 
					    OutputMessage("Terminating: %s", SQSAMPLE_NAME);
 | 
				
			||||||
    // Release the current database (if any)
 | 
					    // Release the current virtual machine, if any
 | 
				
			||||||
    DefaultVM::Set(nullptr);
 | 
					    DefaultVM::Set(nullptr);
 | 
				
			||||||
    // Release script resources...
 | 
					    // Release script resources...
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ namespace SqMod {
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
SQInteger Column::Typename(HSQUIRRELVM vm)
 | 
					SQInteger Column::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SQChar name[] = _SC("SqSQLiteColumn");
 | 
					    static const SQChar name[] = _SC("SqSQLiteColumn");
 | 
				
			||||||
    sq_pushstring(vm, name, sizeof(name));
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,7 @@ namespace SqMod {
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
SQInteger Connection::Typename(HSQUIRRELVM vm)
 | 
					SQInteger Connection::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SQChar name[] = _SC("SqSQLiteConnection");
 | 
					    static const SQChar name[] = _SC("SqSQLiteConnection");
 | 
				
			||||||
    sq_pushstring(vm, name, sizeof(name));
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -97,7 +97,7 @@ void OnSquirrelLoad()
 | 
				
			|||||||
void OnSquirrelTerminate()
 | 
					void OnSquirrelTerminate()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    OutputMessage("Terminating: %s", SQSQLITE_NAME);
 | 
					    OutputMessage("Terminating: %s", SQSQLITE_NAME);
 | 
				
			||||||
    // Release the current database (if any)
 | 
					    // Release the current virtual machine, if any
 | 
				
			||||||
    DefaultVM::Set(nullptr);
 | 
					    DefaultVM::Set(nullptr);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -362,7 +362,6 @@ void RegisterAPI(HSQUIRRELVM vm)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    RootTable(vm).Bind(_SC("SQLite"), sqlns);
 | 
					    RootTable(vm).Bind(_SC("SQLite"), sqlns);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ConstTable(vm).Enum(_SC("ESQLite"), Enumeration(vm)
 | 
					    ConstTable(vm).Enum(_SC("ESQLite"), Enumeration(vm)
 | 
				
			||||||
        .Const(_SC("ABORT"),                            SQLITE_ABORT)
 | 
					        .Const(_SC("ABORT"),                            SQLITE_ABORT)
 | 
				
			||||||
        .Const(_SC("ABORT_ROLLBACK"),                   SQLITE_ABORT_ROLLBACK)
 | 
					        .Const(_SC("ABORT_ROLLBACK"),                   SQLITE_ABORT_ROLLBACK)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,7 +22,7 @@ namespace SqMod {
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
SQInteger Statement::Typename(HSQUIRRELVM vm)
 | 
					SQInteger Statement::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SQChar name[] = _SC("SqSQLiteStatement");
 | 
					    static const SQChar name[] = _SC("SqSQLiteStatement");
 | 
				
			||||||
    sq_pushstring(vm, name, sizeof(name));
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,7 @@ namespace SqMod {
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
SQInteger Attribute::Typename(HSQUIRRELVM vm)
 | 
					SQInteger Attribute::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SQChar name[] = _SC("SqXmlAttribute");
 | 
					    static const SQChar name[] = _SC("SqXmlAttribute");
 | 
				
			||||||
    sq_pushstring(vm, name, sizeof(name));
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ namespace SqMod {
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
SQInteger Document::Typename(HSQUIRRELVM vm)
 | 
					SQInteger Document::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SQChar name[] = _SC("SqXmlDocument");
 | 
					    static const SQChar name[] = _SC("SqXmlDocument");
 | 
				
			||||||
    sq_pushstring(vm, name, sizeof(name));
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -98,7 +98,7 @@ void OnSquirrelLoad()
 | 
				
			|||||||
void OnSquirrelTerminate()
 | 
					void OnSquirrelTerminate()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    OutputMessage("Terminating: %s", SQXML_NAME);
 | 
					    OutputMessage("Terminating: %s", SQXML_NAME);
 | 
				
			||||||
    // Release the current database (if any)
 | 
					    // Release the current virtual machine, if any
 | 
				
			||||||
    DefaultVM::Set(nullptr);
 | 
					    DefaultVM::Set(nullptr);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@ namespace SqMod {
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
SQInteger Node::Typename(HSQUIRRELVM vm)
 | 
					SQInteger Node::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SQChar name[] = _SC("SqXmlNode");
 | 
					    static const SQChar name[] = _SC("SqXmlNode");
 | 
				
			||||||
    sq_pushstring(vm, name, sizeof(name));
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ namespace SqMod {
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
SQInteger Text::Typename(HSQUIRRELVM vm)
 | 
					SQInteger Text::Typename(HSQUIRRELVM vm)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    static SQChar name[] = _SC("SqXmlText");
 | 
					    static const SQChar name[] = _SC("SqXmlText");
 | 
				
			||||||
    sq_pushstring(vm, name, sizeof(name));
 | 
					    sq_pushstring(vm, name, sizeof(name));
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,11 +1,12 @@
 | 
				
			|||||||
#ifndef _SQBASE_HPP_
 | 
					#ifndef _SQMODBASE_HPP_
 | 
				
			||||||
#define _SQBASE_HPP_
 | 
					#define _SQMODBASE_HPP_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
#include <sqconfig.h>
 | 
					#include <sqconfig.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
#include <cstddef>
 | 
					#include <cstddef>
 | 
				
			||||||
 | 
					#include <cassert>
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
@@ -94,7 +95,7 @@
 | 
				
			|||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    // Unsupported system
 | 
					    // Unsupported system
 | 
				
			||||||
    #error This operating system is not supported by the Squirrel Modules
 | 
					    #error This operating system is not supported by the Squirrel Module
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef SQMOD_ARCHITECTURE
 | 
					#ifndef SQMOD_ARCHITECTURE
 | 
				
			||||||
@@ -108,6 +109,7 @@
 | 
				
			|||||||
/* ------------------------------------------------------------------------------------------------
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 * SQUIRREL FORWARD DECLARATIONS
 | 
					 * SQUIRREL FORWARD DECLARATIONS
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
    typedef struct tagSQObject SQObject;
 | 
					    typedef struct tagSQObject SQObject;
 | 
				
			||||||
    struct SQVM;
 | 
					    struct SQVM;
 | 
				
			||||||
@@ -118,6 +120,7 @@ extern "C" {
 | 
				
			|||||||
/* ------------------------------------------------------------------------------------------------
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 * SQRAT FORWARD DECLARATIONS
 | 
					 * SQRAT FORWARD DECLARATIONS
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Sqrat {
 | 
					namespace Sqrat {
 | 
				
			||||||
    class Array;
 | 
					    class Array;
 | 
				
			||||||
    class Object;
 | 
					    class Object;
 | 
				
			||||||
@@ -189,7 +192,8 @@ typedef Uint32                      SizeT;
 | 
				
			|||||||
/* ------------------------------------------------------------------------------------------------
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 * STRING TYPE
 | 
					 * STRING TYPE
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
typedef ::std::basic_string<SQChar> String;
 | 
					
 | 
				
			||||||
 | 
					typedef std::basic_string<SQChar>   String;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef char *                      CStr;
 | 
					typedef char *                      CStr;
 | 
				
			||||||
typedef const char *                CCStr;
 | 
					typedef const char *                CCStr;
 | 
				
			||||||
@@ -200,6 +204,7 @@ typedef const SQChar *              CSStr;
 | 
				
			|||||||
/* ------------------------------------------------------------------------------------------------
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 * SHORT SQUIRREL TYPENAMES
 | 
					 * SHORT SQUIRREL TYPENAMES
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef SQUnsignedInteger32         SQUint32;
 | 
					typedef SQUnsignedInteger32         SQUint32;
 | 
				
			||||||
typedef SQUnsignedInteger           SQUint;
 | 
					typedef SQUnsignedInteger           SQUint;
 | 
				
			||||||
typedef SQInteger                   SQInt;
 | 
					typedef SQInteger                   SQInt;
 | 
				
			||||||
@@ -207,6 +212,12 @@ typedef SQInteger                   SQInt;
 | 
				
			|||||||
// ------------------------------------------------------------------------------------------------
 | 
					// ------------------------------------------------------------------------------------------------
 | 
				
			||||||
using namespace Sqrat;
 | 
					using namespace Sqrat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					 * Squirrel compatible stl string.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef std::basic_string< SQChar > String;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 * FORWARD DECLARATIONS
 | 
					 * FORWARD DECLARATIONS
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
@@ -323,12 +334,12 @@ using namespace Sqrat;
 | 
				
			|||||||
 * COLOR PACKING
 | 
					 * COLOR PACKING
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SQMOD_PACK_RGB(r, g, b) (Uint32)(r << 16 | g << 8 | b)
 | 
					#define SQMOD_PACK_RGB(r, g, b) static_cast< Uint32 >(r << 16 | g << 8 | b)
 | 
				
			||||||
#define SQMOD_PACK_RGBA(r, g, b, a) (Uint32)(r << 24 | g << 16 | b << 8 | a)
 | 
					#define SQMOD_PACK_RGBA(r, g, b, a) static_cast< Uint32 >(r << 24 | g << 16 | b << 8 | a)
 | 
				
			||||||
#define SQMOD_PACK_ARGB(a, r, g, b) (Uint32)(a << 24 | r << 16 | g << 8 | b)
 | 
					#define SQMOD_PACK_ARGB(a, r, g, b) static_cast< Uint32 >(a << 24 | r << 16 | g << 8 | b)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SQMOD_PACK_RGB_TO_RGBA(r, g, b) (Uint32)(r << 24 | g << 16 | b << 8 | 0)
 | 
					#define SQMOD_PACK_RGB_TO_RGBA(r, g, b) static_cast< Uint32 >(r << 24 | g << 16 | b << 8 | 0)
 | 
				
			||||||
#define SQMOD_PACK_RGB_TO_ARGB(r, g, b) (Uint32)(0 << 24 | r << 16 | g << 8 | b)
 | 
					#define SQMOD_PACK_RGB_TO_ARGB(r, g, b) static_cast< Uint32 >(0 << 24 | r << 16 | g << 8 | b)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 * GENERAL RESPONSES
 | 
					 * GENERAL RESPONSES
 | 
				
			||||||
@@ -364,13 +375,10 @@ using namespace Sqrat;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define SQMOD_BLIP_POOL         128
 | 
					#define SQMOD_BLIP_POOL         128
 | 
				
			||||||
#define SQMOD_CHECKPOINT_POOL   2000
 | 
					#define SQMOD_CHECKPOINT_POOL   2000
 | 
				
			||||||
#define SQMOD_FORCEFIELD_POOL   2000
 | 
					 | 
				
			||||||
#define SQMOD_KEYBIND_POOL      256
 | 
					#define SQMOD_KEYBIND_POOL      256
 | 
				
			||||||
#define SQMOD_OBJECT_POOL       3000
 | 
					#define SQMOD_OBJECT_POOL       3000
 | 
				
			||||||
#define SQMOD_PICKUP_POOL       2000
 | 
					#define SQMOD_PICKUP_POOL       2000
 | 
				
			||||||
#define SQMOD_PLAYER_POOL       100
 | 
					#define SQMOD_PLAYER_POOL       100
 | 
				
			||||||
#define SQMOD_SPRITE_POOL       128
 | 
					 | 
				
			||||||
#define SQMOD_TEXTDRAW_POOL     256
 | 
					 | 
				
			||||||
#define SQMOD_VEHICLE_POOL      1000
 | 
					#define SQMOD_VEHICLE_POOL      1000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
@@ -382,7 +390,7 @@ using namespace Sqrat;
 | 
				
			|||||||
#define SQMOD_CREATE_POOL       -4
 | 
					#define SQMOD_CREATE_POOL       -4
 | 
				
			||||||
#define SQMOD_CREATE_AUTOMATIC  -5
 | 
					#define SQMOD_CREATE_AUTOMATIC  -5
 | 
				
			||||||
#define SQMOD_CREATE_OVERWRITE  -6
 | 
					#define SQMOD_CREATE_OVERWRITE  -6
 | 
				
			||||||
#define SQMOD_CREATE_RESURECT   -7
 | 
					#define SQMOD_CREATE_IMPORT     -7
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SQMOD_DESTROY_DEFAULT   0
 | 
					#define SQMOD_DESTROY_DEFAULT   0
 | 
				
			||||||
#define SQMOD_DESTROY_MANUAL    -3
 | 
					#define SQMOD_DESTROY_MANUAL    -3
 | 
				
			||||||
@@ -413,36 +421,11 @@ using namespace Sqrat;
 | 
				
			|||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SQMOD_STACK_SIZE            2048
 | 
					#define SQMOD_STACK_SIZE            2048
 | 
				
			||||||
 | 
					#define SQMOD_MAX_ROUTINES          1024
 | 
				
			||||||
#define SQMOD_MAX_CMD_ARGS          12
 | 
					#define SQMOD_MAX_CMD_ARGS          12
 | 
				
			||||||
#define SQMOD_PLAYER_MSG_PREFIXES   16
 | 
					#define SQMOD_PLAYER_MSG_PREFIXES   16
 | 
				
			||||||
#define SQMOD_PLAYER_TMP_BUFFER     128
 | 
					#define SQMOD_PLAYER_TMP_BUFFER     128
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					 | 
				
			||||||
 * ENTITY POOL UPDATE IDENTIFIERS
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#define SQMOD_ENTITY_POOL_VEHICLE       1
 | 
					 | 
				
			||||||
#define SQMOD_ENTITY_POOL_OBJECT        2
 | 
					 | 
				
			||||||
#define SQMOD_ENTITY_POOL_PICKUP        3
 | 
					 | 
				
			||||||
#define SQMOD_ENTITY_POOL_RADIO         4
 | 
					 | 
				
			||||||
#define SQMOD_ENTITY_POOL_SPRITE        5
 | 
					 | 
				
			||||||
#define SQMOD_ENTITY_POOL_TEXTDRAW      6
 | 
					 | 
				
			||||||
#define SQMOD_ENTITY_POOL_BLIP          7
 | 
					 | 
				
			||||||
#define SQMOD_ENTITY_POOL_MAX           8
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					 | 
				
			||||||
 * PLAYER STATE IDENTIFIERS
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#define SQMOD_PLAYER_STATE_NONE                     0
 | 
					 | 
				
			||||||
#define SQMOD_PLAYER_STATE_NORMAL                   1
 | 
					 | 
				
			||||||
#define SQMOD_PLAYER_STATE_SHOOTING                 2
 | 
					 | 
				
			||||||
#define SQMOD_PLAYER_STATE_DRIVER                   3
 | 
					 | 
				
			||||||
#define SQMOD_PLAYER_STATE_PASSENGER                4
 | 
					 | 
				
			||||||
#define SQMOD_PLAYER_STATE_ENTERING_AS_DRIVER       5
 | 
					 | 
				
			||||||
#define SQMOD_PLAYER_STATE_ENTERING_AS_PASSENGER    6
 | 
					 | 
				
			||||||
#define SQMOD_PLAYER_STATE_EXITING_VEHICLE          7
 | 
					 | 
				
			||||||
#define SQMOD_PLAYER_STATE_UNSPAWNED                8
 | 
					 | 
				
			||||||
#define SQMOD_PLAYER_STATE_MAX                      9
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 * PLAYER ACTION IDENTIFIERS
 | 
					 * PLAYER ACTION IDENTIFIERS
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
@@ -461,43 +444,6 @@ using namespace Sqrat;
 | 
				
			|||||||
#define SQMOD_PLAYER_ACTION_EXITING_VEHICLE         60
 | 
					#define SQMOD_PLAYER_ACTION_EXITING_VEHICLE         60
 | 
				
			||||||
#define SQMOD_PLAYER_ACTION_MAX                     61
 | 
					#define SQMOD_PLAYER_ACTION_MAX                     61
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					 | 
				
			||||||
 * VEHICLE UPDATE IDENTIFIERS
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#define SQMOD_VEHICLEUPD_DRIVER         0
 | 
					 | 
				
			||||||
#define SQMOD_VEHICLEUPD_OTHER          1
 | 
					 | 
				
			||||||
#define SQMOD_VEHICLEUPD_MAX            2
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					 | 
				
			||||||
 * PLAYER UPDATE IDENTIFIERS
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#define SQMOD_PLAYERUPD_ONFOOT          0
 | 
					 | 
				
			||||||
#define SQMOD_PLAYERUPD_AIM             1
 | 
					 | 
				
			||||||
#define SQMOD_PLAYERUPD_DRIVER          2
 | 
					 | 
				
			||||||
#define SQMOD_PLAYERUPD_PASSENGER       3
 | 
					 | 
				
			||||||
#define SQMOD_PLAYERUPD_MAX             4
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					 | 
				
			||||||
 * PART REASON IDENTIFIERS
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#define SQMOD_PARTREASON_TIMEOUT        0
 | 
					 | 
				
			||||||
#define SQMOD_PARTREASON_DISCONNECTED   1
 | 
					 | 
				
			||||||
#define SQMOD_PARTREASON_KICKEDBANNED   2
 | 
					 | 
				
			||||||
#define SQMOD_PARTREASON_CRASHED        3
 | 
					 | 
				
			||||||
#define SQMOD_PARTREASON_MAX            4
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					 | 
				
			||||||
 * BODY PART IDENTIFIERS
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#define SQMOD_BODYPART_BODY             0
 | 
					 | 
				
			||||||
#define SQMOD_BODYPART_TORSO            1
 | 
					 | 
				
			||||||
#define SQMOD_BODYPART_LEFTARM          2
 | 
					 | 
				
			||||||
#define SQMOD_BODYPART_RIGHTARM         3
 | 
					 | 
				
			||||||
#define SQMOD_BODYPART_LEFTLEG          4
 | 
					 | 
				
			||||||
#define SQMOD_BODYPART_RIGHTLEG         5
 | 
					 | 
				
			||||||
#define SQMOD_BODYPART_HEAD             6
 | 
					 | 
				
			||||||
#define SQMOD_BODYPART_MAX              7
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* ------------------------------------------------------------------------------------------------
 | 
					/* ------------------------------------------------------------------------------------------------
 | 
				
			||||||
 * WEATHER IDENTIFIERS
 | 
					 * WEATHER IDENTIFIERS
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
@@ -1193,4 +1139,4 @@ using namespace Sqrat;
 | 
				
			|||||||
#define SQMOD_ASCII_UNDEFINED               127
 | 
					#define SQMOD_ASCII_UNDEFINED               127
 | 
				
			||||||
#define SQMOD_ASCII_MAX                     128
 | 
					#define SQMOD_ASCII_MAX                     128
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // _SQBASE_HPP_
 | 
					#endif // _SQMODBASE_HPP_
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user