iconv_list.c revision 48edc7cf07b5dccc3ad84bf2dafe4150bd666d60
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* Copyright 2016 Nexenta Systems, Inc. All rights reserved.
*/
/*
* implement "iconv -l"
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#include <unistd.h>
#include <alloca.h>
#include <stddef.h>
#include <dirent.h>
#include <unistd.h>
#define PATH_LIBICONV "/usr/lib/iconv"
#define PATH_BTABLES "/usr/lib/iconv/geniconvtbl/binarytables"
#define PATH_ALIASES "/usr/lib/iconv/alias"
typedef struct codeset {
char *cs_name;
} codeset_t;
typedef struct csalias {
char *a_name;
} csalias_t;
static avl_tree_t cs_avl;
static void alias_destroy(csalias_t *);
/*
* codesets
*/
static int
{
int rv;
}
static void
{
return; /* already there */
perror("cs_insert:calloc");
exit(1);
}
perror("cs_insert:strdup");
exit(1);
}
}
const char topmatter[] =
"The following are all supported code set names. All combinations\n"
"of those names are not necessarily available for the pair of the\n"
"fromcode-tocode. Some of those code set names have aliases, which\n"
"are case-insensitive and described in parentheses following the\n"
"canonical name:\n";
static void
cs_dump(void)
{
csalias_t *a;
}
(void) printf(")");
}
(void) printf(",\n");
}
}
static void
cs_destroy(void)
{
csalias_t *a;
alias_destroy(a);
}
}
}
/*
* aliases
*/
static void
{
csalias_t *a;
/*
* Find the codeset. If non-existent,
* ignore aliases of this codeset.
*/
return;
/*
* Add this alias
*/
a = calloc(1, sizeof (*a));
if (a == NULL) {
perror("alias_insert:calloc");
exit(1);
}
perror("alias_insert:strdup");
exit(1);
}
}
static void
{
free(a);
}
static void
{
char namebuf[MAXNAMELEN];
/*
* We'll modify, so let's copy. If the dirent name is
* longer than MAXNAMELEN, then it can't possibly be a
* valid pair of codeset names, so just skip it.
*/
sizeof (namebuf))
continue;
/* Find suffix (.so | .t) */
continue;
continue;
*p2 = '\0';
continue;
*p1++ = '\0';
/* More than one sep? */
continue;
/* Empty strings? */
continue;
/* OK, add both to the map. */
}
}
static void
{
char linebuf[256];
if (linebuf[0] == '#')
continue;
continue;
*p1++ = '\0';
continue;
*p2 = '\0';
}
}
int
list_codesets(void)
{
return (1);
}
return (1);
}
/* let's continue */
} else {
}
cs_dump();
cs_destroy();
return (0);
}