home *** CD-ROM | disk | FTP | other *** search
- TABLE OF CONTENTS
-
- regexp.library/--background--
- regexp.library/RegComp
- regexp.library/RegFree
- regexp.library/RegExec
-
- regexp.library/--background--
-
- /****************************************************************
- * regexp.library *
- * 1998 by M.Bethke *
- * V37.2 *
- ****************************************************************/
-
- regexp.library gives you the functionality of the NetBSD regexp
- package through the standard AmigaOS shared library API.
- Basically it works just like the dos.library pattern matching
- functions (ParsePattern() / MatchPattern()), excpet that instead
- of you providing your own buffer for the parsed expression the
- library allocates one for you which you have to free later. A
- typical call will look like this:
-
- BOOL MatchStrings(STRPTR pattern, STRPTR string)
- {
- regexp *re;
- LONG result=0;
-
- if(re = RegComp(pattern))
- {
- result = RegExec(re,string);
- if(result == -1)
- {
- LONG err = IoErr();
-
- Printf("Error matching pattern: %s\n",RegXlatError(err));
- }
- } else
- {
- LONG err = IoErr();
-
- Printf("Error compiling pattern: %s\n",RegXlatError(err));
- }
- return (BOOL)result;
- }
-
-
- regexp.library/RegComp
-
- NAME
- RegComp -- compile a regular expression to internal format
-
- SYNOPSIS
- handle = RegComp(Expression)
- D0 A0
-
- regexp *RegComp(STRPTR);
-
- FUNCTION
- RegComp compiles a regular expression to an internal format that the
- actual pattern matcher can understand. It's roughly the equivalent of
- dos.library/ParsePattern() for AmigaDOS patternmatching.
-
- INPUTS
- Expression = a pointer to the regular expression as a C string
-
- RESULT
- regexp handle as defines in libraries/regexp.h. The structure of this
- handle is defined in the same include file but should usually not be
- messed with.
-
- SEE ALSO
- RegFree()
-
- regexp.library/RegFree
-
- NAME
- RegFree -- free any storage allocated by RegComp().
-
- SYNOPSIS
- RegFree (Handle)
- A1
-
- void RegFree(regexp*);
-
- FUNCTION
- Frees any storage that RegComp() may have attached to the regexp
- handle it gave you. Basically, RegFree() does nothing more than a
- FreeVec() at the moment but it's there to complete the API and to
- allow future extensions.
-
- INPUTS
- Handle = a regexp handle as returned by RegComp()
-
- RESULT
- nothing
-
- SEE ALSO
- RegComp()
-
- regexp.library/RegExec
-
- NAME
- RegExec -- match a regular expression
-
- SYNOPSIS
- Success = RegExec (Handle,String)
- D0 A0 A1
-
- LONG RegExec(regexp*, STRPTR);
-
- FUNCTION
- This is the actual matching function. It takes a regexp handle and a
- stringpointer and tries to match the expression the handle was created
- from onto the string. A match is indicated by a return value of 1.
-
- INPUTS
- Handle = regexp handle as returned by RegComp()
- String = string to match the expression on
-
- RESULT
- 1 : Pattern matched string
- 0 : Pattern did not match
- -1 : Failure while matching. IoErr() will return an error number
- as defined in libraries/regexp.h in this case.
-
- SEE ALSO
- RegComp(), RegFree()
-
- regexp.library/RegXlatError
-
- NAME
- RegXlatError -- translate error code to string
-
- SYNOPSIS
- Text = RegXlatError(Error)
- D0 D0
-
- STRPTR RegXlatError(LONG);
-
- FUNCTION
- If a regexp.library function fails, IoErr() will return the reason for
- the failure in numeric form. RegXlatError() translates this into a
- human-readable form, i.e. the error messages given in libraries/regexp.h.
-
- INPUTS
- Error = numeric error code as returned by IoErr()
-
- RESULT
- Pointer to a descriptive string for that error code.
-
- SEE ALSO
-