Exemple #1
0
int philos_fsm_save_info(void* entity, void* msg)
{
    if (!entity || !msg) return FSM_FAIL;

    if (!philos_dict){
        philos_dict = fdict_create(MAX_PHILOS_NUM, philos_hash_match, philos_hash_calc);
        if (!philos_dict){
            LOG_NE("create fdict failed");
            return FSM_FAIL;
        }
    }
    
    philosopher* phi = (philosopher*) malloc(sizeof (philosopher));
    if (!phi) return FSM_FAIL;

    memcpy (phi, GET_DATA(msg), sizeof (philosopher));
    if (FDICT_SUCCESS != fdict_insert(philos_dict, &phi->whoami, phi)){
        LOG_NE("insert philosopher to dict failed");
        free(phi);
        return FSM_FAIL;
    }
    CVTTO_PHILOS(phifsm, entity);

    phifsm->philos = phi;
    philos_count += 1;

    // 用于显示
    show_addphilos(phi);

    return  philos_think(entity);
}
Exemple #2
0
void remmina_rdp_cliprdr_request_data(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, RemminaProtocolWidget* gp)
{
	GdkAtom target;
	gpointer data;
	RDP_CB_DATA_REQUEST_EVENT* event;
	rfContext* rfi = GET_DATA(gp);

	target = gtk_selection_data_get_target(selection_data);
	rfi->format = remmina_rdp_cliprdr_get_format_from_gdkatom(target);
	rfi->clipboard_queue = g_async_queue_new();

	/* Request Clipboard data of the server */
	event = (RDP_CB_DATA_REQUEST_EVENT*)
		freerdp_event_new(CliprdrChannel_Class, CliprdrChannel_DataRequest, NULL, NULL);
	event->format = rfi->format;
	freerdp_channels_send_event(rfi->instance->context->channels, (wMessage*) event);

	data = g_async_queue_timeout_pop(rfi->clipboard_queue, 1000000);
	if (data != NULL)
	{
		if (info == CB_FORMAT_PNG || info == CB_FORMAT_DIB || info == CB_FORMAT_JPEG)
		{
			gtk_selection_data_set_pixbuf(selection_data, data);
			g_object_unref(data);
		}
		else
		{
			gtk_selection_data_set_text(selection_data, data, -1);
		}
	}
}
// process incoming squadmate messaging info 
void multi_msg_process_squadmsg_packet(unsigned char *data, header *hinfo)
{	
	int command;
	ushort net_sig;
	short source_id;
	int source_index;
	char s_val;
	int offset = HEADER_LENGTH;

	// get all packet data
	GET_INT(command);
	GET_SHORT(source_id);
	GET_USHORT(net_sig);
	GET_DATA(s_val);
	PACKET_SET_SIZE();

	// determine who the order is from
	source_index = find_player_id(source_id);
	if(source_index == -1){
		nprintf(("Network","Received squadmsg order packet from unknown player!!\n"));
		return;
	}

	// display the squadmessage somehow
	multi_msg_show_squadmsg(&Net_players[source_index],command,net_sig,(int)s_val);
}
Exemple #4
0
// FLTK::Widget#activate
// Activate the widget.
mrb_value mrb_fltk_widget_activate_instance_method( mrb_state *mrb, mrb_value self ) {
  GET_DATA( fl_widget, Fl_Widget, self );

  fl_widget->activate();

  return self;
}
Exemple #5
0
static void remmina_rdp_call_feature(RemminaProtocolWidget* gp, const RemminaProtocolFeature* feature)
{
    RemminaFile* remminafile;
    rfContext* rfi;

    rfi = GET_DATA(gp);
    remminafile = remmina_plugin_service->protocol_plugin_get_file(gp);

    switch (feature->id)
    {
    case REMMINA_RDP_FEATURE_UNFOCUS:
        remmina_rdp_event_unfocus(gp);
        break;

    case REMMINA_RDP_FEATURE_SCALE:
        rfi->scale = remmina_plugin_service->file_get_int(remminafile, "scale", FALSE);
        remmina_rdp_event_update_scale(gp);
        break;

    case REMMINA_RDP_FEATURE_TOOL_REFRESH:
        gtk_widget_queue_draw_area(rfi->drawing_area, 0, 0,
                                   remmina_plugin_service->protocol_plugin_get_width(gp),
                                   remmina_plugin_service->protocol_plugin_get_height(gp));
        break;

    default:
        break;
    }
}
int main(){  
  /*--- message ---*/
  printf("*********************************\n");
  printf("*** Use SGESV to solve Ax = B ***\n");
  printf("*********************************\n");
  printf("\n");
    
    
  /*--- open files that store data ---*/
  OPEN_FILE();

  
  /*--- read data ---*/
  GET_DATA();
  
  
  /*--- call lapack subroutine SGESV, note: ---*/  
  /*--- (1) all the arguments must be pointers ---*/ 
  /*--- (2) add an underscore to the routine name ---*/
  /*--- (3) matrices must be transformed into their Fortran vector formats ---*/ 
  SGESV_(&n, &nrhs, AT, &lda, IPIV, BT, &ldb, &info); 

  
  /*--- print the solution ---*/
  PRINT_SOLUTION();
  
  
  /*--- close files ---*/
  fclose(fptA);
  fclose(fptB);

  return 0;
}
Exemple #7
0
// FLTK::Widget#redraw
mrb_value mrb_fltk_widget_redraw_instance_method( mrb_state *mrb, mrb_value self ) {
  GET_DATA( fl_widget, Fl_Widget, self );

  fl_widget->redraw();

  return self;
}
Exemple #8
0
void remmina_rdp_event_update_scale(RemminaProtocolWidget* gp)
{
	gint width, height;
	gint hscale, vscale;
	RemminaFile* remminafile;
	rfContext* rfi;

	rfi = GET_DATA(gp);
	remminafile = remmina_plugin_service->protocol_plugin_get_file(gp);

	width = remmina_plugin_service->protocol_plugin_get_width(gp);
	height = remmina_plugin_service->protocol_plugin_get_height(gp);
	hscale = remmina_plugin_service->file_get_int(remminafile, "hscale", 0);
	vscale = remmina_plugin_service->file_get_int(remminafile, "vscale", 0);

	if (rfi->scale)
	{
		gtk_widget_set_size_request(rfi->drawing_area,
			(hscale > 0 ? width * hscale / 100 : -1),
			(vscale > 0 ? height * vscale / 100 : -1));
	}
	else
	{
		gtk_widget_set_size_request(rfi->drawing_area, width, height);
	}

	remmina_plugin_service->protocol_plugin_emit_signal(gp, "update-align");
}
Exemple #9
0
Object obj_get(Object self, Object k) {
    Object v;
    switch (TM_TYPE(self)) {
    case TYPE_STR: {
        DictNode* node;
        if (TM_TYPE(k) == TYPE_NUM) {
            double d = GET_NUM(k);
            int n = d;
            if (n < 0) {
                n += GET_STR_LEN(self);
            }
            if (n >= GET_STR_LEN(self) || n < 0)
                tm_raise("String_get: index overflow ,len=%d,index=%d, str=%o",
                        GET_STR_LEN(self), n, self);
            return string_chr(0xff & GET_STR(self)[n]);
        } else if ((node = dict_get_node(GET_DICT(tm->str_proto), k)) != NULL) {
            return method_new(node->val, self);
        }
        break;
    }
    case TYPE_LIST:{
        DictNode* node;
        if (TM_TYPE(k) == TYPE_NUM) {
            return list_get(GET_LIST(self), GET_NUM(k));
        } else if ((node = dict_get_node(GET_DICT(tm->list_proto), k))!=NULL) {
            return method_new(node->val, self);
        }
        break;
    }
    case TYPE_DICT:{
        DictNode* node;
        node = dict_get_node(GET_DICT(self), k);
        if (node != NULL) {
            return node->val;
        } else if ((node = dict_get_node(GET_DICT(tm->dict_proto), k))!=NULL) {
            return method_new(node->val, self);
        }
        break;
    }
    case TYPE_FUNCTION:
        return get_func_attr(GET_FUNCTION(self), k);
    case TYPE_DATA:
        return GET_DATA(self)->get(GET_DATA(self), k);
    }
    tm_raise("keyError %o", k);
    return NONE_OBJECT;
}
Exemple #10
0
static void remmina_rdp_event_update_cursor(RemminaProtocolWidget* gp, RemminaPluginRdpUiObject* ui)
{
	rfContext* rfi;

	rfi = GET_DATA(gp);

	gdk_window_set_cursor(gtk_widget_get_window(rfi->drawing_area), ui->cursor.cursor);
}
VALUE rb_outcome(VALUE rb_obj)
{
	randvar_t *rv = NULL;
	
	GET_DATA(rb_obj, rv);

	return (*(outcome_func[RANDVAR_TYPE(rv)]))(rv);
}
Exemple #12
0
static gboolean remmina_rdp_close_connection(RemminaProtocolWidget* gp)
{
	rfContext* rfi;
	freerdp* instance;


	rfi = GET_DATA(gp);
	instance = rfi->instance;

	if (rfi->thread)
	{
		pthread_cancel(rfi->thread);

		if (rfi->thread)
			pthread_join(rfi->thread, NULL);
	}

	pthread_mutex_destroy(&rfi->mutex);

	g_mutex_free(rfi->gmutex);
	g_cond_free(rfi->gcond);

	remmina_rdp_event_uninit(gp);
	remmina_plugin_service->protocol_plugin_emit_signal(gp, "disconnect");

	if (instance)
	{
		if ( rfi->connected ) {
			if (instance->context->channels)
				freerdp_channels_close(instance->context->channels, instance);
			freerdp_disconnect(instance);
			rfi->connected = False;
		}
	}

	if (rfi->rfx_context)
	{
		rfx_context_free(rfi->rfx_context);
		rfi->rfx_context = NULL;
	}

	if (instance)
	{
		/* Remove instance->context from gp object data to avoid double free */
		g_object_steal_data(G_OBJECT(gp), "plugin-data");

		if (instance->context->channels) {
			freerdp_channels_free(instance->context->channels);
			instance->context->channels = NULL;
		}

		freerdp_context_free(instance); /* context is rfContext* rfi */
		freerdp_free(instance);
		rfi->instance = NULL;
	}

	return FALSE;
}
Exemple #13
0
		void testSendingResponse()
		{
			JsonQt::JsonRpc t;
			QSignalSpy spy(&t, SIGNAL(sendJson(const QString&)));
			t.sendResponse(QVariant(123), "foo");
			GET_DATA();
			QCOMPARE(data.value("result").toString(), QString("foo"));
			QCOMPARE(data.value("id").toInt(), 123);
		}
