init: Create classes for Action and Command
This creates the concept of 'event_trigger' vs 'property_trigger'
Previously these were merged into one, such that 'on property:a=b &&
property:b=c' is triggered when properties a=b and b=c as expected,
however combinations such as 'on early-boot && boot' would trigger
during both early-boot and boot. Similarly, 'on early-boot &&
property:a=b' would trigger on both early-boot and again when property
a equals b.
The event trigger distinction ensures that the first example fails to
parse and the second example only triggers on early-boot if
property a equals b.
This coalesces Actions with the same triggers into a single Action object
Change-Id: I8f661d96e8a2d40236f252301bfe10979d663ea6
diff --git a/init/init.h b/init/init.h
index d2b2dfb..4d23103 100644
--- a/init/init.h
+++ b/init/init.h
@@ -18,47 +18,17 @@
#define _INIT_INIT_H
#include <sys/types.h>
+#include <stdlib.h>
+#include <list>
+#include <map>
#include <string>
#include <vector>
#include <cutils/list.h>
#include <cutils/iosched_policy.h>
-struct command
-{
- /* list of commands in an action */
- struct listnode clist;
-
- int (*func)(int nargs, char **args);
-
- int line;
- const char *filename;
-
- int nargs;
- char *args[1];
-};
-
-struct trigger {
- struct listnode nlist;
- const char *name;
-};
-
-struct action {
- /* node in list of all actions */
- struct listnode alist;
- /* node in the queue of pending actions */
- struct listnode qlist;
- /* node in list of actions for a trigger */
- struct listnode tlist;
-
- unsigned hash;
-
- /* list of actions which triggers the commands*/
- struct listnode triggers;
- struct listnode commands;
- struct command *current;
-};
+class Action;
struct socketinfo {
struct socketinfo *next;
@@ -117,7 +87,7 @@
struct socketinfo *sockets;
struct svcenvinfo *envvars;
- struct action onrestart; /* Actions to execute on restart. */
+ Action* onrestart; /* Commands to execute on restart. */
std::vector<std::string>* writepid_files_;
@@ -138,8 +108,6 @@
extern struct selabel_handle *sehandle;
extern struct selabel_handle *sehandle_prop;
-std::string build_triggers_string(struct action *cur_action);
-
void handle_control_message(const char *msg, const char *arg);
struct service *service_find_by_name(const char *name);
@@ -161,6 +129,5 @@
void zap_stdio(void);
void register_epoll_handler(int fd, void (*fn)());
-bool expand_command_arguments(int nargs, char** args, std::vector<std::string>* expanded_args);
-#endif /* _INIT_INIT_H */
+#endif /* _INIT_INIT_H */