localedef.c revision 6b5e5868e7ebf1aff3a5abd7d0c4ef0e5fbf3648
/*
* 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 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 2010 Nexenta Systems, Inc. All rights reserved.
*/
/*
* POSIX localedef.
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <libgen.h>
#include <stddef.h>
#include <unistd.h>
#include <limits.h>
#include <locale.h>
#include <dirent.h>
#include "localedef.h"
#include "parser.tab.h"
#ifndef TEXT_DOMAIN
#define TEXT_DOMAIN "SYS_TEST"
#endif
int verbose = 0;
int undefok = 0;
int warnok = 0;
const char *
category_name(void)
{
switch (get_category()) {
case T_CHARMAP:
return ("CHARMAP");
case T_COLLATE:
return ("LC_COLLATE");
case T_CTYPE:
return ("LC_CTYPE");
case T_MESSAGES:
return ("LC_MESSAGES");
case T_MONETARY:
return ("LC_MONETARY");
case T_NUMERIC:
return ("LC_NUMERIC");
case T_TIME:
return ("LC_TIME");
default:
return (NULL);
}
}
static char *
category_file(void)
{
locname, category_name());
return (locpath);
}
FILE *
open_category(void)
{
if (verbose) {
}
/* make the parent directory */
/*
* note that we have to regenerate the file name, as dirname
* clobbered it.
*/
return (NULL);
}
return (file);
}
void
close_category(FILE *f)
{
(void) fclose(f);
(void) unlink(category_file());
}
if (fclose(f) < 0) {
(void) unlink(category_file());
}
if (verbose) {
}
}
/*
* This function is used when copying the category from another
* locale. Note that the copy is actually performed using a hard
* link for efficiency.
*/
void
copy_category(char *src)
{
int rv;
src, category_name());
/* Maybe we should try the system locale */
}
if (rv != 0) {
return;
}
if (verbose > 1) {
(void) printf(_("Copying category %s from %s: "),
category_name(), src);
}
/* make the parent directory */
return;
}
if (verbose > 1) {
(void) printf(_("done.\n"));
}
}
int
putl_category(const char *s, FILE *f)
{
(void) fclose(f);
(void) unlink(category_file());
return (EOF);
}
(void) fclose(f);
(void) unlink(category_file());
return (EOF);
}
return (0);
}
int
{
if (!sz) {
return (0);
}
(void) fclose(f);
(void) unlink(category_file());
return (EOF);
}
return (0);
}
int yyparse(void);
static void
usage(void)
{
_("Usage: localedef [-v] [-f charmap] [-i locsrc] [-u encoding] "
"[-v] [-U] localename\n"));
exit(4);
}
int
{
int c;
init_charmap();
init_collate();
init_ctype();
init_numeric();
init_time();
yydebug = 0;
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'v':
verbose++;
break;
case 'i':
break;
case 'u':
break;
case 'f':
break;
case 'U':
undefok++;
break;
case 'c':
warnok++;
break;
case '?':
usage();
break;
}
}
usage();
}
if (verbose) {
}
if (cfname) {
if (verbose)
(void) yyparse();
}
if (verbose) {
(void) printf(_("Loading POSIX portable characters.\n"));
}
if (lfname) {
} else {
}
/* make the directory for the locale if not already present */
}
}
(void) yyparse();
if (verbose) {
(void) printf(_("All done.\n"));
}
return (warnings ? 1 : 0);
}