Exemple #1
0
BTSV_API void btRegisterSpawnAlias(char *srcname, char *dstname)
{
	int i;

	if(!btge_spawn_alias_src)
	{
		btge_spawn_alias_src=gcalloc(64*sizeof(char *));
		btge_spawn_alias_dst=gcalloc(64*sizeof(char *));
		btge_spawn_m_alias=64;
	}
	
	for(i=0; i<btge_spawn_n_alias; i++)
		if(!strcmp(btge_spawn_alias_src[i], srcname))
	{
		btge_spawn_alias_dst[i]=dystrdup(dstname);
		return;
	}
	
	if((btge_spawn_n_alias+1)>=btge_spawn_m_alias)
	{
		i=btge_spawn_m_alias+(btge_spawn_m_alias>>1);
		btge_spawn_alias_src=gcrealloc(
			btge_spawn_alias_src, i*sizeof(char *));
		btge_spawn_alias_dst=gcrealloc(
			btge_spawn_alias_dst, i*sizeof(char *));
		btge_spawn_m_alias=i;
	}
Exemple #2
0
/*--
Cat pdnet;NET;Sock
Form
	VADDR *NET_Str2Addr(char *str, int proto);
Description
	Parses the address from a string.
	proto identifies the expected protocol.
--*/
VADDR *NET_Str2Addr(char *str, int proto)
{
	VADDR *tmp;
	char *s;

	switch(proto)
	{
	case PROTO_IPV4UDP:
	case PROTO_IPV4TCP:
		tmp=gcalloc(sizeof(VADDR));
		tmp->proto=proto;

//		tmp->ipv4.addr=htonl(str2ipv4(str, &tmp->ipv4.port));
		tmp->ipv4.port=htons(tmp->ipv4.port);
		break;
	case PROTO_IPV6UDP:
	case PROTO_IPV6TCP:
		tmp=gcalloc(sizeof(VADDR));
		tmp->proto=proto;

		s=str2ipv6(tmp->ipv6.addr, str);
		sscanf(s, ":%d", &tmp->ipv6.port);
		tmp->ipv6.port=htons(tmp->ipv6.port);
		break;
	default:
		tmp=NULL;
		break;
	}
	return(tmp);
}
int BTLZA_BitEnc_EncodeBlock(BGBBTJ_BTLZA_Context *ctx,
	byte *ibuf, int isz, int last)
{
	int i;

	i=isz;
	if(!ctx->lz_tbuf || (isz>ctx->lz_tsz))
	{
		if(ctx->lz_tbuf)gcfree(ctx->lz_tbuf);
		if(ctx->lz_mbuf)gcfree(ctx->lz_mbuf);
		ctx->lz_tsz=i; ctx->lz_msz=(i+7)/8;
		ctx->lz_tbuf=gcalloc(ctx->lz_tsz);
		ctx->lz_mbuf=gcalloc(ctx->lz_msz);
	}

	if(ctx->lz_maxdist>65536)
	{
		ctx->lbase=btlza_lbase3; ctx->lextra=btlza_lextra3;
		return(BTLZA_BitEnc_EncodeBlockBTLZH(ctx, ibuf, isz, last));
	}else
	{
		if(ctx->lz_maxdist>32768)
			{ ctx->lbase=btlza_lbase2; ctx->lextra=btlza_lextra2; }
		else
			{ ctx->lbase=btlza_lbase1; ctx->lextra=btlza_lextra1; }
		return(BTLZA_BitEnc_EncodeBlockDynamic(ctx, ibuf, isz, last));
	}
}
LBXGL_NoiseContext *LBXGL_Noise_CreateContext(
	int ord, int sz, s64 seed)
{
	LBXGL_NoiseContext *tmp;
	float f, g;
	int i, j, k, l;
	
	//create context
	tmp=gctalloc("lbxgl_noisectx_t", sizeof(LBXGL_NoiseContext));
	tmp->ord=ord;
	tmp->sz=sz;
	tmp->seed=seed;

	//eat initial values
	for(i=0; i<sz; i++)
		LBXGL_Noise_Random(tmp);

	//create arrays and fill them with random values
	for(i=0; i<ord; i++)
	{
		tmp->arr[i]=gcalloc(sz*sizeof(float));
		tmp->parr[i]=gcalloc(sz*sizeof(int));
		for(j=0; j<sz; j++)
		{
			tmp->arr[i][j]=LBXGL_Noise_SRandom(tmp);
			tmp->parr[i][j]=j;
		}
	}

	//normalize values if applicable
	if(ord>1)
	{
		for(i=0; i<sz; i++)
		{
			g=0;
			for(j=0; j<ord; j++)
				{ f=tmp->arr[j][i]; g+=f*f; }
			f=sqrt(g);
			for(j=0; j<ord; j++)
				{ tmp->arr[j][i]/=f; }
		}
	}

	//randomize permutation arrays
	for(i=0; i<ord; i++)
	{
		for(j=0; j<sz; j++)
		{
			k=LBXGL_Noise_Random(tmp)*sz;
			k=(k<0)?0:((k>sz)?sz:k);	//clamp range
		
			//swap elements
			l=tmp->parr[i][j];
			tmp->parr[i][j]=tmp->parr[i][k];
			tmp->parr[i][k]=l;
		}
	}
	
	return(tmp);
}
Exemple #5
0
NET_Struct *Verify_NewNetStruct(int max)
{
	NET_Struct *tmp;

	tmp=gcalloc(sizeof(NET_Struct));
	tmp->types=gcalloc(max*sizeof(char *));
	tmp->names=gcalloc(max*sizeof(char *));
	tmp->values=gcalloc(max*sizeof(long));

	return(tmp);
}
Exemple #6
0
/* importvar -- import a single environment variable */
static void importvar(char *name0, char *value) {
	char sep[2] = { ENV_SEPARATOR, '\0' };

	Ref(char *, name, name0);
	Ref(List *, defn, NULL);
	defn = fsplit(sep, mklist(mkstr(value + 1), NULL), FALSE);

	if (strchr(value, ENV_ESCAPE) != NULL) {
		List *list;
		gcdisable();
		for (list = defn; list != NULL; list = list->next) {
			int offset = 0;
			const char *word = list->term->str;
			const char *escape;
			while ((escape = strchr(word + offset, ENV_ESCAPE))
			       != NULL) {
				offset = escape - word + 1;
				switch (escape[1]) {
				    case '\0':
					if (list->next != NULL) {
						const char *str2
						  = list->next->term->str;
						char *str
						  = gcalloc(offset
							    + strlen(str2) + 1,
							    &StringTag);
						memcpy(str, word, offset - 1);
						str[offset - 1]
						  = ENV_SEPARATOR;
						strcpy(str + offset, str2);
						list->term->str = str;
						list->next = list->next->next;
					}
					break;
				    case ENV_ESCAPE: {
					char *str
					  = gcalloc(strlen(word), &StringTag);
					memcpy(str, word, offset);
					strcpy(str + offset, escape + 2);
					list->term->str = str;
					offset += 1;
					break;
				    }
				}
			}
		}
		gcenable();
	}
	vardef(name, NULL, defn);
	RefEnd2(defn, name);
}
Exemple #7
0
mstring wstrtocstr(wstring str) {
  size_t sz = wcstombs(NULL, str, 0);
  if (!~sz) {
    sz = wcslen(str);
    mstring ret = gcalloc(sz+1);
    for (unsigned i = 0; i < sz; ++i)
      ret[i] = str[i];
    return ret;
  } else {
    mstring ret = gcalloc(sz+1);
    wcstombs(ret, str, sz);
    return ret;
  }
}
Exemple #8
0
mwstring cstrtowstr(string str) {
  size_t sz = mbstowcs(NULL, str, 0);
  if (!~sz) {
    // Invalid byte string, fall back to ISO-8859-1
    sz = strlen(str);
    mwstring ret = gcalloc((sz+1)*sizeof(wchar_t));
    for (unsigned i = 0; i < sz; ++i)
      ret[i] = ((wchar_t)str[i]) & (wchar_t)0xFF;
    return ret;
  } else {
    mwstring ret = gcalloc((sz+1)*sizeof(wchar_t));
    mbstowcs(ret, str, sz);
    return ret;
  }
}
Exemple #9
0
BSP_Face *BSP_ReadLeafFace(VFILE *fd)
{
	float pt[3], dv[3], dn[4];
	BSP_Face *tmp;
	int i, j;

	tmp=gcalloc(sizeof(BSP_Face));
	memset(tmp, 0, sizeof(BSP_Face));

//	BSP_ReadFourcc(fd);
	BSP_ReadInt32(fd);

	BSP_ReadNormal(fd, tmp->norm);
	tmp->nvecs=BSP_ReadInt16(fd);
	tmp->flags=BSP_ReadInt16(fd);

	tmp->vecs=gcatomic(tmp->nvecs*3*sizeof(float));
	for(i=0; i<tmp->nvecs; i++)
		BSP_ReadVector(fd, tmp->vecs+i*3);

	tmp->evecs=gcatomic(4*tmp->nvecs*sizeof(float));
	for(i=0; i<tmp->nvecs; i++)
	{
		j=(i+1)%tmp->nvecs;
		V3F_SUB(tmp->vecs+j*3, tmp->vecs+i*3, dv);
		V3F_CROSS(tmp->norm, dv, dn);
		V3F_NORMALIZE(dn, dn);
		dn[3]=V3F_DOT(tmp->vecs+i*3, dn);
		V4F_COPY(dn, tmp->evecs+i*4);
	}

	return(tmp);
}
Exemple #10
0
BSP_Face *BSP_ReadTraceSurf(VFILE *fd, BSP_Node *node)
{
	float pt[3], dv[3], dn[4];
	BSP_Face *tmp;
	int i, j;

	tmp=gcalloc(sizeof(BSP_Face));
	memset(tmp, 0, sizeof(BSP_Face));

	BSP_ReadInt32(fd);

	tmp->nvecs=BSP_ReadInt16(fd);
	tmp->flags=BSP_ReadInt16(fd);

	V4F_COPY(node->norm, tmp->norm);
	if(tmp->flags&BSPFACE_FL_BACKSIDE)
		{ V4F_SCALE(node->norm, -1, tmp->norm); }

	tmp->vecs=gcatomic(tmp->nvecs*3*sizeof(float));
	for(i=0; i<tmp->nvecs; i++)
		BSP_ReadVector(fd, tmp->vecs+i*3);

	tmp->evecs=gcatomic(4*tmp->nvecs*sizeof(float));
	for(i=0; i<tmp->nvecs; i++)
	{
		j=(i+1)%tmp->nvecs;
		V3F_SUB(tmp->vecs+j*3, tmp->vecs+i*3, dv);
		V3F_CROSS(tmp->norm, dv, dn);
		V3F_NORMALIZE(dn, dn);
		dn[3]=V3F_DOT(tmp->vecs+i*3, dn);
		V4F_COPY(dn, tmp->evecs+i*4);
	}

	return(tmp);
}
Exemple #11
0
static void JScriptMatrixInit(struct matrixinit *mi,Justify *js) {
    struct matrix_data *md;
    int k, cnt;
    Justify *jscript;

    memset(mi,0,sizeof(*mi));
    mi->col_cnt = 4;
    mi->col_init = justify_ci;

    md = NULL;
    for ( k=0; k<2; ++k ) {
	cnt = 0;
	for ( jscript=js; jscript!=NULL; jscript = jscript->next ) {
	    if ( k ) {
		md[4*cnt+0].u.md_str = copy(Tag2Str(jscript->script));
		md[4*cnt+1].u.md_str  = copy(jscript->extenders);
		/* Nothing in 4*cnt+2 */
		md[4*cnt+3].u.md_addr = JstfLangsCopy(jscript->langs);
	    }
	    ++cnt;
	}
	if ( md==NULL )
	    md = gcalloc(4*(cnt+10),sizeof(struct matrix_data));
    }
    mi->matrix_data = md;
    mi->initial_row_cnt = cnt;
}
Exemple #12
0
void LBXGL_Voxel_RecalcStaticLight(
	LBXGL_BrushWorld *world, LBXGL_VoxelChunk *chk)
{
	int i, j, k, n;

	if(!chk->mesh)
		return;

	n=chk->mesh->n_face*3;
	if(n<=0)return;
	
	if(!chk->mesh->face_tlrgba)
	{
//		chk->mesh->face_tlrgba=gcalloc(n*4);
		k=chk->mesh->m_face*3;
		chk->mesh->face_tlrgba=gcalloc(k*4);
	}

	for(i=0; i<n; i++)
		for(j=0; j<4; j++)
	{
		k=
			chk->mesh->face_slrgba[i*4+j]+
			chk->mesh->face_vlrgba[i*4+j];
		if(k>255)k=255;
		chk->mesh->face_tlrgba[i*4+j]=k;
	}
}
Exemple #13
0
static void LookupMatrixInit(struct matrixinit *mi,char *lookupstr,
	SplineFont *sf, int col) {
    struct matrix_data *md;
    int j, k, cnt;
    char *temp;
    char *start, *end;

    memset(mi,0,sizeof(*mi));
    mi->col_cnt = 1;
    mi->col_init = lookup_ci;

    lookup_ci[0].enum_vals = SFLookupArrayFromMask(sf,col==3 || col==6 ? (gpos_single_mask|gpos_pair_mask) : 0 );

    md = NULL;
    for ( k=0; k<2; ++k ) {
	cnt = 0;
	if ( lookupstr!=NULL ) for ( start = lookupstr; *start; ) {
	    for ( end=start; *end!='\0' && *end!=','; ++end );
	    if ( k ) {
		for ( j=0; (temp=(char *) (lookup_ci[0].enum_vals[j].text))!=NULL; ++j )
		    if ( strlen(temp)==end-start && strncmp(temp,start,end-start)==0 ) {
			md[1*cnt++ + 0].u.md_ival = (intpt) lookup_ci[0].enum_vals[j].userdata;
		break;
		    }
	    } else
		++cnt;
	    while ( *end==' ' || *end==',') ++end;
	    start = end;
	}
	if ( md==NULL )
	    md = gcalloc(1*(cnt+10),sizeof(struct matrix_data));
    }
    mi->matrix_data = md;
    mi->initial_row_cnt = cnt;
}
Exemple #14
0
static void GlyphMatrixInit(struct matrixinit *mi,char *glyphstr,SplineFont *sf) {
    struct matrix_data *md;
    int k, cnt;
    char *start, *end;

    memset(mi,0,sizeof(*mi));
    mi->col_cnt = 1;
    mi->col_init = glyph_ci;

    md = NULL;
    for ( k=0; k<2; ++k ) {
	cnt = 0;
	if ( glyphstr!=NULL ) for ( start = glyphstr; *start; ) {
	    for ( end=start; *end!='\0' && *end!=' ' && *end!=','; ++end );
	    if ( k ) {
		char *str = copyn(start,end-start);
		md[1*cnt+0].u.md_str = SFNameList2NameUni(sf,str);
		free(str);
	    }
	    ++cnt;
	    while ( *end==' ' || *end==',' ) ++end;
	    start = end;
	}
	if ( md==NULL )
	    md = gcalloc(1*(cnt+10),sizeof(struct matrix_data));
    }
    mi->matrix_data = md;
    mi->initial_row_cnt = cnt;
}
Exemple #15
0
BGBDY_API void *dycApplyStaticV(dycClass inf, dyt mth,
	char *sig, va_list args)
{
	BGBGC_StubMethod *sinf;
	void *pv;
	dyt *abuf;
	dyt p;
	char *s, *ty;
	int i, j;

	ty=dygettype(mth);

	if(!strcmp(ty, "_raw_func_t"))
	{
		pv=dyllApplyRawFuncV((BGBGC_RawFunc *)mth, (dyt)inf, sig, args);
		return(pv);
	}

	if(!strcmp(ty, "_stubmethod_t"))
	{
		sinf=(BGBGC_StubMethod *)mth;
		abuf=gcalloc(32*sizeof(dyt));
		i=dyllUnpackArgsSigUArgs(sig, args, (void **)abuf);
		pv=sinf->fcn(sinf, (dyt)inf, sig, (void **)abuf, i);
		gcfree(abuf);
		return(pv);
	}

	return(dyApplyMethodV((dyt)inf, mth, sig, args));
}
Exemple #16
0
BGBDY_API dycArrayN dycNewArrayN(char *sig, int ord, int *sz)
{
	dycArrayN tmp;
	void *p, *q;
	int i, cnt, asz, osz;

	cnt=1;
	for(i=0; i<ord; i++)cnt*=sz[i];


	asz=dyllSigAlignSize(sig);

	osz=ord*sizeof(int);
	if(osz%asz)osz+=asz-(osz%asz);

	p=gcalloc(osz+cnt*asz);
	q=(void *)(((byte *)p)+osz);

	tmp=gctalloc("_sqrarray_t", sizeof(dycArray));
	tmp->data=q;
	tmp->sig=dystrsym(sig);
	tmp->cnt=cnt;
	tmp->step=asz;

	tmp->ord=ord;
	tmp->psz=p;
	for(i=0; i<ord; i++)tmp->psz[i]=sz[i];

	return(tmp);
}
Exemple #17
0
PDGLUI_API char *PDGLUI_BeginForm(char *type, char *id)
{
	if(id)
	{
		pdglui_form=PDGLUI_Forms_Lookup(id);
		if(pdglui_form)return(NULL);

	}else
	{
		id=gcrsprint("form_%d", pdglui_formrover++);
	}

	if(!type)type="window";

	pdglui_form=gcalloc(sizeof(PDGLUI_Form));
	pdglui_form->name=dystrdup(id);
	pdglui_form->style=dystrdup(type);

	pdglui_form->fgcolor=pdglui_fgcolor;
	pdglui_form->bgcolor=pdglui_bgcolor;
	pdglui_form->wbgcolor=pdglui_wbgcolor;

	pdglui_form->next=pdglui_forms_root;
	pdglui_forms_root=pdglui_form;

	pdglui_stackpos=0;

	return(pdglui_form->name);
}
Exemple #18
0
BTGE_API BTGE_Brush *BTGE_Brush_CloneBrush(BTGE_Brush *brush)
{
	BTGE_Brush *tmp;
	int n;

	BTGE_Brush_Init();

	if(brush->mesh)
	{
		tmp=gctalloc("lbxgl_brush_t", sizeof(BTGE_Brush));
		tmp->mesh=BTGE_Mesh_ClonePrim(brush->mesh);
		return(tmp);
	}

	tmp=gctalloc("lbxgl_brush_t", sizeof(BTGE_Brush));
	tmp->n_face=brush->n_face;
	tmp->m_face=brush->m_face;
	tmp->flags=brush->flags;

	n=brush->m_face;
	tmp->norm=gcatomic(n*4*sizeof(float));
	tmp->sdir=gcatomic(n*4*sizeof(float));
	tmp->tdir=gcatomic(n*4*sizeof(float));
	tmp->norg=gcatomic(n*3*sizeof(float));
	tmp->tex=gcalloc(n*1*sizeof(char *));

	memcpy(tmp->norm, brush->norm, n*4*sizeof(float));
	memcpy(tmp->sdir, brush->sdir, n*4*sizeof(float));
	memcpy(tmp->tdir, brush->tdir, n*4*sizeof(float));
	memcpy(tmp->norg, brush->norg, n*3*sizeof(float));
	memcpy(tmp->tex, brush->tex, n*1*sizeof(float));

	return(tmp);
}
Exemple #19
0
void DelayEvent(void (*func)(void *), void *data) {
    struct delayed_event *info = gcalloc(1,sizeof(struct delayed_event));

    info->data = data;
    info->func = func;
    GDrawRequestTimer(splashw,100,0,info);
}
Exemple #20
0
FRIR_ObjectContext *FRASM_AllocObject()
{
	FRIR_ObjectContext *tmp;
	
	tmp=gcalloc("frasm_objectcontext_s", sizeof(FRIR_ObjectContext));
	return(tmp);
}
GTextInfo *GetEncodingTypes(void) {
    GTextInfo *ti;
    int i, cnt;
    Encoding *item;

    EncodingInit();

    cnt = 0;
    for ( item=enclist; item!=NULL ; item=item->next )
        if ( !item->hidden )
            ++cnt;
    i = cnt + sizeof(encodingtypes)/sizeof(encodingtypes[0]);
    ti = gcalloc(i+1,sizeof(GTextInfo));
    memcpy(ti,encodingtypes,sizeof(encodingtypes)-sizeof(encodingtypes[0]));
    for ( i=0; i<sizeof(encodingtypes)/sizeof(encodingtypes[0])-1; ++i ) {
        ti[i].text = (unichar_t *) copy((char *) ti[i].text);
    }
    if ( cnt!=0 ) {
        ti[i++].line = true;
        for ( item=enclist; item!=NULL ; item=item->next )
            if ( !item->hidden ) {
                ti[i].text = uc_copy(item->enc_name);
                ti[i++].userdata = (void *) item->enc_name;
            }
    }
    return( ti );
}
Exemple #22
0
/* queueheredoc -- add a heredoc to the queue to process at the end of the line */
extern Boolean queueheredoc(Tree *t) {
	Tree *eof;
	Here *here;

	assert(hereq == NULL || hereq->marker->kind == nList);
	assert(t->kind == nList);
	assert(t->CAR->kind == nWord);
#if !REISER_CPP
	assert(streq(t->CAR->u[0].s, "%heredoc"));
#endif
	t->CAR->u[0].s = "%here";
	assert(t->CDR->kind == nList);
	eof = t->CDR->CDR;
	assert(eof->kind == nList);
	if (eof->CAR->kind != nWord && eof->CAR->kind != nQword) {
		yyerror("here document eof-marker not a single literal word");
		return FALSE;
	}

	here = gcalloc(sizeof (Here), NULL);
	here->next = hereq;
	here->marker = eof;
	hereq = here;
	return TRUE;
}
Exemple #23
0
struct font_name *_GDraw_HashFontFamily(FState *fonts,unichar_t *name, int prop) {
    struct font_name *fn;
    int ch;
    int b,i;

    ch = *name;
    if ( isupper(ch)) ch = tolower(ch);
    if ( ch<'a' ) ch = 'q'; else if ( ch>'z' ) ch='z';
    ch -= 'a';

    fn = fonts->font_names[ch];
    while ( fn!=NULL ) {
	if ( u_strmatch(name,fn->family_name)==0 )
    break;
	fn = fn->next;
    }
    if ( fn==NULL ) {
	fn = gcalloc(1,sizeof(struct font_name));
	fn->family_name = u_copy(name);
	fn->ft = _GDraw_ClassifyFontName(fn->family_name,&b,&i);
	if ( !prop && fn->ft==ft_unknown )
	    fn->ft = ft_mono;
	fn->next = fonts->font_names[ch];
	fonts->font_names[ch] = fn;
    }
return( fn );
}
Exemple #24
0
/*--
Cat pdnet;NET;Sock;UDP
Form
	VFILE *UDP_OpenSocket(int port);
Description
	Creates a new socket.
	Returns a VFILE representing the socket.
--*/
BGBNET_API VFILE *UDP_OpenSocket(int port)
{
	VFILE *tmp;
	int *hnd, sock;
	int t=1;

	sock=__UDP_OpenSocket(port);
	if(sock==-1)
	{
		printf("socket creation error.\n");
		return(NULL);
	}

	ioctlsocket(sock, FIONBIO, &t);

	tmp=vfnew();
	tmp->buffer=gcalloc(sizeof(int));
	hnd=tmp->buffer;
	*hnd=sock;

	tmp->get_proc=&udpsock_get;
	tmp->send_proc=&udpsock_send;
//	tmp->getaddr=&udpsock_getaddr;

	return(tmp);
}
Exemple #25
0
static void JLanguageMatrixInit(struct matrixinit *mi, struct jstf_lang *jl) {
    struct matrix_data *md;
    int i, cnt;
    struct jstf_lang *jlang;

    memset(mi,0,sizeof(*mi));
    mi->col_cnt = 7;
    mi->col_init = jstf_lang_ci;

    md = NULL;
    cnt = 0;
    for ( jlang = jl; jlang!=NULL; jlang=jlang->next )
	cnt += jlang->cnt;
    md = gcalloc(mi->col_cnt*(cnt+10),sizeof(struct matrix_data));
    cnt = 0;
    for ( jlang = jl; jlang!=NULL; jlang=jlang->next ) {
	for ( i=0; i<jlang->cnt; ++i ) {
	    md[7*cnt+0].u.md_str = copy(Tag2Str(jl->lang));
	    md[7*cnt+1].u.md_str  = OTList2Str(jl->prios[i].enableExtend);
	    md[7*cnt+2].u.md_str  = OTList2Str(jl->prios[i].disableExtend);
	    md[7*cnt+3].u.md_str  = OTList2Str(jl->prios[i].maxExtend);
	    md[7*cnt+4].u.md_str  = OTList2Str(jl->prios[i].enableShrink);
	    md[7*cnt+5].u.md_str  = OTList2Str(jl->prios[i].disableShrink);
	    md[7*cnt+6].u.md_str  = OTList2Str(jl->prios[i].maxShrink);
	    ++cnt;
	}
    }
    mi->matrix_data = md;
    mi->initial_row_cnt = cnt;
}
Exemple #26
0
static void find_fonts_callback(GtkFileChooser *dialog) {
    GSList *files = gtk_file_chooser_get_filenames(dialog);
    GSList *test;
    int len, cnt, i;
    char ***fonts, *pt, *text;

    if ( files==NULL || (cnt = g_slist_length(files))==0 )
	gtk_widget_set_tooltip_text(GTK_WIDGET(dialog),"");
    else {
	fonts = gcalloc(cnt,sizeof(char **));
	cnt = len = 0;
	for ( test=files; test!=NULL; test=test->next, ++cnt) {
	    fonts[cnt] = GetFontNames((char *) (test->data));
	    if ( fonts[cnt]!=NULL ) {
		len += 4*strlen((char *) (test->data))+1;	/* allow space for utf8 conversion */
		for ( i=0; fonts[cnt][i]!=NULL; ++i )
		    len += strlen( fonts[cnt][i])+2;
	    }
	}
	pt = text = galloc(len+10);
	cnt = 0;
	for ( test=files; test!=NULL; test=test->next, ++cnt) {
	    if ( fonts[cnt]!=NULL ) {
		/* If there is only one file selected, don't bother to name it */
		if ( cnt!=0 || test->next!=NULL ) {
		    gsize junk;
		    char *temp = g_filename_to_utf8(GFileNameTail( (char *) (test->data) ),
			    -1, &junk, &junk, NULL);
		    strcpy(pt,temp);
		    g_free(temp);
		    pt += strlen(pt);
		    *pt++ = '\n';
		}
		for ( i=0; fonts[cnt][i]!=NULL; ++i ) {
		    *pt++ = ' ';
		    strcpy(pt,fonts[cnt][i]);
		    free(fonts[cnt][i]);
		    pt += strlen(pt);
		    *pt ++ = '\n';
		}
		free(fonts[cnt]);
	    }
	}
	if ( pt>text && pt[-1]=='\n' )
	    pt[-1]='\0';
	else
	    *pt = '\0';
	free(fonts);
	if ( *text=='\0' )
	    gtk_widget_set_tooltip_text(GTK_WIDGET(dialog), "???");
	else {
	    gtk_widget_set_tooltip_text(GTK_WIDGET(dialog), text);
	}
	free(text);
    }

    for ( test=files; test!=NULL; test=test->next)
	g_free(test->data);
    g_slist_free(files);
}
Exemple #27
0
static void BdfP_PopupMenuProps(struct bdf_dlg *bd, GEvent *e) {
    GMenuItem *mi;
    int i;

    for ( i=0 ; StandardProps[i].name!=NULL; ++i );
    mi = gcalloc(i+3,sizeof(GMenuItem));
    mi[0].ti.text = (unichar_t *) _("No Change");
    mi[0].ti.text_is_1byte = true;
    mi[0].ti.fg = COLOR_DEFAULT;
    mi[0].ti.bg = COLOR_DEFAULT;

    mi[1].ti.line = true;
    mi[1].ti.fg = COLOR_DEFAULT;
    mi[1].ti.bg = COLOR_DEFAULT;
    
    for ( i=0 ; StandardProps[i].name!=NULL; ++i ) {
	mi[i+2].ti.text = (unichar_t *) StandardProps[i].name;	/* These do not translate!!! */
	mi[i+2].ti.text_is_1byte = true;
	mi[i+2].ti.fg = COLOR_DEFAULT;
	mi[i+2].ti.bg = COLOR_DEFAULT;
	mi[i+2].invoke = BdfP_Invoked;
    }

    GMenuCreatePopupMenu(bd->v,e,mi);
    free(mi);
}
Exemple #28
0
static void AddMajorEdge(EdgeList *es, Spline *sp) {
    Edge *e, *pr;
    real m1;
    Spline1D *msp = &sp->splines[es->major], *osp = &sp->splines[es->other];

    e = gcalloc(1,sizeof(Edge));
    e->spline = sp;

    e->mmin = e->mmax = m1 = msp->d * es->scale - es->mmin;
    e->t_mmin = 0;
    e->t_mmax = 1;
    e->up = false;
    e->o_mmin = osp->d * es->scale;
    e->o_mmax = ( osp->a + osp->b + osp->c + osp->d ) * es->scale;
    if ( e->o_mmin == e->o_mmax ) {	/* Just a point? */
	free(e);
return;
    }
    if ( e->mmin<0 )
	IError("Grg!");

    if ( ceil(e->m_cur)>e->mmax ) {
	free(e);
return;
    }

    if ( es->majors==NULL || es->majors->mmin>=m1 ) {
	e->esnext = es->majors;
	es->majors = e;
    } else {
	for ( pr=es->majors; pr->esnext!=NULL && pr->esnext->mmin<m1; pr = pr->esnext );
	e->esnext = pr->esnext;
	pr->esnext = e;
    }
}
Exemple #29
0
struct MATH *MathTableNew(SplineFont *sf) {
    struct MATH *math = gcalloc(1,sizeof(struct MATH));	/* Too big for chunkalloc */
    int emsize = sf->ascent+sf->descent;
    DBounds b;
    SplineChar *sc;

    math->ScriptPercentScaleDown	= 80;
    math->ScriptScriptPercentScaleDown	= 60;
    math->DelimitedSubFormulaMinHeight	= emsize*1.5;
    /* No default given for math->DisplayOperatorMinHeight */
    /* No default given for math->AxisHeight */
    sc = SFGetChar(sf,'x',NULL);
    if ( sc!=NULL ) {
	SplineCharFindBounds(sc,&b);
	math->AccentBaseHeight = b.maxy;
    }
    sc = SFGetChar(sf,'I',NULL);
    if ( sc!=NULL ) {
	SplineCharFindBounds(sc,&b);
	math->FlattenedAccentBaseHeight = b.maxy;
    }
    if ( sf->pfminfo.subsuper_set )
	math->SubscriptShiftDown = sf->pfminfo.os2_subyoff;
    math->SubscriptTopMax = math->AccentBaseHeight;		/* X-height */
    /* No default given for math->SubscriptBaselineDropMin */
    if ( sf->pfminfo.subsuper_set )
	math->SuperscriptShiftUp = sf->pfminfo.os2_supyoff;
    /* No default given for math->SuperscriptShiftUpCramped */
    math->SuperscriptBottomMin = math->AccentBaseHeight;	/* X-height */
    /* No default given for math->SuperscriptBaselineDropMax */
    math->SubSuperscriptGapMin = 4*sf->uwidth;			/* 4* default rule thickness */
    math->SuperscriptBottomMaxWithSubscript = math->AccentBaseHeight;	/* X-height */
    math->SpaceAfterScript = emsize/24;				/* .5pt at 12pt */
    math->StackGapMin = 3*sf->uwidth;				/* 3* default rule thickness */
    math->StackDisplayStyleGapMin = 7*sf->uwidth;
    math->StretchStackGapAboveMin = math->UpperLimitGapMin;
    math->StretchStackGapBelowMin = math->LowerLimitGapMin;
    math->FractionNumeratorDisplayStyleShiftUp = math->StackTopDisplayStyleShiftUp;
    math->FractionDenominatorDisplayStyleShiftDown = math->StackBottomDisplayStyleShiftDown;
    math->FractionNumeratorGapMin = sf->uwidth;
    math->FractionNumeratorDisplayStyleGapMin = 3*sf->uwidth;
    math->FractionRuleThickness = sf->uwidth;
    math->FractionDenominatorGapMin = sf->uwidth;
    math->FractionDenominatorDisplayStyleGapMin = 3*sf->uwidth;
    math->OverbarVerticalGap = 3*sf->uwidth;
    math->OverbarRuleThickness = sf->uwidth;
    math->OverbarExtraAscender = sf->uwidth;
    math->UnderbarVerticalGap = 3*sf->uwidth;
    math->UnderbarRuleThickness = sf->uwidth;
    math->UnderbarExtraDescender = sf->uwidth;
    math->RadicalVerticalGap = sf->uwidth;
    math->RadicalExtraAscender = sf->uwidth;
    math->RadicalKernBeforeDegree = 5*emsize/18;
    math->RadicalKernAfterDegree = -10*emsize/18;
    math->RadicalDegreeBottomRaisePercent = 60;

    math->MinConnectorOverlap = emsize/50;
return( math );
}
Exemple #30
0
BGBGC_WorkerInfo *pdgl_worker_spawn(void *data)
{
	BGBGC_WorkerInfo *inf;
	inf=gcalloc(sizeof(BGBGC_WorkerInfo));
	inf->begin=pdgl_worker_begin;
	inf->end=pdgl_worker_end;
	return(inf);
}