diff options
Diffstat (limited to 'src/shared/generator.h')
-rw-r--r-- | src/shared/generator.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/shared/generator.h b/src/shared/generator.h index f0a493b21e..5a1c1e32f7 100644 --- a/src/shared/generator.h +++ b/src/shared/generator.h @@ -3,6 +3,8 @@ #include <stdio.h> +#include "main-func.h" + int generator_open_unit_file( const char *dest, const char *source, @@ -47,3 +49,19 @@ int generator_hook_up_growfs( const char *dir, const char *where, const char *target); + +void log_setup_generator(void); + +/* Similar to DEFINE_MAIN_FUNCTION, but initializes logging and assigns positional arguments. */ +#define DEFINE_MAIN_GENERATOR_FUNCTION(impl) \ + _DEFINE_MAIN_FUNCTION( \ + ({ \ + log_setup_generator(); \ + if (argc > 1 && argc != 4) \ + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), \ + "This program takes zero or three arguments."); \ + }), \ + impl(argc > 1 ? argv[1] : "/tmp", \ + argc > 1 ? argv[2] : "/tmp", \ + argc > 1 ? argv[3] : "/tmp"), \ + r < 0 ? EXIT_FAILURE : EXIT_SUCCESS) |