task main(){ while(true) { moveR(); moveL(); moveS(); moveB(); } }
P op_errormessage(void) { LBIG e, pid, port; P nb, tnb; B *m, *s; if (o_6 < FLOORopds) goto baderror; if (CLASS(o_6) != NUM) goto baderror; if (! VALUE(o_6, &pid)) goto baderror; if (TAG(o_5) != (ARRAY | BYTETYPE)) goto baderror; if (CLASS(o_4) != NUM) goto baderror; if (! VALUE(o_4, &port)) goto baderror; if (TAG(o_3) != (ARRAY | BYTETYPE)) goto baderror; if (CLASS(o_2) != NUM) goto baderror; if (!VALUE(o_2, &e)) goto baderror; if (TAG(o_1) != (ARRAY | BYTETYPE)) goto baderror; s = (B *)VALUE_BASE(o_1); tnb = ARRAY_SIZE(o_1); nb = dm_snprintf((char*) s, tnb, "On %*s port %llu, pid %llu: ", (int) ARRAY_SIZE(o_5), (char*) VALUE_BASE(o_5), (unsigned long long) port, (unsigned long long) pid); s += nb; tnb -= nb; if ((P)e < 0) /*Clib error */ nb = dm_snprintf((char*) s, tnb, "errno: %s", (char*) strerror(-(int)e)); else { /* one of our error codes: decode */ m = geterror((P) e); nb = strlen((char*) m); if (nb > tnb) nb = tnb; moveB(m, s, nb); } s += nb; tnb -= nb; nb = dm_snprintf((char*)s, tnb, " in %*s\n", (int) ARRAY_SIZE(o_3), (char*) VALUE_BASE(o_3)); ARRAY_SIZE(o_1) = (P)(s + nb) - VALUE_BASE(o_1); moveframe(o_1,o_6); FREEopds = o_5; return OK; baderror: printf("**Error with corrupted error info on operand stack!\n"); return op_halt(); }
P op_Xconnect(void) { #if X_DISPLAY_MISSING return NO_XWINDOWS; #else P retc; if (o_1 < FLOORopds) return OPDS_UNF; if (TAG(o_1) != (ARRAY | BYTETYPE)) return OPD_ERR; if (ARRAY_SIZE(o_1) > (P) sizeof(displayname)-1) return RNG_CHK; DEBUG("open display%s", ""); if (ARRAY_SIZE(o_1) > 0) { moveB((B *)VALUE_BASE(o_1), displayname, ARRAY_SIZE(o_1)); displayname[ARRAY_SIZE(o_1)] = '\000'; dvtdisplay = XOpenDisplay((char*)displayname); } else if ((dvtdisplay = XOpenDisplay(NULL))) { strncpy((char*)displayname, DisplayString(dvtdisplay), sizeof(displayname)-1); displayname[sizeof(displayname)-1] = '\000'; }; if (! dvtdisplay) { *displayname = '\0'; return X_BADHOST; }; setenv("DISPLAY", (char*)displayname, 1); dvtscreen = HXDefaultScreenOfDisplay(dvtdisplay); dvtrootwindow = HXDefaultRootWindow(dvtdisplay); if (HXGetWindowAttributes(dvtdisplay,dvtrootwindow,&rootwindowattr) == 0) dm_error(0, "Xwindows: no root window attributes"); ndvtwindows = 0; ncachedfonts = 0; dvtgc = HXCreateGC(dvtdisplay,dvtrootwindow,0,NULL); xsocket = ConnectionNumber(dvtdisplay); if ((retc = addsocket(xsocket, &sockettype, &defaultsocketinfo))) { if (retc == SOCK_STATE) { if (close(xsocket)) return -errno; xsocket = -1; } int_Xdisconnect(TRUE); return retc; } FREEopds = o_1; XSetErrorHandler(xerrorhandler); XSetIOErrorHandler(xioerrorhandler); return OK; #endif }
void keyPressed(unsigned char x, int i, int j) { switch(x){ case 'x': exit(0); case 'z': Aisclippingwindow = !Aisclippingwindow; break; case 'a': eyex-=0.5; break; case 'd': eyex+=0.5; break; case 'w': eyez-=0.5; break; case 's': eyez+=0.5; break; case 'q': eyey+=0.5; break; case 'e': eyey-=0.5; break; case 'n': moveB(posB++); break; } onDraw(); }
// (pattern) | [ (path)...] P op_glob(void) { glob_t gl; size_t i; B* curr = FREEvm; B* top; P retc = OK; if (o_1 < FLOORopds) return OPDS_UNF; if (TAG(o_1) != (ARRAY|BYTETYPE)) return OPD_CLA; if (curr + ARRAY_SIZE(o_1) + 1 >= CEILvm) return VM_OVF; moveB(VALUE_PTR(o_1), curr, ARRAY_SIZE(o_1)); curr += ARRAY_SIZE(o_1); curr[0] = '\0'; curr = FREEvm; switch (glob((char*) curr, GLOB_BRACE|GLOB_TILDE, NULL, &gl)) { case 0: break; case GLOB_NOMATCH: if (curr + FRAMEBYTES >= CEILvm) return VM_OVF; TAG(curr) = LIST; ATTR(curr) = PARENT; VALUE_PTR(curr) = LIST_CEIL_PTR(curr) = curr + FRAMEBYTES; curr += FRAMEBYTES; moveframe(FREEvm, o_1); FREEvm = curr; return OK; case GLOB_NOSPACE: return MEM_OVF; case GLOB_ABORTED: return errno ? -errno : READ_ERROR; default: return UNKNOWN_ERR; }; if (curr + FRAMEBYTES + FRAMEBYTES * gl.gl_pathc >= CEILvm) goto vm_ovf; TAG(curr) = LIST; ATTR(curr) = PARENT; VALUE_PTR(curr) = curr + FRAMEBYTES; top = LIST_CEIL_PTR(curr) = curr + FRAMEBYTES + FRAMEBYTES * gl.gl_pathc; curr += FRAMEBYTES; for (i = 0; i < gl.gl_pathc; ++i) { size_t len = strlen(gl.gl_pathv[i]); if (top + FRAMEBYTES + DALIGN(len) >= CEILvm) goto vm_ovf; TAG(top) = (ARRAY|BYTETYPE); ATTR(top) = PARENT; VALUE_PTR(top) = top + FRAMEBYTES; ARRAY_SIZE(top) = len; moveframe(top, curr); curr += FRAMEBYTES; top += FRAMEBYTES; moveB((B*) gl.gl_pathv[i], top, len); top += DALIGN(len); } moveframe(FREEvm, o_1); FREEvm = top; goto exit; vm_ovf: retc = VM_OVF; exit: globfree(&gl); return retc; }
P op_makewindow(void) { #if X_DISPLAY_MISSING return NO_XWINDOWS; #else static XClassHint classhint = {"d_machine", "d_machine"}; static XWMHints xwmhints = {InputHint, False}; static Atom atom[2]; static Atom opaque; static L32 opaqueval = ~(L32) 0; P retc; W *pxy; B *xyf, *freevm, nstr[31], icstr[13], *pn[1] = { nstr }, *pic[1] = { icstr }; XSetWindowAttributes attr; XTextProperty wname, icname; if (dvtdisplay == NULL) return NO_XWINDOWS; attr.event_mask = (ButtonPressMask | ExposureMask | StructureNotifyMask); attr.override_redirect = False; if (o_3 < FLOORopds) return OPDS_UNF; if (TAG(o_1) != (ARRAY | BYTETYPE)) return OPD_ERR; if (ARRAY_SIZE(o_1) > 12) return RNG_CHK; moveB((B *)VALUE_BASE(o_1),icstr,ARRAY_SIZE(o_1)); icstr[ARRAY_SIZE(o_1)] = '\000'; if (XStringListToTextProperty((char**) pic,1,&icname) == 0) return X_ERR; if (TAG(o_2) != (ARRAY | BYTETYPE)) return OPD_ERR; if (ARRAY_SIZE(o_2) > 30) return RNG_CHK; moveB((B *)VALUE_BASE(o_2),nstr,ARRAY_SIZE(o_2)); nstr[ARRAY_SIZE(o_2)] = '\000'; if (XStringListToTextProperty((char**)pn,1,&wname) == 0) return X_ERR; FREEopds = o_2; freevm = FREEvm; if ((retc = xy(&xyf,&freevm)) != OK) return retc; pxy = (W *)VALUE_BASE(xyf); if (ARRAY_SIZE(xyf) != 4) return RNG_CHK; if (ndvtwindows >= MAXDVTWINDOWS) return RNG_CHK; wid = HXCreateWindow(dvtdisplay, dvtrootwindow, pxy[0], pxy[1], pxy[2], pxy[3], 0, CopyFromParent, InputOutput, CopyFromParent, CWEventMask, &attr); HXSetWMProperties(dvtdisplay, wid, &wname, &icname, NULL, 0, NULL, &xwmhints, &classhint); atom[0] = HXInternAtom(dvtdisplay, "WM_DELETE_WINDOW", False); atom[1] = HXInternAtom(dvtdisplay, "WM_TAKE_FOCUS", False); HXSetWMProtocols(dvtdisplay, wid, atom, 2); opaque = HXInternAtom(dvtdisplay, "_KDE_WM_WINDOW_OPACITY", False); HXChangeProperty(dvtdisplay, wid, opaque, XA_CARDINAL, 32, PropModeReplace, (unsigned char*) &opaqueval, 1); dvtwindows[ndvtwindows++] = wid; TAG(o1) = NUM | LONGBIGTYPE; ATTR(o1) = 0; LONGBIG_VAL(o1) = wid; FREEopds = o2; return OK; #endif }