📄 0922-0926.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Complete Command Reference:Library Functions:EarthWeb Inc.-</TITLE>
</HEAD>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311046 //-->
<!-- TITLE=Linux Complete Command Reference//-->
<!-- AUTHOR=Red Hat//-->
<!-- PUBLISHER=Macmillan Computer Publishing//-->
<!-- IMPRINT=Sams//-->
<!-- CHAPTER=03 //-->
<!-- PAGES=0891-1062 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0921-0921.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0927-0929.html">Next</A></CENTER></P>
<A NAME="PAGENUM-922"><P>Page 922</P></A>
<P><B>RETURN VALUE</b>
</P>
<P>The fgetgrent()function returns the group information structure, or
NULL if there are no more entries or an error occurs.
</P>
<P><B>ERRORS</b>
</P>
<!-- CODE SNIP //-->
<PRE>
ENOMEM Insufficient memory to allocate group information structure.
</PRE>
<!-- END CODE SNIP //-->
<P><B>CONFORMS TO</b>
</P>
<P>SVID 3</P>
<P></B>SEE ALSO</b>
</P>
<!-- CODE SNIP //-->
<PRE>
getgrnam(3), getgrgid(3), getgrent(3), setgrent(3),
endgrent(3)
</PRE>
<!-- END CODE SNIP //-->
<P>GNU, 4 April 1993</P>
<H3><A NAME="ch03_ 63">
fgetpwent
</A></H3>
<P>fgetpwent—Gets password file entry</P>
<P><B>SYNOPSIS</b>
</P>
<!-- CODE SNIP //-->
<PRE WIDTH="1">#include <pwd.h>
#include <stdio.h>
#include <sys/types.h>
struct passwd *fgetpwent(FILE *stream);
</PRE>
<!-- END CODE SNIP //-->
<P><B>DESCRIPTION</b>
</P>
<P>The fgetpwent() function returns a pointer to a structure containing the broken-out fields of a line in the file
stream. The first time it is called it returns the first entry; thereafter, it returns successive entries. The file
stream must have the same format as /etc/passwd.
<P>The passwd structure is defined in
<pwd.h> as follows:
<!-- CODE //-->
<PRE WIDTH="1">struct passwd {
char *pw_name; /* username */
char *pw_passwd; /* user password */
uid_t pw_uid; /* user id */
gid_t pw_gid; /* group id */
char *pw_gecos; /* real name */
char *pw_dir; /* home directory */
char *pw_shell; /* shell program */
};
</PRE>
<!-- END CODE //-->
<P><B>RETURN VALUE</b>
</P>
<P>The fgetpwent() function returns the passwd structure, or
NULL if there are no more entries or an error occurs.
</P>
<P><B>ERRORS</b>
</P>
<!-- CODE SNIP //-->
<PRE>
ENOMEM Insufficient memory to allocate passwd structure.
</PRE>
<!-- END CODE SNIP //-->
<P><B>FILES</b>
</P>
<BLOCKQUOTE>
/etc/passwd password database file
</BLOCKQUOTE>
<P><B>CONFORMS TO</b>
</P>
<P>SVID 3<P>
<A NAME="PAGENUM-923"><P>Page 923</P></A>
<P></B>SEE ALSO</b>
</P>
<P>getpwnam(3), getpwuid(3), getpwent(3), setpwent(3),
endpwent(3), getpw(3), putpwent( 3), passwd(5)
</P>
<P>GNU, 17 May 1996
</P>
<H3><A NAME="ch03_ 64">
floor
</A></H3>
<P>floor—Largest integral value not greater than
x
</P>
<P><B>SYNOPSIS</b>
</P>
<!-- CODE SNIP //-->
<PRE WIDTH="1">#include <math.h>
double floor(double x);
</PRE>
<!-- END CODE SNIP //-->
<P><B>DESCRIPTION</b>
</P>
<P>The floor() function rounds x downward to the nearest integer, returning that value as a double.
</P>
<P><B>CONFORMS TO</b>
</P>
<P>SVID 3, POSIX, BSD 4.3, ISO 9899
</P>
<P></B>SEE ALSO</b>
</P>
<P>abs(3), fabs(3), ceil(3), rint(3)</P>
<P>6 June 1993</P>
<H3><A NAME="ch03_ 65">
fmod
</A></H3>
<P>fmod—Floating-point remainder function
</P>
<P><B>SYNOPSIS</b>
</P>
<!-- CODE SNIP //-->
<PRE WIDTH="1">#include <math.h>
double fmod(double x, double y);
</PRE>
<!-- END CODE SNIP //-->
<P><B>DESCRIPTION</b>
</P>
<P>The modf() function computes the remainder of dividing
x by y. The return value is x_n*y, where n is the quotient of
x/y, rounded toward 0 to an integer.
</P>
<P><B>RETURN VALUE
</B></P>
<P>The fmod() function returns the remainder unless
y is 0, in which case the function fails and errno is set.
</P>
<P><B>ERRORS</b>
</P>
<BLOCKQUOTE>
EDOM The denominator y is 0.
</BLOCKQUOTE>
<P><B>CONFORMS TO</b>
</P>
<P>SVID 3, POSIX, BSD 4.3, ISO 9899
</P>
<P></B>SEE ALSO</b>
</P>
<P>drem(3)</P>
<P>6 June 1993</P>
<A NAME="PAGENUM-924"><P>Page 924</P></A>
<H3><A NAME="ch03_ 66">
fnmatch
</A></H3>
<P>fnmatch—Matches filename or pathname
</P>
<P><B>SYNOPSIS</b>
</P>
<!-- CODE SNIP //-->
<PRE>
#include <fnmatch.h>
int fnmatch(const char *pattern, const char *strings,int flags);
</PRE>
<!-- END CODE SNIP //-->
<P><B>DESCRIPTION</b>
</P>
<P>fnmatch() checks the strings argument and checks whether it matches the
pattern argument, which is a shell wildcard pattern.
</P>
<P>The flags argument modifies the behavior; it is the bitwise
OR of zero or more of the following flags:
</P>
<TABLE>
<TR><TD>
FNM_NOESCAPE
</TD><TD>
If this flag is set, treat backslash as an ordinary character instead of as an escape character.
</TD></TR><TR><TD>
FNM_PATHNAME
</TD><TD>
If this flag is set, match a slash in
string only with a slash in pattern and not, for example,
with a [] - sequence containing a slash.
</TD></TR><TR><TD>
FNM_PERIOD
</TD><TD>
If this flag is set, a leading period in
string has to be matched exactly by a period in
pattern. A period is considered to be leading if it is the first character in
string, or if both FNM_PATHNAME is set and the period immediately follows a slash.
</TD></TR></TABLE>
<P><B>RETURN VALUE</b></P>
<P>Zero if string matches pattern, FNM_NOMATCH if there is no match, or another value if there is an error.
</P>
<P><B>CONFORMS TO</b></P>
<P>Proposed POSIX.2
</P>
<P><B>BUGS</B>
</P>
<P>POSIX.2 is not yet an approved standard; the information in this man page is subject to change.
</P>
<P></B>SEE ALSO</b>
</P>
<P>sh(1), glob(3), glob(7)</P>
<P>GNU, 19 April 1993</P>
<H3><A NAME="ch03_ 67">
fopen, fdopen, freopen
</A></H3>
<P>fopen, fdopen, freopen—Stream open functions
</P>
<P><B>SYNOPSIS</b>
</P>
<!-- CODE //-->
<PRE>
#include <stdio.h>
FILE *fopen( char *path, char *mode);
FILE *fdopen( int fildes, char *mode);
FILE *freopen( char *path, char *mode,FILE*stream);
</PRE>
<!-- END CODE //-->
<P><B>DESCRIPTION</b>
</P>
<P>The fopen function opens the file whose name is the string pointed to by
path and associates a stream with it.
</P>
<P>The argument mode points to a string beginning with one of the following sequences (additional characters may follow
these sequences):
</P>
<TABLE>
<TR><TD>
r
</TD><TD>
Open text file for reading. The stream is positioned at the beginning of the file.
</TD></TR><TR><TD>
r+
</TD><TD>
Open for reading and writing. The stream is positioned at the beginning of the file.
</TD></TR></TABLE>
<A NAME="PAGENUM-925"><P>Page 925</P></A>
<TABLE>
<TR><TD>
w
</TD><TD>
Truncate file to zero length or create a text file for writing. The stream is positioned at
the beginning of the file.
</TD></TR><TR><TD>
w+
</TD><TD>
Open for reading and writing. The file is created if it does not exist; otherwise it is
truncated. The stream is positioned at the beginning of the file.
</TD></TR><TR><TD>
a
</TD><TD>
Open for writing. The file is created if it does not exist. The stream is positioned at the end
of the file.
</TD></TR><TR><TD>
a+
</TD><TD>
Open for reading and writing. The file is created if it does not exist. The stream is positioned
at the end of the file.
</TD></TR></TABLE>
<P>The mode string can also include the letter b either as a third character or as a character between the characters in any of
the two-character strings described previously. This is strictly for compatibility with ANSI C3.159-1989 (ANSI C) and has
no effect; the b is ignored.
</P>
<P>Any created files will have mode
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH (0666), as modified by the
process's umask value. (See umask(2).)
</P>
<P>Reads and writes may be intermixed on read/write streams in any order. Note that ANSI C requires that a file
positioning function intervene between output and input, unless an input operation encounters end-of-file. (If this condition is not
met, then a read is allowed to return the result of writes other than the most recent.) Therefore it is good practice (and
indeed sometimes necessary under Linux) to put an
fseek or fgetpos operation between write and read operations on such a
stream. This operation may be an apparent no-op (as in
fseek(..., 0L, SEEK_CUR)) called for its synchronizing side effect.
</P>
<P>The fdopen function associates a stream with the existing file descriptor,
fildes. The mode of the stream must be compatible with the mode of the file descriptor. The file descriptor is not duplicated.
</P>
<P>The freopen function opens the file whose name is the string pointed to by
path and associates the stream pointed to by
stream with it. The original stream (if it exists) is closed. The
mode argument is used just as in the fopen function.
The primary use of the freopen function is to change the file associated with a standard text stream
(stderr, stdin, or stdout).
</P>
<P><B>RETURN VALUES</b>
</P>
<P>On successful completion, fopen, fdopen, and
freopen return a FILE pointer. Otherwise, NULL is returned, and the
global variable errno is set to indicate the error.
</P>
<P><B>ERRORS</B>
</P>
<TABLE>
<TR><TD>
EINVAL
</TD><TD>
The mode provided to fopen, fdopen, or
freopen was invalid.
</TD></TR></TABLE>
<P>The fopen, fdopen, and freopen functions may also fail and set
errno for any of the errors specified for the routine
malloc(3).</P>
<P>The fopen function may also fail and set errno for any of the errors specified for the routine
open(2).</P>
<P>The fdopen function may also fail and set errno for any of the errors specified for the routine
fcntl(2).</P>
<P>The freopen function may also fail and set
errno for any of the errors specified for the routines
open(2), fclose(3) and fflush(3).</P>
<P></B>SEE ALSO
</P></B>
<P>open(2), fclose(3)</P>
<P></B>STANDARDS
</P></B>
<P>The fopen and freopen functions conform to ANSI C3.159-1989 (ANSI C). The
fdopen function conforms to IEEE Std1003.1-1988 (POSIX.1).</P>
<P>BSD Man Page, 13 December 1995</P>
<H3><A NAME="ch03_ 68">
fpathconf, pathconf
</A></H3>
<P>fpathconf, pathconf—Get configuration values for files</P>
<A NAME="PAGENUM-926"><P>Page 926</P></A>
<P><B>SYNOPSIS
</P></B>
<!-- CODE SNIP //-->
<PRE>
#include <unistd.h>
long fpathconf(int filedes,intname);
long pathconf(char *path, int name);
</PRE>
<!-- END CODE SNIP //-->
<P><B>DESCRIPTION
</P></B>
<P>fpathconf() gets a value for the configuration option
name for the open file descriptor filedes.</P>
<P>pathconf() gets a value for configuration option
name for the filename path.</P>
<P>The corresponding macros defined in
<unistd.h> are the minimum values; if an application wants to take advantage of
values that may change, a call to fpathconf() or
pathconf() can be made, which may yield more liberal results.</P>
<P>Setting name equal to one of the following constants returns the following configuration options:</P>
<TABLE>
<TR><TD>
_PC_LINK_MAX
</TD><TD>
Returns the maximum number of links to the file. If
filedes or path refers to a directory, the value applies to the whole directory. The corresponding macro is
_POSIX_LINK_MAX.
</TD></TR><TR><TD>
_PC_MAX_CANON
</TD><TD>
Returns the maximum length of a formatted input line, where
filedes or path must refer to a terminal. The corresponding macro is
_POSIX_MAX_CANON.
</TD></TR><TR><TD>
_PC_MAX_INPUT
</TD><TD>
Returns the maximum length of an input line, where
filedes or path must refer to a terminal. The corresponding macro is
_POSIX_MAX_INPUT.
</TD></TR><TR><TD>
_PC_NAME_MAX
</TD><TD>
Returns the maximum length of a filename in the directory
path or filedes the process is allowed to create. The corresponding macro is
_POSIX_MAX_.
</TD></TR><TR><TD>
_PC PATH_MAX
</TD><TD>
Returns the maximum length of a relative pathname when
path or filedes is the current working directory. The corresponding macro is
_POSIX_PATH_MAX.
</TD></TR><TR><TD>
_PC_PIPE_BUF
</TD><TD>
Returns the size of the pipe buffer, where
filedes must refer to a pipe or FIFO, and path
must refer to a FIFO. The corresponding macro is
_POSIX_PIPE_BUF.
</TD></TR><TR><TD>
_PC_CHOWN_RESTRICTED
</TD><TD>
Returns nonzero if the
chown(2) call may not be used on this file. If
filedes or path refers to a directory, this applies to all files in that directory. The corresponding macro
is _POSIX_CHOWN_RESTRICTED.
</TD></TR><TR><TD>
_PC_NO_TRUNC
</TD><TD>
Returns nonzero if accessing filenames longer than
_POSIX_NAME_MAX generates an error. The corresponding macro is
_POSIX_NO_TRUNC.
</TD></TR><TR><TD>
_PC_VDISABLE
</TD><TD>
Returns nonzero if special character processing can be disabled, where
filedes or path must refer to a terminal.
</TD></TR></TABLE>
<P><B>RETURN VALUE
</P></B>
<P>The limit is returned, if one exists. If the system does not have a limit for the requested resource,
_1 is returned, and errno is unchanged. If there is an error,
_1 is returned, and errno is set to reflect the nature of the error.</P>
<P><B>CONFORMS TO
</P></B>
<P>POSIX.1. Files with name lengths longer than the value returned for
name equal to _PC_NAME_MAX may exist in the given directory.</P>
<P>Some returned values may be huge; they are not suitable for allocating memory.</P>
<P></B>SEE ALSO
</P></B>
<P>getconf(1), statfs(2), open(2), sysconf(3)</P>
<P>GNU, 4 April 1993</P>
<H3><A NAME="ch03_ 69">
fread, fwrite
</A></H3>
<P>fread, fwrite—Binary stream input/output</P>
<P><CENTER>
<a href="0921-0921.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0927-0929.html">Next</A></CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -