131921Sbrian/*- 231921Sbrian * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org> 331921Sbrian * All rights reserved. 431921Sbrian * 531921Sbrian * Redistribution and use in source and binary forms, with or without 631921Sbrian * modification, are permitted provided that the following conditions 731921Sbrian * are met: 831921Sbrian * 1. Redistributions of source code must retain the above copyright 931921Sbrian * notice, this list of conditions and the following disclaimer. 1031921Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1131921Sbrian * notice, this list of conditions and the following disclaimer in the 1231921Sbrian * documentation and/or other materials provided with the distribution. 1331921Sbrian * 1431921Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1531921Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1631921Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1731921Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1831921Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1931921Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2031921Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2131921Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2231921Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2331921Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2431921Sbrian * SUCH DAMAGE. 2531921Sbrian * 2650479Speter * $FreeBSD$ 2730715Sbrian */ 2830715Sbrian 2936285Sbrianstruct bundle; 3026940Sbrian 3136285Sbrianstruct server { 3258028Sbrian struct fdescriptor desc; 3336285Sbrian int fd; 3436285Sbrian 3571657Sbrian struct { 3671657Sbrian char passwd[50]; 3736285Sbrian 3874001Sbrian char sockname[PATH_MAX]; /* Points to local socket path */ 3971657Sbrian mode_t mask; 4071657Sbrian 4171657Sbrian u_short port; /* tcp socket */ 4271657Sbrian } cfg; 4336285Sbrian}; 4436285Sbrian 4571657Sbrianenum server_stat { 4671657Sbrian SERVER_OK, /* Diagnostic socket available */ 4771657Sbrian SERVER_INVALID, /* Bad args, can't be set up */ 4871657Sbrian SERVER_FAILED, /* Failed - lack of resources */ 4971657Sbrian SERVER_UNSET /* Not already set up */ 5071657Sbrian}; 5171657Sbrian 5236285Sbrian#define descriptor2server(d) \ 5336285Sbrian ((d)->type == SERVER_DESCRIPTOR ? (struct server *)(d) : NULL) 5436285Sbrian 5536285Sbrianextern struct server server; 5636285Sbrian 5771657Sbrianextern enum server_stat server_LocalOpen(struct bundle *, const char *, mode_t); 5871657Sbrianextern enum server_stat server_TcpOpen(struct bundle *, u_short); 5971657Sbrianextern enum server_stat server_Reopen(struct bundle *); 6036285Sbrianextern int server_Close(struct bundle *); 6171657Sbrianextern int server_Clear(struct bundle *); 62