namespace Bscript { template <> TmplExecutorModule<Module::AttributeExecutorModule>::FunctionDef TmplExecutorModule< Module::AttributeExecutorModule>::function_table[] = { {"CheckSkill", &Module::AttributeExecutorModule::mf_CheckSkill}, {"GetAttributeName", &Module::AttributeExecutorModule::mf_GetAttributeName}, {"GetAttributeDefaultCap", &Module::AttributeExecutorModule::mf_GetAttributeDefaultCap}, {"GetAttribute", &Module::AttributeExecutorModule::mf_GetAttribute}, {"GetAttributeBaseValue", &Module::AttributeExecutorModule::mf_GetAttributeBaseValue}, {"GetAttributeTemporaryMod", &Module::AttributeExecutorModule::mf_GetAttributeTemporaryMod}, {"GetAttributeIntrinsicMod", &Module::AttributeExecutorModule::mf_GetAttributeIntrinsicMod}, {"GetAttributeLock", &Module::AttributeExecutorModule::mf_GetAttributeLock}, {"GetAttributeCap", &Module::AttributeExecutorModule::mf_GetAttributeCap}, {"SetAttributeCap", &Module::AttributeExecutorModule::mf_SetAttributeCap}, {"SetAttributeLock", &Module::AttributeExecutorModule::mf_SetAttributeLock}, {"SetAttributeBaseValue", &Module::AttributeExecutorModule::mf_SetAttributeBaseValue}, {"SetAttributeTemporaryMod", &Module::AttributeExecutorModule::mf_SetAttributeTemporaryMod}, {"AlterAttributeTemporaryMod", &Module::AttributeExecutorModule::mf_AlterAttributeTemporaryMod}, {"RawSkillToBaseSkill", &Module::AttributeExecutorModule::mf_RawSkillToBase}, {"BaseSkillToRawSkill", &Module::AttributeExecutorModule::mf_BaseSkillToRaw}}; template <> int TmplExecutorModule<Module::AttributeExecutorModule>::function_table_size = arsize( function_table ); }
static Hdr * readhdr(int ar) { int32_t hdrcksum; Hdr *hp; hp = getblkrd(ar, Alldata); if (hp == nil) sysfatal("unexpected EOF instead of archive header in %s", arname); if (eotar(hp)) /* end-of-archive block? */ return nil; hdrcksum = parsecksum(hp->chksum, name(hp)); if (hdrcksum == -1 || chksum(hp) != hdrcksum) { if (!resync) sysfatal("bad archive header checksum in %s: " "name %.100s...; expected %#luo got %#luo", arname, hp->name, hdrcksum, chksum(hp)); fprint(2, "%s: skipping past archive header with bad checksum in %s...", argv0, arname); do { hp = getblkrd(ar, Alldata); if (hp == nil) sysfatal("unexpected EOF looking for archive header in %s", arname); hdrcksum = parsecksum(hp->chksum, name(hp)); } while (hdrcksum == -1 || chksum(hp) != hdrcksum); fprint(2, "found %s\n", name(hp)); } nexthdr += Tblock*(1 + BYTES2TBLKS(arsize(hp))); return hp; }
/* * copy a file from the archive into the filesystem. * fname is result of name(), so has two extra bytes at beginning. */ static void extract1(int ar, Hdr *hp, char *fname) { int fd = -1, dir = 0; int32_t mtime = strtol(hp->mtime, nil, 8); uint32_t mode = strtoul(hp->mode, nil, 8) & 0777; Off bytes = hdrsize(hp); /* for printing */ uint32_t blksleft = BYTES2TBLKS(arsize(hp)); /* fiddle name, figure out mode and blocks */ if (isdir(hp)) { mode |= DMDIR|0700; dir = 1; } switch (hp->linkflag) { case LF_LINK: case LF_SYMLINK1: case LF_SYMLINK2: case LF_FIFO: blksleft = 0; break; } if (relative) if(fname[0] == '/') *--fname = '.'; else if(fname[0] == '#'){ *--fname = '/'; *--fname = '.'; } if (verb == Xtract) fd = openfname(hp, fname, dir, mode); else if (verbose) { char *cp = ctime(mtime); print("%M %8lld %-12.12s %-4.4s %s\n", mode, bytes, cp+4, cp+24, fname); } else print("%s\n", fname); copyfromar(ar, fd, fname, blksleft, bytes); /* touch up meta data and close */ if (fd >= 0) { /* * directories should be wstated *after* we're done * creating files in them, but we don't do that. */ if (settime) wrmeta(fd, hp, mtime, mode); close(fd); } }
static void skip(int ar, Hdr *hp, char *msg) { uint32_t blksleft, blksread; Off bytes; bytes = arsize(hp); for (blksleft = BYTES2TBLKS(bytes); blksleft > 0; blksleft -= blksread) { if (getblkrd(ar, Justnxthdr) == nil) sysfatal("unexpected EOF on archive %s %s", arname, msg); blksread = gothowmany(blksleft); putreadblks(ar, blksread); } }
{ using namespace Module; template <> TmplExecutorModule<SQLExecutorModule>::FunctionDef TmplExecutorModule<SQLExecutorModule>::function_table[] = { {"MySQL_Connect", &SQLExecutorModule::mf_ConnectToDB}, {"MySQL_Query", &SQLExecutorModule::mf_Query}, {"MySQL_Close", &SQLExecutorModule::mf_Close}, {"MySQL_Num_Fields", &SQLExecutorModule::mf_NumFields}, {"MySQL_Fetch_Row", &SQLExecutorModule::mf_FetchRow}, {"MySQL_Affected_Rows", &SQLExecutorModule::mf_AffectedRows}, {"MySQL_Num_Rows", &SQLExecutorModule::mf_NumRows}, {"MySQL_Select_Db", &SQLExecutorModule::mf_SelectDb}, {"MySQL_Field_Name", &SQLExecutorModule::mf_FieldName}}; template <> int TmplExecutorModule<SQLExecutorModule>::function_table_size = arsize( function_table ); } namespace Module { using namespace Bscript; #ifdef HAVE_MYSQL BObjectImp* SQLExecutorModule::background_connect( weak_ptr<Core::UOExecutor> uoexec, const std::string host, const std::string username, const std::string password ) { auto msg = [uoexec, host, username, password]() { std::unique_ptr<Core::BSQLConnection> sql; {
{ { "FileExists", &FileAccessExecutorModule::mf_FileExists }, { "ReadFile", &FileAccessExecutorModule::mf_ReadFile }, { "WriteFile", &FileAccessExecutorModule::mf_WriteFile }, { "AppendToFile", &FileAccessExecutorModule::mf_AppendToFile }, { "LogToFile", &FileAccessExecutorModule::mf_LogToFile }, { "OpenBinaryFile", &FileAccessExecutorModule::mf_OpenBinaryFile }, { "CreateDirectory",&FileAccessExecutorModule::mf_CreateDirectory }, { "ListDirectory", &FileAccessExecutorModule::mf_ListDirectory }, { "OpenXMLFile", &FileAccessExecutorModule::mf_OpenXMLFile }, { "CreateXMLFile", &FileAccessExecutorModule::mf_CreateXMLFile } }; template<> int TmplExecutorModule<FileAccessExecutorModule>::function_table_size = arsize(function_table); FileAccess::FileAccess( ConfigElem& elem ) : AllowWrite( elem.remove_bool( "AllowWrite", false ) ), AllowAppend( elem.remove_bool( "AllowAppend", false ) ), AllowRead( elem.remove_bool( "AllowRead", false ) ), AllowRemote( elem.remove_bool( "AllowRemote", false ) ), AllPackages( false ), AllDirectories( false ), AllExtensions( false ) { string tmp; while (elem.remove_prop( "Package", &tmp )) { if (tmp == "*") AllPackages = true;
{ "Packages", &PolSystemExecutorModule::mf_Packages }, { "GetPackageByName", &PolSystemExecutorModule::mf_GetPackageByName }, { "ListTextCommands", &PolSystemExecutorModule::mf_ListTextCommands}, { "Realms", &PolSystemExecutorModule::mf_Realms }, { "ReloadConfiguration", &PolSystemExecutorModule::mf_ReloadConfiguration }, { "ReadMillisecondClock", &PolSystemExecutorModule::mf_ReadMillisecondClock }, { "ListenPoints", &PolSystemExecutorModule::mf_ListenPoints }, { "SetSysTrayPopupText", &PolSystemExecutorModule::mf_SetSysTrayPopupText }, { "GetItemDescriptor", &PolSystemExecutorModule::mf_GetItemDescriptor }, { "CreatePacket", &PolSystemExecutorModule::mf_CreatePacket }, { "AddRealm", &PolSystemExecutorModule::mf_AddRealm }, { "DeleteRealm", &PolSystemExecutorModule::mf_DeleteRealm }, { "MD5Encrypt", &PolSystemExecutorModule::mf_MD5Encrypt } }; template<> int TmplExecutorModule<PolSystemExecutorModule>::function_table_size = arsize(function_table); const char* PackageObjImp::typeOf() const { return "Package"; } int PackageObjImp::typeOfInt() const { return OTPackage; } BObjectImp* PackageObjImp::copy() const { return new PackageObjImp( obj_ ); }