Last change
on this file since 3423 was 1421, checked in by Bruno Cornec, 17 years ago |
tests reviewed
|
-
Property svn:eol-style
set to
native
|
File size:
1.0 KB
|
Line | |
---|
1 | /*
|
---|
2 | * Test file to test the configuration file handling
|
---|
3 | *
|
---|
4 | * $Id$
|
---|
5 | *
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include <string.h>
|
---|
9 | #include <stdlib.h>
|
---|
10 | #include <stdio.h>
|
---|
11 |
|
---|
12 | #include "mr_str.h"
|
---|
13 | #include "mr_mem.h"
|
---|
14 |
|
---|
15 | void (*mr_cleanup)(void) = NULL;
|
---|
16 |
|
---|
17 | int main(void) {
|
---|
18 | const char delims[3] = ": \n";
|
---|
19 |
|
---|
20 | int lastpos = 0;
|
---|
21 | char *token = NULL;
|
---|
22 | char *string = NULL;
|
---|
23 |
|
---|
24 | mr_asprintf(&string, "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n");
|
---|
25 | fprintf(stdout, "string=|%s|\n", string);
|
---|
26 | while ((token = mr_strtok(string, delims, &lastpos))) {
|
---|
27 | fprintf(stdout, "token=|%s|, lastpos=%d\n", token, lastpos);
|
---|
28 | mr_free(token);
|
---|
29 | }
|
---|
30 | mr_free(string);
|
---|
31 |
|
---|
32 | mr_asprintf(&string, " This is a chain with spaces before and behind ");
|
---|
33 | fprintf(stdout, "string=|%s|\n", string);
|
---|
34 | mr_strip_spaces(string);
|
---|
35 | fprintf(stdout, "string=|%s|\n", string);
|
---|
36 | mr_free(string);
|
---|
37 | mr_asprintf(&string, "This is a chain without spaces before and behind");
|
---|
38 | fprintf(stdout, "string=|%s|\n", string);
|
---|
39 | mr_strip_spaces(string);
|
---|
40 | fprintf(stdout, "string=|%s|\n", string);
|
---|
41 | mr_free(string);
|
---|
42 |
|
---|
43 | exit(0);
|
---|
44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.