예제 #1
0
파일: term.c 프로젝트: ArtifTh/einkterm
int main(int argc, char** argv)
{
	init_eink();
	init_ptm();
	open_keyboard();
	//put_str("HELLO");
	//draw_bitmap();
	put_str("HELLO\n");
	update_part();
	init_reactor(10);
	add_callback(get_ptm(), update_disp, READ);
	add_callback(get_keyboard(), read_keyboard, READ);
	//add_callback(get_disp(), disp_allow, WRITE);
	//if(entries==2) { put_str("2\n"); }
	loop();
    return 0;
}
예제 #2
0
int register_script_cb( cb_function f, int type, void *param )
{
    /* type checkings */
    if ( (type&(REQ_TYPE_CB|RPL_TYPE_CB|PARSE_ERR_CB))==0 ) {
        LM_CRIT("request / reply / error type not specified\n");
        goto error;
    }
    if ( (type&(PRE_SCRIPT_CB|POST_SCRIPT_CB|PARSE_ERR_CB))==0 ||
            (type&PRE_SCRIPT_CB && type&POST_SCRIPT_CB) ) {
        LM_CRIT("callback POST or PRE type must be exactly one\n");
        goto error;
    }

    if (type&PARSE_ERR_CB) {
        if (add_callback( &parse_err_cb, f, param)<0)
            goto add_error;
    }

    if (type&REQ_TYPE_CB) {
        /* callback for request script */
        if (type&PRE_SCRIPT_CB) {
            if (add_callback( &pre_req_cb, f, param)<0)
                goto add_error;
        } else if (type&POST_SCRIPT_CB) {
            if (add_callback( &post_req_cb, f, param)<0)
                goto add_error;
        }
    }
    if (type&RPL_TYPE_CB) {
        /* callback (also) for reply script */
        if (type&PRE_SCRIPT_CB) {
            if (add_callback( &pre_rpl_cb, f, param)<0)
                goto add_error;
        } else if (type&POST_SCRIPT_CB) {
            if (add_callback( &post_rpl_cb, f, param)<0)
                goto add_error;
        }
    }

    return 0;
add_error:
    LM_ERR("failed to add callback\n");
error:
    return -1;
}
예제 #3
0
int register_script_cb( cb_function f, int type, void *param )
{
	/* type checkings */
	if ( (type&(REQ_TYPE_CB|RPL_TYPE_CB))==0 ) {
		LOG(L_CRIT,"BUG:register_script_cb: REQUEST or REPLY "
			"type not specified\n");
		goto error;
	}
	if ( (type&(PRE_SCRIPT_CB|POST_SCRIPT_CB))==0 ||
	(type&PRE_SCRIPT_CB && type&POST_SCRIPT_CB) ) {
		LOG(L_CRIT,"BUG:register_script_cb: callback POST or PRE type must "
			"be exactly one\n");
		goto error;
	}

	if (type&REQ_TYPE_CB) {
		/* callback for request script */
		if (type&PRE_SCRIPT_CB) {
			if (add_callback( &pre_req_cb, f, param)<0)
				goto add_error;
		} else if (type&POST_SCRIPT_CB) {
			if (add_callback( &post_req_cb, f, param)<0)
				goto add_error;
		}
	}
	if (type&RPL_TYPE_CB) {
		/* callback (also) for reply script */
		if (type&PRE_SCRIPT_CB) {
			if (add_callback( &pre_rpl_cb, f, param)<0)
				goto add_error;
		} else if (type&POST_SCRIPT_CB) {
			if (add_callback( &post_rpl_cb, f, param)<0)
				goto add_error;
		}
	}

	return 0;
add_error:
	LOG(L_ERR,"ERROR:register_script_cb: failed to add callback\n");
error:
	return -1;
}
예제 #4
0
/**
 * im_add_eval_callback:
 * @im: image to attach callback to
 * @fn: callback function
 * @a: user data 1
 * @b: user data 2
 *
 * Attaches an eval callback @fn to @im.
 *
 * Eval callbacks are called during evaluation and are a good place to give
 * the user feedback about computation progress. In the eval callback, you may
 * look at the #VipsProgress #time member of #IMAGE to get information about 
 * the number of
 * pels processed, elapsed time, and so on.
 *
 * Eval callbacks are inherited. That is, any images which use your  image
 * as  input  will inherit your eval callbacks. As a result, if you add an
 * eval callback to an image, you will be notified if any later image uses
 * your image for computation.
 *
 * If  a  later image adds eval callbacks, then the inheritance is broken,
 * and that image will recieve notification instead.
 *
 * See also: im_add_evalend_callback(), im_add_evalstart_callback().
 *
 * Returns: 0 on success, or -1 on error.
 */
