void callHandlersOnCreate(){ CALL(onCreate()); }
dlAnimTick* dlNewAnimTick( dlAnim *anim ) { dlNodeAnim *node; dlAnimTickOldNode **oldNode; dlVectorKey *vkey; dlQuatKey *qkey; DL_NODE_TYPE count; CALL("%p", anim); if(!anim) { RET("%p", NULL); return( NULL ); } /* Allocate animation handler object */ dlSetAlloc( ALLOC_EVALUATOR ); dlAnimTick *animTick = (dlAnimTick*)dlCalloc( 1, sizeof(dlAnimTick) ); if(!animTick) { RET("%p", NULL); return( NULL ); } /* assign animation */ animTick->anim = anim; animTick->oldTime = 0.0f; /* null */ animTick->oldNode = NULL; node = anim->node; oldNode = &animTick->oldNode; for(; node; node = node->next) { *oldNode = dlCalloc( 1, sizeof(dlAnimTickOldNode) ); if(!*oldNode) { dlFreeAnimTick( animTick ); RET("%p", NULL); return( NULL ); } /* store translations to pointer array */ if(node->translation) { (*oldNode)->translation = dlCalloc( node->num_translation, sizeof(dlVectorKey*) ); if(!(*oldNode)->translation) { dlFreeAnimTick( animTick ); RET("%p", NULL); return( NULL ); } vkey = node->translation; count = 0; for(; vkey; vkey = vkey->next) (*oldNode)->translation[count++] = vkey; } /* store rortations to pointer array */ if(node->rotation) { (*oldNode)->rotation = dlCalloc( node->num_rotation, sizeof(dlQuatKey*) ); if(!(*oldNode)->rotation) { dlFreeAnimTick( animTick ); RET("%p", NULL); return( NULL ); } qkey = node->rotation; count = 0; for(; qkey; qkey = qkey->next) (*oldNode)->rotation[count++] = qkey; } /* store scalings to pointer array */ if(node->scaling) { (*oldNode)->scaling = dlCalloc( node->num_scaling, sizeof(dlVectorKey*) ); if(!(*oldNode)->scaling) { dlFreeAnimTick( animTick ); RET("%p", NULL); return( NULL ); } vkey = node->scaling; count = 0; for(; vkey; vkey = vkey->next) (*oldNode)->scaling[count++] = vkey; } oldNode = &(*oldNode)->next; } /* no animations, pointless */ if(!anim->node) { dlFreeAnimTick( animTick ); RET("%p", NULL); return( NULL ); } LOGOK("NEW"); /* return */ RET("%p", animTick); return( animTick ); }
ssize_t videobuf_read_stream(struct videobuf_queue *q, char __user *data, size_t count, loff_t *ppos, int vbihack, int nonblocking) { int rc, retval; unsigned long flags = 0; MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); dprintk(2, "%s\n", __FUNCTION__); mutex_lock(&q->vb_lock); retval = -EBUSY; if (q->streaming) goto done; if (!q->reading) { retval = __videobuf_read_start(q); if (retval < 0) goto done; } retval = 0; while (count > 0) { /* get / wait for data */ if (NULL == q->read_buf) { q->read_buf = list_entry(q->stream.next, struct videobuf_buffer, stream); list_del(&q->read_buf->stream); q->read_off = 0; } rc = videobuf_waiton(q->read_buf, nonblocking, 1); if (rc < 0) { if (0 == retval) retval = rc; break; } if (q->read_buf->state == VIDEOBUF_DONE) { rc = CALL(q, copy_stream, q, data + retval, count, retval, vbihack, nonblocking); if (rc < 0) { retval = rc; break; } retval += rc; count -= rc; q->read_off += rc; } else { /* some error */ q->read_off = q->read_buf->size; if (0 == retval) retval = -EIO; } /* requeue buffer when done with copying */ if (q->read_off == q->read_buf->size) { list_add_tail(&q->read_buf->stream, &q->stream); if (q->irqlock) spin_lock_irqsave(q->irqlock, flags); q->ops->buf_queue(q, q->read_buf); if (q->irqlock) spin_unlock_irqrestore(q->irqlock, flags); q->read_buf = NULL; } if (retval < 0) break; }
// License dialog UINT EmLicenseDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) { RPC *s = (RPC *)param; NMHDR *n; // Validate arguments if (hWnd == NULL) { return 0; } switch (msg) { case WM_INITDIALOG: EmLicenseDlgInit(hWnd, s); break; case WM_NOTIFY: n = (NMHDR *)lParam; switch (n->code) { case LVN_ITEMCHANGED: switch (n->idFrom) { case L_LIST: case L_STATUS: EmLicenseDlgUpdate(hWnd, s); break; } break; } break; case WM_COMMAND: switch (wParam) { case IDOK: if (IsEnable(hWnd, IDOK)) { UINT i = LvGetSelected(hWnd, L_LIST); if (i != INFINITE) { char *s = LvGetStrA(hWnd, L_LIST, i, 5); char tmp[MAX_SIZE]; Format(tmp, sizeof(tmp), _SS("LICENSE_SUPPORT_URL"), s); ShellExecute(hWnd, "open", tmp, NULL, NULL, SW_SHOW); Free(s); } } break; case B_OBTAIN: ShellExecute(hWnd, "open", _SS("LICENSE_INFO_URL"), NULL, NULL, SW_SHOW); break; case B_ADD: if (EmLicenseAdd(hWnd, s)) { EmLicenseDlgRefresh(hWnd, s); } break; case B_DEL: if (IsEnable(hWnd, B_DEL)) { UINT id = (UINT)LvGetParam(hWnd, L_LIST, LvGetSelected(hWnd, L_LIST)); if (id != 0) { if (MsgBox(hWnd, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2, _UU("SM_LICENSE_DELETE_MSG")) == IDYES) { RPC_TEST t; Zero(&t, sizeof(t)); t.IntValue = id; if (CALL(hWnd, EcDelLicenseKey(s, &t))) { EmLicenseDlgRefresh(hWnd, s); } } } } break; case IDCANCEL: Close(hWnd); break; } break; case WM_CLOSE: EndDialog(hWnd, 0); break; } LvStandardHandler(hWnd, msg, wParam, lParam, L_LIST); return 0; }
int METH(mainItf, main)(int argc, char **argv) { return CALL(zeroItf, returnZero)(); }
// Main dialog procedure UINT EmMainDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) { NMHDR *n; RPC *r = (RPC *)param; UINT i; char *name; // Validate arguments if (hWnd == NULL) { return 0; } switch (msg) { case WM_INITDIALOG: EmMainInit(hWnd, r); break; case WM_COMMAND: switch (wParam) { case IDOK: // Edit i = LvGetSelected(hWnd, L_LIST); if (i != INFINITE) { wchar_t *tmp; tmp = LvGetStr(hWnd, L_LIST, i, 0); if (tmp != NULL) { name = CopyUniToStr(tmp); EmAdd(hWnd, r, name); Free(tmp); Free(name); } } break; case B_PASSWORD: // Admin password Dialog(hWnd, D_EM_PASSWORD, EmPasswordDlg, r); break; case B_LICENSE: // Admin password Dialog(hWnd, D_EM_LICENSE, EmLicenseDlg, r); break; case B_ADD: // Add EmAdd(hWnd, r, NULL); EmMainRefresh(hWnd, r); break; case B_DELETE: // Delete i = LvGetSelected(hWnd, L_LIST); if (i != INFINITE) { wchar_t *tmp; tmp = LvGetStr(hWnd, L_LIST, i, 0); if (tmp != NULL) { RPC_DELETE_DEVICE t; wchar_t msg[MAX_SIZE]; name = CopyUniToStr(tmp); UniFormat(msg, sizeof(msg), _UU("EM_DELETE_CONFIRM"), name); if (MsgBox(hWnd, MB_YESNO | MB_ICONEXCLAMATION | MB_DEFBUTTON2, msg) == IDYES) { Zero(&t, sizeof(t)); StrCpy(t.DeviceName, sizeof(t.DeviceName), name); if (CALL(hWnd, EcDelDevice(r, &t))) { EmMainRefresh(hWnd, r); } } Free(tmp); Free(name); } } break; case IDCANCEL: Close(hWnd); break; } break; case WM_TIMER: switch (wParam) { case 1: KillTimer(hWnd, 1); EmMainRefresh(hWnd, r); SetTimer(hWnd, 1, 1000, NULL); break; } break; case WM_NOTIFY: n = (NMHDR *)lParam; switch (n->code) { case NM_DBLCLK: switch (n->idFrom) { case L_LIST: if (IsEnable(hWnd, IDOK)) { Command(hWnd, IDOK); } break; } break; case LVN_ITEMCHANGED: switch (n->idFrom) { case L_LIST: EmMainUpdate(hWnd, r); break; } break; } break; case WM_CLOSE: EndDialog(hWnd, 0); break; } return 0; }
// Start the EtherLogger Manager void EMExec() { char *host; char *ret; bool cancel_now = false; TOKEN_LIST *t; UINT port = EL_ADMIN_PORT; InitWinUi(_UU("EM_TITLE"), _SS("DEFAULT_FONT"), _II("DEFAULT_FONT_SIZE")); while (true) { ret = EmRemoteDlg(); if (ret != NULL) { t = ParseToken(ret, ":"); if (t->NumTokens == 1 || t->NumTokens == 2) { RPC *rpc = NULL; bool ok = false; UINT ret; host = t->Token[0]; if (t->NumTokens == 2) { port = ToInt(t->Token[1]); } else { port = EL_ADMIN_PORT; } // Try without a password first ret = EcConnect(host, port, "", &rpc); RETRY: if (ret != ERR_NO_ERROR && ret != ERR_AUTH_FAILED) { // Connection failed CALL(NULL, ret); } else { if (ret == ERR_NO_ERROR) { // Successful connection ok = true; } else { // Password required char *pass = SmPassword(NULL, host); if (pass == NULL) { // Cancel cancel_now = true; } else { // Retry ret = EcConnect(host, port, pass, &rpc); Free(pass); if (ret == ERR_NO_ERROR) { ok = true; } else { goto RETRY; } } } } if (ok) { // Main screen EMMain(rpc); // Disconnect EcDisconnect(rpc); cancel_now = true; } FreeToken(t); } Free(ret); } else { cancel_now = true; } if (cancel_now) { break; } } FreeWinUi(); }
/* non-SSL begin() function. */ static int begin(ne_socket **sock, server_fn fn, void *ud) { unsigned int port; CALL(new_spawn_server(1, fn, ud, &port)); return do_connect(sock, localhost, port); }
int main(void) { int i = 0; int error = 0; int a[5] = {1, 3, 4, 5, 2}; float b[5] = {1.0, 3.0, 4.0, 5.0, 2.0}; char c[5] = {'a', 'b', 'c', 'd', '\0'}; char *strarr[5] = {"ab", "cd", "ef", "g", "h"}; char *dynamicstrarr[5] = {0}; void *p = NULL; PCMstack *s = NULL; CALL(PCMstackcreate (&s, 3)); //integer printf ("integer stack:\n"); for (i = 0; i < 5; ++i) { CALL(PCMstackpush (s, &a[i])); } for (i = 0; i < 5; ++i) { printf ("%5d", *(int*)s->data[i]); } putchar('\n'); for (i = 0; i < 5; ++i) { printf ("%d is poped\n", *(int*)(PCMstackpop(s))); } if ( PCMstackisempty(s) ) { printf ("stack is empty now!\n"); } //float printf ("float stack:\n"); for (i = 0; i < 5; ++i) { CALL(PCMstackpush (s, &b[i])); } for (i = 0; i < 5; ++i) { printf ("%5.2f", *(float*)s->data[i]); } putchar('\n'); for (i = 0; i < 5; ++i) { printf ("%.2f is poped\n", *(float*)(PCMstackpop(s))); } if ( PCMstackisempty(s) ) { printf ("stack is empty now!\n"); } //char printf ("char stack:\n"); for (i = 0; i < 5; ++i) { CALL(PCMstackpush (s, &c[i])); } for (i = 0; i < 5; ++i) { printf ("%5c", *(char*)s->data[i]); } putchar('\n'); for (i = 0; i < 5; ++i) { printf ("%c is poped\n", *(char*)(PCMstackpop(s))); } if ( PCMstackisempty(s) ) { printf ("stack is empty now!\n"); } //strarray printf ("str array stack:\n"); for (i = 0; i < 5; ++i) { CALL(PCMstackpush (s, strarr[i])); } for (i = 0; i < 5; ++i) { printf ("%5s", (char*)s->data[i]); } putchar('\n'); for (i = 0; i < 5; ++i) { printf ("%s is poped\n", (char*)(PCMstackpop(s))); } if ( PCMstackisempty(s) ) { printf ("stack is empty now!\n"); } //dynamic string array printf ("dynamic string array:\n"); for (i = 0; i < 5; ++i) { dynamicstrarr[i] = NULL; dynamicstrarr[i] = malloc (sizeof(char*)); strcpy(dynamicstrarr[i], strarr[i]); CALL(PCMstackpush (s, dynamicstrarr[i])); } for (i = 0; i < 5; ++i) { printf ("%5s", (char*)s->data[i]); } putchar('\n'); /* for (i = 0; i < 5; ++i) { */ /* p = PCMstackpop(s); */ /* printf ("%s is poped\n", (char*)p); */ /* free (p); */ /* } */ if ( PCMstackisempty(s) ) { printf ("stack is empty now!\n"); } PCMstackfree (&s, free); TERMINATE: PCMstackfree (&s, free); PCMcheckerror (error); return 0; }
static int echo_expect(ne_socket *sock, const char *line) { CALL(full_write(sock, line, strlen(line))); return line_expect(sock, line); }
static int fail_socks(void) { static const struct { enum ne_sock_sversion version; enum socks_failure failure; const char *expect; const char *username, *password; } ts[] = { { NE_SOCK_SOCKSV5, fail_init_vers, "Invalid version in proxy response", NULL, NULL }, { NE_SOCK_SOCKSV5, fail_init_trunc, "Could not read initial response from proxy: Connection closed", NULL, NULL }, { NE_SOCK_SOCKSV5, fail_init_close, "Could not read initial response from proxy: Connection closed", NULL, NULL }, { NE_SOCK_SOCKSV5, fail_no_auth, "No acceptable authentication method", NULL, NULL }, { NE_SOCK_SOCKSV5, fail_bogus_auth, "Unexpected authentication method chosen", NULL, NULL }, { NE_SOCK_SOCKSV5, fail_auth_close, "Could not read login reply: Connection closed", "foo", "bar" }, { NE_SOCK_SOCKSV5, fail_auth_denied, "Authentication failed", "foo", "bar" } }; unsigned n; for (n = 0; n < sizeof(ts)/sizeof(ts[n]); n++) { ne_socket *sock; struct socks_server arg = {0}; int ret; arg.version = ts[n].version; arg.failure = ts[n].failure; arg.expect_port = 5555; arg.expect_addr = ne_iaddr_make(ne_iaddr_ipv4, raw_127); arg.username = ts[n].username; arg.password = ts[n].password; CALL(begin_socks(&sock, &arg, echo_server, NULL)); ret = ne_sock_proxy(sock, ts[n].version, arg.expect_addr, NULL, arg.expect_port, ts[n].username, ts[n].password); ONV(ret == 0, ("proxy connect #%u succeeded, expected failure '%s'", n, ts[n].expect)); if (ret != 0 && strstr(ne_sock_error(sock), ts[n].expect) == NULL) { t_warning("proxy connect #%u got unexpected failure '%s', wanted '%s'", n, ne_sock_error(sock), ts[n].expect); } ne_iaddr_free(arg.expect_addr); CALL(finish(sock, 0)); } return OK; }
void callHandlersOnVisibility(bool v){ CALL(onVisibility(v)); }
void callHandlersOnResize(int w, int h){ CALL(onResize(w, h)); }
void callHandlersOnDestroy(){ CALL(onDestroy()); contextDestroy(); }
/* \brief builds and sends the default projection to renderer */ void _glhckRenderDefaultProjection(int width, int height) { CALL(1, "%d, %d", width, height); assert(width > 0 && height > 0); glhckRenderProjection2D(width, height, -1000.0f, 1000.0f); }
LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) { _assert_msg_(G3D, id.linear, "Linear should be set on sampler id"); BeginWrite(); // We'll first write the nearest sampler, which we will CALL. // This may differ slightly based on the "linear" flag. const u8 *nearest = AlignCode16(); if (!Jit_ReadTextureFormat(id)) { EndWrite(); SetCodePtr(const_cast<u8 *>(nearest)); return nullptr; } RET(); // Now the actual linear func, which is exposed externally. const u8 *start = AlignCode16(); // NOTE: This doesn't use the general register mapping. // POSIX: arg1=uptr, arg2=vptr, arg3=frac_u, arg4=frac_v, arg5=src, arg6=bufw, stack+8=level // Win64: arg1=uptr, arg2=vptr, arg3=frac_u, arg4=frac_v, stack+40=src, stack+48=bufw, stack+56=level // // We map these to nearest CALLs, with order: u, v, src, bufw, level // Let's start by saving a bunch of registers. PUSH(R15); PUSH(R14); PUSH(R13); PUSH(R12); // Won't need frac_u/frac_v for a while. PUSH(arg4Reg); PUSH(arg3Reg); // Extra space to restore alignment and save resultReg for lerp. // TODO: Maybe use XMMs instead? SUB(64, R(RSP), Imm8(24)); MOV(64, R(R12), R(arg1Reg)); MOV(64, R(R13), R(arg2Reg)); #ifdef _WIN32 // First arg now starts at 24 (extra space) + 48 (pushed stack) + 8 (ret address) + 32 (shadow space) const int argOffset = 24 + 48 + 8 + 32; MOV(64, R(R14), MDisp(RSP, argOffset)); MOV(32, R(R15), MDisp(RSP, argOffset + 8)); // level is at argOffset + 16. #else MOV(64, R(R14), R(arg5Reg)); MOV(32, R(R15), R(arg6Reg)); // level is at 24 + 48 + 8. #endif // Early exit on !srcPtr. FixupBranch zeroSrc; if (id.hasInvalidPtr) { CMP(PTRBITS, R(R14), Imm8(0)); FixupBranch nonZeroSrc = J_CC(CC_NZ); XOR(32, R(RAX), R(RAX)); zeroSrc = J(true); SetJumpTarget(nonZeroSrc); } // At this point: // R12=uptr, R13=vptr, stack+24=frac_u, stack+32=frac_v, R14=src, R15=bufw, stack+X=level auto doNearestCall = [&](int off) { MOV(32, R(uReg), MDisp(R12, off)); MOV(32, R(vReg), MDisp(R13, off)); MOV(64, R(srcReg), R(R14)); MOV(32, R(bufwReg), R(R15)); // Leave level, we just always load from RAM. Separate CLUTs is uncommon. CALL(nearest); MOV(32, MDisp(RSP, off), R(resultReg)); }; doNearestCall(0); doNearestCall(4); doNearestCall(8); doNearestCall(12); // Convert TL, TR, BL, BR to floats for easier blending. if (!cpu_info.bSSE4_1) { PXOR(XMM0, R(XMM0)); } MOVD_xmm(fpScratchReg1, MDisp(RSP, 0)); MOVD_xmm(fpScratchReg2, MDisp(RSP, 4)); MOVD_xmm(fpScratchReg3, MDisp(RSP, 8)); MOVD_xmm(fpScratchReg4, MDisp(RSP, 12)); if (cpu_info.bSSE4_1) { PMOVZXBD(fpScratchReg1, R(fpScratchReg1)); PMOVZXBD(fpScratchReg2, R(fpScratchReg2)); PMOVZXBD(fpScratchReg3, R(fpScratchReg3)); PMOVZXBD(fpScratchReg4, R(fpScratchReg4)); } else { PUNPCKLBW(fpScratchReg1, R(XMM0)); PUNPCKLBW(fpScratchReg2, R(XMM0)); PUNPCKLBW(fpScratchReg3, R(XMM0)); PUNPCKLBW(fpScratchReg4, R(XMM0)); PUNPCKLWD(fpScratchReg1, R(XMM0)); PUNPCKLWD(fpScratchReg2, R(XMM0)); PUNPCKLWD(fpScratchReg3, R(XMM0)); PUNPCKLWD(fpScratchReg4, R(XMM0)); } CVTDQ2PS(fpScratchReg1, R(fpScratchReg1)); CVTDQ2PS(fpScratchReg2, R(fpScratchReg2)); CVTDQ2PS(fpScratchReg3, R(fpScratchReg3)); CVTDQ2PS(fpScratchReg4, R(fpScratchReg4)); // Okay, now multiply the R sides by frac_u, and L by (256 - frac_u)... MOVD_xmm(fpScratchReg5, MDisp(RSP, 24)); CVTDQ2PS(fpScratchReg5, R(fpScratchReg5)); SHUFPS(fpScratchReg5, R(fpScratchReg5), _MM_SHUFFLE(0, 0, 0, 0)); if (RipAccessible(by256)) { MULPS(fpScratchReg5, M(by256)); // rip accessible } else { Crash(); // TODO } MOVAPS(XMM0, M(ones)); SUBPS(XMM0, R(fpScratchReg5)); MULPS(fpScratchReg1, R(XMM0)); MULPS(fpScratchReg2, R(fpScratchReg5)); MULPS(fpScratchReg3, R(XMM0)); MULPS(fpScratchReg4, R(fpScratchReg5)); // Now set top=fpScratchReg1, bottom=fpScratchReg3. ADDPS(fpScratchReg1, R(fpScratchReg2)); ADDPS(fpScratchReg3, R(fpScratchReg4)); // Next, time for frac_v. MOVD_xmm(fpScratchReg5, MDisp(RSP, 32)); CVTDQ2PS(fpScratchReg5, R(fpScratchReg5)); SHUFPS(fpScratchReg5, R(fpScratchReg5), _MM_SHUFFLE(0, 0, 0, 0)); MULPS(fpScratchReg5, M(by256)); MOVAPS(XMM0, M(ones)); SUBPS(XMM0, R(fpScratchReg5)); MULPS(fpScratchReg1, R(XMM0)); MULPS(fpScratchReg3, R(fpScratchReg5)); // Still at the 255 scale, now we're interpolated. ADDPS(fpScratchReg1, R(fpScratchReg3)); // Time to convert back to a single 32 bit value. CVTPS2DQ(fpScratchReg1, R(fpScratchReg1)); PACKSSDW(fpScratchReg1, R(fpScratchReg1)); PACKUSWB(fpScratchReg1, R(fpScratchReg1)); MOVD_xmm(R(resultReg), fpScratchReg1); if (id.hasInvalidPtr) { SetJumpTarget(zeroSrc); } ADD(64, R(RSP), Imm8(24)); POP(arg3Reg); POP(arg4Reg); POP(R12); POP(R13); POP(R14); POP(R15); RET(); EndWrite(); return (LinearFunc)start; }
/* * Perform sanity checks on the dentry in a client's file handle. * * Note that the file handle dentry may need to be freed even after * an error return. * * This is only called at the start of an nfsproc call, so fhp points to * a svc_fh which is all 0 except for the over-the-wire file handle. */ u32 fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) { struct knfsd_fh *fh = &fhp->fh_handle; struct svc_export *exp = NULL; struct dentry *dentry; struct inode *inode; u32 error = 0; dprintk("nfsd: fh_verify(%s)\n", SVCFH_fmt(fhp)); /* keep this filehandle for possible reference when encoding attributes */ rqstp->rq_reffh = fh; if (!fhp->fh_dentry) { __u32 *datap=NULL; __u32 tfh[3]; /* filehandle fragment for oldstyle filehandles */ int fileid_type; int data_left = fh->fh_size/4; error = nfserr_stale; if (rqstp->rq_client == NULL) goto out; if (rqstp->rq_vers > 2) error = nfserr_badhandle; if (rqstp->rq_vers == 4 && fh->fh_size == 0) return nfserr_nofilehandle; if (fh->fh_version == 1) { int len; datap = fh->fh_auth; if (--data_left<0) goto out; switch (fh->fh_auth_type) { case 0: break; default: goto out; } len = key_len(fh->fh_fsid_type) / 4; if (len == 0) goto out; if (fh->fh_fsid_type == 2) { /* deprecated, convert to type 3 */ len = 3; fh->fh_fsid_type = 3; fh->fh_fsid[0] = new_encode_dev(MKDEV(ntohl(fh->fh_fsid[0]), ntohl(fh->fh_fsid[1]))); fh->fh_fsid[1] = fh->fh_fsid[2]; } if ((data_left -= len)<0) goto out; exp = exp_find(rqstp->rq_client, fh->fh_fsid_type, datap, &rqstp->rq_chandle); datap += len; } else { dev_t xdev; ino_t xino; if (fh->fh_size != NFS_FHSIZE) goto out; /* assume old filehandle format */ xdev = old_decode_dev(fh->ofh_xdev); xino = u32_to_ino_t(fh->ofh_xino); mk_fsid_v0(tfh, xdev, xino); exp = exp_find(rqstp->rq_client, 0, tfh, &rqstp->rq_chandle); } error = nfserr_dropit; if (IS_ERR(exp) && PTR_ERR(exp) == -EAGAIN) goto out; error = nfserr_stale; if (!exp || IS_ERR(exp)) goto out; /* Check if the request originated from a secure port. */ error = nfserr_perm; if (!rqstp->rq_secure && EX_SECURE(exp)) { printk(KERN_WARNING "nfsd: request from insecure port (%08x:%d)!\n", ntohl(rqstp->rq_addr.sin_addr.s_addr), ntohs(rqstp->rq_addr.sin_port)); goto out; } /* Set user creds for this exportpoint */ error = nfsd_setuser(rqstp, exp); if (error) { error = nfserrno(error); goto out; } /* * Look up the dentry using the NFS file handle. */ error = nfserr_stale; if (rqstp->rq_vers > 2) error = nfserr_badhandle; if (fh->fh_version != 1) { tfh[0] = fh->ofh_ino; tfh[1] = fh->ofh_generation; tfh[2] = fh->ofh_dirino; datap = tfh; data_left = 3; if (fh->ofh_dirino == 0) fileid_type = 1; else fileid_type = 2; } else fileid_type = fh->fh_fileid_type; if (fileid_type == 0) dentry = dget(exp->ex_dentry); else { struct export_operations *nop = exp->ex_mnt->mnt_sb->s_export_op; dentry = CALL(nop,decode_fh)(exp->ex_mnt->mnt_sb, datap, data_left, fileid_type, nfsd_acceptable, exp); } if (dentry == NULL) goto out; if (IS_ERR(dentry)) { if (PTR_ERR(dentry) != -EINVAL) error = nfserrno(PTR_ERR(dentry)); goto out; } #ifdef NFSD_PARANOIA if (S_ISDIR(dentry->d_inode->i_mode) && (dentry->d_flags & DCACHE_DISCONNECTED)) { printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n", dentry->d_parent->d_name.name, dentry->d_name.name); } #endif fhp->fh_dentry = dentry; fhp->fh_export = exp; nfsd_nr_verified++; } else { /* just rechecking permissions * (e.g. nfsproc_create calls fh_verify, then nfsd_create does as well) */ dprintk("nfsd: fh_verify - just checking\n"); dentry = fhp->fh_dentry; exp = fhp->fh_export; } cache_get(&exp->h); inode = dentry->d_inode; /* Type check. The correct error return for type mismatches * does not seem to be generally agreed upon. SunOS seems to * use EISDIR if file isn't S_IFREG; a comment in the NFSv3 * spec says this is incorrect (implementation notes for the * write call). */ /* Type can be negative when creating hardlinks - not to a dir */ if (type > 0 && (inode->i_mode & S_IFMT) != type) { if (rqstp->rq_vers == 4 && (inode->i_mode & S_IFMT) == S_IFLNK) error = nfserr_symlink; else if (type == S_IFDIR) error = nfserr_notdir; else if ((inode->i_mode & S_IFMT) == S_IFDIR) error = nfserr_isdir; else error = nfserr_inval; goto out; } if (type < 0 && (inode->i_mode & S_IFMT) == -type) { if (rqstp->rq_vers == 4 && (inode->i_mode & S_IFMT) == S_IFLNK) error = nfserr_symlink; else if (type == -S_IFDIR) error = nfserr_isdir; else error = nfserr_notdir; goto out; } /* Finally, check access permissions. */ error = nfsd_permission(exp, dentry, access); #ifdef NFSD_PARANOIA_EXTREME if (error) { printk("fh_verify: %s/%s permission failure, acc=%x, error=%d\n", dentry->d_parent->d_name.name, dentry->d_name.name, access, (error >> 24)); } #endif out: if (exp && !IS_ERR(exp)) exp_put(exp); if (error == nfserr_stale) nfsdstats.fh_stale++; return error; }
void svc( SYSTEM_CALL_DATA *SystemCallData ) { short call_type; static short do_print = 10; short i; INT32 Time; call_type = (short)SystemCallData->SystemCallNumber; if ( do_print > 0 ) { printf( "SVC handler: %s\n", call_names[call_type]); for (i = 0; i < SystemCallData->NumberOfArguments - 1; i++ ){ //Value = (long)*SystemCallData->Argument[i]; printf( "Arg %d: Contents = (Decimal) %8ld, (Hex) %8lX\n", i, (unsigned long )SystemCallData->Argument[i], (unsigned long )SystemCallData->Argument[i]); } do_print--; } switch (call_type) { case SYSNUM_GET_TIME_OF_DAY: CALL(MEM_READ(Z502ClockStatus, &Time)); *(INT32*)SystemCallData->Argument[0] = Time; break; case SYSNUM_GET_PROCESS_ID: SVCGetProcessID(SystemCallData); break; case SYSNUM_CREATE_PROCESS: SVCCreateProcess(SystemCallData); break; case SYSNUM_SLEEP: SVCStartTimer(SystemCallData); break; case SYSNUM_TERMINATE_PROCESS: SVCTerminateProcess(SystemCallData); break; case SYSNUM_SUSPEND_PROCESS: SVCSuspendProcess(SystemCallData); break; case SYSNUM_RESUME_PROCESS: SVCResumeProcess(SystemCallData); break; case SYSNUM_CHANGE_PRIORITY: SVCChangeProcessPriority(SystemCallData); break; case SYSNUM_SEND_MESSAGE: SVCSendMessage(SystemCallData); break; case SYSNUM_RECEIVE_MESSAGE: SVCReceiveMessage(SystemCallData); break; case SYSNUM_DISK_WRITE: SVCWriteDisk(SystemCallData); break; case SYSNUM_DISK_READ: SVCReadDisk(SystemCallData); break; default: printf("ERROR! call_type not recognized!\n"); printf("Call_type is - %i\n", call_type); break; } } // End of svc
// Installation of WinPcap void EmInstallWinPcap(HWND hWnd, RPC *r) { wchar_t temp_name[MAX_SIZE]; HGLOBAL g; HINSTANCE h; HRSRC hr; UINT size; void *data; IO *io; // Ask whether the user want to start the installation if (MsgBox(hWnd, MB_ICONQUESTION | MB_YESNO, _UU("EM_WPCAP_INSTALL")) == IDNO) { return; } // Generate a temporary file name UniFormat(temp_name, sizeof(temp_name), L"%s\\winpcap_installer.exe", MsGetTempDirW()); // Read from the resource h = GetUiDll(); hr = FindResource(h, MAKEINTRESOURCE(BIN_WINPCAP), "BIN"); if (hr == NULL) { RES_ERROR: MsgBox(hWnd, MB_ICONSTOP, _UU("EM_RESOURCE")); return; } g = LoadResource(h, hr); if (g == NULL) { goto RES_ERROR; } size = SizeofResource(h, hr); data = LockResource(g); if (data == NULL) { goto RES_ERROR; } // Write to a temporary file io = FileCreateW(temp_name); if (io == NULL) { goto RES_ERROR; } FileWrite(io, data, size); FileClose(io); // Run if (RunW(temp_name, NULL, false, true) == false) { // Failure FileDeleteW(temp_name); goto RES_ERROR; } FileDeleteW(temp_name); if (r == NULL) { return; } // Message after the end if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType) == false) { // Need to restart the computer MsgBox(hWnd, MB_ICONINFORMATION, _UU("EM_WPCAP_REBOOT1")); } else { // Need to restart the service if (MsgBox(hWnd, MB_ICONQUESTION | MB_YESNO, _UU("EM_WPCAP_REBOOT2")) == IDNO) { // Not restart } else { // Restart RPC_TEST t; RPC_BRIDGE_SUPPORT t2; Zero(&t, sizeof(t)); EcRebootServer(r, &t); SleepThread(500); Zero(&t2, sizeof(t2)); CALL(hWnd, EcGetBridgeSupport(r, &t2)); } } }
const char *signCMS( struct CMS *cms, const char *keyfilename, bool bad) { bool hashContext_initialized = false; CRYPT_CONTEXT hashContext; bool sigKeyContext_initialized = false; CRYPT_CONTEXT sigKeyContext; CRYPT_KEYSET cryptKeyset; int signatureLength; int tbs_lth; char *msg = (char *)0; uchar *tbsp; uchar *signature; uchar hash[40]; struct casn *sidp; struct Attribute *attrp; struct AttrTableDefined *attrtdp; struct SignerInfo *sigInfop; // signer info // firat clear out any old stuff in signerInfos that may have been put // there by old code while (num_items(&cms->content.signedData.signerInfos.self) > 0) eject_casn(&cms->content.signedData.signerInfos.self, 0); sigInfop = (struct SignerInfo *) inject_casn(&(cms->content.signedData.signerInfos.self), 0); // write the signature version (3) to the signer info write_casn_num(&sigInfop->version.self, 3); // find the SID if ((sidp = findSID(cms)) == NULL) return "finding SID"; // copy the CMS's SID over to the signature's SID copy_casn(&sigInfop->sid.subjectKeyIdentifier, sidp); // use sha256 as the algorithm write_objid(&sigInfop->digestAlgorithm.algorithm, id_sha256); // no parameters to sha256 write_casn(&sigInfop->digestAlgorithm.parameters.sha256, (uchar *) "", 0); // first attribute: content type attrp = (struct Attribute *)inject_casn(&sigInfop->signedAttrs.self, 0); write_objid(&attrp->attrType, id_contentTypeAttr); attrtdp = (struct AttrTableDefined *)inject_casn(&attrp->attrValues.self, 0); copy_casn(&attrtdp->contentType, &cms->content.signedData.encapContentInfo.eContentType); // second attribute: message digest attrp = (struct Attribute *)inject_casn(&sigInfop->signedAttrs.self, 1); write_objid(&attrp->attrType, id_messageDigestAttr); // create the hash for the content // first pull out the content if ((tbs_lth = readvsize_casn(&cms->content.signedData.encapContentInfo.eContent. self, &tbsp)) < 0) return "getting content"; // set up the context, initialize crypt memset(hash, 0, 40); if (cryptInit() != CRYPT_OK) return "initializing cryptlib"; // the following calls function f, and if f doesn't return 0 sets // msg to m, then breaks out of the loop. Used immediately below. #define CALL(f,m) if (f != 0) { msg = m; break; } // use a "do { ... } while (0)" loop to bracket this code, so we can // bail out on failure. (Note that this construct isn't really a // loop; it's a way to use break as a more clean version of goto.) do { // first sign the body of the message // create the context CALL(cryptCreateContext(&hashContext, CRYPT_UNUSED, CRYPT_ALGO_SHA2), "creating context"); hashContext_initialized = true; // generate the hash CALL(cryptEncrypt(hashContext, tbsp, tbs_lth), "hashing"); CALL(cryptEncrypt(hashContext, tbsp, 0), "hashing"); // get the hash value. then we're done, so destroy it CALL(cryptGetAttributeString (hashContext, CRYPT_CTXINFO_HASHVALUE, hash, &signatureLength), "getting first hash"); CALL(cryptDestroyContext(hashContext), "destroying intermediate context"); // insert the hash as the first attribute attrtdp = (struct AttrTableDefined *)inject_casn(&attrp->attrValues.self, 0); write_casn(&attrtdp->messageDigest, hash, signatureLength); // create signing time attribute; mark the signing time as now if (getenv("RPKI_NO_SIGNING_TIME") == NULL) { attrp = (struct Attribute *)inject_casn(&sigInfop->signedAttrs.self, 2); write_objid(&attrp->attrType, id_signingTimeAttr); attrtdp = (struct AttrTableDefined *)inject_casn(&attrp->attrValues.self, 0); write_casn_time(&attrtdp->signingTime.utcTime, time((time_t *) 0)); } // we are all done with the content free(tbsp); // now sign the attributes // get the size of signed attributes and allocate space for them if ((tbs_lth = size_casn(&sigInfop->signedAttrs.self)) < 0) { msg = "sizing SignerInfo"; break; } tbsp = (uchar *) calloc(1, tbs_lth); encode_casn(&sigInfop->signedAttrs.self, tbsp); *tbsp = ASN_SET; // create a new, fresh hash context for hashing the attrs, and hash // them CALL(cryptCreateContext(&hashContext, CRYPT_UNUSED, CRYPT_ALGO_SHA2), "creating hash context"); CALL(cryptEncrypt(hashContext, tbsp, tbs_lth), "hashing attrs"); CALL(cryptEncrypt(hashContext, tbsp, 0), "hashing attrs"); // get the hash value CALL(cryptGetAttributeString (hashContext, CRYPT_CTXINFO_HASHVALUE, hash, &signatureLength), "getting attr hash"); // get the key and sign it CALL(cryptKeysetOpen (&cryptKeyset, CRYPT_UNUSED, CRYPT_KEYSET_FILE, keyfilename, CRYPT_KEYOPT_READONLY), "opening key set"); CALL(cryptCreateContext(&sigKeyContext, CRYPT_UNUSED, CRYPT_ALGO_RSA), "creating RSA context"); sigKeyContext_initialized = true; CALL(cryptGetPrivateKey (cryptKeyset, &sigKeyContext, CRYPT_KEYID_NAME, "label", "password"), "getting key"); CALL(cryptCreateSignature (NULL, 0, &signatureLength, sigKeyContext, hashContext), "signing"); // check the signature to make sure it's right signature = (uchar *) calloc(1, signatureLength + 20); // second parameter is signatureMaxLength, so we allow a little more CALL(cryptCreateSignature (signature, signatureLength + 20, &signatureLength, sigKeyContext, hashContext), "signing"); // verify that the signature is right CALL(cryptCheckSignature (signature, signatureLength, sigKeyContext, hashContext), "verifying"); // end of protected block } while (0); // done with cryptlib, shut it down if (hashContext_initialized) { cryptDestroyContext(hashContext); hashContext_initialized = false; } if (sigKeyContext_initialized) { cryptDestroyContext(sigKeyContext); sigKeyContext_initialized = false; } // did we have any trouble above? if so, bail if (msg != 0) { return msg; } // ok, write the signature back to the object struct SignerInfo sigInfo; SignerInfo(&sigInfo, (ushort) 0); decode_casn(&sigInfo.self, signature); // were we supposed to make a bad signature? if so, make it bad if (bad) { uchar *sig; int siz = readvsize_casn(&sigInfo.signature, &sig); sig[0]++; write_casn(&sigInfo.signature, sig, siz); free(sig); } // copy the signature into the object copy_casn(&sigInfop->signature, &sigInfo.signature); delete_casn(&sigInfo.self); // all done with it now free(signature); // Mark it as encrypted with rsa, no params. // See http://www.ietf.org/mail-archive/web/sidr/current/msg04813.html for // why we use id_rsadsi_rsaEncryption instead of id_sha_256WithRSAEncryption // here. write_objid(&sigInfop->signatureAlgorithm.algorithm, id_rsadsi_rsaEncryption); write_casn(&sigInfop->signatureAlgorithm.parameters.self, (uchar *) "", 0); // no errors, we return NULL return NULL; }
// License dialog update void EmLicenseDlgRefresh(HWND hWnd, RPC *s) { RPC_ENUM_LICENSE_KEY t; RPC_EL_LICENSE_STATUS st; UINT i; wchar_t tmp[MAX_SIZE]; LVB *b; // Validate arguments if (hWnd == NULL || s == NULL) { return; } Zero(&t, sizeof(t)); if (CALL(hWnd, EcEnumLicenseKey(s, &t)) == false) { Close(hWnd); return; } b = LvInsertStart(); for (i = 0;i < t.NumItem;i++) { wchar_t tmp1[32], tmp2[LICENSE_KEYSTR_LEN + 1], tmp3[LICENSE_MAX_PRODUCT_NAME_LEN + 1], *tmp4, tmp5[128], tmp6[LICENSE_LICENSEID_STR_LEN + 1], tmp7[64], tmp8[64], tmp9[64]; RPC_ENUM_LICENSE_KEY_ITEM *e = &t.Items[i]; UniToStru(tmp1, e->Id); StrToUni(tmp2, sizeof(tmp2), e->LicenseKey); StrToUni(tmp3, sizeof(tmp3), e->LicenseName); tmp4 = LiGetLicenseStatusStr(e->Status); if (e->Expires == 0) { UniStrCpy(tmp5, sizeof(tmp5), _UU("SM_LICENSE_NO_EXPIRES")); } else { GetDateStrEx64(tmp5, sizeof(tmp5), e->Expires, NULL); } StrToUni(tmp6, sizeof(tmp6), e->LicenseId); UniToStru(tmp7, e->ProductId); UniFormat(tmp8, sizeof(tmp8), L"%I64u", e->SystemId); UniToStru(tmp9, e->SerialId); LvInsertAdd(b, e->Status == LICENSE_STATUS_OK ? ICO_PASS : ICO_DISCARD, (void *)e->Id, 9, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9); } LvInsertEnd(b, hWnd, L_LIST); FreeRpcEnumLicenseKey(&t); Zero(&st, sizeof(st)); if (CALL(hWnd, EcGetLicenseStatus(s, &st)) == false) { Close(hWnd); return; } b = LvInsertStart(); if (st.Valid == false) { LvInsertAdd(b, 0, NULL, 2, _UU("EM_NO_LICENSE_COLUMN"), _UU("EM_NO_LICENSE")); } else { // Current system ID UniFormat(tmp, sizeof(tmp), L"%I64u", st.SystemId); LvInsertAdd(b, 0, NULL, 2, _UU("SM_LICENSE_STATUS_SYSTEM_ID"), tmp); // Expiration date of the current license product if (st.SystemExpires == 0) { UniStrCpy(tmp, sizeof(tmp), _UU("SM_LICENSE_NO_EXPIRES")); } else { GetDateStrEx64(tmp, sizeof(tmp), st.SystemExpires, NULL); } LvInsertAdd(b, 0, NULL, 2, _UU("SM_LICENSE_STATUS_EXPIRES"), tmp); } LvInsertEnd(b, hWnd, L_STATUS); if (LvNum(hWnd, L_STATUS) >= 1) { LvAutoSize(hWnd, L_STATUS); } EmLicenseDlgUpdate(hWnd, s); }
/* \brief set render pass flags */ GLHCKAPI void glhckRenderPass(unsigned int flags) { GLHCK_INITIALIZED(); CALL(2, "%u", flags); GLHCKRP()->flags = flags; }
// Initialize void EmAddInit(HWND hWnd, EM_ADD *p) { // Validate arguments if (hWnd == NULL || p == NULL) { return; } // Initialize controls CbAddStr(hWnd, C_PACKET_SWITCH, _UU("SM_LOG_SWITCH_0"), 0); CbAddStr(hWnd, C_PACKET_SWITCH, _UU("SM_LOG_SWITCH_1"), 1); CbAddStr(hWnd, C_PACKET_SWITCH, _UU("SM_LOG_SWITCH_2"), 2); CbAddStr(hWnd, C_PACKET_SWITCH, _UU("SM_LOG_SWITCH_3"), 3); CbAddStr(hWnd, C_PACKET_SWITCH, _UU("SM_LOG_SWITCH_4"), 4); CbAddStr(hWnd, C_PACKET_SWITCH, _UU("SM_LOG_SWITCH_5"), 5); if (p->NewMode) { // Newly creation mode RPC_ENUM_DEVICE t; HUB_LOG g; Zero(&g, sizeof(g)); g.PacketLogSwitchType = LOG_SWITCH_DAY; g.PacketLogConfig[PACKET_LOG_TCP_CONN] = g.PacketLogConfig[PACKET_LOG_DHCP] = 1; EmHubLogToDlg(hWnd, &g); Zero(&t, sizeof(t)); if (CALL(hWnd, EcEnumAllDevice(p->Rpc, &t))) { UINT i; CbSetHeight(hWnd, C_DEVICE, 18); for (i = 0;i < t.NumItem;i++) { RPC_ENUM_DEVICE_ITEM *dev = &t.Items[i]; wchar_t tmp[MAX_SIZE]; StrToUni(tmp, sizeof(tmp), dev->DeviceName); CbAddStr(hWnd, C_DEVICE, tmp, 0); } FreeRpcEnumDevice(&t); } SetText(hWnd, 0, _UU("EM_ADD_NEW")); } else { // Edit mode (to obtain a configuration) wchar_t tmp[MAX_PATH]; RPC_ADD_DEVICE t; Hide(hWnd, R_PROMISCUOUS); Zero(&t, sizeof(t)); StrCpy(t.DeviceName, sizeof(t.DeviceName), p->DeviceName); if (CALL(hWnd, EcGetDevice(p->Rpc, &t))) { EmHubLogToDlg(hWnd, &t.LogSetting); } else { Close(hWnd); } StrToUni(tmp, sizeof(tmp), p->DeviceName); CbAddStr(hWnd, C_DEVICE, tmp, 0); Disable(hWnd, C_DEVICE); SetText(hWnd, 0, _UU("EM_ADD_EDIT")); } EmAddUpdate(hWnd, p); }
/* \brief set render pass front face orientation */ GLHCKAPI void glhckRenderFrontFace(glhckFaceOrientation orientation) { GLHCK_INITIALIZED(); CALL(2, "%d", orientation); GLHCKRP()->frontFace = orientation; }
void dlAdvanceAnimTick( dlAnimTick *animTick, float pTime ) { dlAnim *anim; dlNodeAnim *node; dlAnimTickOldNode *oldNode; unsigned int frame, nextFrame; dlVectorKey *vkey, *nextvKey; dlQuatKey *qkey, *nextqKey; kmVec3 presentTranslation, presentScaling; kmQuaternion presentRotation; float diffTime, factor; float ticksPerSecond; CALL("%p, %f", animTick, pTime); /* get dlAnim */ anim = animTick->anim; ticksPerSecond = anim->ticksPerSecond != 0.0 ? anim->ticksPerSecond : 25.0f; pTime *= ticksPerSecond; /* map into anim's duration */ float time = 0.0f; if( anim->duration > 0.0) time = fmod( pTime, anim->duration); /* calculate the transformations for each animation channel */ node = anim->node; oldNode = animTick->oldNode; while(node && oldNode) { /* ******** Position **** */ presentTranslation.x = 0; presentTranslation.y = 0; presentTranslation.z = 0; if(node->translation) { frame = (time >= animTick->oldTime) ? oldNode->translationTime : 0; while( frame < node->num_translation - 1) { if( time < oldNode->translation[frame+1]->time) break; ++frame; } /* interpolate between this frame's value and next frame's value */ nextFrame = (frame + 1) % node->num_translation; vkey = oldNode->translation[frame]; nextvKey = oldNode->translation[nextFrame]; diffTime = nextvKey->time - vkey->time; #if 1 if( diffTime < 0.0) diffTime += anim->duration; if( diffTime > 0) { factor = (time - vkey->time) / diffTime; presentTranslation.x = vkey->value.x + (nextvKey->value.x - vkey->value.x) * factor; presentTranslation.y = vkey->value.y + (nextvKey->value.y - vkey->value.y) * factor; presentTranslation.z = vkey->value.z + (nextvKey->value.z - vkey->value.z) * factor; } else { presentTranslation = vkey->value; } #else presentTranslation = vkey->value; #endif oldNode->translationTime = frame; } /* ******** Rotation ******** */ presentRotation.w = 0; presentRotation.x = 0; presentRotation.y = 0; presentRotation.z = 0; if(node->rotation) { frame = (time >= animTick->oldTime) ? oldNode->rotationTime : 0; while( frame < node->num_rotation - 1) { if( time < oldNode->rotation[frame+1]->time) break; ++frame; } /* interpolate between this frame's value and next frame's value */ nextFrame = (frame + 1) % node->num_rotation; qkey = oldNode->rotation[frame]; nextqKey = oldNode->rotation[nextFrame]; diffTime = nextqKey->time - qkey->time; #if 1 if( diffTime < 0.0f) diffTime += anim->duration; if( diffTime > 0.0f) { factor = (time - qkey->time) / diffTime; kmQuaternionSlerp( &presentRotation, &qkey->value, &nextqKey->value, factor); } else { presentRotation = qkey->value; } #else presentRotation = qkey->value; #endif oldNode->rotationTime = frame; } /* ******** Scaling ********** */ presentScaling.x = 1; presentScaling.y = 1; presentScaling.z = 1; if(node->scaling) { frame = (time >= animTick->oldTime) ? oldNode->scalingTime : 0; while( frame < node->num_scaling - 1) { if( time < oldNode->scaling[frame+1]->time) break; ++frame; } /* TODO: (thom) interpolation maybe? This time maybe even logarithmic, not linear */ presentScaling = oldNode->scaling[frame]->value; oldNode->scalingTime = frame; } // build a transformation matrix from it kmMat4 *mat = &node->bone->relativeMatrix; kmMat4RotationQuaternion( mat, &presentRotation ); mat->mat[0] *= presentScaling.x; mat->mat[4] *= presentScaling.x; mat->mat[8] *= presentScaling.x; mat->mat[1] *= presentScaling.y; mat->mat[5] *= presentScaling.y; mat->mat[9] *= presentScaling.y; mat->mat[2] *= presentScaling.z; mat->mat[6] *= presentScaling.z; mat->mat[10] *= presentScaling.z; mat->mat[3] = presentTranslation.x; mat->mat[7] = presentTranslation.y; mat->mat[11] = presentTranslation.z; node = node->next; oldNode = oldNode->next; } /* old time */ animTick->oldTime = time; }
/* \brief set render pass cull face side */ GLHCKAPI void glhckRenderCullFace(glhckCullFaceType face) { GLHCK_INITIALIZED(); CALL(2, "%d", face); GLHCKRP()->cullFace = face; }
ssize_t videobuf_read_one(struct videobuf_queue *q, char __user *data, size_t count, loff_t *ppos, int nonblocking) { enum v4l2_field field; unsigned long flags = 0; unsigned size, nbufs; int retval; MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); mutex_lock(&q->vb_lock); nbufs = 1; size = 0; q->ops->buf_setup(q, &nbufs, &size); if (NULL == q->read_buf && count >= size && !nonblocking) { retval = videobuf_read_zerocopy(q, data, count, ppos); if (retval >= 0 || retval == -EIO) /* ok, all done */ goto done; /* fallback to kernel bounce buffer on failures */ } if (NULL == q->read_buf) { /* need to capture a new frame */ retval = -ENOMEM; q->read_buf = videobuf_alloc(q); dprintk(1, "video alloc=0x%p\n", q->read_buf); if (NULL == q->read_buf) goto done; q->read_buf->memory = V4L2_MEMORY_USERPTR; q->read_buf->bsize = count; /* preferred size */ field = videobuf_next_field(q); retval = q->ops->buf_prepare(q, q->read_buf, field); if (0 != retval) { kfree(q->read_buf); q->read_buf = NULL; goto done; } if (q->irqlock) spin_lock_irqsave(q->irqlock, flags); q->ops->buf_queue(q, q->read_buf); if (q->irqlock) spin_unlock_irqrestore(q->irqlock, flags); q->read_off = 0; } /* wait until capture is done */ retval = videobuf_waiton(q->read_buf, nonblocking, 1); if (0 != retval) goto done; CALL(q, sync, q, q->read_buf); if (VIDEOBUF_ERROR == q->read_buf->state) { /* catch I/O errors */ q->ops->buf_release(q, q->read_buf); kfree(q->read_buf); q->read_buf = NULL; retval = -EIO; goto done; } /* Copy to userspace */ retval = CALL(q, video_copy_to_user, q, data, count, nonblocking); if (retval < 0) goto done; q->read_off += retval; if (q->read_off == q->read_buf->size) { /* all data copied, cleanup */ q->ops->buf_release(q, q->read_buf); kfree(q->read_buf); q->read_buf = NULL; } done: mutex_unlock(&q->vb_lock); return retval; }
/* \brief set vertically flipped rendering mode */ GLHCKAPI void glhckRenderFlip(int flip) { GLHCK_INITIALIZED(); CALL(2, "%d", flip); GLHCKRD()->view.flippedProjection = flip; }
int main(int argc, const char * argv[]) { check_same("Mov literal", 3, Asm<int>( MOV(eax, 3_d), RET())() ); check_same("64 bit register MOV", 6, Asm<int>( MOV(rax, 6_q), RET())() ); check_same("Negative literal", -103, Asm<int>( MOV(eax, -3_d), ADD(eax, - - -100_d), RET())() ); check_same("Move reg to reg", 4, Asm<int>( MOV(ecx, 4_d), MOV(eax, ecx), RET())() ); check_same("Simple jmp", 3, Asm<int>( MOV(eax, 3_d), JMP("a"_rel8), ADD(eax, 2_d), "a"_label, RET())() ); check_same("Simple loop", 30, Asm<int>( MOV(ecx, 5_d), MOV(eax, 0_d), "start"_label, CMP(ecx, 0_d), JE("done"_rel8), ADD(eax, 6_d), DEC(ecx), JMP("start"_rel8), "done"_label, RET())() ); check_same("Macro simple loop", 30, Asm<int>( MOV(eax, 0_d), do_x_times(5_d, ADD(eax, 6_d)), RET())() ); check_same("Access arg using esp", 1, Asm<int>( MOV(eax, _[esp + 28_d]), RET())(1, 2, 3) ); check_same("Access arg using ebp", 1, Asm<int>( MOV(eax, _[ebp - 0xc_b]), RET())(1, 2, 3) ); check_same("Index ebp", 1, Asm<int>( MOV(ecx, 2_d), MOV(eax, _[ebp + ecx * 2_b - 0x10_d]), RET())(1, 2, 3) ); check_same("Access args using ebp", 5, Asm<int>( MOV(edx, 0_d), MOV(eax, _[ebp - 0xc_b]), MOV(ecx, _[ebp - 0x10_b]), DIV(ecx), MOV(ecx, _[ebp - 0x14_b]), DIV(ecx), RET())(100, 5, 4) ); check_same("Access arg with 64 bit reg", 2, Asm<int>( MOV(rax, _[rsp + 24_d]), RET())(1, 2, 3) ); check_same("Access second register zero", 1, Asm<int>( MOV(ecx, 0_d), MOV(eax, _[esp + 28_d + ecx]), RET())(1, 2, 3) ); check_same("Access second register with offset", 1, Asm<int>( MOV(ecx, 8_d), MOV(eax, _[esp + 20_d + ecx]), RET())(1, 2, 3) ); check_same("Access second register with offset and 1 scale", 1, Asm<int>( MOV(ecx, 8_d), MOV(eax, _[esp + 20_d + ecx * 1_b]), RET())(1, 2, 3) ); check_same("Access second register with offset and 4 scale", 1, Asm<int>( MOV(ecx, 2_d), MOV(eax, _[esp + 20_d + ecx * 4_b]), RET())(1, 2, 3) ); check_same("Call c function from assembly", 66, Asm<int>( MOV(rbx, _[rsp + 8_d]), CALL(rbx), RET())(&ret66) ); check_same("Call c function from esp directly", 66, Asm<int>( CALL(_[rsp + 8_d]), RET())(&ret66) ); check_same("Call c function from ebp directly", 66, Asm<int>( CALL(_[rbp - 0x10_d]), RET())(&ret66) ); // auto p = Asm<int>(CALL(_[rbp - 0xc_d])); // Print<decltype(p)::program> x{}; std::cout << "done" << std::endl; return 0; }
void callHandlersOnFrame() { CALL(onFrame()); }