go to
> open(2)
Homepage > Man Pages > Category > Subroutines
Homepage > Man Pages > Name > P

parse_open_flags

man page of parse_open_flags

parse_open_flags: converts open flag symbols into bitmask openflags2symbols

NAME
parse_open_flags - converts open flag symbols into bitmask openflags2symbols - converts open flag bitmask into symbols
SYNOPSIS
int parse_open_flags(symbols, badname) char *symbols; char **badname; char * openflags2symbols(openflags, sep, mode) int openflags; char *sep; int mode;

DESCRIPTION

The parse_open_flags function can be used to convert a list of comma separated open(2) flag symbols (i.e. O_TRUNC) into the bitmask that can be used by open(2). If a symbol is unknown and badname is not NULL, badname will updated to point that symbol in symbols. Parse_open_flags will return -1 on this error. Otherwise parse_open_flags will return the open flag bitmask. If parse_open_flags returns, string will left unchanged. The openflags2symbols function attempts to convert open flag bits into human readable symbols (i.e. O_TRUNC). If there are more than one symbol, the sep string will be placed as a separator between symbols. Commonly used separators would be a comma "," or pipe "|". If mode is one and not all openflags bits can be converted to symbols, the UNKNOWN symbol will be added to return string. Openflags2symbols will return the identified symbols. If no symbols are recognized the return value will be a empty string or the UNKNOWN symbol. If the O_WRONLY and O_RDWR bits are not set, openflags2symbols assumes that O_RDONLY symbol is wanted.

SEE ALSO

open(2), /usr/include/sys/fcntl.h.

EXAMPLES

/* * The following code provides a UNIT test main for * parse_open_flags and openflags2symbols functions. */ #include <stdio.h> main(argc, argv) int argc; char **argv; { int bits; int ret; char *err; if (argc == 1 ) { printf("Usage: %s openflagsbits%s symbols0, argv[0], argv[0]); exit(1); } if ( sscanf(argv[1], "%i", &bits) == 1 ) { printf("openflags2symbols(%#o, bits, openflags2symbols(bits, ",", 1)); } else { ret=parse_open_flags(argv[1], &err); if ( ret == -1 ) printf("parse_open_flags(%s, &err) returned -1, err = %s0, argv[0], err); else printf("parse_open_flags(%s, &err) returned %#o0, argv[0], ret); } exit(0); }

LIMITATIONS

Currently (06/96) all known symbols are coded into openflags2symbols. If new open flags are added this function code will have to updated to know about them or they will not be recognized. The static space where openflags2symbols stores open flag symbols with callers separators is limited to 512 characters. This should be large enough for most open flags symbols as long as the separator is kept short. PARSE_OPEN_FLAGS(3)
 
 
 

Copyright © 2011–2018 by topics-of-interest.com . All rights reserved. Hosted by all-inkl.
Contact · Imprint · Privacy

Page generated in 29.90ms.

backbar.es | www.daelim-wiki.de | adsenseexperts.com