int
im_add_eval_callback( IMAGE *im, im_callback_fn fn, void *a, void *b )
{
	/* Mark this image as needing progress feedback. im__link_make()
	 * propogates this value to our children as we build a pipeline.
	 * im__handle_eval() looks up the IMAGE it should signal on.
	 */
	im->progress = im;

	return( add_callback( im, &im->evalfns, fn, a, b ) );
}
예제 #5
0
int f_saveas() {
	/* register callbacks */
	add_callback(K_NEWLINE, f_saveas_finish);
	add_callback(K_LEFT, 	f_saveas_nav);
	add_callback(K_RIGHT, 	f_saveas_nav);
	add_callback(K_UP, 		f_saveas_nav);
	add_callback(K_DOWN, 	f_saveas_nav);

	modal_t modal;
	char header[] = "Save as";
	modal.header = malloc(sizeof(char) * (strlen(header) + 1));
	strcpy(modal.header, header);

	char body[] = "- Enter the file name:";
	modal.body = malloc(sizeof(char**));
	modal.body[0] = malloc(sizeof(char*) * (strlen(body) + 1));
	strcpy(modal.body[0], body);
	modal.bodysize = 1;

	modal.footer = NULL;
	modal.type = MOD_TEXTBOX;
	show_modal(curfile, modal);
	return 0;
}
예제 #6
0
int register_route_cb( cb_function f, int type, void *param )
{
    /* type checkings */
    if ( ((type&(PRE_SCRIPT_CB|POST_SCRIPT_CB))==0) ||
            (type&PRE_SCRIPT_CB && type&POST_SCRIPT_CB) ) {
        LM_CRIT("callback POST or PRE type must be exactly one\n");
        goto error;
    }

    /* callback for request script */
    if (type&PRE_SCRIPT_CB) {
        if (add_callback( &pre_route_cb, f, param)<0)
            goto add_error;
    } else if (type&POST_SCRIPT_CB) {
        if (add_callback( &post_route_cb, f, param)<0)
            goto add_error;
    }

    return 0;
add_error:
    LM_ERR("failed to add callback\n");
error:
    return -1;
}
예제 #7
0
void register_event_callback(const char *event, const char *callback,
				struct event_callback_entry **map)
{
	struct event_callback_entry *i, *last;

	if (!*map) {
		*map = init_new_event_callback(event, callback);
		return;
	}

	for (i = *map; i != NULL; i = i->next) {
		if (strcmp(event, i->event) == 0) {
			add_callback(i, callback);
			return;
		}
		last = i;
	} 
	last->next = init_new_event_callback(event, callback);
}
예제 #8
0
/* Register pre- or post-script callbacks.
 * Returns -1 on error, 0 on success
 */
