亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? p4

?? unix v7是最后一個廣泛發布的研究型UNIX版本
??
字號:
.NHLOW-LEVEL I/O.PPThis section describes the bottom level of I/O on the.UC UNIXsystem.The lowest level of I/O in.UC UNIXprovides no buffering or any other services;it is in fact a direct entry into the operating system.You are entirely on your own,but on the other hand,you have the most control over what happens.And since the calls and usage are quite simple,this isn't as bad as it sounds..NH 2File Descriptors.PPIn the.UC UNIXoperating system,all input and output is doneby reading or writing files,because all peripheral devices, even the user's terminal,are files in the file system.This means that a single, homogeneous interfacehandles all communication between a program and peripheral devices..PPIn the most general case,before reading or writing a file,it is necessary to inform the systemof your intent to do so,a process called``opening'' the file.If you are going to write on a file,it may also be necessary to create it.The system checks your right to do so(Does the file exist?Do you have permission to access it?),and if all is well,returns a small positive integercalled a.ulfile descriptor.Whenever I/O is to be done on the file,the file descriptor is used instead of the name to identify the file.(This is roughly analogous to the use of.UC READ(5,...)and.UC WRITE(6,...)in Fortran.)Allinformation about an open file is maintained by the system;the user program refers to the fileonlyby the file descriptor..PPThe file pointers discussed in section 3are similar in spirit to file descriptors,but file descriptors are more fundamental.A file pointer is a pointer to a structure that contains,among other things, the file descriptor for the file in question..PPSince input and output involving the user's terminalare so common,special arrangements exist to make this convenient.When the command interpreter (the``shell'')runs a program,it opensthree files, with file descriptors 0, 1, and 2,called the standard input,the standard output, and the standard error output.All of these are normally connected to the terminal,so if a program reads file descriptor 0and writes file descriptors 1 and 2,it can do terminal I/Owithout worrying about opening the files..PPIf I/O is redirected to and from files with.UL < and.UL > ,as in.P1prog <infile >outfile.P2the shell changes the default assignments for file descriptors0 and 1from the terminal to the named files.Similar observations hold if the input or output is associated with a pipe.Normally file descriptor 2 remains attached to the terminal,so error messages can go there.In all cases,the file assignments are changed by the shell,not by the program.The program does not need to know where its inputcomes from nor where its output goes,so long as it uses file 0 for input and 1 and 2 for output..NH 2Read and Write.PPAll input and output is done bytwo functions called.UL readand.UL write .For both, the first argument is a file descriptor.The second argument is a buffer in your program where the data is tocome from or go to.The third argument is the number of bytes to be transferred.The calls are.P1n_read = read(fd, buf, n);n_written = write(fd, buf, n);.P2Each call returns a byte countwhich is the number of bytes actually transferred.On reading,the number of bytes returned may be less thanthe number asked for,because fewer than.UL nbytes remained to be read.(When the file is a terminal,.UL readnormally reads only up to the next newline,which is generally less than what was requested.)A return value of zero bytes implies end of file,and.UL -1indicates an error of some sort.For writing, the returned value is the number of bytesactually written;it is generally an error if this isn't equalto the number supposed to be written..PPThe number of bytes to be read or written is quite arbitrary.The two most common values are 1,which means one character at a time(``unbuffered''),and512,which corresponds to a physical blocksize on many peripheral devices.This latter size will be most efficient,but even character at a time I/Ois not inordinately expensive..PPPutting these facts together,we can write a simple program to copyits input to its output.This program will copy anything to anything,since the input and output can be redirected to any file or device..P1#define	BUFSIZE	512	/* best size for PDP-11 UNIX */main()	/* copy input to output */{	char	buf[BUFSIZE];	int	n;	while ((n = read(0, buf, BUFSIZE)) > 0)		write(1, buf, n);	exit(0);}.P2If the file size is not a multiple of.UL BUFSIZE ,some .UL readwill return a smaller number of bytesto be written by.UL write ;the next call to .UL readafter thatwill return zero..PPIt is instructive to see how.UL readand.UL writecan be used to constructhigher level routines like.UL getchar ,.UL putchar ,etc.For example,here is a version of.UL getcharwhich does unbuffered input..P1#define	CMASK	0377	/* for making char's > 0 */getchar()	/* unbuffered single character input */{	char c;	return((read(0, &c, 1) > 0) ? c & CMASK : EOF);}.P2.UL c.ulmustbe declared.UL char ,because.UL readaccepts a character pointer.The character being returned must be masked with.UL 0377to ensure that it is positive;otherwise sign extension may make it negative.(The constant.UL 0377is appropriate for the.UC PDP -11but not necessarily for other machines.).PPThe second version of.UL getchardoes input in big chunks,and hands out the characters one at a time..P1#define	CMASK	0377	/* for making char's > 0 */#define	BUFSIZE	512getchar()	/* buffered version */{	static char	buf[BUFSIZE];	static char	*bufp = buf;	static int	n = 0;	if (n == 0) {	/* buffer is empty */		n = read(0, buf, BUFSIZE);		bufp = buf;	}	return((--n >= 0) ? *bufp++ & CMASK : EOF);}.P2.NH 2Open, Creat, Close, Unlink.PPOther than the defaultstandard input, output and error files,you must explicitly open files in order toread or write them.There are two system entry points for this,.UL openand.UL creat [sic]..PP.UL openis rather like the.UL  fopendiscussed in the previous section,except that instead of returning a file pointer,it returns a file descriptor,which is just an.UL int ..P1int fd;fd = open(name, rwmode);.P2As with.UL fopen ,the.UL nameargumentis a character string corresponding to the external file name.The access mode argumentis different, however:.UL rwmodeis 0 for read, 1 for write, and 2 for read and write access..UL openreturns.UL -1if any error occurs;otherwise it returns a valid file descriptor..PPIt is an error to try to.UL opena file that does not exist.The entry point.UL creatis provided to create new files,or to re-write old ones..P1fd = creat(name, pmode);.P2returns a file descriptorif it was able to create the filecalled.UL name ,and.UL -1if not.If the filealready exists,.UL creatwill truncate it to zero length;it is not an error to.UL creata file that already exists..PPIf the file is brand new,.UL creatcreates it with the.ulprotection mode specified bythe.UL pmodeargument.In the.UC UNIXfile system,there are nine bits of protection informationassociated with a file,controlling read, write and execute permission forthe owner of the file,for the owner's group,and for all others.Thus a three-digit octal numberis most convenient for specifying the permissions.For example,0755specifies read, write and execute permission for the owner,and read and execute permission for the group and everyone else..PPTo illustrate,here is a simplified version ofthe.UC UNIXutility.IT cp ,a program which copies one file to another.(The main simplification is that our versioncopies only one file,and does not permit the second argumentto be a directory.).P1#define NULL 0#define BUFSIZE 512#define PMODE 0644 /* RW for owner, R for group, others */main(argc, argv)	/* cp: copy f1 to f2 */int argc;char *argv[];{	int	f1, f2, n;	char	buf[BUFSIZE];	if (argc != 3)		error("Usage: cp from to", NULL);	if ((f1 = open(argv[1], 0)) == -1)		error("cp: can't open %s", argv[1]);	if ((f2 = creat(argv[2], PMODE)) == -1)		error("cp: can't create %s", argv[2]);	while ((n = read(f1, buf, BUFSIZE)) > 0)		if (write(f2, buf, n) != n)			error("cp: write error", NULL);	exit(0);}.P2.P1error(s1, s2)	/* print error message and die */char *s1, *s2;{	printf(s1, s2);	printf("\n");	exit(1);}.P2.PPAs we said earlier,there is a limit (typically 15-25)on the number of files which a programmay have open simultaneously.Accordingly, any program which intends to processmany files must be prepared to re-usefile descriptors.The routine.UL closebreaks the connection between a file descriptorand an open file,and frees thefile descriptor for use with some other file.Termination of a programvia.UL exitor return from the main program closes all open files..PPThe function.UL unlink(filename)removes the file.UL filenamefrom the file system..NH 2Random Access \(em Seek and Lseek.PPFile I/O is normally sequential:each.UL reador.UL writetakes place at a position in the fileright after the previous one.When necessary, however,a file can be read or written in any arbitrary order.Thesystem call.UL lseekprovides a way to move around ina file without actually readingor writing:.P1lseek(fd, offset, origin);.P2forces the current position in the filewhose descriptor is.UL fdto move to position.UL offset ,which is taken relative to the locationspecified by.UL origin .Subsequent reading or writing will begin at that position..UL offsetisa.UL long ;.UL fdand.UL originare.UL int 's..UL origincan be 0, 1, or 2 to specify that .UL offsetis to bemeasured fromthe beginning, from the current position, or from theend of the file respectively.For example,to append to a file,seek to the end before writing:.P1lseek(fd, 0L, 2);.P2To get back to the beginning (``rewind''),.P1lseek(fd, 0L, 0);.P2Notice the.UL 0Largument;it could also be written as.UL (long)\ 0 ..PPWith .UL lseek ,it is possible to treat files more or less like large arrays,at the price of slower access.For example, the following simple function reads any number of bytesfrom any arbitrary place in a file..P1get(fd, pos, buf, n) /* read n bytes from position pos */int fd, n;long pos;char *buf;{	lseek(fd, pos, 0);	/* get to pos */	return(read(fd, buf, n));}.P2.PPIn pre-version 7.UC UNIX ,the basic entry point to the I/O systemis called.UL seek ..UL seekis identical to.UL lseek ,except that its.UL  offset argument is an.UL intrather than  a.UL long .Accordingly,since.UC PDP -11integers have only 16 bits,the.UL offsetspecifiedfor.UL seekis limited to 65,535;for this reason,.UL originvalues of 3, 4, 5 cause.UL seekto multiply the given offset by 512(the number of bytes in one physical block)and then interpret.UL originas if it were 0, 1, or 2 respectively.Thus to get to an arbitrary place in a large filerequires two seeks, first one which selectsthe block, then one whichhas.UL originequal to 1 and moves to the desired byte within the block..NH 2Error Processing.PPThe routines discussed in this section,and in fact all the routines which are direct entries into the systemcan incur errors.Usually they indicate an error by returning a value of \-1.Sometimes it is nice to know what sort of error occurred;for this purpose all these routines, when appropriate,leave an error number in the external cell.UL errno .The meanings of the various error numbers arelistedin the introduction to Section IIof the.I.UC UNIXProgrammer's Manual,.Rso your program can, for example, determine ifan attempt to open a file failed because it did not existor because the user lacked permission to read it.Perhaps more commonly,you may want to print out thereason for failure.The routine.UL perrorwill print a message associated with the valueof.UL errno ;more generally,.UL sys\_errnois an array of character strings which can be indexedby.UL errnoand printed by your program.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
人人精品人人爱| 国产一区二区在线免费观看| 26uuu另类欧美亚洲曰本| 欧美性猛片aaaaaaa做受| av中文字幕在线不卡| 粉嫩嫩av羞羞动漫久久久 | 欧美一区二区三区思思人| 欧美视频中文字幕| 日韩小视频在线观看专区| 91精品国产色综合久久不卡电影 | 美国十次了思思久久精品导航| 亚洲成人自拍网| 午夜不卡在线视频| 天堂精品中文字幕在线| 丝袜亚洲精品中文字幕一区| 国产精品一区久久久久| 成人性生交大片免费看在线播放 | 欧美国产成人精品| 国产精品灌醉下药二区| 中文字幕一区二区三区在线观看| 一区二区中文字幕在线| 奇米精品一区二区三区在线观看一 | 福利一区二区在线观看| 欧美另类久久久品| 91精品免费在线| 日韩欧美久久久| 国产日韩欧美不卡在线| 国产精品久久福利| 麻豆精品一二三| 色妞www精品视频| 国产91精品免费| 7777精品伊人久久久大香线蕉经典版下载 | 69av一区二区三区| 亚洲女同ⅹxx女同tv| 亚洲一级在线观看| 青娱乐精品视频| 91同城在线观看| 欧美精品欧美精品系列| 中文av一区特黄| 亚洲国产你懂的| 久久国产福利国产秒拍| 国v精品久久久网| 欧美一级片免费看| 亚洲最大成人网4388xx| 奇米亚洲午夜久久精品| 在线观看日韩毛片| 精品国产污污免费网站入口 | 调教+趴+乳夹+国产+精品| 成人福利视频网站| 欧美亚洲一区二区在线观看| 国产片一区二区三区| 美日韩一区二区三区| 欧美色区777第一页| 欧美大尺度电影在线| 久久精品亚洲精品国产欧美kt∨ | 91蜜桃网址入口| 国产欧美日韩在线看| 紧缚捆绑精品一区二区| 99久久婷婷国产精品综合| 91麻豆精品国产自产在线观看一区| 五月天久久比比资源色| 在线区一区二视频| 亚洲欧美日韩一区二区| 99这里只有精品| 国产精品久久毛片a| 国产成人在线免费观看| 欧洲精品中文字幕| 亚洲欧美激情小说另类| 99re热视频精品| 国产精品福利一区二区三区| 国产精品99久| 久久精品夜色噜噜亚洲aⅴ| 国产一区二区三区四区五区美女 | 亚洲成人免费视频| 91国产免费看| 樱花草国产18久久久久| 国产一区二区在线看| 日韩欧美国产1| 麻豆久久久久久| 26uuu精品一区二区在线观看| 激情综合色播激情啊| 一本一道久久a久久精品| 1024亚洲合集| 在线欧美一区二区| 一区二区三区四区高清精品免费观看 | 欧美一区二区三区四区高清| 日韩中文字幕区一区有砖一区| 欧美精品 日韩| 蜜臀av性久久久久蜜臀aⅴ| 欧美xingq一区二区| 国产精品综合网| 中文字幕一区三区| 欧美在线观看一区二区| 亚欧色一区w666天堂| 欧美一区二区三区免费大片 | 国产色产综合色产在线视频 | 亚洲国产综合在线| 在线播放/欧美激情| 精品亚洲porn| 亚洲国产精华液网站w | 午夜国产精品影院在线观看| 自拍偷拍亚洲综合| 国产剧情一区二区| 亚洲欧美在线观看| 在线欧美一区二区| 久久成人免费网站| 中文字幕一区二区三区在线播放 | 亚洲一区在线免费观看| 欧美精品丝袜中出| 国产精品一区在线观看乱码 | 色婷婷综合视频在线观看| 午夜久久久久久电影| 久久综合九色综合久久久精品综合| 国产成人午夜高潮毛片| 亚洲一区二区三区精品在线| 日韩欧美你懂的| 97se狠狠狠综合亚洲狠狠| 亚洲福利视频一区| 久久精品亚洲精品国产欧美kt∨| 在线观看视频一区二区| 九九**精品视频免费播放| 国产精品久久久爽爽爽麻豆色哟哟| 欧美图区在线视频| 国产在线观看一区二区| 亚洲激情在线播放| 精品国产乱码久久久久久1区2区| 99热精品国产| 精品亚洲成av人在线观看| 亚洲女与黑人做爰| 久久精品夜色噜噜亚洲a∨| 欧美性大战久久久久久久| 国内精品久久久久影院色| 亚洲欧洲99久久| 欧美大胆人体bbbb| 欧洲一区二区三区在线| 国产凹凸在线观看一区二区| 亚洲国产日韩一级| 中文字幕免费不卡在线| 日韩欧美另类在线| 欧美三级在线播放| 成人不卡免费av| 黄色日韩网站视频| 亚洲成人av免费| 1区2区3区精品视频| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 欧美日韩国产乱码电影| 日本美女一区二区| 欧美激情一区二区三区四区 | 久久国产麻豆精品| 亚洲综合色网站| 自拍偷拍亚洲激情| 久久久精品tv| 在线免费观看日韩欧美| 成人久久视频在线观看| 韩国毛片一区二区三区| 午夜成人免费视频| 亚洲自拍都市欧美小说| 国产精品三级久久久久三级| 欧美本精品男人aⅴ天堂| 欧美乱妇15p| 欧美自拍偷拍一区| 色老汉一区二区三区| 成人av手机在线观看| 国产麻豆一精品一av一免费| 日本伊人色综合网| 亚洲成人三级小说| 亚洲一区二区三区四区不卡| 亚洲欧洲日产国码二区| 亚洲国产精品99久久久久久久久| 久久综合色鬼综合色| 日韩美女在线视频 | 久久成人精品无人区| 日本在线不卡视频一二三区| 亚洲激情在线播放| 亚洲精品中文字幕乱码三区| 国产精品久久久久永久免费观看| 中文字幕国产一区| 国产日本一区二区| 中文字幕va一区二区三区| 久久久一区二区三区捆绑**| 久久先锋影音av| 久久先锋影音av鲁色资源| 久久在线观看免费| 久久久国产一区二区三区四区小说| 久久婷婷成人综合色| 久久久噜噜噜久久人人看| 久久综合久久久久88| 国产日韩三级在线| 国产欧美日韩精品在线| 国产精品日产欧美久久久久| 最近日韩中文字幕| 亚洲综合一二三区| 性感美女久久精品| 美女脱光内衣内裤视频久久网站| 日本不卡高清视频| 紧缚奴在线一区二区三区| 国产·精品毛片| 99国产精品久久久久| 在线观看三级视频欧美| 69堂国产成人免费视频|