[3111] | 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>
|
---|
[3116] | 8 | #include <stdlib.h>
|
---|
[3111] | 9 | #include "mr_str.h"
|
---|
[3171] | 10 | #include "mr_mem.h"
|
---|
[3141] | 11 | #include "my-stuff.h"
|
---|
[3111] | 12 |
|
---|
[3141] | 13 | /* Whether we should fail immediately at first error */
|
---|
| 14 | bool g_fail_immediately = FALSE;
|
---|
| 15 |
|
---|
[3116] | 16 | void (*mr_cleanup)(void) = NULL;
|
---|
| 17 |
|
---|
[3141] | 18 | char *strl[] = {
|
---|
[3111] | 19 | "test with space",
|
---|
[3170] | 20 | "test with \\ backslash",
|
---|
[3111] | 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",
|
---|
[3170] | 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
|
---|
[3111] | 33 | };
|
---|
| 34 |
|
---|
[3116] | 35 | int main() {
|
---|
[3111] | 36 |
|
---|
| 37 | char *p;
|
---|
| 38 | int i;
|
---|
| 39 |
|
---|
[3170] | 40 | for (i = 1; strl[i] != NULL ; i++) {
|
---|
| 41 | printf("Test %2d Original chain is %s\n",i,strl[i]);
|
---|
[3171] | 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);
|
---|
[3111] | 48 | }
|
---|
| 49 | exit(0);
|
---|
| 50 | }
|
---|