1*d8883177SAlan Somers /*- 2*d8883177SAlan Somers * SPDX-License-Identifier: BSD-2-Clause 3*d8883177SAlan Somers * 4*d8883177SAlan Somers * Copyright (c) 2025 ConnectWise 5*d8883177SAlan Somers * All rights reserved. 6*d8883177SAlan Somers * 7*d8883177SAlan Somers * Redistribution and use in source and binary forms, with or without 8*d8883177SAlan Somers * modification, are permitted provided that the following conditions 9*d8883177SAlan Somers * are met: 10*d8883177SAlan Somers * 1. Redistributions of source code must retain the above copyright 11*d8883177SAlan Somers * notice, this list of conditions and the following disclaimer 12*d8883177SAlan Somers * in this position and unchanged. 13*d8883177SAlan Somers * 2. Redistributions in binary form must reproduce the above copyright 14*d8883177SAlan Somers * notice, this list of conditions and the following disclaimer in the 15*d8883177SAlan Somers * documentation and/or other materials provided with the distribution. 16*d8883177SAlan Somers * 17*d8883177SAlan Somers * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18*d8883177SAlan Somers * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19*d8883177SAlan Somers * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20*d8883177SAlan Somers * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21*d8883177SAlan Somers * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22*d8883177SAlan Somers * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23*d8883177SAlan Somers * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24*d8883177SAlan Somers * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25*d8883177SAlan Somers * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26*d8883177SAlan Somers * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27*d8883177SAlan Somers */ 28*d8883177SAlan Somers 29*d8883177SAlan Somers #define INT_BIT (sizeof(int)*CHAR_BIT) 30*d8883177SAlan Somers #define SET_PORT(p) do { ports[p / INT_BIT] |= 1 << (p % INT_BIT); } while (0) 31*d8883177SAlan Somers #define CHK_PORT(p) (ports[p / INT_BIT] & (1 << (p % INT_BIT))) 32*d8883177SAlan Somers 33*d8883177SAlan Somers extern int *ports; 34*d8883177SAlan Somers 35*d8883177SAlan Somers int parse_ports(const char *portspec); 36