当前位置: 首页>>代码示例>>C++>>正文


C++ convM2D函数代码示例

本文整理汇总了C++中convM2D函数的典型用法代码示例。如果您正苦于以下问题:C++ convM2D函数的具体用法?C++ convM2D怎么用?C++ convM2D使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了convM2D函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dsoconcatread

static long
dsoconcatread(MyFiles *f, void *a, long n, vlong offset){
	int nfiles = f->nfiles;
	long leido = 0, aux_leido;
	vlong newoff = offset;
	Dir* fs;
	int tamb = 1024;
	int i = 0, j;
	long toread;
	uchar* buffer = (uchar*)malloc(sizeof(uchar)*tamb);

	// Posicionamos el offset
	
	Chan* file = f->files[i];

	if (offset >= f->size)
		return 0;
	if ((offset + n) > f->size)
		n = f->size - offset;
	if (n == 0)
		return 0;

	fs = &(f->info[i]);

	devtab[file->type]->stat(file,buffer,tamb);
	convM2D(buffer, tamb, fs, 0);

	for(; (newoff > fs->length) && (i < nfiles);){
		newoff -= fs->length;
		file = f->files[++i];
		devtab[file->type]->stat(file,buffer,tamb);
		convM2D(buffer, tamb, fs, 0);
	}

	// Vamos leyendo hasta terminar
	if(i < nfiles){
		toread = fs->length - newoff;
		leido += devtab[file->type]->read(file, a, toread, newoff);
		a = (char*)a + leido;
		for(j = i+1; (leido < n) && (j < nfiles); j++){
			file = f->files[j];
			fs = &(f->info[j]);
			devtab[file->type]->stat(file,buffer,tamb);
			convM2D(buffer, tamb, fs, 0);	

			if((leido + fs->length) < n)
				toread = fs->length;
			else
				toread = n-leido; 

			aux_leido = devtab[file->type]->read(file, a, toread, 0);
			
			a = (char*)a + aux_leido;
			leido += aux_leido;
		}
	}

	return leido;
}
开发者ID:LuisGP,项目名称:Plan9,代码行数:59,代码来源:devdso.C

示例2: setswapchan

void
setswapchan(Chan *c)
{
	uchar dirbuf[sizeof(Dir)+100];
	Dir d;
	int n;

	if(swapimage.c) {
		if(swapalloc.free != conf.nswap){
			cclose(c);
			error(Einuse);
		}
		cclose(swapimage.c);
	}

	/*
	 *  if this isn't a file, set the swap space
	 *  to be at most the size of the partition
	 */
	if(devtab[c->type]->dc != L'M'){
		n = devtab[c->type]->stat(c, dirbuf, sizeof dirbuf);
		if(n <= 0){
			cclose(c);
			error("stat failed in setswapchan");
		}
		convM2D(dirbuf, n, &d, nil);
		if(d.length < conf.nswap*BY2PG){
			conf.nswap = d.length/BY2PG;
			swapalloc.top = &swapalloc.swmap[conf.nswap];
			swapalloc.free = conf.nswap;
		}
	}

	swapimage.c = c;
}
开发者ID:Zabrane,项目名称:smalltable,代码行数:35,代码来源:swap.c

示例3: sdwstat

static int
sdwstat(Chan* c, uchar* dp, int n)
{
	Dir *d;
	SDpart *pp;
	SDperm *perm;
	SDunit *unit;
	SDev *sdev;

	if(c->qid.type & QTDIR)
		error(Eperm);

	sdev = sdgetdev(DEV(c->qid));
	if(sdev == nil)
		error(Enonexist);
	unit = sdev->unit[UNIT(c->qid)];
	qlock(&unit->ctl);
	d = nil;
	if(waserror()){
		free(d);
		qunlock(&unit->ctl);
		decref(&sdev->r);
		nexterror();
	}

	switch(TYPE(c->qid)){
	default:
		error(Eperm);
	case Qctl:
		perm = &unit->ctlperm;
		break;
	case Qraw:
		perm = &unit->rawperm;
		break;
	case Qpart:
		pp = &unit->part[PART(c->qid)];
		if(unit->vers+pp->vers != c->qid.vers)
			error(Enonexist);
		perm = &pp->SDperm;
		break;
	}

	if(strcmp(up->env->user, perm->user) && !iseve())
		error(Eperm);

	d = smalloc(sizeof(Dir)+n);
	n = convM2D(dp, n, &d[0], (char*)&d[1]);
	if(n == 0)
		error(Eshortstat);
	if(!emptystr(d[0].uid))
		kstrdup(&perm->user, d[0].uid);
	if(d[0].mode != ~0UL)
		perm->perm = (perm->perm & ~0777) | (d[0].mode & 0777);

	free(d);
	qunlock(&unit->ctl);
	decref(&sdev->r);
	poperror();
	return n;
}
开发者ID:Mekapaedia,项目名称:inferno-rpi,代码行数:60,代码来源:devsd.c