int register_script_cb( cb_function f, unsigned int flags, void *param )
{
	struct script_cb	**cb_array;
	int	i;

	/* type checkings */
	if ( (flags&((1<<SCRIPT_CB_NUM)-1))==0 ) {
		LOG(L_BUG, "register_script_cb: callback flag not specified\n");
		return -1;
	}
	if ( (flags&(~(PRE_SCRIPT_CB|POST_SCRIPT_CB))) >= 1<<SCRIPT_CB_NUM ) {
		LOG(L_BUG, "register_script_cb: unsupported callback flags: %u\n",
			flags);
		return -1;
	}
	if ( (flags&(PRE_SCRIPT_CB|POST_SCRIPT_CB))==0 ||
	(flags&PRE_SCRIPT_CB && flags&POST_SCRIPT_CB) ) {
		LOG(L_BUG, "register_script_cb: callback POST or PRE type must "
			"be exactly one\n");
		return -1;
	}

	if (flags&PRE_SCRIPT_CB)
		cb_array = pre_script_cb;
	else
		cb_array = post_script_cb;

	/* Add the callback to the lists.
	 * (as many times as many flags are set)
	 */
	for (i=0; i<SCRIPT_CB_NUM; i++) {
		if ((flags&(1<<i)) == 0)
			continue;
		if (add_callback(&cb_array[i], f, param) < 0)
			goto add_error;
	}
	return 0;

add_error:
	LM_ERR("failed to add callback\n");
	return -1;
}
예제 #9
0
파일: gate.c 프로젝트: rdnelson/Hazzard
//Init the ISR, and register the callback
int init (callback_t callback)
{
    int pin;
    int myCounter [NUM_GATES];

    for (pin = 0 ; pin < NUM_GATES ; ++pin) {
        runningDiff [pin] = myCounter [pin] = 0 ;
        gettimeofday(&lastTime[pin], NULL);
    }

    wiringPiSetup () ;

    add_callback(callback);

    wiringPiISR (0, INT_EDGE_RISING, &myInterrupt0);
    pullUpDnControl (0, PUD_UP);
    pullUpDnControl (2, PUD_UP);

    return 0;
}
예제 #10
0
dbus_bool_t
_dbus_loop_add_timeout (DBusLoop            *loop,
                        DBusTimeout        *timeout,
                        DBusTimeoutFunction  function,
                        void               *data,
                        DBusFreeFunction    free_data_func)
{
    TimeoutCallback *tcb;

    tcb = timeout_callback_new (timeout, function, data, free_data_func);
    if (tcb == NULL)
        return FALSE;

    if (!add_callback (loop, (Callback*) tcb))
    {
        tcb->callback.free_data_func = NULL; /* don't want to have this side effect */
        callback_unref ((Callback*) tcb);
        return FALSE;
    }

    return TRUE;
}
예제 #11
0
dbus_bool_t
_dbus_loop_add_watch (DBusLoop          *loop,
                      DBusWatch        *watch,
                      DBusWatchFunction  function,
                      void             *data,
                      DBusFreeFunction  free_data_func)
{
    WatchCallback *wcb;

    wcb = watch_callback_new (watch, function, data, free_data_func);
    if (wcb == NULL)
        return FALSE;

    if (!add_callback (loop, (Callback*) wcb))
    {
        wcb->callback.free_data_func = NULL; /* don't want to have this side effect */
        callback_unref ((Callback*) wcb);
        return FALSE;
    }

    return TRUE;
}
예제 #12
0
void AsyncResult::add_interrupt ( const avalon::thread::AsyncResult::Callback& callback )
{
    add_callback(callback, CALLBACK_INTERRUPT);
}
예제 #13
0
/**
 * im_add_evalstart_callback:
 * @im: image to attach callback to
 * @fn: callback function
 * @a: user data 1
 * @b: user data 2
 *
 * Attaches an eval start callback @fn to @im.
 *
 * Eval start callbacks are called at the beginning of evaluation. They are a 
 * good
 * place to get ready to give progress notification.
 * They can be called 
 * many times. Every evalend call is guaranteed to have a matching evalstart,
 * but not necessarily any eval calls.
 *
 * Eval callbacks are inherited. That is, any images which use your  image
 * as  input  will inherit your eval callbacks. As a result, if you add an
 * eval callback to an image, you will be notified if any later image uses
 * your image for computation.
 *
 * If  a  later image adds eval callbacks, then the inheritance is broken,
 * and that image will recieve notification instead.
 *
 * See also: im_add_eval_callback(), im_add_evalend_callback().
 *
 * Returns: 0 on success, or -1 on error.
 */
