<cmdsynopsis>
<command index='false'>/path/to/generator</command>
<arg choice="plain"><replaceable>normal-dir</replaceable></arg>
- <arg choice="plain"><replaceable>early-dir</replaceable></arg>
- <arg choice="plain"><replaceable>late-dir</replaceable></arg>
+ <arg choice="option"><replaceable>early-dir</replaceable></arg>
+ <arg choice="option"><replaceable>late-dir</replaceable></arg>
</cmdsynopsis>
<para>
that they can extend the unit file hierarchy the service manager subsequently loads and operates
on.</para>
- <para>Each generator is called with three directory paths that are to be used for generator output. In
- these three directories, generators may dynamically generate unit files (regular ones, instances, as well
- as templates), unit file <filename>.d/</filename> drop-ins, and create symbolic links to unit files to
- add additional dependencies, create aliases, or instantiate existing templates. Those directories are
- included in the unit load path of
- <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, allowing
- generated configuration to extend or override existing definitions.</para>
+ <para><command>systemd</command> will call each generator with three directory paths that are to be used
+ for generator output. In these three directories, generators may dynamically generate unit files (regular
+ ones, instances, as well as templates), unit file <filename>.d/</filename> drop-ins, and create symbolic
+ links to unit files to add additional dependencies, create aliases, or instantiate existing templates.
+ Those directories are included in the unit load path, allowing generated configuration to extend or
+ override existing definitions. For tests, generators may be called with just one argument; the generator
+ should assume that all three paths are the same in that case.</para>
<para>Directory paths for generator output differ by priority: <filename>…/generator.early</filename> has
priority higher than the admin configuration in <filename>/etc/</filename>, while
<para>Generators are invoked with three arguments: paths to directories where generators can place their
generated unit files or symlinks. By default those paths are runtime directories that are included in the
search path of <command>systemd</command>, but a generator may be called with different paths for
- debugging purposes.</para>
+ debugging purposes. If only one argument is provided, the generator should use the same directory as the
+ the three output paths.</para>
<orderedlist>
<listitem>
#include <stdio.h>
+#include "macro.h"
#include "main-func.h"
int generator_open_unit_file(
_DEFINE_MAIN_FUNCTION( \
({ \
log_setup_generator(); \
- if (argc > 1 && argc != 4) \
+ if (!IN_SET(argc, 2, 4)) \
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), \
- "This program takes zero or three arguments."); \
+ "This program takes one or three arguments."); \
}), \
- impl(argc > 1 ? argv[1] : "/tmp", \
- argc > 1 ? argv[2] : "/tmp", \
- argc > 1 ? argv[3] : "/tmp"), \
+ impl(argv[1], \
+ argv[argc == 4 ? 2 : 1], \
+ argv[argc == 4 ? 3 : 1]), \
r < 0 ? EXIT_FAILURE : EXIT_SUCCESS)