myopen.c

来自「C-C++源代码行数计算器SrcLines.zip」· C语言 代码 · 共 57 行

C
57
字号
/*  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 + =
减小字号Ctrl + -
显示快捷键?