Ejemplo n.º 1
0
void show_weather()
{
	int i;
	for(i = 0; i < 8; i++)
	{
		put_line(1);
		put_line(6);
		footer();

		details(DAYS[i].day, DAYS[i].temp, DAYS[i].wind_f, DAYS[i].wind_d, DAYS[i].state, i);

		if(strcmp(DAYS[i].state, "SLONECZNIE"))
			put_image(slo1, slo2);
		else
		if(strcmp(DAYS[i].state, "PRZEWAZNIE SLONECZNIE"))
			put_image(prz_slo1, prz_slo2);
		else
		if(strcmp(DAYS[i].state, "ZMIENNE ZACHMURZENIE"))
			put_image(zach_zm1, zach_zm2);
		else
		if(strcmp(DAYS[i].state, "ZACHMURZENIE PELNE, SLABY DESZCZ"))
			put_image(sd1, sd2);

		ClearScreen();
	}
}
Ejemplo n.º 2
0
Archivo: tank.c Proyecto: d11/sdl_tank
// Render the entire screen
// (in the right order)
void render()
{   
	// Lock video surface (if needed)
	if (SDL_MUSTLOCK(screen)) 
		if (SDL_LockSurface(screen) < 0) 
			return;

	// Draw game objects to the screen
	draw_walls(screen, wal);
	draw_player(screen, &plr);
	draw_bots(screen, bot);
	draw_bullets(screen, bul);

	// Health bar
	int y, x;
	x = DISPLAY_WIDTH - 10 - plr.max_hp;
	for (y = DISPLAY_HEIGHT - 20; y < DISPLAY_HEIGHT - 10; y++)
	{
		put_line(screen, x, y, x + plr.hp, y, HEALTH_COLOR_GOOD);
		put_line(screen, x + plr.hp, y, DISPLAY_WIDTH - 10, y, HEALTH_COLOR_BAD);
	}

	// Unlock screen (if needed)
	if (SDL_MUSTLOCK(screen)) 
		SDL_UnlockSurface(screen);

	// Tell SDL to update the whole screen
	SDL_UpdateRect(screen, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT);    
}
Ejemplo n.º 3
0
int ff_ccitt_unpack(AVCodecContext *avctx, const uint8_t *src, int srcsize,
                    uint8_t *dst, int height, int stride,
                    enum TiffCompr compr, int opts)
{
    int j;
    BitstreamContext bc;
    int *runs, *ref = NULL, *runend;
    int ret;
    int runsize = avctx->width + 2;

    runs = av_malloc(runsize * sizeof(runs[0]));
    ref  = av_malloc(runsize * sizeof(ref[0]));
    if (!runs || !ref) {
        ret = AVERROR(ENOMEM);
        goto fail;
    }
    ref[0] = avctx->width;
    ref[1] = 0;
    ref[2] = 0;
    bitstream_init(&bc, src, srcsize * 8);
    for (j = 0; j < height; j++) {
        runend = runs + runsize;
        if (compr == TIFF_G4) {
            ret = decode_group3_2d_line(avctx, &bc, avctx->width, runs, runend,
                                        ref);
            if (ret < 0)
                goto fail;
        } else {
            int g3d1 = (compr == TIFF_G3) && !(opts & 1);
            if (compr != TIFF_CCITT_RLE &&
                find_group3_syncmarker(&bc, srcsize * 8) < 0)
                break;
            if (compr == TIFF_CCITT_RLE || g3d1 || bitstream_read_bit(&bc))
                ret = decode_group3_1d_line(avctx, &bc, avctx->width, runs,
                                            runend);
            else
                ret = decode_group3_2d_line(avctx, &bc, avctx->width, runs,
                                            runend, ref);
            if (compr == TIFF_CCITT_RLE)
                bitstream_align(&bc);
        }
        if (avctx->err_recognition & AV_EF_EXPLODE && ret < 0)
            goto fail;

        if (ret < 0) {
            put_line(dst, stride, avctx->width, ref);
        } else {
            put_line(dst, stride, avctx->width, runs);
            FFSWAP(int *, runs, ref);
        }
        dst += stride;
    }
    ret = 0;
fail:
    av_free(runs);
    av_free(ref);
    return ret;
}
Ejemplo n.º 4
0
int ff_ccitt_unpack(AVCodecContext *avctx,
                    const uint8_t *src, int srcsize,
                    uint8_t *dst, int height, int stride,
                    enum TiffCompr compr, int opts)
{
    int j;
    GetBitContext gb;
    int *runs, *ref = NULL, *runend;
    int ret;
    int runsize= avctx->width + 2;
    int err = 0;
    int has_eol;

    runs = av_malloc(runsize * sizeof(runs[0]));
    ref  = av_malloc(runsize * sizeof(ref[0]));
    if (!runs || ! ref) {
        err = AVERROR(ENOMEM);
        goto fail;
    }
    ref[0] = avctx->width;
    ref[1] = 0;
    ref[2] = 0;
    init_get_bits(&gb, src, srcsize*8);
    has_eol = show_bits(&gb, 12) == 1 || show_bits(&gb, 16) == 1;

    for(j = 0; j < height; j++){
        runend = runs + runsize;
        if(compr == TIFF_G4){
            ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref);
            if(ret < 0){
                err = -1;
                goto fail;
            }
        }else{
            int g3d1 = (compr == TIFF_G3) && !(opts & 1);
            if(compr!=TIFF_CCITT_RLE && has_eol && find_group3_syncmarker(&gb, srcsize*8) < 0)
                break;
            if(compr==TIFF_CCITT_RLE || g3d1 || get_bits1(&gb))
                ret = decode_group3_1d_line(avctx, &gb, avctx->width, runs, runend);
            else
                ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref);
            if(compr==TIFF_CCITT_RLE)
                align_get_bits(&gb);
        }
        if(ret < 0){
            put_line(dst, stride, avctx->width, ref);
        }else{
            put_line(dst, stride, avctx->width, runs);
            FFSWAP(int*, runs, ref);
        }
        dst += stride;
    }
