-
Notifications
You must be signed in to change notification settings - Fork 0
/
c_fileno.c
53 lines (33 loc) · 1.11 KB
/
c_fileno.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
///////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
//
void c_fileno_ ( FILE **fp, int *fno )
{
*fno = fileno ( *fp ) ;
}
//
#include <stdint.h>
void c_fileno_intref_ ( intptr_t *iptr, int *fno )
{
*fno = fileno ( (FILE *) (*iptr) ) ;
}
/*
NAME
fileno - map a stream pointer to a file descriptor
SYNOPSIS
[CX] [Option Start] #include <stdio.h>
int fileno(FILE *stream); [Option End]
DESCRIPTION
The fileno() function shall return the integer file descriptor associated with the stream pointed to by stream.
RETURN VALUE
Upon successful completion, fileno() shall return the integer value of the file descriptor associated with stream. Otherwise, the value -1 shall be returned and errno set to indicate the error.
ERRORS
The fileno() function shall fail if:
[EBADF]
The stream is not associated with a file.
The fileno() function may fail if:
[EBADF]
The file descriptor underlying stream is not a valid file descriptor.
Src:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fileno.html
*/