summaryrefslogtreecommitdiff
blob: d6662c6cd044dd18bc90683bbbd70673446b72fc (plain)
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
/*
 * depend.h
 *
 * Dependancy engine for Gentoo style rc-scripts.
 *
 * Copyright (C) 2004,2005 Martin Schlemmer <azarah@nosferatu.za.org>
 *
 *
 *      This program is free software; you can redistribute it and/or modify it
 *      under the terms of the GNU General Public License as published by the
 *      Free Software Foundation version 2 of the License.
 *
 *      This program is distributed in the hope that it will be useful, but
 *      WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *      General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License along
 *      with this program; if not, write to the Free Software Foundation, Inc.,
 *      675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Header$
 */

#ifndef __DEPEND_H__
#define __DEPEND_H__

/* Dependency types supported or still to be implemented */
typedef enum
{
  NEED,				/* All dependencies needed by specified service */
  NEED_ME,			/* All dependencies that need specified service */
  USE,				/* All dependencies used by specified service */
  USE_ME,			/* All dependencies that use specified service */
  BEFORE,			/* All services started before specified service */
  AFTER,			/* All services started after specified service */
  BROKEN,			/* All dependencies of type NEED missing for
				   specified service */
  PROVIDE,			/* All virtual services provided by specified service */
  ALL_SERVICE_TYPE_T
} service_type_t;

/* Names for above service types (service_type_t).
 * Note that this should sync with above service_type_t */
extern char *service_type_names[];

typedef struct
{
  struct list_head node;

  char *name;			/* Name of service */
  char **depend_info[ALL_SERVICE_TYPE_T];	/* String lists for each service
						   type */
  char *provide;		/* Name of virtual service it
				   provides.  This is only valid
				   after we resolving - thus after
				   service_resolve_dependencies() */
  time_t mtime;			/* Modification time of script */
} service_info_t;

struct list_head service_info_list;

service_info_t *service_get_info (char *servicename);
int service_add (char *servicename);
int service_is_dependency (char *servicename, char *dependency,
			   service_type_t type);
int service_add_dependency (char *servicename, char *dependency,
			    service_type_t type);
int service_del_dependency (char *servicename, char *dependency,
			    service_type_t type);
service_info_t *service_get_virtual (char *virtual);
int service_add_virtual (char *servicename, char *virtual);
int service_set_mtime (char *servicename, time_t mtime);
int service_resolve_dependencies (void);

#endif /* __DEPEND_H__ */