示例#1
0
/* ARGSUSED */
static void
output_trans2_findfirst(int flags, uchar_t *data, char *xtra, int xsz)
{
	int length;
	char filename[256];
	char infolevel[100];

	if (flags & F_SUM) {
		length = snprintf(xtra, xsz, " Findfirst");
		xtra += length;
		xsz -= length;
		data += 12;
		(void) unicode2ascii(filename, 256, data, 512);
		snprintf(xtra, xsz, " File=%s", filename);
	}

	if (flags & F_DTAIL) {
		show_line("FunctionName = Findfirst");
		show_printf("SearchAttributes = 0x%.4x", get2(data));
		data += 2;
		show_printf("FindCount = 0x%.4x", get2(data));
		data += 2;
		show_printf("FindFlags = 0x%.4x", get2(data));
		data += 2;
		get_info_level(infolevel, sizeof (infolevel), get2(data));
		show_printf("InfoLevel = %s", infolevel);
		data += 6;
		(void) unicode2ascii(filename, 256, data, 512);
		show_printf("FileName = %s", filename);
	}
}
示例#2
0
static void cochran_debug_write(const char *filename, const unsigned char *data, unsigned size)
{
	int i, show = 1;

	for (i = 0; i < size; i += 16)
		show = show_line(i, data + i, size - i, show);
}
示例#3
0
/*
 * updall:
 *	update all the lines in a window on the virtual screen
 *
 * struct window *wp;		window to update lines in
 */
static void updall(struct window *wp)
{
	struct line *lp;	/* line to update */
	int sline;	/* physical screen line to update */

	/* search down the lines, updating them */
	lp = wp->w_linep;
	sline = wp->w_toprow;
	while (sline < wp->w_toprow + wp->w_ntrows) {

		/* and update the virtual line */
		vscreen[sline]->v_flag |= VFCHG;
		vscreen[sline]->v_flag &= ~VFREQ;
		vtmove(sline, 0);
		if (lp != wp->w_bufp->b_linep) {
			/* if we are not at the end */
			show_line(lp);
			lp = lforw(lp);
		}

		/* on to the next one */
#if	COLOR
		vscreen[sline]->v_rfcolor = wp->w_fcolor;
		vscreen[sline]->v_rbcolor = wp->w_bcolor;
#endif
		vteeol();
		++sline;
	}

}
示例#4
0
/*
 * upddex:
 *	de-extend any line that derserves it
 */
void upddex(void)
{
	struct window *wp;
	struct line *lp;
	int i;

	wp = wheadp;

	while (wp != NULL) {
		lp = wp->w_linep;
		i = wp->w_toprow;

		while (i < wp->w_toprow + wp->w_ntrows) {
			if (vscreen[i]->v_flag & VFEXT) {
				if ((wp != curwp) || (lp != wp->w_dotp) ||
				    (curcol < term.t_ncol - 1)) {
					vtmove(i, 0);
					show_line(lp);
					vteeol();

					/* this line no longer is extended */
					vscreen[i]->v_flag &= ~VFEXT;
					vscreen[i]->v_flag |= VFCHG;
				}
			}
			lp = lforw(lp);
			++i;
		}
		/* and onward to the next window */
		wp = wp->w_wndp;
	}
}
示例#5
0
文件: rl.c 项目: carriercomm/opentik
void redraw_line() {
	static int alloc_size = 0;

	// Make sure we have enough memory for the syntax
	// highlighting
	if(line_len > alloc_size) {
		alloc_size = line_len + 256;
		syntax = realloc(syntax, alloc_size);
		memset(syntax, 127, line_len);
	}

	// TODO: flag to say no syntax check
	int i;

	for(i=0; i < line_len; i++) {
		if(i%6 == 1) {
			syntax[i] = i%7;
		}
	}

	save_pos();
	move_to(0, 0);
	show_line();
	putp(clr_eol);
	restore_pos();
}
示例#6
0
static void cochran_debug_write(const unsigned char *data, unsigned size)
{
	return;

	int show = 1,  i;
	for (i = 0; i < size; i += 16)
		show = show_line(i, data + i, size - i, show);
}
void Cui::show(const vector<struct process*>& pvec)
{
	int c = pvec.size();
	for(int i = 0;i<c;i++)
	{
		struct line l( *pvec[i] );
		show_line(l, i);
	}
	refresh();
}
示例#8
0
/*
 * Display the given line.  If it is tagged, highlight the name.
 */
void
showLINE(RING * gbl, unsigned inx)
{
    unsigned save = vue->curfile = gbl->curfile;
    unsigned j;

    for (j = 0; j < maxview; j++)
	if (viewlist[j].gbl == gbl) {
	    gbl->curfile = viewlist[j].curfile;
	    show_line(&viewlist[j], inx);
	}
    gbl->curfile = save;
}
示例#9
0
/*
 * Display all files in the current viewport
 */
