home *** CD-ROM | disk | FTP | other *** search
-
- #include "sregexpbase.h"
- #include "sregexp_protos.h"
- #include <libraries/dos.h>
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <string.h>
- #include <assert.h>
- #include <stdlib.h>
-
- struct SregExpBase *SregExpBase;
-
- void
- puts(c)
- char *c;
- {
- chkabort();
- Write(Output(),c,strlen(c));
- Write(Output(),"\n",1);
- }
-
- #include <stdarg.h>
-
- extern void vsprintf(char *, char *, va_list);
-
- void printf(f, ...)
- char *f;
- {
- char buff[100];
- va_list va;
-
- chkabort();
- va_start(va,f);
- vsprintf(buff,f,va);
- va_end(va);
- Write(Output(),buff,strlen(buff));
- }
-
- int
- brk()
- { /* Don't worry about lost memory for now... */
-
- Write(Output(),"BREAK\n",6);
- CloseLibrary(SregExpBase);
- return 1;
-
- }
-
- int
- main(ac,av)
- int ac;
- char *av;
- {
- struct SregExp *pat;
- struct SpathInfo *spi;
- char buff[300],fb[110];
- BPTR lock;
-
- if (!(SregExpBase = OpenLibrary("sregexp.library",0))) {
- puts("Unable to open library.");
- return 5;
- }
- onbreak(brk);
-
- pat = ParseSregExp("sys:docs/#?/&(#?)");
- if (!pat) {
- printf("%d\n",IoErr());
- CloseLibrary(SregExpBase);
- exit(1);
- }
-
- if (MatchSregExp("hello dog",pat,1))
- puts("right");
- else
- puts("wrong");
-
- if (MatchSregExp("hello Dog",pat,1))
- puts("right");
- else
- puts("wrong");
-
- if (MatchSregExp("hello Dog",pat,0))
- puts("right");
- else
- puts("wrong");
-
- if (MatchSregExp("hello cat",pat,1))
- puts("right");
- else
- puts("wrong");
-
- FreeSregExp(pat);
-
- if (!(spi = AnchorPath("","sys:docs/#?/&(.doc|.txt|"))) {
- printf("%d\n",IoErr());
- CloseLibrary(SregExpBase);
- exit(1);
- }
-
- FreeSpathInfo(spi);
- }
-