Esempio n. 1
0
void vbi_get(int fd)
{
	if (options[OptGetSlicedVbiFormat]) {
		vbi_fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
		if (doioctl(fd, VIDIOC_G_FMT, &vbi_fmt) == 0)
			printfmt(vbi_fmt);
	}

	if (options[OptGetSlicedVbiOutFormat]) {
		vbi_fmt_out.type = V4L2_BUF_TYPE_SLICED_VBI_OUTPUT;
		if (doioctl(fd, VIDIOC_G_FMT, &vbi_fmt_out) == 0)
			printfmt(vbi_fmt_out);
	}

	if (options[OptGetVbiFormat]) {
		raw_fmt.type = V4L2_BUF_TYPE_VBI_CAPTURE;
		if (doioctl(fd, VIDIOC_G_FMT, &raw_fmt) == 0)
			printfmt(raw_fmt);
	}

	if (options[OptGetVbiOutFormat]) {
		raw_fmt_out.type = V4L2_BUF_TYPE_VBI_OUTPUT;
		if (doioctl(fd, VIDIOC_G_FMT, &raw_fmt_out) == 0)
			printfmt(raw_fmt_out);
	}
}
void vidout_set(int fd)
{
	int ret;

	if (options[OptSetVideoOutFormat] || options[OptTryVideoOutFormat]) {
		struct v4l2_format in_vfmt;

		in_vfmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
		if (doioctl(fd, VIDIOC_G_FMT, &in_vfmt) == 0) {
			if (set_fmts_out & FmtWidth)
				in_vfmt.fmt.pix.width = vfmt_out.fmt.pix.width;
			if (set_fmts_out & FmtHeight)
				in_vfmt.fmt.pix.height = vfmt_out.fmt.pix.height;
			if (set_fmts_out & FmtPixelFormat) {
				in_vfmt.fmt.pix.pixelformat = vfmt_out.fmt.pix.pixelformat;
				if (in_vfmt.fmt.pix.pixelformat < 256) {
					in_vfmt.fmt.pix.pixelformat =
						find_pixel_format(fd, in_vfmt.fmt.pix.pixelformat,
								  false);
				}
			}

			if (options[OptSetVideoOutFormat])
				ret = doioctl(fd, VIDIOC_S_FMT, &in_vfmt);
			else
				ret = doioctl(fd, VIDIOC_TRY_FMT, &in_vfmt);
			if (ret == 0 && verbose)
				printfmt(in_vfmt);
		}
	}

	if (options[OptSetVideoOutMplaneFormat] || options[OptTryVideoOutMplaneFormat]) {
		struct v4l2_format in_vfmt;

		in_vfmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
		if (doioctl(fd, VIDIOC_G_FMT, &in_vfmt) == 0) {
			if (set_fmts_out & FmtWidth)
				in_vfmt.fmt.pix_mp.width = vfmt_out.fmt.pix_mp.width;
			if (set_fmts_out & FmtHeight)
				in_vfmt.fmt.pix_mp.height = vfmt_out.fmt.pix_mp.height;
			if (set_fmts_out & FmtPixelFormat) {
				in_vfmt.fmt.pix_mp.pixelformat = vfmt_out.fmt.pix_mp.pixelformat;
				if (in_vfmt.fmt.pix_mp.pixelformat < 256) {
					in_vfmt.fmt.pix_mp.pixelformat =
						find_pixel_format(fd, in_vfmt.fmt.pix_mp.pixelformat,
								  true);
				}
			}
			if (options[OptSetVideoOutMplaneFormat])
				ret = doioctl(fd, VIDIOC_S_FMT, &in_vfmt);
			else
				ret = doioctl(fd, VIDIOC_TRY_FMT, &in_vfmt);
			if (ret == 0 && verbose)
				printfmt(in_vfmt);
		}
	}
}
void vidout_get(int fd)
{
	if (options[OptGetVideoOutFormat]) {
		vfmt_out.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
		if (doioctl(fd, VIDIOC_G_FMT, &vfmt_out) == 0)
			printfmt(vfmt_out);
	}

	if (options[OptGetVideoOutMplaneFormat]) {
		vfmt_out.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
		if (doioctl(fd, VIDIOC_G_FMT, &vfmt_out) == 0)
			printfmt(vfmt_out);
	}
}
Esempio n. 4
0
File: secho.c Progetto: Orc/secho
/* print a character, processing it according to whichever of the
 * bewildering collection of options were used.
 */
