/*
 * Copyright (c) 2005 Sendmail, Inc. and its suppliers.
 *	All rights reserved.
 *
 * By using this file, you agree to the terms and conditions set
 * forth in the LICENSE file which can be found at the top level of
 * the sendmail distribution.
 */

#include "sm/generic.h"
SM_RCSID("@(#)$Id: t-verpify.c,v 1.3 2006/09/29 05:36:03 ca Exp $")
#include "sm/assert.h"
#include "sm/error.h"
#include "sm/str.h"
#include "sm/misc.h"
#include "sm/test.h"
#include "sm/io.h"

static int Verbosity = 0;

#define LEN	256

static void
test(const char *mail, const char *rcpt)
{
	sm_ret_T ret;
	sm_str_P mail_pa, rcpt_pa, verp_pa;

	mail_pa = sm_str_new(NULL, LEN, LEN + 2 );
	SM_TEST_E(mail_pa != NULL);
	rcpt_pa = sm_str_new(NULL, LEN, LEN + 2 );
	SM_TEST_E(rcpt_pa != NULL);
	verp_pa = sm_str_new(NULL, LEN, LEN + 2 );
	SM_TEST_E(verp_pa != NULL);

	ret = sm_str_scat(mail_pa, mail);
	SM_TEST_E(sm_is_success(ret));
	ret = sm_str_scat(rcpt_pa, rcpt);
	SM_TEST_E(sm_is_success(ret));
	ret = sm_verpify(mail_pa, rcpt_pa, '\0', '\0', verp_pa);
	SM_TEST_E(sm_is_success(ret));
	sm_io_fprintf(smioout, "%S\n", verp_pa);
	sm_io_flush(smioout);

	SM_STR_FREE(mail_pa);
	SM_STR_FREE(rcpt_pa);
	SM_STR_FREE(verp_pa);
  error:
	return;
}

int
main(int argc, char *argv[])
{
	int c;

	while ((c = getopt(argc, argv, "V")) != -1)
	{
		switch (c)
		{
		  case 'V':
			++Verbosity;
			break;
		}
	}
	sm_test_begin(argc, argv, "test verpify");

	argc -= optind;
	argv += optind;

	if (argc > 0)
	{
		for (c = 0; c < argc - 1; c += 2)
		{
			test(argv[c], argv[c + 1]);
		}
	}
	else
		test(NULL, NULL);

	return sm_test_end();
}


syntax highlighted by Code2HTML, v. 0.9.1