x_cat.c,v

来自「关于SHELL方面的」· C,V 代码 · 共 66 行

C,V
66
字号
head	1.1;access;symbols;locks	dls:1.1; strict;comment	@ * @;1.1date	97.09.21.19.29.03;	author dls;	state Dist;branches;next	;desc@@1.1log@pre-3e code@text@/* x_cat.c - x_cat */#include <conf.h>#include <kernel.h>/*------------------------------------------------------------------------ *  x_cat  -  (command cat) concatenate files and write on stdout *------------------------------------------------------------------------ */COMMAND	x_cat(stdin, stdout, stderr, nargs, args)int	stdin, stdout, stderr, nargs;char	*args[];{	int	device;	char	*buf;	int	ret;	int	len;	int	i;	if ( (int) (buf = (char *)getmem(512)) == SYSERR) {		fprintf(stderr, "no memory\n");		return(SYSERR);	}	ret = OK;	if (nargs == 1) {		while ( (len=read(stdin, buf, 512)) > 0)			write(stdout, buf, len);	}	for (i=1 ; i<nargs ; i++) {		if ( (device = open(NAMESPACE,args[i],"ro")) == SYSERR) {			fprintf(stderr, "Cannot open %s\n", args[i]);			ret = SYSERR;			break;		}		while ( (len=read(device, buf, 512)) > 0)			write (stdout, buf, len);		close(device);	}	freemem(buf, 512);	return(ret);}@

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?