PAPI 7.1.0.0
Loading...
Searching...
No Matches
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];
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);
29 return rc;
30}
31
32#endif
unsigned long AO_t __attribute__((__aligned__(4)))
Definition: m68k.h:21
__gnuc_va_list va_list
int fclose(FILE *__stream)
rc
Definition: pscanf.h:23
va_list arg_list
Definition: pscanf.h:15
const char * fmt
Definition: pscanf.h:10
char file_buf[4096]
Definition: pscanf.h:14
const char FILE * file
Definition: pscanf.h:13
va_end(arg_list)
setvbuf(file, file_buf, _IOFBF, sizeof(file_buf))
va_start(arg_list, fmt)