Annotation of libelwix/example/test_find2replace.c, revision 1.1.2.1
1.1.2.1 ! misho 1: #include <stdio.h>
! 2: #include <string.h>
! 3: #include <elwix.h>
! 4:
! 5:
! 6: int
! 7: main(int argc, char **argv)
! 8: {
! 9: int mlen, hm;
! 10: char *str;
! 11: const char *cs = "ABCDEF123GHIJ321KL123MNOP123QRST122UWV123XYZ";
! 12: const char *csb = "123ABCDEF123GHIJ321KL123MNOP123QRST122UWV123XYZ";
! 13: const char *cse = "ABCDEF123GHIJ321KL123MNOP123QRST122UWV123XYZ123";
! 14: const char *csn = "";
! 15: const char *cso = "AB";
! 16:
! 17: hm = str_find2replace(cs, "123", NULL, NULL, NULL);
! 18: printf("s&r howmany=%d only\n", hm);
! 19:
! 20: hm = str_find2replace(cs, "123", "*3245*", &str, &mlen);
! 21: printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, cs, mlen, str);
! 22: e_free(str);
! 23: hm = str_find2replace(csb, "123", "*3245*", &str, &mlen);
! 24: printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, csb, mlen, str);
! 25: e_free(str);
! 26: hm = str_find2replace(cse, "123", "*3245*", &str, &mlen);
! 27: printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, cse, mlen, str);
! 28: e_free(str);
! 29: hm = str_find2replace(csn, "123", "*3245*", &str, &mlen);
! 30: printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, csn, mlen, str);
! 31: e_free(str);
! 32: hm = str_find2replace(cso, "123", "*3245*", &str, &mlen);
! 33: printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, cso, mlen, str);
! 34: e_free(str);
! 35:
! 36: hm = str_find2replace(cs, "123", NULL, &str, &mlen);
! 37: printf("s&e howmany=%d origin=%s new(%d)=%s\n", hm, cs, mlen, str);
! 38: e_free(str);
! 39:
! 40: hm = str_find2replace(cs, "123", "*", &str, &mlen);
! 41: printf("s&r howmany=%d origin=%s new(%d)=%s\n", hm, cs, mlen, str);
! 42: e_free(str);
! 43: return 0;
! 44: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>