summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-04 05:02:19 -0400
committermidipix <writeonce@midipix.org>2018-08-04 05:21:03 -0400
commit2dfa014f328f366d1f78481d9f91c76df5b5007a (patch)
treeff12454b64c8cceb1966e548dee81bf6612abb74
parentd4f88d42725956c3aa6d9c6e83e70729c1a938e8 (diff)
downloadsofort-2dfa014f328f366d1f78481d9f91c76df5b5007a.tar.bz2
sofort-2dfa014f328f366d1f78481d9f91c76df5b5007a.tar.xz
output interfaces: revised API and implementation to use fdctx and pure fdio.
-rw-r--r--include/sofort/sofort.h9
-rw-r--r--src/driver/sfrt_amain.c6
-rw-r--r--src/output/sfrt_output_address.c13
-rw-r--r--src/output/sfrt_output_dummy.c12
-rw-r--r--src/output/sfrt_output_name.c12
5 files changed, 37 insertions, 15 deletions
diff --git a/include/sofort/sofort.h b/include/sofort/sofort.h
index 1c1dee2..e516d90 100644
--- a/include/sofort/sofort.h
+++ b/include/sofort/sofort.h
@@ -130,9 +130,12 @@ sfrt_api int sfrt_set_driver_fdctx (struct sfrt_driver_ctx *, const struct
/* utility api */
sfrt_api int sfrt_main (int, char **, char **, const struct sfrt_fd_ctx *);
-sfrt_api int sfrt_output_dummy (const struct sfrt_common_ctx *, FILE *); /* dummy */
-sfrt_api int sfrt_output_name (const struct sfrt_unit_ctx *, FILE *); /* dummy */
-sfrt_api int sfrt_output_address (const struct sfrt_unit_ctx *, FILE *); /* dummy */
+
+sfrt_api int sfrt_output_dummy (const struct sfrt_driver_ctx *); /* dummy */
+sfrt_api int sfrt_output_name (const struct sfrt_driver_ctx *, const struct sfrt_unit_ctx *); /* dummy */
+sfrt_api int sfrt_output_address (const struct sfrt_driver_ctx *, const struct sfrt_unit_ctx *); /* dummy */
+
+/* error trace api */
sfrt_api int sfrt_output_error_record (const struct sfrt_driver_ctx *, const struct sfrt_error_info *);
sfrt_api int sfrt_output_error_vector (const struct sfrt_driver_ctx *);
diff --git a/src/driver/sfrt_amain.c b/src/driver/sfrt_amain.c
index c37f77d..9a2c1dc 100644
--- a/src/driver/sfrt_amain.c
+++ b/src/driver/sfrt_amain.c
@@ -48,10 +48,10 @@ static void sfrt_perform_unit_actions(
uint64_t flags = dctx->cctx->actflags; /* dummy */
/* dummy */
if (flags & SFRT_OUTPUT_NAME) /* dummy */
- sfrt_output_name(uctx,stdout); /* dummy */
+ sfrt_output_name(dctx,uctx); /* dummy */
/* dummy */
if (flags & SFRT_OUTPUT_ADDRESS) /* dummy */
- sfrt_output_address(uctx,stdout); /* dummy */
+ sfrt_output_address(dctx,uctx); /* dummy */
}
static int sfrt_exit(struct sfrt_driver_ctx * dctx, int ret)
@@ -83,7 +83,7 @@ int sfrt_main(int argc, char ** argv, char ** envp, const struct sfrt_fd_ctx * f
return sfrt_exit(dctx,SFRT_ERROR);
if (dctx->cctx->anystring) /* dummy */
- if ((sfrt_output_dummy(dctx->cctx,stdout)) < 0) /* dummy */
+ if ((sfrt_output_dummy(dctx)) < 0) /* dummy */
return sfrt_exit(dctx,2); /* dummy */
/* dummy */
for (unit=dctx->units; *unit && !dctx->errv[0]; unit++) {
diff --git a/src/output/sfrt_output_address.c b/src/output/sfrt_output_address.c
index 019a2dd..c9b16a1 100644
--- a/src/output/sfrt_output_address.c
+++ b/src/output/sfrt_output_address.c
@@ -5,9 +5,16 @@
#include <errno.h>
#include <sofort/sofort.h>
+#include "sofort_driver_impl.h"
+#include "sofort_dprintf_impl.h"
-sfrt_api
-int sfrt_output_address(const struct sfrt_unit_ctx * uctx, FILE * f)
+int sfrt_output_address(
+ const struct sfrt_driver_ctx * dctx,
+ const struct sfrt_unit_ctx * uctx)
{
- return fprintf(f,"%*p\n",(int)(2*sizeof(size_t)),uctx->map->addr);
+ return sfrt_dprintf(
+ sfrt_driver_fdout(dctx),
+ "%*p\n",
+ (int)(2*sizeof(size_t)),
+ uctx->map->addr);
}
diff --git a/src/output/sfrt_output_dummy.c b/src/output/sfrt_output_dummy.c
index 4342737..c29f7e1 100644
--- a/src/output/sfrt_output_dummy.c
+++ b/src/output/sfrt_output_dummy.c
@@ -5,9 +5,15 @@
#include <errno.h>
#include <sofort/sofort.h>
+#include "sofort_driver_impl.h"
+#include "sofort_dprintf_impl.h"
-sfrt_api
-int sfrt_output_dummy (const struct sfrt_common_ctx * cctx, FILE * f)
+int sfrt_output_dummy (const struct sfrt_driver_ctx * dctx)
{
- return fprintf(f,"%s\n",cctx->anystring ? cctx->anystring : "(null)");
+ return sfrt_dprintf(
+ sfrt_driver_fdout(dctx),
+ "%s\n",
+ dctx->cctx->anystring
+ ? dctx->cctx->anystring
+ : "(null)");
}
diff --git a/src/output/sfrt_output_name.c b/src/output/sfrt_output_name.c
index c0aff5e..7eb874e 100644
--- a/src/output/sfrt_output_name.c
+++ b/src/output/sfrt_output_name.c
@@ -5,9 +5,15 @@
#include <errno.h>
#include <sofort/sofort.h>
+#include "sofort_driver_impl.h"
+#include "sofort_dprintf_impl.h"
-sfrt_api
-int sfrt_output_name(const struct sfrt_unit_ctx * uctx, FILE * f)
+int sfrt_output_name(
+ const struct sfrt_driver_ctx * dctx,
+ const struct sfrt_unit_ctx * uctx)
{
- return fprintf(f,"%s\n",*uctx->path);
+ return sfrt_dprintf(
+ sfrt_driver_fdout(dctx),
+ "%s\n",
+ *uctx->path);
}