add some man pages
This commit is contained in:
parent
3cf6f00371
commit
5950f0c5ae
12
Makefile
12
Makefile
@ -122,32 +122,32 @@ rename:
|
||||
|
||||
haveip6.h: tryip6.c
|
||||
-rm -f $@
|
||||
if $(DIET) $(CC) -c tryip6.c >/dev/null 2>&1; then echo "#define LIBC_HAS_IP6"; fi > $@
|
||||
if $(DIET) $(CC) $(CFLAGS) -c tryip6.c >/dev/null 2>&1; then echo "#define LIBC_HAS_IP6"; fi > $@
|
||||
-rm -f tryip6.o
|
||||
|
||||
haven2i.h: tryn2i.c
|
||||
-rm -f $@
|
||||
if $(DIET) $(CC) -o t tryn2i.c >/dev/null 2>&1; then echo "#define HAVE_N2I"; fi > $@
|
||||
if $(DIET) $(CC) $(CFLAGS) -o t tryn2i.c >/dev/null 2>&1; then echo "#define HAVE_N2I"; fi > $@
|
||||
-rm -f t
|
||||
|
||||
havesl.h: trysl.c
|
||||
-rm -f $@
|
||||
if ! $(DIET) $(CC) -o t trysl.c >/dev/null 2>&1; then echo "typedef int socklen_t;"; fi > $@
|
||||
if ! $(DIET) $(CC) $(CFLAGS) -o t trysl.c >/dev/null 2>&1; then echo "typedef int socklen_t;"; fi > $@
|
||||
-rm -f t
|
||||
|
||||
haveinline.h: tryinline.c
|
||||
-rm -f $@
|
||||
if ! $(DIET) $(CC) -c tryinline.c >/dev/null 2>&1; then echo "#define inline"; fi > $@
|
||||
if ! $(DIET) $(CC) $(CFLAGS) -c tryinline.c >/dev/null 2>&1; then echo "#define inline"; fi > $@
|
||||
-rm -f tryinline.o
|
||||
|
||||
iopause.h: iopause.h1 iopause.h2 trypoll.c
|
||||
-rm -f $@
|
||||
if $(DIET) $(CC) -o t trypoll.c >/dev/null 2>&1; then cp iopause.h2 iopause.h; else cp iopause.h1 iopause.h; fi
|
||||
if $(DIET) $(CC) $(CFLAGS) -o t trypoll.c >/dev/null 2>&1; then cp iopause.h2 iopause.h; else cp iopause.h1 iopause.h; fi
|
||||
-rm -f t
|
||||
|
||||
select.h: select.h1 select.h2 trysysel.c
|
||||
-rm -f $@
|
||||
if $(DIET) $(CC) -c trysysel.c >/dev/null 2>&1; then cp select.h2 select.h; else cp select.h1 select.h; fi
|
||||
if $(DIET) $(CC) $(CFLAGS) -c trysysel.c >/dev/null 2>&1; then cp select.h2 select.h; else cp select.h1 select.h; fi
|
||||
-rm -f trysysel.o
|
||||
|
||||
|
||||
|
15
buffer.h
15
buffer.h
@ -2,12 +2,12 @@
|
||||
#define BUFFER_H
|
||||
|
||||
typedef struct buffer {
|
||||
char *x;
|
||||
unsigned int p;
|
||||
unsigned int n;
|
||||
unsigned int a;
|
||||
int fd;
|
||||
int (*op)();
|
||||
char *x; /* actual buffer space */
|
||||
unsigned int p; /* current position */
|
||||
unsigned int n; /* current size of string in buffer */
|
||||
unsigned int a; /* allocated buffer size */
|
||||
int fd; /* passed as first argument to op */
|
||||
int (*op)(); /* use read(2) or write(2) */
|
||||
} buffer;
|
||||
|
||||
#define BUFFER_INIT(op,fd,buf,len) { (buf), 0, 0, (len), (fd), (op) }
|
||||
@ -15,7 +15,7 @@ typedef struct buffer {
|
||||
#define BUFFER_INSIZE 8192
|
||||
#define BUFFER_OUTSIZE 8192
|
||||
|
||||
extern void buffer_init(buffer* b,int (*op)(),int fd,char* y,unsigned int ylen);
|
||||
extern void buffer_init(buffer* b,int (*op)(int,char*,unsigned int),int fd,char* y,unsigned int ylen);
|
||||
|
||||
extern int buffer_flush(buffer* b);
|
||||
extern int buffer_put(buffer* b,const char* x,unsigned int len);
|
||||
@ -35,7 +35,6 @@ extern int buffer_putnlflush(buffer* b); /* put \n and flush */
|
||||
)
|
||||
|
||||
extern int buffer_get(buffer* b,char* x,unsigned int len);
|
||||
extern int buffer_bget(buffer* b,char* x,unsigned int len);
|
||||
extern int buffer_feed(buffer* b);
|
||||
extern int buffer_getc(buffer* b,char* x);
|
||||
extern int buffer_getn(buffer* b,char* x,unsigned int len);
|
||||
|
37
buffer/buffer.3
Normal file
37
buffer/buffer.3
Normal file
@ -0,0 +1,37 @@
|
||||
.TH buffer 3
|
||||
.SH NAME
|
||||
buffer.h \- generic read/write buffering
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
buffer* buffer_0; /* like stdio's stdin */
|
||||
buffer* buffer_1; /* like stdio's stdout */
|
||||
buffer* buffer_2; /* like stdio's stderr */
|
||||
|
||||
.SH DESCRIPTION
|
||||
buffer.h provides a generic buffer interface that can be used for
|
||||
read and write buffering. Buffers must be initialized with
|
||||
\fBbuffer_init\fR.
|
||||
|
||||
A buffer can only be used for reading or writing at the same time, not
|
||||
both.
|
||||
|
||||
Unlike stdio, these write buffers are not flushed automatically at
|
||||
program termination; you must manually call \fBbuffer_flush\fR,
|
||||
\fBbuffer_putsflush\fR, \fBbuffer_putflush\fR or
|
||||
\fBbuffer_putnlflush\fR.
|
||||
|
||||
.SH EXAMPLE
|
||||
See buffer_init(3) for example read buffer code. Here is typical code
|
||||
for printing an error message on stderr:
|
||||
|
||||
#include <buffer.h>
|
||||
|
||||
buffer_puts(buffer_2,"error: got only ");
|
||||
buffer_putulong(buffer_2,got);
|
||||
buffer_puts(buffer_2," bytes, but expected at least ");
|
||||
buffer_putulong(buffer_2,expected);
|
||||
buffer_putsflush(buffer_2," bytes!");
|
||||
|
||||
.SH "SEE ALSO"
|
||||
buffer_init(3), buffer_put(3), buffer_get(3), buffer_flush(3)
|
14
buffer/buffer_feed.3
Normal file
14
buffer/buffer_feed.3
Normal file
@ -0,0 +1,14 @@
|
||||
.TH buffer_feed 3
|
||||
.SH NAME
|
||||
buffer_feed \- low-level component of buffer_get
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_feed\fP(buffer* \fIb\fR);
|
||||
.SH DESCRIPTION
|
||||
If the string is nonempty, buffer_feed returns the length of the string.
|
||||
If the string is empty, buffer_feed uses the read operation to feed data
|
||||
into the string; it then returns the new length of the string, or 0 for
|
||||
end of input, or -1 for error.
|
||||
.SH "SEE ALSO"
|
||||
buffer_init(3), buffer_get(3), buffer_peek(3), buffer_feed(3), buffer(3)
|
27
buffer/buffer_flush.3
Normal file
27
buffer/buffer_flush.3
Normal file
@ -0,0 +1,27 @@
|
||||
.TH buffer_flush 3
|
||||
.SH NAME
|
||||
buffer_flush \- feed buffer to write function
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_flush\fP(buffer* \fIb\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_flush feeds a string \fId\fR[0], \fId\fR[1], ...,
|
||||
\fId\fR[\fIdlen\fR-1] to the write operation by calling
|
||||
|
||||
\fBop\fR(\fIfd\fR,\fId\fR,\fIdlen\fR)
|
||||
|
||||
If \fBop\fR successfully handles one or more bytes at the beginning of
|
||||
the string, it must return the number of bytes handled; if this number
|
||||
is smaller than \fIdlen\fR, buffer_flush will call \fBop\fR again with
|
||||
the rest of the string. If \fBop\fR does not handle any bytes, and does
|
||||
not encounter an error, it must return 0, or return -1 with \fIerrno\fR
|
||||
set to EINTR; in either case, buffer_flush will immediately call \fBop\fR
|
||||
again. If \fBop\fR encounters an error, it must return -1 with errno set to
|
||||
something other than EINTR; buffer_flush will pass the error to the
|
||||
caller.
|
||||
|
||||
On success, buffer_flush returns 0. On error, buffer_flush returns -1,
|
||||
setting \fIerrno\fR appropriately.
|
||||
.SH "SEE ALSO"
|
||||
buffer_init(3)
|
26
buffer/buffer_get.3
Normal file
26
buffer/buffer_get.3
Normal file
@ -0,0 +1,26 @@
|
||||
.TH buffer_get 3
|
||||
.SH NAME
|
||||
buffer_get \- read binary data from buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_get\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned int \fIlen\fR);
|
||||
.SH DESCRIPTION
|
||||
Normally buffer_get copies data to \fIx\fR[0], \fIx\fR[1], ...,
|
||||
\fIx\fR[\fIlen\fR-1] from the beginning of a string stored in
|
||||
preallocated space; removes these \fIlen\fR bytes from the string; and
|
||||
returns \fIlen\fR.
|
||||
|
||||
If, however, the string has fewer than \fIlen\fR (but more than 0)
|
||||
bytes, buffer_get copies only that many bytes, and returns that number.
|
||||
|
||||
If the string is empty, buffer_get first uses a \fBread operation\fR to
|
||||
feed data into the string. The \fBread operation\fR may indicate end of
|
||||
input, in which case buffer_get returns 0; or a read error, in which
|
||||
case buffer_get returns -1, setting \fIerrno\fR approporiately.
|
||||
|
||||
The preallocated space and the \fBread operation\fR are specified by
|
||||
\fIb\fR. You must initialize \fBb\fR using buffer_init before calling
|
||||
buffer_get (or use the pre-initialized buffer_0).
|
||||
.SH "SEE ALSO"
|
||||
buffer_init(3), buffer_feed(3), buffer_peek(3), buffer_seek(3), buffer(3)
|
27
buffer/buffer_get_token.3
Normal file
27
buffer/buffer_get_token.3
Normal file
@ -0,0 +1,27 @@
|
||||
.TH buffer_get_token 3
|
||||
.SH NAME
|
||||
buffer_get_token \- read token from buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_get_token\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned int \fIlen\fR,
|
||||
const char* \fIcharset\fR,unsigned int \fIsetlen\fR);
|
||||
.SH DESCRIPTION
|
||||
Normally buffer_get_token copies data to \fIx\fR[0], \fIx\fR[1], ...,
|
||||
\fIx\fR[\fIlen\fR-1] from the beginning of a string stored in
|
||||
preallocated space; removes these \fIlen\fR bytes from the string; and
|
||||
returns \fIlen\fR.
|
||||
|
||||
If, however, the string has fewer than \fIlen\fR (but more than 0)
|
||||
bytes, buffer_get_token copies only that many bytes, and returns that number.
|
||||
|
||||
If the string is empty, buffer_get_token first uses a \fBread operation\fR to
|
||||
feed data into the string. The \fBread operation\fR may indicate end of
|
||||
input, in which case buffer_get_token returns 0; or a read error, in which
|
||||
case buffer_get_token returns -1, setting \fIerrno\fR approporiately.
|
||||
|
||||
The preallocated space and the \fBread operation\fR are specified by
|
||||
\fIb\fR. You must initialize \fBb\fR using buffer_init before calling
|
||||
buffer_get_token (or use the pre-initialized buffer_0).
|
||||
.SH "SEE ALSO"
|
||||
buffer_init(3), buffer_feed(3), buffer_peek(3), buffer_seek(3), buffer(3)
|
11
buffer/buffer_getc.3
Normal file
11
buffer/buffer_getc.3
Normal file
@ -0,0 +1,11 @@
|
||||
.TH buffer_getc 3
|
||||
.SH NAME
|
||||
buffer_getc \- read one char from buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_getc\fP(buffer* \fIb\fR,char* \fIx\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_getc(b,x) is similar to buffer_get(b,x,1).
|
||||
.SH "SEE ALSO"
|
||||
buffer_init(3), buffer_get(3), buffer(3)
|
22
buffer/buffer_getn.3
Normal file
22
buffer/buffer_getn.3
Normal file
@ -0,0 +1,22 @@
|
||||
.TH buffer_getn 3
|
||||
.SH NAME
|
||||
buffer_getn \- read binary data from buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_getn\fP(buffer* \fIb\fR,char* \fIx\fR,unsigned int \fIlen\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_getn copies data to \fIx\fR[0], \fIx\fR[1], ...,
|
||||
\fIx\fR[\fIlen\fR-1] from the buffer, calling buffer_feed as needed, and
|
||||
returns \fIlen\fR.
|
||||
|
||||
If a read error occurs, buffer_getn returns -1 and sets \fIerrno\fR
|
||||
appropriately. It may then have put any number between 0 and \fIlen\fR
|
||||
in the buffer, you can't tell. That makes this function only useful if
|
||||
you don't care when an error occurs. Use buffer_get otherwise.
|
||||
|
||||
If the read operation signals end-of-file before \fIlen\fR bytes were
|
||||
read, buffer_getn returns the number of bytes read from the buffer
|
||||
before end-of-file.
|
||||
.SH "SEE ALSO"
|
||||
buffer_init(3), buffer_get(3), buffer(3)
|
45
buffer/buffer_init.3
Normal file
45
buffer/buffer_init.3
Normal file
@ -0,0 +1,45 @@
|
||||
.TH buffer_init 3
|
||||
.SH NAME
|
||||
buffer_init \- initialize buffer structure
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_init\fR(buffer &\fIb\fR,
|
||||
int (*\fIop\fR)(int,char*,unsigned int),
|
||||
int \fIfd\fR, char* \fIy\fR, unsigned int \fIylen\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_init prepares \fIb\fR to store a string in \fIy\fR[0], \fIy\fR[1], ...,
|
||||
\fIy\fR[\fIylen\fR-1]. Initially the string is empty.
|
||||
|
||||
buffer_init also prepares \fIb\fR to use the read/write operation specified by
|
||||
\fIop\fR and \fIfd\fR.
|
||||
|
||||
You can use
|
||||
|
||||
buffer \fIb\fR = BUFFER_INIT(\fIop\fR,\fIfd\fR,\fIy\fR,\fIylen\fR);
|
||||
|
||||
to initialize \fIb\fR statically if \fIop\fR, \fIfd\fR, \fIy\fR, and \fIylen\fR
|
||||
are compile-time constants.
|
||||
|
||||
You can call buffer_init again at any time. Note that this discards the
|
||||
currently buffered string.
|
||||
.SH EXAMPLE
|
||||
#include <buffer.h>
|
||||
#include <open.h>
|
||||
|
||||
char buf[4096];
|
||||
int fd=open_read("/etc/services");
|
||||
buffer input;
|
||||
|
||||
if (fd>=0) {
|
||||
char x;
|
||||
buffer_init(&input,read,fd,buf,sizeof buf);
|
||||
while (buffer_get(&input,&x,1)==1) {
|
||||
buffer_put(buffer_1,&x,1);
|
||||
if (x=='\\n') break;
|
||||
}
|
||||
buffer_flush(buffer_1);
|
||||
}
|
||||
|
||||
.SH "SEE ALSO"
|
||||
buffer_flush(3), buffer(3)
|
23
buffer/buffer_peek.3
Normal file
23
buffer/buffer_peek.3
Normal file
@ -0,0 +1,23 @@
|
||||
.TH buffer_peek 3
|
||||
.SH NAME
|
||||
buffer_peek \- return pointer to string in buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_peek\fP(buffer* \fIb\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_peek returns a pointer to the first byte of the string in the
|
||||
buffer.
|
||||
.SH EXAMPLE
|
||||
buffer_feed, buffer_peek and buffer_seek can be used for efficient reading
|
||||
loops, nearly the same speed as calling \fBop\fR directly:
|
||||
|
||||
for (;;) {
|
||||
r = buffer_feed(&b);
|
||||
if (r <= 0) return r;
|
||||
x = buffer_peek(&b);
|
||||
dosomething(x,r);
|
||||
buffer_seek(&b,r);
|
||||
}
|
||||
.SH "SEE ALSO"
|
||||
buffer_init(3), buffer_feed(3), buffer_get(3), buffer_seek(3), buffer(3)
|
19
buffer/buffer_put.3
Normal file
19
buffer/buffer_put.3
Normal file
@ -0,0 +1,19 @@
|
||||
.TH buffer_put 3
|
||||
.SH NAME
|
||||
buffer_put \- write binary data to buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_put\fP(buffer* \fIb\fR,const char* \fIx\fR,unsigned int \fIlen\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_put writes \fIlen\fR bytes from \fIx\fR to \fIb\fR.
|
||||
|
||||
The difference to buffer_putalign is that, when there isn't enough space
|
||||
for new data, buffer_put calls buffer_flush before copying any data,
|
||||
while buffer_putalign fills all available space with data before calling
|
||||
buffer_flush.
|
||||
|
||||
On success, buffer_put returns 0. On error, buffer_put returns -1,
|
||||
setting \fIerrno\fR appropriately.
|
||||
.SH "SEE ALSO"
|
||||
buffer_putalign(3), buffer_puts(3), buffer_flush(3), buffer(3)
|
13
buffer/buffer_put8long.3
Normal file
13
buffer/buffer_put8long.3
Normal file
@ -0,0 +1,13 @@
|
||||
.TH buffer_put8long 3
|
||||
.SH NAME
|
||||
buffer_put8long \- write an octal ASCII representation of an unsigned
|
||||
long integer to buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_put8long\fP(buffer* \fIb\fR,unsigned long \fIx\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_put8long is similar to passing the result of fmt_8long to
|
||||
buffer_put.
|
||||
.SH "SEE ALSO"
|
||||
fmt_8long(3), buffer_put(3), buffer_flush(3), buffer(3)
|
16
buffer/buffer_putalign.3
Normal file
16
buffer/buffer_putalign.3
Normal file
@ -0,0 +1,16 @@
|
||||
.TH buffer_putalign 3
|
||||
.SH NAME
|
||||
buffer_putalign \- write binary data to buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_putalign\fP(buffer* \fIb\fR,const char* \fIx\fR,unsigned int \fIlen\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_putalign is similar to buffer_put.
|
||||
|
||||
The difference to buffer_put is that, when there isn't enough space for
|
||||
new data, buffer_put calls buffer_flush before copying any data, while
|
||||
buffer_putalign fills all available space with data before calling
|
||||
buffer_flush.
|
||||
.SH "SEE ALSO"
|
||||
buffer_put(3), buffer_putsalign(3), buffer_flush(3), buffer(3)
|
13
buffer/buffer_putflush.3
Normal file
13
buffer/buffer_putflush.3
Normal file
@ -0,0 +1,13 @@
|
||||
.TH buffer_putflush 3
|
||||
.SH NAME
|
||||
buffer_putflush \- write binary data to buffer and flush
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_putflush\fP(buffer* \fIb\fR,
|
||||
const char* \fIx\fR,unsigned int \fIlen\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_putflush is similar to calling
|
||||
buffer_put(\fIb\fR,\fIx\fR,\fIlen\fR) and then buffer_flush(\fIb\fR).
|
||||
.SH "SEE ALSO"
|
||||
buffer_put(3), buffer_flush(3), buffer(3)
|
13
buffer/buffer_putlong.3
Normal file
13
buffer/buffer_putlong.3
Normal file
@ -0,0 +1,13 @@
|
||||
.TH buffer_putlong 3
|
||||
.SH NAME
|
||||
buffer_putlong \- write a decimal ASCII representation of a signed
|
||||
long integer to buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_putlong\fP(buffer* \fIb\fR,unsigned long \fIx\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_putlong is similar to passing the result of fmt_long to
|
||||
buffer_put.
|
||||
.SH "SEE ALSO"
|
||||
fmt_long(3), buffer_put(3), buffer_flush(3), buffer(3)
|
12
buffer/buffer_putnlflush.3
Normal file
12
buffer/buffer_putnlflush.3
Normal file
@ -0,0 +1,12 @@
|
||||
.TH buffer_putnlflush 3
|
||||
.SH NAME
|
||||
buffer_putnlflush \- write '\\n' to buffer and flush
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_putnlflush\fP(buffer* \fIb\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_putnlflush writes a single ASCII new-line character ('\\n') to
|
||||
\fIb\fR and calls buffer_flush(\fIb\fR).
|
||||
.SH "SEE ALSO"
|
||||
buffer_puts(3), buffer_put(3), buffer_flush(3), buffer(3)
|
17
buffer/buffer_puts.3
Normal file
17
buffer/buffer_puts.3
Normal file
@ -0,0 +1,17 @@
|
||||
.TH buffer_puts 3
|
||||
.SH NAME
|
||||
buffer_puts \- write ASCIIZ string to buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_puts\fP(buffer* \fIb\fR,const char* \fIx\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_puts is like buffer_put with \fIlen\fR determined as the number
|
||||
of bytes before the first \\0 in \fIx\fR.
|
||||
|
||||
The difference to buffer_putsalign is that, when there isn't enough space
|
||||
for new data, buffer_puts calls buffer_flush before copying any data,
|
||||
while buffer_putsalign fills all available space with data before calling
|
||||
buffer_flush.
|
||||
.SH "SEE ALSO"
|
||||
buffer_putsalign(3), buffer_put(3), buffer_flush(3), buffer(3)
|
12
buffer/buffer_putsalign.3
Normal file
12
buffer/buffer_putsalign.3
Normal file
@ -0,0 +1,12 @@
|
||||
.TH buffer_putsalign 3
|
||||
.SH NAME
|
||||
buffer_putsalign \- write ASCIIZ string to buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_putsalign\fP(buffer* \fIb\fR,const char* \fIx\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_putsalign is like buffer_putalign with \fIlen\fR determined as
|
||||
the number of bytes before the first \\0 in \fIx\fR.
|
||||
.SH "SEE ALSO"
|
||||
buffer_puts(3), buffer_put(3), buffer_flush(3), buffer(3)
|
12
buffer/buffer_putsflush.3
Normal file
12
buffer/buffer_putsflush.3
Normal file
@ -0,0 +1,12 @@
|
||||
.TH buffer_putsflush 3
|
||||
.SH NAME
|
||||
buffer_putsflush \- write ASCIIZ string to buffer and flush
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_putsflush\fP(buffer* \fIb\fR,const char* \fIx\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_putsflush is like buffer_putflush with \fIlen\fR determined as
|
||||
the number of bytes before the first \\0 in \fIx\fR.
|
||||
.SH "SEE ALSO"
|
||||
buffer_put(3), buffer_flush(3), buffer(3)
|
11
buffer/buffer_putspace.3
Normal file
11
buffer/buffer_putspace.3
Normal file
@ -0,0 +1,11 @@
|
||||
.TH buffer_putspace 3
|
||||
.SH NAME
|
||||
buffer_putspace \- write ASCII space to buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_putspace\fP(buffer* \fIb\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_putspace writes a single ASCII space character to \fIb\fR.
|
||||
.SH "SEE ALSO"
|
||||
buffer_puts(3), buffer_put(3), buffer_flush(3), buffer(3)
|
13
buffer/buffer_putulong.3
Normal file
13
buffer/buffer_putulong.3
Normal file
@ -0,0 +1,13 @@
|
||||
.TH buffer_putulong 3
|
||||
.SH NAME
|
||||
buffer_putulong \- write a decimal ASCII representation of an unsigned
|
||||
long integer to buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_putulong\fP(buffer* \fIb\fR,unsigned long \fIx\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_putulong is similar to passing the result of fmt_ulong to
|
||||
buffer_put.
|
||||
.SH "SEE ALSO"
|
||||
fmt_ulong(3), buffer_put(3), buffer_flush(3), buffer(3)
|
13
buffer/buffer_putxlong.3
Normal file
13
buffer/buffer_putxlong.3
Normal file
@ -0,0 +1,13 @@
|
||||
.TH buffer_putxlong 3
|
||||
.SH NAME
|
||||
buffer_putxlong \- write a hexidecimal ASCII representation of an unsigned
|
||||
long integer to buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_putxlong\fP(buffer* \fIb\fR,unsigned long \fIx\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_putxlong is similar to passing the result of fmt_xlong to
|
||||
buffer_put.
|
||||
.SH "SEE ALSO"
|
||||
fmt_xlong(3), buffer_put(3), buffer_flush(3), buffer(3)
|
12
buffer/buffer_seek.3
Normal file
12
buffer/buffer_seek.3
Normal file
@ -0,0 +1,12 @@
|
||||
.TH buffer_seek 3
|
||||
.SH NAME
|
||||
buffer_seek \- remove bytes from beginning of string in buffer
|
||||
.SH SYNTAX
|
||||
.B #include <buffer.h>
|
||||
|
||||
int \fBbuffer_seek\fP(buffer* \fIb\fR,unsigned int \fIr\fR);
|
||||
.SH DESCRIPTION
|
||||
buffer_seek removes \fIr\fR bytes from the beginning of the string.
|
||||
\fIr\fR must be at most the current length of the string.
|
||||
.SH "SEE ALSO"
|
||||
buffer_init(3), buffer_feed(3), buffer_peek(3), buffer_get(3), buffer(3)
|
7
buffer/buffer_seek.c
Normal file
7
buffer/buffer_seek.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include "buffer.h"
|
||||
|
||||
void buffer_seek(buffer* b,unsigned int len) {
|
||||
unsigned int n=b->p+len;
|
||||
if (n>b->n) n=b->n;
|
||||
b->p=n;
|
||||
}
|
@ -4,7 +4,8 @@ fmt_strn \- write an ASCII string
|
||||
.SH SYNTAX
|
||||
.B #include <fmt.h>
|
||||
|
||||
unsigned int \fBfmt_strn\fP(char *\fIdest\fR,const char *\fIsource\fR,unsigned int maxlen);
|
||||
unsigned int \fBfmt_strn\fP(char *\fIdest\fR,const char *\fIsource\fR,
|
||||
unsigned int maxlen);
|
||||
.SH DESCRIPTION
|
||||
fmt_str copies at most \fImaxlen\fR leading nonzero bytes from
|
||||
\fIsource\fR to \fIdest\fR and returns the number of bytes it copied.
|
||||
|
@ -4,7 +4,8 @@ fmt_uint0 \- write a zero-padded ASCII representation of an unsigned integer
|
||||
.SH SYNTAX
|
||||
.B #include <fmt.h>
|
||||
|
||||
unsigned int \fBfmt_uint0\fP(char *\fIdest\fR, unsigned int \fIsource\fR, unsigned int \fIn\fR);
|
||||
unsigned int \fBfmt_uint0\fP(char *\fIdest\fR,unsigned int \fIsource\fR,
|
||||
unsigned int \fIn\fR);
|
||||
.SH DESCRIPTION
|
||||
fmt_uint0 writes an ASCII representation ('0' to '9', base 10) of
|
||||
\fIsource\fR to \fIdest\fR and returns the number of bytes written.
|
||||
|
@ -4,7 +4,8 @@ fmt_ulong0 \- write a zero-padded ASCII representation of an unsigned long integ
|
||||
.SH SYNTAX
|
||||
.B #include <fmt.h>
|
||||
|
||||
unsigned int \fBfmt_uint0\fP(char *\fIdest\fR, unsigned long \fIsource\fR, unsigned int \fIn\fR);
|
||||
unsigned int \fBfmt_ulong0\fP(char *\fIdest\fR, unsigned long \fIsource\fR,
|
||||
unsigned int \fIn\fR);
|
||||
.SH DESCRIPTION
|
||||
fmt_ulong0 writes an ASCII representation ('0' to '9', base 10) of
|
||||
\fIsource\fR to \fIdest\fR and returns the number of bytes written.
|
||||
|
13
scan/scan_8short.3
Normal file
13
scan/scan_8short.3
Normal file
@ -0,0 +1,13 @@
|
||||
.TH scan_8short 3
|
||||
.SH NAME
|
||||
scan_8short \- parse an unsigned short integer in octal ASCII representation
|
||||
.SH SYNTAX
|
||||
.B #include <scan.h>
|
||||
|
||||
int \fBscan_8short\fP(const char *\fIsrc\fR,unsigned short *\fIdest\fR);
|
||||
.SH DESCRIPTION
|
||||
scan_8short parses an unsigned short integer in octal ASCII representation
|
||||
from \fIsrc\fR and writes the result into \fIdest\fR. It returns the
|
||||
number of bytes read from \fIsrc\fR.
|
||||
.SH "SEE ALSO"
|
||||
scan_xshort(3)
|
13
scan/scan_ushort.3
Normal file
13
scan/scan_ushort.3
Normal file
@ -0,0 +1,13 @@
|
||||
.TH scan_ushort 3
|
||||
.SH NAME
|
||||
scan_ushort \- parse an unsigned short integer in decimal ASCII representation
|
||||
.SH SYNTAX
|
||||
.B #include <scan.h>
|
||||
|
||||
int \fBscan_ushort\fP(const char *\fIsrc\fR,unsigned short *\fIdest\fR);
|
||||
.SH DESCRIPTION
|
||||
scan_ushort parses an unsigned short integer in decimal ASCII representation
|
||||
from \fIsrc\fR and writes the result into \fIdest\fR. It returns the
|
||||
number of bytes read from \fIsrc\fR.
|
||||
.SH "SEE ALSO"
|
||||
scan_xshort(3), scan_8short(3), fmt_ulong(3)
|
17
scan/scan_xshort.3
Normal file
17
scan/scan_xshort.3
Normal file
@ -0,0 +1,17 @@
|
||||
.TH scan_xshort 3
|
||||
.SH NAME
|
||||
scan_xshort \- parse an unsigned short integer in hexadecimal ASCII representation
|
||||
.SH SYNTAX
|
||||
.B #include <scan.h>
|
||||
|
||||
int \fBscan_xshort\fP(const char *\fIsrc\fR,unsigned short *\fIdest\fR);
|
||||
.SH DESCRIPTION
|
||||
scan_xshort parses an unsigned short integer in hexadecimal ASCII
|
||||
representation from \fIsrc\fR and writes the result into \fIdest\fR. It
|
||||
returns the number of bytes read from \fIsrc\fR.
|
||||
|
||||
scan_xshort understands both upper and lower case letters.
|
||||
|
||||
scan_xshort does not expect or understand a "0x" prefix.
|
||||
.SH "SEE ALSO"
|
||||
fmt_xshort(3)
|
Loading…
x
Reference in New Issue
Block a user