(check-windows): Build and run test_et.exe.
* error_message.c: Include autoconf.h.
(HAVE_STRERROR) [_WIN32]: Don't define.
(error_message) [_WIN32]: Check for range WSABASEERR+[0,1100) instead of
all values under 12000. Use k5_getspecific and k5_setspecific for local buffer.
* test_et.c (EXPORT_LIST): Define on Windows.
(main): Use add/remove_error_table, not the initialize_ routines.
(main) [EXPORT_LIST]: Don't test error_table_name, it's not in the export list.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16481
dc483132-0cff-0310-8789-
dd5450dbe970
+2004-06-18 Ken Raeburn <raeburn@mit.edu>
+
+ * Makefile.in ($(OUTPRE)test_et.exe): New target.
+ (check-windows): Build and run test_et.exe.
+
+ * error_message.c: Include autoconf.h.
+ (HAVE_STRERROR) [_WIN32]: Don't define.
+ (error_message) [_WIN32]: Check for range WSABASEERR+[0,1100)
+ instead of all values under 12000. Use k5_getspecific and
+ k5_setspecific for local buffer.
+
+ * test_et.c (EXPORT_LIST): Define on Windows.
+ (main): Use add/remove_error_table, not the initialize_ routines.
+ (main) [EXPORT_LIST]: Don't test error_table_name, it's not in the
+ export list.
+
2004-06-04 Ken Raeburn <raeburn@mit.edu>
* Makefile.in (LIBBASE): Renamed from LIB.
t_com_err: t_com_err.o et1.o et2.o $(COM_ERR_DEPLIB) $(SUPPORT_DEPLIB)
$(CC_LINK) -o t_com_err t_com_err.o et1.o et2.o -lcom_err $(SUPPORT_LIB)
+$(OUTPRE)test_et.exe: $(OUTPRE)test_et.$(OBJEXT) $(OUTPRE)test1.$(OBJEXT) \
+ $(OUTPRE)test2.$(OBJEXT) $(CLIB)
+ link $(EXE_LINKOPTS) -out:$(OUTPRE)test_et$(EXEEXT) $**
+
all-unix:: compile_et includes
includes:: com_err.h
$(RUN_SETUP) ./test_et
$(RUN_SETUP) ./t_com_err
+check-windows:: $(OUTPRE)test_et$(EXEEXT)
+ set path=$(BUILDTOP)\lib\$(OUTPRE);%path%;
+ path
+ $(OUTPRE)test_et$(EXEEXT)
+
# The real compile_et just isn't portable. (But then again, anything using
# lex and yacc isn't portable by definition. :-( )
#
* provided "as is" without express or implied warranty.
*/
+#include "autoconf.h"
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#include "error_table.h"
#include "k5-platform.h"
-#if defined(_WIN32)
-#define HAVE_STRERROR
-#endif
-
#if !defined(HAVE_STRERROR) && !defined(SYS_ERRLIST_DECLARED)
extern char const * const sys_errlist[];
extern const int sys_nerr;
* WinSock errors exist in the 10000 and 11000 ranges
* but might not appear if WinSock is not initialized
*/
- if (code < 12000) {
+ if (code >= WSABASEERR && code < WSABASEERR + 1100) {
table_num = 0;
offset = code;
- divisor = 10000;
+ divisor = WSABASEERR;
}
#endif
#ifdef _WIN32
* WinSock errors exist in the 10000 and 11000 ranges
* but might not appear if WinSock is not initialized
*/
- if (code < 12000) {
+ if (code >= WSABASEERR && code < WSABASEERR + 1100) {
table_num = 0;
offset = code;
divisor = 10000;
goto oops;
} else {
- strncpy(buffer, msgbuf, sizeof(buffer));
- buffer[sizeof(buffer)-1] = '\0';
+ char *buffer;
+ cp = k5_getspecific(K5_KEY_COM_ERR);
+ if (cp == NULL) {
+ cp = malloc(ET_EBUFSIZ);
+ if (cp == NULL) {
+ win32_no_specific:
+ return "Unknown error code";
+ }
+ if (k5_setspecific(K5_KEY_COM_ERR, cp) != 0) {
+ free(cp);
+ goto win32_no_specific;
+ }
+ }
+ buffer = cp;
+ strncpy(buffer, msgbuf, ET_EBUFSIZ);
+ buffer[ET_EBUFSIZ-1] = '\0';
cp = buffer + strlen(buffer) - 1;
if (*cp == '\n') *cp-- = '\0';
if (*cp == '\r') *cp-- = '\0';
#include "test1.h"
#include "test2.h"
+#ifdef _WIN32
+# define EXPORT_LIST
+#endif
+
/* XXX Not part of official public API. */
extern const char *error_table_name (errcode_t);
int main()
{
printf("Before initiating error table:\n\n");
+#ifndef EXPORT_LIST
printf("Table name '%s'\n", error_table_name(KRB_MK_AP_TGTEXP));
printf("UNIX name '%s'\n", error_table_name(EPERM));
+#endif
printf("Msg TGT-expired is '%s'\n", error_message(KRB_MK_AP_TGTEXP));
printf("Msg EPERM is '%s'\n", error_message(EPERM));
printf("Msg FOO_ERR is '%s'\n", error_message(FOO_ERR));
printf("With 0: tgt-expired -> %s\n", error_message(KRB_MK_AP_TGTEXP));
initialize_krb_error_table();
+#ifndef EXPORT_LIST
printf("KRB error table initialized: base %ld (%s), name %s\n",
ERROR_TABLE_BASE_krb, error_message(ERROR_TABLE_BASE_krb),
error_table_name(ERROR_TABLE_BASE_krb));
- initialize_krb_error_table();
+#else
+ printf("KRB error table initialized: base %ld (%s)\n",
+ ERROR_TABLE_BASE_krb, error_message(ERROR_TABLE_BASE_krb));
+#endif
+ add_error_table(&et_krb_error_table);
printf("With krb: tgt-expired -> %s\n",
error_message(KRB_MK_AP_TGTEXP));
- initialize_quux_error_table();
+ add_error_table(&et_quux_error_table);
+#ifndef EXPORT_LIST
printf("QUUX error table initialized: base %ld (%s), name %s\n",
ERROR_TABLE_BASE_quux, error_message(ERROR_TABLE_BASE_quux),
error_table_name(ERROR_TABLE_BASE_quux));
+#else
+ printf("QUUX error table initialized: base %ld (%s)\n",
+ ERROR_TABLE_BASE_quux, error_message(ERROR_TABLE_BASE_quux));
+#endif
printf("Msg for TGT-expired is '%s'\n",
error_message(KRB_MK_AP_TGTEXP));