libzypp  10.5.0
ExternalDataSource.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00015 #ifndef ZYPP_EXTERNALDATASOURCE_H
00016 #define ZYPP_EXTERNALDATASOURCE_H
00017 
00018 #include <stdio.h>
00019 
00020 #include <string>
00021 
00022 namespace zypp {
00023   namespace externalprogram {
00024 
00028     class ExternalDataSource
00029     {
00030     protected:
00031       FILE *inputfile;
00032       FILE *outputfile;
00033     
00034     private:
00035       char *linebuffer;
00036       size_t linebuffer_size;
00037     
00038     public:
00045       ExternalDataSource(FILE *inputfile = 0, FILE *outputfile = 0);
00046     
00050       virtual ~ExternalDataSource();
00051     
00057       bool send (const char *buffer, size_t length);
00058     
00063       bool send (std::string s);
00064     
00071       size_t receive(char *buffer, size_t length);
00072     
00077       std::string receiveLine();
00078     
00083       std::string receiveUpto(char c);
00089       void setBlocking(bool mode);
00090     
00094       virtual int close();
00095     
00099       FILE *inputFile() const  { return inputfile; }
00100     
00104       FILE *outputFile() const { return outputfile; }
00105     };
00106 
00107   } // namespace externalprogram
00108 } // namespace zypp
00109 
00110 #endif // ZYPP_EXTERNALDATASOURCE_H
00111