libqaeda

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

dummy.c (1069B)


      1 #include <stddef.h>
      2 #include <stdio.h>
      3 
      4 #include <hex.h>
      5 
      6 #include "lq/store.h"
      7 #include "lq/err.h"
      8 
      9 static const int store_typ_dummy = 1;
     10 
     11 static char buf[4096];
     12 
     13 int lq_dummy_content_get(enum payload_e typ, LQStore *store, const char *key, size_t key_len, char *value, size_t *value_len) {
     14 	if (store_typ_dummy != store->store_typ) {
     15 		return ERR_COMPAT;
     16 	}
     17 	b2h((const unsigned char*)key, (int)key_len, (unsigned char*)buf);
     18 	fprintf(stderr, "pretend get %d: %s\n", typ, buf);
     19 	return 0;
     20 }
     21 
     22 int lq_dummy_content_put(enum payload_e typ, LQStore *store, const char *key, size_t *key_len, char *value, size_t value_len) {
     23 	if (store_typ_dummy != store->store_typ) {
     24 		return ERR_COMPAT;
     25 	}
     26 	b2h((const unsigned char*)key, (int)*key_len, (unsigned char*)buf);
     27 	fprintf(stderr, "pretend put %d: %s -> %s\n", typ, buf, value);
     28 	return 0;
     29 }
     30 
     31 void lq_dummy_content_free(LQStore *store) {
     32 }
     33 
     34 struct lq_store_t LQDummyContent = {
     35 	.store_typ = store_typ_dummy,
     36 	.userdata = NULL,
     37 	.get = lq_dummy_content_get,	
     38 	.put = lq_dummy_content_put,
     39 	.free = lq_dummy_content_free,
     40 };