xtrans

Nathanael Nerode neroden at twcny.rr.com
Thu May 19 22:44:27 PDT 2005


Keith Packard wrote:
>There's no real need -- xtrans cannot be used by any package which it
>doesn't know about.  Check out Xtrans.h; each user of xtrans has custom
>code in that file -- one for Xlib, one for the Xserver, XIM, Font
>server, font library, ICE, LBX.
>
>Xtrans is a spectacular example of encapsulation gone wrong...
>
>-keith

So I poked into this monstrosity a little.

All files are heavily ifdeffed on TRANS_CLIENT, TRANS_SERVER, and TRANS_REOPEN.
  * libX11/XIM, and the font server are TRANS_CLIENT
  * lbxproxy (although only the 'os' subdir uses it)
    and the Xserver are TRANS_SERVER
  * ICE is TRANS_CLIENT and TRANS_SERVER
  * the font library is TRANS_CLIENT, TRANS_SERVER, and TRANS_REOPEN

And of course I'm ignoring the per-system ifdefs.  It also seems to
depend on some other defines which are probably per-build.
* Xtrans.h:
  One clause for each user, renaming functions.
  With gratuitous support for pre-ANSI CPP.
  Extra clauses for libX11, ICE.
  -- and lbxproxy and the X server define libX11's special code, invoking
     its special cases, after Xtrans.h is included.  Boy oh boy.
* Xtransint.h:
  Relatively clean, oddly.
* transport.c:
  Ifdefs on enabled connection types.
  Special case for X server.
* Xtrans.c:
  Ifdefs on enabled connection types.  Special cases for font library/server.
* Xtransutil.c:
  Special case for libX11... which contains duplicated code from X.h and
  Xauth.h which "MUST" be kept in sync.  Great.  Completely different special
  case for ICE.

Oddly, the rest of these contain lots of almost-identical code, as each
handles a different connection type.  Gee.
* Xtransdnet.c:
  Special cases per user for DNETOBJ.  Additional special cases for libX11.
* Xtranslcl.c:
  Special cases per user for node name.
* Xtransos2.c:
  Special cases for X server.
* Xtranssock.c:
  Special cases per user for socket location (and *that* varies by system).
  Extra special cases for libX11.
* Xtranstli.c:
  Yep, special cases per user for node name.  Extra special case for libX11.

Hmm.  This should probably have been sliced differently.  
* The TRANS_SERVER and TRANS_CLIENT ifdefs are so pervasive that the files
  should perhaps be broken into client-only, server-only, and
  both-client-and-server pieces.  Not to mention TRANS_REOPEN.
* The per-user node name stuff should clearly be passed in in some sane way
  from the user's headers rather than via the scattered ifdefs currently used.
* Perhaps some of the redundant code for different transport types could be
  abstracted out as well; an awful lot of it seems to be generic error messages.
* libX11, ICE, and the X server have additional substantive variations which
  would have to be eliminated to make this a reasonable shared library.

It's very very tempting to suggest that each user be given its own copy,
at least as an interim measure.

Not only would it be work to convert this to a shared library, each user
would undoubtedly have to be converted individually because no two of them
are actually using the same code at the moment, even without regard to the
node name business. :-P  So the code has already diverged.

* libX11: TRANS_CLIENT plus libX11 specials 
* XIM: TRANS_CLIENT
* Xserver: TRANS_SERVER plus libX11 specials plus Xserver specials
* lbxproxy: TRANS_SERVER plus libX11 specials
* Font server: TRANS_CLIENT plus font specials
* Font library: TRANS_SERVER, TRANS_CLIENT, TRANS_REOPEN plus font specials
* ICE: TRANS_SERVER, TRANS_CLIENT plus ICE specials

-- 
This space intentionally left blank.


More information about the xorg-modular mailing list