Exemple #14
0
/*
 * Open the named file for read, create the cluster chain, return the
 * directory structure or NULL on error.
 */
int makeit(char *dosname,
	    char *longname,
	    void *arg0,
	    direntry_t *targetEntry)
{
	Stream_t *Target;
	CreateArg_t *arg = (CreateArg_t *) arg0;
	int fat;
	direntry_t subEntry;	

	/* will it fit? At least one cluster must be free */
	if (!getfreeMinClusters(targetEntry->Dir, 1))
		return -1;
	
	mk_entry(dosname, ATTR_DIR, 1, 0, arg->mtime, &targetEntry->dir);
	Target = OpenFileByDirentry(targetEntry);
	if(!Target){
		fprintf(stderr,"Could not open Target\n");
		return -1;
	}

	/* this allocates the first cluster for our directory */

	initializeDirentry(&subEntry, Target);

	subEntry.entry = 1;
	GET_DATA(targetEntry->Dir, 0, 0, 0, &fat);
	if (fat == fat32RootCluster(targetEntry->Dir)) {
	    fat = 0;
	}
	mk_entry("..         ", ATTR_DIR, fat, 0, arg->mtime, &subEntry.dir);
	dir_write(&subEntry);

	FLUSH((Stream_t *) Target);
	subEntry.entry = 0;
	GET_DATA(Target, 0, 0, 0, &fat);
	mk_entry(".          ", ATTR_DIR, fat, 0, arg->mtime, &subEntry.dir);
	dir_write(&subEntry);

	mk_entry(dosname, ATTR_DIR | arg->attr, fat, 0, arg->mtime, 
		 &targetEntry->dir);
	arg->NewDir = Target;
	return 0;
}
Exemple #15
0
int
sftp_get_uint32(struct sftp_input *i, uint32_t *value)
{
  uint8_t buf[4];
  if (!GET_DATA(i, buf))
    return 0;

  *value = READ_UINT32(buf);
  return 1;
}
Exemple #16
0
// FLTK::Widget#box=(value)
// Sets the box type.
// TODO: Tried to use IMPLEMENT_FIXNUM_ATTRIBUTE_ACCESSOR but got this:
//       candidate function not viable: no known conversion from 'int' to 'Fl_Boxtype' for 1st argument
mrb_value mrb_fltk_widget_box_setter_instance_method( mrb_state *mrb, mrb_value self ) {
  GET_DATA( fl_widget, Fl_Widget, self );

  mrb_value value;
  mrb_get_args( mrb, "i", &value );

  fl_widget->box( (Fl_Boxtype)mrb_fixnum( value ) );

  return value;
}
Exemple #17
0
int
sftp_get_uint64(struct sftp_input *i, off_t *value)
{
  uint8_t buf[8];
  if (!GET_DATA(i, buf))
    return 0;

  *value = READ_UINT64(buf);
  return 1;
}
Exemple #18
0
// FLTK::Widget#x=(value)
mrb_value mrb_fltk_widget_x_setter_instance_method( mrb_state *mrb, mrb_value self ) {
  GET_DATA( fl_widget, Fl_Widget, self );

  mrb_value x;
  mrb_get_args( mrb, "i", &x );

  fl_widget->position( mrb_fixnum( x ), fl_widget->y() );

  return x;
}
Exemple #19
0
// FLTK::Widget#y=(value)
mrb_value mrb_fltk_widget_y_setter_instance_method( mrb_state *mrb, mrb_value self ) {
  GET_DATA( fl_widget, Fl_Widget, self );

  mrb_value y;
  mrb_get_args( mrb, "i", &y );

  fl_widget->position( fl_widget->x(), mrb_fixnum( y ) );

  return y;
}
Exemple #20
0
		void testSendingSimpleRequest()
		{
			JsonQt::JsonRpc t;
			QSignalSpy spy(&t, SIGNAL(sendJson(const QString&)));
			t.sendRequest(QVariant(123), "foo");
			GET_DATA();
			QCOMPARE(data.value("method").toString(), QString("foo"));
			QCOMPARE(data.value("id").toInt(), 123);
			QVERIFY(!data.contains("params"));
		}
