19b50d902SRodney W. Grimes /* 2389844c0SBaptiste Daroussin * SPDX-License-Identifier: BSD-3-Clause 3df57947fSPedro F. Giffuni * 4139764e8SWolfram Schneider * Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. 59b50d902SRodney W. Grimes * Copyright (c) 1989, 1993 69b50d902SRodney W. Grimes * The Regents of the University of California. All rights reserved. 79b50d902SRodney W. Grimes * 89b50d902SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 99b50d902SRodney W. Grimes * modification, are permitted provided that the following conditions 109b50d902SRodney W. Grimes * are met: 119b50d902SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 129b50d902SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 139b50d902SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 149b50d902SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 159b50d902SRodney W. Grimes * documentation and/or other materials provided with the distribution. 16389844c0SBaptiste Daroussin * 3. Neither the name of the University nor the names of its contributors 179b50d902SRodney W. Grimes * may be used to endorse or promote products derived from this software 189b50d902SRodney W. Grimes * without specific prior written permission. 199b50d902SRodney W. Grimes * 209b50d902SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 219b50d902SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 229b50d902SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 239b50d902SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 249b50d902SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 259b50d902SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 269b50d902SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 279b50d902SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 289b50d902SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 299b50d902SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 309b50d902SRodney W. Grimes * SUCH DAMAGE. 319b50d902SRodney W. Grimes */ 329b50d902SRodney W. Grimes 339b50d902SRodney W. Grimes /* Symbolic constants shared by locate.c and code.c */ 349b50d902SRodney W. Grimes 359b50d902SRodney W. Grimes #define NBG 128 /* number of bigrams considered */ 369b50d902SRodney W. Grimes #define OFFSET 14 /* abs value of max likely diff */ 379b50d902SRodney W. Grimes #define PARITY 0200 /* parity bit */ 389b50d902SRodney W. Grimes #define SWITCH 30 /* switch code */ 39139764e8SWolfram Schneider #define UMLAUT 31 /* an 8 bit char followed */ 4037002181SWolfram Schneider 4137002181SWolfram Schneider /* 0-28 likeliest differential counts + offset to make nonnegative */ 4237002181SWolfram Schneider #define LDC_MIN 0 4337002181SWolfram Schneider #define LDC_MAX 28 4437002181SWolfram Schneider 4537002181SWolfram Schneider /* 128-255 bigram codes (128 most common, as determined by 'updatedb') */ 46b396ac3dSNathan Whitehorn #define BIGRAM_MIN (UCHAR_MAX - SCHAR_MAX) 4737002181SWolfram Schneider #define BIGRAM_MAX UCHAR_MAX 4837002181SWolfram Schneider 4937002181SWolfram Schneider /* 32-127 single character (printable) ascii residue (ie, literal) */ 5037002181SWolfram Schneider #define ASCII_MIN 32 51b396ac3dSNathan Whitehorn #define ASCII_MAX SCHAR_MAX 5237002181SWolfram Schneider 53b396ac3dSNathan Whitehorn /* #define TO7BIT(x) (x = ( ((u_char)x) & SCHAR_MAX )) */ 54b396ac3dSNathan Whitehorn #define TO7BIT(x) (x = x & SCHAR_MAX ) 5537002181SWolfram Schneider 5637002181SWolfram Schneider 5737002181SWolfram Schneider #if UCHAR_MAX >= 4096 5837002181SWolfram Schneider define TOLOWER(ch) tolower(ch) 5937002181SWolfram Schneider #else 6037002181SWolfram Schneider 618dddde9eSKyle Evans extern u_char myctype[UCHAR_MAX + 1]; 6237002181SWolfram Schneider #define TOLOWER(ch) (myctype[ch]) 6337002181SWolfram Schneider #endif 6437002181SWolfram Schneider 6537002181SWolfram Schneider #define INTSIZE (sizeof(int)) 66b72acdbdSWolfram Schneider 67b72acdbdSWolfram Schneider #define LOCATE_REG "*?[]\\" /* fnmatch(3) meta characters */ 68*834a8fa1SWolfram Schneider 69*834a8fa1SWolfram Schneider /* max. path length for locate. Should be at least 1024 (PATH_MAX), but can be longer */ 70*834a8fa1SWolfram Schneider #ifndef LOCATE_PATH_MAX 71*834a8fa1SWolfram Schneider #define LOCATE_PATH_MAX (1*1024) 72*834a8fa1SWolfram Schneider #endif 73*834a8fa1SWolfram Schneider 74