Blame src/internal/sofort_driver_impl.h

8805b2
#ifndef SOFORT_DRIVER_IMPL_H
8805b2
#define SOFORT_DRIVER_IMPL_H
f46039
f46039
#include <stdint.h>
f46039
#include <stdio.h>
f46039
#include <sys/types.h>
f46039
f46039
#include <sofort/sofort.h>
e9413d
#include "sofort_dprintf_impl.h"
0090d8
#include "argv/argv.h"
0090d8
a04059
#define SFRT_OPTV_ELEMENTS 64
a04059
0090d8
extern const struct argv_option sfrt_default_options[];
f46039
f46039
enum app_tags {
f46039
	TAG_HELP,
f46039
	TAG_VERSION,
bbc20f
	TAG_OUTPUT_DUMMY,	/* dummy */
bbc20f
	TAG_OUTPUT_PROPERTY,	/* dummy */
f46039
};
f46039
f46039
struct sfrt_driver_ctx_impl {
7a0b56
	struct sfrt_common_ctx          cctx;
7a0b56
	struct sfrt_driver_ctx	        ctx;
d4f88d
	struct sfrt_fd_ctx		fdctx;
7a0b56
	const  struct sfrt_unit_ctx *   euctx;
7a0b56
	const  char *                   eunit;
7a0b56
	struct sfrt_error_info **       errinfp;
7a0b56
	struct sfrt_error_info **       erricap;
7a0b56
	struct sfrt_error_info *        erriptr[64];
7a0b56
	struct sfrt_error_info	        erribuf[64];
f46039
};
f46039
f46039
struct sfrt_unit_ctx_impl {
f46039
	const char *		path;
f46039
	struct sfrt_input	map;
f46039
	struct sfrt_unit_ctx	uctx;
f46039
};
f46039
39a81c
static inline struct sfrt_driver_ctx_impl * sfrt_get_driver_ictx(
39a81c
	const struct sfrt_driver_ctx * dctx)
39a81c
{
39a81c
        uintptr_t addr;
39a81c
39a81c
        if (dctx) {
39a81c
                addr = (uintptr_t)dctx - offsetof(struct sfrt_driver_ctx_impl,ctx);
39a81c
                return (struct sfrt_driver_ctx_impl *)addr;
39a81c
        }
39a81c
39a81c
        return 0;
39a81c
}
39a81c
7a168e
static inline void sfrt_driver_set_ectx(
7a168e
	const struct sfrt_driver_ctx * dctx,
7a168e
	const struct sfrt_unit_ctx *   uctx,
7a168e
	const char *                   unit)
7a168e
{
7a168e
	struct sfrt_driver_ctx_impl *  ictx;
7a168e
7a168e
	ictx        = sfrt_get_driver_ictx(dctx);
7a168e
	ictx->euctx = uctx;
7a168e
	ictx->eunit = unit;
7a168e
}
7a168e
d4f88d
static inline int sfrt_driver_fdin(const struct sfrt_driver_ctx * dctx)
d4f88d
{
d4f88d
	struct sfrt_fd_ctx fdctx;
d4f88d
	sfrt_get_driver_fdctx(dctx,&fdctx);
d4f88d
	return fdctx.fdin;
d4f88d
}
d4f88d
d4f88d
static inline int sfrt_driver_fdout(const struct sfrt_driver_ctx * dctx)
d4f88d
{
d4f88d
	struct sfrt_fd_ctx fdctx;
d4f88d
	sfrt_get_driver_fdctx(dctx,&fdctx);
d4f88d
	return fdctx.fdout;
d4f88d
}
d4f88d
d4f88d
static inline int sfrt_driver_fderr(const struct sfrt_driver_ctx * dctx)
d4f88d
{
d4f88d
	struct sfrt_fd_ctx fdctx;
d4f88d
	sfrt_get_driver_fdctx(dctx,&fdctx);
d4f88d
	return fdctx.fderr;
d4f88d
}
d4f88d
d4f88d
static inline int sfrt_driver_fdlog(const struct sfrt_driver_ctx * dctx)
d4f88d
{
d4f88d
	struct sfrt_fd_ctx fdctx;
d4f88d
	sfrt_get_driver_fdctx(dctx,&fdctx);
d4f88d
	return fdctx.fdlog;
d4f88d
}
d4f88d
d4f88d
static inline int sfrt_driver_fdcwd(const struct sfrt_driver_ctx * dctx)
d4f88d
{
d4f88d
	struct sfrt_fd_ctx fdctx;
d4f88d
	sfrt_get_driver_fdctx(dctx,&fdctx);
d4f88d
	return fdctx.fdcwd;
d4f88d
}
d4f88d
d4f88d
static inline int sfrt_driver_fddst(const struct sfrt_driver_ctx * dctx)
d4f88d
{
d4f88d
	struct sfrt_fd_ctx fdctx;
d4f88d
	sfrt_get_driver_fdctx(dctx,&fdctx);
d4f88d
	return fdctx.fddst;
d4f88d
}
d4f88d
f46039
#endif