perf data: Allow to use stdio functions for pipe mode
[linux-2.6-microblaze.git] / tools / perf / util / data.h
index 75947ef..c563fcb 100644 (file)
@@ -2,6 +2,7 @@
 #ifndef __PERF_DATA_H
 #define __PERF_DATA_H
 
+#include <stdio.h>
 #include <stdbool.h>
 
 enum perf_data_mode {
@@ -16,7 +17,10 @@ enum perf_dir_version {
 
 struct perf_data_file {
        char            *path;
-       int              fd;
+       union {
+               int      fd;
+               FILE    *fptr;
+       };
        unsigned long    size;
 };
 
@@ -26,6 +30,7 @@ struct perf_data {
        bool                     is_pipe;
        bool                     is_dir;
        bool                     force;
+       bool                     use_stdio;
        enum perf_data_mode      mode;
 
        struct {
@@ -62,11 +67,15 @@ static inline bool perf_data__is_single_file(struct perf_data *data)
 
 static inline int perf_data__fd(struct perf_data *data)
 {
+       if (data->use_stdio)
+               return fileno(data->file.fptr);
+
        return data->file.fd;
 }
 
 int perf_data__open(struct perf_data *data);
 void perf_data__close(struct perf_data *data);
+ssize_t perf_data__read(struct perf_data *data, void *buf, size_t size);
 ssize_t perf_data__write(struct perf_data *data,
                              void *buf, size_t size);
 ssize_t perf_data_file__write(struct perf_data_file *file,