Created
May 5, 2014 18:37
-
-
Save carlosmn/30a1ab5bf1ec79491f9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <stdarg.h> | |
int p_open(const char *path, int flags, ...) | |
{ | |
mode_t mode = 0; | |
if (flags & O_CREAT) { | |
va_list arg_list; | |
va_start(arg_list, flags); | |
mode = (mode_t)va_arg(arg_list, int); | |
va_end(arg_list); | |
} | |
return mode; | |
} | |
int main(int argc, char **argv) | |
{ | |
int mode; | |
mode = p_open("foo", O_CREAT, 0666); | |
printf("mode %4o\n", mode); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment