testcase.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Thu, 16 Apr 2009 12:49:13 +0200
changeset 59 a7ba10b68915
parent 48 b94d657a9acb
child 61 4b4c97f179da
permissions -rw-r--r--
getpwnam_error.c: * The memory hole can be fixed with two different approaches 1) Change /etc/nsswitch.conf: passwd: compat to passwd: files 2) LD_PRELOAD=/lib/libnss_compat.so.2 valgrind ./getpwnam_error GLIBC loads libnss_compat on the fly and unloads it. Thanks to telexicon for reporting this... committer: Markus Bröker <mbroeker@largo.homelinux.org>

/**
 * test/demos/testcase.c
 * Copyright (C) 2008 Markus Broeker
 */

#define _XOPEN_SOURCE 500

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (int argc, char **argv)
{
    char line[83];
    char *token;

    if (argc != 4) {
        printf ("Usage: %s (char*)string (char*)delim1 (char*)delim2\n", argv[0]);
        return EXIT_FAILURE;
    }

    snprintf (line, 80, "%s\r\n", argv[1]);

    token = strtok (line, argv[2]);

    while (token) {
        printf ("TOKEN: %s\n", token);
        token = strtok (NULL, argv[3]);
    }

    printf ("\nTest finished\n");

    return EXIT_SUCCESS;
}