static void
show_view(RING * gbl)
{
    unsigned j;

    setup_view(gbl);

    for (j = vue->base_file; j <= vue->last_file; j++)
	show_line(vue, j);
    for (j = (unsigned) file2row(vue->last_file + 1); j < vue->last_row; j++) {
	move((int) j, 0);
	clrtoeol();
    }
}
void run_all(apr_pool_t *pool, int argc, const char * const *argv)
{
    apr_sockaddr_t *sockaddr;

    if (argc != 1) {
        THROW(MESSAGE_ARGUMENT_INVALID);
    }

    DownloadFlowController flow_controller;
    show_line();

    sockaddr = get_sockaddr(pool, DUMMY_ADDRESS);

    run_can_download(&flow_controller, sockaddr);
}
示例#11
0
文件: error.c 项目: ColdSauce/psxsdk
void assembler_error(char *format, ...)
{
	va_list ap;
	
	va_start(ap, format);

	printf("Line %d, assembler error: ", line_number);
	vprintf(format, ap);
	printf("\n");
	show_line();
	
	va_end(ap);
	
	exit(EXIT_FAILURE);
}
示例#12
0
文件: error.c 项目: ColdSauce/psxsdk
void instruction_error(char *format, ...)
{
	va_list ap;
	
	va_start(ap, format);
	
	printf("Line %d: Error(%s) - ", line_number, curIns);
	vprintf(format, ap);
	printf("\n");
	show_line();

	va_end(ap);
	
	exit(EXIT_FAILURE);
}
示例#13
0
文件: error.c 项目: ColdSauce/psxsdk
void instruction_warning(char *format, ...)
{
	if(curPass <= 0)
		return;
	
	va_list ap;
	
	va_start(ap, format);
	
	printf("Line %d: Warning (%s) - ", line_number, curIns);
	vprintf(format, ap);
	printf("\n");
	show_line();
	
	va_end(ap);
}
示例#14
0
static void
output_bytes(uchar_t *data, int bytecount)
{
	int i;
	char buff[80];
	char word[10];

	(void) strlcpy(buff, "  ", sizeof (buff));
	for (i = 0; i < bytecount; i++) {
		snprintf(word, sizeof (word), "%.2x ", data[i]);
		(void) strlcat(buff, word, sizeof (buff));
		if ((i+1)%16 == 0 || i == (bytecount-1)) {
			show_line(buff);
			(void) strlcpy(buff, "  ", sizeof (buff));
		}
	}
}
示例#15
0
文件: display.c 项目: bert/depcb
static void
show_item_layer(PcbItem *item, int layer)
{
	if (!pcb.layer->olay)
		return;
	hide_item_layer(item, layer);
	if (!(item->layers & LAYER(layer)))
		return;
	switch (item->type) {
	case PCB_POINT:
		show_point(item, layer);
		break;
	case PCB_LINE:
		show_line(item, layer);
		break;
	}
}
示例#16
0
文件: grep.c 项目: 2quala/git
static void show_pre_context(struct grep_opt *opt, struct grep_source *gs,
			     char *bol, char *end, unsigned lno)
{
	unsigned cur = lno, from = 1, funcname_lno = 0;
	int funcname_needed = !!opt->funcname;

	if (opt->funcbody && !match_funcname(opt, gs, bol, end))
		funcname_needed = 2;

	if (opt->pre_context < lno)
		from = lno - opt->pre_context;
	if (from <= opt->last_shown)
		from = opt->last_shown + 1;

	/* Rewind. */
	while (bol > gs->buf &&
	       cur > (funcname_needed == 2 ? opt->last_shown + 1 : from)) {
		char *eol = --bol;

		while (bol > gs->buf && bol[-1] != '\n')
			bol--;
		cur--;
		if (funcname_needed && match_funcname(opt, gs, bol, eol)) {
			funcname_lno = cur;
			funcname_needed = 0;
		}
	}

	/* We need to look even further back to find a function signature. */
	if (opt->funcname && funcname_needed)
		show_funcname_line(opt, gs, bol, cur);

	/* Back forward. */
	while (cur < lno) {
		char *eol = bol, sign = (cur == funcname_lno) ? '=' : '-';

		while (*eol != '\n')
			eol++;
		show_line(opt, bol, eol, gs->name, cur, sign);
		bol = eol + 1;
		cur++;
	}
}
示例#17
0
文件: grep.c 项目: sanj/git
static void show_funcname_line(struct grep_opt *opt, const char *name,
			       char *buf, char *bol, unsigned lno)
{
	while (bol > buf) {
		char *eol = --bol;

		while (bol > buf && bol[-1] != '\n')
			bol--;
		lno--;

		if (lno <= opt->last_shown)
			break;

		if (match_funcname(opt, bol, eol)) {
			show_line(opt, bol, eol, name, lno, '=');
			break;
		}
	}
}
示例#18
0
/* ARGSUSED */
static void
output_trans2_setfile(int flags, uchar_t *data, char *xtra, int xsz)
{
	int length;

	if (flags & F_SUM) {
		length = snprintf(xtra, xsz, " SetFileInfo");
		xtra += length;
		xsz -= length;
		snprintf(xtra, xsz, " FileID=0x%x", get2(data));
	}

	if (flags & F_DTAIL) {
		show_line("FunctionName = SetFileInfo");
		show_printf("FileID = 0x%.4x", get2(data));
		data += 2;
		show_printf("InfoLevel = 0x%.4x", get2(data));
	}
}
void run_all(apr_pool_t *pool, int argc, const char * const *argv)
{
    const char *from_file_path;
    const char *to_file_path;

    if (argc != 3) {
        THROW(MESSAGE_ARGUMENT_INVALID);
    }

    from_file_path = argv[1];
    to_file_path = argv[2];

    if (!File::is_exist(pool, from_file_path)) {
        THROW(MESSAGE_FILE_NOT_FOUND);
    }

    show_item("from_file_path", from_file_path);
    show_item("to_file_path", to_file_path);

    show_line();
    run_copy(pool, from_file_path, to_file_path);
}
示例#20
0
/*
 * updext:
 *	update the extended line which the cursor is currently
 *	on at a column greater than the terminal width. The line
 *	will be scrolled right or left to let the user see where
 *	the cursor is
 */
