void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv) { char *cwd = atom_getsymbolarg(0, argc, argv)->s_name; t_namelist *nl; unsigned int i; int did_fontwarning = 0; int j; sys_oldtclversion = atom_getfloatarg(1, argc, argv); if (argc != 2 + 3 * NZOOM * NFONT) bug("glob_initfromgui"); for (j = 0; j < NZOOM; j++) for (i = 0; i < NFONT; i++) { int size = atom_getfloatarg(3 * (i + j * NFONT) + 2, argc, argv); int width = atom_getfloatarg(3 * (i + j * NFONT) + 3, argc, argv); int height = atom_getfloatarg(3 * (i + j * NFONT) + 4, argc, argv); if (!(size && width && height)) { size = (j+1)*sys_fontspec[i].fi_pointsize; width = (j+1)*sys_fontspec[i].fi_width; height = (j+1)*sys_fontspec[i].fi_height; if (!did_fontwarning) { verbose(1, "ignoring invalid font-metrics from GUI"); did_fontwarning = 1; } } sys_gotfonts[j][i].fi_pointsize = size; sys_gotfonts[j][i].fi_width = width; sys_gotfonts[j][i].fi_height = height; #if 0 fprintf(stderr, "font (%d %d %d)\n", sys_gotfonts[j][i].fi_pointsize, sys_gotfonts[j][i].fi_width, sys_gotfonts[j][i].fi_height); #endif } /* load dynamic libraries specified with "-lib" args */ if (sys_oktoloadfiles(0)) { for (nl = STUFF->st_externlist; nl; nl = nl->nl_next) if (!sys_load_lib(0, nl->nl_string)) post("%s: can't load library", nl->nl_string); sys_oktoloadfiles(1); } /* open patches specifies with "-open" args */ for (nl = sys_openlist; nl; nl = nl->nl_next) openit(cwd, nl->nl_string); namelist_free(sys_openlist); sys_openlist = 0; /* send messages specified with "-send" args */ for (nl = sys_messagelist; nl; nl = nl->nl_next) { t_binbuf *b = binbuf_new(); binbuf_text(b, nl->nl_string, strlen(nl->nl_string)); binbuf_eval(b, 0, 0, 0); binbuf_free(b); } namelist_free(sys_messagelist); sys_messagelist = 0; }
void glob_initfromgui(void *dummy, t_symbol *s, int argc, t_atom *argv) { char *cwd = atom_getsymbolarg(0, argc, argv)->s_name; t_namelist *nl; unsigned int i; int j; int nhostfont = (argc-2)/3; sys_oldtclversion = atom_getfloatarg(1, argc, argv); if (argc != 2 + 3 * nhostfont) bug("glob_initfromgui"); for (i = 0; i < NFONT; i++) { int best = 0; int wantheight = sys_fontlist[i].fi_maxheight; int wantwidth = sys_fontlist[i].fi_maxwidth; for (j = 1; j < nhostfont; j++) { if (atom_getintarg(3 * j + 4, argc, argv) <= wantheight && atom_getintarg(3 * j + 3, argc, argv) <= wantwidth) best = j; } /* best is now the host font index for the desired font index i. */ sys_fontlist[i].fi_hostfontsize = atom_getintarg(3 * best + 2, argc, argv); sys_fontlist[i].fi_width = atom_getintarg(3 * best + 3, argc, argv); sys_fontlist[i].fi_height = atom_getintarg(3 * best + 4, argc, argv); } #if 0 for (i = 0; i < 6; i++) fprintf(stderr, "font (%d %d %d) -> (%d %d %d)\n", sys_fontlist[i].fi_fontsize, sys_fontlist[i].fi_maxwidth, sys_fontlist[i].fi_maxheight, sys_fontlist[i].fi_hostfontsize, sys_fontlist[i].fi_width, sys_fontlist[i].fi_height); #endif /* auto-load anything in that is in startupdir */ if(!sys_nostartup) sys_loadstartup(); /* load dynamic libraries specified with "-lib" args */ for (nl = sys_externlist; nl; nl = nl->nl_next) if (!sys_load_lib(0, nl->nl_string)) post("%s: can't load library", nl->nl_string); /* open patches specifies with "-open" args */ for (nl = sys_openlist; nl; nl = nl->nl_next) openit(cwd, nl->nl_string); namelist_free(sys_openlist); sys_openlist = 0; /* send messages specified with "-send" args */ for (nl = sys_messagelist; nl; nl = nl->nl_next) { t_binbuf *b = binbuf_new(); binbuf_text(b, nl->nl_string, strlen(nl->nl_string)); binbuf_eval(b, 0, 0, 0); binbuf_free(b); } namelist_free(sys_messagelist); sys_messagelist = 0; }
static void gobj_restoreconnections(t_glist *gl, t_binbuf *bb) { #ifdef FRINGE_DEBUG fprintf(stderr, "restoring connections:\n"); binbuf_print(bb); #endif canvas_setcurrent(gl); binbuf_eval(bb, 0, 0, 0); canvas_unsetcurrent(gl); }
static void netrec_socketreceiver_read(t_netrec_socketreceiver *x, int fd) { if (x->sr_udp) /* UDP ("datagram") socket protocol */ netrec_socketreceiver_getudp(x, fd); else /* TCP ("streaming") socket protocol */ { char *semi; int readto = (x->sr_inhead >= x->sr_intail ? INBUFSIZE : x->sr_intail-1); int ret; t_netrec *y = x->sr_owner; y->x_sock_fd = fd; /* the input buffer might be full. If so, drop the whole thing */ if (readto == x->sr_inhead) { fprintf(stderr, "netrec: dropped message"); x->sr_inhead = x->sr_intail = 0; readto = INBUFSIZE; } else { ret = recv(fd, x->sr_inbuf + x->sr_inhead, readto - x->sr_inhead, 0); if (ret < 0) { sys_sockerror("recv"); if (x->sr_notifier) (*x->sr_notifier)(x->sr_owner); sys_rmpollfn(fd); sys_closesocket(fd); } else if (ret == 0) { post("netrec: connection closed on socket %d", fd); if (x->sr_notifier) (*x->sr_notifier)(x->sr_owner); sys_rmpollfn(fd); sys_closesocket(fd); } else { x->sr_inhead += ret; if (x->sr_inhead >= INBUFSIZE) x->sr_inhead = 0; while (netrec_socketreceiver_doread(x)) { outlet_setstacklim(); if (x->sr_socketreceivefn) (*x->sr_socketreceivefn)(x->sr_owner, inbinbuf); else binbuf_eval(inbinbuf, 0, 0, 0); } } } } }
void ofxPd::sendRawMessage( const string& message ) { // senda message to pd t_binbuf *b = binbuf_new(); static char msg_buf[MAXPDSTRING+1]; strncpy( msg_buf, message.c_str(), message.size() ); binbuf_text(b, msg_buf, message.size() ); sys_lock(); binbuf_eval(b, 0, 0, 0); sys_unlock(); binbuf_free(b); }
static t_object*triggerize_createobj(t_glist*x, t_binbuf*b) { /* send a binbuf to a canvas */ t_pd *boundx = s__X.s_thing, *boundn = s__N.s_thing; s__X.s_thing = &x->gl_pd; s__N.s_thing = &pd_canvasmaker; binbuf_eval(b, 0, 0, 0); s__X.s_thing = boundx; s__N.s_thing = boundn; return g2o(glist_getlast(x)); }
static void netserver_socketreceiver_read(t_netserver_socketreceiver *x, int fd) { char *semi; int readto = (x->sr_inhead >= x->sr_intail ? INBUFSIZE : x->sr_intail-1); int ret; t_netserver *y = x->sr_owner; y->x_sock_fd = fd; /* the input buffer might be full. If so, drop the whole thing */ if (readto == x->sr_inhead) { if (y->x_log_pri >= LOG_ERR) post("netserver: dropped message"); x->sr_inhead = x->sr_intail = 0; readto = INBUFSIZE; } else { ret = recv(fd, x->sr_inbuf + x->sr_inhead, readto - x->sr_inhead, 0); if (ret < 0) { sys_sockerror("recv"); if (x->sr_notifier) (*x->sr_notifier)(x->sr_owner); sys_rmpollfn(fd); sys_closesocket(fd); } else if (ret == 0) { if (y->x_log_pri >= LOG_NOTICE) post("netserver: << connection closed on socket %d", fd); if (x->sr_notifier) (*x->sr_notifier)(x->sr_owner); sys_rmpollfn(fd); sys_closesocket(fd); } else { x->sr_inhead += ret; if (x->sr_inhead >= INBUFSIZE) x->sr_inhead = 0; while (netserver_socketreceiver_doread(x)) { outlet_setstacklim(); if (x->sr_socketreceivefn) (*x->sr_socketreceivefn)(x->sr_owner, inbinbuf); else binbuf_eval(inbinbuf, 0, 0, 0); } } } }