Skip to content

Instantly share code, notes, and snippets.

@carlosmn
Created May 5, 2014 18:37
Show Gist options
  • Save carlosmn/30a1ab5bf1ec79491f9f to your computer and use it in GitHub Desktop.
Save carlosmn/30a1ab5bf1ec79491f9f to your computer and use it in GitHub Desktop.
#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