source: MondoRescue/branches/2.2.10/mondo/test/test-string.c @ 2310

Last change on this file since 2310 was 2310, checked in by Bruno Cornec, 11 years ago

Backport all test programs from trunk into 2.2.10

  • Property svn:eol-style set to native
File size: 686 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
15void (*mr_cleanup)(void) = NULL;
16
17int 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, "%s", "md0 : active raid10 hda1[0] hda12[3] hda6[2] hda5[1]\n");
25    fprintf(stdout, "string=|%s|\n", string);
26    token = mr_strtok(string, delims, &lastpos);
27    while (lastpos > 0) {
28        fprintf(stdout, "token=|%s|, lastpos=%d\n", token, lastpos);
29        mr_free(token);
30        token = mr_strtok(string, delims, &lastpos);
31    }
32    mr_free(string);
33
34    exit(0);
35}
Note: See TracBrowser for help on using the repository browser.