How to pass a newlisp string to C function as uint8_t* arg
Posted: Mon Dec 08, 2014 5:38 pm
The existing C function is:
I import it in newlisp:
Now when I try to use bson_new_from_json function, always get 0 value returned.
Code: Select all
bson_t * bson_new_from_json (const uint8_t* data, ssize_t len, bson_error_t *error);
Code: Select all
(import bson-lib "bson_new_from_json" "void*" "void*" "unsigned int" "void*")
;; I also tried to use char* instead
;; (import bson-lib "bson_new_from_json" "void*" "char*" "unsigned int" "void*")
;; @syntax (mongo:bson-new-from-json json-str)
;; @return the pointer of bson_t
(define (bson-new-from-json json-str)
(bson_new_from_json json-str (length json-str) 0)
)
Code: Select all
(load "mongo.lsp")
(set 'cmd-str "{stats:true}")
"{stats:true}"
> (mongo:bson-new-from-json cmd-str)
0