Mercurial > hg > th-libs
diff th_ioctx.c @ 686:dfc2c9f0577f
Add functions thfopen(ctx) and thfclose(ctx) to th_ioctx.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 06 Mar 2020 00:16:30 +0200 |
parents | 7e207f1023d9 |
children | 49c818acbbbe |
line wrap: on
line diff
--- a/th_ioctx.c Thu Mar 05 00:12:16 2020 +0200 +++ b/th_ioctx.c Fri Mar 06 00:16:30 2020 +0200 @@ -66,8 +66,7 @@ ctx->mallocated = TRUE; - if (ctx->fops->fopen != NULL) - ctx->status = ctx->fops->fopen(ctx); + ctx->status = thfopen(ctx); return ctx->status; } @@ -97,8 +96,7 @@ { if (ctx != NULL) { - if (ctx->fops != NULL && ctx->fops->fclose != NULL) - ctx->fops->fclose(ctx); + thfclose(ctx); if (ctx->fallocated) th_free_r(&ctx->filename); @@ -172,6 +170,27 @@ } +int thfopen(th_ioctx *ctx) +{ + if (ctx == NULL) + return THERR_NULLPTR; + + if (ctx->fops == NULL || ctx->fops->fopen == NULL) + return THERR_OK; + + return ctx->fops->fopen(ctx); +} + + +void thfclose(th_ioctx *ctx) +{ + if (ctx != NULL && + ctx->fops == NULL && + ctx->fops->fclose == NULL) + ctx->fops->fclose(ctx); +} + + int thfreset(th_ioctx *ctx) { if (ctx == NULL)