tester2.c

Sat, 19 Feb 2000 23:23:29 +0100

author
tuomov
date
Sat, 19 Feb 2000 23:23:29 +0100
changeset 1
6e704fc09528
parent 0
86b7f6f9c5c0
child 2
e14a1aba4c56
permissions
-rw-r--r--

trunk: changeset 4
- Added include support in config file parser

- Added scatn()

- Fixed remalloczero()

- Fixed is_end() in numparser2.h -- EOF case was missing

/*
 * libtu/tester2.c
 *
 * Copyright (c) Tuomo Valkonen 1999-2000.
 * 
 * This file is distributed under the terms of the "Artistic License".
 * See the included file LICENSE for details.
 */

#include <stdio.h>
#include "include/misc.h"
#include "include/tokenizer.h"
#include "include/parser.h"
#include "include/util.h"


static bool test_fn(Tokenizer *tokz, int n, Token *toks)
{
	printf("test_fn() %d %s\n", n, TOK_IDENT_VAL(toks)); 
	
	return TRUE;
}



static bool sect_fn(Tokenizer *tokz, int n, Token *toks)
{
	printf("sect_fn() %d %s\n", n, TOK_IDENT_VAL(toks+1));
	
	return TRUE;
}


static bool test2_fn(Tokenizer *tokz, int n, Token *toks)
{
	printf("test2_fn() %d %ld %f\n", n, TOK_LONG_VAL(toks+1), TOK_DOUBLE_VAL(toks+2));

	return TRUE;
}

static bool test3_fn(Tokenizer *tokz, int n, Token *toks)
{
	if(n==1)
		printf("test3_fn() \"%s\"\n", TOK_STRING_VAL(toks+1));
	else
		printf("test3_fn() \"%s\" %ld\n", TOK_STRING_VAL(toks+1), TOK_LONG_VAL(toks+2));

	return TRUE;
}
	
	
static ConfOpt opts[]={
	{"test", NULL, test_fn, NULL},
	{"t2", "ld", test2_fn, NULL},
	{"foo", "s?l", test3_fn, NULL},
	{"sect", "s", sect_fn, opts},
	{NULL, NULL, NULL, NULL}
};

			 
int main(int argc, char *argv[])
{
	libtu_init_argv0(argv[0], NULL);
	parse_config_file(stdin, opts);
	
	return EXIT_SUCCESS;
}

mercurial