]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/edit-util.h
systemctl: add "edit --stdin"
[thirdparty/systemd.git] / src / shared / edit-util.h
CommitLineData
a01c4bc9
MY
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2#pragma once
3
78e32003 4#include <stdbool.h>
a01c4bc9 5
6e5d0e31
MY
6#define DROPIN_MARKER_START "### Anything between here and the comment below will become the contents of the drop-in file"
7#define DROPIN_MARKER_END "### Edits below this comment will be discarded"
8
043db340
YW
9typedef struct EditFile EditFile;
10typedef struct EditFileContext EditFileContext;
11
12struct EditFile {
13 EditFileContext *context;
a01c4bc9 14 char *path;
9a11b4f9
MY
15 char *original_path;
16 char **comment_paths;
17 char *temp;
a01c4bc9 18 unsigned line;
043db340 19};
a01c4bc9 20
043db340 21struct EditFileContext {
9a11b4f9
MY
22 EditFile *files;
23 size_t n_files;
24 const char *marker_start;
25 const char *marker_end;
26 bool remove_parent;
329050c5
ZJS
27 bool overwrite_with_origin; /* Always overwrite target with original file. */
28 bool stdin; /* Read contents from stdin instead of launching an editor. */
043db340 29};
a01c4bc9 30
9a11b4f9
MY
31void edit_file_context_done(EditFileContext *context);
32
33bool edit_files_contains(const EditFileContext *context, const char *path);
a01c4bc9 34
9a11b4f9
MY
35int edit_files_add(
36 EditFileContext *context,
37 const char *path,
38 const char *original_path,
39 char * const *comment_paths);
a01c4bc9 40
9a11b4f9 41int do_edit_files_and_install(EditFileContext *context);