示例#1
0
static void send_data(int sd, const char *to, const char *data, int len) {
	int n;
	//int i, seq;
	char *sid = new_sid();

	send_recv(sd, get_send_init(buf, to, new_id(), sid, "log.xml", 619));
	send_recv(sd, get_send_disco(buf, to, new_id()));
	n = read(sd, buf, BUFSIZE);
	buf[n] = '\0';
	printf("<===\n%s\n", buf);
	send_recv(sd, get_send_block_size(buf, to, new_id(), sid));

	sprintf(buf, "<iq id=\"%s\" to=\"%s@%s/Spark 2.6.3\" type=\"set\"><data xmlns=\"http://jabber.org/protocol/ibb\" seq=\"0\" sid=\"%s\">PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz48c3RyZWFtOnN0cmVhbSB4bWxuczpzdHJlYW09Imh0dHA6Ly9ldGhlcnguamFiYmVyLm9yZy9zdHJlYW1zIiB4bWxucz0iamFiYmVyOmNsaWVudCIgZnJvbT0iMTkyLjE2OC4xLjEyNyIgaWQ9IjE1ZDc0NTAzIiB4bWw6bGFuZz0iZW4iIHZlcnNpb249IjEuMCI+PHN0cmVhbTpmZWF0dXJlcz48bWVjaGFuaXNtcyB4bWxucz0idXJuOmlldGY6cGFyYW1zOnhtbDpuczp4bXBwLXNhc2wiPjxtZWNoYW5pc20+RElHRVNULU1ENTwvbWVjaGFuaXNtPjxtZWNoYW5pc20+SklWRS1TSEFSRURTRUNSRVQ8L21lY2hhbmlzbT48bWVjaGFuaXNtPlBMQUlOPC9tZWNoYW5pc20+PG1lY2hhbmlzbT5DUkFNLU1ENTwvbWVjaGFuaXNtPjwvbWVjaGFuaXNtcz48Y29tcHJlc3Npb24geG1sbnM9Imh0dHA6Ly9qYWJiZXIub3JnL2ZlYXR1cmVzL2NvbXByZXNzIj48bWV0aG9kPnpsaWI8L21ldGhvZD48L2NvbXByZXNzaW9uPjxhdXRoIHhtbG5zPSJodHRwOi8vamFiYmVyLm9yZy9mZWF0dXJlcy9pcS1hdXRoIi8+PHJlZ2lzdGVyIHhtbG5zPSJodHRwOi8vamFiYmVyLm9yZy9mZWF0dXJlcy9pcS1yZWdpc3RlciIvPjwvc3RyZWFtOmZlYXR1cmVzPg==</data></iq>", new_id(), to, SERVER_IP, sid);
	send_recv(sd, buf);

	send_recv(sd, get_send_close(buf, new_id(), to, sid));

	return;
#if 0
	for (i = 0, seq = 0; i < len; i += 400, seq++) {
		n = sprintf(sock_buf, "<iq id=\"%s\" to=\"%s@%s/Spark 2.6.3\" type=\"set\"><data xmlns=\"http://jabber.org/protocol/ibb\" seq=\"%d\" sid=\"%s\">", new_id(), to, SERVER_IP, seq, sid);
		base64_encode(sock_buf + n, data+i, (len - i) > 400 ? 400 : (len -i));
		strcat(sock_buf, "</data></iq>");
		
		send_recv(sd, sock_buf);
	}

	send_recv(sd, get_send_close(buf, to, id, sid));
#endif
}
示例#2
0
/* ------------------------------------------------------------------------- */
#if 0 /* UNUSED */
void autotexname(Tex *tex)
{
	Main *bmain = G.main;
	char texstr[20][15] = {"None", "Clouds", "Wood", "Marble", "Magic", "Blend",
		                   "Stucci", "Noise", "Image", "EnvMap", "Musgrave",
		                   "Voronoi", "DistNoise", "Point Density", "Voxel Data", "Ocean", "", "", ""};
	Image *ima;
	char di[FILE_MAXDIR], fi[FILE_MAXFILE];
	
	if (tex) {
		if (tex->use_nodes) {
			new_id(&bmain->tex, (ID *)tex, "Noddy");
		}
		else if (tex->type == TEX_IMAGE) {
			ima = tex->ima;
			if (ima) {
				BLI_split_file_part(ima->name, fi, sizeof(fi));
				strcpy(di, "I.");
				strcat(di, fi);
				new_id(&bmain->tex, (ID *)tex, di);
			}
			else {
				new_id(&bmain->tex, (ID *)tex, texstr[tex->type]);
			}
		}
		else {
			new_id(&bmain->tex, (ID *)tex, texstr[tex->type]);
		}
	}
}
示例#3
0
// Table construction.
unsigned id_of_nexus_0(ivl_nexus_t nexus, nexus_table_t table, unsigned is_driven)
{
  if (nexus == table->nexus) {
    table->is_driven = table->is_driven || is_driven;
    return table->id;
  }
  else if (nexus < table->nexus)
    if (table->lt)
      return id_of_nexus_0(nexus, table->lt, is_driven);
    else {
      table->lt = (nexus_table_t) (malloc(sizeof(*table)));
      table->lt->nexus = nexus;
      table->lt->id = new_id();
      table->lt->is_driven = is_driven;
      table->lt->lt = 0;
      table->lt->gt = 0;
      return table->lt->id;
    }
  else // nexus > table->nexus
    if (table->gt)
      return id_of_nexus_0(nexus, table->gt, is_driven);
    else {
      table->gt = (nexus_table_t) (malloc(sizeof(*table)));
      table->gt->nexus = nexus;
      table->gt->id = new_id();
      table->gt->is_driven = is_driven;
      table->gt->lt = 0;
      table->gt->gt = 0;
      return table->gt->id;
    }
}
示例#4
0
// does copy_fcurve...
void make_local_action(bAction *act)
{
	tMakeLocalActionContext mlac = {act, NULL, 0, 0};
	Main *bmain= G.main;
	
	if (act->id.lib==NULL) 
		return;
	
	// XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default
	if ((act->id.flag & LIB_FAKEUSER) && (act->id.us<=1)) {
		act->id.lib= NULL;
		act->id.flag= LIB_LOCAL;
		new_id(&bmain->action, (ID *)act, NULL);
		return;
	}
	
	BKE_animdata_main_cb(bmain, make_localact_init_cb, &mlac);
	
	if (mlac.local && mlac.lib==0) {
		act->id.lib= NULL;
		act->id.flag= LIB_LOCAL;
		//make_local_action_channels(act);
		new_id(&bmain->action, (ID *)act, NULL);
	}
	else if (mlac.local && mlac.lib) {
		mlac.actn= copy_action(act);
		mlac.actn->id.us= 0;
		
		BKE_animdata_main_cb(bmain, make_localact_apply_cb, &mlac);
	}
}
示例#5
0
文件: int.c 项目: openSUSE/hwinfo
/*
 * Turn some drives into floppies.
 */
