2013-02-09 13:31:31 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2013-12-31 10:24:12 +00:00
|
|
|
Copyright 2006-2014 Chung, Hyung-Hwan.
|
2013-02-09 13:31:31 +00:00
|
|
|
This file is part of QSE.
|
|
|
|
|
|
|
|
QSE is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as
|
|
|
|
published by the Free Software Foundation, either version 3 of
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
QSE is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "xli.h"
|
|
|
|
#include "../cmn/mem.h"
|
|
|
|
|
|
|
|
const qse_char_t* qse_xli_dflerrstr (
|
|
|
|
const qse_xli_t* xli, qse_xli_errnum_t errnum)
|
|
|
|
{
|
|
|
|
static const qse_char_t* errstr[] =
|
|
|
|
{
|
|
|
|
QSE_T("no error"),
|
|
|
|
QSE_T("other error"),
|
|
|
|
QSE_T("not implemented"),
|
|
|
|
QSE_T("subsystem error"),
|
|
|
|
QSE_T("internal error that should never have happened"),
|
|
|
|
|
|
|
|
QSE_T("insufficient memory"),
|
|
|
|
QSE_T("invalid parameter or data"),
|
|
|
|
QSE_T("'${0}' not found"),
|
|
|
|
QSE_T("'${0}' already exists"),
|
|
|
|
QSE_T("I/O error with file '${0}'"),
|
|
|
|
QSE_T("error returned by user I/O handler"),
|
|
|
|
|
2013-02-18 13:45:50 +00:00
|
|
|
QSE_T("syntax error"),
|
2013-02-09 13:31:31 +00:00
|
|
|
QSE_T("semicolon expected in place of '${0}'"),
|
|
|
|
QSE_T("left-brace or equal-sign expected in place of '${0}'"),
|
|
|
|
QSE_T("right-brace expected in place of '${0}'"),
|
2013-02-18 13:45:50 +00:00
|
|
|
QSE_T("pair value expected in place of '${0}'"),
|
|
|
|
QSE_T("string not closed"),
|
2013-09-24 14:02:06 +00:00
|
|
|
QSE_T("string tag not closed"),
|
2013-02-18 13:45:50 +00:00
|
|
|
QSE_T("'@include' not followed by a string"),
|
|
|
|
QSE_T("invalid character '${0}'"),
|
2013-09-24 14:02:06 +00:00
|
|
|
QSE_T("invalid tag character '${0}'"),
|
2013-02-18 13:45:50 +00:00
|
|
|
QSE_T("'${0}' not recognized"),
|
2013-07-11 16:55:08 +00:00
|
|
|
QSE_T("@ not followed by a valid word"),
|
2013-09-17 01:28:04 +00:00
|
|
|
QSE_T("invalid identifier '${0}'"),
|
2013-09-25 06:40:40 +00:00
|
|
|
QSE_T("missing key after key tag"),
|
2013-07-12 15:37:29 +00:00
|
|
|
QSE_T("undefined key '${0}'"),
|
|
|
|
QSE_T("no alias for '${0}'"),
|
2013-07-11 16:55:08 +00:00
|
|
|
QSE_T("illegal value for '${0}'"),
|
2013-07-12 15:37:29 +00:00
|
|
|
QSE_T("no value for '${0}'"),
|
2013-07-11 16:55:08 +00:00
|
|
|
QSE_T("too many string segments for '${0}'")
|
2013-02-09 13:31:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return (errnum >= 0 && errnum < QSE_COUNTOF(errstr))?
|
|
|
|
errstr[errnum]: QSE_T("unknown error");
|
|
|
|
}
|
|
|
|
|
|
|
|
qse_xli_errstr_t qse_xli_geterrstr (const qse_xli_t* xli)
|
|
|
|
{
|
|
|
|
return xli->errstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qse_xli_seterrstr (qse_xli_t* xli, qse_xli_errstr_t errstr)
|
|
|
|
{
|
|
|
|
xli->errstr = errstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
qse_xli_errnum_t qse_xli_geterrnum (const qse_xli_t* xli)
|
|
|
|
{
|
|
|
|
return xli->errnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
const qse_xli_loc_t* qse_xli_geterrloc (const qse_xli_t* xli)
|
|
|
|
{
|
|
|
|
return &xli->errloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
const qse_char_t* qse_xli_geterrmsg (const qse_xli_t* xli)
|
|
|
|
{
|
|
|
|
return (xli->errmsg[0] == QSE_T('\0'))?
|
|
|
|
qse_xli_geterrstr(xli)(xli,xli->errnum): xli->errmsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qse_xli_geterror (
|
|
|
|
const qse_xli_t* xli, qse_xli_errnum_t* errnum,
|
|
|
|
const qse_char_t** errmsg, qse_xli_loc_t* errloc)
|
|
|
|
{
|
|
|
|
if (errnum != QSE_NULL) *errnum = xli->errnum;
|
|
|
|
if (errmsg != QSE_NULL)
|
|
|
|
{
|
|
|
|
*errmsg = (xli->errmsg[0] == QSE_T('\0'))?
|
|
|
|
qse_xli_geterrstr(xli)(xli,xli->errnum):
|
|
|
|
xli->errmsg;
|
|
|
|
}
|
|
|
|
if (errloc != QSE_NULL) *errloc = xli->errloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qse_xli_seterrnum (
|
2014-07-02 12:28:58 +00:00
|
|
|
qse_xli_t* xli, qse_xli_errnum_t errnum, const qse_xstr_t* errarg)
|
2013-02-09 13:31:31 +00:00
|
|
|
{
|
|
|
|
qse_xli_seterror (xli, errnum, errarg, QSE_NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void qse_xli_seterrmsg (
|
|
|
|
qse_xli_t* xli, qse_xli_errnum_t errnum,
|
|
|
|
const qse_char_t* errmsg, const qse_xli_loc_t* errloc)
|
|
|
|
{
|
|
|
|
xli->errnum = errnum;
|
|
|
|
qse_strxcpy (xli->errmsg, QSE_COUNTOF(xli->errmsg), errmsg);
|
|
|
|
if (errloc != QSE_NULL) xli->errloc = *errloc;
|
|
|
|
else QSE_MEMSET (&xli->errloc, 0, QSE_SIZEOF(xli->errloc));
|
|
|
|
}
|
|
|
|
|
|
|
|
void qse_xli_seterror (
|
|
|
|
qse_xli_t* xli, qse_xli_errnum_t errnum,
|
2014-07-02 12:28:58 +00:00
|
|
|
const qse_xstr_t* errarg, const qse_xli_loc_t* errloc)
|
2013-02-09 13:31:31 +00:00
|
|
|
{
|
|
|
|
const qse_char_t* errfmt;
|
|
|
|
|
|
|
|
xli->errnum = errnum;
|
|
|
|
|
|
|
|
errfmt = qse_xli_geterrstr(xli)(xli,xli->errnum);
|
|
|
|
QSE_ASSERT (errfmt != QSE_NULL);
|
|
|
|
qse_strxfncpy (xli->errmsg, QSE_COUNTOF(xli->errmsg), errfmt, errarg);
|
|
|
|
|
|
|
|
if (errloc != QSE_NULL) xli->errloc = *errloc;
|
|
|
|
else QSE_MEMSET (&xli->errloc, 0, QSE_SIZEOF(xli->errloc));
|
|
|
|
}
|
|
|
|
|