Browse code

webkernel: sbuf acquire/release

Dario Rodriguez authored on 15/06/2014 14:41:12
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,71 +0,0 @@
1
-/*
2
- * iobuf.c
3
- *
4
- * An I/O buffer library based on sbuf.
5
- *
6
- * History:
7
- *      12/03/2014 Creation.
8
- *      14/03/2014 Compilation fixes.
9
- *
10
- * Author: Dario Rodriguez dario@softhome.net
11
- * This library is licensed on the terms of the GNU LGPL v2+
12
- */
13
-
14
-#include <stdlib.h>
15
-#include <string.h>
16
-#include "iobuf.h"
17
-
18
-/* exported funcions */
19
-siobuf *
20
-iobuf_init(int insize,int outsize)
21
-{
22
-        siobuf *iobuf;
23
-        if((iobuf=malloc(sizeof(siobuf)))==NULL)
24
-                return(NULL);
25
-        memset(iobuf,0,sizeof(siobuf));
26
-        if((iobuf->in=sbuf_init(insize))==NULL) {
27
-                free(iobuf),iobuf=NULL;
28
-                return(NULL);
29
-        }
30
-        if((iobuf->out=sbuf_init(outsize))==NULL) {
31
-                sbuf_free(iobuf->in),iobuf->in=NULL;
32
-                free(iobuf),iobuf=NULL;
33
-                return(NULL);
34
-        }
35
-        return(iobuf);
36
-}
37
-
38
-siobuf *
39
-iobuf_staticinit(siobuf *uninitiobuf, sbuf *uninitinbuf, sbuf *uninitoutbuf,int insize, int outsize, char *inbuf, char *outbuf)
40
-{
41
-        memset(uninitiobuf,0,sizeof(siobuf));
42
-        if((uninitiobuf->in=sbuf_staticinit(uninitinbuf,insize,inbuf))==NULL)
43
-                return(NULL);
44
-        if((uninitiobuf->out=sbuf_staticinit(uninitoutbuf,outsize,outbuf))==NULL)
45
-                return(NULL);
46
-        return(uninitiobuf);
47
-}
48
-
49
-void
50
-iobuf_free(siobuf *iobuf)
51
-{
52
-        if(iobuf==NULL)
53
-                return;
54
-        if(iobuf->in!=NULL)
55
-                sbuf_free(iobuf->in),iobuf->in=NULL;
56
-        if(iobuf->out!=NULL)
57
-                sbuf_free(iobuf->out),iobuf->out=NULL;
58
-        free(iobuf);
59
-}
60
-
61
-void
62
-iobuf_staticfree(siobuf *iobuf)
63
-{
64
-        if(iobuf==NULL)
65
-                return;
66
-        sbuf_staticfree(iobuf->in),iobuf->in=NULL;
67
-        sbuf_staticfree(iobuf->out),iobuf->out=NULL;
68
-        return;
69
-}
70
-
71
-
Browse code

Compilation fixes. Implementation of loglib and parselib

Dario Rodriguez authored on 14/03/2014 12:42:03
Showing 1 changed files
... ...
@@ -5,12 +5,14 @@
5 5
  *
6 6
  * History:
7 7
  *      12/03/2014 Creation.
8
+ *      14/03/2014 Compilation fixes.
8 9
  *
9 10
  * Author: Dario Rodriguez dario@softhome.net
10 11
  * This library is licensed on the terms of the GNU LGPL v2+
11 12
  */
12 13
 
13 14
 #include <stdlib.h>
15
+#include <string.h>
14 16
 #include "iobuf.h"
15 17
 
16 18
 /* exported funcions */
... ...
@@ -37,9 +39,9 @@ siobuf *
37 39
 iobuf_staticinit(siobuf *uninitiobuf, sbuf *uninitinbuf, sbuf *uninitoutbuf,int insize, int outsize, char *inbuf, char *outbuf)
38 40
 {
39 41
         memset(uninitiobuf,0,sizeof(siobuf));
40
-        if((siobuf->in=sbuf_staticinit(uninitinbuf,insize,inbuf))==NULL)
42
+        if((uninitiobuf->in=sbuf_staticinit(uninitinbuf,insize,inbuf))==NULL)
41 43
                 return(NULL);
42
-        if((siobuf->out=sbuf_staticinit(uninitoutbuf,outsize,outbuf))==NULL)
44
+        if((uninitiobuf->out=sbuf_staticinit(uninitoutbuf,outsize,outbuf))==NULL)
43 45
                 return(NULL);
44 46
         return(uninitiobuf);
45 47
 }
... ...
@@ -66,5 +68,4 @@ iobuf_staticfree(siobuf *iobuf)
66 68
         return;
67 69
 }
68 70
 
69
-#endif
70 71
 
Browse code

iobuf implementation

Dario Rodriguez authored on 12/03/2014 12:35:36
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,70 @@
1
+/*
2
+ * iobuf.c
3
+ *
4
+ * An I/O buffer library based on sbuf.
5
+ *
6
+ * History:
7
+ *      12/03/2014 Creation.
8
+ *
9
+ * Author: Dario Rodriguez dario@softhome.net
10
+ * This library is licensed on the terms of the GNU LGPL v2+
11
+ */
12
+
13
+#include <stdlib.h>
14
+#include "iobuf.h"
15
+
16
+/* exported funcions */
17
+siobuf *
18
+iobuf_init(int insize,int outsize)
19
+{
20
+        siobuf *iobuf;
21
+        if((iobuf=malloc(sizeof(siobuf)))==NULL)
22
+                return(NULL);
23
+        memset(iobuf,0,sizeof(siobuf));
24
+        if((iobuf->in=sbuf_init(insize))==NULL) {
25
+                free(iobuf),iobuf=NULL;
26
+                return(NULL);
27
+        }
28
+        if((iobuf->out=sbuf_init(outsize))==NULL) {
29
+                sbuf_free(iobuf->in),iobuf->in=NULL;
30
+                free(iobuf),iobuf=NULL;
31
+                return(NULL);
32
+        }
33
+        return(iobuf);
34
+}
35
+
36
+siobuf *
37
+iobuf_staticinit(siobuf *uninitiobuf, sbuf *uninitinbuf, sbuf *uninitoutbuf,int insize, int outsize, char *inbuf, char *outbuf)
38
+{
39
+        memset(uninitiobuf,0,sizeof(siobuf));
40
+        if((siobuf->in=sbuf_staticinit(uninitinbuf,insize,inbuf))==NULL)
41
+                return(NULL);
42
+        if((siobuf->out=sbuf_staticinit(uninitoutbuf,outsize,outbuf))==NULL)
43
+                return(NULL);
44
+        return(uninitiobuf);
45
+}
46
+
47
+void
48
+iobuf_free(siobuf *iobuf)
49
+{
50
+        if(iobuf==NULL)
51
+                return;
52
+        if(iobuf->in!=NULL)
53
+                sbuf_free(iobuf->in),iobuf->in=NULL;
54
+        if(iobuf->out!=NULL)
55
+                sbuf_free(iobuf->out),iobuf->out=NULL;
56
+        free(iobuf);
57
+}
58
+
59
+void
60
+iobuf_staticfree(siobuf *iobuf)
61
+{
62
+        if(iobuf==NULL)
63
+                return;
64
+        sbuf_staticfree(iobuf->in),iobuf->in=NULL;
65
+        sbuf_staticfree(iobuf->out),iobuf->out=NULL;
66
+        return;
67
+}
68
+
69
+#endif
70
+