summaryrefslogtreecommitdiff
path: root/checkpasswd/buffer.h
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-06-03 01:38:28 (GMT)
committerJohn Denker <jsd@av8n.com>2012-06-03 01:38:28 (GMT)
commit78488dc84afac1398e582ae6bbaf9606d07afa1e (patch)
tree71723e916f23a6a07422587de275dece3ea60252 /checkpasswd/buffer.h
parent81b5f8f3ab26a7969956faef29a90499ece40ff5 (diff)
checkpassword ... as downloaded
Diffstat (limited to 'checkpasswd/buffer.h')
-rw-r--r--checkpasswd/buffer.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/checkpasswd/buffer.h b/checkpasswd/buffer.h
new file mode 100644
index 0000000..12539b3
--- /dev/null
+++ b/checkpasswd/buffer.h
@@ -0,0 +1,56 @@
+#ifndef BUFFER_H
+#define BUFFER_H
+
+typedef struct buffer {
+ char *x;
+ unsigned int p;
+ unsigned int n;
+ int fd;
+ int (*op)();
+} buffer;
+
+#define BUFFER_INIT(op,fd,buf,len) { (buf), 0, (len), (fd), (op) }
+#define BUFFER_INSIZE 8192
+#define BUFFER_OUTSIZE 8192
+
+extern void buffer_init(buffer *,int (*)(),int,char *,unsigned int);
+
+extern int buffer_flush(buffer *);
+extern int buffer_put(buffer *,char *,unsigned int);
+extern int buffer_putalign(buffer *,char *,unsigned int);
+extern int buffer_putflush(buffer *,char *,unsigned int);
+extern int buffer_puts(buffer *,char *);
+extern int buffer_putsalign(buffer *,char *);
+extern int buffer_putsflush(buffer *,char *);
+
+#define buffer_PUTC(s,c) \
+ ( ((s)->n != (s)->p) \
+ ? ( (s)->x[(s)->p++] = (c), 0 ) \
+ : buffer_put((s),&(c),1) \
+ )
+
+extern int buffer_get(buffer *,char *,unsigned int);
+extern int buffer_bget(buffer *,char *,unsigned int);
+extern int buffer_feed(buffer *);
+
+extern char *buffer_peek(buffer *);
+extern void buffer_seek(buffer *,unsigned int);
+
+#define buffer_PEEK(s) ( (s)->x + (s)->n )
+#define buffer_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) )
+
+#define buffer_GETC(s,c) \
+ ( ((s)->p > 0) \
+ ? ( *(c) = (s)->x[(s)->n], buffer_SEEK((s),1), 1 ) \
+ : buffer_get((s),(c),1) \
+ )
+
+extern int buffer_copy(buffer *,buffer *);
+
+extern buffer *buffer_0;
+extern buffer *buffer_0small;
+extern buffer *buffer_1;
+extern buffer *buffer_1small;
+extern buffer *buffer_2;
+
+#endif