File: actions.h

package info (click to toggle)
fsvs 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 2,964 kB
  • ctags: 1,464
  • sloc: ansic: 16,650; sh: 5,885; perl: 783; makefile: 338; python: 90
file content (150 lines) | stat: -rw-r--r-- 5,241 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/************************************************************************
 * Copyright (C) 2005-2009 Philipp Marek.
 *
 * This program is free software;  you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 ************************************************************************/

#ifndef __ACTION_H__
#define __ACTION_H__

#include "global.h" 


/** \file
 * Action handling header file. */

/** \anchor callbacks \name callbacks Action callbacks. */
/** @{ */
/** Callback that gets called for each entry.
 *
 * Entries get read from the entry list in global [device, inode] order; in 
 * the normal action callback (\ref actionlist_t::local_callback and \ref 
 * actionlist_t::repos_feedback) the parent entries are handled \b after child 
 * entries (but the parent \c struct \ref estat "estats" exist, of course), 
 * so that the list of children is correct.
 *
 *
 * See also \ref waa__update_tree.
 *
 * The full (wc-based) path can be built as required by \ref 
 * ops__build_path().*/
/* unused, wrong doc
 * As in the entry list file (\ref dir) there is a callback \ref 
 * actionlist_t::early_entry that's done \b before the child entries;
 * Clearing \ref estat::do_this_entry and \ref estat::do_tree in this 
 * callback will skip calling \ref actionlist_t::local_callback for this and 
 * the child entries (see \ref ops__set_to_handle_bits()). */
typedef int (action_t)(struct estat *sts);
/** Callback for initializing the action. */
typedef int (work_t)(struct estat *root, int argc, char *argv[]);
/** One after all progress has been made. */
typedef int (action_uninit_t)(void);
/** @} */

/** The action wrapper. */
action_t ac__dispatch;


/** The always allowed action - printing general or specific help. */
work_t ac__Usage;
/** For convenience: general help, and help for the current action. */
#define ac__Usage_dflt() do { ac__Usage(NULL, 0, NULL); } while (0)
/** Print help for the current action. */
#define ac__Usage_this() do { ac__Usage(NULL, 1, (char**)action->name); } while (0)


/** Definition of an \c action. */
struct actionlist_t
{
	/** Array of names this action will be called on the command line. */
	const char** name;

	/** The function doing the setup, tear down, and in-between - the 
	 * worker main function.
	 *
	 * See \ref callbacks. */
	work_t *work;

	/** The output function for repository accesses.
	 * Currently only used in cb__record_changes().
	 *
	 * See \ref callbacks. */
	action_t *repos_feedback;

	/** The local callback.
	 * Called for each entry, just after it's been checked for changes.
	 * Should give the user feedback about individual entries and what 
	 * happens with them.
	 *
	 * For directories this gets called when they're finished; so immediately 
	 * for empty directories, or after all children are loaded.
	 * \note A removed directory is taken as empty (as no more elements are 
	 * here) - this is used in \ref revert so that revert gets called twice 
	 * (once for restoring the directory itself, and again after its 
	 * populated). 
	 *
	 * See \ref callbacks. */
	action_t *local_callback;
	/** The progress reporter needs a callback to clear the line after printing
	 * the progress. */
	action_uninit_t *local_uninit;

	/** A pointer to the verbose help text. */
	char const *help_text;

	/** Flag for usage in the action handler itself. */
	int i_val;

	/** Is this an import or export, ie do we need a WAA?
	 * We don't cache properties, manber-hashes, etc., if is_import_export 
	 * is set. */
	int is_import_export:1;
	/** This is set if it's a compare operation (remote-status).
	 * The properties are parsed, but instead of writing them into the 
	 * \c struct \c estat they are compared, and \c entry_status set
	 * accordingly. */
	int is_compare:1;
	/** Whether we need fsvs:update-pipe cached. 
	 * Do we install files from the repository locally? Then we need to know 
	 * how to decode them.
	 * We don't do that in every case, to avoid wasting memory. */
	int needs_decoder:1;
	/** Whether the entries should be filtered on opt_filter. */
	int only_opt_filter:1;
	/** Whether user properties should be stored in estat::user_prop while 
	 * running cb__record_changes(). */
	int keep_user_prop:1;
	/** Makes ops__update_single_entry() keep the children of removed 
	 * directories. */
	int keep_children:1;
	/** Says that we want the \c estat::st overwritten while looking for 
	 * local changes.  */
	int overwrite_sts_st:1;
	/** Whether waa__update_dir() may happen.
	 * (It must not for updates, as we'd store local changes as "from 
	 * repository"). */
	int do_update_dir:1;
	/** Says that this is a read-only operation (like "status"). */
	int is_readonly:1;
};


/** Find the action structure by name.
 *
 * Returns in \c * \a action_p the action matching (a prefix of) \a cmd.
 * */
int act__find_action_by_name(const char *cmd, 
		struct actionlist_t **action_p);


/** Array of all known actions. */
extern struct actionlist_t action_list[];
/** Gets set to the \e current action after commandline parsing. */
extern struct actionlist_t *action;
/** How many actions we know. */
extern const int action_list_count;


#endif