1 | /*
|
---|
2 | * $Id$
|
---|
3 | *
|
---|
4 | * Test program for mr_stresc
|
---|
5 | * Can be used on host system with valgrind easier than with mondorestore
|
---|
6 | */
|
---|
7 | #include <stdio.h>
|
---|
8 | #include <stdlib.h>
|
---|
9 | #include "mr_str.h"
|
---|
10 | #include "mr_mem.h"
|
---|
11 | #include "my-stuff.h"
|
---|
12 |
|
---|
13 | /* Whether we should fail immediately at first error */
|
---|
14 | bool g_fail_immediately = FALSE;
|
---|
15 |
|
---|
16 | void (*mr_cleanup)(void) = NULL;
|
---|
17 |
|
---|
18 | char *strl[] = {
|
---|
19 | "test with space",
|
---|
20 | "test with \\ backslash",
|
---|
21 | "test with \" doublequote",
|
---|
22 | "test with ' simplequote",
|
---|
23 | "test with ~ tilde",
|
---|
24 | "test with ? questionmark",
|
---|
25 | "test with ! exclammark",
|
---|
26 | "test with & ampersand",
|
---|
27 | "test with * star",
|
---|
28 | "test with | pipe",
|
---|
29 | "test with \\' backslash quote",
|
---|
30 | "test with nothing SPECIAL 1234",
|
---|
31 | "test with rtmp:_ retrieval with rtmpdump and tcpdump « Pxnh's Blog_files",
|
---|
32 | NULL
|
---|
33 | };
|
---|
34 |
|
---|
35 | int main() {
|
---|
36 |
|
---|
37 | char *p;
|
---|
38 | int i;
|
---|
39 |
|
---|
40 | for (i = 1; strl[i] != NULL ; i++) {
|
---|
41 | printf("Test %2d Original chain is %s\n",i,strl[i]);
|
---|
42 | p = mr_stresc(strl[i], "`$\\\"(){}'[]&*?|!#~", '\\', '"');
|
---|
43 | printf("Test %2d Transformed chain (with \") is %s\n",i,p);
|
---|
44 | mr_free(p);
|
---|
45 | p = mr_stresc(strl[i], "`$\\\"(){}'[]&*?|!#~", '\\', '\'');
|
---|
46 | printf("Test %2d Transformed chain (with ') is %s\n",i,p);
|
---|
47 | mr_free(p);
|
---|
48 | }
|
---|
49 | exit(0);
|
---|
50 | }
|
---|