fail:
    av_free(runs);
    av_free(ref);
    return err;
}
Ejemplo n.º 5
0
int main()
{
	LINE_LIST *ll = 
	//set_line("#define ssss(asdf, abcf) abd##tfs ## abcf##dc abcf\\");
	set_line("#define ssss(asdf, abcf) abcf\\");
	put_line(ll, "asdf##crt");
	put_line(ll, "#define rollrat rollratset");
	DEF_LIST *dl = parse_define(ll);
	char buf[999];
	replace_defines(dl, "asdxc ssss(crt, (s,t))asdf rollrat()", buf);
	printf(buf);
}
Ejemplo n.º 6
0
void
write_header(header the_header)
{
  register header old = the_header;
  do {
      register line_list the_list;
      for (the_list = the_header->text;
	   the_list != NIL;
	   the_list = the_list->continuation)
	put_line(the_list->string);
      the_header = the_header->next;
  } while (the_header != old);
  put_line ("");
  return;
}
Ejemplo n.º 7
0
void
java(const struct parser_param *param)
{
        char *ctags_x;

        assert(param->size >= sizeof(*param));

        if (op == NULL)
                start_ctags(param);

        /* Write path of input file to pipe. */
        fputs(param->file, op);
        putc('\n', op);
        fflush(op);

        /* Read output of ctags command. */
        for (;;) {
                ctags_x = get_line(param);
                if (ctags_x == NULL)
                        param->die("unexpected EOF.");
                if (strcmp(ctags_x, TERMINATOR) == 0)
                        break;
                put_line(ctags_x, param);
        }
}
Ejemplo n.º 8
0
void
parser(const struct parser_param *param)
{
	char *ctags_x;
	int filename_len;

	assert(param->size >= sizeof(*param));

	if (op == NULL)
		start_ctags(param);

	filename_len = strlen(param->file);

	handle_special_files(param, filename_len, ".xml", "xml:\t***");
	if (handle_special_files(param, filename_len, ".9.png", "9png:\t***") ||
	    handle_special_files(param, filename_len, ".png", "png:\t***")) {
		return;
	}		

	/* Write path of input file to pipe. */
	fputs(param->file, op);
	putc('\n', op);
	fflush(op);

	/* Read output of ctags command. */
	for (;;) {
		ctags_x = get_line(param);
		if (ctags_x == NULL)
			param->die("unexpected EOF.");
		if (strcmp(ctags_x, TERMINATOR) == 0)
			break;
		put_line(ctags_x, param);
	}
}
Ejemplo n.º 9
0
Archivo: wall.c Proyecto: d11/sdl_tank
// draw wall
void draw_wall(SDL_Surface *screen, Wall *w)
{
//	int i;
//	for (i = -2; i <= 2; i++)
//	{
    put_line(screen, w->end1.x, w->end1.y, w->end2.x, w->end2.y, 0xDDDDDD);
//	}
}
Ejemplo n.º 10
0
int ff_ccitt_unpack(AVCodecContext *avctx,
                       const uint8_t *src, int srcsize,
                       uint8_t *dst, int height, int stride, enum TiffCompr compr)
{
    int j;
    GetBitContext gb;
    int *runs, *ref, *runend;
    int ret;
    int runsize= avctx->width + 2;

    runs = av_malloc(runsize * sizeof(runs[0]));
    ref  = av_malloc(runsize * sizeof(ref[0]));
    ref[0] = avctx->width;
    ref[1] = 0;
    ref[2] = 0;
    init_get_bits(&gb, src, srcsize*8);
    for(j = 0; j < height; j++){
        runend = runs + runsize;
        if(compr == TIFF_G4){
            ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref);
            if(ret < 0){
                av_free(runs);
                av_free(ref);
                return -1;
            }
        }else{
            if(find_group3_syncmarker(&gb, srcsize*8) < 0)
                break;
            if(compr==TIFF_CCITT_RLE || get_bits1(&gb))
                ret = decode_group3_1d_line(avctx, &gb, avctx->width, runs, runend);
            else
                ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref);
        }
        if(ret < 0){
            put_line(dst, stride, avctx->width, ref);
        }else{
            put_line(dst, stride, avctx->width, runs);
            FFSWAP(int*, runs, ref);
        }
        dst += stride;
    }
    av_free(runs);
    av_free(ref);
    return 0;
}
Ejemplo n.º 11
0
int main() {
    // Render a cube from a perspective
    std::cout << "Rendering polygon mesh to .svg file";
    std::ofstream ofs("out.svg");
    const int width = 1920, height = 1080;
    ofs << "<svg version=\"1.1\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" "
           "xmlns=\"http://www.w3.org/2000/svg\" height=\""
        << height << "\" width=\"" << width << "\">" << std::endl;
    ofs << "<style> line{stroke:rgb(0, 0, 0); stroke-width:0.2;} </style>\n";

    alpha::math::Matrix44f world_to_cam{
        {-4.371138828673793e-08, 4.371138828673793e-08, 1.0, 4.814777374267578},
        {0.0, 1.0, -4.371138828673793e-08, 0.5494518280029297},
        {-1.0, -1.910685676922942e-15, -4.371138828673793e-08,
         1.4970126152038574},
        {0.0, 0.0, 0.0, 1.0}};
    world_to_cam.invert();
    world_to_cam.transpose();
    float aperture_width = 0.980, aperture_height = 0.735;
    float z_near = 0.1, z_far = 100, focal_length = 35.f;
    auto cam_inst = std::make_shared<alpha::Camera>(
        width, height, aperture_width, aperture_height, z_near, z_far,
        focal_length, world_to_cam);
    alpha::Rasteriser<> rast(cam_inst);
    // Now render the cube
    for (int i = 0; i < numtris; i++) {
        const auto v0 = vertices[3 * i];
        const auto v1 = vertices[3 * i + 1];
        const auto v2 = vertices[3 * i + 2];
        alpha::math::Vec3f v0_rast;
        alpha::math::Vec3f v1_rast;
        alpha::math::Vec3f v2_rast;
        cam_inst->convert_to_raster(v0, v0_rast);
        cam_inst->convert_to_raster(v1, v1_rast);
        cam_inst->convert_to_raster(v2, v2_rast);
        put_line(v0_rast, v1_rast, ofs);
        put_line(v1_rast, v2_rast, ofs);
        put_line(v2_rast, v0_rast, ofs);
    }
    ofs << "</svg>\n";
    std::cout << "\nDone. \n";
    ofs.close();
}
Ejemplo n.º 12
0
Archivo: contin.c Proyecto: rdebath/sgt
extern void end_hairpin(int stave) {
    int lwid, rwid;

    if (wrk.hairpins[stave].down)
	lwid = hairpin_width/2, rwid = 0;
    else
	lwid = 0, rwid = hairpin_width/2;

    put_line (wrk.hairpins[stave].x, wrk.hairpins[stave].ax,
	      stave_y(stave, STAVE_BOTTOM)-hairpin_yoff-lwid,
	      xpos, axpos, stave_y(stave, STAVE_BOTTOM)-hairpin_yoff-rwid,
	      thin_barline);
    put_line (wrk.hairpins[stave].x, wrk.hairpins[stave].ax,
	      stave_y(stave, STAVE_BOTTOM)-hairpin_yoff+lwid,
	      xpos, axpos, stave_y(stave, STAVE_BOTTOM)-hairpin_yoff+rwid,
	      thin_barline);

    wrk.hairpins[stave].exists = FALSE;
}
Ejemplo n.º 13
0
Archivo: contin.c Proyecto: rdebath/sgt
extern void end_eightva(int stave) {
    int sign = (wrk.eightva[stave].down ? -1 : 1);
    int end = (sign < 0 ? STAVE_BOTTOM : STAVE_TOP);
    int numpos = (sign < 0 ? 0 : -smalldigit_ht);

    put_symbol (wrk.eightva[stave].x + eightva_fwd, wrk.eightva[stave].ax,
		stave_y(stave, end) + sign*eightva_yoff + numpos,
		s_small8);
    put_line (wrk.eightva[stave].x + eightva_lstart, wrk.eightva[stave].ax,
	      stave_y(stave, end) + sign*eightva_yoff,
	      xpos - eightva_back, axpos,
	      stave_y(stave, end) + sign*eightva_yoff,
	      thin_barline);
    put_line (xpos - eightva_back, axpos,
	      stave_y(stave, end) + sign*eightva_yoff,
	      xpos - eightva_back, axpos,
	      stave_y(stave, end) + sign*(eightva_yoff-smalldigit_ht),
	      thin_barline);

    wrk.eightva[stave].exists = FALSE;
}
Ejemplo n.º 14
0
static void _fastcall restart_window(int wknum)
/* force a worklist entry to restart */
{   int yfrom,yto,xfrom,xto;
    if ((yfrom = worklist[wknum].yystart) < 0) yfrom = 0;
    if ((xfrom = worklist[wknum].xxstart) < 0) xfrom = 0;
    if ((yto = worklist[wknum].yystop) >= ydots) yto = ydots - 1;
    if ((xto = worklist[wknum].xxstop) >= xdots) xto = xdots - 1;
    memset(dstack,0,xdots); /* use dstack as a temp for the row; clear it */
    while (yfrom <= yto)
        put_line(yfrom++,xfrom,xto,(BYTE *)dstack);
    worklist[wknum].sym = worklist[wknum].pass = 0;
    worklist[wknum].yybegin = worklist[wknum].yystart;
}
Ejemplo n.º 15
0
void		show_alias(void)
{
	t_alias	*l_alias;

	if (!(l_alias = ft_my_sig_alias(NULL, 0)))
		ft_error_alias(NO_ALIAS, NULL);
	while (l_alias)
	{
		ft_putstr(l_alias->name);
		put_line();
		ft_putendl(l_alias->cmd);
		l_alias = l_alias->next;
	}
}
Ejemplo n.º 16
0
void
print_query(char *query, size_t length, size_t position, size_t scroll)
{
	size_t	i = 0;

	tty_putp(restore_cursor);
	put_line(query + scroll, length - scroll);

	tty_putp(restore_cursor);
	while (i < position - scroll) {
		while (isu8cont(query[++i]));
		tty_putp(cursor_right);
	}
}
Ejemplo n.º 17
0
static void _fastcall move_row(int fromrow,int torow,int col)
/* move a row on the screen */
{   int startcol,endcol,tocol;
    memset(dstack,0,xdots); /* use dstack as a temp for the row; clear it */
    if (fromrow >= 0 && fromrow < ydots) {
        tocol = startcol = 0;
        endcol = xdots-1;
        if (col < 0) {
            tocol -= col;
            endcol += col; }
        if (col > 0)
            startcol += col;
        get_line(fromrow,startcol,endcol,(BYTE *)&dstack[tocol]);
        }
    put_line(torow,0,xdots-1,(BYTE *)dstack);
    }
