X-Git-Url: https://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=keydb%2Fkeydb_pg.c;fp=keydb%2Fkeydb_pg.c;h=85c16ccbdcf39d10c2e3aa0584e4da7c67517d49;hp=c8392f721b9460800b73867c1189f63d4933313e;hb=35e886f23fde338387c8e2a3a74c9251f7735c3b;hpb=db700de99a954f1d88d15b28b386bc5b5e694df7 diff --git a/keydb/keydb_pg.c b/keydb/keydb_pg.c index c8392f7..85c16cc 100644 --- a/keydb/keydb_pg.c +++ b/keydb/keydb_pg.c @@ -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; } /**