source: MondoRescue/branches/stable/mondo/src/test/test-string.c@ 1196

Last change on this file since 1196 was 1186, checked in by Bruno Cornec, 17 years ago
  • Small typo fix for mondorestore man page (reported by petes-bugs_at_thegoldenear.org)
  • mondo ChangeLog is now UTF-8
  • New tests for mr_strip_spaces
  • Some attempts to remove valgrind errors
  • Property svn:eol-style set to native
File size: 1001 bytes
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
15int main(void) {
16 const char delims[3] = ": \n";
17
18 int lastpos = 0;
19 char *token = NULL;
20 char *string = NULL;
21
22 mr_asprintf(&string, "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n");
23 fprintf(stdout, "string=|%s|\n", string);
24 while ((token = mr_strtok(string, delims, &lastpos))) {
25 fprintf(stdout, "token=|%s|, lastpos=%d\n", token, lastpos);
26 mr_free(token);
27 }
28 mr_free(string);
29
30 mr_asprintf(&string, " This is a chain with spaces before and behind ");
31 fprintf(stdout, "string=|%s|\n", string);
32 mr_strip_spaces(string);
33 fprintf(stdout, "string=|%s|\n", string);
34 mr_free(string);
35 mr_asprintf(&string, "This is a chain without spaces before and behind");
36 fprintf(stdout, "string=|%s|\n", string);
37 mr_strip_spaces(string);
38 fprintf(stdout, "string=|%s|\n", string);
39 mr_free(string);
40
41 exit(0);
42}
Note: See TracBrowser for help on using the repository browser.