void int_floppy(hd_data_t *hd_data)
{
  hd_t *hd;
  hd_res_t *res;

  for(hd = hd_data->hd; hd; hd = hd->next) {
    if(is_zip(hd)) hd->is.zip = 1;
    if(
      hd->base_class.id == bc_storage_device &&
      hd->sub_class.id == sc_sdev_disk
    ) {
      if(hd->is.zip) {
        hd->sub_class.id = sc_sdev_floppy;
        new_id(hd_data, hd);
      }
      else {
        /* make everything a floppy that is 1440k */
        for(res = hd->res; res; res = res->next) {
          if(
            res->any.type == res_size &&
            res->size.unit == size_unit_sectors &&
            res->size.val1 == 2880 &&
            res->size.val2 == 512
          ) {
            hd->sub_class.id = sc_sdev_floppy;
            new_id(hd_data, hd);
            break;
          }
        }
      }
    }
  }
}
示例#6
0
void autotexname(Tex *tex)
{
	Main *bmain= G.main;
	char texstr[20][15]= {"None"  , "Clouds" , "Wood", "Marble", "Magic"  , "Blend",
		"Stucci", "Noise"  , "Image", "Plugin", "EnvMap" , "Musgrave",
		"Voronoi", "DistNoise", "Point Density", "Voxel Data", "", "", "", ""};
	Image *ima;
	char di[FILE_MAXDIR], fi[FILE_MAXFILE];
	
	if(tex) {
		if(tex->use_nodes) {
			new_id(&bmain->tex, (ID *)tex, "Noddy");
		}
		else
		if(tex->type==TEX_IMAGE) {
			ima= tex->ima;
			if(ima) {
				strcpy(di, ima->name);
				BLI_splitdirstring(di, fi);
				strcpy(di, "I.");
				strcat(di, fi);
				new_id(&bmain->tex, (ID *)tex, di);
			}
			else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]);
		}
		else if(tex->type==TEX_PLUGIN && tex->plugin) new_id(&bmain->tex, (ID *)tex, tex->plugin->pname);
		else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]);
	}
}
示例#7
0
void make_local_brush(Brush *brush)
{

	/* - only lib users: do nothing
	 * - only local users: set flag
	 * - mixed: make copy
	 */

	Main *bmain= G.main;
	Scene *scene;
	int local= 0, lib= 0;

	if(brush->id.lib==NULL) return;

	if(brush->clone.image) {
		/* special case: ima always local immediately */
		brush->clone.image->id.lib= NULL;
		brush->clone.image->id.flag= LIB_LOCAL;
		new_id(&bmain->brush, (ID *)brush->clone.image, NULL);
		extern_local_brush(brush);
	}

	for(scene= bmain->scene.first; scene && ELEM(0, lib, local); scene=scene->id.next) {
		if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
			if(scene->id.lib) lib= 1;
			else local= 1;
		}
	}

	if(local && lib==0) {
		brush->id.lib= NULL;
		brush->id.flag= LIB_LOCAL;
		new_id(&bmain->brush, (ID *)brush, NULL);
		extern_local_brush(brush);

		/* enable fake user by default */
		if (!(brush->id.flag & LIB_FAKEUSER)) {
			brush->id.flag |= LIB_FAKEUSER;
			brush->id.us++;
		}
	}
	else if(local && lib) {
		Brush *brushn= copy_brush(brush);
		brushn->id.us= 1; /* only keep fake user */
		brushn->id.flag |= LIB_FAKEUSER;
		
		for(scene= bmain->scene.first; scene; scene=scene->id.next) {
			if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
				if(scene->id.lib==NULL) {
					paint_brush_set(&scene->toolsettings->imapaint.paint, brushn);
				}
			}
		}
	}
}
示例#8
0
void
evaluate_beagle_instances_proposal (proposal_fmt * proposal,
				    node * mother,  
				    node * newdaughter, long newdaughter_id, long newdaughter_bid, 
				    MYREAL v)
{
    node *nn = NULL, *d1 = NULL, *d2 = NULL, *oldnn = NULL;

    if (mother->type != 'r')
    {
        children (mother, &d1, &d2);
        if (d1 == newdaughter)
	  {
	    d1 = d2;
	  }
	long id0, id1, id2;
	long bid1, bid2;
	double v1, v2;
	id0  = mother->id; 
	id1  = new_id(newdaughter_id, proposal->world->sumtips);
	bid1 = newdaughter_bid;
	v1 = v;
	id2  = d1->id;
	bid2 = d1->bid;
	v2 = d1->v;
	prepare_beagle_instances_proposal(proposal, id0, id1, bid1, v1, id2, bid2, v2, proposal->world->beagle);

        oldnn = mother;
        nn = showtop (crawlback (mother));
        while (nn->type != 'r')
        {
            children (nn, &d1, &d2);
            if (d1 == oldnn)
	      {
		d1 = d2;
		d2 = oldnn;
	      }
	    if(d2->id != oldnn->id)
	      {
		warning("One of the children is not what it should be\n");
	      }
	    id0  = nn->id; 
	    id1  = new_id(d2->id,proposal->world->sumtips);;
	    bid1 = d2->bid;
	    v1 = d2->v;
	    id2  = d1->id;
	    bid2 = d1->bid;
	    v2 = d1->v;
	    prepare_beagle_instances_proposal(proposal, id0, id1, bid1, v1, id2, bid2, v2, proposal->world->beagle);

            oldnn = nn;
            nn = showtop (crawlback (nn));
        }
    }
}
示例#9
0
文件: mesh.c 项目: jinjoh/NOOR
void make_local_mesh(Mesh *me)
{
	Object *ob;
	Mesh *men;
	int local=0, lib=0;

	/* - only lib users: do nothing
	    * - only local users: set flag
	    * - mixed: make copy
	    */
	
	if(me->id.lib==0) return;
	if(me->id.us==1) {
		me->id.lib= 0;
		me->id.flag= LIB_LOCAL;
		new_id(0, (ID *)me, 0);
		
		if(me->mtface) make_local_tface(me);
		
		return;
	}
	
	ob= G.main->object.first;
	while(ob) {
		if( me==get_mesh(ob) ) {
			if(ob->id.lib) lib= 1;
			else local= 1;
		}
		ob= ob->id.next;
	}
	
	if(local && lib==0) {
		me->id.lib= 0;
		me->id.flag= LIB_LOCAL;
		new_id(0, (ID *)me, 0);
		
		if(me->mtface) make_local_tface(me);
		
	}
	else if(local && lib) {
		men= copy_mesh(me);
		men->id.us= 0;
		
		ob= G.main->object.first;
		while(ob) {
			if( me==get_mesh(ob) ) {				
				if(ob->id.lib==0) {
					set_mesh(ob, men);
				}
			}
			ob= ob->id.next;
		}
	}
}
示例#10
0
/* if lib!=NULL, only all from lib local */
void all_local(Library *lib, int untagged_only)
{
	ListBase *lbarray[MAX_LIBARRAY], tempbase={NULL, NULL};
	ID *id, *idn;
	int a;

	a= set_listbasepointers(G.main, lbarray);
	while(a--) {
		id= lbarray[a]->first;
		
		while(id) {
			id->newid= NULL;
			idn= id->next;		/* id is possibly being inserted again */
			
			/* The check on the second line (LIB_PRE_EXISTING) is done so its
			 * possible to tag data you dont want to be made local, used for
			 * appending data, so any libdata already linked wont become local
			 * (very nasty to discover all your links are lost after appending)  
			 * */
			if(id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW) &&
			  (untagged_only==0 || !(id->flag & LIB_PRE_EXISTING)))
			{
				if(lib==NULL || id->lib==lib) {
					id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW);

					if(id->lib) {
						/* relative file patch */
						if(GS(id->name)==ID_IM)
							image_fix_relative_path((Image *)id);
						
						id->lib= NULL;
						new_id(lbarray[a], id, NULL);	/* new_id only does it with double names */
						sort_alpha_id(lbarray[a], id);
					}
				}
			}
			id= idn;
		}
		
		/* patch2: make it aphabetically */
		while( (id=tempbase.first) ) {
			BLI_remlink(&tempbase, id);
			BLI_addtail(lbarray[a], id);
			new_id(lbarray[a], id, NULL);
		}
	}

	/* patch 3: make sure library data isn't indirect falsely... */
	a= set_listbasepointers(G.main, lbarray);
	while(a--) {
		for(id= lbarray[a]->first; id; id=id->next)
			lib_indirect_test_id(id, lib);
	}
}
示例#11
0
文件: speaker.c 项目: BHCLL/blendocv
void make_local_speaker(Speaker *spk)
{
	Main *bmain= G.main;
	Object *ob;
	int local=0, lib=0;

	/* - only lib users: do nothing
		* - only local users: set flag
		* - mixed: make copy
		*/

	if(spk->id.lib==NULL) return;
	if(spk->id.us==1) {
		spk->id.lib= NULL;
		spk->id.flag= LIB_LOCAL;
		new_id(&bmain->speaker, (ID *)spk, NULL);
		return;
	}

	ob= bmain->object.first;
	while(ob) {
		if(ob->data==spk) {
			if(ob->id.lib) lib= 1;
			else local= 1;
		}
		ob= ob->id.next;
	}

	if(local && lib==0) {
		spk->id.lib= NULL;
		spk->id.flag= LIB_LOCAL;
		new_id(&bmain->speaker, (ID *)spk, NULL);
	}
	else if(local && lib) {
		Speaker *spkn= copy_speaker(spk);
		spkn->id.us= 0;

		ob= bmain->object.first;
		while(ob) {
			if(ob->data==spk) {

				if(ob->id.lib==NULL) {
					ob->data= spkn;
					spkn->id.us++;
					spk->id.us--;
				}
			}
			ob= ob->id.next;
		}
	}
}
示例#12
0
文件: world.c 项目: jinjoh/NOOR
void make_local_world(World *wrld)
{
	Scene *sce;
	World *wrldn;
	int local=0, lib=0;

	/* - only lib users: do nothing
	    * - only local users: set flag
	    * - mixed: make copy
	    */
	
	if(wrld->id.lib==0) return;
	if(wrld->id.us==1) {
		wrld->id.lib= 0;
		wrld->id.flag= LIB_LOCAL;
		new_id(0, (ID *)wrld, 0);
		return;
	}
	
	sce= G.main->scene.first;
	while(sce) {
		if(sce->world==wrld) {
			if(sce->id.lib) lib= 1;
			else local= 1;
		}
		sce= sce->id.next;
	}
	
	if(local && lib==0) {
		wrld->id.lib= 0;
		wrld->id.flag= LIB_LOCAL;
		new_id(0, (ID *)wrld, 0);
	}
	else if(local && lib) {
		wrldn= copy_world(wrld);
		wrldn->id.us= 0;
		
		sce= G.main->scene.first;
		while(sce) {
			if(sce->world==wrld) {
				if(sce->id.lib==0) {
					sce->world= wrldn;
					wrldn->id.us++;
					wrld->id.us--;
				}
			}
			sce= sce->id.next;
		}
	}
}
示例#13
0
void make_local_mesh(Mesh *me)
{
	Main *bmain= G.main;
	Object *ob;
	int local=0, lib=0;

	/* - only lib users: do nothing
	 * - only local users: set flag
	 * - mixed: make copy
	 */

	if(me->id.lib==NULL) return;
	if(me->id.us==1) {
		me->id.lib= NULL;
		me->id.flag= LIB_LOCAL;

		new_id(&bmain->mesh, (ID *)me, NULL);
		expand_local_mesh(bmain, me);
		return;
	}

	for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) {
		if(me == ob->data) {
			if(ob->id.lib) lib= 1;
			else local= 1;
		}
	}

	if(local && lib==0) {
		me->id.lib= NULL;
		me->id.flag= LIB_LOCAL;

		new_id(&bmain->mesh, (ID *)me, NULL);
		expand_local_mesh(bmain, me);
	}
	else if(local && lib) {
		Mesh *men= copy_mesh(me);
		men->id.us= 0;

		for(ob= bmain->object.first; ob; ob= ob->id.next) {
			if(me == ob->data) {
				if(ob->id.lib==NULL) {
					set_mesh(ob, men);
				}
			}
		}
	}
}
示例#14
0
/**
 * Pull an ID out of a library (make it local). Only call this for IDs that
 * don't have other library users.
 */
