本文整理汇总了C++中do_callback函数的典型用法代码示例。如果您正苦于以下问题:C++ do_callback函数的具体用法?C++ do_callback怎么用?C++ do_callback使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了do_callback函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transition_to_body
/****************
* We have read in all header lines and are about to receive the body
* part. The delimiter line has already been processed.
*
* FIXME: we's better return an error in case of memory failures.
*/
static int
transition_to_body (rfc822parse_t msg)
{
rfc822parse_field_t ctx;
int rc;
rc = do_callback (msg, RFC822PARSE_T2BODY);
if (!rc)
{
/* Store the boundary if we have multipart type. */
ctx = rfc822parse_parse_field (msg, "Content-Type", -1);
if (ctx)
{
const char *s;
s = rfc822parse_query_media_type (ctx, NULL);
if (s && !strcmp (s,"multipart"))
{
s = rfc822parse_query_parameter (ctx, "boundary", 0);
if (s)
{
assert (!msg->current_part->boundary);
msg->current_part->boundary = malloc (strlen (s) + 1);
if (msg->current_part->boundary)
{
part_t part;
strcpy (msg->current_part->boundary, s);
msg->boundary = msg->current_part->boundary;
part = new_part ();
if (!part)
{
int save_errno = errno;
rfc822parse_release_field (ctx);
errno = save_errno;
return -1;
}
rc = do_callback (msg, RFC822PARSE_LEVEL_DOWN);
assert (!msg->current_part->down);
msg->current_part->down = part;
msg->current_part = part;
msg->in_preamble = 1;
}
}
}
rfc822parse_release_field (ctx);
}
}
return rc;
}
示例2: LOG_ERROR
//回调函数,第三个参数为NULL,不使用
void GetRuleTask::done_get_new_rule(void *req , RET_TYPE type , void *data)
{
MsgHeader header;
InReq *cb_req = NULL;
//如果SCAgent执行失败,不再执行接下来的操纵,回调上层的回调函数,
//当然还可以使用其它的设置,例如重试多次等
if(Task::parse_callback_ret(req , type) < 0)
{
goto ERR ;
}
cb_req = (InReq *)req;
header = cb_req->m_msgHeader;
//检查回复的报文的cmd字段是否符合定义,如果出错也不会执行接下来的操作
if(MU_RULER == m_type && MSG_RS_CS_UPDATE_MU_HASH_ACK != header.cmd)
{
LOG_ERROR("GetRuleTask::Undefined mu ack header cmd : " + int_to_str(header.cmd));
goto ERR ;
}
if(SU_RULER == m_type && MSG_RS_CS_UPDATE_SU_HASH_ACK != header.cmd)
{
LOG_ERROR("GetRuleTask::Undefined su ack header cmd : " + int_to_str(header.cmd));
goto ERR ;
}
//这里需要保证原子性!
if(get_new_rule_ack(cb_req) < 0)
{
LOG_ERROR("GetRuleTask::Parse new rule from CS error !");
goto ERR ;
}
//每次更新报文之后都需要唤醒所有等待的客户端
if(m_is_wait_client)
{
wakeup_all_wait_request();
}
//唤醒之后就可以执行回调了
do_callback(true);
ERR :
//这里可以使用其他的方式处理操作失败的情况,或者对不同的失败情况执行不同的操作
//这里仅仅是回调上层执行失败
if(m_is_wait_client)
{
wakeup_all_wait_request();
}
do_callback(false);
}
示例3: switch
int orb_mapctrl::handle(int event)
{
switch (event) {
case FL_MOVE:
m_mousepos.set_x(Fl::event_x()-x());
m_mousepos.set_y(Fl::event_y()-y());
return 1;
case FL_ENTER:
fl_cursor(FL_CURSOR_HAND);
return 1;
case FL_LEAVE:
fl_cursor(FL_CURSOR_DEFAULT);
return 1;
case FL_PUSH:
if (Fl::event_button() == FL_RIGHT_MOUSE)
do_callback();
return 1;
case FL_RELEASE:
return 1;
case FL_DRAG:
{
if (!Fl::event_inside(this))
break;
int dx = m_mousepos.get_x() - (Fl::event_x()-x());
int dy = m_mousepos.get_y() - (Fl::event_y()-y());
m_mousepos.set_x(Fl::event_x()-x());
m_mousepos.set_y(Fl::event_y()-y());
m_viewport->move(dx, dy);
redraw();
return 1;
}
case FL_MOUSEWHEEL:
if (!Fl::event_inside(this))
break;
// Prevent integer underflow
if ((Fl::event_dy() > 0) && (m_viewport->z() == 0))
return 1;
// The image of the viewport might be smaller then our current
// client area. We need to take this delta into account.
int dpx = 0, dpy = 0;
if (w() > (int)m_viewport->w())
dpx = (w() - (int)m_viewport->w())/2;
if (h() > (int)m_viewport->h())
dpy = (h() - (int)m_viewport->h())/2;
int px = Fl::event_x()- x() - dpx;
int py = Fl::event_y()- y() - dpy;
m_viewport->z(m_viewport->z()-Fl::event_dy(), px, py);
redraw();
return 1;
}
return Fl_Widget::handle(event);
}
示例4: handle
int Fl_Envelope::handle(int event)
{
int ret=Fl_Group::handle(event);
// search for deleted handles
for(list<Fl_Handle*>::iterator i = m_HandleList.begin();
i!=m_HandleList.end(); ++i)
{
// if it's been modified, update the env via the callback
if ((*i)->Changed()) do_callback();
if ((*i)->Deleted())
{
remove(*i);
m_HandleList.erase(i);
break; // one at a time
}
}
if (!ret)
{
int Mousebutton=Fl::event_button();
if (event==FL_PUSH && Mousebutton==2)
{
Fl_Handle * newhandle = new
Fl_Handle(Fl::event_x()-5,Fl::event_y()-5,10,10,"");
m_HandleList.push_back(newhandle);
add(newhandle);
}
redraw();
}
return ret;
}
示例5: rtosc_argument_string
void EnvelopeFreeEdit::OSC_raw(const char *msg)
{
const char *args = rtosc_argument_string(msg);
if(strstr(msg,"Penvpoints") && !strcmp(args, "i")) {
Penvpoints = rtosc_argument(msg, 0).i;
} else if(strstr(msg,"Penvdt") && !strcmp(args, "b")) {
rtosc_blob_t b = rtosc_argument(msg, 0).b;
assert(b.len == MAX_ENVELOPE_POINTS);
memcpy(Penvdt, b.data, MAX_ENVELOPE_POINTS);
} else if(strstr(msg,"Penvval") && !strcmp(args, "b")) {
rtosc_blob_t b = rtosc_argument(msg, 0).b;
assert(b.len == MAX_ENVELOPE_POINTS);
memcpy(Penvval, b.data, MAX_ENVELOPE_POINTS);
} else if(strstr(msg, "Penvval") && !strcmp(args, "c")) {
const char *str = strstr(msg, "Penvval");
int id = atoi(str+7);
assert(0 <= id && id < MAX_ENVELOPE_POINTS);
Penvval[id] = rtosc_argument(msg, 0).i;
} else if(strstr(msg, "Penvdt") && !strcmp(args, "c")) {
const char *str = strstr(msg, "Penvdt");
int id = atoi(str+6);
assert(0 <= id && id < MAX_ENVELOPE_POINTS);
Penvdt[id] = rtosc_argument(msg, 0).i;
} else if(strstr(msg,"Penvsustain") && !strcmp(args, "i")) {
Penvsustain = rtosc_argument(msg, 0).i;
}
redraw();
do_callback();
}
示例6: do_callback
void gdMidiOutputMidiCh::__cb_close() {
ch->midiOut = enableOut->value();
ch->midiOutChan = chanListOut->value();
ch->midiOutL = enableLightning->value();
ch->guiChannel->update();
do_callback();
}
示例7: rfc822_add_header
/****************
* Add header lines to the existing ones.
* Such a line may include LFs which are used to split the line
* int several fields. This must be a valid header line.
*/
int
rfc822_add_header( RFC822 msg, const char *line )
{
HDR_LINE hdr;
const char *lf;
size_t n;
int do_cb;
/* send the notification only if we have not processed all header lines */
do_cb = !msg->in_body && strlen(line) >= 9 && !memicmp(line, "Received:", 9);
do {
lf = strchr( line, '\n' );
n = lf? ( lf - line ) : strlen( line );
hdr = malloc( sizeof( *hdr ) + n );
if( !hdr )
return RFC822ERR_NOMEM;
hdr->next = NULL;
hdr->cont = (*line == ' ' || *line == '\t');
memcpy(hdr->line, line, n );
hdr->line[n] = 0;
*msg->hdr_lines_head = hdr;
msg->hdr_lines_head = &hdr->next;
} while( lf && *(line=lf+1) );
if( do_cb )
do_callback( msg, RFC822EVT_RCVD_SEEN );
return 0;
}
示例8: insert_header
/****************
* Note: For program supplied (and therefore syntactically correct)
* header lines, rfc822_add_header() may be used.
*/
int
insert_header( RFC822 msg, char *line, size_t length )
{
HDR_LINE hdr;
if( !length ) {
msg->in_body = 1;
return transition_to_body(msg);
}
trim_trailing_spaces(line);
/* Hmmm: should we check for invalid header data here? */
hdr = malloc( sizeof( *hdr ) + strlen(line) );
if( !hdr )
return RFC822ERR_NOMEM;
hdr->next = NULL;
hdr->cont = (*line == ' ' || *line == '\t');
strcpy(hdr->line, line );
*msg->hdr_lines_head = hdr;
msg->hdr_lines_head = &hdr->next;
/* lets help the caller to prevent mail loops
* It is okay to use length here, also this value
* not correct due to the space trimming */
if( length >= 9 && !memicmp(line, "Received:", 9) )
do_callback( msg, RFC822EVT_RCVD_SEEN );
return 0;
}
示例9: rfc822_close
void
rfc822_close( RFC822 msg )
{
do_callback( msg, RFC822EVT_CLOSE );
release_handle_data( msg );
free(msg);
}
示例10: rfc822_cancel
void
rfc822_cancel( RFC822 msg )
{
do_callback( msg, RFC822EVT_CANCEL );
release_handle_data( msg );
free(msg);
}
示例11: glue_setBeats
void gdBeatsInput::__cb_update_batt()
{
if (!strcmp(beats->value(), "") || !strcmp(bars->value(), ""))
return;
glue_setBeats(atoi(beats->value()), atoi(bars->value()), resizeRec->value());
do_callback();
}
示例12: do_callback
/**
* @brief Updates all timers currently running for this script.
*/
void LuaContext::update_timers() {
// Update all timers.
std::map<Timer*, LuaTimerData>::iterator it;
for (it = timers.begin(); it != timers.end(); ++it) {
Timer* timer = it->first;
timer->update();
if (timer->is_finished()) {
do_callback(it->second.callback_ref);
it->second.callback_ref = LUA_REFNIL;
timers_to_remove.push_back(timer);
}
}
// Destroy the ones that should be removed.
std::list<Timer*>::iterator it2;
for (it2 = timers_to_remove.begin(); it2 != timers_to_remove.end(); ++it2) {
Timer* timer = *it2;
if (timers.find(timer) != timers.end()) {
if (!timer->is_finished()) {
cancel_callback(timers[timer].callback_ref);
}
timers.erase(timer);
timer->decrement_refcount();
if (timer->get_refcount() == 0) {
delete timer;
}
}
}
timers_to_remove.clear();
}
示例13: switch
/*
* FIXME: icon will loose focus if is selected then press OK, which will take focus from it.
* In this case, nothing will be returned; double-click works as expected.
*/
int IconBox::handle(int event) {
switch(event) {
case FL_FOCUS:
corig = color();
color(selection_color());
redraw();
sel = true;
return 1;
case FL_UNFOCUS:
color(corig);
redraw();
sel = false;
return 1;
case FL_PUSH:
take_focus();
// double-click
if(Fl::event_clicks())
do_callback();
return 1;
case FL_RELEASE:
return 1;
default:
return Fl_Button::handle(event);
}
return 1;
}
示例14: set_changed
// When user picks a menu item, call this. It will do the callback.
// Unfortunatly this also casts away const for the checkboxes, but this
// was necessary so non-checkbox menus can really be declared const...
const MenuItem* MenuBase::picked(const MenuItem* v) {
if (v) {
if (v->radio()) {
if (!v->value()) { // they are turning on a radio item
set_changed();
((MenuItem*)v)->setonly();
}
redraw();
} else if (v->flags & FL_MENU_TOGGLE) {
set_changed();
((MenuItem*)v)->flags ^= FL_MENU_VALUE;
redraw();
} else if (v != value_) { // normal item
set_changed();
}
value_ = v;
if (when()&(FL_WHEN_CHANGED|FL_WHEN_RELEASE)) {
if (changed() || when()&FL_WHEN_NOT_CHANGED) {
if (value_ && value_->callback_) value_->do_callback((Fl_Widget*)this);
else do_callback();
}
}
}
return v;
}
示例15: switch
int IndicatorWindow::handle(int iEvent)
{
switch (iEvent) {
case FL_PUSH:
switch (Fl::event_button()) {
case 1: // left button
{
// find the indicator and move the floating indicator there
int x = Fl::event_x();
float fIndicator = findIndicator(x, 5);
if (fIndicator != ks_fIndicatorNotFound) {
floatingIndicator(fIndicator);
redraw();
}
}
break;
}
return 1;
case FL_RELEASE:
switch (Fl::event_button()) {
case 1: // left button
// do the callback function so that the parent can update other
// widgets accordingly
do_callback();
break;
}
return 1;
default:
break;
}
return Fl_Double_Window::handle(iEvent);
}