2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: Buffer.hh /main/3 1996/06/11 16:18:01 cde-hal $
26 * Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved.
27 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28 * States. Use of a copyright notice is precautionary only and does not
29 * imply publication or disclosure.
31 * This software contains confidential information and trade secrets of HaL
32 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
33 * without the prior express written permission of HaL Computer Systems, Inc.
35 * RESTRICTED RIGHTS LEGEND
36 * Use, duplication, or disclosure by the Government is subject to
37 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38 * Technical Data and Computer Software clause at DFARS 252.227-7013.
39 * HaL Computer Systems, Inc.
40 * 1315 Dell Avenue, Campbell, CA 95008
48 Buffer (u_int initial_size = 1024);
51 void init (u_int initial_size = 1024);
55 // Might want to add assert to make sure point is valid. 15:07 01/12/93 DJB
56 void point (char *new_point)
57 { f_point = new_point; }
58 const char *data() const
61 { return (f_end_of_data - f_start); }
62 // Methods for saving buffer independent position inforation, since
63 // the buffer can be dynamically reallocated. You must save offsets
64 // if you want to get an existing string out of the buffer after a
66 int offset (const char *point) const
67 { return (point - f_start); }
68 char *position (int offset)
69 { return (f_start + offset); }
70 // Return the number of bytes of real data remaining after the point.
71 u_int remaining() const
72 { return (f_end_of_data - f_point); }
74 { f_point = f_start; }
76 void write (const int integer);
78 void write (const unsigned int integer)
79 { write ((int) (integer)); }
81 void write (const char *string);
82 void write (const char *bytes, u_int size, u_int length);
84 void read (int *integer);
85 void read (unsigned int *integer)
86 { read ((int *) integer); }
87 // Versions to get copy (space must exist!):
88 u_int read (char *const string);
89 void read (char *const bytes, u_int size, u_int length);
90 // Versions to point into buffer memory:
91 u_int read (char **string);
92 void read (char **bytes, u_int size, u_int length);
95 void check_space (u_int);
102 static int f_reference_count;