PAPI
5.7.0.0
pscanf.h
Go to the documentation of this file.
1
/* This file was taken from the tacc_stats utility, which is distributed
2
* under a GPL license.
3
*/
4
#ifndef _PSCANF_H_
5
#define _PSCANF_H_
6
#include <stdio.h>
7
#include <stdarg.h>
8
9
__attribute__
((format(scanf, 2, 3)))
10
static inline
int
pscanf(const
char
*path, const
char
*
fmt
, ...)
11
{
12
int
rc
= -1;
13
FILE *
file
= NULL;
14
char
file_buf
[4096];
15
va_list
arg_list
;
16
va_start
(
arg_list
,
fmt
);
17
18
file
= fopen(path,
"r"
);
19
if
(
file
== NULL)
20
goto
out;
21
setvbuf
(
file
,
file_buf
, _IOFBF,
sizeof
(
file_buf
));
22
23
rc
= vfscanf(
file
,
fmt
,
arg_list
);
24
25
out:
26
if
(
file
!= NULL)
27
fclose(
file
);
28
va_end
(
arg_list
);
29
return
rc
;
30
}
31
32
#endif
rc
rc
Definition:
pscanf.h:23
va_start
va_start(arg_list, fmt)
arg_list
va_list arg_list
Definition:
pscanf.h:15
file
const char FILE * file
Definition:
pscanf.h:13
fmt
const char * fmt
Definition:
pscanf.h:10
file_buf
char file_buf[4096]
Definition:
pscanf.h:14
va_end
va_end(arg_list)
setvbuf
setvbuf(file, file_buf, _IOFBF, sizeof(file_buf))
__attribute__
__attribute__((format(scanf, 2, 3))) static inline int pscanf(const char *path
src
components
infiniband
pscanf.h
Generated on Wed Mar 27 2019 00:55:11 for PAPI by
1.8.15