Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int query(int (*callback)(char *, size_t *))
|
||||
{
|
||||
char buffer[1024];
|
||||
size_t size = sizeof buffer;
|
||||
|
||||
if (callback(buffer, &size) == 0) {
|
||||
puts("query: callback failed");
|
||||
} else {
|
||||
char *ptr = buffer;
|
||||
|
||||
while (size-- > 0)
|
||||
putchar (*ptr++);
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
gcc -g -fPIC query.c -c
|
||||
gcc -g --shared query.c -o query.c
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
(with-dyn-lib "./query.so"
|
||||
(deffi query "query" void (closure)))
|
||||
|
||||
(deffi-cb query-cb int ((carray char) (ptr (array 1 size-t))))
|
||||
|
||||
(query (query-cb (lambda (buf sizeptr)
|
||||
(symacrolet ((size [sizeptr 0]))
|
||||
(let* ((s "Here am I")
|
||||
(l (length s)))
|
||||
(cond
|
||||
((> l size) 0)
|
||||
(t (carray-set-length buf size)
|
||||
(carray-put buf s)
|
||||
(set size l))))))))
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
(with-dyn-lib "./query.so"
|
||||
(deffi query "query" void (closure)))
|
||||
|
||||
(with-dyn-lib nil
|
||||
(deffi memcpy "memcpy" cptr (cptr str size-t)))
|
||||
|
||||
(deffi-cb query-cb int (cptr (ptr (array 1 size-t))))
|
||||
|
||||
(query (query-cb (lambda (buf sizeptr) ; int lambda(void *buf, siz
|
||||
(symacrolet ((size [sizeptr 0])) ; { #define size sizeptr[0]
|
||||
(let* ((s "Here am I") ; char *s = "Here am I";
|
||||
(l (length s))) ; size_t l = strlen(s);
|
||||
(cond ; if (length > size)
|
||||
((> l size) 0) ; { return 0; } else
|
||||
(t (memcpy buf s l) ; { memcpy(buf, s, l);
|
||||
(set size l)))))))) ; return size = l; } }
|
||||
|
|
@ -0,0 +1 @@
|
|||
(deffi-cb query-cb int (cptr (ptr (array 1 size-t))) -1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue