Esempio n. 1
0
Handle
Widget_first_that( Handle self, void * actionProc, void * params)
{
    Handle child  = nilHandle;
    int i, count  = var-> widgets. count;
    Handle * list;
    if ( actionProc == nil || count == 0) return nilHandle;
    if (!(list = allocn( Handle, count + 2))) return nilHandle;

    list[0] = (Handle)( var-> enum_lists);
    list[1] = (Handle)( count);
    var-> enum_lists = list;
    memcpy( list + 2, var-> widgets. items, sizeof( Handle) * count);

    for ( i = 2; i < count + 2; i++)
    {
        if ( list[i] && (( PActionProc) actionProc)( self, list[ i], params))
        {
            child = list[ i];
            break;
        }
    }
    var-> enum_lists = (Handle*)(*list);
    free( list);
    return child;
}
Esempio n. 2
0
void
Clipboard_deregister_format( Handle self, char * format)
{
	PClipboardFormatReg fr, list; 

	if ( protect_formats && (
		( strlen( format) == 0)          ||
		( strcmp( format, "Text") == 0)  ||
		( strcmp( format, "UTF8") == 0)  ||
		( strcmp( format, "Image") == 0)))
		return;

	fr = first_that( self, (void*)find_format, format);
	if ( fr == nil) return;
	list = formats;
	fr-> server( self, fr, cefDone, nilSV);
	free( fr-> id);
	formatCount--;
	memmove( fr, fr + 1, sizeof( ClipboardFormatReg) * ( formatCount - ( fr - list)));
	if ( formatCount > 0) {
		if (( fr = allocn( ClipboardFormatReg, formatCount)))
			memcpy( fr, list, sizeof( ClipboardFormatReg) * formatCount);
	} else
		fr = nil;
	free( formats);
	formats = fr;
}
Esempio n. 3
0
void
dodef(char *p)
{
	if(nDlist%8 == 0)
		Dlist = allocn(Dlist, nDlist*sizeof(char *),
			8*sizeof(char *));
	Dlist[nDlist++] = p;
}
Esempio n. 4
0
File: lex.c Progetto: hfeeki/go
void
main(int argc, char *argv[])
{
	char *p;
	int c;

	thechar = '5';
	thestring = "arm";

	ensuresymb(NSYMB);
	memset(debug, 0, sizeof(debug));
	cinit();
	outfile = 0;
	setinclude(".");
	ARGBEGIN {
	default:
		c = ARGC();
		if(c >= 0 || c < sizeof(debug))
			debug[c] = 1;
		break;

	case 'o':
		outfile = ARGF();
		break;

	case 'D':
		p = ARGF();
		if(p) {
			if (nDlist%8 == 0) 
				Dlist = allocn(Dlist, nDlist*sizeof(char *), 
					8*sizeof(char *));
			Dlist[nDlist++] = p;
		}
		break;

	case 'I':
		p = ARGF();
		setinclude(p);
		break;
	case 't':
		thechar = 't';
		thestring = "thumb";
		break;
	} ARGEND
	if(*argv == 0) {
		print("usage: %ca [-options] file.s\n", thechar);
		errorexit();
	}
	if(argc > 1){
		print("can't assemble multiple files\n");
		errorexit();
	}
	if(assemble(argv[0]))
		errorexit();
	exits(0);
}
Esempio n. 5
0
void
cinit(void)
{
	Sym *s;
	int i;

	nullgen.sym = S;
	nullgen.offset = 0;
	nullgen.type = D_NONE;
	if(FPCHIP)
		nullgen.dval = 0;
	for(i=0; i<sizeof(nullgen.sval); i++)
		nullgen.sval[i] = 0;
	nullgen.displace = 0;
	nullgen.type = D_NONE;
	nullgen.index = D_NONE;
	nullgen.scale = 0;
	nullgen.field = 0;

	nerrors = 0;
	iostack = I;
	iofree = I;
	peekc = IGN;
	nhunk = 0;
	for(i=0; i<NHASH; i++)
		hash[i] = S;
	for(i=0; itab[i].name; i++) {
		s = slookup(itab[i].name);
		s->type = itab[i].type;
		s->value = itab[i].value;
	}

	pathname = allocn(pathname, 0, 100);
	if(mygetwd(pathname, 99) == 0) {
		pathname = allocn(pathname, 100, 900);
		if(mygetwd(pathname, 999) == 0)
			strcpy(pathname, "/???");
	}
}
Esempio n. 6
0
void *
Clipboard_register_format_proc( Handle self, char * format, void * serverProc)
{
	PClipboardFormatReg list = first_that( self, (void*)find_format, format);
	if ( list) {
		my-> deregister_format( self, format);
	}
	if (!( list = allocn( ClipboardFormatReg, formatCount + 1)))
		return nil;
	if ( formats != nil) {
		memcpy( list, formats, sizeof( ClipboardFormatReg) * formatCount);
		free( formats);
	}
	formats = list;
	list += formatCount++;
	list-> id     = duplicate_string( format);
	list-> server = ( ClipboardExchangeFunc *) serverProc;
	list-> sysId  = ( Handle) list-> server( self, list, cefInit, nilSV);
	return list;
}
Esempio n. 7
0
Point *
Drawable_polypoints( SV * points, char * procName, int mod, int * n_points)
{
   AV * av;
   int i, count;
   Point * p;

   if ( !SvROK( points) || ( SvTYPE( SvRV( points)) != SVt_PVAV)) {
      warn("RTC0050: Invalid array reference passed to %s", procName);
      return nil;
   }
   av = ( AV *) SvRV( points);
   count = av_len( av) + 1;
   if ( count % mod) {
      warn("RTC0051: Drawable::%s: Number of elements in an array must be a multiple of %d",
           procName, mod);
      return nil;
   }
   count /= 2;
   if ( count < 2) return nil;
   if (!( p = allocn( Point, count))) return false;
   for ( i = 0; i < count; i++)
   {
       SV** psvx = av_fetch( av, i * 2, 0);
       SV** psvy = av_fetch( av, i * 2 + 1, 0);
       if (( psvx == nil) || ( psvy == nil)) {
          free( p);
          warn("RTC0052: Array panic on item pair %d on Drawable::%s", i, procName);
          return nil;
       }
       p[ i]. x = SvIV( *psvx);
       p[ i]. y = SvIV( *psvy);
   }
   *n_points = count;
   return p;
}
Esempio n. 8
0
void
main(int argc, char *argv[])
{
	char *p;
	int nout, nproc, i, c;

	thechar = '5';
	thestring = "arm";

	ensuresymb(NSYMB);
	memset(debug, 0, sizeof(debug));
	cinit();
	outfile = 0;
	setinclude(".");
	ARGBEGIN {
	default:
		c = ARGC();
		if(c >= 0 || c < sizeof(debug))
			debug[c] = 1;
		break;

	case 'o':
		outfile = ARGF();
		break;

	case 'D':
		p = ARGF();
		if(p) {
			if (nDlist%8 == 0) 
				Dlist = allocn(Dlist, nDlist*sizeof(char *), 
					8*sizeof(char *));
			Dlist[nDlist++] = p;
		}
		break;

	case 'I':
		p = ARGF();
		setinclude(p);
		break;
	case 't':
		thechar = 't';
		thestring = "thumb";
		break;
	} ARGEND
	if(*argv == 0) {
		print("usage: %ca [-options] file.s\n", thechar);
		errorexit();
	}
	if(argc > 1 && systemtype(Windows)){
		print("can't assemble multiple files on windows\n");
		errorexit();
	}
	if(argc > 1 && !systemtype(Windows)) {
		nproc = 1;
		if(p = getenv("NPROC"))
			nproc = atol(p);	/* */
		c = 0;
		nout = 0;
		for(;;) {
			Waitmsg *w;

			while(nout < nproc && argc > 0) {
				i = fork();
				if(i < 0) {
					fprint(2, "fork: %r\n");
					errorexit();
				}
				if(i == 0) {
					print("%s:\n", *argv);
					if(assemble(*argv))
						errorexit();
					exits(0);
				}
				nout++;
				argc--;
				argv++;
			}
			w = wait();
			if(w == nil) {
				if(c)
					errorexit();
				exits(0);
			}
			if(w->msg[0])
				c++;
			nout--;
		}
	}
	if(assemble(argv[0]))
		errorexit();
	exits(0);
}
Esempio n. 9
0
File: lex.c Progetto: rosrad/go-rep
void
main(int argc, char *argv[])
{
	char *p;
	int c;

	thechar = '8';
	thestring = "386";

	ctxt = linknew(&link386);
	ctxt->diag = yyerror;
	ctxt->bso = &bstdout;
	Binit(&bstdout, 1, OWRITE);
	listinit8();
	fmtinstall('L', Lconv);

	// Allow GOARCH=thestring or GOARCH=thestringsuffix,
	// but not other values.	
	p = getgoarch();
	if(strncmp(p, thestring, strlen(thestring)) != 0)
		sysfatal("cannot use %cc with GOARCH=%s", thechar, p);

	ensuresymb(NSYMB);
	memset(debug, 0, sizeof(debug));
	cinit();
	outfile = 0;
	setinclude(".");
	ARGBEGIN {
	default:
		c = ARGC();
		if(c >= 0 && c < sizeof(debug))
			debug[c] = 1;
		break;

	case 'o':
		outfile = ARGF();
		break;

	case 'D':
		p = ARGF();
		if(p) {
			if (nDlist%8 == 0)
				Dlist = allocn(Dlist, nDlist*sizeof(char *), 
					8*sizeof(char *));
			Dlist[nDlist++] = p;
		}
		break;

	case 'I':
		p = ARGF();
		setinclude(p);
		break;

	case 'S':
		ctxt->debugasm++;
		break;
	} ARGEND
	if(*argv == 0) {
		print("usage: %ca [-options] file.s\n", thechar);
		errorexit();
	}
	if(argc > 1){
		print("can't assemble multiple files\n");
		errorexit();
	}
	if(assemble(argv[0]))
		errorexit();
	Bflush(&bstdout);
	exits(0);
}