12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #ifndef MAIN_H
- #define MAIN_H
- #include <tss2/tss2_esys.h>
- #include <stdbool.h>
- #include "tool_rc.h"
- #include "tpm2_options.h"
- #include "tpm2_tool_output.h"
- typedef bool (*tpm2_tool_onstart_t)(tpm2_options **opts);
- typedef tool_rc (*tpm2_tool_onrun_t)(ESYS_CONTEXT *ectx, tpm2_option_flags flags);
- typedef tool_rc (*tpm2_tool_onstop_t)(ESYS_CONTEXT *ectx);
- typedef void (*tpm2_tool_onexit_t)(void);
- typedef struct {
- const char * name;
- tpm2_tool_onstart_t onstart;
- tpm2_tool_onrun_t onrun;
- tpm2_tool_onstop_t onstop;
- tpm2_tool_onexit_t onexit;
- } tpm2_tool;
- void tpm2_tool_register(const tpm2_tool * tool);
- #define TPM2_TOOL_REGISTER(tool_name,tool_onstart,tool_onrun,tool_onstop,tool_onexit) \
- static const tpm2_tool tool = { \
- .name = tool_name, \
- .onstart = tool_onstart, \
- .onrun = tool_onrun, \
- .onstop = tool_onstop, \
- .onexit = tool_onexit, \
- }; \
- static void \
- __attribute__((__constructor__)) \
- __attribute__((__used__)) \
- _tpm2_tool_init(void) \
- { \
- tpm2_tool_register(&tool); \
- }
- #endif
|