void cmmjl_osc_makeDefaultAddress(void *x, long instance, char *buf){ char buf2[256], tmp[64]; t_patcher *p, *pp; t_box *b; t_symbol *name; char *ptr; int index; object_obex_lookup(x, gensym("#P"), (t_object **)&p); if(!p){ return; } name = jpatcher_get_name(p); if(name){ if(strcmp(name->s_name, "")){ // if this is a filename, get rid of the extension if(ptr = strrchr(name->s_name, '.')){ memset(tmp, '\0', 64); index = name->s_name - ptr; if(index < 0) index = -index; memcpy(tmp, name->s_name, index); sprintf(buf2, "/%s", tmp); }else{ sprintf(buf2, "/%s", name->s_name); } } }else{ // maybe we didn't wait long enough... } b = jpatcher_get_box(p); if(b){ while(p){ pp = jpatcher_get_parentpatcher(p); if(pp){ name = jpatcher_get_name(pp); if(name){ if(strcmp(name->s_name, "")){ if(ptr = strrchr(name->s_name, '.')){ memset(tmp, '\0', 64); index = name->s_name - ptr; if(index < 0) index = -index; memcpy(tmp, name->s_name, index); sprintf(buf, "/%s%s", tmp, buf2); }else{ sprintf(buf, "/%s%s", name->s_name, buf2); } } } } p = pp; strcpy(buf2, buf); } } }
void posit_getinfo(t_posit *x) { t_object *jp; t_object *jb; t_object *pbox; t_rect jr; t_symbol *scriptingname = ps_none; t_symbol *patchername = ps_none; t_symbol *patcherscriptingname = ps_none; t_max_err err; t_symbol *classname; t_atom *outlist; outlist = x->p_outlist; err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp); // get the object's parent patcher if (err != MAX_ERR_NONE) return; err = object_obex_lookup(x, gensym("#B"), (t_object **)&jb); // get the object's wrapping box if (err != MAX_ERR_NONE) return; patchername = jpatcher_get_name(jp); classname = jbox_get_maxclass(jb); // class name scriptingname = jbox_get_varname(jb); // scripting name if (scriptingname == NULL || scriptingname == ps_nothing) { scriptingname = ps_none; } pbox = jpatcher_get_box(jp); if(pbox) patcherscriptingname = jbox_get_varname(pbox); // scripting name if (patcherscriptingname == NULL || patcherscriptingname == ps_nothing) { patcherscriptingname = ps_none; } jbox_get_patching_rect(jb, &jr); // x, y, width, height (double) atom_setsym(outlist+0, classname); // class name atom_setsym(outlist+1, scriptingname); // scripting name atom_setlong(outlist+2, (long)((long)jr.x)); atom_setlong(outlist+3, (long)((long)jr.y)); atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height)); atom_setsym(outlist+6, patchername); // patcher name atom_setsym(outlist+7, patcherscriptingname); outlet_list(x->p_outlet,0L,8,outlist); outlet_bang(x->p_outlet2); //bang to notify of end of dump }