void id_clear_lib_data(Main *bmain, ID *id)
{
	bNodeTree *ntree = NULL;

	BKE_id_lib_local_paths(bmain, id->lib, id);

	if (id->flag & LIB_FAKEUSER) {
		id->us--;
		id->flag &= ~LIB_FAKEUSER;
	}

	id->lib = NULL;
	id->flag = LIB_LOCAL;
	new_id(which_libbase(bmain, GS(id->name)), id, NULL);

	/* internal bNodeTree blocks inside ID types below
	 * also stores id->lib, make sure this stays in sync.
	 */
	switch (GS(id->name)) {
		case ID_SCE:	ntree = ((Scene *)id)->nodetree;		break;
		case ID_MA:		ntree = ((Material *)id)->nodetree;		break;
		case ID_LA:		ntree = ((Lamp *)id)->nodetree;			break;
		case ID_WO:		ntree = ((World *)id)->nodetree;		break;
		case ID_TE:		ntree = ((Tex *)id)->nodetree;			break;
	}
	if (ntree)
		ntree->id.lib = NULL;
}
示例#15
0
message_ex* message_ex::create_request(dsn_task_code_t rpc_code, int timeout_milliseconds, int hash)
{
    message_ex* msg = new message_ex();
    msg->_is_read = false;
    msg->prepare_buffer_header();

    // init header
    auto& hdr = *msg->header;
    memset(&hdr, 0, sizeof(hdr));
    hdr.hdr_crc32 = hdr.body_crc32 = CRC_INVALID;    
    
    if (DSN_INVALID_HASH != hash) 
        hdr.client.hash = hash;

    if (0 == timeout_milliseconds)
    {
        hdr.client.timeout_ms = task_spec::get(rpc_code)->rpc_timeout_milliseconds;
    }
    else
    {
        hdr.client.timeout_ms = timeout_milliseconds;
    }

    strncpy(hdr.rpc_name, dsn_task_code_to_string(rpc_code), sizeof(hdr.rpc_name));

    hdr.id = new_id();

    msg->local_rpc_code = (uint16_t)rpc_code;
    return msg;
}
示例#16
0
ERL_NIF_TERM x_create(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    const char * func_name = "x_create()";
    logger.debug(MOD_NAME, func_name, "Entered");
    logger.flush();

    rados_t cluster;
    int err = rados_create(&cluster, NULL);
    if (err < 0) 
    {
        logger.error(MOD_NAME, func_name, "Unable to create cluster handle");
        return make_error_tuple(env, -err);
    }

    logger.debug(MOD_NAME, func_name, "cluster created");
    logger.flush();

    uint64_t id = new_id();
    map_cluster_add(id, cluster);

    logger.debug(MOD_NAME, func_name, "cluster added to local map: %ld", id);
    logger.flush();

    return enif_make_tuple2(env, 
                            enif_make_atom(env, "ok"),
                            enif_make_uint64(env, id));
}
示例#17
0
ERL_NIF_TERM x_create_with_user(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    const char * func_name = "x_create_with_user()";
    logger.debug(MOD_NAME, func_name, "Entered");

    char name[MAX_NAME_LEN];
    memset(name, 0, MAX_NAME_LEN);
    if (!enif_get_string(env, argv[0], name, MAX_NAME_LEN, ERL_NIF_LATIN1))
    {
        logger.error(MOD_NAME, func_name, "enif get params failed");
        return enif_make_badarg(env);
    }

    rados_t cluster;
    int err = rados_create(&cluster, name);
    if (err < 0) 
    {
        logger.error(MOD_NAME, func_name, "Unable to create cluster handle with name: %s", name);
        return make_error_tuple(env, -err);
    }

    uint64_t id = new_id();
    map_cluster_add(id, cluster);

    logger.debug(MOD_NAME, func_name, "cluster : %ld", id);

    return enif_make_tuple2(env,
                            enif_make_atom(env, "ok"),
                            enif_make_uint64(env, id));
}
示例#18
0
// Create bit concat.
unsigned create_bit_concat(unsigned input_id, unsigned input_width, ivl_nexus_t nexus)
{
  unsigned id = new_id();
  indent();
  fprintf(output, "  (concat %i 1 %i %i %i)\n", id, input_width, id_of_nexus(nexus, 0), input_id);
  return id;
}
示例#19
0
文件: rpc_message.cpp 项目: ykwd/rDSN
message_ex* message_ex::create_request(dsn_task_code_t rpc_code, int timeout_milliseconds, uint64_t hash)
{
    message_ex* msg = new message_ex();
    msg->_is_read = false;
    msg->prepare_buffer_header();

    // init header
    auto& hdr = *msg->header;
    memset(&hdr, 0, sizeof(hdr));
    hdr.hdr_crc32 = hdr.body_crc32 = CRC_INVALID;

    hdr.client.hash = hash;

    if (0 == timeout_milliseconds)
    {
        hdr.client.timeout_ms = task_spec::get(rpc_code)->rpc_timeout_milliseconds;
    }
    else
    {
        hdr.client.timeout_ms = timeout_milliseconds;
    }

    task_spec* sp = task_spec::get(rpc_code);
    strncpy(hdr.rpc_name, sp->name.c_str(), sizeof(hdr.rpc_name));
    hdr.rpc_name_fast.local_rpc_id = (uint32_t)rpc_code;
    hdr.rpc_name_fast.local_hash = s_local_hash;

    hdr.id = new_id();

    hdr.context.u.is_request = true;
    hdr.context.u.serialize_format = sp->rpc_msg_payload_serialize_default_format;

    msg->local_rpc_code = (uint32_t)rpc_code;
    return msg;
}
示例#20
0
/* Pull an ID out of a library (make it local). Only call this for IDs that
 * don't have other library users. */
