Пример #1
0
/**
 * Checks if given fill colour is already set in PDF gstate and if not,
 * update the gstate accordingly.
 * \param page	PDF page where the update needs to happen.
 * \param col	Wanted fill colour.
 */
void pdfw_gs_fillcolour(HPDF_Page page, colour col)
{
	if (col == pdfw_gs[pdfw_gs_level].fillColour)
		return;
	pdfw_gs[pdfw_gs_level].fillColour = col;
	if (RBYTE(col) == GBYTE(col) && GBYTE(col) == BBYTE(col))
		HPDF_Page_SetGrayFill(pdf_page, R(col));
	else
		HPDF_Page_SetRGBFill(pdf_page, R(col), G(col), B(col));
}
Пример #2
0
/**
 * Checks if given stroke colour is already set in PDF gstate and if not,
 * update the gstate accordingly.
 * \param page	PDF page where the update needs to happen.
 * \param col	Wanted stroke colour.
 */
void pdfw_gs_strokecolour(HPDF_Page page, colour col)
{
	if (col == pdfw_gs[pdfw_gs_level].strokeColour)
		return;
	pdfw_gs[pdfw_gs_level].strokeColour = col;
	if (RBYTE(col) == GBYTE(col) && GBYTE(col) == BBYTE(col))
		HPDF_Page_SetGrayStroke(pdf_page, R(col));
	else
		HPDF_Page_SetRGBStroke(pdf_page, R(col), G(col), B(col));
}
Пример #3
0
Xfid *
rpc2xfid(Rpccall *cmd, Dir *dp)
{
	char *argptr = cmd->args;
	Xfile *xp;
	Xfid *xf;
	Session *s;
	char *service;
	Authunix au;
	Qid qid;
	char client[256], *user;
	Unixidmap *m;
	int i;
	uvlong x1, x2;

	chat("rpc2xfid %.8lux %.8lux %p %p\n", *((ulong*)argptr), *((ulong*)argptr+1), buf, argptr);
	if(argptr[0] == 0 && argptr[1] == 0){	/* root */
		chat("root...");
		xp = xfroot(&argptr[2], 0);
		s = xp ? xp->s : 0;
	}else{
		ulong ul;
		chat("noroot %.8lux...", *((ulong*)argptr));
		if((ul=GLONG()) != starttime){
			chat("bad tag %lux %lux...", ul, starttime);
			return 0;
		}
		s = (Session *)GLONG();
		x1 = GLONG();
		x2 = GLONG();
		qid.path = x1 | (x2<<32);
		qid.vers = 0;
		qid.type = GBYTE();
		xp = xfile(&qid, s, 0);
	}
	if(xp == 0){
		chat("no xfile...");
		return 0;
	}
	if(auth2unix(&cmd->cred, &au) != 0){
		chat("auth flavor=%ld, count=%ld\n",
			cmd->cred.flavor, cmd->cred.count);
		for(i=0; i<cmd->cred.count; i++)
			chat(" %.2ux", ((uchar *)cmd->cred.data)[i]);
		chat("...");
		return 0;
	}else{
/*		chat("auth: %d %.*s u=%d g=%d",
 *			au.stamp, utfnlen(au.mach.s, au.mach.n), au.mach.s, au.uid, au.gid);
 *		for(i=0; i<au.gidlen; i++)
 *			chat(", %d", au.gids[i]);
 *		chat("...");
 */
		char *p = memchr(au.mach.s, '.', au.mach.n);
		chat("%ld@%.*s...", au.uid, utfnlen(au.mach.s, (p ? p-au.mach.s : au.mach.n)), au.mach.s);
	}
	if(au.mach.n >= sizeof client){
		chat("client name too long...");
		return 0;
	}
	memcpy(client, au.mach.s, au.mach.n);
	client[au.mach.n] = 0;
	service = xp->parent->s->service;
	cmd->up = m = pair2idmap(service, cmd->host);
	if(m == 0){
		chat("no map for pair (%s,%s)...", service, client);
		/*chat("getdom %d.%d.%d.%d", cmd->host&0xFF, (cmd->host>>8)&0xFF,
			(cmd->host>>16)&0xFF, (cmd->host>>24)&0xFF);/**/
		/*if(getdom(cmd->host, client, sizeof(client))<0)
			return 0;/**/
		return 0;
	}
	/*chat("map=(%s,%s)...", m->server, m->client);/**/
	cmd->user = user = id2name(&m->u.ids, au.uid);
	if(user == 0){
		chat("no user for id %ld...", au.uid);
		return 0;
	}
	chat("user=%s...", user);/**/
	xf = 0;
	if(s == xp->parent->s){
		if(!s->noauth)
			xf = setuser(xp, user);
		if(xf == 0)
			xf = setuser(xp, "none");
		if(xf == 0)
			chat("can't set user none...");
	}else
		xf = xp->users;
	if(xf)
		chat("uid=%s...", xf->uid);
	if(xf && dp && xfstat(xf, dp) < 0){
		chat("can't stat %s...", xp->name);
		return 0;
	}
	return xf;
}