Last change
on this file since 2137 was 1421, checked in by Bruno Cornec, 17 years ago |
tests reviewed
|
-
Property svn:eol-style
set to
native
|
File size:
1.0 KB
|
Rev | Line | |
---|
[1054] | 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 |
|
---|
[1421] | 15 | void (*mr_cleanup)(void) = NULL;
|
---|
| 16 |
|
---|
[1064] | 17 | int main(void) {
|
---|
[1054] | 18 | const char delims[3] = ": \n";
|
---|
| 19 |
|
---|
| 20 | int lastpos = 0;
|
---|
| 21 | char *token = NULL;
|
---|
| 22 | char *string = NULL;
|
---|
| 23 |
|
---|
[1140] | 24 | mr_asprintf(&string, "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n");
|
---|
[1054] | 25 | fprintf(stdout, "string=|%s|\n", string);
|
---|
[1140] | 26 | while ((token = mr_strtok(string, delims, &lastpos))) {
|
---|
[1054] | 27 | fprintf(stdout, "token=|%s|, lastpos=%d\n", token, lastpos);
|
---|
| 28 | mr_free(token);
|
---|
| 29 | }
|
---|
| 30 | mr_free(string);
|
---|
| 31 |
|
---|
[1186] | 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 |
|
---|
[1054] | 43 | exit(0);
|
---|
| 44 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.