Add and use com_err error codes

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22556 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2008-02-01 16:38:46 +00:00
parent 3ff43c30b9
commit 3ad1f2d308
10 changed files with 61 additions and 51 deletions

View File

@@ -46,8 +46,7 @@ BUILT_SOURCES = \
wind_err.c \
wind_err.h
include_HEADERS = wind.h
dist_include_HEADERS = wind.h
nodist_include_HEADERS = wind_err.h
TESTS = \

View File

@@ -40,7 +40,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
DIST_COMMON = $(dist_include_HEADERS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(top_srcdir)/Makefile.am.common \
$(top_srcdir)/cf/Makefile.am.common ChangeLog
@versionscript_TRUE@am__append_1 = $(LDFLAGS_VERSION_SCRIPT)$(srcdir)/version-script.map
@@ -164,9 +164,9 @@ SOURCES = $(libwind_la_SOURCES) $(idn_lookup_SOURCES) test-bidi.c \
DIST_SOURCES = $(libwind_la_SOURCES) $(idn_lookup_SOURCES) test-bidi.c \
test-map.c test-normalize.c test-prohibited.c \
$(test_punycode_SOURCES) test-utf8.c
includeHEADERS_INSTALL = $(INSTALL_HEADER)
dist_includeHEADERS_INSTALL = $(INSTALL_HEADER)
nodist_includeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(include_HEADERS) $(nodist_include_HEADERS)
HEADERS = $(dist_include_HEADERS) $(nodist_include_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -417,7 +417,7 @@ BUILT_SOURCES = \
wind_err.c \
wind_err.h
include_HEADERS = wind.h
dist_include_HEADERS = wind.h
nodist_include_HEADERS = wind_err.h
TESTS = \
$(check_PROGRAMS)
@@ -592,19 +592,19 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
install-includeHEADERS: $(include_HEADERS)
install-dist_includeHEADERS: $(dist_include_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
@list='$(include_HEADERS)'; for p in $$list; do \
@list='$(dist_include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
$(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
echo " $(dist_includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
$(dist_includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
done
uninstall-includeHEADERS:
uninstall-dist_includeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(include_HEADERS)'; for p in $$list; do \
@list='$(dist_include_HEADERS)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
rm -f "$(DESTDIR)$(includedir)/$$f"; \
@@ -836,7 +836,8 @@ info: info-am
info-am:
install-data-am: install-includeHEADERS install-nodist_includeHEADERS
install-data-am: install-dist_includeHEADERS \
install-nodist_includeHEADERS
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-data-hook
@@ -875,7 +876,7 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \
uninstall-am: uninstall-binPROGRAMS uninstall-dist_includeHEADERS \
uninstall-libLTLIBRARIES uninstall-nodist_includeHEADERS
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-hook
@@ -889,17 +890,18 @@ uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \
dist-hook distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-data-hook install-dvi \
install-dvi-am install-exec install-exec-am install-exec-hook \
install-html install-html-am install-includeHEADERS \
install-info install-info-am install-libLTLIBRARIES \
install-man install-nodist_includeHEADERS install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
install-data install-data-am install-data-hook \
install-dist_includeHEADERS install-dvi install-dvi-am \
install-exec install-exec-am install-exec-hook install-html \
install-html-am install-info install-info-am \
install-libLTLIBRARIES install-man \
install-nodist_includeHEADERS install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-binPROGRAMS \
uninstall-hook uninstall-includeHEADERS \
uninstall-dist_includeHEADERS uninstall-hook \
uninstall-libLTLIBRARIES uninstall-nodist_includeHEADERS

View File

@@ -72,12 +72,12 @@ _wind_stringprep_map(const uint32_t *in, size_t in_len,
for (j = 0; j < s->val_len; ++j) {
if (o >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
out[o++] = _wind_map_table_val[s->val_offset + j];
}
} else {
if (o >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
out[o++] = in[i];
}

View File

@@ -38,6 +38,7 @@
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include "normalize_table.h"
@@ -81,7 +82,7 @@ hangul_decomp(const uint32_t *in, size_t in_len,
if (t != t_base)
++o;
if (*out_len < o)
return -1;
return WIND_ERR_OVERRUN;
out[0] = l;
out[1] = v;
if (t != t_base)
@@ -132,7 +133,7 @@ compat_decomp(const uint32_t *in, size_t in_len,
ret = hangul_decomp(in + i, in_len - i,
out + o, &sub_len);
if (ret) {
if (ret == -1)
if (ret == WIND_ERR_OVERRUN)
return ret;
o += sub_len;
} else {
@@ -152,7 +153,7 @@ compat_decomp(const uint32_t *in, size_t in_len,
o += sub_len;
} else {
if (o >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
out[o++] = in[i];
}
@@ -274,7 +275,7 @@ _wind_stringprep_normalize(const uint32_t *in, size_t in_len,
tmp_len = MAX_LENGTH;
tmp = malloc(tmp_len * sizeof(uint32_t));
if (tmp == NULL)
return -1;
return ENOMEM;
ret = compat_decomp(in, in_len, tmp, &tmp_len);
if (ret) {

View File

@@ -88,14 +88,14 @@ wind_punycode_toascii(const uint32_t *in, size_t in_len,
if (in[i] < 0x80) {
++h;
if (o >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
out[o++] = in[i];
}
}
b = h;
if (b > 0) {
if (o >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
out[o++] = 0x2D;
}
while (h < in_len) {
@@ -124,12 +124,12 @@ wind_punycode_toascii(const uint32_t *in, size_t in_len,
if (q < t)
break;
if (o >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
out[o++] = digit(t + ((q - t) % (base - t)));
q = (q - t) / (base - t);
}
if (o >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
out[o++] = digit(q);
/* output */
bias = adapt(delta, h + 1, h == b);

View File

@@ -37,6 +37,7 @@
#include "windlocl.h"
#include <stdlib.h>
#include <strings.h>
#include <errno.h>
RCSID("$Id$");
@@ -63,7 +64,7 @@ wind_stringprep(const uint32_t *in, size_t in_len,
int ret;
if (tmp == NULL)
return -1;
return ENOMEM;
ret = _wind_stringprep_map(in, in_len, tmp, &tmp_len, flags);
if (ret) {
@@ -113,5 +114,5 @@ wind_profile(const char *name, wind_profile_flags *flags)
return 0;
}
}
return -1;
return WIND_ERR_NO_PROFILE;
}

View File

@@ -115,7 +115,7 @@ main(void)
for (s = failing_testcases; *s != NULL; ++s) {
len = MAX_LENGTH;
ret = wind_utf8ucs4(*s, u, &len);
if (ret != -1) {
if (ret == 0) {
printf("utf8 decode of \"%s\" should have failed\n", *s);
++failures;
}

View File

@@ -71,7 +71,7 @@ wind_utf8ucs4(const char *in, uint32_t *out, size_t *out_len)
u = ((c & 0x1F) << 6)
| (c2 & 0x3F);
} else {
return -1;
return WIND_ERR_INVALID_UTF8;
}
} else if ((c & 0xF0) == 0xE0) {
const unsigned c2 = *++p;
@@ -82,10 +82,10 @@ wind_utf8ucs4(const char *in, uint32_t *out, size_t *out_len)
| ((c2 & 0x3F) << 6)
| (c3 & 0x3F);
} else {
return -1;
return WIND_ERR_INVALID_UTF8;
}
} else {
return -1;
return WIND_ERR_INVALID_UTF8;
}
} else if ((c & 0xF8) == 0xF0) {
const unsigned c2 = *++p;
@@ -99,23 +99,23 @@ wind_utf8ucs4(const char *in, uint32_t *out, size_t *out_len)
| ((c3 & 0x3F) << 6)
| (c4 & 0x3F);
} else {
return -1;
return WIND_ERR_INVALID_UTF8;
}
} else {
return -1;
return WIND_ERR_INVALID_UTF8;
}
} else {
return -1;
return WIND_ERR_INVALID_UTF8;
}
} else {
return -1;
return WIND_ERR_INVALID_UTF8;
}
} else {
u = c;
}
if (out) {
if (o >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
out[o++] = u;
}
}
@@ -178,13 +178,13 @@ wind_ucs4utf8(const uint32_t *in, size_t in_len, char *out, size_t *out_len)
} else if (ch <= 0x10FFFF) {
len = 4;
} else
return -1;
return WIND_ERR_INVALID_UTF32;
o += len;
if (out) {
if (o >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
switch(len) {
case 4:
@@ -204,7 +204,7 @@ wind_ucs4utf8(const uint32_t *in, size_t in_len, char *out, size_t *out_len)
}
if (out) {
if (o + 1 >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
*out = '\0';
}
*out_len = o;
@@ -246,7 +246,7 @@ _wind_ucs2read(void *ptr, size_t len, uint16_t *out)
int little = 1;
if (len & 1)
return -1;
return WIND_ERR_LENGTH_NOT_EVEN;
/* check for BOM */
while (len) {
@@ -296,7 +296,7 @@ wind_ucs2utf8(const uint16_t *in, size_t in_len, char *out, size_t *out_len)
if (out) {
if (o >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
switch(len) {
case 3:
@@ -313,7 +313,7 @@ wind_ucs2utf8(const uint16_t *in, size_t in_len, char *out, size_t *out_len)
}
if (out) {
if (o + 1 >= *out_len)
return -1;
return WIND_ERR_OVERRUN;
*out = '\0';
}
*out_len = o;

View File

@@ -7,8 +7,14 @@ id "$Id$"
error_table wind
prefix WIND
prefix WIND_ERR
error_code NONE, "No error"
error_code FOO, "Random error"
error_code NO_PROFILE, "No such profile"
error_code OVERRUN, "Buffer overrun"
error_code UNDERUN, "Buffer underrun"
error_code LENGTH_NOT_EVEN, "Lenght not even"
error_code INVALID_UTF8, "Invalid UTF-8 combination in string"
error_code INVALID_UTF16, "Invalid UTF-16 combination in string"
error_code INVALID_UTF32, "Invalid UTF-32 combination in string"
end

View File

@@ -41,6 +41,7 @@
#endif
#include "wind.h"
#include "wind_err.h"
int _wind_combining_class(uint32_t);