]> the.earth.li Git - onak.git/blobdiff - keydb/keydb_pg.c
Switch charfuncs to returning number of read/written characters
[onak.git] / keydb / keydb_pg.c
index c8392f721b9460800b73867c1189f63d4933313e..85c16ccbdcf39d10c2e3aa0584e4da7c67517d49 100644 (file)
@@ -47,21 +47,28 @@ struct pg_fc_ctx {
 /**
  *     keydb_fetchchar - Fetches a char from a file.
  */
-static int keydb_fetchchar(void *_ctx, size_t count, void *c)
+static size_t keydb_fetchchar(void *_ctx, size_t count, void *c)
 {
+       int ret;
+
        struct pg_fc_ctx *ctx = (struct pg_fc_ctx *) _ctx;
 
-       return (!lo_read(ctx->dbconn, ctx->fd, (char *) c, count));
+       ret = lo_read(ctx->dbconn, ctx->fd, (char *) c, count);
+
+       return (ret > 0) ? ret : 0;
 }
 
 /**
  *     keydb_putchar - Puts a char to a file.
  */
-static int keydb_putchar(void *_ctx, size_t count, void *c)
+static size_t keydb_putchar(void *_ctx, size_t count, void *c)
 {
        struct pg_fc_ctx *ctx = (struct pg_fc_ctx *) _ctx;
+       int ret;
+
+       ret = lo_write(ctx->dbconn, ctx->fd, (char *) c, count);
 
-       return !(lo_write(ctx->dbconn, ctx->fd, (char *) c, count));
+       return (ret > 0) ? ret : 0;
 }
 
 /**