void
outc(unsigned char c, FILE *out)
{
    int i;
    
    switch (format) {
    case ASCII:
	    if ( (c == '') && !doescapes ) {
		printc('^', out);
		printc('[', out);
		break;
	    }
	    if ( !isprint(c) ) {
		if ( nononprint ) break;
		if ( visnonprint ) { printfmt(out, "%#o", c); break; }
	    }
	    switch (whichcase) {
	    case UPPERCASE: printc(toupper(c), out); break;
	    case LOWERCASE: printc(tolower(c), out); break;
	    default:        printc(c, out);          break;
	    }
	    break;
    case BINARY:
	    printc(' ', out);
	    for (i=7; i; --i)
		printc( c & (1<<i) ? '1': '0', out);
	    break;
    case OCTAL:
	    printfmt(out, " %03o", c);
	    break;
    case DECIMAL:
	    printfmt(out, " %d", c);
	    break;
    case HEX:
	    printfmt(out, (whichcase==UPPERCASE)?" %02X":" %02x", c);
	    break;
    case SPQR:
	    printc(' ', out);
	    baser(out, c);
	    break;
    default:
	    printc(' ', out);
	    basen(c, out);
	    break;
    }
}
Esempio n. 5
0
void vidcap_get(int fd)
{
	if (options[OptGetVideoFormat]) {
		struct v4l2_format vfmt;

		memset(&vfmt, 0, sizeof(vfmt));
		vfmt.fmt.pix.priv = priv_magic;
		vfmt.type = vidcap_buftype;
		if (doioctl(fd, VIDIOC_G_FMT, &vfmt) == 0)
			printfmt(vfmt);
	}
}
Esempio n. 6
0
File: secho.c Progetto: Orc/secho
/* print an argument.
 */
