- int fd, access;
- FILE *fp;
-
- if (strcmp (mode, "r") == 0)
- access = O_RDONLY;
- else if (strcmp (mode, "r+") == 0)
- access = O_RDWR;
- else if (strcmp (mode, "w") == 0)
- access = O_WRONLY | O_CREAT | O_TRUNC;
- else if (strcmp (mode, "w+") == 0)
- access = O_RDWR | O_CREAT | O_TRUNC;
- else if (strcmp (mode, "a") == 0)
- access = O_WRONLY | O_CREAT | O_APPEND;
- else if (strcmp (mode, "a+") == 0)
- access = O_RDWR | O_CREAT | O_APPEND;
- else {
- errno = EINVAL;
- return NULL;
- }
-
- if ((fd = lkopen (file, access, 0666)) == -1)
- return NULL;
-
- if ((fp = fdopen (fd, mode)) == NULL) {
- close (fd);
- return NULL;
- }
-
- return fp;
+ int fd, access;
+ FILE *fp;
+
+ if (strcmp(mode, "r") == 0)
+ access = O_RDONLY;
+ else if (strcmp(mode, "r+") == 0)
+ access = O_RDWR;
+ else if (strcmp(mode, "w") == 0)
+ access = O_WRONLY | O_CREAT | O_TRUNC;
+ else if (strcmp(mode, "w+") == 0)
+ access = O_RDWR | O_CREAT | O_TRUNC;
+ else if (strcmp(mode, "a") == 0)
+ access = O_WRONLY | O_CREAT | O_APPEND;
+ else if (strcmp(mode, "a+") == 0)
+ access = O_RDWR | O_CREAT | O_APPEND;
+ else {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if ((fd = lkopen(file, access, 0666)) == -1)
+ return NULL;
+
+ if ((fp = fdopen(fd, mode)) == NULL) {
+ close(fd);
+ return NULL;
+ }
+
+ return fp;