示例4: progwstat

static int
progwstat(Chan *c, uchar *db, int n)
{
	Dir d;
	Prog *p;
	char *u;
	Osenv *o;

	if(c->qid.type&QTDIR)
		error(Eperm);
	acquire();
	p = progpid(PID(c->qid));
	if(p == nil) {
		release();
		error(Ethread);
	}

	u = up->env->user;
	o = p->osenv;
	if(strcmp(u, o->user) != 0 && strcmp(u, eve) != 0) {
		release();
		error(Eperm);
	}

	n = convM2D(db, n, &d, nil);
	if(n == 0){
		release();
		error(Eshortstat);
	}
	if(d.mode != ~0UL)
		o->pgrp->progmode = d.mode&0777;
	release();
	return n;
}
开发者ID:8l,项目名称:inferno,代码行数:34,代码来源:devprog.c

示例5: dsopartwrite

static long
dsopartwrite(MyFiles *f, void *a, long n, vlong offset){
	Chan* file = f->files[0];
	int tamb = 1024;
	Dir* fs;
	int r;
	uchar* buffer = (uchar*)malloc(sizeof(uchar)*tamb);

	if (offset >= f->size)
		return 0;
	if ((offset + n) > f->size)
		n = f->size - offset;
	if (n == 0)
		return 0;

	r = devtab[file->type]->write(file, a, n, (offset + f->offset));

	fs = &(f->info[0]);

	devtab[file->type]->stat(file,buffer,tamb);
	convM2D(buffer, tamb, fs, 0);
	f->mdate[0] = fs->mtime;

	return r;
}
开发者ID:LuisGP,项目名称:Plan9,代码行数:25,代码来源:devdso.C

示例6: segmentwstat

static int
segmentwstat(Chan *c, uchar *dp, int n)
{
	Globalseg *g;
	Dir *d;

	if(c->qid.type == QTDIR)
		error(Eperm);

	g = getgseg(c);
	if(waserror()){
		putgseg(g);
		nexterror();
	}

	if(strcmp(g->uid, up->user) && !iseve())
		error(Eperm);
	d = smalloc(sizeof(Dir)+n);
	n = convM2D(dp, n, &d[0], (char*)&d[1]);
	g->perm = d->mode & 0777;

	putgseg(g);
	poperror();

	free(d);
	return n;
}
开发者ID:Akheon23,项目名称:nix-os,代码行数:27,代码来源:devsegment.c

示例7: ipwstat

static int
ipwstat(Chan *c, uchar *dp, int n)
{
	Dir d;
	Conv *cv;
	Fs *f;
	Proto *p;

	f = ipfs[c->dev];
	switch(TYPE(c->qid)) {
	default:
		error(Eperm);
		break;
	case Qctl:
	case Qdata:
		break;
	}

	n = convM2D(dp, n, &d, nil);
	if(n > 0){
		p = f->p[PROTO(c->qid)];
		cv = p->conv[CONV(c->qid)];
		if(!iseve() && strcmp(ATTACHER(c), cv->owner) != 0)
			error(Eperm);
		if(d.uid[0])
			kstrdup(&cv->owner, d.uid);
		cv->perm = d.mode & 0777;
	}
	return n;
}
开发者ID:99years,项目名称:plan9,代码行数:30,代码来源:devip.c

示例8: netifwstat

