?? 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 + -