home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 534.lha / sregexp.library_v11.1 / utils / try.c < prev   
C/C++ Source or Header  |  1991-08-08  |  2KB  |  102 lines

  1.  
  2. #include "sregexpbase.h"
  3. #include "sregexp_protos.h"
  4. #include <libraries/dos.h>
  5. #include <clib/exec_protos.h>
  6. #include <clib/dos_protos.h>
  7. #include <string.h>
  8. #include <assert.h>
  9. #include <stdlib.h>
  10.  
  11. struct SregExpBase *SregExpBase;
  12.  
  13. void
  14. puts(c)
  15. char *c;
  16. {
  17. chkabort();
  18.     Write(Output(),c,strlen(c));
  19.     Write(Output(),"\n",1);
  20. }
  21.  
  22. #include <stdarg.h>
  23.  
  24. extern void vsprintf(char *, char *, va_list);
  25.  
  26. void printf(f, ...)
  27. char *f;
  28. {
  29.     char buff[100];
  30.     va_list va;
  31.  
  32. chkabort();
  33.     va_start(va,f);
  34.     vsprintf(buff,f,va);
  35.     va_end(va);
  36.     Write(Output(),buff,strlen(buff));
  37. }
  38.  
  39. int
  40. brk()
  41. {  /* Don't worry about lost memory for now... */
  42.  
  43. Write(Output(),"BREAK\n",6);
  44.     CloseLibrary(SregExpBase);
  45.     return 1;
  46.  
  47. }
  48.  
  49. int
  50. main(ac,av)
  51. int ac;
  52. char *av;
  53. {
  54.     struct SregExp *pat;
  55.     struct SpathInfo *spi;
  56.     char buff[300],fb[110];
  57.     BPTR    lock;
  58.  
  59.     if (!(SregExpBase = OpenLibrary("sregexp.library",0))) {
  60.     puts("Unable to open library.");
  61.     return 5;
  62.     }
  63.     onbreak(brk);
  64.  
  65.     pat = ParseSregExp("sys:docs/#?/&(#?)");
  66.     if (!pat) {
  67.     printf("%d\n",IoErr());
  68.     CloseLibrary(SregExpBase);
  69.     exit(1);
  70.     }
  71.  
  72.     if (MatchSregExp("hello dog",pat,1))
  73.     puts("right");
  74.     else
  75.     puts("wrong");
  76.  
  77.     if (MatchSregExp("hello Dog",pat,1))
  78.     puts("right");
  79.     else
  80.     puts("wrong");
  81.  
  82.     if (MatchSregExp("hello Dog",pat,0))
  83.     puts("right");
  84.     else
  85.     puts("wrong");
  86.  
  87.     if (MatchSregExp("hello cat",pat,1))
  88.     puts("right");
  89.     else
  90.     puts("wrong");
  91.  
  92.     FreeSregExp(pat);
  93.  
  94.     if (!(spi = AnchorPath("","sys:docs/#?/&(.doc|.txt|"))) {
  95.     printf("%d\n",IoErr());
  96.     CloseLibrary(SregExpBase);
  97.     exit(1);
  98.     }
  99.  
  100.     FreeSpathInfo(spi);
  101. }
  102.