📄 myopen.c
字号:
/* myopen.c For Free Chat By Bill Kendrick kendrick@zippy.sonoma.edu http://zippy.sonoma.edu/kendrick/ October 1, 1996 - June 7, 1998*/#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <fcntl.h>#include "myopen.h"#include "defines.h"/* Old myopen which used file locking when opening the file: */FILE * myopen(char * file, char * mode){ int modeint, fdi; FILE * fi; if (strcmp(mode, "r") == 0) modeint = O_RDONLY; else if (strcmp(mode, "w") == 0) modeint = O_CREAT | O_WRONLY | O_TRUNC; else if (strcmp(mode, "a") == 0) modeint = O_CREAT | O_WRONLY | O_APPEND; else return(NULL); fdi = open(file, modeint); if (fdi == -1) { printf("FDI returned -1!"); return(NULL); } #ifdef SYSV lockf(fdi, F_LOCK, 0);#else flock(fdi, LOCK_EX);#endif fi = fdopen(fdi, mode); return(fi);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -