Пример #1
0
// ----------------------------------------------------------------
// Process a flag command-line argument.
static int handleflags(int i, FILE *err) {
	int v;
	int errcnt = 0;
	int j;
	for(j=0; op[j].label; j++){
		if (strncmp(&argv[i][1],op[j].label,strlen(op[j].label))==0)  break;
	}
	v = argv[i][0]=='-' ? 1 : 0;
	if (op[j].label==0) {
		if (err) {
			fprintf(err,"%sundefined option.\n",emsg);
			errline(i,1,err);
		}
		errcnt++;
	} else if (op[j].type==OPT_FLAG) {
		*((int*)op[j].arg) = v;
	} else if (op[j].type==OPT_FFLAG) {
		(*(void(*)())(op[j].arg))(v);
	} else if (op[j].type==OPT_FSTR) {
		(*(void(*)())(op[j].arg))(&argv[i][2]);
	} else {
		if (err) {
			fprintf(err,"%smissing argument on switch.\n",emsg);
			errline(i,1,err);
		}
		errcnt++;
	}
	return errcnt;
}
Пример #2
0
Errcode step_init_screen(Vdevice **vd, Rcel **dcel, 
					char *drv_name, int drv_mode)
/* Open up display driver and open a screen in the requested mode.
 * Display error message if there's a problem. */
{
Errcode err;
Vmode_info mode_info;

	if((err = pj_open_vdriver(vd,drv_name)) < Success)
		goto error;

	if((err = pj_vd_get_mode(*vd,drv_mode,&mode_info)) < Success)
		goto error;

	if((err = alloc_display_rcel(*vd, dcel, 
							 mode_info.width.actual,
							 mode_info.height.actual, drv_mode)) < Success)
	{
		goto error;
	}

error:
	return(errline(err,"Can't open screen driver \"%s\"\nmode %d", 
				   drv_name, drv_mode));
}
Пример #3
0
main(int argc, char **argv)
{
Errcode err;

	scb.ovmode = pj_get_vmode();

	if((err = getargs(argc,argv)) < Success)
		goto error;

	if((err = step_init_screen(&scb.vd, &scb.dcel, scb.vd_path, scb.vd_mode)) 
		< Success)
		goto error;

	err = step_fli(scb.fli_path);

	goto done;

error:
	errline(err,"failure in main");
done:
	pj_rcel_free(scb.dcel);
	pj_close_vdriver(&scb.vd);
	pj_set_vmode(scb.ovmode);
	exit((err < Success)?-1:0);
}
Пример #4
0
main(int argc, char **argv)
{
Errcode err;

	tcb.ovmode = pj_get_vmode();

	if((err = getargs(argc,argv)) < Success)
		goto error;

	if((err = init_screen(&tcb.vd, &tcb.dcel, tcb.vd_path, tcb.vd_mode)) 
		< Success)
		goto error;

	err = test_draw(tcb.dcel);

	goto done;

error:
	errline(err,"failure in main");
done:
	pj_rcel_free(tcb.dcel);
	pj_close_vdriver(&tcb.vd);
	pj_set_vmode(tcb.ovmode);
	exit((err < Success)?-1:0);
}
Пример #5
0
Errcode pj_fli_error_report(Errcode err, char *msg, char *filename)
{

#ifndef FLILIB_CODE

	errline(err, msg, filename);

#endif

	return err;
}
Пример #6
0
Errcode pj_copyfile(char *source, char *dest)
/* Make a copy of a (closed) file. Report errors except for
   source file not existing. */
{
Errcode err;
char *errfile;

	err = pj_cpfile(source,dest,&errfile);
	if (err != Success && err != Err_no_file)
		err = errline(err, "%s", errfile);
	return(err);
}
Пример #7
0
static int set_out_func(char *s) {

	int i;

#ifdef WIN32
	if (strcmp(s, "off")==0) {
		errline("Sorry, no OFF output on WIN32");
		return 0;
	}
#endif

	for (i=0;i< sizeof(out_funcs)/(sizeof (out_func*)); i++)
		if (strcmp(s,output_forms[i])==0) return i;
	tell_options();
	return 0;
}
Пример #8
0
Pull *id_to_pull(Menuhdr *mh, SHORT id)
/* find a pull with the appropriate id */
{
Pull *p, *ip;

p = mh->mbs;
while (p != NULL)
	{
	if (p->id == id)
		return(p);
	ip = p->children->children;
	while (ip != NULL)
		{
		if (ip->id == id)
			return(ip);
		ip = ip->next;
		}
	p = p->next;
	}
/* shouldn't happen unless resource file is bad... */
errline(Err_not_found, "id_to_pull(%d)\n", id);
return(NULL);
}
Пример #9
0
static void new_dev(Button *b)
{
	switch(b->identity)
	{
		case -2:
			go_updir(b);
			return;
		case -1:
			go_rootdir(b);
			return;
		default:
			break;
	}

#if defined(__WATCOMC__)
	{
		Dsel_group *dg = b->group;
		char devname[2];
		Errcode err;

		devname[0] = 'A' + b->identity;
		devname[1] = 0;

		check_devicewait(devname);
		err = pj_change_device(devname);
		if (err >= Success) {
			set_device_group(b->group);
			mb_unhi_group(b);
			err = make_good_dir(dg->drawer);
			mb_hi_group(b);
		}

		errline(err,"%s:", devname);
		(*dg->on_newdrawer)(dg->on_newd_data);
	}
#endif /* __WATCOMC__ */
}
Пример #10
0
static void tell_options(void) {

	errline("options:");
	errline( "-m mult  multiply by mult before rounding;");
	errline( "-aa<alpha> alpha shape, alpha=<alpha>;");
}
Пример #11
0
// ----------------------------------------------------------------
// Process a command-line switch which has an argument.
static int handleswitch(int i, FILE *err) {
	int lv = 0;
	double dv = 0.0;
	char *sv = 0, *end;
	char *cp;
	int j;
	int errcnt = 0;
	cp = strchr(argv[i],'=');
	*cp = 0;
	for(j=0; op[j].label; j++){
		if (strcmp(argv[i],op[j].label)==0)  break;
	}
	*cp = '=';
	if (op[j].label==0) {
		if (err) {
			fprintf(err,"%sundefined option.\n",emsg);
			errline(i,0,err);
		}
		errcnt++;
	} else {
		cp++;
		switch (op[j].type) {
			case OPT_FLAG:
			case OPT_FFLAG:
				if (err) {
					fprintf(err,"%soption requires an argument.\n",emsg);
					errline(i,0,err);
				}
				errcnt++;
				break;
			case OPT_DBL:
			case OPT_FDBL:
				dv = strtod(cp,&end);
				if (*end) {
					if (err) {
						fprintf(err,"%sillegal character in floating-point argument.\n",emsg);
						errline(i,((unsigned long)end)-(unsigned long)argv[i],err);
					}
					errcnt++;
				}
				break;
			case OPT_INT:
			case OPT_FINT:
				lv = strtol(cp,&end,0);
				if (*end) {
					if (err) {
						fprintf(err,"%sillegal character in integer argument.\n",emsg);
						errline(i,((unsigned long)end)-(unsigned long)argv[i],err);
					}
					errcnt++;
				}
				break;
			case OPT_STR:
			case OPT_FSTR:
				sv = cp;
				break;
		}
		switch (op[j].type) {
			case OPT_FLAG:
			case OPT_FFLAG:
				break;
			case OPT_DBL:
				*(double*)(op[j].arg) = dv;
				break;
			case OPT_FDBL:
				(*(void(*)())(op[j].arg))(dv);
				break;
			case OPT_INT:
				*(int*)(op[j].arg) = lv;
				break;
			case OPT_FINT:
				(*(void(*)())(op[j].arg))((int)lv);
				break;
			case OPT_STR:
				*(char**)(op[j].arg) = sv;
				break;
			case OPT_FSTR:
				(*(void(*)())(op[j].arg))(sv);
				break;
		}
	}
	return errcnt;
}
Пример #12
0
// ----------------------------------------------------------------
void OptErr(int n) {
	int i;
	i = argindex(n);
	if (i>=0)  errline(i,0,errstream);
}
Пример #13
0
static Errcode step_fli(char *fliname)
/* Load up a fli and step through it frame by frame each time
 * user hits a key.  If he hits <ESC> or  some other quit looking
 * key we'll quit instead of advancing frame. */
{
Errcode err;			/* oop, aak, eek, if negative there's trouble */
Flifile flif;  			/* current fli file and header */
Rcel cel;				/* (clipped) cel to play fli */
int frame=0;			/* current frame index */
int scancode;			/* keyboard scancode */
char asckey;			/* ascii representation of keyboard scan code */


							/* Open up fli file and verify header */
	if((err = pj_fli_open(fliname,&flif,JREADONLY)) < Success)
		goto error;

	/* The following block of code transform our display cel (scb.dcel)
	 * into a cel that is the size of the fli,  but which will
	 * clip drawing outside of the display cel (cel).  The purpose is to
	 * let us play fli's larger than the display screen without
	 * going kaboom as memory is overwritten.
	 * This won't consume more than a few K of memory.  It only
	 * creates a Cel that _seems_ larger. */
	{
	Rectangle celrect;

		celrect.x = (scb.dcel->width - flif.hdr.width)/2;
		celrect.y = (scb.dcel->height - flif.hdr.height)/2;
		celrect.width = flif.hdr.width;
		celrect.height = flif.hdr.height;
		pj_rcel_make_virtual(&cel, scb.dcel, &celrect);
	}


											/* Position file pointer 
											 * to first frame of fli */
	if((err = pj_fli_seek_first(&flif)) < Success)
		goto error;

	for (;;)
	{
											/* Get next frame of fli
											 * onto display cel, and don't
											 * forget to update the color
											 * map. */
		if((err = pj_fli_read_next(fliname,&flif,&cel,TRUE)) < Success)
		{
			goto error;
		}
											/* See if it's time to wrap
											 * around the fli back to
											 * the second frame.
											 * (The very last frame of
											 * a fli brings you back to the
											 * first frame) */
		if(++frame > flif.hdr.frame_count)	
		{
			frame = 1;
			if((err = pj_fli_seek_second(&flif)) < Success)
				goto error;
		}

											/* See if tired (ab)user
											 * is ready to go on to
											 * better things. */

		asckey = scancode = pj_key_in();	/* Hey dos, what did they hit? */
#define ESCKEY 0x1b
		switch (asckey)						/* Quit program on any 
											 * escape looking key */
		{
			case ESCKEY:
			case 'q':
			case 'Q':
			case 'x':
			case 'X':
				goto done_stepping;
		}
	}
done_stepping:
error:
	pj_fli_close(&flif);
	return(errline(err,"Unable to play flic \"%s\"", fliname ));
}