[Spice-devel] [PATCH libcacard 2/3] libcacard: add a warning for libcacard.h inclusion

Marc-André Lureau mlureau at redhat.com
Thu Nov 19 08:03:07 PST 2015



----- Original Message -----
> On 11/19/2015 10:30 AM, Marc-André Lureau wrote:
> > Only libcacard.h should be included directly.
> 
> ACK, although I don't really like this kind of restriction but it seems
> to be a convention with the project, so fine with me.

It's a convention in more and more gnome-like project. I think it helps with simplifying library usage and future enhancement or code reorgnization. We recently did the same conversion of spice-gtk for ex.

> 
> The series is ok, except by the inclusion of glib.h in libcacard.h.
> 
> 
> > 
> > Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
> > ---
> >  Makefile.am           | 1 +
> >  src/cac.h             | 5 +++++
> >  src/capcsc.h          | 4 ++++
> >  src/card_7816.c       | 4 ++++
> >  src/card_7816.h       | 4 ++++
> >  src/card_7816t.h      | 4 ++++
> >  src/eventt.h          | 5 +++++
> >  src/libcacard.h       | 2 ++
> >  src/vcard.h           | 4 ++++
> >  src/vcard_emul.h      | 4 ++++
> >  src/vcard_emul_type.h | 5 +++++
> >  src/vcardt.h          | 4 ++++
> >  src/vevent.h          | 5 +++++
> >  src/vreader.h         | 4 ++++
> >  src/vreadert.h        | 4 ++++
> >  src/vscard_common.h   | 4 ++++
> >  16 files changed, 63 insertions(+)
> > 
> > diff --git a/Makefile.am b/Makefile.am
> > index 07df869..4d9c7f8 100644
> > --- a/Makefile.am
> > +++ b/Makefile.am
> > @@ -71,6 +71,7 @@ tests_libcacard_LDADD = libcacard.la $(GTHREAD_LIBS)
> >  
> >  AM_CPPFLAGS =					\
> >  	-DG_LOG_DOMAIN=\"libcacard\"		\
> > +	-DLIBCACARD_COMPILATION			\
> >  	$(CACARD_CFLAGS)			\
> >  	$(CODE_COVERAGE_CFLAGS)			\
> >  	$(PCSC_CFLAGS)				\
> > diff --git a/src/cac.h b/src/cac.h
> > index a91b88f..26b4379 100644
> > --- a/src/cac.h
> > +++ b/src/cac.h
> > @@ -7,6 +7,11 @@
> >   */
> >  #ifndef CAC_H
> >  #define CAC_H 1
> > +
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  #include "vcard.h"
> >  #include "vreader.h"
> >  
> > diff --git a/src/capcsc.h b/src/capcsc.h
> > index bb59a4e..4696499 100644
> > --- a/src/capcsc.h
> > +++ b/src/capcsc.h
> > @@ -5,6 +5,10 @@
> >  #ifndef CAPCSC_H
> >  #define CAPCSC_H 1
> >  
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  #define CAPCSC_POLL_TIME            50      /* ms  - Time we will poll for
> >  */
> >                                              /*       card change when a
> >                                              */
> >                                              /*       reader is connected
> >                                              */
> > diff --git a/src/card_7816.c b/src/card_7816.c
> > index 8b12689..4baa207 100644
> > --- a/src/card_7816.c
> > +++ b/src/card_7816.c
> > @@ -13,6 +13,10 @@
> >  #include "vcard_emul.h"
> >  #include "card_7816.h"
> >  
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  /*
> >   * set the status bytes based on the status word
> >   */
> > diff --git a/src/card_7816.h b/src/card_7816.h
> > index 30b6d09..90588b9 100644
> > --- a/src/card_7816.h
> > +++ b/src/card_7816.h
> > @@ -7,6 +7,10 @@
> >  #ifndef CARD_7816_H
> >  #define CARD_7816_H  1
> >  
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  #include "card_7816t.h"
> >  #include "vcardt.h"
> >  
> > diff --git a/src/card_7816t.h b/src/card_7816t.h
> > index 8e78444..14c1fae 100644
> > --- a/src/card_7816t.h
> > +++ b/src/card_7816t.h
> > @@ -7,6 +7,10 @@
> >  #ifndef CARD_7816T_H
> >  #define CARD_7816T_H 1
> >  
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  typedef unsigned short vcard_7816_status_t;
> >  
> >  struct VCardResponseStruct {
> > diff --git a/src/eventt.h b/src/eventt.h
> > index af1de1a..d676591 100644
> > --- a/src/eventt.h
> > +++ b/src/eventt.h
> > @@ -5,6 +5,11 @@
> >  
> >  #ifndef EVENTT_H
> >  #define EVENTT_H 1
> > +
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  #include "vreadert.h"
> >  #include "vcardt.h"
> >  
> > diff --git a/src/libcacard.h b/src/libcacard.h
> > index d048472..0770d13 100644
> > --- a/src/libcacard.h
> > +++ b/src/libcacard.h
> > @@ -5,6 +5,8 @@
> >  #ifndef LIBCACARD_H
> >  #define LIBCACARD_H
> >  
> > +#define __LIBCACARD_H_INSIDE__
> > +
> >  #include "cac.h"
> >  #include "card_7816.h"
> >  #include "card_7816t.h"
> > diff --git a/src/vcard.h b/src/vcard.h
> > index 1364dfb..9bc722c 100644
> > --- a/src/vcard.h
> > +++ b/src/vcard.h
> > @@ -5,6 +5,10 @@
> >  #ifndef VCARD_H
> >  #define VCARD_H 1
> >  
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  #include "vcardt.h"
> >  
> >  /*
> > diff --git a/src/vcard_emul.h b/src/vcard_emul.h
> > index a552efb..9dd7b3b 100644
> > --- a/src/vcard_emul.h
> > +++ b/src/vcard_emul.h
> > @@ -13,6 +13,10 @@
> >  #ifndef VCARD_EMUL_H
> >  #define VCARD_EMUL_H 1
> >  
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  #include "card_7816t.h"
> >  #include "vcard.h"
> >  #include "vcard_emul_type.h"
> > diff --git a/src/vcard_emul_type.h b/src/vcard_emul_type.h
> > index deea026..46e0782 100644
> > --- a/src/vcard_emul_type.h
> > +++ b/src/vcard_emul_type.h
> > @@ -10,6 +10,11 @@
> >  
> >  #ifndef VCARD_EMUL_TYPE_H
> >  #define VCARD_EMUL_TYPE_H 1
> > +
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  #include "vcardt.h"
> >  #include "vreadert.h"
> >  
> > diff --git a/src/vcardt.h b/src/vcardt.h
> > index 0589d13..db82b4b 100644
> > --- a/src/vcardt.h
> > +++ b/src/vcardt.h
> > @@ -5,6 +5,10 @@
> >  #ifndef VCARDT_H
> >  #define VCARDT_H 1
> >  
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  /*
> >   * these should come from some common spice header file
> >   */
> > diff --git a/src/vevent.h b/src/vevent.h
> > index 80c7eb7..640ea41 100644
> > --- a/src/vevent.h
> > +++ b/src/vevent.h
> > @@ -4,6 +4,11 @@
> >   */
> >  #ifndef EVENT_H
> >  #define EVENT_H 1
> > +
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  #include "eventt.h"
> >  #include "vreadert.h"
> >  #include "vcardt.h"
> > diff --git a/src/vreader.h b/src/vreader.h
> > index dd9414a..4aa75ed 100644
> > --- a/src/vreader.h
> > +++ b/src/vreader.h
> > @@ -6,6 +6,10 @@
> >  #ifndef VREADER_H
> >  #define VREADER_H 1
> >  
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  #include "eventt.h"
> >  #include "vreadert.h"
> >  #include "vcardt.h"
> > diff --git a/src/vreadert.h b/src/vreadert.h
> > index 53078e0..085ac70 100644
> > --- a/src/vreadert.h
> > +++ b/src/vreadert.h
> > @@ -6,6 +6,10 @@
> >  #ifndef VREADERT_H
> >  #define VREADERT_H 1
> >  
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  typedef enum {
> >      VREADER_OK = 0,
> >      VREADER_NO_CARD,
> > diff --git a/src/vscard_common.h b/src/vscard_common.h
> > index f2a18e1..50079ec 100644
> > --- a/src/vscard_common.h
> > +++ b/src/vscard_common.h
> > @@ -22,6 +22,10 @@
> >  #ifndef VSCARD_COMMON_H
> >  #define VSCARD_COMMON_H
> >  
> > +#if !defined(__LIBCACARD_H_INSIDE__) && !defined(LIBCACARD_COMPILATION)
> > +#warning "Only <libcacard.h> can be included directly"
> > +#endif
> > +
> >  #include <stdint.h>
> >  #include <glib.h>
> >  
> > 
> 
> 
> --
> Eduardo de Barros Lima (Etrunko)
> Software Engineer - RedHat
> etrunko at redhat.com
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 


More information about the Spice-devel mailing list