]> err.no Git - sope/blob - sope-appserver/mod_ngobjweb/NGBufferedDescriptor.h
added strict OSX bundle dependencies
[sope] / sope-appserver / mod_ngobjweb / NGBufferedDescriptor.h
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE 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   SOPE 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 SOPE; 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
22 #ifndef __NGBufferedDescriptor_H__
23 #define __NGBufferedDescriptor_H__
24
25 typedef struct _NGBufferedDescriptor {
26   int  fd; // descriptor
27   void *readBuffer;
28   void *readBufferPos;     // current position (ptr) in buffer
29   int  readBufferFillSize; // number of 'read' bytes in the buffer
30   int  readBufferSize;     // maximum capacity in bytes
31   void *writeBuffer;
32   int  writeBufferFillSize;
33   int  writeBufferSize;
34   char ownsFd;
35 } NGBufferedDescriptor;
36
37 NGBufferedDescriptor *
38 NGBufferedDescriptor_newWithOwnedDescriptorAndSize(int _fd, int _size);
39 NGBufferedDescriptor *
40 NGBufferedDescriptor_newWithDescriptorAndSize(int _fd, int _size);
41 NGBufferedDescriptor *
42 NGBufferedDescriptor_newWithDescriptor(int _fd);
43
44 void NGBufferedDescriptor_free(NGBufferedDescriptor *self);
45
46 // accessors
47
48 int  NGBufferedDescriptor_getReadBufferSize(NGBufferedDescriptor *self);
49 int  NGBufferedDescriptor_getWriteBufferSize(NGBufferedDescriptor *self);
50
51 // primary read functions
52
53 int  NGBufferedDescriptor_read(NGBufferedDescriptor *self,
54                                void *_buffer, int _len);
55 int  NGBufferedDescriptor_write(NGBufferedDescriptor *self,
56                                 const void *_buffer, int _len);
57
58 // following functions return 1 on success and 0 and error/close
59
60 char NGBufferedDescriptor_flush(NGBufferedDescriptor *self);
61
62 unsigned char NGBufferedDescriptor_safeRead(NGBufferedDescriptor *self,
63                                    void *_buffer, int _len);
64 char NGBufferedDescriptor_safeWrite(NGBufferedDescriptor *self,
65                                     const void *_buffer, int _len);
66
67 int  NGBufferedDescriptor_readChar(NGBufferedDescriptor *self);
68
69 char NGBufferedDescriptor_writeHttpHeader(NGBufferedDescriptor *self,
70                                           const unsigned char *_key,
71                                           const unsigned char *_value);
72
73 #endif