| 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 | /* Reference to global bkpinfo */
|
|---|
| 17 | struct s_bkpinfo *bkpinfo;
|
|---|
| 18 |
|
|---|
| 19 | void (*mr_cleanup)(void) = NULL;
|
|---|
| 20 |
|
|---|
| 21 | char *strl[] = {
|
|---|
| 22 | "test with space",
|
|---|
| 23 | "test with \\ backslash",
|
|---|
| 24 | "test with \" doublequote",
|
|---|
| 25 | "test with ' simplequote",
|
|---|
| 26 | "test with ~ tilde",
|
|---|
| 27 | "test with ? questionmark",
|
|---|
| 28 | "test with ! exclammark",
|
|---|
| 29 | "test with & ampersand",
|
|---|
| 30 | "test with * star",
|
|---|
| 31 | "test with | pipe",
|
|---|
| 32 | "test with \\' backslash quote",
|
|---|
| 33 | "test with nothing SPECIAL 1234",
|
|---|
| 34 | "test with rtmp:_ retrieval with rtmpdump and tcpdump « Pxnh's Blog_files",
|
|---|
| 35 | NULL
|
|---|
| 36 | };
|
|---|
| 37 |
|
|---|
| 38 | int main() {
|
|---|
| 39 |
|
|---|
| 40 | char *p;
|
|---|
| 41 | int i;
|
|---|
| 42 |
|
|---|
| 43 | for (i = 0; strl[i] != NULL ; i++) {
|
|---|
| 44 | printf("Test %2d Original chain is %s\n",i,strl[i]);
|
|---|
| 45 | p = mr_stresc(strl[i], "`$\\\"(){}'[]&*?|!#~", '\\', '"');
|
|---|
| 46 | printf("Test %2d Transformed chain (with \") is %s\n",i,p);
|
|---|
| 47 | mr_free(p);
|
|---|
| 48 | p = mr_stresc(strl[i], "`$\\\"(){}'[]&*?|!#~", '\\', '\'');
|
|---|
| 49 | printf("Test %2d Transformed chain (with ') is %s\n",i,p);
|
|---|
| 50 | mr_free(p);
|
|---|
| 51 | }
|
|---|
| 52 | exit(0);
|
|---|
| 53 | }
|
|---|