home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / xp_reg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.0 KB  |  106 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*
  20.  * shexp.h: Defines and prototypes for shell exp. match routines
  21.  * 
  22.  *
  23.  * This routine will match a string with a shell expression. The expressions
  24.  * accepted are based loosely on the expressions accepted by zsh.
  25.  * 
  26.  * o * matches anything
  27.  * o ? matches one character
  28.  * o \ will escape a special character
  29.  * o $ matches the end of the string
  30.  * o [abc] matches one occurence of a, b, or c. The only character that needs
  31.  *         to be escaped in this is ], all others are not special.
  32.  * o [a-z] matches any character between a and z
  33.  * o [^az] matches any character except a or z
  34.  * o ~ followed by another shell expression will remove any pattern
  35.  *     matching the shell expression from the match list
  36.  * o (foo|bar) will match either the substring foo, or the substring bar.
  37.  *             These can be shell expressions as well.
  38.  * 
  39.  * The public interface to these routines is documented below.
  40.  * 
  41.  * Rob McCool
  42.  * 
  43.  */
  44.  
  45. #ifndef SHEXP_H
  46. #define SHEXP_H
  47.  
  48. #include "xp_core.h"
  49.  
  50. /*
  51.  * Requires that the macro MALLOC be set to a "safe" malloc that will 
  52.  * exit if no memory is available. If not under MCC httpd, define MALLOC
  53.  * to be the real malloc and play with fire, or make your own function.
  54.  */
  55.  
  56. #if 0
  57. #ifdef MCC_HTTPD
  58. #include "../mc-httpd.h"
  59. #endif
  60. #endif
  61.  
  62. #include <ctype.h>  /* isalnum */
  63. #include <string.h> /* strlen */
  64.  
  65.  
  66.  
  67. /* --------------------------- Public routines ---------------------------- */
  68.  
  69.  
  70. /*
  71.  * shexp_valid takes a shell expression exp as input. It returns:
  72.  * 
  73.  *  NON_SXP      if exp is a standard string
  74.  *  INVALID_SXP  if exp is a shell expression, but invalid
  75.  *  VALID_SXP    if exp is a valid shell expression
  76.  */
  77.  
  78. #define NON_SXP -1
  79. #define INVALID_SXP -2
  80. #define VALID_SXP 1
  81.  
  82. extern int XP_RegExpValid(char *exp);
  83.  
  84. /*
  85.  * shexp_match 
  86.  * 
  87.  * Takes a prevalidated shell expression exp, and a string str.
  88.  *
  89.  * Returns 0 on match and 1 on non-match.
  90.  */
  91. extern int XP_RegExpMatch(char *str, char *exp, Bool case_insensitive);
  92.  
  93. /*
  94.  * 
  95.  * Same as above, but validates the exp first. 0 on match, 1 on non-match,
  96.  * -1 on invalid exp.
  97.  */
  98.  
  99. extern int XP_RegExpSearch(char *str, char *exp);
  100.  
  101. /* same as above but uses case insensitive search
  102.  */
  103. extern int XP_RegExpCaseSearch(char *str, char *exp);
  104.  
  105. #endif
  106.