Exemple #21
0
// FLTK::Widget#width=(value)
mrb_value mrb_fltk_widget_width_setter_instance_method( mrb_state *mrb, mrb_value self ) {
  GET_DATA( fl_widget, Fl_Widget, self );

  mrb_value width;
  mrb_get_args( mrb, "i", &width );

  fl_widget->size( mrb_fixnum( width ), fl_widget->h() );

  return width;
}
Exemple #22
0
// FLTK::Widget#height=(value)
mrb_value mrb_fltk_widget_height_setter_instance_method( mrb_state *mrb, mrb_value self ) {
  GET_DATA( fl_widget, Fl_Widget, self );

  mrb_value height;
  mrb_get_args( mrb, "i", &height );

  fl_widget->size( fl_widget->w(), mrb_fixnum( height ) );

  return height;
}
Exemple #23
0
		void testSendingSimpleNotification()
		{
			JsonQt::JsonRpc t;
			QSignalSpy spy(&t, SIGNAL(sendJson(const QString&)));
			t.sendNotification("foo");
			GET_DATA();
			QCOMPARE(data.value("method").toString(), QString("foo"));
			QVERIFY(!data.contains("id"));
			QVERIFY(!data.contains("params"));
		}
Exemple #24
0
// FLTK.focus=(widget)
// Sets the current focused widget.
mrb_value mrb_fltk_focus_setter_module_method( mrb_state *mrb, mrb_value self ) {
  mrb_value mrb_widget;
  mrb_get_args( mrb, "o", &mrb_widget );
  // TODO: Raise error unless it is a FLTK::Widget

  GET_DATA( fl_widget, Fl_Widget, mrb_widget );

  Fl::focus( fl_widget );

  return mrb_widget;
}
// get data from multi_local_options struct
void get_local_options(ubyte *data, int *size, multi_local_options *mlo)
{
	int offset = *size;

	GET_DATA(*mlo);

	mlo->flags = INTEL_INT(mlo->flags); //-V570
	mlo->obj_update_level = INTEL_INT(mlo->obj_update_level); //-V570

	*size = offset;
}
Exemple #26
0
void remmina_rdp_event_update_rect(RemminaProtocolWidget* gp, gint x, gint y, gint w, gint h)
{
	rfContext* rfi;

	rfi = GET_DATA(gp);

	if (remmina_plugin_service->protocol_plugin_get_scale(gp))
		remmina_rdp_event_scale_area(gp, &x, &y, &w, &h);

	gtk_widget_queue_draw_area(rfi->drawing_area, x, y, w, h);
}
Exemple #27
0
// FLTK::Widget#type=(value)
// Sets the widget type.
mrb_value mrb_fltk_widget_type_setter_instance_method( mrb_state *mrb, mrb_value self ) {
  GET_DATA( fl_widget, Fl_Widget, self );

  mrb_value value;
  mrb_get_args( mrb, "i", &value );

  fl_widget->type( (int)mrb_fixnum( value ) );

  Fl_Group::current( 0 ); // Prevent new widgets from being added to a group

  return value;
}
Exemple #28
0
void rf_get_fds(RemminaProtocolWidget* gp, void** rfds, int* rcount)
{
    rfContext* rfi;

    rfi = GET_DATA(gp);

    if (rfi->event_pipe[0] != -1)
    {
        rfds[*rcount] = GINT_TO_POINTER(rfi->event_pipe[0]);
        (*rcount)++;
    }
}
Exemple #29
0
		void testSendingComplexNotification()
		{
			JsonQt::JsonRpc t;
			QSignalSpy spy(&t, SIGNAL(sendJson(const QString&)));
			QVariantMap params;
			params["bar"] = "baz";
			t.sendNotification("foo", params);
			GET_DATA();
			QCOMPARE(data.value("method").toString(), QString("foo"));
			QVERIFY(!data.contains("id"));
			QCOMPARE(data.value("params").toMap(), params);
		}
