1 1.2 mrg /* $NetBSD: common.h,v 1.2 2019/02/03 12:03:22 mrg Exp $ */ 2 1.1 christos 3 1.1 christos /*- 4 1.1 christos * Copyright (c) 2017 The NetBSD Foundation, Inc. 5 1.1 christos * Copyright (c) 2016 The DragonFly Project 6 1.1 christos * Copyright (c) 2014 The FreeBSD Foundation 7 1.1 christos * All rights reserved. 8 1.1 christos * 9 1.1 christos * This code is derived from software contributed to The NetBSD Foundation 10 1.1 christos * by Tomohiro Kusumi <kusumi.tomohiro (at) gmail.com>. 11 1.1 christos * 12 1.1 christos * This software was developed by Edward Tomasz Napierala under sponsorship 13 1.1 christos * from the FreeBSD Foundation. 14 1.1 christos * 15 1.1 christos * Redistribution and use in source and binary forms, with or without 16 1.1 christos * modification, are permitted provided that the following conditions 17 1.1 christos * are met: 18 1.1 christos * 1. Redistributions of source code must retain the above copyright 19 1.1 christos * notice, this list of conditions and the following disclaimer. 20 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright 21 1.1 christos * notice, this list of conditions and the following disclaimer in the 22 1.1 christos * documentation and/or other materials provided with the distribution. 23 1.1 christos * 24 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 25 1.1 christos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 1.1 christos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 1.1 christos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 28 1.1 christos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 1.1 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 1.1 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 1.1 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 1.1 christos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 1.1 christos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 1.1 christos * SUCH DAMAGE. 35 1.1 christos * 36 1.1 christos * $FreeBSD$ 37 1.1 christos */ 38 1.1 christos 39 1.1 christos #ifndef AUTOMOUNTD_H 40 1.1 christos #define AUTOMOUNTD_H 41 1.1 christos 42 1.1 christos #include <sys/types.h> 43 1.1 christos #include <sys/queue.h> 44 1.1 christos #include <stdio.h> 45 1.1 christos #include <stdbool.h> 46 1.1 christos 47 1.1 christos #define AUTO_MASTER_PATH "/etc/auto_master" 48 1.1 christos #define AUTO_MAP_PREFIX "/etc" 49 1.1 christos #define AUTO_SPECIAL_PREFIX "/etc/autofs" 50 1.1 christos #define AUTO_INCLUDE_PATH AUTO_SPECIAL_PREFIX "/include" 51 1.1 christos 52 1.1 christos struct node { 53 1.1 christos TAILQ_ENTRY(node) n_next; 54 1.1 christos TAILQ_HEAD(nodehead, node) n_children; 55 1.1 christos struct node *n_parent; 56 1.1 christos char *n_key; 57 1.1 christos char *n_options; 58 1.1 christos char *n_location; 59 1.1 christos char *n_map; 60 1.1 christos const char *n_config_file; 61 1.1 christos int n_config_line; 62 1.1 christos }; 63 1.1 christos 64 1.1 christos struct defined_value { 65 1.1 christos TAILQ_ENTRY(defined_value) d_next; 66 1.1 christos char *d_name; 67 1.1 christos char *d_value; 68 1.1 christos }; 69 1.1 christos 70 1.1 christos void log_init(int); 71 1.1 christos void log_set_peer_name(const char *); 72 1.1 christos void log_set_peer_addr(const char *); 73 1.2 mrg void log_err(int, const char *, ...) __printflike(2, 3) __dead; 74 1.2 mrg void log_errx(int, const char *, ...) __printflike(2, 3) __dead; 75 1.1 christos void log_warn(const char *, ...) __printflike(1, 2); 76 1.1 christos void log_warnx(const char *, ...) __printflike(1, 2); 77 1.1 christos void log_debugx(const char *, ...) __printflike(1, 2); 78 1.1 christos 79 1.1 christos char *checked_strdup(const char *); 80 1.1 christos char *concat(const char *, char, const char *); 81 1.1 christos void create_directory(const char *); 82 1.1 christos 83 1.1 christos struct node *node_new_root(void); 84 1.1 christos struct node *node_new(struct node *, char *, char *, char *, const char *, 85 1.1 christos int); 86 1.1 christos struct node *node_new_map(struct node *, char *, char *, char *, 87 1.1 christos const char *, int); 88 1.1 christos struct node *node_find(struct node *, const char *mountpoint); 89 1.1 christos bool node_is_direct_map(const struct node *); 90 1.1 christos bool node_has_wildcards(const struct node *); 91 1.1 christos char *node_path(const struct node *); 92 1.1 christos char *node_options(const struct node *); 93 1.1 christos void node_expand_ampersand(struct node *, const char *); 94 1.1 christos void node_expand_wildcard(struct node *, const char *); 95 1.1 christos int node_expand_defined(struct node *); 96 1.1 christos void node_expand_indirect_maps(struct node *); 97 1.1 christos void node_print(const struct node *, const char *); 98 1.1 christos void parse_master(struct node *, const char *); 99 1.1 christos void parse_map(struct node *, const char *, const char *, bool *); 100 1.1 christos char *defined_expand(const char *); 101 1.1 christos void defined_init(void); 102 1.1 christos void defined_parse_and_add(char *); 103 1.1 christos void lesser_daemon(void); 104 1.1 christos 105 1.1 christos int main_automount(int, char **); 106 1.1 christos int main_automountd(int, char **); 107 1.1 christos int main_autounmountd(int, char **); 108 1.1 christos 109 1.1 christos FILE *auto_popen(const char *, ...); 110 1.1 christos int auto_pclose(FILE *); 111 1.1 christos 112 1.1 christos /* 113 1.1 christos * lex(1) stuff. 114 1.1 christos */ 115 1.1 christos extern int lineno; 116 1.1 christos 117 1.1 christos #define STR 1 118 1.1 christos #define NEWLINE 2 119 1.1 christos 120 1.1 christos #endif /* !AUTOMOUNTD_H */ 121