2 * $XConsortium: Buffer.hh /main/3 1996/06/11 16:18:01 cde-hal $
4 * Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved.
5 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
9 * This software contains confidential information and trade secrets of HaL
10 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
11 * without the prior express written permission of HaL Computer Systems, Inc.
13 * RESTRICTED RIGHTS LEGEND
14 * Use, duplication, or disclosure by the Government is subject to
15 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
16 * Technical Data and Computer Software clause at DFARS 252.227-7013.
17 * HaL Computer Systems, Inc.
18 * 1315 Dell Avenue, Campbell, CA 95008
26 Buffer (u_int initial_size = 1024);
29 void init (u_int initial_size = 1024);
33 // Might want to add assert to make sure point is valid. 15:07 01/12/93 DJB
34 void point (char *new_point)
35 { f_point = new_point; }
36 const char *data() const
39 { return (f_end_of_data - f_start); }
40 // Methods for saving buffer independent position inforation, since
41 // the buffer can be dynamically reallocated. You must save offsets
42 // if you want to get an existing string out of the buffer after a
44 int offset (const char *point) const
45 { return (point - f_start); }
46 char *position (int offset)
47 { return (f_start + offset); }
48 // Return the number of bytes of real data remaining after the point.
49 u_int remaining() const
50 { return (f_end_of_data - f_point); }
52 { f_point = f_start; }
54 void write (const int integer);
57 void write (const size_t integer)
58 { write ((size_t) ((void *) integer)); }
60 void write (const unsigned int integer)
61 { write ((int) integer); }
64 void write (const char *string);
65 void write (const char *bytes, u_int size, u_int length);
67 void read (int *integer);
68 void read (unsigned int *integer)
69 { read ((int *) integer); }
70 // Versions to get copy (space must exist!):
71 u_int read (char *const string);
72 void read (char *const bytes, u_int size, u_int length);
73 // Versions to point into buffer memory:
74 u_int read (char **string);
75 void read (char **bytes, u_int size, u_int length);
78 void check_space (u_int);
85 static int f_reference_count;