177 if (type < 0 || type > 255)
178 msg_panic(
"rec_put_type: bad record type %d", type);
181 msg_info(
"rec_put_type: %d at %ld", type, (
long) offset);
199 if (type < 0 || type > 255)
200 msg_panic(
"rec_put: bad record type %d", type);
203 msg_info(
"rec_put: type %c len %ld data %.10s",
204 type, (
long) len, data);
218 len_byte = len_rest & 0177;
224 }
while (len_rest != 0);
238 const char *myname =
"rec_get";
248 msg_panic(
"%s: bad record size limit: %ld", myname, (
long) maxsize);
263 for (len = 0, shift = 0; ; shift += 7) {
264 if (shift >= (
int) (
NBBY *
sizeof(
int))) {
265 msg_warn(
"%s: too many length bits, record type %d",
270 msg_warn(
"%s: unexpected EOF reading length, record type %d",
274 len |= (len_byte & 0177) << shift;
275 if ((len_byte & 0200) == 0)
278 if (len < 0 || (maxsize > 0 && len > maxsize)) {
279 msg_warn(
"%s: illegal length %ld, record type %d",
293 msg_warn(
"%s: unexpected EOF in data, record type %d length %ld",
300 msg_info(
"%s: type %c len %ld data %.10s", myname,
315 msg_warn(
"%s: seek error after reading END record: %m",
329 static const char *saved_path;
330 static off_t saved_offset;
331 static int reverse_count;
342 #define STREQ(x,y) ((x) == (y) && strcmp((x), (y)) == 0)
343 #define REVERSE_JUMP_LIMIT 10000
353 msg_warn(
"%s: malformed pointer record value: %s",
356 }
else if (offset == 0) {
363 msg_warn(
"%s: seek error after pointer record: %m",
367 saved_offset = offset;
396 va_start(ap, format);
406 return (
rec_put(stream, type, str, str ? strlen(str) : 0));
416 width < 1 ? 1 : width,
"0"));
int rec_put_type(VSTREAM *stream, int type, off_t offset)
int rec_vfprintf(VSTREAM *stream, int type, const char *format, va_list ap)
NORETURN msg_panic(const char *fmt,...)
#define REC_FLAG_SKIP_DTXT
#define REC_FLAG_FOLLOW_PTR
int rec_goto(VSTREAM *stream, const char *buf)
off_t off_cvt_string(const char *str)
#define VSTRING_TERMINATE(vp)
#define REC_PUT_BUF(v, t, b)
int rec_get_raw(VSTREAM *stream, VSTRING *buf, ssize_t maxsize, int flags)
VSTRING * vstring_vsprintf(VSTRING *vp, const char *format, va_list ap)
#define REC_FLAG_SEEK_END
#define REVERSE_JUMP_LIMIT
int rec_pad(VSTREAM *stream, int type, ssize_t len)
#define VSTRING_RESET(vp)
int rec_fputs(VSTREAM *stream, int type, const char *str)
void msg_warn(const char *fmt,...)
VSTRING * vstring_alloc(ssize_t len)
int rec_put(VSTREAM *stream, int type, const char *data, ssize_t len)
off_t vstream_fseek(VSTREAM *stream, off_t offset, int whence)
#define vstream_fread(v, b, n)
#define vstream_fwrite(v, b, n)
#define VSTRING_SPACE(vp, len)
#define VSTRING_AT_OFFSET(vp, offset)
#define VSTREAM_PUTC(ch, vp)
int rec_fprintf(VSTREAM *stream, int type, const char *format,...)
void msg_info(const char *fmt,...)