This file is indexed.

/usr/include/publib/sbuf.h is in publib-dev 0.40-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/* Part of publib.

   Copyright (c) 1994-2006 Lars Wirzenius.  All rights reserved.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions
   are met:

   1. Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.

   2. Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.

   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
 * sbuf.h -- simple text editor buffer routines
 *
 * Part of Publib.  See manpage for more information.
 * "@(#)publib-sbuf:$Id: sbuf.h,v 1.21 1996/12/27 22:48:34 liw Exp $"
 */


#ifndef __publib_sbuf_included
#define __publib_sbuf_included


/*
 * Includes for types defined elsewhere.
 * These are all standard headers or Publib headers.
 */

#include <stdio.h>		/* need size_t and FILE */
#include <publib/alloc.h>	/* need struct dynarr */


typedef struct __publib_sbuf Sbuf;


struct __sbufmark {
	unsigned inuse:1;	/* is this mark in use? */
	unsigned dirty:1;	/* has text in mark been modified? */
	unsigned columnar:1;	/* is the mark columnar? */
	int code;		/* code number for easy finding (0=no code) */
	long begin;		/* where the buffer begins ... */
	long len;		/* ...and how long it is */
	struct __sbufmarkhandle *handle;
};


/*
 * This is how the client sees a struct __bufmark.  We can't use a
 * pointer directly, since the struct __bufmarks may move because of
 * realloc, and we can't assume that the client will be able to update
 * his pointers.
 */
typedef struct __sbufmarkhandle {
	Sbuf *buf;
	size_t mark;
} Sbufmark;


/*
 * sbuf_lineno caches the values it computes.  The cache
 * contains entries of the following type.
 */
struct __sbuf_pos_cache {
	long pos;
	long lineno;
};
#define SBUF_POS_CACHE_MAX (50000)
#define SBUF_POS_CACHE_MIN (16)

#if SBUF_POS_CACHE_MAX < SBUF_POS_CACHE_MIN
#error Do not make SBUF_POS_CACHE_MAX smaller than SBUF_POS_CACHE_MIN.
#endif

#if SBUF_POS_CACHE_MIN < 16
#error Do not make SBUF_POS_CACHE_MIN too small.
#endif


/*
 * Flags for Sbuf.
 */
enum {
	SBUF_LOCKED_FLAG = 0x01,
	SBUF_DIRTY_FLAG = 0x02,
	SBUF_LOADED_FLAG = 0x04,
	
	/* Users are allowed to use and define meaning for the following */
	SBUF_USER01_FLAG = 0x0100,
	SBUF_USER02_FLAG = 0x0200,
	SBUF_USER03_FLAG = 0x0400,
	SBUF_USER04_FLAG = 0x0800,
	SBUF_USER05_FLAG = 0x1000,
	SBUF_USER06_FLAG = 0x2000,
	SBUF_USER07_FLAG = 0x4000,
	SBUF_USER08_FLAG = 0x8000
};


struct __publib_sbuf {
	char *block;
	char *name;
	unsigned long flags;
	size_t gappos;
	size_t alloc;
	size_t len;

	struct __sbufmark *marks;
	size_t markalloc;
	
	Sbufmark *aux;

	struct dynarr pc;
	long poshits, posmisses;
	double posmissavg;
	
	struct __sbuf_change *log_head, *log_tail;
	long log_max;
};



/*
 * Change log information for undo/redo.
 */
struct __sbuf_change {
	long pos;
	long newlen;
	char *oldtext;
	long oldlen;
	unsigned last_composite:1;
	unsigned buffer_was_dirty:1;
	struct __sbuf_change *next, *prev;
};


/*
 * Default maximum size of change log. (struct __sbuf_change's and
 * saved oldtext's.)
 */
#define SBUF_MAX_CHANGE_LOG	(64*1024)


/*
 * The validation functions shouldn't generate any code when NDEBUG is
 * defined.  This is the same behaviour as assert has.  Note that the
 * prototypes and definitions of these functions are protected against
 * the macros by virtue of having the function names within parentheses.
 */
#ifdef NDEBUG
#define sbuf_validate(buf)	((void)0)
#define sbuf_validate_mark(m)	((void)0)
#endif


/*
 * Let's use the same NDEBUG flag to turn on a macro version of sbuf_charat.
 * _NO_ error checking for this baby.  Use the non-macro version for that.
 */
