/*
* Copyright 2013 Garrett D'Amore <garrett@damore.org>
* Copyright 2010 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "lint.h"
#include "file64.h"
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include "libc.h"
#include "ldpart.h"
#include "setlocale.h"
static int split_lines(char *, const char *);
int
char **locale_buf, const char *category_filename,
int locale_buf_size_max, int locale_buf_size_min,
const char **dst_localebuf)
{
char *lbuf, *p;
const char *plim;
/*
* Slurp the locale file into the cache.
*/
/* 'PathLocale' must be already set & checked. */
return (_LDP_ERROR);
goto bad_locale;
goto bad_locale;
}
goto bad_locale;
}
goto bad_lbuf;
/*
* Parse the locale file into localebuf.
*/
goto bad_lbuf;
}
if (num_lines >= locale_buf_size_max)
else if (num_lines >= locale_buf_size_min)
else {
goto bad_lbuf;
}
/*
* Record the successful parse in the cache.
*/
*locale_buf = lbuf;
for (p = *locale_buf, i = 0; i < num_lines; i++)
for (i = num_lines; i < locale_buf_size_max; i++)
dst_localebuf[i] = NULL;
return (_LDP_LOADED);
return (_LDP_ERROR);
}
static int
{
int i;
i = 0;
while (p < plim) {
if (*p == '\n') {
*p = '\0';
i++;
}
p++;
}
return (i);
}