view src/util/imap-utf7.c @ 9532:00cd9aacd03c HEAD

Updated copyright notices to include year 2010.
author Timo Sirainen <tss@iki.fi>
date Mon, 25 Jan 2010 01:18:58 +0200
parents 6c0fb914e03e
children
line wrap: on
line source

/* Copyright (c) 2008-2010 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "str.h"
#include "imap-utf7.h"

#include <stdio.h>

int main(int argc ATTR_UNUSED, const char *argv[])
{
	string_t *dest;
	bool reverse = FALSE;
	int ret;

	lib_init();

	if (argv[1] != NULL && strcmp(argv[1], "-r") == 0) {
		reverse = TRUE;
		argv++;
	}

	if (argv[1] == NULL) {
		fprintf(stderr, "Usage: %s [-r] <string>\n", argv[0]);
		return 1;
	}

	dest = t_str_new(256);
	ret = reverse ?
		imap_utf8_to_utf7(argv[1], dest) :
		imap_utf7_to_utf8(argv[1], dest);
	if (ret < 0) {
		fprintf(stderr, "Invalid input\n");
		return 1;
	}
	printf("%s\n", str_c(dest));
	return 0;
}