3 * $Id: mono.c,v 1.1 2003/09/15 02:48:54 mdw Exp $
5 * Monoalphabetic matcher
7 * (c) 2003 Mark Wooding
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Anag: a simple wordgame helper.
14 * Anag is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * Anag is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Anag; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.1 2003/09/15 02:48:54 mdw
33 * Monoalphabetic match filter.
37 /*----- Header files ------------------------------------------------------*/
41 /*----- Data structures ---------------------------------------------------*/
43 typedef struct node_mono {
49 /*----- Main code ---------------------------------------------------------*/
51 /* --- Matching --- */
53 static int n_mono(node *nn, const char *p, size_t sz)
55 node_mono *n = (node_mono *)nn;
56 unsigned map[UCHAR_MAX], imap[UCHAR_MAX];
57 const unsigned char *q = n->p;
62 memset(map, 0, sizeof(map));
63 memset(imap, 0, sizeof(imap));
72 } else if (map[i] != ch)
78 /* --- Node creation --- */
80 node *mono(const char *const *av)
82 unsigned char map[UCHAR_MAX];
88 node_mono *n = xmalloc(sizeof(*n));
90 memset(map, UCHAR_MAX, sizeof(map));
105 /*----- That's all, folks -------------------------------------------------*/