From: Tom Yu Date: Fri, 7 Feb 2003 21:39:44 +0000 (+0000) Subject: Fix ABI divergence between Unix and Mac krb4 libraries in declaration X-Git-Tag: krb5-1.3-alpha1~112 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f783834660ced3cabc14fdc184f4808606c856a8;p=krb5.git Fix ABI divergence between Unix and Mac krb4 libraries in declaration of krb_err_txt by means of a gross hack. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15165 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/ChangeLog b/src/ChangeLog index d936dd164..8f4618294 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-02-07 Tom Yu + + * Makefile.in: Add rules for generating lib/krb4/krb_err_txt.c for + Windows. + 2003-01-14 Ezra Peisach * Makefile.in (check-unix): Invoke t_krbconf instead of struggling diff --git a/src/Makefile.in b/src/Makefile.in index ad53c7e23..be9a1db7e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -366,7 +366,8 @@ ETOUT = \ $(INC)/kerberosIV/krb_err.h lib/krb4/krb_err.c \ $(PR)prof_err.h $(PR)prof_err.c \ $(GG)gssapi_err_generic.h $(GG)gssapi_err_generic.c \ - $(GK)gssapi_err_krb5.h $(GK)gssapi_err_krb5.c + $(GK)gssapi_err_krb5.h $(GK)gssapi_err_krb5.c \ + lib$(S)krb4$(S)krb_err_txt.c HOUT = $(INC)krb5.h $(GG)gssapi.h $(PR)profile.h @@ -499,6 +500,10 @@ $(GG)gssapi_err_generic.c: $(AC) $(GG)gssapi_err_generic.et $(GK)gssapi_err_krb5.c: $(AC) $(GK)gssapi_err_krb5.et $(AWK) -f $(AC) outfile=$@ $(GK)gssapi_err_krb5.et +lib$(S)krb4$(S)krb_err_txt.c: lib$(S)krb4$(S)krb_err.et + $(AWK) -f lib$(S)krb4$(S)et_errtxt.awk outfile=$@ \ + lib$(S)krb4$(S)krb_err.et + KRBHDEP = $(INC)krb5.hin $(INC)krb5_err.h $(INC)kdb5_err.h \ $(INC)kv5m_err.h $(INC)asn1_err.h diff --git a/src/include/kerberosIV/ChangeLog b/src/include/kerberosIV/ChangeLog index 58eb897b8..6c13b9770 100644 --- a/src/include/kerberosIV/ChangeLog +++ b/src/include/kerberosIV/ChangeLog @@ -1,3 +1,7 @@ +2003-02-07 Tom Yu + + * krb.h: Declare krb_err_txt differently on Mac. + 2003-01-16 Ken Raeburn * Makefile.in (all-unix, install): Build and install kadm_err.h. diff --git a/src/include/kerberosIV/krb.h b/src/include/kerberosIV/krb.h index 9e9a151ce..684f50968 100644 --- a/src/include/kerberosIV/krb.h +++ b/src/include/kerberosIV/krb.h @@ -74,7 +74,13 @@ KRBINT_BEGIN_DECLS #define KRB_UINT32 DES_UINT32 #define MAX_KRB_ERRORS 256 + +#if TARGET_OS_MAC +/* ABI divergence on Mac for backwards compatibility. */ extern const char * const * const krb_err_txt; +#else +extern const char * const krb_err_txt[MAX_KRB_ERRORS]; +#endif /* General definitions */ #define KSUCCESS 0 @@ -655,6 +661,7 @@ int send_to_kdc /* Used to return pointer to non-const char */ const char * KRB5_CALLCONV tkt_string (void); +/* Previously not KRB5_CALLCONV */ void KRB5_CALLCONV krb_set_tkt_string (char *); diff --git a/src/lib/krb4/ChangeLog b/src/lib/krb4/ChangeLog index ada0773b9..0ba4774f0 100644 --- a/src/lib/krb4/ChangeLog +++ b/src/lib/krb4/ChangeLog @@ -1,3 +1,12 @@ +2003-02-07 Tom Yu + + * Makefile.in: Add rules to generate krb_err_txt.c. + + * err_txt.c: Include two copies of the error table, one generated + by com_err, and one generated by a special-purpose awk script. + + * et_errtxt.awk: New file; used to generate krb_err_txt.c + 2003-02-04 Tom Yu * decomp_tkt.c (dcmp_tkt_int): Patch from Booker Bense to use diff --git a/src/lib/krb4/Makefile.in b/src/lib/krb4/Makefile.in index bdb43f467..c9b9ff889 100644 --- a/src/lib/krb4/Makefile.in +++ b/src/lib/krb4/Makefile.in @@ -206,6 +206,13 @@ krb_err.c: krb_err.et kadm_err.h: kadm_err.et kadm_err.c: kadm_err.et +GEN_ERRTXT=$(AWK) -f $(srcdir)$(S)et_errtxt.awk outfile=$@ + +krb_err_txt.c: krb_err.et $(srcdir)$(S)et_errtxt.awk + $(GEN_ERRTXT) $(srcdir)/krb_err.et + +err_txt.so err_txt.po $(OUTPRE)err_txt.$(OBJEXT): err_txt.c krb_err_txt.c + depend-dependencies: krb_err.h $(EHDRDIR)$(S)krb_err.h \ kadm_err.h $(EHDRDIR)$(S)kadm_err.h \ krb_err.c diff --git a/src/lib/krb4/err_txt.c b/src/lib/krb4/err_txt.c index 64663b3d7..57d346a40 100644 --- a/src/lib/krb4/err_txt.c +++ b/src/lib/krb4/err_txt.c @@ -29,8 +29,10 @@ /* * This is gross. We want krb_err_txt to match the contents of the - * com_err error table, but the text is static in krb_err.c. To avoid - * multiple registrations of the error table, we also want to override + * com_err error table, but the text is static in krb_err.c. We can't + * alias it by making a pointer to it, either, so we have to suck in + * another copy of it that is named differently. Also, to avoid + * multiple registrations of the error table, we want to override * initialize_krb_error_table() in case someone decides to call it. */ #undef initialize_krb_error_table @@ -38,12 +40,10 @@ void krb4int_init_krb_err_tbl(void); #include "krb_err.c" #undef initialize_krb_error_table +#include "krb_err_txt.c" void initialize_krb_error_table(void); -/* YUCK -- depends on naming of the static table. */ -const char * const * const krb_err_txt = text; - static int inited = 0; void diff --git a/src/lib/krb4/et_errtxt.awk b/src/lib/krb4/et_errtxt.awk new file mode 100644 index 000000000..888dad695 --- /dev/null +++ b/src/lib/krb4/et_errtxt.awk @@ -0,0 +1,71 @@ +/^[ \t]*(error_table|et)[ \t]+[a-zA-Z][a-zA-Z0-9_]+/ { + print "/*" > outfile + print " * " outfile ":" > outfile + print " * This file is automatically generated; please do not edit it." > outfile + print " */" > outfile + print "#if TARGET_OS_MAC" > outfile + print "const char * const * const krb_err_txt" > outfile + print "#else" > outfile + print "const char * const krb_err_txt[]" > outfile + print "#endif" > outfile + print "\t= {" > outfile + table_item_count = 0 +} + +(continuation == 1) && ($0 ~ /\\[ \t]*$/) { + text=substr($0,1,length($0)-1); +# printf "\t\t\"%s\"\n", text > outfile + cont_buf=cont_buf text; +} + +(continuation == 1) && ($0 ~ /"[ \t]*$/) { +# " +# printf "\t\t\"%s,\n", $0 > outfile + printf "\t%s,\n", cont_buf $0 > outfile + continuation = 0; +} +/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*$/ { + table_item_count++ + skipone=1 + next +} + +/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*".*"[ \t]*$/ { + text="" + for (i=3; i<=NF; i++) { + text = text FS $i + } + text=substr(text,2,length(text)-1); + printf "\t%s,\n", text > outfile + table_item_count++ +} +/^[ \t]*(error_code|ec)[ \t]+[A-Z_0-9]+,[ \t]*".*\\[ \t]*$/ { + text="" + for (i=3; i<=NF; i++) { + text = text FS $i + } + text=substr(text,2,length(text)-2); +# printf "\t%s\"\n", text > outfile + cont_buf=text + continuation++; +} + +/^[ \t]*".*\\[ \t]*$/ { + if (skipone) { + text=substr($0,1,length($0)-1); +# printf "\t%s\"\n", text > outfile + cont_buf=text + continuation++; + } + skipone=0 +} + +{ + if (skipone) { + printf "\t%s,\n", $0 > outfile + } + skipone=0 +} +END { + print "};" > outfile +}