gets.c

来自「著名操作系统Plan 9的第三版的部分核心源代码。现在很难找到了。Plan 9是」· C语言 代码 · 共 42 行

C
42
字号
#include	<u.h>#include	<libc.h>#include 	<auth.h>#include	<fcall.h>/* *  read a message from fd and convert it. *  ignore 0-length messages. */char *getS(int fd, char *buf, Fcall *f, long *lp){	long m, n;	int i, j;	char *errstr;	errstr = "EOF";	n = 0;	for(i = 0; i < 3; i++){		n = read(fd, buf, *lp);		if(n == 0){			fprint(2, "getS: read retry\n");			continue;		}		if(n < 0)			return "read error";		m = convM2S(buf, f, n);		if(m == 0){			fprint(2, "getS: retry bad type, n=%ld\n", n);			for(j=0; j<10; j++)				fprint(2, "%.2ux ", buf[j]&0xFF);			fprint(2, "\n");			errstr = "bad type";			continue;		}		*lp = m;		return 0;	}	*lp = n;	return errstr;}

⌨️ 快捷键说明

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