1270096Strasz/*-
2270096Strasz * Copyright (c) 2014 The FreeBSD Foundation
3270096Strasz * All rights reserved.
4270096Strasz *
5270096Strasz * This software was developed by Edward Tomasz Napierala under sponsorship
6270096Strasz * from the FreeBSD Foundation.
7270096Strasz *
8270096Strasz * Redistribution and use in source and binary forms, with or without
9270096Strasz * modification, are permitted provided that the following conditions
10270096Strasz * are met:
11270096Strasz * 1. Redistributions of source code must retain the above copyright
12270096Strasz *    notice, this list of conditions and the following disclaimer.
13270096Strasz * 2. Redistributions in binary form must reproduce the above copyright
14270096Strasz *    notice, this list of conditions and the following disclaimer in the
15270096Strasz *    documentation and/or other materials provided with the distribution.
16270096Strasz *
17270096Strasz * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18270096Strasz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19270096Strasz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20270096Strasz * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21270096Strasz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22270096Strasz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23270096Strasz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24270096Strasz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25270096Strasz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26270096Strasz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27270096Strasz * SUCH DAMAGE.
28270096Strasz *
29270096Strasz * $FreeBSD: releng/10.3/usr.sbin/autofs/common.h 283239 2015-05-21 13:37:48Z trasz $
30270096Strasz */
31270096Strasz
32270096Strasz#ifndef AUTOMOUNTD_H
33270096Strasz#define	AUTOMOUNTD_H
34270096Strasz
35270096Strasz#include <sys/queue.h>
36270096Strasz#include <stdbool.h>
37270096Strasz
38270096Strasz#define	AUTO_MASTER_PATH	"/etc/auto_master"
39270096Strasz#define	AUTO_MAP_PREFIX		"/etc"
40270096Strasz#define	AUTO_SPECIAL_PREFIX	"/etc/autofs"
41270096Strasz#define	AUTO_INCLUDE_PATH	AUTO_SPECIAL_PREFIX "/include"
42270096Strasz
43270096Straszstruct node {
44270096Strasz	TAILQ_ENTRY(node)	n_next;
45270096Strasz	TAILQ_HEAD(nodehead, node)	n_children;
46270096Strasz	struct node		*n_parent;
47270096Strasz	char			*n_key;
48270096Strasz	char			*n_options;
49270096Strasz	char			*n_location;
50270096Strasz	char			*n_map;
51270096Strasz	const char		*n_config_file;
52270096Strasz	int			n_config_line;
53270096Strasz};
54270096Strasz
55270096Straszstruct defined_value {
56270096Strasz	TAILQ_ENTRY(defined_value)	d_next;
57270096Strasz	char				*d_name;
58270096Strasz	char				*d_value;
59270096Strasz};
60270096Strasz
61270096Straszvoid	log_init(int level);
62270096Straszvoid	log_set_peer_name(const char *name);
63270096Straszvoid	log_set_peer_addr(const char *addr);
64270096Straszvoid	log_err(int, const char *, ...)
65270096Strasz	    __dead2 __printf0like(2, 3);
66270096Straszvoid	log_errx(int, const char *, ...)
67270096Strasz	    __dead2 __printf0like(2, 3);
68270096Straszvoid	log_warn(const char *, ...) __printf0like(1, 2);
69270096Straszvoid	log_warnx(const char *, ...) __printflike(1, 2);
70270096Straszvoid	log_debugx(const char *, ...) __printf0like(1, 2);
71270096Strasz
72270096Straszchar	*checked_strdup(const char *);
73283231Straszchar	*concat(const char *s1, char separator, const char *s2);
74270096Straszvoid	create_directory(const char *path);
75270096Strasz
76270096Straszstruct node	*node_new_root(void);
77270096Straszstruct node	*node_new(struct node *parent, char *key, char *options,
78270096Strasz		    char *location, const char *config_file, int config_line);
79270096Straszstruct node	*node_new_map(struct node *parent, char *key, char *options,
80270096Strasz		    char *map, const char *config_file, int config_line);
81270096Straszstruct node	*node_find(struct node *root, const char *mountpoint);
82270096Straszbool		node_is_direct_map(const struct node *n);
83279741Straszbool		node_has_wildcards(const struct node *n);
84270096Straszchar	*node_path(const struct node *n);
85270096Straszchar	*node_options(const struct node *n);
86270096Straszvoid	node_expand_ampersand(struct node *root, const char *key);
87270096Straszvoid	node_expand_wildcard(struct node *root, const char *key);
88270096Straszint	node_expand_defined(struct node *root);
89270096Straszvoid	node_expand_indirect_maps(struct node *n);
90283239Straszvoid	node_print(const struct node *n, const char *cmdline_options);
91270096Straszvoid	parse_master(struct node *root, const char *path);
92279741Straszvoid	parse_map(struct node *parent, const char *map, const char *args,
93279741Strasz	    bool *wildcards);
94270096Straszchar	*defined_expand(const char *string);
95270096Straszvoid	defined_init(void);
96270096Straszvoid	defined_parse_and_add(char *def);
97270096Straszvoid	lesser_daemon(void);
98270096Strasz
99270096Straszint	main_automount(int argc, char **argv);
100270096Straszint	main_automountd(int argc, char **argv);
101270096Straszint	main_autounmountd(int argc, char **argv);
102270096Strasz
103270096StraszFILE	*auto_popen(const char *argv0, ...);
104270096Straszint	auto_pclose(FILE *iop);
105270096Strasz
106270096Strasz/*
107270096Strasz * lex(1) stuff.
108270096Strasz */
109270096Straszextern int lineno;
110270096Strasz
111270096Strasz#define	STR	1
112270096Strasz#define	NEWLINE	2
113270096Strasz
114270096Strasz#endif /* !AUTOMOUNTD_H */
115