home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 4 / MA_Cover_4.iso / libs / regexp / regexp.doc next >
Encoding:
Text File  |  1998-02-26  |  3.7 KB  |  153 lines

  1. TABLE OF CONTENTS
  2.  
  3. regexp.library/--background--
  4. regexp.library/RegComp
  5. regexp.library/RegFree
  6. regexp.library/RegExec
  7.  
  8. regexp.library/--background--
  9.  
  10.     /****************************************************************
  11.      *                    regexp.library                            *
  12.      *                   1998 by M.Bethke                           *
  13.      *                         V37.2                                *
  14.      ****************************************************************/
  15.  
  16.     regexp.library gives you the functionality of the NetBSD regexp
  17.     package through the standard AmigaOS shared library API.
  18.     Basically it works just like the dos.library pattern matching
  19.     functions (ParsePattern() / MatchPattern()), excpet that instead
  20.     of you providing your own buffer for the parsed expression the
  21.     library allocates one for you which you have to free later. A
  22.     typical call will look like this:
  23.  
  24.     BOOL MatchStrings(STRPTR pattern, STRPTR string)
  25.     {
  26.     regexp *re;
  27.     LONG result=0;
  28.  
  29.        if(re = RegComp(pattern))
  30.        {
  31.           result = RegExec(re,string);
  32.           if(result == -1)
  33.           {
  34.             LONG err = IoErr();
  35.  
  36.               Printf("Error matching pattern: %s\n",RegXlatError(err));
  37.           }
  38.        } else
  39.         {
  40.         LONG err = IoErr();
  41.  
  42.             Printf("Error compiling pattern: %s\n",RegXlatError(err));
  43.         }
  44.        return (BOOL)result;
  45.     }
  46.  
  47.  
  48. regexp.library/RegComp
  49.  
  50.     NAME
  51.     RegComp -- compile a regular expression to internal format
  52.  
  53.     SYNOPSIS
  54.     handle = RegComp(Expression)
  55.     D0         A0
  56.  
  57.     regexp *RegComp(STRPTR);
  58.  
  59.     FUNCTION
  60.     RegComp compiles a regular expression to an internal format that the
  61.     actual pattern matcher can understand. It's roughly the equivalent of
  62.     dos.library/ParsePattern() for AmigaDOS patternmatching.
  63.  
  64.     INPUTS
  65.     Expression = a pointer to the regular expression as a C string
  66.  
  67.     RESULT
  68.     regexp handle as defines in libraries/regexp.h. The structure of this
  69.     handle is defined in the same include file but should usually not be
  70.     messed with.
  71.  
  72.     SEE ALSO
  73.     RegFree()
  74.  
  75. regexp.library/RegFree
  76.  
  77.     NAME
  78.     RegFree -- free any storage allocated by RegComp().
  79.  
  80.     SYNOPSIS
  81.     RegFree (Handle)
  82.          A1
  83.  
  84.     void RegFree(regexp*);
  85.  
  86.     FUNCTION
  87.     Frees any storage that RegComp() may have attached to the regexp
  88.     handle it gave you. Basically, RegFree() does nothing more than a
  89.     FreeVec() at the moment but it's there to complete the API and to
  90.     allow future extensions.
  91.  
  92.     INPUTS
  93.     Handle    = a regexp handle as returned by RegComp()
  94.  
  95.     RESULT
  96.     nothing
  97.  
  98.     SEE ALSO
  99.     RegComp()
  100.  
  101. regexp.library/RegExec
  102.  
  103.     NAME
  104.     RegExec -- match a regular expression
  105.  
  106.     SYNOPSIS
  107.     Success = RegExec (Handle,String)
  108.     D0                 A0     A1
  109.  
  110.     LONG RegExec(regexp*, STRPTR);
  111.  
  112.     FUNCTION
  113.     This is the actual matching function. It takes a regexp handle and a
  114.     stringpointer and tries to match the expression the handle was created
  115.     from onto the string. A match is indicated by a return value of 1.
  116.  
  117.     INPUTS
  118.     Handle  = regexp handle as returned by RegComp()
  119.     String  = string to match the expression on
  120.  
  121.     RESULT
  122.      1 : Pattern matched string
  123.      0 : Pattern did not match
  124.     -1 : Failure while matching. IoErr() will return an error number
  125.           as defined in libraries/regexp.h in this case.
  126.  
  127.     SEE ALSO
  128.     RegComp(), RegFree()
  129.  
  130. regexp.library/RegXlatError
  131.  
  132.     NAME
  133.     RegXlatError -- translate error code to string
  134.  
  135.     SYNOPSIS
  136.     Text = RegXlatError(Error)
  137.     D0                  D0
  138.  
  139.     STRPTR RegXlatError(LONG);
  140.  
  141.     FUNCTION
  142.     If a regexp.library function fails, IoErr() will return the reason for
  143.     the failure in numeric form. RegXlatError() translates this into a
  144.     human-readable form, i.e. the error messages given in libraries/regexp.h.
  145.  
  146.     INPUTS
  147.     Error = numeric error code as returned by IoErr()
  148.  
  149.     RESULT
  150.     Pointer to a descriptive string for that error code.
  151.  
  152.     SEE ALSO
  153.