int
im_add_evalstart_callback( IMAGE *im, im_callback_fn fn, void *a, void *b )
{	
	return( add_callback( im, &im->evalstartfns, fn, a, b ) );
}
예제 #14
0
파일: vesa.c 프로젝트: Haifisch/axle
void setup_vesa_screen_refresh(Screen* screen, double interval) {
	screen->callback = add_callback(vesa_screen_refresh, interval, true, screen);
}
예제 #15
0
/**
 * im_add_invalidate_callback:
 * @im: image to attach callback to
 * @fn: callback function
 * @a: user data 1
 * @b: user data 2
 *
 * Attaches an invalidate callback @fn to @im.
 *
 * Invalidate callbacks are triggered
 * when VIPS invalidates the cache on an image. This is useful for
 * removing images from other, higher-level caches.
 *
 * See also: im_invalidate().
 *
 * Returns: 0 on success, or -1 on error.
 */
int
im_add_invalidate_callback( IMAGE *im, im_callback_fn fn, void *a, void *b )
{	
	return( add_callback( im, &im->invalidatefns, fn, a, b ) );
}
예제 #16
0
EffectSlider::EffectSlider(const ossia::net::node_base& fx, QWidget* parent):
  QWidget{parent},
  m_param{fx}
{
  auto addr = m_param.getAddress();

  auto dom = addr->getDomain();

  if(auto f = dom.maybe_min<ossia::Float>()) m_min = *f;
  if(auto f = dom.maybe_max<ossia::Float>()) m_max = *f;

  auto lay = new iscore::MarginLess<QVBoxLayout>;
  lay->addWidget(new AddressLabel{
                     m_param,
                     QString::fromStdString(addr->getDescription()),
                     this});
  m_slider = new iscore::DoubleSlider{this};
  lay->addWidget(m_slider);
  this->setLayout(lay);

  auto cur_val = ossia::convert<float>(m_param.getAddress()->cloneValue());
  scaledValue = (cur_val - m_min) / (m_max - m_min);
  m_slider->setValue(scaledValue);

  connect(m_slider, &iscore::DoubleSlider::valueChanged,
          this, [=] (double v)
  {
    // TODO undo ???
    // v is between 0 - 1
    auto cur = m_param.getAddress()->cloneValue();
    auto exp = float(m_min + (m_max - m_min) * v);
    if(ossia::convert<float>(cur) != exp)
      m_param.getAddress()->pushValue(ossia::Float{exp});

  });

  m_callback = addr->add_callback([=] (const ossia::value& val)
  {
    if(auto v = val.target<ossia::Float>())
    {
      scaledValue = (*v - m_min) / (m_max - m_min);
     // if(scaled != m_slider->value()) // TODO qFuzzyCompare instead
     //   m_slider->setValue(scaled);
    }
  });

  m_addAutomAction = new QAction{tr("Add automation"), this};
  connect(m_addAutomAction, &QAction::triggered,
          this, [=] () {
    auto& ossia_addr = *m_param.getAddress();
    auto& dom = ossia_addr.getDomain();
    auto addr = State::parseAddress(QString::fromStdString(ossia::net::address_string_from_node(ossia_addr)));

    if(addr)
    {
      auto min = dom.convert_min<double>();
      auto max = dom.convert_max<double>();
      emit createAutomation(std::move(*addr), min, max);
    }
  });
  // TODO show tooltip with current value
}
예제 #17
0
/**
 * im_add_written_callback:
 * @im: image to attach callback to
 * @fn: callback function
 * @a: user data 1
 * @b: user data 2
 *
 * Attaches a written callback @fn to @im.
 *
 * Written callbacks are triggered exactly once, just after @im has been
 * written to.
 *
 * Written callbacks are a good place to do background writes to files. VIPS
 * uses them to implement (for example) writing to im_open("poop.jpg","w")
 * triggering a write to jpeg.
 *
 * Evalend callbacks happen after a real write loop, whereas written is
 * triggered even for just attaching some callbacks to a "p" image.
 *
 * Returns: 0 on success, or -1 on error.
 */