void
printarg(FILE *out)
{
    int i;

    if ( counter > 1 )
	printc(outputdelim, out);
    if ( numbered )
	printfmt(out, "%d\t", counter);
    for (i=0; i < S(arg); i++)
	outc(T(arg)[i], out);
}
Esempio n. 7
0
void printip(void (*putch) (int, void **), void **putdat, uint8_t * ip)
{
	int i, j, eln, eli;
	uint16_t s;
	if (memcmp(ip, v4prefix, 12) == 0)
		printfmt(putch, putdat, ifmt, ip[12], ip[13], ip[14], ip[15]);
	else {
		/* find longest elision */
		eln = eli = -1;
		for (i = 0; i < 16; i += 2) {
			for (j = i; j < 16; j += 2)
				if (ip[j] != 0 || ip[j + 1] != 0)
					break;
			if (j > i && j - i > eln) {
				eli = i;
				eln = j - i;
			}
		}

		/* print with possible elision */
		for (i = 0; i < 16; i += 2) {
			if (i == eli) {
				/* not sure what to do ... we don't get
				 * the number of bytes back from printing.
				 */
				printfmt(putch, putdat, "::");
				i += eln;
				if (i >= 16)
					break;
			} else if (i != 0)
				printfmt(putch, putdat, ":");

			s = (ip[i] << 8) + ip[i + 1];
			printfmt(putch, putdat, "0x%x", s);
		}
	}
}
Esempio n. 8
0
void overlay_get(int fd)
{
	if (options[OptGetOverlayFormat]) {
		struct v4l2_format fmt;

		fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
		if (doioctl(fd, VIDIOC_G_FMT, &fmt) == 0)
			printfmt(fmt);
	}

	if (options[OptGetOutputOverlayFormat]) {
		struct v4l2_format fmt;

		fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY;
		if (doioctl(fd, VIDIOC_G_FMT, &fmt) == 0)
			printfmt(fmt);
	}

	if (options[OptGetFBuf]) {
		struct v4l2_framebuffer fb;
		if (doioctl(fd, VIDIOC_G_FBUF, &fb) == 0)
			printfbuf(fb);
	}
}
Esempio n. 9
0
void vbi_set(int fd)
{
	int ret;

	if (options[OptSetSlicedVbiFormat] || options[OptTrySlicedVbiFormat]) {
		vbi_fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
		if (options[OptSetSlicedVbiFormat])
			ret = doioctl(fd, VIDIOC_S_FMT, &vbi_fmt);
		else
			ret = doioctl(fd, VIDIOC_TRY_FMT, &vbi_fmt);
		if (ret == 0 && (verbose || options[OptTrySlicedVbiFormat]))
			printfmt(vbi_fmt);
	}

	if (options[OptSetSlicedVbiOutFormat] || options[OptTrySlicedVbiOutFormat]) {
		vbi_fmt_out.type = V4L2_BUF_TYPE_SLICED_VBI_OUTPUT;
		if (options[OptSetSlicedVbiOutFormat])
			ret = doioctl(fd, VIDIOC_S_FMT, &vbi_fmt_out);
		else
			ret = doioctl(fd, VIDIOC_TRY_FMT, &vbi_fmt_out);
		if (ret == 0 && (verbose || options[OptTrySlicedVbiOutFormat]))
			printfmt(vbi_fmt_out);
	}
}
Esempio n. 10
0
File: secho.c Progetto: Orc/secho
void
baser(FILE *out, unsigned char number)
{
    int i, j, rep;

    if ( number == 0 )
	printfmt(out, "nil", 0);
    else
	for ( i=6; i > 0; --i ) {
	    if ( rep = (number / d_r[i].val) )
		for (j=0; r1to10[rep][j]; j++)
		    printc(d_r[i].let[r1to10[rep][j]-'0'], out);
	    number %= d_r[i].val;
	}
}
Esempio n. 11
0
/* mprint -- create a string in ealloc space by printing to it */
extern char *mprint VARARGS1(const char *, fmt) {
	Format format;
	format.u.n = 1;
	VA_START(format.args, fmt);

	format.buf	= ealloc(PRINT_ALLOCSIZE);
	format.bufbegin	= format.buf;
	format.bufend	= format.buf + PRINT_ALLOCSIZE - 1;
	format.grow	= mprint_grow;
	format.flushed	= 0;

	printfmt(&format, fmt);
	*format.buf = '\0';
	va_end(format.args);
	return format.bufbegin;
}
Esempio n. 12
0
/* strv -- print a formatted string into gc space */
extern char *strv(const char *fmt, va_list args) {
	Buffer *buf;
	Format format;

	gcdisable(0);
	buf = openbuffer(0);
	format.u.p	= buf;
	format.args	= args;
	format.buf	= buf->str;
	format.bufbegin	= buf->str;
	format.bufend	= buf->str + buf->len;
	format.grow	= str_grow;
	format.flushed	= 0;

	printfmt(&format, fmt);
	fmtputc(&format, '\0');
	gcenable();

	return sealbuffer(format.u.p);
}
Esempio n. 13
0
void printipmask(void (*putch) (int, void **), void **putdat, uint8_t * ip)
{
	int i, j, n;
	/* look for a prefix mask */
	for (i = 0; i < 16; i++)
		if (ip[i] != 0xff)
			break;
	if (i < 16) {
		if ((prefixvals[ip[i]] & Isprefix) == 0) {
			printip(putch, putdat, ip);
			return;
		}
		for (j = i + 1; j < 16; j++)
			if (ip[j] != 0) {
				printip(putch, putdat, ip);
				return;
			}
		n = 8 * i + (prefixvals[ip[i]] & ~Isprefix);
	} else
		n = 8 * 16;

	/* got one, use /xx format */
	printfmt(putch, putdat, "/%d", n);
}
Esempio n. 14
0
void vidcap_set(int fd)
{
	int ret;

	if (options[OptSetVideoFormat] || options[OptTryVideoFormat]) {
		struct v4l2_format vfmt;

		memset(&vfmt, 0, sizeof(vfmt));
		vfmt.fmt.pix.priv = priv_magic;
		vfmt.type = vidcap_buftype;

		if (doioctl(fd, VIDIOC_G_FMT, &vfmt) == 0) {
			if (is_multiplanar) {
				if (set_fmts & FmtWidth)
					vfmt.fmt.pix_mp.width = width;
				if (set_fmts & FmtHeight)
					vfmt.fmt.pix_mp.height = height;
				if (set_fmts & FmtPixelFormat) {
					vfmt.fmt.pix_mp.pixelformat = pixfmt;
					if (vfmt.fmt.pix_mp.pixelformat < 256) {
						vfmt.fmt.pix_mp.pixelformat =
							find_pixel_format(fd, vfmt.fmt.pix_mp.pixelformat,
									false, true);
					}
				}
				if (set_fmts & FmtField)
					vfmt.fmt.pix_mp.field = field;
				if (set_fmts & FmtFlags)
					vfmt.fmt.pix_mp.flags = flags;
				if (set_fmts & FmtBytesPerLine) {
					for (unsigned i = 0; i < VIDEO_MAX_PLANES; i++)
						vfmt.fmt.pix_mp.plane_fmt[i].bytesperline =
							bytesperline[i];
				} else {
					/* G_FMT might return bytesperline values > width,
					 * reset them to 0 to force the driver to update them
					 * to the closest value for the new width. */
					for (unsigned i = 0; i < vfmt.fmt.pix_mp.num_planes; i++)
						vfmt.fmt.pix_mp.plane_fmt[i].bytesperline = 0;
				}
			} else {
				if (set_fmts & FmtWidth)
					vfmt.fmt.pix.width = width;
				if (set_fmts & FmtHeight)
					vfmt.fmt.pix.height = height;
				if (set_fmts & FmtPixelFormat) {
					vfmt.fmt.pix.pixelformat = pixfmt;
					if (vfmt.fmt.pix.pixelformat < 256) {
						vfmt.fmt.pix.pixelformat =
							find_pixel_format(fd, vfmt.fmt.pix.pixelformat,
									false, false);
					}
				}
				if (set_fmts & FmtField)
					vfmt.fmt.pix.field = field;
				if (set_fmts & FmtFlags)
					vfmt.fmt.pix.flags = flags;
				if (set_fmts & FmtBytesPerLine) {
					vfmt.fmt.pix.bytesperline = bytesperline[0];
				} else {
					/* G_FMT might return a bytesperline value > width,
					 * reset this to 0 to force the driver to update it
					 * to the closest value for the new width. */
					vfmt.fmt.pix.bytesperline = 0;
				}
			}

			if (options[OptSetVideoFormat])
				ret = doioctl(fd, VIDIOC_S_FMT, &vfmt);
			else
				ret = doioctl(fd, VIDIOC_TRY_FMT, &vfmt);
			if (ret == 0 && (verbose || options[OptTryVideoFormat]))
				printfmt(vfmt);
		}
	}
}
Esempio n. 15
0
void overlay_set(int fd)
{
	int ret;

	if (options[OptSetOverlayFormat] || options[OptTryOverlayFormat]) {
		struct v4l2_format fmt;

		fmt.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
		if (doioctl(fd, VIDIOC_G_FMT, &fmt) == 0) {
			if (set_overlay_fmt & FmtChromaKey)
				fmt.fmt.win.chromakey = overlay_fmt.fmt.win.chromakey;
			if (set_overlay_fmt & FmtGlobalAlpha)
				fmt.fmt.win.global_alpha = overlay_fmt.fmt.win.global_alpha;
			if (set_overlay_fmt & FmtLeft)
				fmt.fmt.win.w.left = overlay_fmt.fmt.win.w.left;
			if (set_overlay_fmt & FmtTop)
				fmt.fmt.win.w.top = overlay_fmt.fmt.win.w.top;
			if (set_overlay_fmt & FmtWidth)
				fmt.fmt.win.w.width = overlay_fmt.fmt.win.w.width;
			if (set_overlay_fmt & FmtHeight)
				fmt.fmt.win.w.height = overlay_fmt.fmt.win.w.height;
			if (set_overlay_fmt & FmtField)
				fmt.fmt.win.field = overlay_fmt.fmt.win.field;
			if (options[OptSetOverlayFormat])
				ret = doioctl(fd, VIDIOC_S_FMT, &fmt);
			else
				ret = doioctl(fd, VIDIOC_TRY_FMT, &fmt);
			if (ret == 0 && (verbose || options[OptTryOverlayFormat]))
				printfmt(fmt);
		}
	}

	if (options[OptSetOutputOverlayFormat] || options[OptTryOutputOverlayFormat]) {
		struct v4l2_format fmt;

		fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY;
		if (doioctl(fd, VIDIOC_G_FMT, &fmt) == 0) {
			if (set_overlay_fmt_out & FmtChromaKey)
				fmt.fmt.win.chromakey = overlay_fmt_out.fmt.win.chromakey;
			if (set_overlay_fmt_out & FmtGlobalAlpha)
				fmt.fmt.win.global_alpha = overlay_fmt_out.fmt.win.global_alpha;
			if (set_overlay_fmt_out & FmtLeft)
				fmt.fmt.win.w.left = overlay_fmt_out.fmt.win.w.left;
			if (set_overlay_fmt_out & FmtTop)
				fmt.fmt.win.w.top = overlay_fmt_out.fmt.win.w.top;
			if (set_overlay_fmt_out & FmtWidth)
				fmt.fmt.win.w.width = overlay_fmt_out.fmt.win.w.width;
			if (set_overlay_fmt_out & FmtHeight)
				fmt.fmt.win.w.height = overlay_fmt_out.fmt.win.w.height;
			if (set_overlay_fmt_out & FmtField)
				fmt.fmt.win.field = overlay_fmt_out.fmt.win.field;
			if (options[OptSetOutputOverlayFormat])
				ret = doioctl(fd, VIDIOC_S_FMT, &fmt);
			else
				ret = doioctl(fd, VIDIOC_TRY_FMT, &fmt);
			if (ret == 0 && (verbose || options[OptTryOutputOverlayFormat]))
				printfmt(fmt);
		}
	}

	if (options[OptSetFBuf]) {
		struct v4l2_framebuffer fb;

		if (doioctl(fd, VIDIOC_G_FBUF, &fb) == 0) {
			fb.flags &= ~set_fbuf;
			fb.flags |= fbuf.flags;
			doioctl(fd, VIDIOC_S_FBUF, &fb);
		}
	}

	if (options[OptOverlay]) {
		doioctl(fd, VIDIOC_OVERLAY, &overlay);
	}
}
Esempio n. 16
0
void printqid(void (*putch) (int, void **), void **putdat, struct qid *q)
{
	printfmt(putch, putdat, "{path:%p,type:%02x,vers:%p}",
		 q->path, q->type, q->vers);

}
Esempio n. 17
0
void printcname(void (*putch) (int, void **), void **putdat, struct cname *c)
{
	if (c)
		printfmt(putch, putdat, "{ref %d, alen %d, len %d, s %s}",
		 	kref_refcnt(&c->ref), c->alen, c->len, c->s);
}
Esempio n. 18
0
void printchan(void (*putch) (int, void **), void **putdat, struct chan *c)
{
	if (! c)
		return;
	printfmt(putch, putdat, "(%p): ", c);
	printfmt(putch, putdat, "%slocked ", spin_locked(&c->lock) ? "":"un");
	printfmt(putch, putdat, "refs %p ", kref_refcnt(&c->ref));
//	printfmt(putch, putdat, "%p ", struct chan *next,
//	printfmt(putch, putdat, "%p ", struct chan *link,
	printfmt(putch, putdat, "off %p ", c->offset);
	printfmt(putch, putdat, "type %p ", c->type);
	if (c->type != -1)
		printfmt(putch, putdat, "(#%s) ", devtab[c->type].name);
	printfmt(putch, putdat, "dev %p ", c->dev);
	printfmt(putch, putdat, "mode %p ", c->mode);
	printfmt(putch, putdat, "flag %p ", c->flag);
	printfmt(putch, putdat, "qid");
	printqid(putch, putdat, &c->qid);
	printfmt(putch, putdat, " fid %p ", c->fid);
	printfmt(putch, putdat, "iounit %p ", c->iounit);
	printfmt(putch, putdat, "umh %p ", c->umh);
	printfmt(putch, putdat, "umc %p ", c->umc);
//      printfmt(putch, putdat, "%p ", qlock_t umqlock,
	printfmt(putch, putdat, "uri %p ", c->uri);
	printfmt(putch, putdat, "dri %p ", c->dri);
	printfmt(putch, putdat, "mountid %p ", c->mountid);
	printfmt(putch, putdat, "mntcache %p ", c->mcp);
	printfmt(putch, putdat, "mux %p ", c->mux);
	if (c->mux && c->mux->c) 	printfmt(putch, putdat, "mux->c %p ", c->mux->c);
	printfmt(putch, putdat, "aux %p ", c->aux);
	printfmt(putch, putdat, "mchan %p ", c->mchan);
	printfmt(putch, putdat, "mqid %p ");
	printqid(putch, putdat, &c->mqid);
	printfmt(putch, putdat, " cname ");
	printcname(putch, putdat, c->name);
	printfmt(putch, putdat, " ateof %p ", c->ateof);
	printfmt(putch, putdat, "buf %p ", c->buf);
	printfmt(putch, putdat, "bufused %p ", c->bufused);
}
Esempio n. 19
0
void printemac(void (*putch) (int, void **), void **putdat, uint8_t * mac)
{
	printfmt(putch, putdat, efmt, mac[0], mac[1], mac[2], mac[3], mac[4],
			 mac[5]);
}
Esempio n. 20
0
/*******************************************************************************
This function is called to sequence through "blocks" of statements.  The entire
program is the outer-most block, and each foreach statement begins another one.
That is, this function is RECURSIVE!!!
*******************************************************************************/
Exprnode
doblock(int begstmtidx, int endstmtidx)
{
    Exprnode  *lhsexprptr, result;
    int       newdepth, i;

    int stmtidx;
    stmtidx = begstmtidx;
    while (stmtidx <= endstmtidx) {
	curstmtidx = stmtidx;			/* global, for error messages */
	switch (stmts[stmtidx].typ) {
	    case PRINTF: case SPRINTF:
		printfmt(stmtidx);
		stmtidx++;
		break;
	    case FOREACH:
		newdepth = stmts[stmtidx].s.foreach.fldidx;
		for (i=axistbl[newdepth].first; i<=axistbl[newdepth].last; i++){
		    curfldvalptrtbl[newdepth] = axistbl[newdepth].array[i];

		    /* this skips "outer joins" where there is no data */
		    if (stmts[stmtidx].s.foreach.restrictflag) {
			chk4badflds(stmts[stmtidx].s.foreach.fldbits,
					    stmts[stmtidx].s.foreach.maxdepth);
			if (getcount(datarootptr,
					stmts[stmtidx].s.foreach.fldbits, 0,
					stmts[stmtidx].s.foreach.maxdepth) == 0)
			    continue; /* skip doblock */
		    }

		    doblock(stmtidx+1, stmts[stmtidx].s.foreach.next-1);
		}
		curfldvalptrtbl[newdepth] = NULL;
		stmtidx = stmts[stmtidx].s.foreach.next;
		break;
	    case WHILE:
		result = *(stmts[stmtidx].s.while_.exprptr);
		evalexpr(&result);
		while (result.arg.ival) {
		    doblock(stmtidx+1, stmts[stmtidx].s.while_.next-1);
		    result = *(stmts[stmtidx].s.while_.exprptr);
		    evalexpr(&result);
		}
		stmtidx = stmts[stmtidx].s.while_.next;
		break;
	    case DO:
		result = *(stmts[stmtidx].s.dowhile.exprptr);
		evalexpr(&result);
		if (result.arg.ival)
		    stmtidx = stmts[stmtidx].s.dowhile.next;
		else
		    stmtidx++;
		break;
	    case IF:
		result = *(stmts[stmtidx].s.if_.exprptr);
		evalexpr(&result);
		if (result.arg.ival)
		    stmtidx++;
		else
		    stmtidx = stmts[stmtidx].s.if_.next;
		break;
	    case ELSE:
		stmtidx = stmts[stmtidx].s.else_.next;
		break;
	    case ASSIGNOP:			/* assign ops are STATMENTS */
		switch (stmts[stmtidx].s.assign.lhsexprptr->typ) {
		    case UFNCPARAMEXPR:
			lhsexprptr = &argstk[botargstkidx]+stmts[stmtidx].s.
						    assign.lhsexprptr->arg.ival;
			break;
		    case ARRAYVAREXPR:
			lhsexprptr = rtgetarrvaraddr(
					    stmts[stmtidx].s.assign.lhsexprptr);
			break;
		    default:			/* an "ordinary" variable */
			lhsexprptr = stmts[stmtidx].s.assign.lhsexprptr;
			break;
		}
		assignop(lhsexprptr, stmts[stmtidx].s.assign.optyp,
					    stmts[stmtidx].s.assign.rhsexprptr);
		stmtidx++;
		break;
	    case SORT:
		newdepth = stmts[stmtidx].s.sort.fldidx;
		sortaxisarray(stmts[stmtidx].s.sort.exprptr, newdepth, 
					    stmts[stmtidx].s.sort.reverseflag);
		stmtidx++;
		break;
	    case FIRST:
		newdepth = stmts[stmtidx].s.fstlst.fldidx;
		result = *(stmts[stmtidx].s.fstlst.exprptr);
		evalexpr(&result);
		axistbl[newdepth].last =
		    MIN(axistbl[newdepth].first+result.arg.ival-1,
			axistbl[newdepth].last);
		stmtidx++;
		break;
	    case LAST:
		newdepth = stmts[stmtidx].s.fstlst.fldidx;
		result = *(stmts[stmtidx].s.fstlst.exprptr);
		evalexpr(&result);
		axistbl[newdepth].first =
		    MAX(axistbl[newdepth].last-result.arg.ival+1,
			axistbl[newdepth].first);
		stmtidx++;
		break;
	    case SYSTEM:
		result = *(stmts[stmtidx].s.system_.exprptr);
		evalexpr(&result);
		if (result.typ == STRING) {
		    (void) system(result.arg.sval);
		} else {
		    fprintf(stderr,
			    "`system' must be called with a string argument");
		}
		stmtidx++;
		break;
	    case RETURN:
		if (stmts[stmtidx].s.return_.exprptr != NULL) {
		    result = *(stmts[stmtidx].s.return_.exprptr);
		    evalexpr(&result);
		} else {
		    result.typ = NORETVALEXPR;
		}
		return result;
	    case EXPRSTMT:
		result = *(stmts[stmtidx].s.expr.exprptr);
		evalexpr(&result);
		stmtidx++;
		break;
	    case TRAP:
		updatetraptbl(stmts[stmtidx].s.trap.linnumexprptr,
				    stmts[stmtidx].s.trap.ufncexprptr);
		stmtidx++;
		break;
	    default:
		fatalerrlin("doblock: illegal statement type");
		stmtidx++;
		break;
	}
    }
    result.typ = NORETVALEXPR;
    return result;
}
Esempio n. 21
0
void printipv4(void (*putch) (int, void **), void **putdat, uint8_t * p)
{
	printfmt(putch, putdat, ifmt, p[0], p[1], p[2], p[3]);
}