void id_clear_lib_data(Main *bmain, ID *id)
{
    BKE_id_lib_local_paths(bmain, id->lib, id);

    id->lib = NULL;
    id->flag = LIB_LOCAL;
    new_id(which_libbase(bmain, GS(id->name)), id, NULL);
}
示例#21
0
void make_local_lattice(Lattice *lt)
{
	Main *bmain= G.main;
	Object *ob;
	int local=0, lib=0;

	/* - only lib users: do nothing
	 * - only local users: set flag
	 * - mixed: make copy
	 */
	
	if(lt->id.lib==NULL) return;
	if(lt->id.us==1) {
		lt->id.lib= NULL;
		lt->id.flag= LIB_LOCAL;
		new_id(&bmain->latt, (ID *)lt, NULL);
		return;
	}
	
	for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) {
		if(ob->data==lt) {
			if(ob->id.lib) lib= 1;
			else local= 1;
		}
	}
	
	if(local && lib==0) {
		lt->id.lib= NULL;
		lt->id.flag= LIB_LOCAL;
		new_id(&bmain->latt, (ID *)lt, NULL);
	}
	else if(local && lib) {
		Lattice *ltn= copy_lattice(lt);
		ltn->id.us= 0;

		for(ob= bmain->object.first; ob; ob= ob->id.next) {
			if(ob->data==lt) {
				if(ob->id.lib==NULL) {
					ob->data= ltn;
					ltn->id.us++;
					lt->id.us--;
				}
			}
		}
	}
}
示例#22
0
void rename_id(ID *id, const char *name)
{
	ListBase *lb;

	BLI_strncpy(id->name+2, name, sizeof(id->name)-2);
	lb= which_libbase(G.main, GS(id->name) );
	
	new_id(lb, id, name);				
}
示例#23
0
message::id_t message::set_id(id_t id) {
	if (!id) {
		new_id();
		return 0;
	} else {
		msg_id = id;
		return id;
	} // end if id
} // end set_id
示例#24
0
文件: library.c 项目: jinjoh/NOOR
void rename_id(ID *id, char *name)
{
	ListBase *lb;
	
	strncpy(id->name+2, name, 21);
	lb= wich_libbase(G.main, GS(id->name) );
	
	new_id(lb, id, name);				
}
示例#25
0
文件: int.c 项目: openSUSE/hwinfo
/*
 * Remove usb entries that are handled by usb-storage.
 */
