From: Adam Heath Date: Sat, 6 Jan 2001 04:28:57 +0000 (+0000) Subject: varbuf(v)printf now return the number of characters they added to the X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9cfdc100829395e78cb96359620427056598730;p=dpkg varbuf(v)printf now return the number of characters they added to the buffer. --- diff --git a/ChangeLog b/ChangeLog index 7b50c6cc..53f585f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jan 5 22:25:06 CST 2001 Adam Heath + + * lib/varbuf.c: varbuf(v)printf now return the number of characters + they added to the buffer. + Thu Jan 4 01:20:27 CST 2001 Adam Heath * dpkg-deb/build.c, dpkg-deb/extract.c, dpkg-deb/info.c, diff --git a/include/dpkg-db.h b/include/dpkg-db.h index bece2d04..3d272ab1 100644 --- a/include/dpkg-db.h +++ b/include/dpkg-db.h @@ -226,6 +226,8 @@ struct varbuf; extern void varbufaddc(struct varbuf *v, int c); extern void varbufdupc(struct varbuf *v, int c, ssize_t s); +int varbufprintf(struct varbuf *v, const char *fmt, ...) PRINTFFORMAT(2,3); +int varbufvprintf(struct varbuf *v, const char *fmt, va_list va); void varbufinit(struct varbuf *v); void varbufreset(struct varbuf *v); void varbufextend(struct varbuf *v); @@ -285,8 +287,6 @@ void writedb(const char *filename, int available, int mustsync); void varbufrecord(struct varbuf*, const struct pkginfo*, const struct pkginfoperfile*); void varbufdependency(struct varbuf *vb, struct dependency *dep); -void varbufprintf(struct varbuf *v, const char *fmt, ...) PRINTFFORMAT(2,3); -void varbufvprintf(struct varbuf *v, const char *fmt, va_list va); /* NB THE VARBUF MUST HAVE BEEN INITIALISED AND WILL NOT BE NULL-TERMINATED */ /*** from vercmp.c ***/ diff --git a/lib/varbuf.c b/lib/varbuf.c index ed33837b..0092bdda 100644 --- a/lib/varbuf.c +++ b/lib/varbuf.c @@ -43,7 +43,7 @@ void varbufdupc(struct varbuf *v, int c, ssize_t n) { } } -void varbufprintf(struct varbuf *v, const char *fmt, ...) { +int varbufprintf(struct varbuf *v, const char *fmt, ...) { int ou, r; va_list al; @@ -58,9 +58,10 @@ void varbufprintf(struct varbuf *v, const char *fmt, ...) { if (r < 0) r= (v->size-ou+1) * 2; v->used= ou+r; } while (r >= v->size-ou-1); + return r; } -void varbufvprintf(struct varbuf *v, const char *fmt, va_list va) { +int varbufvprintf(struct varbuf *v, const char *fmt, va_list va) { int ou, r; va_list al; @@ -74,6 +75,7 @@ void varbufvprintf(struct varbuf *v, const char *fmt, va_list va) { if (r < 0) r= (v->size-ou+1) * 2; v->used= ou+r; } while (r >= v->size-ou-1); + return r; } void varbufaddbuf(struct varbuf *v, const void *s, const int l) {