Exemple #30
0
static gboolean remmina_rdp_close_connection(RemminaProtocolWidget* gp)
{
    rfContext* rfi;
    freerdp* instance;

    rfi = GET_DATA(gp);
    instance = rfi->instance;

    if (rfi->thread)
    {
        pthread_cancel(rfi->thread);

        if (rfi->thread)
            pthread_join(rfi->thread, NULL);
    }

    pthread_mutex_destroy(&rfi->mutex);

    g_mutex_free(rfi->gmutex);
    g_cond_free(rfi->gcond);

    remmina_rdp_event_uninit(gp);
    remmina_plugin_service->protocol_plugin_emit_signal(gp, "disconnect");

    if (instance)
    {
        if (rfi->channels)
        {
            //freerdp_channels_close(rfi->channels, instance);
            freerdp_channels_free(rfi->channels);
            rfi->channels = NULL;
        }
        if (freerdp_shall_disconnect(instance))
        {
            freerdp_disconnect(instance);
        }
    }

    if (rfi->rfx_context)
    {
        rfx_context_free(rfi->rfx_context);
        rfi->rfx_context = NULL;
    }

    if (instance)
    {
        //freerdp_context_free(instance); /* context is rfContext* rfi */
        freerdp_free(instance);
    }

    return FALSE;
}