Source: kio_connection.h


Annotated List
Files
Globals
Hierarchy
Index
#ifndef __protocol_h__
#define __protocol_h__ "$Id: kio_connection.h,v 1.9 1999/12/13 23:30:42 kulow Exp $"

#include <sys/types.h>

#include <stdio.h>
#include <kprocess.h>

/**
  * This class provides a simple means for IPC between two applications
  * via a pipe.
  */
class KIOConnection
{
public:
  KIOConnection();
  KIOConnection( int _in_fd, int _out_fd, size_t _buf_len = defaultBufferSize());
  virtual ~KIOConnection();
  
  int inFD() { return m_in; }
  int outFD() { return m_out; }

  int send( int _cmd, const void *_p, int _len );
  void* read( int* _cmd, int* _len );

  bool eof() { return feof( m_fin ); }

  /**
    * Return a writable pointer to the buffer.
    */
  char* buffer() { return m_pBuffer; }

  /**
    * Return the current size of the buffer, in bytes.
    */
  size_t bufferSize() {return m_iBufferSize;}

protected:
  void init( int _in_fd, int _out_fd, size_t _buf_len );

public:
  /**
    * Return the default size of the buffer.  This is useful when
    * constructing a "Connection", but rarely useful otherwise.
    */
  static size_t defaultBufferSize();

protected:
  int m_in;
  int m_out;
  FILE *m_fin;
  FILE *m_fout;

  char* m_pBuffer;
  size_t m_iBufferSize;
};

class KIOSlave : public KIOConnection, public KProcess
{
public:
  KIOSlave( const char *_cmd );
  ~KIOSlave();
};

#endif

Generated by: root@tantive.terraplex.com on Sun Feb 27 17:39:31 2000, using kdoc 2.0a33.