Ejemplo n.º 18
0
static int
pass_IfNode(void *self, Pass pass, int level, void *par)
{
   VAR(IfNode, np, self);
   int i;

   switch (pass)
   {
   case Print:
      fprintfOffs(stdout, level, "IfNode :\n");
      break;
   case PrintSrc:
      {
	 VAR(CodestrNode, cp, par);
	 VAR(StrBuf, out, cp->buf);
	 putString_StrBuf(out, "iif(");
	 for (i = 0; i < np->elseifs->count_of_Coll; i += 2)
	 {
		 VAR(Node, p, np->elseifs->items_of_Coll[i]);
		 VAR(Node, lp, np->elseifs->items_of_Coll[i + 1]);
	    p->pass(p, pass, level, par);
	    putString_StrBuf(out, ",");
	    lp->pass(lp, pass, level, par);
	 }
	 putString_StrBuf(out, ",");
	 if (np->elselist)
	    np->elselist->pass(np->elselist, pass, level, par);
	 putString_StrBuf(out, ")");
      }
      return 0;
   case CalcDeep:
      {
	 VAR(Function, fp, par);
	 addDeep(fp, 1);
      }
      break;
   case CText:
      {
	 VAR(FILE, out, par);
	 int no = np->labelNo;

	 int eno = no + np->elseifs->count_of_Coll / 2 + (np->elselist ? 0 : -1);

	 print_line(self, level, out);
	 for (i = 0; i < np->elseifs->count_of_Coll; i += 2)
	 {
		 VAR(Node, p, np->elseifs->items_of_Coll[i]);
		 VAR(Node, lp, np->elseifs->items_of_Coll[i + 1]);
	    p->pass(p, pass, level, par);
	    fprintfOffs(out, level, "if ((_ret=_clip_cond( _mp, &_if ))) goto _trap_%d;\n", np->node.seqNo);
	    fprintfOffs(out, level, "if ( !_if ) goto _endif_%d_%d;\n", no, loopPart);
	    lp->pass(lp, pass, level, par);
	    fprintfOffs(out, level, "goto _endif_%d_%d;\n", eno, loopPart);
	    fprintfOffs(out, level, "_endif_%d_%d:\n", no, loopPart);
	    ++no;
	 }
	 if (np->elselist)
	 {
	    np->elselist->pass(np->elselist, pass, level, par);
	    fprintfOffs(out, level, "_endif_%d_%d:\n", no, loopPart);
	 }
      }
      return 0;
   case OText:
      {
	 VAR(StrBuf, out, par);
	 int no;

	 int count = np->elseifs->count_of_Coll / 2 + (np->elselist ? 0 : -1);

	 int eoffs;

	 int *ejmps = (int *) malloc(sizeof(int) * (count + 1));

	 put_line(self, level, out);
	 for (i = 0, no = 0; i < np->elseifs->count_of_Coll; i += 2, ++no)
	 {
		 VAR(Node, p, np->elseifs->items_of_Coll[i]);
		 VAR(Node, lp, np->elseifs->items_of_Coll[i + 1]);
	    int jmp;

	    p->pass(p, pass, level, par);
	    putByte_StrBuf(out, CLIP_COND);
	    jmp = out->ptr_of_StrBuf - out->buf_of_StrBuf;
	    putShort_StrBuf(out, 0);
	    lp->pass(lp, pass, level, par);

	    if (no < count)
	    {
	       putByte_StrBuf(out, CLIP_GOTO);
	       ejmps[no] = out->ptr_of_StrBuf - out->buf_of_StrBuf;
	       putShort_StrBuf(out, 0);
	    }

	    SETSHORT(out, jmp, (out->ptr_of_StrBuf - out->buf_of_StrBuf) - (jmp + sizeof(short)));
	 }
	 if (np->elselist)
	 {
	    np->elselist->pass(np->elselist, pass, level, par);
	 }
	 eoffs = out->ptr_of_StrBuf - out->buf_of_StrBuf;
	 for (i = 0; i < count; ++i)
	 {
	    SETSHORT(out, ejmps[i], eoffs - (ejmps[i] + sizeof(short)));
	 }
	 free(ejmps);
      }
      return 0;
   case Traverse:
      {
	 VAR(TraversePar, tp, par);
	 tp->func((Node *) self, tp->par);
      }
      break;
   default:
      break;
   }
      for (i = 0; i < np->elseifs->count_of_Coll; i += 2)
   {
		VAR(Node, p, np->elseifs->items_of_Coll[i]);
		VAR(Node, lp, np->elseifs->items_of_Coll[i + 1]);
      p->pass(p, pass, level, par);
      lp->pass(lp, pass, level, par);
   }
   if (np->elselist)
      np->elselist->pass(np->elselist, pass, level, par);
   return 0;
}
Ejemplo n.º 19
0
main(int argc, char *argv[])
{
	FILE *out;
	struct task_struct task;
	struct thread_struct tss;
	struct pt_regs regs;
	if (!(out = fopen(argv[1], "w")))
	{
		fprintf(stderr, "Can't create output file: %s\n", strerror(errno));
		exit(1);
	}
	fprintf(out, "/*\n");
	fprintf(out, " * WARNING! This file is automatically generated - DO NOT EDIT!\n");
	fprintf(out, " */\n");
	put_line(out, "STATE", (int)&task.state-(int)&task);
	put_line(out, "COUNTER", (int)&task.counter-(int)&task);
	put_line(out, "BLOCKED", (int)&task.blocked-(int)&task);
	put_line(out, "SIGNAL", (int)&task.signal-(int)&task);
	put_line(out, "KERNEL_STACK_PAGE", (int)&task.kernel_stack_page-(int)&task);
	put_line(out, "TSS", (int)&task.tss-(int)&task);
	put_line(out, "KSP", (int)&tss.ksp-(int)&tss);
	put_line(out, "LAST_PC", (int)&tss.last_pc-(int)&tss);
	put_line(out, "USER_STACK", (int)&tss.user_stack-(int)&tss);
	put_line(out, "PT_REGS", (int)&tss.regs-(int)&tss);
	put_line(out, "PF_TRACESYS", PF_TRACESYS);
	put_line(out, "TASK_FLAGS", (int)&task.flags-(int)&task);
	put_line(out, "MMU_SEG0", (int)&tss.segs[0]-(int)&tss);
	put_line(out, "MMU_SEG1", (int)&tss.segs[1]-(int)&tss);
	put_line(out, "MMU_SEG2", (int)&tss.segs[2]-(int)&tss);
	put_line(out, "MMU_SEG3", (int)&tss.segs[3]-(int)&tss);
	put_line(out, "MMU_SEG4", (int)&tss.segs[4]-(int)&tss);
	put_line(out, "MMU_SEG5", (int)&tss.segs[5]-(int)&tss);
	put_line(out, "MMU_SEG6", (int)&tss.segs[6]-(int)&tss);
	put_line(out, "MMU_SEG7", (int)&tss.segs[7]-(int)&tss);
	put_line(out, "MMU_SEG8", (int)&tss.segs[8]-(int)&tss);
	put_line(out, "MMU_SEG9", (int)&tss.segs[9]-(int)&tss);
	put_line(out, "MMU_SEG10", (int)&tss.segs[10]-(int)&tss);
	put_line(out, "MMU_SEG11", (int)&tss.segs[11]-(int)&tss);
	put_line(out, "MMU_SEG12", (int)&tss.segs[12]-(int)&tss);
	put_line(out, "MMU_SEG13", (int)&tss.segs[13]-(int)&tss);
	put_line(out, "MMU_SEG14", (int)&tss.segs[14]-(int)&tss);
	put_line(out, "MMU_SEG15", (int)&tss.segs[15]-(int)&tss);
	put_line(out, "TSS_FPR0", (int)&tss.fpr[0]-(int)&tss);
	put_line(out, "TSS_FPR1", (int)&tss.fpr[1]-(int)&tss);
	put_line(out, "TSS_FPR2", (int)&tss.fpr[2]-(int)&tss);
	put_line(out, "TSS_FPR3", (int)&tss.fpr[3]-(int)&tss);
	put_line(out, "TSS_FPR4", (int)&tss.fpr[4]-(int)&tss);
	put_line(out, "TSS_FPR5", (int)&tss.fpr[5]-(int)&tss);
	put_line(out, "TSS_FPR6", (int)&tss.fpr[6]-(int)&tss);
	put_line(out, "TSS_FPR7", (int)&tss.fpr[7]-(int)&tss);
	put_line(out, "TSS_FPR8", (int)&tss.fpr[8]-(int)&tss);
	put_line(out, "TSS_FPR9", (int)&tss.fpr[9]-(int)&tss);
	put_line(out, "TSS_FPR10", (int)&tss.fpr[10]-(int)&tss);
	put_line(out, "TSS_FPR11", (int)&tss.fpr[11]-(int)&tss);
	put_line(out, "TSS_FPR12", (int)&tss.fpr[12]-(int)&tss);
	put_line(out, "TSS_FPR13", (int)&tss.fpr[13]-(int)&tss);
	put_line(out, "TSS_FPR14", (int)&tss.fpr[14]-(int)&tss);
	put_line(out, "TSS_FPR15", (int)&tss.fpr[15]-(int)&tss);
	put_line(out, "TSS_FPR16", (int)&tss.fpr[16]-(int)&tss);
	put_line(out, "TSS_FPR17", (int)&tss.fpr[17]-(int)&tss);
	put_line(out, "TSS_FPR18", (int)&tss.fpr[18]-(int)&tss);
	put_line(out, "TSS_FPR19", (int)&tss.fpr[19]-(int)&tss);
	put_line(out, "TSS_FPR20", (int)&tss.fpr[20]-(int)&tss);
	put_line(out, "TSS_FPR21", (int)&tss.fpr[21]-(int)&tss);
	put_line(out, "TSS_FPR22", (int)&tss.fpr[22]-(int)&tss);
	put_line(out, "TSS_FPR23", (int)&tss.fpr[23]-(int)&tss);
	put_line(out, "TSS_FPR24", (int)&tss.fpr[24]-(int)&tss);
	put_line(out, "TSS_FPR25", (int)&tss.fpr[25]-(int)&tss);
	put_line(out, "TSS_FPR26", (int)&tss.fpr[26]-(int)&tss);
	put_line(out, "TSS_FPR27", (int)&tss.fpr[27]-(int)&tss);
	put_line(out, "TSS_FPR28", (int)&tss.fpr[28]-(int)&tss);
	put_line(out, "TSS_FPR29", (int)&tss.fpr[29]-(int)&tss);
	put_line(out, "TSS_FPR30", (int)&tss.fpr[30]-(int)&tss);
	put_line(out, "TSS_FPR31", (int)&tss.fpr[31]-(int)&tss);
	/* Interrupt register frame */
	put_line(out, "INT_FRAME_SIZE", sizeof(regs));
	put_line(out, "GPR0", (int)&regs.gpr[0]-(int)&regs);
	put_line(out, "GPR1", (int)&regs.gpr[1]-(int)&regs);
	put_line(out, "GPR2", (int)&regs.gpr[2]-(int)&regs);
	put_line(out, "GPR3", (int)&regs.gpr[3]-(int)&regs);
	put_line(out, "GPR4", (int)&regs.gpr[4]-(int)&regs);
	put_line(out, "GPR5", (int)&regs.gpr[5]-(int)&regs);
	put_line(out, "GPR6", (int)&regs.gpr[6]-(int)&regs);
	put_line(out, "GPR7", (int)&regs.gpr[7]-(int)&regs);
	put_line(out, "GPR8", (int)&regs.gpr[8]-(int)&regs);
	put_line(out, "GPR9", (int)&regs.gpr[9]-(int)&regs);
	put_line(out, "GPR10", (int)&regs.gpr[10]-(int)&regs);
	put_line(out, "GPR11", (int)&regs.gpr[11]-(int)&regs);
	put_line(out, "GPR12", (int)&regs.gpr[12]-(int)&regs);
	put_line(out, "GPR13", (int)&regs.gpr[13]-(int)&regs);
	put_line(out, "GPR14", (int)&regs.gpr[14]-(int)&regs);
	put_line(out, "GPR15", (int)&regs.gpr[15]-(int)&regs);
	put_line(out, "GPR16", (int)&regs.gpr[16]-(int)&regs);
	put_line(out, "GPR17", (int)&regs.gpr[17]-(int)&regs);
	put_line(out, "GPR18", (int)&regs.gpr[18]-(int)&regs);
	put_line(out, "GPR19", (int)&regs.gpr[19]-(int)&regs);
	put_line(out, "GPR20", (int)&regs.gpr[20]-(int)&regs);
	put_line(out, "GPR21", (int)&regs.gpr[21]-(int)&regs);
	put_line(out, "GPR22", (int)&regs.gpr[22]-(int)&regs);
	put_line(out, "GPR23", (int)&regs.gpr[23]-(int)&regs);
	put_line(out, "GPR24", (int)&regs.gpr[24]-(int)&regs);
	put_line(out, "GPR25", (int)&regs.gpr[25]-(int)&regs);
	put_line(out, "GPR26", (int)&regs.gpr[26]-(int)&regs);
	put_line(out, "GPR27", (int)&regs.gpr[27]-(int)&regs);
	put_line(out, "GPR28", (int)&regs.gpr[28]-(int)&regs);
	put_line(out, "GPR29", (int)&regs.gpr[29]-(int)&regs);
	put_line(out, "GPR30", (int)&regs.gpr[30]-(int)&regs);
	put_line(out, "GPR31", (int)&regs.gpr[31]-(int)&regs);
	put_line(out, "FPR0", (int)&regs.fpr[0]-(int)&regs);
	put_line(out, "FPR1", (int)&regs.fpr[1]-(int)&regs);
	put_line(out, "FPR2", (int)&regs.fpr[2]-(int)&regs);
	put_line(out, "FPR3", (int)&regs.fpr[3]-(int)&regs);
	put_line(out, "FPCSR", (int)&regs.fpcsr-(int)&regs);
	/* Note: these symbols include "_" because they overlap with special register names */
	put_line(out, "_NIP", (int)&regs.nip-(int)&regs);
	put_line(out, "_MSR", (int)&regs.msr-(int)&regs);
	put_line(out, "_CTR", (int)&regs.ctr-(int)&regs);
	put_line(out, "_LINK", (int)&regs.link-(int)&regs);
	put_line(out, "_CCR", (int)&regs.ccr-(int)&regs);
	put_line(out, "_XER", (int)&regs.xer-(int)&regs);
	put_line(out, "_DAR", (int)&regs.dar-(int)&regs);
	put_line(out, "_DSISR", (int)&regs.dsisr-(int)&regs);
	put_line(out, "_HASH1", (int)&regs.hash1-(int)&regs);
	put_line(out, "_HASH2", (int)&regs.hash2-(int)&regs);
	put_line(out, "_IMISS", (int)&regs.imiss-(int)&regs);
	put_line(out, "_DMISS", (int)&regs.dmiss-(int)&regs);
	put_line(out, "_ICMP", (int)&regs.icmp-(int)&regs);
	put_line(out, "_DCMP", (int)&regs.dcmp-(int)&regs);
	put_line(out, "ORIG_GPR3", (int)&regs.orig_gpr3-(int)&regs);
	put_line(out, "RESULT", (int)&regs.result-(int)&regs);
	put_line(out, "TRAP", (int)&regs.trap-(int)&regs);
	put_line(out, "MARKER", (int)&regs.marker-(int)&regs);
	exit(0);
}
Ejemplo n.º 20
0
static int
pass_ForNode(void *self, Pass pass, int level, void *par)
{
   VAR(ForNode, np, self);
   switch (pass)
   {
   case Print:
      fprintfOffs(stdout, level, "ForNode :\n");
      break;
   case PrintSrc:
      {
	 yyerror("%s not allowed in CODESTR", np->node.name);
      }
      return 0;
   case CalcDeep:
      break;
   case CText:
      {
	 VAR(FILE, out, par);
	 int no = np->labelNo;

	 int saveNo = loopNo;

	 print_line(self, level, out);
	 loopPart = 0;
	 np->init->pass(np->init, pass, level, par);
	 np->to->pass(np->to, pass, level, par);
	 np->step->pass(np->step, pass, level, par);

	 fprintfOffs(out, level, "if ((_ret=_clip_forstep( _mp, &_if ))) goto _trap_%d;\n", np->node.seqNo);
	 fprintfOffs(out, level, "if ( !_if ) goto _endloop_%d;\n", no);

	 fprintfOffs(out, level, "goto _lbeg_%d;\n", no);

	 fprintfOffs(out, level, "_loop_%d:\n", no);
	 loopPart = 1;
	 np->var->pass(np->var, pass, level, par);
	 np->to->pass(np->to, pass, level, par);
	 np->step->pass(np->step, pass, level, par);
	 loopPart = 0;

	 fprintfOffs(out, level, "if ((_ret=_clip_forstep( _mp, &_if ))) goto _trap_%d;\n", np->node.seqNo);
	 fprintfOffs(out, level, "if ( !_if ) goto _endloop_%d;\n", no);

	 fprintfOffs(out, level, "_lbeg_%d:\n", no);

	 loopNo = no;
	 np->list->pass(np->list, pass, level, par);

	 fprintfOffs(out, level, "goto _loop_%d;\n", no);
	 fprintfOffs(out, level, "_endloop_%d:\n", no);
	 loopNo = saveNo;
      }
      return 0;
   case OText:
      {
	 VAR(StrBuf, out, par);
	 int jmp, eoffs, ibeg, lbeg, boffs;

	 LoopData ld;

	 put_line(self, level, out);
	 np->init->pass(np->init, pass, level, par);
	 np->to->pass(np->to, pass, level, par);
	 np->step->pass(np->step, pass, level, par);
	 putByte_StrBuf(out, CLIP_FORSTEP);
	 ibeg = out->ptr_of_StrBuf - out->buf_of_StrBuf;
	 putShort_StrBuf(out, 0);

	 putByte_StrBuf(out, CLIP_GOTO);
	 lbeg = out->ptr_of_StrBuf - out->buf_of_StrBuf;
	 putShort_StrBuf(out, 0);

	 boffs = out->ptr_of_StrBuf - out->buf_of_StrBuf;
	 put_line(self, level, out);
	 np->var->pass(np->var, pass, level, par);
	 np->to->pass(np->to, pass, level, par);
	 np->step->pass(np->step, pass, level, par);
	 putByte_StrBuf(out, CLIP_FORSTEP);
	 jmp = out->ptr_of_StrBuf - out->buf_of_StrBuf;
	 putShort_StrBuf(out, 0);

	 SETSHORT(out, lbeg, (out->ptr_of_StrBuf - out->buf_of_StrBuf) - (lbeg + sizeof(short)));

	 np->list->pass(np->list, pass, level, par);

	 putByte_StrBuf(out, CLIP_GOTO);
	 eoffs = (out->ptr_of_StrBuf - out->buf_of_StrBuf) + sizeof(short);
	 putShort_StrBuf(out, boffs - eoffs);

	 SETSHORT(out, jmp, eoffs - (jmp + sizeof(short)));
	 SETSHORT(out, ibeg, eoffs - (ibeg + sizeof(short)));

	 ld.StrBuf_out_of_LoopData = out;
	 ld.boffs_of_LoopData = boffs;
	 ld.eoffs_of_LoopData = eoffs;
	 np->list->pass(np->list, OTextLoop, level, &ld);
      }
      return 0;
   case Traverse:
      {
	 VAR(TraversePar, tp, par);
	 tp->func((Node *) self, tp->par);
      }
      break;
   default:
      break;
   }

   np->init->pass(np->init, pass, level, par);
   np->step->pass(np->step, pass, level, par);
   np->var->pass(np->var, pass, level, par);
   np->to->pass(np->to, pass, level, par);
   np->list->pass(np->list, pass, level, par);

   return 0;
}
Ejemplo n.º 21
0
/* returns the length of the reply string */
int parse_command (socket_t* socket, char* line) 
{    
    unsigned int start_addr;
    unsigned int address;
    unsigned int range;
    int len, error = 0;
    
    /* All commands are just a single character.
       Just ignore anything else  */
    switch (line[0]) {
        /* Disconnect */
        case 'e':
        case 'x':
        case 'q':  
            socket->tcp_disconnect = 1;
            return 0;
            
        case 'r': /* Read mem */    
            {
            if (len = get_hex (&line[2], &start_addr)) { 
                if (len = get_hex (&line[3+len], &range)) {
                    for (address=start_addr; address<start_addr+range; address+=4) {
                        put_line (socket->telnet_txbuf, "0x%08x 0x%08x\r\n", 
                                    address, *(unsigned int *)address);
                        }
                    }
                else {
                    put_line (socket->telnet_txbuf, "0x%08x 0x%08x\r\n", 
                                    start_addr, *(unsigned int *)start_addr);
                    }
                }
            else 
                error=1;
            break;                
            }
                

        case 'h': {/* Help */    
            put_line (socket->telnet_txbuf, "You need help alright\r\n");
            break;                
            }

            
        case 's': {/* Status */    
            put_line (socket->telnet_txbuf, "Socket ID           %d\r\n", socket->id);
            put_line (socket->telnet_txbuf, "Packets received    %d\r\n", socket->packets_received);
            put_line (socket->telnet_txbuf, "Packets transmitted %d\r\n", socket->packets_sent);
            put_line (socket->telnet_txbuf, "Packets resent      %d\r\n", socket->packets_resent);
            put_line (socket->telnet_txbuf, "TCP checksum errors %d\r\n", tcp_checksum_errors_g);
            
            put_line (socket->telnet_txbuf, "Counterparty IP %d.%d.%d.%d\r\n",
                socket->rx_packet->src_ip[0],
                socket->rx_packet->src_ip[1],
                socket->rx_packet->src_ip[2],
                socket->rx_packet->src_ip[3]);
            
            put_line (socket->telnet_txbuf, "Counterparty Port %d\r\n",
                socket->rx_packet->tcp_src_port);
                
            put_line (socket->telnet_txbuf, "Malloc pointer 0x%08x\r\n",
                *(unsigned int *)(ADR_MALLOC_POINTER));
            put_line (socket->telnet_txbuf, "Malloc count %d\r\n",
                *(unsigned int *)(ADR_MALLOC_COUNT));
            put_line (socket->telnet_txbuf, "Uptime %d seconds\r\n", current_time_g->seconds);
            break;
            }
            
            
        default: {
            error=1; break;
            }                
        }
        
    
    if (error)
            put_line (socket->telnet_txbuf, "You're not making any sense\r\n", 
                        line[0], line[1], line[2]);
     
    put_line (socket->telnet_txbuf, "> ");
    return 0;
}
Ejemplo n.º 22
0
int main P2C(int,argc,string*,argv)
#line 104 "./ctie.w"
{
#line 38 "./ctie-k.ch"
/*5:*/
#line 84 "./ctie-k.ch"

kpse_set_program_name(argv[0],"ctie");

/*:5*/
#line 38 "./ctie-k.ch"
;
/*19:*/
#line 300 "./ctie.w"

actual_input= 0;
out_mode= normal;

/*:19*/
#line 39 "./ctie-k.ch"
;
#line 106 "./ctie.w"
/*63:*/
#line 1135 "./ctie.w"

{
if(argc> max_file_index+5-1)usage_error();
no_ch= -1;
while(--argc> 0){
argv++;
if(strcmp("-help",*argv)==0||strcmp("--help",*argv)==0)
/*66:*/
#line 1202 "./ctie.w"

usage_help();



/*:66*/
#line 1142 "./ctie.w"
;
if(strcmp("-version",*argv)==0||strcmp("--version",*argv)==0)
/*67:*/
#line 1208 "./ctie.w"

{
print_version_and_exit("CTIE",version_number);

}


/*:67*/
#line 1144 "./ctie.w"
;
if(**argv=='-')/*64:*/
#line 1158 "./ctie.w"

if(prod_chf!=unknown)usage_error();
else
switch(*(*argv+1)){
case'c':case'C':prod_chf= chf;break;
case'm':case'M':prod_chf= master;break;
default:usage_error();
}


/*:64*/
#line 1145 "./ctie.w"

else/*65:*/
#line 1172 "./ctie.w"

{
if(no_ch==(-1)){
out_name= *argv;
}else{
register input_description*inp_desc;

inp_desc= (input_description*)malloc(sizeof(input_description));
if(inp_desc==NULL)
fatal_error(-1,"! No memory for input descriptor","");

inp_desc->mode= search;
inp_desc->line= 0;
inp_desc->type_of_file= chf;
inp_desc->limit= inp_desc->buffer;
inp_desc->buffer[0]= ' ';
inp_desc->loc= inp_desc->buffer+1;
inp_desc->buffer_end= inp_desc->buffer+buf_size-2;
inp_desc->file_name= *argv;
inp_desc->current_include= NULL;
input_organisation[no_ch]= inp_desc;
}
no_ch++;
}


/*:65*/
#line 1146 "./ctie.w"

}
if(no_ch<=0||prod_chf==unknown)usage_error();
}


/*:63*/
#line 106 "./ctie.w"

/*62:*/
#line 1118 "./ctie.w"

#line 382 "./ctie-k.ch"
{
extern KPSEDLL string kpathsea_version_string;
printf("%s (%s)\n",banner,kpathsea_version_string);
}
#line 1120 "./ctie.w"
printf("%s\n",copyright);


/*:62*/
#line 107 "./ctie.w"
;
/*42:*/
#line 277 "./ctie-k.ch"

{
string fullname;

fullname= kpse_find_cweb(input_organisation[0]->file_name);
if(fullname)
input_organisation[0]->the_file= fopen(fullname,"r");

if(fullname==NULL||input_organisation[0]->the_file==NULL){
if(fullname){
pfatal_error("! Cannot open master file ",
input_organisation[0]->file_name);
}else{
fatal_error(-1,"! Cannot find master file ",
input_organisation[0]->file_name);
}
}
else free(fullname);


#line 759 "./ctie.w"
printf("(%s)\n",input_organisation[0]->file_name);
input_organisation[0]->type_of_file= master;
get_line(0,true);
}


/*:42*/
#line 108 "./ctie.w"

/*43:*/
#line 313 "./ctie-k.ch"

{
file_index i;
string fullname;

i= 1;
while(i<no_ch){
fullname= kpse_find_cweb(input_organisation[i]->file_name);
if(fullname)
input_organisation[i]->the_file= fopen(fullname,"r");

if(fullname==NULL||input_organisation[i]->the_file==NULL){
if(fullname){
pfatal_error("! Cannot open change file ",
input_organisation[i]->file_name);
}else{
fatal_error(-1,"! Cannot find change file ",
input_organisation[i]->file_name);
}
}
else free(fullname);


#line 780 "./ctie.w"
printf("(%s)\n",input_organisation[i]->file_name);
init_change_file(i);
i++;
}
}


/*:43*/
#line 109 "./ctie.w"

/*40:*/
#line 729 "./ctie.w"

{
out_file= fopen(out_name,"w");
if(out_file==NULL){
pfatal_error("! Cannot open/create output file","");

}
}


/*:40*/
#line 110 "./ctie.w"

/*59:*/
#line 1074 "./ctie.w"

actual_input= 0;
input_has_ended= false;
while(input_has_ended==false||actual_input!=0)
/*51:*/
#line 917 "./ctie.w"

{
file_index test_file;

/*52:*/
#line 934 "./ctie.w"

{
register input_description*inp_desc;
while(actual_input> 0&&e_of_ch_module(actual_input)){
inp_desc= input_organisation[actual_input];
if(inp_desc->type_of_file==master){

fatal_error(-1,"! This can't happen: change file is master file","");

}
inp_desc->mode= search;
init_change_file(actual_input);
while((input_organisation[actual_input]->mode!=reading
&&actual_input> 0))
actual_input--;
}
}


/*:52*/
#line 921 "./ctie.w"

if(input_has_ended&&actual_input==0)break;
/*53:*/
#line 960 "./ctie.w"

test_input= none;
test_file= actual_input;
while(test_input==none&&test_file<no_ch-1){
test_file++;
switch(input_organisation[test_file]->mode){
case search:
if(lines_dont_match(actual_input,test_file)==false){
input_organisation[test_file]->mode= test;
test_input= test_file;
}
break;
case test:
if(lines_dont_match(actual_input,test_file)){

input_organisation[test_file]->dont_match++;
}
test_input= test_file;
break;
case reading:
break;
case ignore:
break;
}
}


/*:53*/
#line 923 "./ctie.w"

/*54:*/
#line 993 "./ctie.w"

if(prod_chf==chf){
while(1){
/*55:*/
#line 1007 "./ctie.w"

if(out_mode==normal){
if(test_input!=none){
fprintf(out_file,"@x\n");
out_mode= pre;
}else break;
}


/*:55*/
#line 996 "./ctie.w"

/*56:*/
#line 1021 "./ctie.w"

if(out_mode==pre){
if(test_input==none){
fprintf(out_file,"@y\n");
out_mode= post;
}else{
if(input_organisation[actual_input]->type_of_file==master)
put_line(actual_input);
break;
}
}


/*:56*/
#line 997 "./ctie.w"

/*57:*/
#line 1040 "./ctie.w"

if(out_mode==post){
if(input_organisation[actual_input]->type_of_file==chf){
if(test_input==none)put_line(actual_input);
break;
}else{
fprintf(out_file,"@z\n\n");
out_mode= normal;
}
}


/*:57*/
#line 998 "./ctie.w"

}
}else
if(test_input==none)put_line(actual_input);


/*:54*/
#line 924 "./ctie.w"

/*58:*/
#line 1055 "./ctie.w"

get_line(actual_input,true);
if(test_input!=none){
get_line(test_input,true);
if(e_of_ch_preamble(test_input)==true){
get_line(test_input,true);
input_organisation[test_input]->mode= reading;
actual_input= test_input;
test_input= none;
}
}


/*:58*/
#line 925 "./ctie.w"

}


/*:51*/
#line 1078 "./ctie.w"

if(out_mode==post)
fprintf(out_file,"@z\n");


/*:59*/
#line 111 "./ctie.w"

/*60:*/
#line 1087 "./ctie.w"

{
file_index i;

for(i= 1;i<no_ch;i++){
if(input_organisation[i]->mode!=ignore){
input_organisation[i]->loc= input_organisation[i]->buffer;
err_print(i,"! Change file entry did not match");

}
}
}


/*:60*/
#line 112 "./ctie.w"

exit(wrap_up());
}
Ejemplo n.º 23
0
int main P2C(int,argc,string*,argv)
#line 1238 "../../../texk/web2c/tiedir/tie.w"
{{/*12:*/
#line 408 "../../../texk/web2c/tiedir/tie.w"

int i;


/*:12*/
#line 1238 "../../../texk/web2c/tiedir/tie.w"

/*10:*/
#line 296 "../../../texk/web2c/tiedir/tie.w"

xchr[32]= ' ';
xchr[33]= '!';
xchr[34]= '\"';
xchr[35]= '#';
xchr[36]= '$';
xchr[37]= '%';
xchr[38]= '&';
xchr[39]= '\'';
xchr[40]= '(';
xchr[41]= ')';
xchr[42]= '*';
xchr[43]= '+';
xchr[44]= ',';
xchr[45]= '-';
xchr[46]= '.';
xchr[47]= '/';
xchr[48]= '0';
xchr[49]= '1';
xchr[50]= '2';
xchr[51]= '3';
xchr[52]= '4';
xchr[53]= '5';
xchr[54]= '6';
xchr[55]= '7';
xchr[56]= '8';
xchr[57]= '9';
xchr[58]= ':';
xchr[59]= ';';
xchr[60]= '<';
xchr[61]= '=';
xchr[62]= '>';
xchr[63]= '?';
xchr[64]= '@';
xchr[65]= 'A';
xchr[66]= 'B';
xchr[67]= 'C';
xchr[68]= 'D';
xchr[69]= 'E';
xchr[70]= 'F';
xchr[71]= 'G';
xchr[72]= 'H';
xchr[73]= 'I';
xchr[74]= 'J';
xchr[75]= 'K';
xchr[76]= 'L';
xchr[77]= 'M';
xchr[78]= 'N';
xchr[79]= 'O';
xchr[80]= 'P';
xchr[81]= 'Q';
xchr[82]= 'R';
xchr[83]= 'S';
xchr[84]= 'T';
xchr[85]= 'U';
xchr[86]= 'V';
xchr[87]= 'W';
xchr[88]= 'X';
xchr[89]= 'Y';
xchr[90]= 'Z';
xchr[91]= '[';
xchr[92]= '\\';
xchr[93]= ']';
xchr[94]= '^';
xchr[95]= '_';
xchr[96]= '`';
xchr[97]= 'a';
xchr[98]= 'b';
xchr[99]= 'c';
xchr[100]= 'd';
xchr[101]= 'e';
xchr[102]= 'f';
xchr[103]= 'g';
xchr[104]= 'h';
xchr[105]= 'i';
xchr[106]= 'j';
xchr[107]= 'k';
xchr[108]= 'l';
xchr[109]= 'm';
xchr[110]= 'n';
xchr[111]= 'o';
xchr[112]= 'p';
xchr[113]= 'q';
xchr[114]= 'r';
xchr[115]= 's';
xchr[116]= 't';
xchr[117]= 'u';
xchr[118]= 'v';
xchr[119]= 'w';
xchr[120]= 'x';
xchr[121]= 'y';
xchr[122]= 'z';
xchr[123]= '{';
xchr[124]= '|';
xchr[125]= '}';
xchr[126]= '~';
xchr[0]= ' ';xchr[0x7F]= ' ';


/*:10*//*13:*/
#line 429 "../../../texk/web2c/tiedir/tie.w"

for(i= 1;i<32;xchr[i++]= ' ');
xchr[tab_mark]= '\t';
xchr[form_feed]= '\f';
xchr[nl_mark]= '\n';


/*:13*//*14:*/
#line 440 "../../../texk/web2c/tiedir/tie.w"

for(i= first_text_char;i<=last_text_char;xord[i++]= 32)do_nothing;
for(i= 1;i<=126;i++)xord[xchr[i]]= i;





/*:14*/
#line 1239 "../../../texk/web2c/tiedir/tie.w"

}
#line 106 "../../../texk/web2c/tiedir/tie-w2c.ch"
print(banner);
print_ln(versionstring);
print_ln(copyright);
#line 1243 "../../../texk/web2c/tiedir/tie.w"
actual_input= 0;
out_mode= normal;
/*56:*/
#line 1177 "../../../texk/web2c/tiedir/tie.w"

{int act_arg;
if(argc<5||argc> max_file_index+4-1)usage();
no_ch= -1;
for(act_arg= 1;act_arg<argc;act_arg++){
if(argv[act_arg][0]=='-')/*57:*/
#line 1195 "../../../texk/web2c/tiedir/tie.w"

if(prod_chf!=unknown)usage();
else
switch(argv[act_arg][1]){
case'c':
case'C':prod_chf= chf;break;
case'm':
case'M':prod_chf= master;break;
default:usage();
}


/*:57*/
#line 1182 "../../../texk/web2c/tiedir/tie.w"

else/*58:*/
#line 1211 "../../../texk/web2c/tiedir/tie.w"

{if(no_ch==(-1)){
out_name= argv[act_arg];
}else{register input_description*inp_desc;
inp_desc= (input_description*)
malloc(sizeof(input_description));
if(inp_desc==NULL)
fatal_error("! No memory for descriptor");

inp_desc->mode= search;
inp_desc->line= 0;
inp_desc->type_of_file= chf;
inp_desc->limit= 0;
inp_desc->name_of_file= argv[act_arg];
input_organization[no_ch]= inp_desc;
}
incr(no_ch);
}


/*:58*/
#line 1183 "../../../texk/web2c/tiedir/tie.w"

}
if(no_ch<=0||prod_chf==unknown)usage();
}


/*:56*/
#line 1245 "../../../texk/web2c/tiedir/tie.w"

/*34:*/
#line 788 "../../../texk/web2c/tiedir/tie.w"

{
out_file= fopen(out_name,"w");
if(out_file==NULL){
fatal_error("! Could not open/create output file");

}
}


/*:34*/
#line 1246 "../../../texk/web2c/tiedir/tie.w"

/*36:*/
#line 809 "../../../texk/web2c/tiedir/tie.w"

{input_organization[0]->the_file= 
fopen(input_organization[0]->name_of_file,"r");
if(input_organization[0]->the_file==NULL)
fatal_error("! Could not open master file");

print2("(%s)",input_organization[0]->name_of_file);
term_new_line;
input_organization[0]->type_of_file= master;
get_line(0);
}

/*:36*/
#line 1247 "../../../texk/web2c/tiedir/tie.w"

/*37:*/
#line 825 "../../../texk/web2c/tiedir/tie.w"

{file_index i;
i= 1;
while(i<no_ch){
input_organization[i]->the_file= 
fopen(input_organization[i]->name_of_file,"r");
if(input_organization[i]->the_file==NULL)
fatal_error("!Could not open change file");

print2("(%s)",input_organization[i]->name_of_file);
term_new_line;
init_change_file(i,true);
incr(i);
}
}





/*:37*/
#line 1248 "../../../texk/web2c/tiedir/tie.w"

/*53:*/
#line 1128 "../../../texk/web2c/tiedir/tie.w"

actual_input= 0;
input_has_ended= false;
while(input_has_ended==false||actual_input!=0)
/*45:*/
#line 970 "../../../texk/web2c/tiedir/tie.w"

{file_index test_file;
/*46:*/
#line 985 "../../../texk/web2c/tiedir/tie.w"

{register input_description*inp_desc;
while(actual_input> 0&&e_of_ch_module(actual_input)){
inp_desc= input_organization[actual_input];
if(inp_desc->type_of_file==master){

fatal_error("! This can't happen: change file is master file");

}
inp_desc->mode= search;
init_change_file(actual_input,true);
while((input_organization[actual_input]->mode!=reading
&&actual_input> 0))decr(actual_input);
}
}


/*:46*/
#line 972 "../../../texk/web2c/tiedir/tie.w"

if(input_has_ended&&actual_input==0)break;
/*47:*/
#line 1009 "../../../texk/web2c/tiedir/tie.w"

test_input= none;
test_file= actual_input;
while(test_input==none&&test_file<no_ch-1){
incr(test_file);
switch(input_organization[test_file]->mode){
case search:if(lines_dont_match(actual_input,test_file)==false){
input_organization[test_file]->mode= test;
test_input= test_file;
}
break;
case test:if(lines_dont_match(actual_input,test_file)==true){

input_organization[test_file]->mode= search;
err_print("! Sections do not match")(actual_input);

err_loc(test_file);
init_change_file(test_file,false);
}else test_input= test_file;
break;
case reading:do_nothing;
break;
case ignore:do_nothing;
break;
}
}


/*:47*/
#line 974 "../../../texk/web2c/tiedir/tie.w"

/*48:*/
#line 1043 "../../../texk/web2c/tiedir/tie.w"

if(prod_chf==chf){
loop{
/*49:*/
#line 1057 "../../../texk/web2c/tiedir/tie.w"

if(out_mode==normal){
if(test_input!=none){
fputc(map_xchr(64),out_file);fputc(map_xchr(120),out_file);
new_line(out_file);
out_mode= pre;
}else break;
}


/*:49*/
#line 1046 "../../../texk/web2c/tiedir/tie.w"

/*50:*/
#line 1071 "../../../texk/web2c/tiedir/tie.w"


if(out_mode==pre){
if(test_input==none){
fputc(map_xchr(64),out_file);fputc(map_xchr(121),out_file);
new_line(out_file);
out_mode= post;
}else{
if(input_organization[actual_input]->type_of_file==master)
put_line(actual_input);
break;
}
}


/*:50*/
#line 1047 "../../../texk/web2c/tiedir/tie.w"

/*51:*/
#line 1092 "../../../texk/web2c/tiedir/tie.w"

if(out_mode==post){
if(input_organization[actual_input]->type_of_file==chf){
if(test_input==none)put_line(actual_input);
break;
}else{
fputc(map_xchr(64),out_file);fputc(map_xchr(122),out_file);
new_line(out_file);
new_line(out_file);
out_mode= normal;
}
}


/*:51*/
#line 1048 "../../../texk/web2c/tiedir/tie.w"

}
}else
if(test_input==none)put_line(actual_input);
Ejemplo n.º 24
0
int main ( void ) {
    char* line;
    time_t* led_flash_timer;
    time_t* reboot_timer;
    socket_t* socket = socket0_g;
    int reboot_stage = 0;
    
    /* Turn off all LEDs as a starting point */
    led_clear();

    /* this must be first, because all the other init functions call malloc */
    init_malloc();
        
    /* Initialize current time and some timers */
    init_current_time();
    led_flash_timer = init_timer();
    set_timer(led_flash_timer, 500);    
    reboot_timer = init_timer();
    
        
    /* receive packet buffer */
    rx_packet_g = malloc(sizeof(packet_t));
    
    /* socket init */
    socket0_g = init_socket(0);
    socket1_g = init_socket(1);
        
    /* open ethernet port and wait for connection requests 
       keep trying forever */
    while (!open_link());
        
    /* infinite loop. Everything is timer, interrupt and queue driven from here on down */
    while (1) {
        
        /* Flash a heartbeat LED */
        if (timer_expired(led_flash_timer)) {
            led_flip(0);
            set_timer(led_flash_timer, 500);
            }
            
            
        /* Check for newly downloaded tftp file. Add to all tx buffers */
        /* Has a file been uploaded via tftp ? */
        if (udp_file_g != NULL) {
            /* Notify telnet clients that file has been received */
            if (udp_file_g->ready) {
                udp_file_g->ready = 0;
                telnet_broadcast("Received file %s, %d bytes, linux %d\r\n",
                    udp_file_g->filename, udp_file_g->total_bytes, udp_file_g->linux_boot);
                if (process_file(socket0_g) == 0)
                    /* Disconnect in 1 second */
                    set_timer(reboot_timer, 1000);
                else
                    telnet_broadcast("Not an elf file\r\n");
                }
            }
            
            
        /* reboot timer expired */
        if (timer_expired(reboot_timer)) {
            /* First stage of reboot sequence is to nicely disconnect */
            if (reboot_stage == 0) {
                set_timer(reboot_timer, 1000);
                reboot_stage = 1;
                socket0_g->tcp_disconnect = 1;
                socket1_g->tcp_disconnect = 1;
                } 
            else {
            /* Second stage of reboot sequence is to turn off ethmac and then jump to restart vector */
                close_link();
                reboot();
                }
            }


        /* Poll both sockets in turn for activity */
        if (socket == socket0_g)
            socket = socket1_g;
        else
            socket = socket0_g;
            
            
        /* Check if any tcp packets need to be re-transmitted */
        tcp_retransmit(socket);


        /* Handle exit command */
        if (socket->tcp_disconnect && socket->tcp_connection_state == TCP_OPEN) {
            tcp_disconnect(socket);
            }
            

        /* Reset connection */
        if (socket->tcp_reset) {
            socket->tcp_connection_state = TCP_CLOSED;
            socket->telnet_connection_state = TELNET_CLOSED;
            socket->telnet_options_sent = 0;
            tcp_reply(socket, NULL, 0);
            socket->tcp_reset = 0;
            }
                     
        
        /* Send telnet options */             
        if (socket->tcp_connection_state == TCP_OPEN && !socket->telnet_options_sent){
            telnet_options(socket);
            socket->telnet_options_sent = 1;
            }
            
        /* telnet connection open 
           Communicate with client */
        else if (socket->telnet_connection_state == TELNET_OPEN) {
            /* Send telnet greeting */
            if (!socket->telnet_sent_opening_message){
                put_line (socket->telnet_txbuf, "Amber Processor Boot Loader\r\n> ");
                socket->telnet_sent_opening_message = 1;
                }
                
            /* Parse telnet rx buffer */
            if (get_line(socket->telnet_rxbuf, &line)) 
                parse_command (socket, line);

            /* Transmit text from telnet tx buffer */
            telnet_tx(socket, socket->telnet_txbuf);
        }
    }
}
Ejemplo n.º 25
0
int main(int argc, char *argv[]) {
	// Initialize randomness
	srand(time(NULL));
	// 7 parameters are required.
	if (argc != 13) {
		fprintf(stderr, "Usage: %s obj-file sx sy sz tx ty tz rx ry rz focal-dist hiding\n", argv[0]);
		return 0;
	}
	
	unsigned int i, j;

	double sx = atof( argv[2] );
	double sy = atof( argv[3] );
	double sz = atof( argv[4] );
	double tx = atof( argv[5] );
	double ty = atof( argv[6] );
	double tz = atof( argv[7] );
	double rx = atof( argv[8] );
	double ry = atof( argv[9] );
	double rz = atof( argv[10] );
	double fd = atof( argv[11] );

	int hiding = atoi( argv[12] );

	matrix_double scale = scale_by(sx, sy, sz);
	matrix_double tras = traslate(tx, ty, tz);
	matrix_double rot = rotate(rx, ry, rz);
	matrix_double proj = projection(fd);
	
	file_data vnf = readobj(argv[1]);

	// int p;
	// for (p = 0; p < vnf.vertices.num_elems; p++) {
	// 	point3d t = (vnf.vertices.data)[p];
	// 	fprintf(stderr, "(%f,%f,%f)\n", t.x, t.y, t.z);
	// }

	// Join all the transformations in a single matrix
	// Operation order: Scaling, rotation, traslation and projection
	matrix_double t1 = product(proj, tras);
	matrix_double t2 = product(t1, rot);
	matrix_double t3 = product(t2, scale);

	apply_matrix(t3, vnf.vertices);
		
	dispose_matrix(&t3);
	dispose_matrix(&t2);
	dispose_matrix(&t1);
	dispose_matrix(&scale);
	dispose_matrix(&tras);
	dispose_matrix(&rot);
	dispose_matrix(&proj);

	// Projection sets w = z, so divide everything by w.
	for (i = 0; i < vnf.vertices.num_elems; i++) {
		point3d tmp = (vnf.vertices.data)[i];
		tmp.x /= tmp.w;
		tmp.y /= tmp.w;
		tmp.z /= tmp.w;
		(vnf.vertices.data)[i] = tmp;
	}

	// The camera normal (taking advantage of perspective projection)
	vector camera_normal = new_vector( new_point3d(0.0, 0.0, 0.0, 1.0), new_point3d(0.0, 0.0, 1.0, 1.0) );

	// The z-buffer
	double **zbuf = calloc(HEIGHT, sizeof *zbuf);
	for (i = 0; i < HEIGHT; i++) {
		zbuf[i] = calloc(WIDTH, sizeof **zbuf);
		for (j = 0; j < WIDTH; j++)
			zbuf[i][j] = DBL_MAX;
	}
	
	color c = new_color( 255, 255, 255 );

	point center = { WIDTH >> 1, HEIGHT >> 1 };
	int invertX = 0, invertY = 1;
	
	raster tmp = new_raster(WIDTH, HEIGHT, 3);
	for (i = 0; i < vnf.faces.num_elems; i++) {
		point3d v1 = (vnf.vertices.data)[((vnf.faces.data)[i].v1) - 1];
		point3d v2 = (vnf.vertices.data)[((vnf.faces.data)[i].v2) - 1];
		point3d v3 = (vnf.vertices.data)[((vnf.faces.data)[i].v3) - 1];

		point pt[3] = { new_point(v1.x, v1.y), new_point(v2.x, v2.y), new_point(v3.x, v3.y) };

		for (j = 0; j < 3; j++)
			pt[j] = raster_translate(pt[j], center, invertX, invertY);

		// Hiding faces using face normals
		if (hiding == 1) {			
			vector va = new_vector( v1, v2 );
			vector vb = new_vector( v1, v3 );

			vector vn = vector_crossproduct( va, vb );

			if ( abs(vector_angle(vn, camera_normal)) < 90.0 ) continue;
		}

		// Drawing the face
		for (j = 0; j < 3; j++) {

			int curr = j;
			int next = (j+1) % 3;

			point ps = pt[curr];
			point pe = pt[next];

			// Use z-buffering if allowed
			// if (hiding == 2)
			// 	put_line_z(tmp, new_line( ps, pe ), c, bresenham, zbuf, vertices[3][curr], vertices[3][next]);
			// else
			put_line(tmp, new_line( ps, pe ), c, bresenham);
			
		}

		// Filling the face using a random, eye-pleasing colour
		color cr = { ((rand() % 255) + 255) >> 1, ((rand() % 255) + 255) >> 1, ((rand() % 255) + 255) >> 1 };
		// if (hiding == 2)
		// 	fill_face_z(tmp, pt[0], pt[1], pt[2], cr, zbuf, vertices[3][j], vertices[3][(j+1) % 3]);
		// elseelse
			fill_face(tmp, pt[0], pt[1], pt[2], cr);

	}
	raster_out(tmp);
	dispose_raster(tmp);

	for (i = 0; i < HEIGHT; i++) free(zbuf[i]);
	free(zbuf);

	free(vnf.vertices.data);
	free(vnf.faces.data);

	return 0;
}