Fix ABI divergence between Unix and Mac krb4 libraries in declaration
authorTom Yu <tlyu@mit.edu>
Fri, 7 Feb 2003 21:39:44 +0000 (21:39 +0000)
committerTom Yu <tlyu@mit.edu>
Fri, 7 Feb 2003 21:39:44 +0000 (21:39 +0000)
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

src/ChangeLog
src/Makefile.in
src/include/kerberosIV/ChangeLog
src/include/kerberosIV/krb.h
src/lib/krb4/ChangeLog
src/lib/krb4/Makefile.in
src/lib/krb4/err_txt.c
src/lib/krb4/et_errtxt.awk [new file with mode: 0644]

index d936dd164c62cc9cb0a880cdb1fc0337354ab074..8f4618294ecbe782ee8f2f3cab94f2e77eb168eb 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-07  Tom Yu  <tlyu@mit.edu>
+
+       * Makefile.in: Add rules for generating lib/krb4/krb_err_txt.c for
+       Windows.
+
 2003-01-14  Ezra Peisach  <epeisach@bu.edu>
 
        * Makefile.in (check-unix): Invoke t_krbconf instead of struggling
index ad53c7e2341314b6996fa3ef9e06b220359fab88..be9a1db7efea21af0476707f49c8c13e9eefd712 100644 (file)
@@ -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
 
index 58eb897b87d9ac1233ba0fcc9418472abf34d470..6c13b9770389ad752e709c8985f7a6e0816296cc 100644 (file)
@@ -1,3 +1,7 @@
+2003-02-07  Tom Yu  <tlyu@mit.edu>
+
+       * krb.h: Declare krb_err_txt differently on Mac.
+
 2003-01-16  Ken Raeburn  <raeburn@mit.edu>
 
        * Makefile.in (all-unix, install): Build and install kadm_err.h.
index 9e9a151cef5aa7e6f221054bc62fd2b12d2c603b..684f509686899807a8a86c97c02cf6f07753f300 100644 (file)
@@ -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 *);
 
index ada0773b958ba1cea91abcd23a964604b65afe30..0ba4774f09d09fc2b03c9274d85f428419d50c8b 100644 (file)
@@ -1,3 +1,12 @@
+2003-02-07  Tom Yu  <tlyu@mit.edu>
+
+       * 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  <tlyu@mit.edu>
 
        * decomp_tkt.c (dcmp_tkt_int): Patch from Booker Bense to use
index bdb43f467409fad7c87c0b1d8c3cc6db0a3b550c..c9b9ff88919c225f0056fde7ce2d58d80680317c 100644 (file)
@@ -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
index 64663b3d7ef71fa0bad0672703083f38439619d9..57d346a4099c0d4f8000a4f94ce5ae78c4474b25 100644 (file)
 
 /*
  * 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
 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 (file)
index 0000000..888dad6
--- /dev/null
@@ -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
+}