摘要: file/filetype.c #include "apue.h"intmain(int argc, char *argv[]){ int i; struct stat buf; char *ptr; for (i = 1; i < argc; i++) { printf("%s: ", argv[i]); if (lstat(argv[i], &buf) < 0) { err_r... 阅读全文
posted @ 2014-07-16 23:21 paullam 阅读(240) 评论(0) 推荐(0) 编辑
摘要: lib/setfl.c #include "apue.h"#include voidset_fl(int fd, int flags) /* flags are file status flags to turn on */{ int val; if ((val = fcntl(fd, F_GETFL, 0)) < 0) err_sys("fcntl F_GETFL error"); val... 阅读全文
posted @ 2014-07-16 23:18 paullam 阅读(152) 评论(0) 推荐(0) 编辑
摘要: file/fileflags.c #include "apue.h"#include intmain(int argc, char *argv[]){ int val; if (argc != 2) err_quit("usage: a.out "); if ((val = fcntl(atoi(argv[1]), F_GETFL, 0)) < 0) err_sys("fcntl erro... 阅读全文
posted @ 2014-07-16 23:16 paullam 阅读(246) 评论(0) 推荐(0) 编辑
摘要: mycat/mycat.c#include "apue.h"#define BUFFSIZE 4096intmain(void){ int n; char buf[BUFFSIZE]; while ((n = read(STDIN_FILENO, buf, BUFFSIZE)) > 0) if ... 阅读全文
posted @ 2014-07-16 23:13 paullam 阅读(146) 评论(0) 推荐(0) 编辑
摘要: file/hole.c #include "apue.h"#include char buf1[] = "abcdefghij";char buf2[] = "ABCDEFGHIJ";intmain(void){ int fd; if ((fd = creat("file.hole", FILE_MODE)) < 0) err_sys("creat error"); if (write(fd... 阅读全文
posted @ 2014-07-16 23:11 paullam 阅读(201) 评论(0) 推荐(0) 编辑
摘要: file/seek.c#include "apue.h"intmain(void){ if (lseek(STDIN_FILENO, 0, SEEK_CUR) == -1) printf("cannot seek\n"); else printf("seek OK\n"); exit(0);} 阅读全文
posted @ 2014-07-16 23:03 paullam 阅读(219) 评论(0) 推荐(0) 编辑
摘要: lib/openmax.c#include "apue.h"#include #include #ifdef OPEN_MAXstatic long openmax = OPEN_MAX;#elsestatic long openmax = 0;#endif/* * If OPEN_MAX is i... 阅读全文
posted @ 2014-07-16 23:01 paullam 阅读(236) 评论(0) 推荐(0) 编辑
摘要: lib/pathalloc.c#include "apue.h"#include #include #ifdef PATH_MAXstatic int pathmax = PATH_MAX;#elsestatic int pathmax = 0;#endif#define SUSV3 200112L... 阅读全文
posted @ 2014-07-16 22:58 paullam 阅读(204) 评论(0) 推荐(0) 编辑
摘要: (1) sysconf() 返回选项 (变量) 的当前值,这个值可配置的但也是受系统限制的。在成功完成的情况下,sysconf() 返回变量的当前值。该值受到的限制将少于编译时 , 或 中可用的对应值。大多数这些变量的值在调用进程的生存时间内不变。如果出错,那么函数返回 -1 ,并适当地设置 e... 阅读全文
posted @ 2014-07-16 22:57 paullam 阅读(464) 评论(0) 推荐(0) 编辑