int
im_add_written_callback( IMAGE *im, im_callback_fn fn, void *a, void *b )
{	
	return( add_callback( im, &im->writtenfns, fn, a, b ) );
}
예제 #18
0
void AsyncResult::add_cancel ( const avalon::thread::AsyncResult::Callback& callback )
{
    add_callback(callback, CALLBACK_CANCEL);
}
예제 #19
0
void AsyncResult::add_error ( const avalon::thread::AsyncResult::Callback& callback )
{
    add_callback(callback, CALLBACK_ERROR);
}
예제 #20
0
void AsyncResult::add_success ( const avalon::thread::AsyncResult::Callback& callback )
{
    add_callback(callback, CALLBACK_SUCCESS);
}
예제 #21
0
/* Callback for OK button */
static void ok_callback(GtkWidget *widget, gpointer data)
{
	FILE *fp;
	char buff[1024];
	LList *saved_acc_info = NULL, *acc_walk = NULL, *to_remove = NULL;

	if (gtk_entry_get_text(GTK_ENTRY(username)) != NULL
		&& strlen(gtk_entry_get_text(GTK_ENTRY(username))) > 0
		&& num_accounts == 0) {
		add_callback(widget, data);
	}

	g_snprintf(buff, 1024, "%saccounts", config_dir);

	fp = fdopen(creat(buff, 0700), "w");

	if (num_accounts == 0) {
		ay_do_error(_("Invalid Account"),
			_("You didn't define an account."));
		return;
	}

	eb_sign_off_all();

	gtk_tree_model_foreach(GTK_TREE_MODEL(account_list_store),
		save_accounts, fp);

	fclose(fp);

	saved_acc_info = ay_save_account_information(-1);

	acc_walk = accounts;
	if (acc_walk) {
		while (acc_walk != NULL && acc_walk->data != NULL) {
			if (!l_list_find(existing_accounts, acc_walk->data)) {
				eb_local_account *removed =
					(eb_local_account *)(acc_walk->data);
				/* removed account */
				if (removed && removed->connected
					&& RUN_SERVICE(removed)->logout != NULL)
					RUN_SERVICE(removed)->logout(removed);
				to_remove =
					l_list_append(to_remove,
					acc_walk->data);
			}
			acc_walk = acc_walk->next;
		}
		for (acc_walk = to_remove; acc_walk && acc_walk->data;
			acc_walk = acc_walk->next)
			accounts = l_list_remove(accounts, acc_walk->data);
		l_list_free(to_remove);
	}

	acc_walk = new_accounts;
	if (acc_walk) {
		while (acc_walk != NULL) {
			accounts = l_list_append(accounts, acc_walk->data);
			acc_walk = acc_walk->next;
		}
	}

	gtk_widget_destroy(account_window);

	load_accounts();
	rebuild_set_status_menu();
	set_menu_sensitivity();

	ay_restore_account_information(saved_acc_info);
	l_list_free(saved_acc_info);
}
예제 #22
0
/**
 * im_add_preclose_callback:
 * @im: image to attach callback to
 * @fn: callback function
 * @a: user data 1
 * @b: user data 2
 *
 * Attaches a pre-close callback @fn to @im.
 *
 * Pre-close callbacks are triggered exactly once just before an image is
 * closed. The image is still valid and you can do anything with it, except
 * stop close from happening.
 *
 * Pre-close callbacks are a good place for languae bindings to break as
 * association between the language object and the VIPS image.
 *
 * Returns: 0 on success, or -1 on error.
 */
int
im_add_preclose_callback( IMAGE *im, im_callback_fn fn, void *a, void *b )
{	
	return( add_callback( im, &im->preclosefns, fn, a, b ) );
}