home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / AppleScript / Additions / Wild 1.0.1 / project / C sources / match.h < prev    next >
Encoding:
Text File  |  1994-05-09  |  3.0 KB  |  85 lines  |  [TEXT/KAHL]

  1. //    match.h        matching functions for the wildcard AppleScript extension
  2. //
  3. //    93/11/19    File created
  4. //    94/01/24    *** released Wild 1.0.0 ***
  5. //    94/05/09    Totally removed the licensing mechanism and added the GNU comments
  6. //
  7. //--------------------------------------------------------------------------------------------------
  8. //  Copyright © 1993, 1994 by Rainbow Hill Pty Ltd.
  9. //
  10. //    This program is free software; you can redistribute it and/or modify it under the terms of
  11. //    the GNU General Public License as published by the Free Software Foundation; either version 2
  12. //    of the License, or any later version.
  13. //
  14. //    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  15. //    without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. //    See the GNU General Public License for more details.
  17. //
  18. //    You should have received a copy of the GNU General Public License along with this program;
  19. //    if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. //
  21. #pragma once
  22.  
  23. #include <Errors.h>
  24. #include "wild.h"
  25.  
  26.  
  27. //
  28. //    wildcarding
  29. //
  30. //    A single '?' is memorised as a wildcard with min = 1 and max = 1.
  31. //    A single '*' is memorised as a wildcard with min = 0 and max = WILD_maxFilenameLen.
  32. //    Consecutive wildcards are collapsed into a single wildcard entry.
  33. //    Such a combined entry might turn out to have a 'max' exceeding
  34. //    WILD_maxFilenameLen. This is considered to be irrelevant
  35. //
  36. //    Example: A????BC?*?D    k    offset    size    min        max
  37. //
  38. //             01             0       1
  39. //              1234          0              4
  40. //              1234          0                     4         4
  41. //
  42. //                  012       1       2
  43. //                    123     1              3
  44. //                    1 2     1                     2         > max filename size
  45. //                     *      1                             > max filename size
  46. //
  47. //    Note that 'size', as a counter, starts from 1; while 'offset' starts from 0.
  48. //
  49. struct match_wild_struct {
  50.     short    offset;        // distance from previous wildcard within string
  51.     short    size;        // number of wild characters
  52.     short    min;        // minimum number of characters in wildcard
  53.     short    max;        // maximum number of characters in wildcard
  54.     };
  55. typedef struct match_wild_struct match_wild_t;
  56.  
  57.  
  58. // match_criteria checks the type of the item (folder or file), the file creator, and the file type
  59. extern Boolean match_criteria(
  60.                             CInfoPBRec *,    // --> Cat Info Param block of the item
  61.                             wild_parm_t *    // --> flags and wildcarded strings
  62.                             );
  63.  
  64. extern Boolean match_OSType(
  65.                             OSType,            // --> OSType to be matched
  66.                             OSType,            // --> against this
  67.                             Boolean,        // --> do wildcarding
  68.                             char            // --> wildcard character
  69.                             );
  70.  
  71. // match_setWild returns the number of wildcards
  72. extern short match_setWild(
  73.                             char *,            // --> wildcarded filename
  74.                             wild_parm_t *,    // --> flags and wildcarded strings
  75.                             match_wild_t *    // <-- list of wildcards
  76.                             );
  77.  
  78. extern Boolean match_string(
  79.                             char *,            // --> string to be matched
  80.                             char *,            // --> wildcarded filename
  81.                             match_wild_t *,    // --> list of wildcards
  82.                             short,            // --> number of wildcards
  83.                             Boolean            // --> true: case sensitive
  84.                             );
  85.