| ... | ... |
@@ -5,13 +5,6 @@ |
| 5 | 5 |
* |
| 6 | 6 |
* Header file. |
| 7 | 7 |
* |
| 8 |
- * History: |
|
| 9 |
- * 21/01/2014 Creation. |
|
| 10 |
- * 27/01/2014 Finish initial API. |
|
| 11 |
- * 13/03/2014 Removed the low-level API, as it is redundant with |
|
| 12 |
- * _staticinit()/_staticfree(). |
|
| 13 |
- * 14/03/2014 Compilation fixes. |
|
| 14 |
- * |
|
| 15 | 8 |
* Author: Dario Rodriguez dario@softhome.net |
| 16 | 9 |
* This library is licensed on the terms of the GNU LGPL v2+ |
| 17 | 10 |
*/ |
| ... | ... |
@@ -41,8 +41,8 @@ void sbuf_wipe(sbuf *buf); |
| 41 | 41 |
char *sbuf_getbytes(sbuf *buf, long numbytes); |
| 42 | 42 |
long sbuf_count(sbuf *buf); |
| 43 | 43 |
char *sbuf_ptr(sbuf *buf); |
| 44 |
-long sbuf_add(sbuf *buf, char *data, long datasize); |
|
| 45 |
-long sbuf_addstr(sbuf *buf, char *str); |
|
| 44 |
+long sbuf_add(sbuf *buf, const char *data, long datasize); |
|
| 45 |
+long sbuf_addstr(sbuf *buf, const char *str); |
|
| 46 | 46 |
long sbuf_unused(sbuf *buf); |
| 47 | 47 |
char *sbuf_ptrunused(sbuf *buf); |
| 48 | 48 |
long sbuf_addfromunused(sbuf *buf, long numbytes); |
| ... | ... |
@@ -8,8 +8,9 @@ |
| 8 | 8 |
* History: |
| 9 | 9 |
* 21/01/2014 Creation. |
| 10 | 10 |
* 27/01/2014 Finish initial API. |
| 11 |
- * 13/03/2014 removed the low-level API, as it is redundant with |
|
| 11 |
+ * 13/03/2014 Removed the low-level API, as it is redundant with |
|
| 12 | 12 |
* _staticinit()/_staticfree(). |
| 13 |
+ * 14/03/2014 Compilation fixes. |
|
| 13 | 14 |
* |
| 14 | 15 |
* Author: Dario Rodriguez dario@softhome.net |
| 15 | 16 |
* This library is licensed on the terms of the GNU LGPL v2+ |
| ... | ... |
@@ -22,7 +23,7 @@ typedef struct {
|
| 22 | 23 |
long used; |
| 23 | 24 |
long got; |
| 24 | 25 |
long size; |
| 25 |
- char *buf |
|
| 26 |
+ char *buf; |
|
| 26 | 27 |
} sbuf; |
| 27 | 28 |
|
| 28 | 29 |
/* sbuf, high level api */ |
| ... | ... |
@@ -8,6 +8,8 @@ |
| 8 | 8 |
* History: |
| 9 | 9 |
* 21/01/2014 Creation. |
| 10 | 10 |
* 27/01/2014 Finish initial API. |
| 11 |
+ * 13/03/2014 removed the low-level API, as it is redundant with |
|
| 12 |
+ * _staticinit()/_staticfree(). |
|
| 11 | 13 |
* |
| 12 | 14 |
* Author: Dario Rodriguez dario@softhome.net |
| 13 | 15 |
* This library is licensed on the terms of the GNU LGPL v2+ |
| ... | ... |
@@ -34,7 +36,7 @@ char *sbuf_getline(sbuf *buf); |
| 34 | 36 |
void sbuf_discard(sbuf *buf); |
| 35 | 37 |
void sbuf_wipe(sbuf *buf); |
| 36 | 38 |
|
| 37 |
-/* sbuf, addutional functionality */ |
|
| 39 |
+/* sbuf, additional functionality */ |
|
| 38 | 40 |
char *sbuf_getbytes(sbuf *buf, long numbytes); |
| 39 | 41 |
long sbuf_count(sbuf *buf); |
| 40 | 42 |
char *sbuf_ptr(sbuf *buf); |
| ... | ... |
@@ -45,10 +47,5 @@ char *sbuf_ptrunused(sbuf *buf); |
| 45 | 47 |
long sbuf_addfromunused(sbuf *buf, long numbytes); |
| 46 | 48 |
long sbuf_send(sbuf *buf, int fd, long numbytes); |
| 47 | 49 |
|
| 48 |
-/* low level api */ |
|
| 49 |
-long strbuf_fill(char *strbuf, long strbufsize, long *used, int fd. long numbytes); |
|
| 50 |
-char *strbuf_getline(char *strbuf, long strbufsize, long used, long *got); |
|
| 51 |
-void strbuf_discard(char *strbuf, long strbufsize, long *used, long *got); |
|
| 52 |
- |
|
| 53 | 50 |
#endif |
| 54 | 51 |
|
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,54 @@ |
| 1 |
+/* |
|
| 2 |
+ * sbuf.h |
|
| 3 |
+ * |
|
| 4 |
+ * A string buffer library. |
|
| 5 |
+ * |
|
| 6 |
+ * Header file. |
|
| 7 |
+ * |
|
| 8 |
+ * History: |
|
| 9 |
+ * 21/01/2014 Creation. |
|
| 10 |
+ * 27/01/2014 Finish initial API. |
|
| 11 |
+ * |
|
| 12 |
+ * Author: Dario Rodriguez dario@softhome.net |
|
| 13 |
+ * This library is licensed on the terms of the GNU LGPL v2+ |
|
| 14 |
+ */ |
|
| 15 |
+ |
|
| 16 |
+#ifndef SBUF_H |
|
| 17 |
+#define SBUF_H |
|
| 18 |
+ |
|
| 19 |
+typedef struct {
|
|
| 20 |
+ long used; |
|
| 21 |
+ long got; |
|
| 22 |
+ long size; |
|
| 23 |
+ char *buf |
|
| 24 |
+} sbuf; |
|
| 25 |
+ |
|
| 26 |
+/* sbuf, high level api */ |
|
| 27 |
+sbuf *sbuf_init(long bufsize); |
|
| 28 |
+sbuf *sbuf_staticinit(sbuf *uninitsbuf, long bufsize, char *buf); |
|
| 29 |
+void sbuf_free(sbuf *buf); |
|
| 30 |
+void sbuf_staticfree(sbuf *buf); |
|
| 31 |
+ |
|
| 32 |
+int sbuf_fill(sbuf *buf, int fd, long numbytes); |
|
| 33 |
+char *sbuf_getline(sbuf *buf); |
|
| 34 |
+void sbuf_discard(sbuf *buf); |
|
| 35 |
+void sbuf_wipe(sbuf *buf); |
|
| 36 |
+ |
|
| 37 |
+/* sbuf, addutional functionality */ |
|
| 38 |
+char *sbuf_getbytes(sbuf *buf, long numbytes); |
|
| 39 |
+long sbuf_count(sbuf *buf); |
|
| 40 |
+char *sbuf_ptr(sbuf *buf); |
|
| 41 |
+long sbuf_add(sbuf *buf, char *data, long datasize); |
|
| 42 |
+long sbuf_addstr(sbuf *buf, char *str); |
|
| 43 |
+long sbuf_unused(sbuf *buf); |
|
| 44 |
+char *sbuf_ptrunused(sbuf *buf); |
|
| 45 |
+long sbuf_addfromunused(sbuf *buf, long numbytes); |
|
| 46 |
+long sbuf_send(sbuf *buf, int fd, long numbytes); |
|
| 47 |
+ |
|
| 48 |
+/* low level api */ |
|
| 49 |
+long strbuf_fill(char *strbuf, long strbufsize, long *used, int fd. long numbytes); |
|
| 50 |
+char *strbuf_getline(char *strbuf, long strbufsize, long used, long *got); |
|
| 51 |
+void strbuf_discard(char *strbuf, long strbufsize, long *used, long *got); |
|
| 52 |
+ |
|
| 53 |
+#endif |
|
| 54 |
+ |