예제 #1
0
static int events_cb(const struct nlmsghdr *nlh, void *data)
{
	int ret = MNL_CB_OK;
	int event = NFNL_MSG_TYPE(nlh->nlmsg_type);
	int type = *((int *)data);

	switch(event) {
	case NFT_MSG_NEWTABLE:
	case NFT_MSG_DELTABLE:
		ret = table_cb(nlh, event, type);
		break;
	case NFT_MSG_NEWCHAIN:
	case NFT_MSG_DELCHAIN:
		ret = chain_cb(nlh, event, type);
		break;
	case NFT_MSG_NEWRULE:
	case NFT_MSG_DELRULE:
		ret = rule_cb(nlh, event, type);
		break;
	case NFT_MSG_NEWSET:
	case NFT_MSG_DELSET:
		ret = set_cb(nlh, event, type);
		break;
	case NFT_MSG_NEWSETELEM:
	case NFT_MSG_DELSETELEM:
		ret = setelem_cb(nlh, event, type);
		break;
	case NFT_MSG_NEWGEN:
		ret = gen_cb(nlh, event, type);
		break;
	}

	return ret;
}
예제 #2
0
static int lcallback(lua_State *L) {
    struct context* ctx = lua_touserdata(L, lua_upvalueindex(1));
    luaL_checktype(L, 1, LUA_TFUNCTION);
    lua_settop(L, 1);
    lua_rawsetp(L, LUA_REGISTRYINDEX,  &_cb);
    set_cb(ctx, _cb);

    return 0;
}
예제 #3
0
mng_retcode mng_init_callbacks(mng_handle handle)
{
	mng_retcode ret;

#define set_cb(x) \
		if ((ret = mng_setcb_##x(handle, fb_mng_##x)) != MNG_NOERROR) \
			return ret;

	set_cb(errorproc);
	set_cb(openstream);
	set_cb(closestream);
	set_cb(readdata);
	set_cb(getcanvasline);
	set_cb(refresh);
	set_cb(gettickcount);
	set_cb(settimer);
	set_cb(processheader);
#ifdef MNG_SUPPORT_TRACE
	set_cb(traceproc);
#endif

#undef set_cb
	return MNG_NOERROR;
}
예제 #4
0
파일: common.c 프로젝트: agx/ruby-libvirt
VALUE ruby_libvirt_set_typed_parameters(VALUE d, VALUE input,
                                        unsigned int flags, void *opaque,
                                        struct ruby_libvirt_typed_param *allowed,
                                        unsigned int num_allowed,
                                        const char *(*set_cb)(VALUE d,
                                                              unsigned int flags,
                                                              virTypedParameterPtr params,
                                                              int nparams,
                                                              void *opaque))
{
    const char *errname;
    struct ruby_libvirt_parameter_assign_args args;
    unsigned long hashsize;

    /* make sure input is a hash */
    Check_Type(input, T_HASH);

    hashsize = RHASH_SIZE(input);

    if (hashsize == 0) {
        return Qnil;
    }

    args.allowed = allowed;
    args.num_allowed = num_allowed;
    args.params = alloca(sizeof(virTypedParameter) * hashsize);
    args.i = 0;

    rb_hash_foreach(input, ruby_libvirt_typed_parameter_assign, (VALUE)&args);

    errname = set_cb(d, flags, args.params, args.i, opaque);
    ruby_libvirt_raise_error_if(errname != NULL, e_RetrieveError, errname,
                                ruby_libvirt_connect_get(d));

    return Qnil;
}
예제 #5
0
int
SolidColorTexture::draw(CVIEWptr& v)
{
   if (_ctrl)
      return _ctrl->draw(v);

   bool show_weights = debug_patch_blend;
   if (show_weights) {
      if (!dynamic_cast<PatchBlendStripCB*>(cb())) {
         set_cb(new PatchBlendStripCB(patch()));
         assert(dynamic_cast<PatchBlendStripCB*>(cb()));
      }
   } else if (dynamic_cast<PatchBlendStripCB*>(cb())) {
      dynamic_cast<PatchBlendStripCB*>(cb())->set_patch(0);
   }

   // push GL state before changing things
   glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT);

   // Set the color
   COLOR  c = _color;
   double a = _alpha*alpha();
   if (_track_view_color)
      c = v->color();
   glColor4fv(float4(c,a));

   // try it with the display list:
   if (BasicTexture::draw(v))
      return _patch->num_faces();

   // ensure this never happens again! get a display list:
   int dl = _dl.get_dl(v, 1, _patch->stamp());
   if (dl)
      glNewList(dl, GL_COMPILE);

   glDisable(GL_LIGHTING);      // GL_ENABLE_BIT

   // set up face culling for closed surfaces
   set_face_culling();          // GL_ENABLE_BIT

   // draw the triangle strips
   PatchBlendStripCB* pbcb = dynamic_cast<PatchBlendStripCB*>(cb());
   if (show_weights) {
      glEnable(GL_BLEND);                                // GL_ENABLE_BIT
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_COLOR_BUFFER_BIT
      if (Config::get_var_bool("DEBUG_PATCH_BLEND_WEIGHTS",false)) {
         cerr << "SolidColorTexture::draw: patch "
              << mesh()->patches().get_index(patch())
              << ": drawing patch blend weights"
              << endl;
      }
      mesh()->update_patch_blend_weights();
      assert(pbcb);
      pbcb->set_patch(patch()->cur_patch());
      pbcb->set_color(c,a);
      _patch->draw_n_ring_triangles(
         mesh()->patch_blend_smooth_passes() + 1, pbcb, false
         );
      // draw the boundary w/ given line width and color:
      EdgeStrip bdry = patch()->cur_faces().get_boundary();
      GtexUtil::draw_strip(bdry, 2, Color::yellow);
   } else {
      if (pbcb)
         pbcb->set_patch(0);
      _patch->draw_tri_strips(_cb);
   }

   // restore gl state:
   glPopAttrib();

   // end the display list here
   if (_dl.dl(v)) {
      _dl.close_dl(v);

      // the display list is built; now execute it
      BasicTexture::draw(v);
   }

   return _patch->num_faces();
}