Exemple #1
0
int main()
{
  int win, win2, win3;
  double t = 0, h = 2 * M_PI / 100, quit = 0, run = 1;
  double clr2 = 0, clr3 = 0;
  double r[6] = { 0 };

  param_set prms = { &win, &win2, &win3, &F, &D, &B, &t, &h,
    &clr2, &clr3, &run, r
  };
  e_ctrl ctrls[] = {
    {"Force", &F, 0.1, &init, &prms},
    {"Dumping", &D, 0.01, &init, &prms},
    {"Nonlinear", &B, 0.1, &init, &prms},
    {"_Clear Phase", &clr2, 0, NULL, NULL},
    {"_Clear Poincare", &clr3, 0, NULL, NULL},
    {"_Run", &run, 0, NULL, NULL},
    {"_Quit", &quit, 0, NULL, NULL},
  };
  int cwin;
  cwin = init_ctrls(ctrls, 7);

  win = gopen(2 * WD + 2 * MG, HT);
  win2 = gopen(WD + MG, HT);
  win3 = gopen(WD + MG, HT);
  window(win, 0, -HT / 2, 2 * WD + 2 * MG, HT / 2 - 1);
  window(win2, -(MG + WD) / 2, -HT / 2, (WD + MG) / 2 - 1, HT / 2 - 1);
  window(win3, -(MG + WD) / 2, -HT / 2, (WD + MG) / 2 - 1, HT / 2 - 1);
  winname(win2, "Phase chart");
  winname(win3, "Poincare chart");
  layer(win, 0, 1);
  layer(win2, 0, 1);
  layer(win3, 0, 1);
  gsetbgcolor(win, ECTRL_BGCOLOR);
  gsetbgcolor(win2, ECTRL_FGCOLOR);
  gsetbgcolor(win3, ECTRL_FGCOLOR);
  newcolor(win, ECTRL_FGCOLOR);
  newcolor(win2, ECTRL_BGCOLOR);
  newcolor(win3, "red3");
  gclr(win2);
  gclr(win3);
  gsetnonblock(ENABLE);

  while (!quit) {
    int iscwin, type, button;
    double wx, wy;
    iscwin = ggetxpress(&type, &button, &wx, &wy);
    display_ctrls(cwin, ctrls, 7, wx, wy, iscwin, type, button);
    if (run) {
      rk4fixv6(duffing, t, r, h);
      t += h;
      draw(&prms);
    }
    msleep(5);
  }
  gcloseall();
  return 0;
}
Exemple #2
0
TQString KXEventUtil::getXAnyEventInfo(XEvent *xevent) {
    XAnyEvent *e = &xevent->xany;
    TQString winname("window");
    switch (e->type) {
        case  GraphicsExpose:
        case  NoExpose:
            winname="drawable";
            break;
        case  CreateNotify:
        case  ConfigureRequest:
            winname="parent";
            break;
        case  DestroyNotify:
        case  ConfigureNotify:
        case  MapNotify:
        case  ReparentNotify:
        case  UnmapNotify:
            winname="event";
        default:
            break;
    } 
    TQString s("serial=%1 send_event=%2 display=0x%3 %4=%5");
    return 
     s.arg(e->serial)
     .arg(e->send_event)
     .arg((long)e->display, 0, 16)
     .arg(winname)
     .arg(e->window);
}
Exemple #3
0
int main()
{
    int win ;
    time_t time_now ;
    char d0[8],d1[8],d2[8],d3[8], t0[16] ;

    /* open a graphic window */
    win = gopen(FONTSIZE*24/2+4,FONTSIZE+4) ;
    /* set name of window */
    winname(win,"Simple Clock") ;
    /* configure layer */
    layer(win,0,1) ;
    /* display time... */
    while(1){
        time(&time_now) ;
        sscanf(ctime(&time_now),"%s %s %s %s %s",d0,d1,d2,t0,d3) ;
	gclr(win) ;
	drawstr(win,2,2,FONTSIZE,0,"%s %s %s %s %s",d0,d1,d2,t0,d3) ;
	copylayer(win,1,0) ;
	msleep(200) ;
    }
    /* close a graphic window */
    gclose(win) ;

    return(0) ;
}
Exemple #4
0
//--------------------------------メイン--------------------------------------
int main(void){
  int seed;
  
  //ランダム関数設定
  printf("適当に何か入力してreturnを押してください >> ");
  scanf("%d", &seed);
  srand(seed);  
  
  //落ちてくる物体の初期値設定
  syoki_buttai();
    
  //画面表示
  win=gopen(400, 500);
  winname(win, "DODGE GAME");
  
  STA();//スタート画面 
  if(ggetevent(&type, &code, &s, &t)==win){//入力待ち
    if(code==0x073){// sキーを入力した場合
      game();
    }
    else if(code == 0x075){// fキーを押した場合
      return 0;
    }
  }
  return 0;
}
Exemple #5
0
Article*
newpost(void)
{
	Article *m;
	char *p, tmp[40];
	static int nnew;

	m = emalloc(sizeof *m);
	sprint(tmp, "Post%d", ++nnew);
	p = estrstrdup(dir, tmp);

	m->w = newwindow();
	proccreate(wineventproc, m->w, STACK);
	winname(m->w, p);
	wintagwrite(m->w, "Post ", 5);
	m->sayspost = 1;
	m->ispost = 1;
	threadcreate(mesgthread, m, STACK);

	if(mlist){
		m->next = mlist;
		mlist->prev = m;
	}
	mlist = m;
	return m;
}
Exemple #6
0
void
wikiname(Window *w, char *name)
{
	char *p, *q;

	p = emalloc(strlen(dir)+1+strlen(name)+1+1);
	strcpy(p, dir);
	strcat(p, "/");
	strcat(p, name);
	for(q=p; *q; q++)
		if(*q==' ')
			*q = '_';
	winname(w, p);
	free(p);
}
Exemple #7
0
int
mesgopen(char *s)
{
	char *p, tmp[40];
	int fd, n;
	Article *m;

	n = atoi(s);
	if(n==0)
		return 0;

	for(m=mlist; m; m=m->next){
		if(m->n == n){
			ctlprint(m->w->ctl, "show\n");
			return 1;
		}
	}

	sprint(tmp, "%d/article", n);
	p = estrstrdup(dir, tmp);
	if((fd = open(p, OREAD)) < 0){
		free(p);	
		return 0;
	}

	m = emalloc(sizeof(*m));
	m->w = newwindow();
	m->n = n;
	proccreate(wineventproc, m->w, STACK);
	p[strlen(p)-strlen("article")] = '\0';
	winname(m->w, p);
	if(canpost)
		wintagwrite(m->w, "Reply ", 6);
	wintagwrite(m->w, "Headers ", 8);

	free(p);
	if(mlist){
		m->next = mlist;
		mlist->prev = m;
	}
	mlist = m;
	threadcreate(mesgthread, m, STACK);

	fillmesgwindow(fd, m);
	close(fd);
	windormant(m->w);
	return 1;
}
Exemple #8
0
int main(int argc, char **argv)
{
  int win;
  double chbg = 0, quit = 0;
  double order = 8, rt = 0.8, ra = 15, rnd = 0.1;
  int bgcolor_r = 0x036 - 48, bgcolor_g = 0x064 - 48, bgcolor_b =
      0x088 - 48;

  param_set prms = {
    &win, &order, &rt, &ra, &rnd, &chbg,
    &bgcolor_r, &bgcolor_g, &bgcolor_b
  };

  e_ctrl ctrls[] = {
    {"Order", &order, 1, &remake_all, &prms},
    {"Ratio", &rt, 0.01, &remake_all, &prms},
    {"Angle", &ra, 1, &remake_all, &prms},
    {"Randomness", &rnd, 0.01, &remake_all, &prms},
    {"_Change bgcolor", &chbg, 0, &change_bgcolor, &prms},
    {"_Quit", &quit, 0, NULL, NULL},
  };

  int cwin;
  cwin = init_ctrls(ctrls, 6);

  srand48(time(NULL));
  win = gopen(L, L);
  window(win, -L / 2, 0, L / 2 - 1, L - 1);
  winname(win, "Snow falls on fractal tree");
  layer(win, 0, 1);
  remake_all(&prms);
  gsetnonblock(ENABLE);

  while (!quit) {
    int type, button, iscwin;
    double wx, wy;
    if (order > 11)
      order = 12;
    iscwin = ggetxpress(&type, &button, &wx, &wy);
    display_ctrls(cwin, ctrls, 6, wx, wy, iscwin, type, button);
    draw(win, prms.snowx, prms.snowy, MAXSNOW);
    msleep(40);
  }
  gcloseall();
  return 0;
}
Exemple #9
0
void
threadmain(int argc, char **argv)
{
	Scsi *s;
	Drive *d;
	char buf[80];

	ARGBEGIN{
	case 'v':
		debug++;
		scsiverbose++;
	}ARGEND

	if(argc != 1)
		usage();

	fmtinstall('M', msfconv);

	if((s = openscsi(argv[0])) == nil)
		error("opening scsi: %r");

	d = malloc(sizeof(*d));
	if(d == nil)
		error("out of memory");
	memset(d, 0, sizeof d);

	d->scsi = s;
	d->w = newwindow();
	d->ctocdisp = chancreate(sizeof(Toc), 0);
	d->cdbreq = chancreate(sizeof(Toc), 0);
	d->cdbreply = chancreate(sizeof(Toc), 0);
	d->cstatus = chancreate(sizeof(Cdstatus), 0);

	proccreate(wineventproc, d->w, STACK);
	proccreate(cddbproc, d, STACK);
	proccreate(cdstatusproc, d, STACK);

	cleanname(argv[0]);
	snprint(buf, sizeof(buf), "%s/", argv[0]);
	winname(d->w, buf);

	wintagwrite(d->w, "Stop Pause Resume Eject Ingest ", 5+6+7+6+7);
	eventwatcher(d);
}
Exemple #10
0
int
newpipewin(int pid, char *p)
{
	int id;
	Window *w;
	Wpid *wp;

	w = newwindow();
	winname(w, p);
	wintagwrite(w, "Send ", 5);
	wp = emalloc(sizeof(Wpid));
	wp->pid = pid;
	wp->w = w;
	wp->next = wpid;	/* BUG: this happens in fsread proc (we don't use wpid, so it's okay) */
	wpid = wp;
	id = w->id;
	sendp(newpipechan, w);
	return id;
}
Exemple #11
0
void
threadmain(int argc, char *argv[])
{
	int i, j;
	char *dir, *tag, *name;
	char buf[1024], **av;

	quotefmtinstall();
	rfork(RFNAMEG);
	ARGBEGIN{
	case 'd':
		debug = 1;
		chatty9p++;
		break;
	case 'e':
		eraseinput = 1;
		break;
	case 'D':
{extern int _threaddebuglevel;
		_threaddebuglevel = 1<<20;
}
	}ARGEND

	if(argc == 0){
		av = emalloc(3*sizeof(char*));
		av[0] = "rc";
		av[1] = "-i";
		name = getenv("sysname");
	}else{
		av = argv;
		name = utfrrune(av[0], '/');
		if(name)
			name++;
		else
			name = av[0];
	}

	if(getwd(buf, sizeof buf) == 0)
		dir = "/";
	else
		dir = buf;
	dir = estrdup(dir);
	tag = estrdup(dir);
	tag = eappend(estrdup(tag), "/-", name);
	win = newwindow();
	snprint(buf, sizeof buf, "%d", win->id);
	putenv("winid", buf);
	winname(win, tag);
	wintagwrite(win, "Send Noscroll", 5+8);
	threadcreate(mainctl, win, STACK);
	mountcons();
	threadcreate(fsloop, nil, STACK);
	startpipe();
	startcmd(av, &notepg);

	strcpy(buf, "win");
	j = 3;
	for(i=0; i<argc && j+1+strlen(argv[i])+1<sizeof buf; i++){
		strcpy(buf+j, " ");
		strcpy(buf+j+1, argv[i]);
		j += 1+strlen(argv[i]);
	}

	ctlprint(win->ctl, "scroll");
	winsetdump(win, dir, buf);
}
Exemple #12
0
void
threadmain(int argc, char **argv)
{
	char *p, *q;
	Dir *d;
	Window *w;

	ARGBEGIN{
	case 'D':
		debug++;
		break;
	case 'd':
		dir = EARGF(usage());
		break;
	default:
		usage();
		break;
	}ARGEND

	if(argc != 1)
		usage();

	from = findfrom();

	group = estrdup(argv[0]);	/* someone will be cute */
	while(q=strchr(group, '/'))
		*q = '.';

	p = estrdup(argv[0]);
	while(q=strchr(p, '.'))
		*q = '/';
	p = estrstrstrdup(dir, "/", p);
	cleanname(p);

	if((d = dirstat(p)) == nil){	/* maybe it is a new group */
		if((d = dirstat(dir)) == nil){
			fprint(2, "dirstat(%s) fails: %r\n", dir);
			threadexitsall(nil);
		}
		if((d->mode&DMDIR)==0){
			fprint(2, "%s not a directory\n", dir);
			threadexitsall(nil);
		}
		free(d);
		if((d = dirstat(p)) == nil){
			fprint(2, "stat %s: %r\n", p);
			threadexitsall(nil);
		}
	}
	if((d->mode&DMDIR)==0){
		fprint(2, "%s not a directory\n", dir);
		threadexitsall(nil);
	}
	free(d);
	dir = estrstrdup(p, "/");

	q = estrstrdup(dir, "post");
	canpost = access(q, AWRITE)==0;

	w = newwindow();
	root = w;
	proccreate(wineventproc, w, STACK);
	proccreate(timerproc, w, STACK);

	winname(w, dir);
	if(canpost)
		wintagwrite(w, "Newpost ", 8);
	wintagwrite(w, "More ", 5);
	dirwindow(w);
	threadcreate(dirthread, w, STACK);
	threadexits(nil);
}
Exemple #13
0
int main()
{
    int i,j,key,sl=0,wl=1 ;
    int shape_i = 11, shape_j = 4 ;
    float f=MRATIO_F ;
    float x,y,zx,zy,z,ph,ms_w,ms_h ;
    float zran=(ZMAX-ZMIN) ;
    float zcen=(ZMAX+ZMIN)/2.0 ;
    color_prms cl = {
	EGGX_COLOR_BEGIN,			/* カラーパターン */
	CP_CONTRAST | CP_BRIGHTNESS | CP_GAMMA,	/* フラグ */
	1.0,					/* コントラスト */
	0.0,					/* ブライトネス*/
	1.0,					/* γ */
    } ;
    int win ;
    int cl_r,cl_g,cl_b ;

    win=gopen(WINWIDTH,WINHEIGHT) ;	/* ウィンドゥのタイトル */
    /* 座標系を変更する */
    coordinate(win, 0,0, XMIN,YMIN, 
	       WINWIDTH/(XMAX-XMIN), WINHEIGHT/(YMAX-YMIN)) ;
    layer(win,sl,wl) ;

    puts("【キーボードでの操作方法】") ;
    puts("'PageUp','PageDown'  … 質量比変更") ;
    puts("'c','C'              … カラーパターン") ;
    puts("'↑','↓','←','→'  … カラー調整") ;
    puts("'[',']'              … コントラスト") ;
    puts("'{','}'              … ブライトネス") ;
    puts("'<','>'              … γ補正") ;
    puts("'s'                  … 画像を保存") ;
    puts("'q','Esc'            … 終了") ;

    ms_w=(float)(XMAX-XMIN)/XSAMPLES ;	/* メッシュ1個分のサイズ */
    ms_h=(float)(YMAX-YMIN)/YSAMPLES ;

    do{
	/* ウィンドゥのタイトル */
	winname(win,"ロッシュワールド('s'キーで画像save) f=%g zcen=%g zran=%g",
		f,zcen,zran) ;
	for( i=0 ; i<XSAMPLES ; i++ ){	/* ポテンシャルを色で表現 */
	    x=XMIN+ms_w*i ;
	    for( j=0 ; j<YSAMPLES ; j++ ){
		y=YMIN+ms_h*j ;
		ph=get_phi(x+ms_w/2.0,y+ms_w/2.0,f) ;
		generatecolor(&cl,zcen-zran/2,zcen+zran/2,ph,
			      &cl_r,&cl_g,&cl_b) ;
		newrgbcolor(win,cl_r,cl_g,cl_b) ;
		fillrect(win,x,y,ms_w*1.5,ms_h*1.5) ;
	    }
	}
	newpen(win,1) ;
	for( i=0 ; i<XSAMPLES ; i++ ){	/* テスト粒子に働く力を矢印で表現 */
	    x=XMIN+ms_w*(i+0.5) ;
	    for( j=0 ; j<YSAMPLES ; j++ ){
		y=YMIN+ms_h*(j+0.5) ;
		zx=get_fx(x,y,f) ;
		zy=get_fy(x,y,f) ;
		zx *= VXSCALE ;
		zy *= VYSCALE ;
		z=sqrt(zx*zx+zy*zy) ;
		if( z <= VCARMAX ){
		    drawarrow(win,x-zx,y-zy,x+zx,y+zy,0.3,0.2,
			      shape_i*10+shape_j) ;
		}
	    }
	}
	sl ^= 1 ;				/* XORをとってレイヤを切替 */
	wl ^= 1 ;
	layer( win,sl,wl ) ;
	key=ggetch() ;				/* キー入力があるまで待つ */
	if( key == 0x002 ) f += 0.1 ;		/* PageUp */
	else if( key == 0x006 ) f -= 0.1 ;	/* PageDown */
	else if( key == 0x01e ) zcen += 0.1 ;	/* ↑ */
	else if( key == 0x01f ) zcen -= 0.1 ;	/* ↓ */
	else if( key == 0x01c ) zran += 0.1 ;	/* → */
	else if( key == 0x01d ) zran -= 0.1 ;	/* ← */
	else if( key == 'i' ) {
	    shape_i += 1 ;
	    if ( 12 < shape_i ) shape_i = 10 ;
	}
	else if( key == 'j' ) {
	    shape_j += 1 ;
	    if ( 7 < shape_j ) shape_j = 1 ;
	}
	else if( key == 'c' ){			/* 'c','C'キーでカラーパターン変更 */
	    cl.colormode++ ;
	    if( EGGX_COLOR_BEGIN+EGGX_COLOR_NUM <= cl.colormode )
		cl.colormode=EGGX_COLOR_BEGIN ;
	}
	else if( key == 'C' ){
	    cl.colormode-- ;
	    if( cl.colormode < EGGX_COLOR_BEGIN )
		cl.colormode=EGGX_COLOR_BEGIN+EGGX_COLOR_NUM-1 ;
	}
	else if( key == '[' ){			/* '[',']'でコントラスト変更 */
	    cl.contrast += 0.05 ;
	    if( 1 < cl.contrast ) cl.contrast = 1 ;
	}
	else if( key == ']' ){
	    cl.contrast -= 0.05 ;
	    if( cl.contrast < 0 ) cl.contrast = 0 ;
	}
	else if( key == '{' ){			/* '{','}'でブライトネス変更 */
	    cl.brightness += 0.05 ;
	    if( 1 < cl.brightness ) cl.brightness = 1 ;
	}
	else if( key == '}' ){
	    cl.brightness -= 0.05 ;
	    if( cl.brightness < 0 ) cl.brightness = 0 ;
	}
	else if( key == '<' ){			/* '<','>'でγ変更 */
	    cl.gamma += 0.025 ;
	}
	else if( key == '>' ){
	    cl.gamma -= 0.025 ;
	    if( cl.gamma <= 0 ) cl.gamma = 0.025 ;
	}
	else if( key == 's' ){			/* 's'キーで保存 */
#ifdef USE_NETPBM
	    saveimg( win,sl,XMIN,YMIN,XMAX,YMAX,
		     "pnmtops -noturn -dpi 72 -equalpixels -psfilter -flate -ascii85",256,
		     "roche_f=%g.eps",f) ;
	    printf("画像を保存: filename='roche_f=%g.eps'\n",f) ;
#else
#ifdef USE_IMAGEMAGICK
	    saveimg( win,sl,XMIN,YMIN,XMAX,YMAX,"convert",256,
		     "roche_f=%g.png",f) ;
	    printf("画像を保存: filename='roche_f=%g.png'\n",f) ;
#else
	    saveimg( win,sl,XMIN,YMIN,XMAX,YMAX,"",256,
		     "roche_f=%g.ppm",f) ;
	    printf("画像を保存: filename='roche_f=%g.ppm'\n",f) ;
#endif
#endif
	}
	if( f < 0 ) f=0 ;
	if( zran < 0 ) zran=0.1 ;
    } while( key != 0x01b && key != 'q' ) ;	/* ESCキーか 'q'キーで終了 */

    gcloseall() ;
    return(0) ;
}
Exemple #14
0
int
mesgopen(Message *mbox, char *dir, char *s, Message *mesg, int plumbed, char *digest)
{
	char *t, *u, *v;
	Message *m;
	char *direlem[10];
	int i, ndirelem, reuse;

	/* find white-space-delimited first word */
	for(t=s; *t!='\0' && !isspace(*t); t++)
		;
	u = emalloc(t-s+1);
	memmove(u, s, t-s);
	/* separate it on slashes */
	ndirelem = tokenizec(u, direlem, nelem(direlem), "/");
	if(ndirelem <= 0){
    Error:
		free(u);
		return 0;
	}
	if(plumbed){
		write(wctlfd, "top", 3);
		write(wctlfd, "current", 7);
	}
	/* open window for message */
	m = mesglookup(mbox, direlem[0], digest);
	if(m == nil)
		goto Error;
	if(mesg!=nil && m!=mesg)	/* string looked like subpart but isn't part of this message */
		goto Error;
	if(m->opened == 0){
		if(m->w == nil){
			reuse = 0;
			m->w = newwindow();
		}else{
			reuse = 1;
			/* re-use existing window */
			if(winsetaddr(m->w, "0,$", 1)){
				if(m->w->data < 0)
					m->w->data = winopenfile(m->w, "data");
				write(m->w->data, "", 0);
			}
		}
		v = estrstrdup(mbox->name, m->name);
		winname(m->w, v);
		free(v);
		if(!reuse){
			if(m->deleted)
				wintagwrite(m->w, "Q Reply all UnDelmesg Save ", 2+6+4+10+5);
			else
				wintagwrite(m->w, "Q Reply all Delmesg Save ", 2+6+4+8+5);
		}
		threadcreate(mesgctl, m, STACK);
		winopenbody(m->w, OWRITE);
		mesgload(m, dir, m->name, m->w);
		winclosebody(m->w);
		winclean(m->w);
		m->opened = 1;
		if(ndirelem == 1){
			free(u);
			return 1;
		}
	}
	if(ndirelem == 1 && plumbport(m->type, m->filename) <= 0){
		/* make sure dot is visible */
		ctlprint(m->w->ctl, "show\n");
		return 0;
	}
	/* walk to subpart */
	dir = estrstrdup(dir, m->name);
	for(i=1; i<ndirelem; i++){
		m = mesglookup(m, direlem[i], digest);
		if(m == nil)
			break;
		dir = egrow(dir, m->name, nil);
	}
	if(m != nil && plumbport(m->type, m->filename) > 0)
		plumb(m, dir);
	free(dir);
	free(u);
	return 1;
}
Exemple #15
0
void
threadmain(int argc, char *argv[])
{
	char *s, *name;
	char err[ERRMAX], *cmd;
	int i, newdir;
	Fmt fmt;

	doquote = needsrcquote;
	quotefmtinstall();

	/* open these early so we won't miss notification of new mail messages while we read mbox */
	if((plumbsendfd = plumbopenfid("send", OWRITE|OCEXEC)) == nil)
		fprint(2, "warning: open plumb/send: %r\n");
	if((plumbseemailfd = plumbopenfid("seemail", OREAD|OCEXEC)) == nil)
		fprint(2, "warning: open plumb/seemail: %r\n");
	if((plumbshowmailfd = plumbopenfid("showmail", OREAD|OCEXEC)) == nil)
		fprint(2, "warning: open plumb/showmail: %r\n");

	shortmenu = 0;
	srvname = "mail";
	ARGBEGIN{
	case 's':
		shortmenu = 1;
		break;
	case 'S':
		shortmenu = 2;
		break;
	case 'o':
		outgoing = EARGF(usage());
		break;
	case 'm':
		smprint(maildir, "%s/", EARGF(usage()));
		break;
	case 'n':
		srvname = EARGF(usage());
		break;
	default:
		usage();
	}ARGEND

	acmefs = nsmount("acme",nil);
	if(acmefs == nil)
		error("cannot mount acme: %r");
	mailfs = nsmount(srvname, nil);
	if(mailfs == nil)
		error("cannot mount %s: %r", srvname);

	name = "mbox";

	newdir = 1;
	if(argc > 0){
		i = strlen(argv[0]);
		if(argc>2 || i==0)
			usage();
		/* see if the name is that of an existing /mail/fs directory */
		if(argc==1 && argv[0][0] != '/' && ismaildir(argv[0])){
			name = argv[0];
			mboxname = estrdup(name);
			newdir = 0;
		}else{
			if(argv[0][i-1] == '/')
				argv[0][i-1] = '\0';
			s = strrchr(argv[0], '/');
			if(s == nil)
				mboxname = estrdup(argv[0]);
			else{
				*s++ = '\0';
				if(*s == '\0')
					usage();
				mailboxdir = argv[0];
				mboxname = estrdup(s);
			}
			if(argc > 1)
				name = argv[1];
			else
				name = mboxname;
		}
	}

	user = getenv("user");
	if(user == nil)
		user = "******";
	home = getenv("home");
	if(home == nil)
		home = getenv("HOME");
	if(home == nil)
		error("can't find $home");
	if(mailboxdir == nil)
		mailboxdir = estrstrdup(home, "/mail");
	if(outgoing == nil)
		outgoing = estrstrdup(mailboxdir, "/outgoing");

	mbox.ctlfd = fsopen(mailfs, estrstrdup(mboxname, "/ctl"), OWRITE);
	if(mbox.ctlfd == nil)
		error("can't open %s: %r", estrstrdup(mboxname, "/ctl"));

	fsname = estrdup(name);
	if(newdir && argc > 0){
		s = emalloc(5+strlen(mailboxdir)+strlen(mboxname)+strlen(name)+10+1);
		for(i=0; i<10; i++){
			sprint(s, "open %s/%s %s", mailboxdir, mboxname, fsname);
			if(fswrite(mbox.ctlfd, s, strlen(s)) >= 0)
				break;
			err[0] = '\0';
			errstr(err, sizeof err);
			if(strstr(err, "mbox name in use") == nil)
				error("can't create directory %s for mail: %s", name, err);
			free(fsname);
			fsname = emalloc(strlen(name)+10);
			sprint(fsname, "%s-%d", name, i);
		}
		if(i == 10)
			error("can't open %s/%s: %r", mailboxdir, mboxname);
		free(s);
	}

	s = estrstrdup(fsname, "/");
	mbox.name = estrstrdup(maildir, s);
	mbox.level= 0;
	readmbox(&mbox, maildir, s);
	home = getenv("home");
	if(home == nil)
		home = "/";

	wbox = newwindow();
	winname(wbox, mbox.name);
	wintagwrite(wbox, "Put Mail Delmesg ", 3+1+4+1+7+1);
	threadcreate(mainctl, wbox, STACK);

	fmtstrinit(&fmt);
	fmtprint(&fmt, "Mail");
	if(shortmenu)
		fmtprint(&fmt, " -%c", "sS"[shortmenu-1]);
	if(outgoing)
		fmtprint(&fmt, " -o %s", outgoing);
	fmtprint(&fmt, " %s", name);
	cmd = fmtstrflush(&fmt);
	if(cmd == nil)
		sysfatal("out of memory");
	winsetdump(wbox, "/acme/mail", cmd);
	mbox.w = wbox;

	mesgmenu(wbox, &mbox);
	winclean(wbox);

/*	wctlfd = open("/dev/wctl", OWRITE|OCEXEC);	/* for acme window */
	wctlfd = -1;
	cplumb = chancreate(sizeof(Plumbmsg*), 0);
	cplumbshow = chancreate(sizeof(Plumbmsg*), 0);
	if(strcmp(name, "mbox") == 0){
		/*
		 * Avoid creating multiple windows to send mail by only accepting
		 * sendmail plumb messages if we're reading the main mailbox.
		 */
		plumbsendmailfd = plumbopenfid("sendmail", OREAD|OCEXEC);
		cplumbsend = chancreate(sizeof(Plumbmsg*), 0);
		proccreate(plumbsendproc, nil, STACK);
		threadcreate(plumbsendthread, nil, STACK);
	}
	/* start plumb reader as separate proc ... */
	proccreate(plumbproc, nil, STACK);
	proccreate(plumbshowproc, nil, STACK);
	threadcreate(plumbshowthread, nil, STACK);
	fswrite(mbox.ctlfd, "refresh", 7);
	/* ... and use this thread to read the messages */
	plumbthread();
}
Exemple #16
0
int
mboxcommand(Window *w, char *s)
{
	char *args[10], **targs, *save;
	Window *sbox;
	Message *m, *next;
	int ok, nargs, i, j;
	CFid *searchfd;
	char buf[128], *res;

	nargs = tokenize(s, args, nelem(args));
	if(nargs == 0)
		return 0;
	if(strcmp(args[0], "Mail") == 0){
		if(nargs == 1)
			mkreply(nil, "Mail", "", nil, nil);
		else
			mkreply(nil, "Mail", args[1], nil, nil);
		return 1;
	}
	if(strcmp(s, "Del") == 0){
		if(mbox.dirty){
			mbox.dirty = 0;
			fprint(2, "mail: mailbox not written\n");
			return 1;
		}
		if(w != mbox.w){
			windel(w, 1);
			return 1;
		}
		ok = 1;
		for(m=mbox.head; m!=nil; m=next){
			next = m->next;
			if(m->w){
				if(windel(m->w, 0))
					m->w = nil;
				else
					ok = 0;
			}
		}
		for(m=replies.head; m!=nil; m=next){
			next = m->next;
			if(m->w){
				if(windel(m->w, 0))
					m->w = nil;
				else
					ok = 0;
			}
		}
		if(ok){
			windel(w, 1);
			removeupasfs();
			threadexitsall(nil);
		}
		return 1;
	}
	if(strcmp(s, "Put") == 0){
		rewritembox(wbox, &mbox);
		return 1;
	}
	if(strcmp(s, "Get") == 0){
		fswrite(mbox.ctlfd, "refresh", 7);
		return 1;
	}
	if(strcmp(s, "Delmesg") == 0){
		save = nil;
		if(nargs > 1)
			save = args[1];
		s = winselection(w);
		if(s == nil)
			return 1;
		nargs = 1;
		for(i=0; s[i]; i++)
			if(s[i] == '\n')
				nargs++;
		targs = emalloc(nargs*sizeof(char*));	/* could be too many for a local array */
		nargs = getfields(s, targs, nargs, 1, "\n");
		for(i=0; i<nargs; i++){
			if(!isdigit(targs[i][0]))
				continue;
			j = atoi(targs[i]);	/* easy way to parse the number! */
			if(j == 0)
				continue;
			snprint(buf, sizeof buf, "%s%d", mbox.name, j);
			delmesg(buf, nil, 1, save);
		}
		free(s);
		free(targs);
		return 1;
	}
	if(strcmp(s, "Search") == 0){
		if(nargs <= 1)
			return 1;
		s = estrstrdup(mboxname, "/search");
		searchfd = fsopen(mailfs, s, ORDWR);
		if(searchfd == nil)
			return 1;
		save = estrdup(args[1]);
		for(i=2; i<nargs; i++)
			save = eappend(save, " ", args[i]);
		fswrite(searchfd, save, strlen(save));
		fsseek(searchfd, 0, 0);
		j = fsread(searchfd, buf, sizeof buf - 1);
 		if(j == 0){
			fprint(2, "[%s] search %s: no results found\n", mboxname, save);
			fsclose(searchfd);
			free(save);
			return 1;
		}
		free(save);
		buf[j] = '\0';
		res = estrdup(buf);
		j = fsread(searchfd, buf, sizeof buf - 1);
		for(; j != 0; j = fsread(searchfd, buf, sizeof buf - 1), buf[j] = '\0')
			res = eappend(res, "", buf);
		fsclose(searchfd);

		sbox = newwindow();
		winname(sbox, s);
		free(s);
		threadcreate(mainctl, sbox, STACK);
		winopenbody(sbox, OWRITE);

		/* show results in reverse order */
		m = mbox.tail;
		save = nil;
		for(s=strrchr(res, ' '); s!=nil || save!=res; s=strrchr(res, ' ')){
			if(s != nil){
				save = s+1;
				*s = '\0';
			}
			else save = res;
			save = estrstrdup(save, "/");
			for(; m && strcmp(save, m->name) != 0; m=m->prev);
			free(save);
			if(m == nil)
				break;
			fsprint(sbox->body, "%s%s\n", m->name, info(m, 0, 0));
			m = m->prev;
		}
		free(res);
		winclean(sbox);
		winclosebody(sbox);
		return 1;
	}
	return 0;
}
Exemple #17
0
int main(){
  int a, i;//カウンタ変数
  int phase[MAXNUMBER];//波の位相の配列
  int color[MAXNUMBER];//波の色の配列
  int droparray[MAXNUMBER];//落ちる水滴の配列
  float x;//円の中心x座標
  float y;//円の中心y座標
  float r[MAXNUMBER];//円の半径の配列
  float scale;//減衰のための係数
  float phasescale;//位相の減衰係数
  float sum;//波を足し合わせる関数
  int count;//カウント変数
  int offset;//波の相殺
  int flag;//フラグ変数

  win=gopen(800,800);/*画面表示*/
  winname(win,"final");/*題名*/
  phasescale = 0.25;
  flag = 0;

  /*水滴の描画*/
  for(a=0; a<=1; a++){
    for(i=0; i<=150; i++){
      background();//背景を描く関数
      if(a==1){
	newpen(win , 1);
	fillcirc(win, 270, 610, 6, 6);	/*葉っぱの先の水滴を描く*/
      }
      branch();//木の幹を書く関数
      rightleaf();//上側の葉っぱを描く関数
      underleaf();//下側の葉っぱを描く関数
      mainleaf();//メインの葉っぱを描く関数
      surfacewater();//水面を描く関数
      newpen(win, 1);
      fillcirc(win, 426-i, 761-i, 5, 5);  /*葉っぱの初期移動*/
      msleep(50);
    }
  }
  
  /*波の初期設定*/
  for(i=0; i < MAXNUMBER; i++){
    color[i] = 128;
    phase[i] = -1;
    droparray[i]=-1;
    r[i]=(MAXLENGTH / MAXNUMBER) * i;//円の半径初期化
  }

  x=300.0;
  y=300.0;
  
  layer(win, 0, 1); /*表示は 0 番、描画は 1 番レイヤーで*/
  /*波が非同期に落ちる*/
  while(1){
    background();//背景を描く関数
    /*葉っぱの先の水滴を描く*/
    newpen(win , 1);
    fillcirc(win, 270, 610, 6, 6);
    branch();//木の幹を描く関数
    rightleaf();//上側の葉っぱを描く関数
    underleaf();//下側の葉っぱを描く関数
    mainleaf();//メインの葉っぱを描く関数
    surfacewater();//水面を描く関数

    /*初期化*/
    color[0] = 0;
    sum = 0;
    count = 0;

    for(i=0; i < MAXNUMBER; i++){
      if(phase[i] >= 200){
	phase[i] = -1;
	flag = 1;
      }
      if(phase[i] != -1){
	scale = (MAXNUMBER - phase[i])*0.01;
	sum += 128*(sin(ENSHUU/MAXNUMBER-phasescale*phase[i])*scale);
	count++;
	msleep(3);
      }
    }
    
    if(count > 0){
      color[0] = sum / count + 128 - offset;
      if(flag == 1){
	offset += color[0] - color[1];
	flag = 0;
      } 
      if(offset > 0){
	offset--;
      }else if(offset < 0){
	offset++;
      }
    }


    if(color[0] == 0 || color[0] >= 255 ){
      color[0] = 128;
    }

    for(i=MAXNUMBER-1; i>0; i--){
      color[i]=color[i-1];
    }

    for(i=MAXNUMBER-1; i>=0; i--) {
      if( r[i] > 0.0 ) {
	newhsvcolor(win, 200, color[i], 255);
	fillcirc(win, x, y, r[i], r[i]); 
      }
    }

    if(drop(droparray) == 1){
      for(i=0; i<MAXNUMBER; i++){
	if(phase[i] == -1){
	  phase[i] = 0;
	  break;
	}
      }
    }

    for(i=0; i<=MAXNUMBER; i++){
      if(phase[i] != -1){
	phase[i]++;
      }
    }
    copylayer(win, 1, 0); /*レイヤー 1 番の内容を 0 にコピー*/
    msleep(40);
  }

  gclose(win);/*つける必要はないですけど開いたら閉じたかったのでつけました*/
 
 
  return 0;
}
Exemple #18
0
void	querywin::build_querywindow(widget *top)
{
	// Frames
	cstring	winname(path());

	nickframe = new frame(top, ".nickFrame");
	serverframe = new frame(top, ".serverFrame");
	miscframe = new frame(top, ".miscframe");

	queryframe = new frame(top, ".queryFrame", "-border 2");
	buttonframe = new frame(top, ".buttonFrame");

	nicklabel = new label(nickframe, ".nickLabel");
	serverlabel = new label(serverframe, ".serverLabel");
	misclabel = new label(miscframe, ".miscFrame");

	nicklabel->text("Nick  :");
	serverlabel->text("Server:");
	misclabel->text("Info  :");

	nickentry = new entry(nickframe, ".nickEntry", "-border 1");
	serverentry = new entry(serverframe, ".serverEntry", "-border 1");
	miscentry = new entry(miscframe, ".miscEntry", "-border 1");

	nickentry->configure("-state disabled");
	serverentry->configure("-state disabled");
	miscentry->configure("-state disabled");

	dcc_button = new checkbutton(miscframe, ".dccButton");
	dcc_button->text("dcc");
	if(has_dcc == active)
		dcc_button->select();

	chat_button = new checkbutton(miscframe, ".chatButton");
	chat_button->text("chat");

	autoraise = new checkbutton(miscframe, ".autoraiseCheck");
	autoraise->text("autoraise");

	query = new irctext(queryframe, ".queryText", "-width 80 -height 13");
	queryscroll = new scrollbar(queryframe, ".queryScroll");
	queryscroll->yview(query);
	query->yscroll(queryscroll);

	stopbutton = new plushButton(buttonframe, ".stopButton");
	stopbutton->image(img["tnt.gif"]);
	stopbutton->help_image(img["explode.gif"]);

	in = new plushHistEntry(buttonframe, ".queryIn");

	nicklabel->pack("-side left");
	serverlabel->pack("-side left");
	misclabel->pack("-side left");

	nickentry->pack("-side left -fill x -expand true");
	serverentry->pack("-side left -fill x -expand true");
	miscentry->pack("-side left -fill x -expand true");

	dcc_button->pack("-side left");
	chat_button->pack("-side left");
	autoraise->pack("-side left");

        stopbutton->pack("-side left");
	in->pack("-side left -expand true -fill x");

	query->configure("-state disabled");
	query->pack("-side left -fill both -expand true");
	queryscroll->pack("-side right -fill y -expand false");

	nickframe->pack("-fill x -expand false");
	serverframe->pack("-fill x -expand false");
	miscframe->pack("-fill x -expand false");
	queryframe->pack("-side top -fill both -expand true");
	buttonframe->pack("-side bottom -fill x -expand false");

	title("Conversation with " + person);
}
Exemple #19
0
void
mkreply(Message *m, char *label, char *to, Plumbattr *attr, char *quotetext)
{
	char buf[100];
	CFid *fd;
	Message *r;
	char *dir, *t;
	int quotereply;
	Plumbattr *a;

	quotereply = (label[0] == 'Q');
	
	if(quotereply && m && m->replywinid > 0){
		snprint(buf, sizeof buf, "%d/body", m->replywinid);
		if((fd = fsopen(acmefs, buf, OWRITE)) != nil){
			dir = estrstrdup(mbox.name, m->name);
			quote(m, fd, dir, quotetext);
			free(dir);
			return;
		}
	}
	
	r = emalloc(sizeof(Message));
	r->isreply = 1;
	if(m != nil)
		r->replyname = estrdup(m->name);
	r->next = replies.head;
	r->prev = nil;
	if(replies.head != nil)
		replies.head->prev = r;
	replies.head = r;
	if(replies.tail == nil)
		replies.tail = r;
	r->name = emalloc(strlen(mbox.name)+strlen(label)+10);
	sprint(r->name, "%s%s%d", mbox.name, label, ++replyid);
	r->w = newwindow();
	if(m)
		m->replywinid = r->w->id;
	winname(r->w, r->name);
	ctlprint(r->w->ctl, "cleartag");
	wintagwrite(r->w, "fmt Look Post Undo", 4+5+5+4);
	r->tagposted = 1;
	threadcreate(mesgctl, r, STACK);
	winopenbody(r->w, OWRITE);
	if(to!=nil && to[0]!='\0')
		fsprint(r->w->body, "%s\n", to);
	for(a=attr; a; a=a->next)
		fsprint(r->w->body, "%s: %s\n", a->name, a->value);
	dir = nil;
	if(m != nil){
		dir = estrstrdup(mbox.name, m->name);
		if(to == nil && attr == nil){
			/* Reply goes to replyto; Reply all goes to From and To and CC */
			if(strstr(label, "all") == nil)
				fsprint(r->w->body, "To: %s\n", m->replyto);
			else{	/* Replyall */
				if(strlen(m->from) > 0)
					fsprint(r->w->body, "To: %s\n", m->from);
				if(strlen(m->to) > 0)
					fsprint(r->w->body, "To: %s\n", m->to);
				if(strlen(m->cc) > 0)
					fsprint(r->w->body, "CC: %s\n", m->cc);
			}
		}
		if(strlen(m->subject) > 0){
			t = "Subject: Re: ";
			if(strlen(m->subject) >= 3)
				if(tolower(m->subject[0])=='r' && tolower(m->subject[1])=='e' && m->subject[2]==':')
					t = "Subject: ";
			fsprint(r->w->body, "%s%s\n", t, m->subject);
		}
		if(!quotereply){
			fsprint(r->w->body, "Include: %sraw\n", dir);
			free(dir);
		}
	}
	fsprint(r->w->body, "\n");
	if(m == nil)
		fsprint(r->w->body, "\n");
	else if(quotereply){
		quote(m, r->w->body, dir, quotetext);
		free(dir);
	}
	winclosebody(r->w);
	if(m==nil && (to==nil || to[0]=='\0'))
		winselect(r->w, "0", 0);
	else
		winselect(r->w, "$", 0);
	winclean(r->w);
	windormant(r->w);
}
Exemple #20
0
void
mesgsend(Message *m)
{
	char *s, *body, *to;
	int i, j, h, n, natt, p[2];
	struct Exec *e;
	Channel *sync;
	int first, nfld, delit, ofd;
	char *copy, *fld[100], *now;

	body = winreadbody(m->w, &n);
	/* assemble to: list from first line, to: line, and cc: line */
	nto = 0;
	natt = 0;
	ncc = 0;
	nbcc = 0;
	first = 1;
	to = body;
	for(;;){
		for(s=to; *s!='\n'; s++)
			if(*s == '\0'){
				free(body);
				return;
			}
		if(s++ == to)	/* blank line */
			break;
		/* make copy of line to tokenize */
		copy = emalloc(s-to);
		memmove(copy, to, s-to);
		copy[s-to-1] = '\0';
		nfld = tokenizec(copy, fld, nelem(fld), ", \t");
		if(nfld == 0){
			free(copy);
			break;
		}
		n -= s-to;
		switch(h = whichheader(fld[0])){
		case TO:
		case FROM:
			delit = 1;
			commas(to+strlen(fld[0]), s-1);
			for(i=1; i<nfld && nto<nelem(tolist); i++)
				if(!addressed(fld[i]))
					tolist[nto++] = estrdup(fld[i]);
			break;
		case BCC:
			delit = 1;
			commas(to+strlen(fld[0]), s-1);
			for(i=1; i<nfld && nbcc<nelem(bcclist); i++)
				if(!addressed(fld[i]))
					bcclist[nbcc++] = estrdup(fld[i]);
			break;
		case CC:
			delit = 1;
			commas(to+strlen(fld[0]), s-1);
			for(i=1; i<nfld && ncc<nelem(cclist); i++)
				if(!addressed(fld[i]))
					cclist[ncc++] = estrdup(fld[i]);
			break;
		case ATTACH:
		case INCLUDE:
			delit = 1;
			for(i=1; i<nfld && natt<nelem(attlist); i++){
				attlist[natt] = estrdup(fld[i]);
				included[natt++] = (h == INCLUDE);
			}
			break;
		default:
			if(first){
				delit = 1;
				for(i=0; i<nfld && nto<nelem(tolist); i++)
					tolist[nto++] = estrdup(fld[i]);
			}else	/* ignore it */
				delit = 0;
			break;
		}
		if(delit){
			/* delete line from body */
			memmove(to, s, n+1);
		}else
			to = s;
		free(copy);
		first = 0;
	}

	ofd = open(outgoing, OWRITE|OCEXEC);	/* no error check necessary */
	if(ofd > 0){
		/* From dhog Fri Aug 24 22:13:00 EDT 2001 */
		now = ctime(time(0));
		seek(ofd, 0, 2);
		fprint(ofd, "From %s %s", user, now);
		fprint(ofd, "From: %s\n", user);
		fprint(ofd, "Date: %s", now);
		for(i=0; i<natt; i++)
			if(included[i])
				fprint(ofd, "Include: %s\n", attlist[i]);
			else
				fprint(ofd, "Attach: %s\n", attlist[i]);
		/* needed because mail is by default Latin-1 */
		fprint(ofd, "Content-Type: text/plain; charset=\"UTF-8\"\n");
		fprint(ofd, "Content-Transfer-Encoding: 8bit\n");
	}

	e = emalloc(sizeof(struct Exec));
	if(pipe(p) < 0)
		error("can't create pipe: %r");
	e->p[0] = p[0];
	e->p[1] = p[1];
	e->prog = unsharp("#9/bin/upas/marshal");
	e->argv = emalloc((1+1+2+4*natt+1)*sizeof(char*));
	e->argv[0] = estrdup("marshal");
	e->argv[1] = estrdup("-8");
	j = 2;
	if(m->replyname){
		e->argv[j++] = estrdup("-R");
		e->argv[j++] = estrstrdup(mbox.name, m->replyname);
	}
	for(i=0; i<natt; i++){
		if(included[i])
			e->argv[j++] = estrdup("-A");
		else
			e->argv[j++] = estrdup("-a");
		e->argv[j++] = estrdup(attlist[i]);
	}
	sync = chancreate(sizeof(int), 0);
	e->sync = sync;
	proccreate(execproc, e, EXECSTACK);
	recvul(sync);
	/* close(p[0]); */

	/* using marshal -8, so generate rfc822 headers */
	if(nto > 0){
		print2(p[1], ofd, "To: ");
		for(i=0; i<nto-1; i++)
			print2(p[1], ofd, "%s, ", tolist[i]);
		print2(p[1], ofd, "%s\n", tolist[i]);
	}
	if(ncc > 0){
		print2(p[1], ofd, "CC: ");
		for(i=0; i<ncc-1; i++)
			print2(p[1], ofd, "%s, ", cclist[i]);
		print2(p[1], ofd, "%s\n", cclist[i]);
	}
	if(nbcc > 0){
		print2(p[1], ofd, "BCC: ");
		for(i=0; i<nbcc-1; i++)
			print2(p[1], ofd, "%s, ", bcclist[i]);
		print2(p[1], ofd, "%s\n", bcclist[i]);
	}

	i = strlen(body);
	if(i > 0)
		write2(p[1], ofd, body, i, 1);

	/* guarantee a blank line, to ensure attachments are separated from body */
	if(i==0 || body[i-1]!='\n')
		write2(p[1], ofd, "\n\n", 2, 0);
	else if(i>1 && body[i-2]!='\n')
		write2(p[1], ofd, "\n", 1, 0);

	/* these look like pseudo-attachments in the "outgoing" box */
	if(ofd>0 && natt>0){
		for(i=0; i<natt; i++)
			if(included[i])
				fprint(ofd, "=====> Include: %s\n", attlist[i]);
			else
				fprint(ofd, "=====> Attach: %s\n", attlist[i]);
	}
	if(ofd > 0)
		write(ofd, "\n", 1);

	for(i=0; i<natt; i++)
		free(attlist[i]);
	close(ofd);
	close(p[1]);
	free(body);

	if(m->replyname != nil)
		mesgmenumark(mbox.w, m->replyname, "\t[replied]");
	if(m->name[0] == '/')
		s = estrdup(m->name);
	else
		s = estrstrdup(mbox.name, m->name);
	s = egrow(s, "-R", nil);
	winname(m->w, s);
	free(s);
	winclean(m->w);
	/* mark message unopened because it's no longer the original message */
	m->opened = 0;
}
Exemple #21
0
int main()
{
  int win, i, j, k, m, key = 0;
  int arp[5] = { 0, 3, 1, 4, 2 }, ars[7] = {
  0, 5, 3, 1, 6, 4, 2};
  double pentagon[3][5], septagon[3][7], parab[3][144], y;

  win = gopen(L, L);
  window(win, -L / 2, -L / 2, L / 2, L / 2);
  gsetbgcolor(win, ECTRL_BGCOLOR);
  newcolor(win, ECTRL_FGCOLOR);
  winname(win, "e_3d demo");
  layer(win, 0, 1);
  gsetnonblock(ENABLE);
  i = j = m = 0;

  for (i = 0; i < 144; i++) {
    y = L/(2*144.0)*i;
    parab[0][i] = 0;
    parab[1][i] = -y;
    parab[2][i] = 0.02*y*(L/2 - y);
  }

  while (key != 'q') {
    g3dsetangle(torad(40 * (1.5 + sin(j * 2 * M_PI / 30))),
		i * 2 * M_PI / 144);
    gclr(win);

    for (k = 0; k < 5; k++) {
      pentagon[0][k] =
	  L / 6 * cos(arp[k] * 2 * M_PI / 5 + m * 2 * M_PI / 50) + L / 5;
      pentagon[1][k] =
	  L / 6 * sin(arp[k] * 2 * M_PI / 5 + m * 2 * M_PI / 50) + L / 5;
      pentagon[2][k] = 0;
    }
    for (k = 0; k < 7; k++) {
      septagon[0][k] =
	  L / 6 * cos(ars[k] * 2 * M_PI / 7 + 2 * m * 2 * M_PI / 50) -
	  L / 5;
      septagon[1][k] = 0;
      septagon[2][k] =
	  L / 6 * sin(ars[k] * 2 * M_PI / 7 + 2 * m * 2 * M_PI / 50) +
	  L / 5;
    }
    newcolor(win, "lightsteelblue");
    newlinestyle(win, LineOnOffDash);
    for(k = 0; k < 6; k++) {
      drawline3d(win, -L/10*k, 0, 0,  -L/10*k, -L/2, 0);
      drawline3d(win, 0, -L/10*k, 0,  -L/2, -L/10*k, 0);
    }
    newlinestyle(win, LineSolid);
    newcolor(win, "red4");
    fillpoly3d(win, pentagon[0], pentagon[1], pentagon[2], 5, 0);
    newcolor(win, "green4");
    fillpoly3d(win, septagon[0], septagon[1], septagon[2], 7, 0);
    newcolor(win, ECTRL_FGCOLOR);
    drawarrow3d(win, 0, 0, 0, 0, 0, L / 3, 10, 6, 12);
    drawarrow3d(win, 0, 0, 0, 0, L / 3, 0, 10, 6, 12);
    drawarrow3d(win, 0, 0, 0, L / 3, 0, 0, 10, 6, 12);
    newcolor(win, "gold3");
    drawstr3d(win, 0, 0, L/3+10, FONTSET, 0, "z¼´");
    drawlines3d(win, parab[0], parab[1], parab[2], 144);
    y = L/(2*36.0)*(i%36);
    putimg24m3d(win, 0 - 6 *(-sin(_phi) - cos(_th)*cos(_phi)), 
                     -y - 6*(cos(_phi) - cos(_th)*sin(_phi)), 
                0.02*y*(L/2 - y) -6*sin(_th), 12, 12, Xpm_image_stone6);
    copylayer(win, 1, 0);
    i++;
    i %= 144;
    j++;
    j %= 30;
    m++;
    m %= 50;
    msleep(40);
    key = ggetch();
  }
  gcloseall();
  return 0;
}