static void updext(void)
{
	int rcursor;	/* real cursor location */
	struct line *lp;	/* pointer to current line */

	/* calculate what column the real cursor will end up in */
	rcursor = ((curcol - term.t_ncol) % term.t_scrsiz) + term.t_margin;
	taboff = lbound = curcol - rcursor + 1;

	/* scan through the line outputing characters to the virtual screen */
	/* once we reach the left edge                                  */
	vtmove(currow, -lbound);	/* start scanning offscreen */
	lp = curwp->w_dotp;	/* line to output */
	show_line(lp);

	/* truncate the virtual line, restore tab offset */
	vteeol();
	taboff = 0;

	/* and put a '$' in column 1 */
	vscreen[currow]->v_text[0] = '$';
}
示例#21
0
/* ARGSUSED */
static void
output_trans2_querypath(int flags, uchar_t *data, char *xtra, int xsz)
{
	int length;
	char filename[256];

	if (flags & F_SUM) {
		length = snprintf(xtra, xsz, " QueryPathInfo");
		xtra += length;
		xsz -= length;
		data += 6;
		(void) unicode2ascii(filename, 256, data, 512);
		snprintf(xtra, xsz, " File=%s", filename);
	}

	if (flags & F_DTAIL) {
		show_line("FunctionName = QueryPathInfo");
		show_printf("InfoLevel = 0x%.4x", get2(data));
		data += 6;
		(void) unicode2ascii(filename, 256, data, 512);
		show_printf("FileName = %s", filename);
	}
}
示例#22
0
/*
 * updone:
 *	update the current line	to the virtual screen
 *
 * struct window *wp;		window to update current line in
 */
static void updone(struct window *wp)
{
	struct line *lp;	/* line to update */
	int sline;	/* physical screen line to update */

	/* search down the line we want */
	lp = wp->w_linep;
	sline = wp->w_toprow;
	while (lp != wp->w_dotp) {
		++sline;
		lp = lforw(lp);
	}

	/* and update the virtual line */
	vscreen[sline]->v_flag |= VFCHG;
	vscreen[sline]->v_flag &= ~VFREQ;
	vtmove(sline, 0);
	show_line(lp);
#if	COLOR
	vscreen[sline]->v_rfcolor = wp->w_fcolor;
	vscreen[sline]->v_rbcolor = wp->w_bcolor;
#endif
	vteeol();
}
示例#23
0
void redraw_line(lua_State *L) {
	static int alloc_size = 0;

	// Make sure we have enough memory for the syntax
	// highlighting
	if(line_len > alloc_size) {
		alloc_size = line_len + 256;
		syntax = realloc(syntax, alloc_size);
		memset(syntax, 127, line_len);
	}

	// Get the function onto the stack...
	lua_rawgeti(L, LUA_REGISTRYINDEX, function_index);
	lua_pushstring(L, line);
	lua_pushlightuserdata(L, (void *)syntax);
	lua_call(L, 2, 1);

	// Show the line...
	save_pos();
	move_to(0, 0);
	show_line();
	putp(clr_eol);
	restore_pos();
}
示例#24
0
文件: grep.c 项目: Fabiano-lr/git
static int grep_buffer_1(struct grep_opt *opt, const char *name,
			 char *buf, unsigned long size, int collect_hits)
{
	char *bol = buf;
	unsigned long left = size;
	unsigned lno = 1;
	unsigned last_hit = 0;
	int binary_match_only = 0;
	unsigned count = 0;
	enum grep_context ctx = GREP_CONTEXT_HEAD;
	xdemitconf_t xecfg;

	opt->last_shown = 0;

	if (buffer_is_binary(buf, size)) {
		switch (opt->binary) {
		case GREP_BINARY_DEFAULT:
			binary_match_only = 1;
			break;
		case GREP_BINARY_NOMATCH:
			return 0; /* Assume unmatch */
			break;
		default:
			break;
		}
	}

	memset(&xecfg, 0, sizeof(xecfg));
	if (opt->funcname && !opt->unmatch_name_only && !opt->status_only &&
	    !opt->name_only && !binary_match_only && !collect_hits) {
		struct userdiff_driver *drv = userdiff_find_by_path(name);
		if (drv && drv->funcname.pattern) {
			const struct userdiff_funcname *pe = &drv->funcname;
			xdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);
			opt->priv = &xecfg;
		}
	}

	while (left) {
		char *eol, ch;
		int hit;

		eol = end_of_line(bol, &left);
		ch = *eol;
		*eol = 0;

		if ((ctx == GREP_CONTEXT_HEAD) && (eol == bol))
			ctx = GREP_CONTEXT_BODY;

		hit = match_line(opt, bol, eol, ctx, collect_hits);
		*eol = ch;

		if (collect_hits)
			goto next_line;

		/* "grep -v -e foo -e bla" should list lines
		 * that do not have either, so inversion should
		 * be done outside.
		 */
		if (opt->invert)
			hit = !hit;
		if (opt->unmatch_name_only) {
			if (hit)
				return 0;
			goto next_line;
		}
		if (hit) {
			count++;
			if (opt->status_only)
				return 1;
			if (binary_match_only) {
				printf("Binary file %s matches\n", name);
				return 1;
			}
			if (opt->name_only) {
				show_name(opt, name);
				return 1;
			}
			/* Hit at this line.  If we haven't shown the
			 * pre-context lines, we would need to show them.
			 * When asked to do "count", this still show
			 * the context which is nonsense, but the user
			 * deserves to get that ;-).
			 */
			if (opt->pre_context)
				show_pre_context(opt, name, buf, bol, lno);
			else if (opt->funcname)
				show_funcname_line(opt, name, buf, bol, lno);
			if (!opt->count)
				show_line(opt, bol, eol, name, lno, ':');
			last_hit = lno;
		}
		else if (last_hit &&
			 lno <= last_hit + opt->post_context) {
			/* If the last hit is within the post context,
			 * we need to show this line.
			 */
			show_line(opt, bol, eol, name, lno, '-');
		}

	next_line:
		bol = eol + 1;
		if (!left)
			break;
		left--;
		lno++;
	}

	if (collect_hits)
		return 0;

	if (opt->status_only)
		return 0;
	if (opt->unmatch_name_only) {
		/* We did not see any hit, so we want to show this */
		show_name(opt, name);
		return 1;
	}

	xdiff_clear_find_func(&xecfg);
	opt->priv = NULL;

	/* NEEDSWORK:
	 * The real "grep -c foo *.c" gives many "bar.c:0" lines,
	 * which feels mostly useless but sometimes useful.  Maybe
	 * make it another option?  For now suppress them.
	 */
	if (opt->count && count)
		printf("%s%c%u\n", name,
		       opt->null_following_name ? '\0' : ':', count);
	return !!last_hit;
}
示例#25
0
/*
 * This is called by snoop_netbios.c.
 * This is the external entry point.
 */
