CSetRuntimeAttributeValue::CSetRuntimeAttributeValue ( CRCBotKeyValueList *list, void *pAddrBase ) { #ifdef _WIN32 findFunc(list,"set_attribute_value_win",pAddrBase,"\\x55\\x8B\\xEC\\x83\\xEC\\x14\\x33\\xD2\\x53\\x8B\\xD9\\x56\\x57\\x8B\\x73\\x10\\x85\\xF6"); #else findFunc(list,"set_attribute_value_linux",pAddrBase,"@_ZN14CAttributeList24SetRuntimeAttributeValueEPK28CEconItemAttributeDefinitionf"); #endif }
CGetAttributeDefinitionByID::CGetAttributeDefinitionByID(CRCBotKeyValueList *list, void *pAddrBase) { #ifdef _WIN32 findFunc(list, "get_attrib_def_id_win", pAddrBase, "\\x55\\x8B\\xEC\\x83\\xEC\\x2A\\x53\\x56\\x8B\\xD9\\x8D\\x2A\\x2A\\x57"); #else findFunc(list, "get_attrib_def_id_linux", pAddrBase, "@_ZN15CEconItemSchema22GetAttributeDefinitionEi"); #endif }
CGetEconItemSchema::CGetEconItemSchema ( CRCBotKeyValueList *list, void *pAddrBase ) { #ifdef _WIN32 findFunc(list,"get_item_schema_win",pAddrBase,"\\xE8\\x2A\\x2A\\x2A\\x2A\\x83\\xC0\\x04\\xC3"); #else findFunc(list,"get_item_schema_linux",pAddrBase,"@_Z15GEconItemSchemav"); #endif }
CCreateGameRulesObject::CCreateGameRulesObject(CRCBotKeyValueList *list, void *pAddrBase) { #ifdef _WIN32 findFunc(list, "create_gamerules_object_win", pAddrBase, "\\x55\\x8B\\xEC\\x8B\\x0D\\x2A\\x2A\\x2A\\x2A\\x85\\xC9\\x74\\x07"); #else m_func = NULL; #endif }
CGameRulesObject::CGameRulesObject(CRCBotKeyValueList *list, void *pAddrBase) { #ifdef _WIN32 m_func = NULL; #else findFunc(list, "g_pGameRules", pAddrBase, "@g_pGameRules"); #endif }
constrainFunc loadConstrain(char *path) { constrainFunc constraints = noconstraints; #if 0 closeLib(); if (path != NULL) constraints = findFunc(path, constrainName, sizeof(constrainName) - 1); else { constraints = noconstraints; puts("Relaxing all constraints"); } #endif return constraints; }
bool get_call_info_no_eval(const CallInfo *&ci, void *&extra, const char *s, int64 hash) { DECLARE_GLOBAL_VARIABLES(g); extra = NULL; if (hash < 0) hash = hash_string(s); const hashNodeFunc *p = findFunc(s, hash); if (LIKELY(p!=0)) { if (UNLIKELY(p->offset)) { const char *addr = (const char *)g + (int64)p->data; ci = *(const CallInfo **)addr; return ci != 0; } else { ci = (const CallInfo *)p->data; return true; } } return get_call_info_builtin(ci, extra, s, hash); }
/**Loads the proper functions from the package NAME. */ void getFunc(char* name) { int index = findFunc(name); if (*name == '\0') { printf("Running default equation\n"); vMod = defaultV; rMod = defaultR; drivingF = defaultF; } else if (index == -1) { printf("Error couldn't load Equation: %s\n", name); printf("Running default equation\n"); vMod = defaultV; rMod = defaultR; drivingF = defaultF; } else { vMod = eqns[3*index]; rMod = eqns[3*index + 1]; drivingF = eqns[3*index +2]; printf("Loaded %s\n", name); } }
__declspec(dllexport) bool GI_Call(const char* func, int entref, int numParams) { DWORD oldNumParam = *scr_numParam; *scr_numParam = numParams; scriptCall_t thisCall; thisCall = findFunc(func, entref); if (!thisCall) { return false; } *(DWORD*)0x204048C += 1; *(DWORD*)0x2040D08 = 0; // scr_retArgs // call -> __asm { mov eax, 4386E0h call eax } //*(DWORD*)0x1F3E410 -= (8 * numParams); *(DWORD*)0x204048C -= 1; *scr_numParam = oldNumParam; // handle return values Scriptability_HandleReturns(); *(DWORD*)0x2040D08 = 0; // scr_retArgs return true; }
/** * execute example_cmd. * @ param unit chip unit * @ a argument list * @return stat. */ cmd_result_t cmd_example_exec(int unit, args_t *a) { ApplRefFunction_t * pexpls; char *subcmd; int rc = 0; printk("Invoking example cmd\n"); if ( (subcmd = ARG_GET(a)) == NULL ) return CMD_USAGE; if ( exampleCmdGetCmdList == NULL || (pexpls = (*exampleCmdGetCmdList)()) == NULL || pexpls->pf == NULL ) { printk("No Examples Available\n"); return CMD_OK; } if ( sal_strcasecmp(subcmd, "list") == 0 ) { ApplRefFunction_t *pe; char buf[128]; buf[0] = 0; for( pe = pexpls; pe->pf != NULL; pe++ ) { if ( match_str( pe->pname, buf, sizeof(buf)-1 ) ) printk("===================================================================================\n"); printk(" %-25s : %s\n", pe->pname, pe->pbriefdescr); } return CMD_OK; } if ( sal_strcasecmp(subcmd, "alllist") == 0 ) { ApplRefFunction_t *pe; char buf[128]; buf[0] = 0; for( pe = pexpls; pe->pf != NULL; pe++ ) { if ( match_str( pe->pname, buf, sizeof(buf)-1 ) ) printk("===================================================================================\n"); printk(" %-25s : %s\n", pe->pname, pe->pbriefdescr); printk("\n**********************************************\n"); printk("%s\n", pe->pdescr); printk("\n**********************************************\n"); } return CMD_OK; } if ( sal_strcasecmp(subcmd, "info") == 0 ) { ApplRefFunction_t *pe; if ( (subcmd = ARG_GET(a)) == NULL ) return CMD_USAGE; pe = findFunc( pexpls, subcmd ); if ( pe == NULL ) { printk("Example %s is not found\n", subcmd); return CMD_FAIL; } printk("\n**********************************************\n"); printk("%s\n", pe->pdescr); printk("\n**********************************************\n"); return CMD_OK; } if ( sal_strcasecmp(subcmd, "exec") == 0 ) { ApplRefFunction_t *pe; if ( (subcmd = ARG_GET(a)) == NULL ) return CMD_USAGE; pe = findFunc( pexpls, subcmd ); if ( pe == NULL ) { printk("Example %s is not found\n", subcmd); return CMD_FAIL; } /** invoke command */ { char *args[16]; /** limit to 16 args */ int n = 0; while ( (n < 16) && ( (args[n] = ARG_GET(a)) != NULL ) ) n++; if ( n == 16 ) { printk("Excessive amount of arguments\n"); return CMD_FAIL; } if ( BCM_FAILURE(rc = (*pe->dispatch)(pe->pf, n, args)) ) { printk( "Error : fail to execute %d %s\n", rc, bcm_errmsg(rc) ); return rc; } } return CMD_OK; } return CMD_USAGE; }
int main(int argc,char *argv[]){ char *tok,line[MAX],*filename=argv[1],*initTree="InitTree",*insert="Insert",*delete="Delete",*find="Find",*height="Height",*printTree="PrintTree"; BST **T=(BST**)malloc(sizeof(BST*)); int numOper=2,numLines=0; //FILE *fileCountLines=fopen(filename,"r"); //while(fgets(line,sizeof line,fileCountLines)!=NULL){ // numLines++; //} //fclose(fileCountLines); numOper=numLines-1; FILE *file=fopen(filename,"r"); while(fgets(line,sizeof line,file)!=NULL){ trim(line); tok=strtok(line," "); if(strcmp(line,initTree)==0){ char *initTreeParam; tok=strtok(NULL," "); initTreeParam=tok; *T=initTreeFunc(initTreeParam); tok=strtok(NULL," "); } else if(strcmp(line,insert)==0){ char *insertParam; tok=strtok(NULL," "); insertParam=tok; insertFunc(insertParam,T); tok=strtok(NULL," "); } else if(strcmp(line,delete)==0){ char *deleteParam; tok=strtok(NULL," "); deleteParam=tok; deleteFunc(deleteParam,T); tok=strtok(NULL," "); } else if(strcmp(line,find)==0){ char *findParam; tok=strtok(NULL," "); findParam=tok; findFunc(findParam,(*T)); tok=strtok(NULL," "); } else if(strcmp(line,height)==0){ int height=heightFunc(*T); printf("%d\n",height); tok=strtok(NULL," "); } else if(strcmp(line,printTree)==0){ int printTreeParam; tok=strtok(NULL," "); printTreeParam=atoi(tok); printTreeFunc(*T,printTreeParam); tok=strtok(NULL," "); printf("\n"); } }
/* * Trigger */ Datum tsearch2(PG_FUNCTION_ARGS) { TriggerData *trigdata; Trigger *trigger; Relation rel; HeapTuple rettuple = NULL; TSCfgInfo *cfg = findcfg(get_currcfg()); int numidxattr, i; PRSTEXT prs; Datum datum = (Datum) 0; Oid funcoid = InvalidOid; if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */ elog(ERROR, "TSearch: Not fired by trigger manager"); trigdata = (TriggerData *) fcinfo->context; if (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event)) /* internal error */ elog(ERROR, "TSearch: Can't process STATEMENT events"); if (TRIGGER_FIRED_AFTER(trigdata->tg_event)) /* internal error */ elog(ERROR, "TSearch: Must be fired BEFORE event"); if (TRIGGER_FIRED_BY_INSERT(trigdata->tg_event)) rettuple = trigdata->tg_trigtuple; else if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event)) rettuple = trigdata->tg_newtuple; else /* internal error */ elog(ERROR, "TSearch: Unknown event"); trigger = trigdata->tg_trigger; rel = trigdata->tg_relation; if (trigger->tgnargs < 2) /* internal error */ elog(ERROR, "TSearch: format tsearch2(tsvector_field, text_field1,...)"); numidxattr = SPI_fnumber(rel->rd_att, trigger->tgargs[0]); if (numidxattr == SPI_ERROR_NOATTRIBUTE) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("tsvector column \"%s\" does not exist", trigger->tgargs[0]))); prs.lenwords = 32; prs.curwords = 0; prs.pos = 0; prs.words = (WORD *) palloc(sizeof(WORD) * prs.lenwords); /* find all words in indexable column */ for (i = 1; i < trigger->tgnargs; i++) { int numattr; Oid oidtype; Datum txt_toasted; bool isnull; text *txt; numattr = SPI_fnumber(rel->rd_att, trigger->tgargs[i]); if (numattr == SPI_ERROR_NOATTRIBUTE) { funcoid = findFunc(trigger->tgargs[i]); if (funcoid == InvalidOid) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("could not find function or field \"%s\"", trigger->tgargs[i]))); continue; } oidtype = SPI_gettypeid(rel->rd_att, numattr); /* We assume char() and varchar() are binary-equivalent to text */ if (!(oidtype == TEXTOID || oidtype == VARCHAROID || oidtype == BPCHAROID)) { elog(WARNING, "TSearch: '%s' is not of character type", trigger->tgargs[i]); continue; } txt_toasted = SPI_getbinval(rettuple, rel->rd_att, numattr, &isnull); if (isnull) continue; if (funcoid != InvalidOid) { text *txttmp = (text *) DatumGetPointer(OidFunctionCall1( funcoid, PointerGetDatum(txt_toasted) )); txt = (text *) DatumGetPointer(PG_DETOAST_DATUM(PointerGetDatum(txttmp))); if (txt == txttmp) txt_toasted = PointerGetDatum(txt); } else txt = (text *) DatumGetPointer(PG_DETOAST_DATUM(PointerGetDatum(txt_toasted))); parsetext_v2(cfg, &prs, VARDATA(txt), VARSIZE(txt) - VARHDRSZ); if (txt != (text *) DatumGetPointer(txt_toasted)) pfree(txt); } /* make tsvector value */ if (prs.curwords) { datum = PointerGetDatum(makevalue(&prs)); rettuple = SPI_modifytuple(rel, rettuple, 1, &numidxattr, &datum, NULL); pfree(DatumGetPointer(datum)); } else { tsvector *out = palloc(CALCDATASIZE(0, 0)); out->len = CALCDATASIZE(0, 0); out->size = 0; datum = PointerGetDatum(out); pfree(prs.words); rettuple = SPI_modifytuple(rel, rettuple, 1, &numidxattr, &datum, NULL); } if (rettuple == NULL) /* internal error */ elog(ERROR, "TSearch: %d returned by SPI_modifytuple", SPI_result); return PointerGetDatum(rettuple); }
void statement(){ int l; int m; symTableEntry* symbol; int tempLabels[2]; if(currentToken == identsym){ symbol = findSymbol(symTable, VAR, tokenVal.string, scope); if(!findVar(tokenVal.string, scope, &l, &m)){ if(findConst(tokenVal.string, scope, &m)) throwError(CANNOT_ASSIGN_TO_CONST_OR_PROC); else throwError(UNDEC_ID); } readToken(); if(currentToken != becomessym) throwError(ASSIGN_EXPEC); readToken(); expression(); genCode(STO, l, m); } else if(currentToken == syawsym){ readToken(); if(currentToken != identsym) throwError(ID_FOLLOW_SYAW); if(!findFunc(tokenVal.string, scope, &l, &m)) throwError(UNDEC_ID); genCode(CAL, l, m); readToken(); } else if(currentToken == sngaisym){ // 'beginsym' readToken(); statement(); while(currentToken == semicolonsym){ readToken(); statement(); } if(currentToken != fpesym && (currentToken != identsym && currentToken != sngaisym && currentToken != txosym && currentToken != tengkrrsym)) // 'endsym' //throwError(WRONG_SYM_AFTER_STATE); throwError(SEMICOL_OR_RBRACK_EXPEC); else if(currentToken == identsym || currentToken == sngaisym || currentToken == txosym || currentToken == tengkrrsym) throwError(SEMICOL_BW_STATE_MISS); readToken(); } else if(currentToken == txosym){ // 'ifsym' tempLabels[1] = 0; readToken(); condition(); tempLabels[0] = reserveCode(); //Conditional jump will go here if(currentToken != tsakrrsym) // 'thensym' throwError(TSAKRR_EXPEC); readToken(); statement(); if(currentToken == txokefyawsym){ tempLabels[1] = reserveCode(); readToken(); } backPatch(tempLabels[0], JPC, 0, genLabel()); if(tempLabels[1]){ statement(); backPatch(tempLabels[1], JMP, 0, genLabel()); } } else if(currentToken == tengkrrsym){ // 'whilesym' readToken(); tempLabels[0] = genLabel(); //Jump back up to here at the end of the loop condition(); tempLabels[1] = reserveCode(); //Stick the conditional jump here if(currentToken != sisym) // 'dosym' throwError(SI_EXPEC); readToken(); statement(); genCode(JMP, 0, tempLabels[0]); backPatch(tempLabels[1], JPC, 0, genLabel()); } else if(currentToken == misym){ // Input genCode(SIO, 0, 2); readToken(); if(currentToken == identsym){ if(findVar(tokenVal.string, scope, &l, &m)) genCode(STO, l, m); else if(findConst(tokenVal.string, scope, &m) || findFunc(tokenVal.string, scope, &l, &m)) throwError(CANNOT_STORE_IN_CONST_OR_PROC); else throwError(UNDEC_ID); readToken(); } } else if(currentToken == wrrpasym){ // Output readToken(); if(currentToken == identsym){ if(findVar(tokenVal.string, scope, &l, &m)) genCode(LOD, l, m); else if(findConst(tokenVal.string, scope, &m)) genCode(LIT, 0, m); else throwError(UNDEC_ID); readToken(); } genCode(SOI, 0, 1); } else if(currentToken == fpesym){ return; } else{ if(currentToken == periodsym) throwError(RBRACK_EXPEC_AT_END); else throwError(STATEMENT_EXPEC); } return; }