]> err.no Git - sope/blob - sope-appserver/mod_ngobjweb/NGBufferedDescriptor.h
INSTALL_ROOT_DIR patch
[sope] / sope-appserver / mod_ngobjweb / NGBufferedDescriptor.h
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #ifndef __NGBufferedDescriptor_H__
24 #define __NGBufferedDescriptor_H__
25
26 typedef struct _NGBufferedDescriptor {
27   int  fd; // descriptor
28   void *readBuffer;
29   void *readBufferPos;     // current position (ptr) in buffer
30   int  readBufferFillSize; // number of 'read' bytes in the buffer
31   int  readBufferSize;     // maximum capacity in bytes
32   void *writeBuffer;
33   int  writeBufferFillSize;
34   int  writeBufferSize;
35   char ownsFd;
36 } NGBufferedDescriptor;
37
38 NGBufferedDescriptor *
39 NGBufferedDescriptor_newWithOwnedDescriptorAndSize(int _fd, int _size);
40 NGBufferedDescriptor *
41 NGBufferedDescriptor_newWithDescriptorAndSize(int _fd, int _size);
42 NGBufferedDescriptor *
43 NGBufferedDescriptor_newWithDescriptor(int _fd);
44
45 void NGBufferedDescriptor_free(NGBufferedDescriptor *self);
46
47 // accessors
48
49 int  NGBufferedDescriptor_getReadBufferSize(NGBufferedDescriptor *self);
50 int  NGBufferedDescriptor_getWriteBufferSize(NGBufferedDescriptor *self);
51
52 // primary read functions
53
54 int  NGBufferedDescriptor_read(NGBufferedDescriptor *self,
55                                void *_buffer, int _len);
56 int  NGBufferedDescriptor_write(NGBufferedDescriptor *self,
57                                 const void *_buffer, int _len);
58
59 // following functions return 1 on success and 0 and error/close
60
61 char NGBufferedDescriptor_flush(NGBufferedDescriptor *self);
62
63 unsigned char NGBufferedDescriptor_safeRead(NGBufferedDescriptor *self,
64                                    void *_buffer, int _len);
65 char NGBufferedDescriptor_safeWrite(NGBufferedDescriptor *self,
66                                     const void *_buffer, int _len);
67
68 int  NGBufferedDescriptor_readChar(NGBufferedDescriptor *self);
69
70 char NGBufferedDescriptor_writeHttpHeader(NGBufferedDescriptor *self,
71                                           const unsigned char *_key,
72                                           const unsigned char *_value);
73
74 #endif