int32_t
netifwstat(Netif *nif, Chan *c, uint8_t *db, int32_t n)
{
	Proc *up = externup();
	Dir *dir;
	Netfile *f;
	int l;

	f = nif->f[NETID(c->qid.path)];
	if(f == 0)
		error(Enonexist);

	if(netown(f, up->user, OWRITE) < 0)
		error(Eperm);

	dir = smalloc(sizeof(Dir)+n);
	l = convM2D(db, n, &dir[0], (char*)&dir[1]);
	if(l == 0){
		free(dir);
		error(Eshortstat);
	}
	if(!emptystr(dir[0].uid))
		strncpy(f->owner, dir[0].uid, KNAMELEN);
	if(dir[0].mode != (uint32_t)~0UL)
		f->mode = dir[0].mode;
	free(dir);
	return l;
}
开发者ID:Requaos,项目名称:harvey,代码行数:28,代码来源:netif.c

示例9: pipewstat

static int pipewstat(struct chan *c, uint8_t *dp, int n)
{
	ERRSTACK(2);
	struct dir *d;
	Pipe *p;
	int d1;

	if (c->qid.type & QTDIR)
		error(EPERM, ERROR_FIXME);
	p = c->aux;
	if (strcmp(current->user, p->user) != 0)
		error(EPERM, ERROR_FIXME);
	d = kzmalloc(sizeof(*d) + n, 0);
	if (waserror()) {
		kfree(d);
		nexterror();
	}
	n = convM2D(dp, n, d, (char *)&d[1]);
	if (n == 0)
		error(ENODATA, ERROR_FIXME);
	d1 = NETTYPE(c->qid.path) == Qdata1;
	if (!emptystr(d->name)) {
		validwstatname(d->name);
		if (strlen(d->name) >= KNAMELEN)
			error(ENAMETOOLONG, ERROR_FIXME);
		if (strncmp(p->pipedir[1 + !d1].name, d->name, KNAMELEN) == 0)
			error(EEXIST, ERROR_FIXME);
		strncpy(p->pipedir[1 + d1].name, d->name, KNAMELEN);
	}
	if (d->mode != ~0UL)
		p->pipedir[d1 + 1].perm = d->mode & 0777;
	poperror();
	kfree(d);
	return n;
}
开发者ID:GanShun,项目名称:akaros,代码行数:35,代码来源:pipe.c

示例10: identify

/* must call with c qlocked */
static void
identify(Ctlr *c, SDunit *u)
{
	int n;
	uvlong s, osectors;
	uchar buf[sizeof(Dir) + 100];
	Dir dir;

	if(waserror()){
		iprint("sdloop: identify: %s\n", up->errstr);
		nexterror();
	}
	osectors = c->sectors;
	n = devtab[c->c->type]->stat(c->c, buf, sizeof buf);
	if(convM2D(buf, n, &dir, nil) == 0)
		error("internal error: stat error in seek");
	s = dir.length / c->sectsize;
	poperror();

	memset(u->inquiry, 0, sizeof u->inquiry);
	u->inquiry[2] = 2;
	u->inquiry[3] = 2;
	u->inquiry[4] = sizeof u->inquiry - 4;
	memmove(u->inquiry+8, c->path, 40);

	if(osectors == 0 || osectors != s){
		c->sectors = s;
		c->drivechange = 1;
		c->vers++;
	}
}
开发者ID:Nurb432,项目名称:plan9front,代码行数:32,代码来源:sdloop.c

示例11: sys_stat

long
sys_stat(uint32 *arg)
{
	Chan *c;
	uint l;
	uchar buf[128];	/* old DIRLEN plus a little should be plenty */
	char strs[128], *name, *elem;
	Dir d;
	char old[] = "old stat system call - recompile";
	uchar *p;

	p = uvalidaddr(arg[1], 116, 1);
	name = uvalidaddr(arg[0], 1, 0);
	c = namec(name, Aaccess, 0, 0);
	if(waserror()){
		cclose(c);
		nexterror();
	}
	l = devtab[c->type]->stat(c, buf, sizeof buf);
	/* buf contains a new stat buf; convert to old. yuck. */
	if(l <= BIT16SZ)	/* buffer too small; time to face reality */
		error(old);
	elem = pathlast(c->path);
	if(elem)
		l = dirsetname(elem, strlen(elem), buf, l, sizeof buf);
	l = convM2D(buf, l, &d, strs);
	if(l == 0)
		error(old);
	packoldstat(p, &d);
	
	poperror();
	cclose(c);
	return 0;
}
开发者ID:0intro,项目名称:vx32,代码行数:34,代码来源:sysfile.c