void
interpret_smb(int flags, uchar_t *data, int len)
{
	struct smb *smb;
	struct decode *decoder;
	char xtra[MAXLINE];
	ushort_t smb_flags2;
	void (*func)(int, uchar_t *, int, char *, int);

	if (len < sizeof (struct smb))
		return;

	smb = (struct smb *)data;
	decoder = &SMBtable[smb->com & 255];
	smb_flags2 = get2(smb->flags2);
	xtra[0] = '\0';

	/*
	 * SMB Header description
	 * [X/Open-SMB, Sec. 5.1]
	 */
	if (flags & F_DTAIL) {
		show_header("SMB:  ", "SMB Header", len);
		show_space();

		if (smb->flags & SERVER_RESPONSE)
			show_line("SERVER RESPONSE");
		else
			show_line("CLIENT REQUEST");

		if (decoder->name)
			show_printf("Command code = 0x%x (SMB%s)",
			    smb->com, decoder->name);
		else
			show_printf("Command code = 0x%x", smb->com);

		/*
		 * NT status or error class/code
		 * [X/Open-SMB, Sec. 5.6]
		 */
		if (smb_flags2 & FLAGS2_NT_STATUS) {
			show_printf("NT Status = %x", get4(smb->err));
		} else {
			/* Error classes [X/Open-SMB, Sec. 5.6] */
			show_printf("Error class/code = %d/%d",
			    smb->err[0], get2(&smb->err[2]));
		}

		show_printf("Flags summary = 0x%.2x", smb->flags);
		show_printf("Flags2 summary = 0x%.4x", smb_flags2);
		show_printf("Tree ID  (TID) = 0x%.4x", get2(smb->tid));
		show_printf("Proc. ID (PID) = 0x%.4x", get2(smb->pid));
		show_printf("User ID  (UID) = 0x%.4x", get2(smb->uid));
		show_printf("Mux. ID  (MID) = 0x%.4x", get2(smb->mid));
		show_space();
	}

	if ((func = decoder->func) == NULL)
		func = interpret_default;
	(*func)(flags, (uchar_t *)data, len, xtra, sizeof (xtra));

	if (flags & F_SUM) {
		char *p;
		int sz, tl;

		/* Will advance p and decr. sz */
		p = get_sum_line();
		sz = MAXLINE;

		/* Call or Reply */
		if (smb->flags & SERVER_RESPONSE)
			tl = snprintf(p, sz, "SMB R");
		else
			tl = snprintf(p, sz, "SMB C");
		p += tl;
		sz -= tl;

		/* The name, if known, else the cmd code */
		if (decoder->name) {
			tl = snprintf(p, sz, " Cmd=SMB%s", decoder->name);
		} else {
			tl = snprintf(p, sz, " Cmd=0x%02X", smb->com);
		}
		p += tl;
		sz -= tl;

		/*
		 * The "extra" (cmd-specific summary).
		 * If non-null, has leading blank.
		 */
		if (xtra[0] != '\0') {
			tl = snprintf(p, sz, "%s", xtra);
			p += tl;
			sz -= tl;
		}

		/*
		 * NT status or error class/code
		 * [X/Open-SMB, Sec. 5.6]
		 *
		 * Only show for response, not call.
		 */
		if (smb->flags & SERVER_RESPONSE) {
			if (smb_flags2 & FLAGS2_NT_STATUS) {
				uint_t status = get4(smb->err);
				snprintf(p, sz, " Status=0x%x", status);
			} else {
				uchar_t errcl = smb->err[0];
				ushort_t code = get2(&smb->err[2]);
				snprintf(p, sz, " Error=%d/%d", errcl, code);
			}
		}
	}

	if (flags & F_DTAIL)
		show_trailer();
}
示例#26
0
static void
interpret_default(int flags, uchar_t *data, int len, char *xtra, int xsz)
{
	int slength;
	int i, tl;
	int isunicode;
	int printit;
	int wordcount;
	int outsz;
	char *outstr;
	char *format;
	char valuetype;
	char word[10];
	char *label;
	char tempstr[256];
	uchar_t *comdata, *limit;
	char buff[80];
	struct smb *smbdata;
	struct decode *decoder;
	uchar_t bval;
	ushort_t wval;
	ushort_t smb_flags2;
	uint_t lval;

	smbdata  = (struct smb *)data;
	smb_flags2 = get2(smbdata->flags2);
	comdata = (uchar_t *)data + sizeof (struct smb);
	wordcount = *comdata++;
	limit = data + len;

	isunicode = smb_flags2 & FLAGS2_UNICODE;
	decoder = &SMBtable[smbdata->com & 255];

	if (smbdata->flags & SERVER_RESPONSE)
		format = decoder->replyfmt;
	else
		format = decoder->callfmt;

	if (!format || strlen(format) == 0) {
		if (flags & F_SUM)
			return;
		show_printf("WordCount = %d", wordcount);
		if (wordcount == 0)
			return;
		show_line("Word values (in hex):");
		buff[0] = '\0';
		for (i = 0; i < wordcount; i++) {
			snprintf(word, sizeof (word), "%.4x ", get2(comdata));
			comdata += 2;
			if (comdata >= limit)
				wordcount = i+1; /* terminate */
			(void) strlcat(buff, word, sizeof (buff));
			if (((i+1) & 7) == 0 || i == (wordcount-1)) {
				show_line(buff);
				strcpy(buff, "");
			}
		}
		return;
	}

	if (flags & F_DTAIL)
		show_printf("WordCount = %d", wordcount);

	outstr = xtra;
	outsz = xsz;

	valuetype = format[0];
	while (valuetype != '\0') {
		if (comdata >= limit)
			break;
		label = format+1;
		printit = (flags & F_DTAIL) || (valuetype <= 'Z');

		switch (valuetype) {
		case 'W':
		case 'w':
			wval = get2(comdata);
			comdata += 2;
			if (!printit)
				break;
			if (flags & F_DTAIL)
				show_printf(
				    "%s = 0x%.4x", label, wval);
			else {
				tl = snprintf(outstr, outsz,
				    " %s=0x%x", label, wval);
				outstr += tl;
				outsz -= tl;
			}
			break;

		case 'D':
		case 'd':
			wval = get2(comdata);
			comdata += 2;
			if (!printit)
				break;
			if (flags & F_DTAIL)
				show_printf(
				    "%s = %d", label, wval);
			else {
				tl = snprintf(outstr, outsz,
				    " %s=%d", label, wval);
				outstr += tl;
				outsz -= tl;
			}
			break;

		case 'L':
		case 'l':
			lval = get4(comdata);
			comdata += 4;
			if (!printit)
				break;
			if (flags & F_DTAIL)
				show_printf(
				    "%s = 0x%.8x", label, lval);
			else {
				tl = snprintf(outstr, outsz,
				    " %s=0x%x", label, lval);
				outstr += tl;
				outsz -= tl;
			}
			break;

		case 'B':
		case 'b':
			bval = comdata[0];
			comdata += 1;
			if (!printit)
				break;
			if (flags & F_DTAIL)
				show_printf(
				    "%s = 0x%.2x", label, bval);
			else {
				tl = snprintf(outstr, outsz,
				    " %s=0x%x", label, bval);
				outstr += tl;
				outsz -= tl;
			}
			break;

		case 'r':
			comdata++;
			break;

		case 'R':
			comdata += 2;
			break;

		case 'U':
		case 'u':
			/* Unicode or ASCII string. */
			GET_STRING(tempstr, comdata, isunicode);
			if (!printit)
				break;
			if (flags & F_DTAIL)
				show_printf(
				    "%s = %s", label, tempstr);
			else {
				tl = snprintf(outstr, outsz,
				    " %s=%s", label, tempstr);
				outstr += tl;
				outsz -= tl;
			}
			break;

		case 'S':
		case 's':
			slength = strlcpy(tempstr, (char *)comdata,
			    sizeof (tempstr));
			comdata += (slength+1);
			if (!printit)
				break;
			if (flags & F_DTAIL)
				show_printf(
				    "%s = %s", label, tempstr);
			else {
				tl = snprintf(outstr, outsz,
				    " %s=%s", label, tempstr);
				outstr += tl;
				outsz -= tl;
			}
			break;
		}
		format += (strlen(format) + 1);
		valuetype = format[0];
	}
}
示例#27
0
/* ARGSUSED */
static void
interpret_sesssetupX(int flags, uchar_t *data, int len, char *xtra, int xsz)
{
	int bytecount;
	int lm_pw_len;
	int ext_security;
	int sec_blob_len;
	int isunicode;
	int nt_pw_len;
	int wordcount;
	int cap;
	char tbuf[256];
	struct smb *smbdata;
	uchar_t *setupdata;
	ushort_t smb_flags2;

	smbdata  = (struct smb *)data;
	smb_flags2 = get2(smbdata->flags2);
	setupdata = (uchar_t *)data + sizeof (struct smb);
	wordcount = *setupdata++;

	isunicode = smb_flags2 & FLAGS2_UNICODE;
	ext_security = smb_flags2 & FLAGS2_EXT_SEC;

	if ((smbdata->flags & SERVER_RESPONSE) == 0) {
		/* request summary */
		if (flags & F_SUM) {
			if (ext_security) {
				/* No decoder for SPNEGO */
				snprintf(xtra, xsz, " (SPNEGO)");
				return;
			}
			if (wordcount != 13)
				return;
			setupdata += 14;
			lm_pw_len = get2(setupdata);
			setupdata += 2;
			nt_pw_len = get2(setupdata);
			setupdata += 6;
			cap = get4(setupdata);
			setupdata += 6 + lm_pw_len + nt_pw_len;

			GET_STRING(tbuf, setupdata, isunicode);
			snprintf(xtra, xsz, " Username=%s", tbuf);
		}

		if ((flags & F_DTAIL) == 0)
			return;

		/* request detail */
		show_printf("WordCount = %d", wordcount);
		if (wordcount < 7)
			return;
		/* words 0 - 6 */
		show_printf("ChainedCommand = 0x%.2x", setupdata[0]);
		setupdata += 2;
		show_printf("NextOffset = 0x%.4x", get2(setupdata));
		setupdata += 2;
		show_printf("MaxBufferSize = %d", get2(setupdata));
		setupdata += 2;
		show_printf("MaxMPXRequests = %d", get2(setupdata));
		setupdata += 2;
		show_printf("VCNumber = %d", get2(setupdata));
		setupdata += 2;
		show_printf("SessionKey = 0x%.8x", get4(setupdata));
		setupdata += 4;

		if (ext_security) {
			if (wordcount != 12)
				return;
			/* word 7 */
			sec_blob_len = get2(setupdata);
			setupdata += 2;
			show_printf("Sec. blob len = %d", sec_blob_len);
			/* words 8, 9 (reserved) */
			setupdata += 4;
		} else {
			if (wordcount != 13)
				return;
			/* word 7 */
			lm_pw_len = get2(setupdata);
			setupdata += 2;
			show_printf("LM_Hash_Len = %d", lm_pw_len);
			/* word 8 */
			nt_pw_len = get2(setupdata);
			setupdata += 2;
			show_printf("NT_Hash_Len = %d", nt_pw_len);
			/* words 9, 10 (reserved) */
			setupdata += 4;
		}

		cap = get4(setupdata);
		show_printf("Capabilities = 0x%.8x", cap);
		setupdata += 4;

		bytecount = get2(setupdata);
		setupdata += 2;
		show_printf("ByteCount = %d", bytecount);

		if (ext_security) {
			/* No decoder for SPNEGO.  Just dump hex. */
			show_printf("Security blob: (SPNEGO)");
			output_bytes(setupdata, sec_blob_len);
			setupdata += sec_blob_len;
		} else {
			/* Dump password hashes */
			if (lm_pw_len > 0) {
				show_printf("LM Hash (%d bytes)", lm_pw_len);
				output_bytes(setupdata, lm_pw_len);
				setupdata += lm_pw_len;
			}
			if (nt_pw_len > 0) {
				show_printf("NT Hash (%d bytes)", nt_pw_len);
				output_bytes(setupdata, nt_pw_len);
				setupdata += nt_pw_len;
			}

			/* User */
			GET_STRING(tbuf, setupdata, isunicode);
			show_printf("AccountName = %s", tbuf);

			/* Domain */
			GET_STRING(tbuf, setupdata, isunicode);
			show_printf("DomainName = %s", tbuf);
		}

		/*
		 * Remainder is the same for etc. sec. or not
		 * Native OS, Native LanMan
		 */
		GET_STRING(tbuf, setupdata, isunicode);
		show_printf("NativeOS = %s", tbuf);

		GET_STRING(tbuf, setupdata, isunicode);
		show_printf("NativeLanman = %s", tbuf);
	} else {
		/* response summary */
		if (flags & F_SUM) {
			if (ext_security) {
				/* No decoder for SPNEGO */
				snprintf(xtra, xsz, " (SPNEGO)");
			}
			return;
		}

		if ((flags & F_DTAIL) == 0)
			return;

		/* response detail */
		show_printf("WordCount = %d", wordcount);
		if (wordcount < 3)
			return;

		show_printf("ChainedCommand = 0x%.2x", setupdata[0]);
		setupdata += 2;
		show_printf("NextOffset = 0x%.4x", get2(setupdata));
		setupdata += 2;
		show_printf("SetupAction = 0x%.4x", get2(setupdata));
		setupdata += 2;

		if (ext_security) {
			if (wordcount != 4)
				return;
			sec_blob_len = get2(setupdata);
			setupdata += 2;
			show_printf("Sec. blob len = %d", sec_blob_len);
		} else {
			if (wordcount != 3)
				return;
		}

		bytecount = get2(setupdata);
		setupdata += 2;
		show_printf("ByteCount = %d", bytecount);

		if (ext_security) {
			/* No decoder for SPNEGO.  Just dump hex. */
			show_line("Security blob: (SPNEGO)");
			output_bytes(setupdata, sec_blob_len);
			setupdata += sec_blob_len;
		}

		/*
		 * Native OS, Native LanMan
		 */
		GET_STRING(tbuf, setupdata, isunicode);
		show_printf("NativeOS = %s", tbuf);

		GET_STRING(tbuf, setupdata, isunicode);
		show_printf("NativeLanman = %s", tbuf);

		if (ext_security == 0) {
			GET_STRING(tbuf, setupdata, isunicode);
			show_printf("DomainName = %s", tbuf);
		}
	}
}
示例#28
0
文件: ctrl.c 项目: pciavald/42
static int	exit_handler(void)
{
	show_line(1);
	treset(data());
	return (EXIT);
}
示例#29
0
文件: grep.c 项目: sanj/git
static int grep_buffer_1(struct grep_opt *opt, const char *name,
			 char *buf, unsigned long size, int collect_hits)
{
	char *bol = buf;
	unsigned long left = size;
	unsigned lno = 1;
	unsigned last_hit = 0;
	int binary_match_only = 0;
	unsigned count = 0;
	int try_lookahead = 0;
	enum grep_context ctx = GREP_CONTEXT_HEAD;
	xdemitconf_t xecfg;

	opt->last_shown = 0;

	if (!opt->output)
		opt->output = std_output;

	if (buffer_is_binary(buf, size)) {
		switch (opt->binary) {
		case GREP_BINARY_DEFAULT:
			binary_match_only = 1;
			break;
		case GREP_BINARY_NOMATCH:
			return 0; /* Assume unmatch */
			break;
		default:
			break;
		}
	}

	memset(&xecfg, 0, sizeof(xecfg));
	if (opt->funcname && !opt->unmatch_name_only && !opt->status_only &&
	    !opt->name_only && !binary_match_only && !collect_hits) {
		struct userdiff_driver *drv = userdiff_find_by_path(name);
		if (drv && drv->funcname.pattern) {
			const struct userdiff_funcname *pe = &drv->funcname;
			xdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);
			opt->priv = &xecfg;
		}
	}
	try_lookahead = should_lookahead(opt);

	while (left) {
		char *eol, ch;
		int hit;

		/*
		 * look_ahead() skips quicly to the line that possibly
		 * has the next hit; don't call it if we need to do
		 * something more than just skipping the current line
		 * in response to an unmatch for the current line.  E.g.
		 * inside a post-context window, we will show the current
		 * line as a context around the previous hit when it
		 * doesn't hit.
		 */
		if (try_lookahead
		    && !(last_hit
			 && lno <= last_hit + opt->post_context)
		    && look_ahead(opt, &left, &lno, &bol))
			break;
		eol = end_of_line(bol, &left);
		ch = *eol;
		*eol = 0;

		if ((ctx == GREP_CONTEXT_HEAD) && (eol == bol))
			ctx = GREP_CONTEXT_BODY;

		hit = match_line(opt, bol, eol, ctx, collect_hits);
		*eol = ch;

		if (collect_hits)
			goto next_line;

		/* "grep -v -e foo -e bla" should list lines
		 * that do not have either, so inversion should
		 * be done outside.
		 */
		if (opt->invert)
			hit = !hit;
		if (opt->unmatch_name_only) {
			if (hit)
				return 0;
			goto next_line;
		}
		if (hit) {
			count++;
			if (opt->status_only)
				return 1;
			if (binary_match_only) {
				opt->output(opt, "Binary file ", 12);
				output_color(opt, name, strlen(name),
					     opt->color_filename);
				opt->output(opt, " matches\n", 9);
				return 1;
			}
			if (opt->name_only) {
				show_name(opt, name);
				return 1;
			}
			/* Hit at this line.  If we haven't shown the
			 * pre-context lines, we would need to show them.
			 * When asked to do "count", this still show
			 * the context which is nonsense, but the user
			 * deserves to get that ;-).
			 */
			if (opt->pre_context)
				show_pre_context(opt, name, buf, bol, lno);
			else if (opt->funcname)
				show_funcname_line(opt, name, buf, bol, lno);
			if (!opt->count)
				show_line(opt, bol, eol, name, lno, ':');
			last_hit = lno;
		}
		else if (last_hit &&
			 lno <= last_hit + opt->post_context) {
			/* If the last hit is within the post context,
			 * we need to show this line.
			 */
			show_line(opt, bol, eol, name, lno, '-');
		}

	next_line:
		bol = eol + 1;
		if (!left)
			break;
		left--;
		lno++;
	}

	if (collect_hits)
		return 0;

	if (opt->status_only)
		return 0;
	if (opt->unmatch_name_only) {
		/* We did not see any hit, so we want to show this */
		show_name(opt, name);
		return 1;
	}

	xdiff_clear_find_func(&xecfg);
	opt->priv = NULL;

	/* NEEDSWORK:
	 * The real "grep -c foo *.c" gives many "bar.c:0" lines,
	 * which feels mostly useless but sometimes useful.  Maybe
	 * make it another option?  For now suppress them.
	 */
	if (opt->count && count) {
		char buf[32];
		output_color(opt, name, strlen(name), opt->color_filename);
		output_sep(opt, ':');
		snprintf(buf, sizeof(buf), "%u\n", count);
		opt->output(opt, buf, strlen(buf));
	}
	return !!last_hit;
}
示例#30
0
文件: grep.c 项目: 2quala/git
static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int collect_hits)
{
	char *bol;
	unsigned long left;
	unsigned lno = 1;
	unsigned last_hit = 0;
	int binary_match_only = 0;
	unsigned count = 0;
	int try_lookahead = 0;
	int show_function = 0;
	struct userdiff_driver *textconv = NULL;
	enum grep_context ctx = GREP_CONTEXT_HEAD;
	xdemitconf_t xecfg;

	if (!opt->output)
		opt->output = std_output;

	if (opt->pre_context || opt->post_context || opt->file_break ||
	    opt->funcbody) {
		/* Show hunk marks, except for the first file. */
		if (opt->last_shown)
			opt->show_hunk_mark = 1;
		/*
		 * If we're using threads then we can't easily identify
		 * the first file.  Always put hunk marks in that case
		 * and skip the very first one later in work_done().
		 */
		if (opt->output != std_output)
			opt->show_hunk_mark = 1;
	}
	opt->last_shown = 0;

	if (opt->allow_textconv) {
		grep_source_load_driver(gs);
		/*
		 * We might set up the shared textconv cache data here, which
		 * is not thread-safe.
		 */
		grep_attr_lock();
		textconv = userdiff_get_textconv(gs->driver);
		grep_attr_unlock();
	}

	/*
	 * We know the result of a textconv is text, so we only have to care
	 * about binary handling if we are not using it.
	 */
	if (!textconv) {
		switch (opt->binary) {
		case GREP_BINARY_DEFAULT:
			if (grep_source_is_binary(gs))
				binary_match_only = 1;
			break;
		case GREP_BINARY_NOMATCH:
			if (grep_source_is_binary(gs))
				return 0; /* Assume unmatch */
			break;
		case GREP_BINARY_TEXT:
			break;
		default:
			die("bug: unknown binary handling mode");
		}
	}

	memset(&xecfg, 0, sizeof(xecfg));
	opt->priv = &xecfg;

	try_lookahead = should_lookahead(opt);

	if (fill_textconv_grep(textconv, gs) < 0)
		return 0;

	bol = gs->buf;
	left = gs->size;
	while (left) {
		char *eol, ch;
		int hit;

		/*
		 * look_ahead() skips quickly to the line that possibly
		 * has the next hit; don't call it if we need to do
		 * something more than just skipping the current line
		 * in response to an unmatch for the current line.  E.g.
		 * inside a post-context window, we will show the current
		 * line as a context around the previous hit when it
		 * doesn't hit.
		 */
		if (try_lookahead
		    && !(last_hit
			 && (show_function ||
			     lno <= last_hit + opt->post_context))
		    && look_ahead(opt, &left, &lno, &bol))
			break;
		eol = end_of_line(bol, &left);
		ch = *eol;
		*eol = 0;

		if ((ctx == GREP_CONTEXT_HEAD) && (eol == bol))
			ctx = GREP_CONTEXT_BODY;

		hit = match_line(opt, bol, eol, ctx, collect_hits);
		*eol = ch;

		if (collect_hits)
			goto next_line;

		/* "grep -v -e foo -e bla" should list lines
		 * that do not have either, so inversion should
		 * be done outside.
		 */
		if (opt->invert)
			hit = !hit;
		if (opt->unmatch_name_only) {
			if (hit)
				return 0;
			goto next_line;
		}
		if (hit) {
			count++;
			if (opt->status_only)
				return 1;
			if (opt->name_only) {
				show_name(opt, gs->name);
				return 1;
			}
			if (opt->count)
				goto next_line;
			if (binary_match_only) {
				opt->output(opt, "Binary file ", 12);
				output_color(opt, gs->name, strlen(gs->name),
					     opt->color_filename);
				opt->output(opt, " matches\n", 9);
				return 1;
			}
			/* Hit at this line.  If we haven't shown the
			 * pre-context lines, we would need to show them.
			 */
			if (opt->pre_context || opt->funcbody)
				show_pre_context(opt, gs, bol, eol, lno);
			else if (opt->funcname)
				show_funcname_line(opt, gs, bol, lno);
			show_line(opt, bol, eol, gs->name, lno, ':');
			last_hit = lno;
			if (opt->funcbody)
				show_function = 1;
			goto next_line;
		}
		if (show_function && match_funcname(opt, gs, bol, eol))
			show_function = 0;
		if (show_function ||
		    (last_hit && lno <= last_hit + opt->post_context)) {
			/* If the last hit is within the post context,
			 * we need to show this line.
			 */
			show_line(opt, bol, eol, gs->name, lno, '-');
		}

	next_line:
		bol = eol + 1;
		if (!left)
			break;
		left--;
		lno++;
	}

	if (collect_hits)
		return 0;

	if (opt->status_only)
		return 0;
	if (opt->unmatch_name_only) {
		/* We did not see any hit, so we want to show this */
		show_name(opt, gs->name);
		return 1;
	}

	xdiff_clear_find_func(&xecfg);
	opt->priv = NULL;

	/* NEEDSWORK:
	 * The real "grep -c foo *.c" gives many "bar.c:0" lines,
	 * which feels mostly useless but sometimes useful.  Maybe
	 * make it another option?  For now suppress them.
	 */
	if (opt->count && count) {
		char buf[32];
		if (opt->pathname) {
			output_color(opt, gs->name, strlen(gs->name),
				     opt->color_filename);
			output_sep(opt, ':');
		}
		snprintf(buf, sizeof(buf), "%u\n", count);
		opt->output(opt, buf, strlen(buf));
		return 1;
	}
	return !!last_hit;
}