void int_fix_usb_scsi(hd_data_t *hd_data)
{
  hd_t *hd_scsi, *hd_usb;

  for(hd_usb = hd_data->hd; hd_usb; hd_usb= hd_usb->next) {
    if(
      hd_usb->bus.id == bus_usb &&
      hd_usb->sysfs_id &&
      search_str_list(hd_usb->drivers, "usb-storage")
    ) {
      for(hd_scsi = hd_data->hd; hd_scsi; hd_scsi = hd_scsi->next) {
        if(
          hd_scsi->bus.id == bus_scsi &&
          hd_scsi->sysfs_device_link &&
          search_str_list(hd_scsi->drivers, "usb-storage")
        ) {
          if(!strncmp(hd_scsi->sysfs_device_link, hd_usb->sysfs_id, strlen(hd_usb->sysfs_id))) {
            hd_set_hw_class(hd_scsi, hw_usb);

            free_mem(hd_scsi->unique_id);
            hd_scsi->unique_id = hd_usb->unique_id;
            hd_usb->unique_id = NULL;

            add_res_entry(&hd_scsi->res, hd_usb->res);
            hd_usb->res = NULL;

            if(!hd_scsi->modalias) {
              hd_scsi->modalias = hd_usb->modalias;
              hd_usb->modalias = NULL;
            }

            if(!hd_scsi->vendor.id) hd_scsi->vendor.id = hd_usb->vendor.id;
            if(!hd_scsi->device.id) hd_scsi->device.id = hd_usb->device.id;

            if(!hd_scsi->serial) {
              hd_scsi->serial = hd_usb->serial;
              hd_usb->serial = NULL;
            }

            if(!hd_scsi->driver_info) {
              hd_scsi->driver_info = hd_usb->driver_info;
              hd_usb->driver_info = NULL;
            }

            new_id(hd_data, hd_scsi);

            hd_usb->tag.remove = 1;
          }
        }
      }
    }
  }

  remove_tagged_hd_entries(hd_data);
}
示例#26
0
/* if lib!=NULL, only all from lib local
 * bmain is almost certainly G.main */
