libzypp  11.13.5
ExternalDataSource.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
15 #ifndef ZYPP_EXTERNALDATASOURCE_H
16 #define ZYPP_EXTERNALDATASOURCE_H
17 
18 #include <stdio.h>
19 
20 #include <string>
21 
22 namespace zypp {
23  namespace externalprogram {
24 
29  {
30  protected:
31  FILE *inputfile;
32  FILE *outputfile;
33 
34  private:
35  char *linebuffer;
37 
38  public:
45  ExternalDataSource(FILE *inputfile = 0, FILE *outputfile = 0);
46 
50  virtual ~ExternalDataSource();
51 
57  bool send (const char *buffer, size_t length);
58 
63  bool send (std::string s);
64 
71  size_t receive(char *buffer, size_t length);
72 
77  std::string receiveLine();
78 
83  std::string receiveUpto(char c);
89  void setBlocking(bool mode);
90 
94  virtual int close();
95 
99  FILE *inputFile() const { return inputfile; }
100 
104  FILE *outputFile() const { return outputfile; }
105  };
106 
107  } // namespace externalprogram
108 } // namespace zypp
109 
110 #endif // ZYPP_EXTERNALDATASOURCE_H
111