示例12: dirfstat

Dir*
dirfstat(int fd)
{
	Dir *d;
	uint8_t *buf;
	int n, nd, i;

	nd = DIRSIZE;
	for(i=0; i<2; i++){	/* should work by the second try */
		d = malloc(sizeof(Dir) + BIT16SZ + nd);
		if(d == nil)
			return nil;
		buf = (uint8_t*)&d[1];
		n = fstat(fd, buf, BIT16SZ+nd);
		if(n < BIT16SZ){
			free(d);
			return nil;
		}
		nd = GBIT16(buf);	/* upper bound on size of Dir + strings */
		if(nd <= n){
			convM2D(buf, n, d, (char*)&d[1]);
			return d;
		}
		/* else sizeof(Dir)+BIT16SZ+nd is plenty */
		free(d);
	}
	return nil;
}
开发者ID:aahud,项目名称:harvey,代码行数:28,代码来源:dirfstat.c

示例13: looponline

/*
 * Cannot error.
 * Check that unit is online.
 * If media changed, return 2.
 * If ready, return 1.
 * If not ready, return 0.
 */
static int
looponline(SDunit *unit)
{
	uchar buf[sizeof(Dir)+100];
	Chan *c;
	SDev *sdev;
	Ctlr *ctlr;
	Dir dir;
	long n;
	
	if(waserror())
		return 0;

	sdev = unit->dev;
	ctlr = sdev->ctlr;
	c = ctlr->c;
	n = devtab[c->type]->stat(c, buf, sizeof buf);
	if(convM2D(buf, n, &dir, nil) == 0)
		error("internal error: stat error in looponline");
	if(ctlr->qidpath != dir.qid.path){
		unit->sectors = dir.length/512;
		unit->secsize = 512;
		ctlr->qidpath = dir.qid.path;
		poperror();
		return 2;
	}
	poperror();
	return 1;
}
开发者ID:Zabrane,项目名称:smalltable,代码行数:36,代码来源:sdloop.c

示例14: sys_fstat

long
sys_fstat(ulong *arg)
{
	Chan *c;
	char *name;
	uint l;
	uchar buf[128];	/* old DIRLEN plus a little should be plenty */
	char strs[128];
	Dir d;
	char old[] = "old fstat system call - recompile";

	validaddr(arg[1], 116, 1);
	c = fdtochan(arg[0], -1, 0, 1);
	if(waserror()){
		cclose(c);
		nexterror();
	}
	l = devtab[c->type]->stat(c, buf, sizeof buf);
	/* buf contains a new stat buf; convert to old. yuck. */
	if(l <= BIT16SZ)	/* buffer too small; time to face reality */
		error(old);
	name = pathlast(c->path);
	if(name)
		l = dirsetname(name, strlen(name), buf, l, sizeof buf);
	l = convM2D(buf, l, &d, strs);
	if(l == 0)
		error(old);
	packoldstat((uchar*)arg[1], &d);
	
	poperror();
	cclose(c);
	return 0;
}
开发者ID:Akheon23,项目名称:nix-os,代码行数:33,代码来源:sysfile.c

示例15: stat_9p

__private_extern__ int
stat_9p(mount_9p *nmp, fid_9p fid, dir_9p **dpp)
{
	Fcall tx, rx;
	Dir *dp;
	void *p;
	int e, n;
	
	TRACE();
	p = NULL;
	dp = NULL;
	tx.type = Tstat;
	tx.fid = fid;
	if ((e=rpc_9p(nmp, &tx, &rx, &p)))
		return e;

	n = GBIT16((uint8_t*)p);
	dp = malloc_9p(sizeof(Dir) + BIT16SZ + n);
	if (dp == NULL) {
		e = ENOMEM;
		goto error;
	}

	if(convM2D(rx.stat, rx.nstat, dp, (char*)&dp[1], ISSET(nmp->flags, F_DOTU)) != rx.nstat) {
		DEBUG("convM2D");
		e = EBADRPC;
		goto error;
	}

error:
	free_9p(p);
	*dpp = dp;
	return e;
}
开发者ID:joushou,项目名称:mac9p,代码行数:34,代码来源:proto.c


注:本文中的convM2D函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。