Simon Josefsson <[EMAIL PROTECTED]> writes:

> (Since the error contained gss_name_t, I'm assuming you tried the
> gss-lsh branch, and I hope it is OK to provide support for it on this
> list.)

That's perfectly ok with me. I'm sorry I haven't yet had the time to
look into your gss code carefully and integrate it into my own tree.

> This point out a problem with the GABA header creation: how can I make
> the GABA stuff respect #if WITH_GSS?  If someone doesn't have
> WITH_GSS, the gss header files won't be included, and gss_name_t won't
> be defined when the generated client_userauth.h is parsed.  The types
> aren't used when WITH_GSS is 0, so they shouldn't be extracted by the
> GABA stuff.  Perhaps GABA should run the file through CPP?

I've been considering doing some kind of preprocessing on GABA
expressions earlier, but so far I have been able to get by without
that. The easiest way is to put the code that depends on WITH_GSS in a
separate file, layouted like this:

  #if HAVE_CONFIG_H
  #include "config.h"
  #endif
  
  #if WITH_GSS
  #include <gss.h>
  
  #include "gss.c.x"
  
  /* GABA:
     (class
       (name gss_foo)
       (vars
         (name . gss_name_t)))
  */
  
  /* Various functions using gss_foo */
  ...
  
  #endif /* WITH_GSS */

The file zlib.c is an example of that. I think it make sense also for
other reasons to isolate dependencies on special libraries into
separate files. A different and uglier way is to use dummy
definitions:

  #if HAVE_CONFIG_H
  #include "config.h"
  #endif

  #if WITH_GSS
  #include <gss.h>
  #else
  /* Dummy definitions */
  typdef int gss_name_t;
  #endif
  
  #include "gss.c.x"
  
  /* GABA:
     (class
       (name gss_foo)
       (vars
         (name . gss_name_t)))
  */

  #if WITH_GSS
  /* Code that depends on real gss definitions */
  ...
  #endif /* WITH_GSS */

As for adding proper cpp support to GABA, one way of doing that is
introducing a new keyword "condition". It would be used like

  /* GABA:
     (class
       (name gss_foo)
       (condition "WITH_GSS")
       (vars
         (name . gss_name_t)))
  */

When this expression is processed by gaba.scm, it should emit "#if
WITH_GSS"/#endif-guards around all the generated declarations and
definitions. Such a hack would go into the process-class function in
src/scm/gaba.scm (the code would need a little more restructuring to
get cpp conditions not only for expressions of type "class", but also for
"meta", "struct" and "expr"). An untested patch included below ;-)

Regards,
/Niels


Index: src/scm/gaba.scm
===================================================================
RCS file: /cvsroot/lsh/lsh/src/scm/gaba.scm,v
retrieving revision 1.15
diff -u -a -r1.15 gaba.scm
--- src/scm/gaba.scm    23 Feb 2003 18:08:58 -0000      1.15
+++ src/scm/gaba.scm    16 Aug 2003 10:42:24 -0000
@@ -121,7 +121,7 @@
   (for-each (lambda (o)
              (cond ((procedure? o) (o level))
                    ((list? o) (apply out (+ 1 level) o))
-                   (else (display o))))
+                   ((not (null? o)) (display o))))
            args))

 ; This isn't very optimal
@@ -443,6 +443,7 @@

 (define (process-class attributes)
   (let* ((name (get 'name attributes cadr))
+        (condition (get 'condition attributes cadr))
         (super (get 'super attributes cadr))
         (vars (preprocess-vars name (get 'vars attributes cdr)))
         (meta (get 'meta attributes cadr))
@@ -453,6 +454,7 @@
          (free-function (make-free-function name vars)))
                                        ; (werror "baar\n")
       (c-append (class-annotate name super meta)
+               (and condition (c-append "#if " condition "\n"))
                "#ifndef GABA_DEFINE\n"
                (make-instance-struct name super vars)
                (if meta
@@ -467,7 +469,8 @@
                (or free-function "")
                (make-class name super mark-function free-function
                            meta methods)
-               "#endif /* !GABA_DECLARE */\n\n"))))
+               "#endif /* !GABA_DECLARE */\n\n"
+               (and condition (c-append "#endif /* " condition " */\n")) ))))

 (define (process-meta attributes)
   (let ((name (get 'name attributes cadr))
_______________________________________________
lsh-bugs mailing list
[EMAIL PROTECTED]
http://lists.lysator.liu.se/mailman/listinfo/lsh-bugs

Reply via email to