void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only)
{
    ListBase *lbarray[MAX_LIBARRAY], tempbase = {NULL, NULL};
    ID *id, *idn;
    int a;

    a = set_listbasepointers(bmain, lbarray);
    while (a--) {
        id = lbarray[a]->first;

        while (id) {
            id->newid = NULL;
            idn = id->next;      /* id is possibly being inserted again */

            /* The check on the second line (LIB_PRE_EXISTING) is done so its
             * possible to tag data you don't want to be made local, used for
             * appending data, so any libdata already linked wont become local
             * (very nasty to discover all your links are lost after appending)
             * */
            if (id->flag & (LIB_EXTERN | LIB_INDIRECT | LIB_NEW) &&
                    (untagged_only == 0 || !(id->flag & LIB_PRE_EXISTING)))
            {
                if (lib == NULL || id->lib == lib) {
                    if (id->lib) {
                        id_clear_lib_data(bmain, id); /* sets 'id->flag' */

                        /* why sort alphabetically here but not in
                         * id_clear_lib_data() ? - campbell */
                        id_sort_by_name(lbarray[a], id);
                    }
                    else {
                        id->flag &= ~(LIB_EXTERN | LIB_INDIRECT | LIB_NEW);
                    }
                }
            }
            id = idn;
        }

        /* patch2: make it aphabetically */
        while ( (id = tempbase.first) ) {
            BLI_remlink(&tempbase, id);
            BLI_addtail(lbarray[a], id);
            new_id(lbarray[a], id, NULL);
        }
    }

    /* patch 3: make sure library data isn't indirect falsely... */
    a = set_listbasepointers(bmain, lbarray);
    while (a--) {
        for (id = lbarray[a]->first; id; id = id->next)
            lib_indirect_test_id(id, lib);
    }
}
示例#27
0
// Lookup nexus id.
unsigned id_of_nexus(ivl_nexus_t nexus, unsigned is_driven)
{
  if (! nexus_table) {
    nexus_table = (nexus_table_t) (malloc(sizeof(*nexus_table)));
    nexus_table->nexus = nexus;
    nexus_table->id = new_id();
    nexus_table->is_driven = is_driven;
    nexus_table->lt = 0;
    nexus_table->gt = 0;
    return nexus_table->id;
  }
  else
    return id_of_nexus_0(nexus, nexus_table, is_driven);
}
示例#28
0
static int mips_check_control(struct perfctr_cpu_state *state)
{
    unsigned int i, nractrs, nrctrs, pmc_mask, pmi_mask, pmc;
    unsigned int nr_pmcs;

    // ensuring that the total no of performance registers that
    // are monitored are not more than available number
    nr_pmcs = get_nr_pmcs();
    nractrs = state->control.nractrs;
    nrctrs = nractrs + state->control.nrictrs;    // we could have got this from cstatus. Isn't that so?
    if ( (nrctrs < nractrs) || (nrctrs > nr_pmcs) )
        return -EINVAL;

    // ctrl_reg are the control registers, while .map contains
    // the actual register number to use while reading and writing
    pmc_mask = 0;
    pmi_mask = 0;
    // memset(ctrl_regs, 0, sizeof(ctrl_regs));

    for(i = 0; i < nrctrs; ++i) {
        pmc = state->control.pmc[i].map;    // for ppc, 0 <= pmc, the map value <= 5

        // ok, here is where the user-specified values are being copied to the
        // variables in the 'state' variable

        state->pmc[i].map = pmc;

        if (pmc >= nr_pmcs || (pmc_mask & (1<<pmc))) {
            return -EINVAL;
        }

        pmc_mask |= (1<<pmc);
        if (i >= nractrs) {
            pmi_mask |= (1<<pmc);
        }

        // IMPORTANT: check that we haven't set the interrupt-enable bit for a-mode registers

        // do some more sanity check that the user specifed valid control data
        // if ( (ctrl_reg[pmc] & MIPS_XLR_EVNTSEL_RESERVED) != 0 )
        //    return -EINVAL;

        // what more sanity checks do we need ?
    }

    state->k1.id = new_id();

    return 0;
}
示例#29
0
/* used everywhere in blenkernel and text.c */
void *alloc_libblock(ListBase *lb, short type, const char *name)
{
	ID *id= NULL;
	
	id= alloc_libblock_notest(type);
	if(id) {
		BLI_addtail(lb, id);
		id->us= 1;
		id->icon_id = 0;
		*( (short *)id->name )= type;
		new_id(lb, id, name);
		/* alphabetic insterion: is in new_id */
	}
	return id;
}
示例#30
0
void test_idbutton(char *name)
{
	/* called from buttons: when name already exists: call new_id */
	ListBase *lb;
	ID *idtest;
	

	lb= which_libbase(G.main, GS(name-2) );
	if(lb==NULL) return;
	
	/* search for id */
	idtest= BLI_findstring(lb, name, offsetof(ID, name) + 2);

	if(idtest) if( new_id(lb, idtest, name)==0 ) sort_alpha_id(lb, idtest);
}