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);
- /*
- assert(pat = ParseSregExp("#?dog"));
-
- 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);
- */
- assert(pat = ParseSregExp("(Programs|Shell)"));
-
- if (!(spi = AnchorPath("","DCC:#?/dme.refs"))) {
- puts("Couldn't start search.");
- CloseLibrary(SregExpBase);
- return 10;
- }
- puts("Path anchored");
- while (NextFile(spi,buff,300,0) != SPE_ALL_DONE) {
- printf("----------> %s\n",buff);
- }
-
- FreeSpathInfo(spi);
-
- CloseLibrary(SregExpBase);
- }
-