#ifdef NDEBUG
#include <stdio.h> /* need EOF */
#define sbuf_charat(buf, pos) \
	((pos) == (buf)->len \
		?  EOF \
		: (int) (unsigned char) ((pos) < (buf)->gappos \
			? (buf)->block[(pos)] \
			: (buf)->block[(pos) + (buf)->alloc - (buf)->len]))
#endif


/*
 * Er..., did someone say NDEBUG for macros?  Some of the status/info routines
 * are used pretty heavily as well...
 */
#if 0
#ifdef NDEBUG
#define sbuf_length(b)		 ((b)->len)
#define sbuf_mark_begin(m)	 ((m)->buf->marks[(m)->mark].begin)
/*#define sbuf_mark_length(m)	 ((m)->buf->marks[(m)->mark].len)*/
/*#define sbuf_mark_end(m)	 (sbuf_mark_begin(m) + sbuf_mark_length(m))*/
#define sbuf_mark_is_dirty(m)	 ((m)->buf->marks[(m)->mark].dirty)
#define sbuf_mark_set_dirty(m,d) ((m)->buf->marks[(m)->mark].dirty = (d))
#endif
#endif



/*
 * Prototypes for functions provided by sbuf.
 */

Sbuf *sbuf_create(void);
void sbuf_destroy(Sbuf *);
void (sbuf_validate)(Sbuf *);

char *sbuf_get_name(Sbuf *);
int sbuf_set_name(Sbuf *, const char *);

unsigned long sbuf_get_flags(Sbuf *);
int sbuf_has_flags(Sbuf *, unsigned long);
void sbuf_set_all_flags(Sbuf *, unsigned long);
void sbuf_set_flags(Sbuf *, unsigned long);
void sbuf_clear_flags(Sbuf *, unsigned long);

int sbuf_is_dirty(Sbuf *);
void sbuf_set_dirty(Sbuf *, int);

Sbufmark *sbuf_mark(Sbuf *, long, long);
void sbuf_remark(Sbufmark *, long, long);
void sbuf_unmark(Sbufmark *);
long (sbuf_mark_begin)(Sbufmark *);
long (sbuf_mark_end)(Sbufmark *);
long (sbuf_mark_length)(Sbufmark *);
int (sbuf_mark_is_dirty)(Sbufmark *);
void (sbuf_mark_set_dirty)(Sbufmark *, int);
void (sbuf_validate_mark)(Sbufmark *);
int sbuf_mark_is_columnar(Sbufmark *);
void sbuf_mark_set_columnar(Sbufmark *, int);

void sbuf_set_mark_code(Sbufmark *, int);
int sbuf_get_mark_code(Sbufmark *);
Sbufmark *sbuf_find_mark_by_code(Sbuf *, int);

int sbuf_strchange(Sbufmark *, const char *, size_t);
int sbuf_change(Sbufmark *, Sbufmark *);
int (sbuf_charat)(Sbuf *, long);
void sbuf_strat(char *, Sbufmark *);

int sbuf_load(Sbuf *);
int sbuf_save(Sbuf *, int);
int sbuf_insert_file(Sbufmark *, FILE *);
int sbuf_write_to_file(Sbufmark *, FILE *);
int sbuf_write_to(Sbufmark *, const char *);

long (sbuf_length)(Sbuf *);

char *sbuf_lock(Sbuf *);
void sbuf_unlock(Sbuf *);

long sbuf_boln(Sbuf *, long);
long sbuf_eoln(Sbuf *, long);
long sbuf_bow(Sbuf *, long);
long sbuf_eow(Sbuf *, long);
long sbuf_lineno(Sbuf *, long);
long sbuf_linepos(Sbuf *, long);
long sbuf_colno(Sbuf *, long, long);
long sbuf_colpos(Sbuf *, long, long, long);

long sbuf_find_pair(Sbuf *, long);

void sbuf_clear_pos_cache(Sbuf *, long);
void sbuf_adjust_pos_cache(Sbuf *, long, long, long, long);
void sbuf_cache_stats(Sbuf *, FILE *);

#define SBUF_BACKWARD		0x01
#define SBUF_IGNORE_CASE	0x02
#define SBUF_REGEX		0x04

int sbuf_search(Sbufmark *, Sbufmark *, const char *, size_t, unsigned long);

int sbuf_pos_inside_mark(Sbufmark *, long);

void sbufgap_movegap(Sbuf *, size_t);
void sbuf_dump(const char *, Sbuf *);
void sbuf_mark_dump(const char *, Sbufmark *);

int sbuf_undo_atomic(Sbuf *);

#endif