int graphicsGdImageStringFT(gdImage *im, ScmPair **brect0, ScmPair **brect1, ScmPair **brect2, ScmPair **brect3, int fg, ScmString *fontlist, double ptsize, double angle, int x, int y, ScmString *str) { int brect[8]; char *s = Scm_GetString(str); char *fl = Scm_GetString(fontlist); char *e = gdImageStringFT(im, brect, fg, fl, ptsize, angle, x, y, s); if (e == NULL) { *brect0 = SCM_NEW(ScmPair); SCM_SET_CAR(*brect0, Scm_MakeInteger(brect[0])); SCM_SET_CDR(*brect0, Scm_MakeInteger(brect[1])); *brect1 = SCM_NEW(ScmPair); SCM_SET_CAR(*brect1, Scm_MakeInteger(brect[2])); SCM_SET_CDR(*brect1, Scm_MakeInteger(brect[3])); *brect2 = SCM_NEW(ScmPair); SCM_SET_CAR(*brect2, Scm_MakeInteger(brect[4])); SCM_SET_CDR(*brect2, Scm_MakeInteger(brect[5])); *brect3 = SCM_NEW(ScmPair); SCM_SET_CAR(*brect3, Scm_MakeInteger(brect[6])); SCM_SET_CDR(*brect3, Scm_MakeInteger(brect[7])); return 0; } else { graphicsGdRaiseCondition("gdImageStringFT failed: %s", e); return -1; } }
ScmObj Scm_GetBinaryS32(ScmUVector *uv, int off, ScmSymbol *endian) { swap_s32_t v; CHECK_ENDIAN(endian); extract(uv, v.buf, off, 4); SWAP_32(endian, v); return Scm_MakeInteger(v.val); }
ScmObj Scm_ReadBinaryS32(ScmPort *iport, ScmSymbol *endian) { swap_s32_t v; CHECK_ENDIAN(endian); if (getbytes(v.buf, 4, iport) == EOF) return SCM_EOF; SWAP_32(endian, v); return Scm_MakeInteger(v.val); }
ScmObj Scm_SocketRecvX(ScmSocket *sock, ScmUVector *buf, int flags) { int r; u_int size; CLOSE_CHECK(sock->fd, "recv from", sock); char *z = get_message_buffer(buf, &size); SCM_SYSCALL(r, recv(sock->fd, z, size, flags)); if (r < 0) { Scm_SysError("recv(2) failed"); } return Scm_MakeInteger(r); }
ScmObj Scm_Forkpty(ScmObj slaveterm) { int master; pid_t pid; struct termios *term = NULL; if (SCM_SYS_TERMIOS_P(slaveterm)) { term = &SCM_SYS_TERMIOS(slaveterm)->term; } if ((pid = forkpty(&master, NULL, term, NULL)) < 0) { Scm_SysError("forkpty failed"); } return Scm_Values2(Scm_MakeInteger(pid), SCM_MAKE_INT(master)); }
/*------------------------------------------------------------ * Bport seek */ static off_t bport_seek(ScmPort *p, off_t off, int whence) { bport *data = (bport*)p->src.buf.data; SCM_ASSERT(data != NULL); if (!SCM_FALSEP(data->seek_proc)) { ScmObj r = Scm_ApplyRec(data->seek_proc, SCM_LIST2(Scm_OffsetToInteger(off), Scm_MakeInteger(whence))); if (SCM_INTEGERP(r)) { return Scm_IntegerToOffset(r); } } return (off_t)-1; }
ScmObj Scm_ForkptyAndExec(ScmString *file, ScmObj args, ScmObj iomap, ScmObj slaveterm, ScmSysSigset *mask) { int argc = Scm_Length(args); char **argv; const char *program; int *fds; int master; pid_t pid; struct termios *term = NULL; if (argc < 1) { Scm_Error("argument list must have at least one element: %S", args); } argv = Scm_ListToCStringArray(args, TRUE, NULL); program = Scm_GetStringConst(file); if (SCM_SYS_TERMIOS_P(slaveterm)) { term = &SCM_SYS_TERMIOS(slaveterm)->term; } fds = Scm_SysPrepareFdMap(iomap); if ((pid = forkpty(&master, NULL, term, NULL)) < 0) { Scm_SysError("forkpty failed"); } if (pid == 0) { Scm_SysSwapFds(fds); if (mask) { Scm_ResetSignalHandlers(&mask->set); Scm_SysSigmask(SIG_SETMASK, mask); } execvp(program, (char *const*)argv); /* here, we failed */ Scm_Panic("exec failed: %s: %s", program, strerror(errno)); } return Scm_Values2(Scm_MakeInteger(pid), SCM_MAKE_INT(master)); }
static void timer_cb(int value) { if (!SCM_FALSEP(timer_closure)) { Scm_ApplyRec(timer_closure, SCM_LIST1(Scm_MakeInteger(value))); } }