Atrinik Server 2.5
include/re-cmp.h
Go to the documentation of this file.
00001 /************************************************************************
00002 *            Atrinik, a Multiplayer Online Role Playing Game            *
00003 *                                                                       *
00004 *    Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team    *
00005 *                                                                       *
00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game)     *
00007 * and Crossfire (Multiplayer game for X-windows).                       *
00008 *                                                                       *
00009 * This program is free software; you can redistribute it and/or modify  *
00010 * it under the terms of the GNU General Public License as published by  *
00011 * the Free Software Foundation; either version 2 of the License, or     *
00012 * (at your option) any later version.                                   *
00013 *                                                                       *
00014 * This program is distributed in the hope that it will be useful,       *
00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00017 * GNU General Public License for more details.                          *
00018 *                                                                       *
00019 * You should have received a copy of the GNU General Public License     *
00020 * along with this program; if not, write to the Free Software           *
00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             *
00022 *                                                                       *
00023 * The author can be reached at admin@atrinik.org                        *
00024 ************************************************************************/
00025 
00032 /* Regexp's with syntax errors will core dump if
00033  * this is undefined. */
00034 #define SAFE_CHECKS
00035 
00036 /*
00037  * Max amount of tokens in a regexp.
00038  * Each token uses ~264 bytes. They are allocated
00039  * as needed, but never de-allocated.
00040  * E.g. [A-Za-z0-9_] counts as one token, so 64
00041  * should be plenty for most purposes. */
00042 #define RE_TOKEN_MAX 64
00043 
00044 typedef enum
00045 {
00046     /* corresponds to e.g. . */
00047     sel_any,
00048 
00049     /* "           $ */
00050     sel_end,
00051 
00052     /* "           q */
00053     sel_single,
00054 
00055     /* "           [A-F] */
00056     sel_range,
00057 
00058     /* "           [AF-RqO-T] */
00059     sel_array,
00060 
00061     /* "           [^f] */
00062     sel_not_single,
00063 
00064     /* "           [^A-F] */
00065     sel_not_range
00066 } selection_type;
00067 
00068 typedef enum
00069 {
00070     /* corresponds to no meta-char  */
00071     rep_once,
00072 
00073     /* "       + */
00074     rep_once_or_more,
00075 
00076     /* "       ? */
00077     rep_null_or_once,
00078 
00079     /* "       * */
00080     rep_null_or_more
00081 } repetetion_type;
00082 
00083 typedef struct
00084 {
00085     selection_type type;
00086 
00087     union
00088     {
00089         unsigned char single;
00090 
00091         struct
00092         {
00093             unsigned char low, high;
00094         } range;
00095 
00096         int array[UCHAR_MAX];
00097     } u;
00098 
00099     repetetion_type repeat;
00100 } selection;