Skip to content
Snippets Groups Projects
Select Git revision
  • 866e78ba1bdb7e3ceb6f27bb3712ea0ee85fe8a8
  • master default protected
  • experimental
3 results

01_why_linux.md

Blame
  • labcomm_type_signature.h 3.45 KiB
    #ifndef LABCOMM_TYPE_SIGNATURE_H
    #define LABCOMM_TYPE_SIGNATURE_H
    
    //XXX move to common.h
    #ifndef labcomm_bool
    #define labcomm_bool char
    #define TRUE 1
    #define FALSE 0
    #endif
    
    /*
     * Signature entry
     */
    #ifndef LABCOMM_NO_TYPEDECL
    #ifdef USE_UNIONS
    
    /* Useful for C99 and up (or GCC without -pedantic) */ 
    
    #define LABCOMM_SIGDEF_BYTES_OR_SIGNATURE          \
      union {                                   \
        char *bytes;                            \
        struct labcomm_signature* signature;            \
      } u;
    
    #define LABCOMM_SIGDEF_BYTES(l, b) { l, .u.bytes=b }
    #define LABCOMM_SIGDEF_SIGNATURE(s) { 0, .u.signature=&s } // addressof, as s is pointing at the sig struct, not directly the the sig_bytes[]
    #define LABCOMM_SIGDEF_END { -1, .u.bytes=0 }
    
    #else
    
    #define LABCOMM_SIGDEF_BYTES_OR_SIGNATURE          \
      struct {                                  \
        char *bytes;                            \
        const struct labcomm_signature *signature;            \
      } u;
    
    #define LABCOMM_SIGDEF_BYTES(l, b) { l, { b, 0 } }
    #define LABCOMM_SIGDEF_SIGNATURE(s) { 0, { 0, &s } }
    #define LABCOMM_SIGDEF_END { -1, { 0, 0 } }
    
    #endif
    
    struct labcomm_signature_data {
      int length;
      LABCOMM_SIGDEF_BYTES_OR_SIGNATURE
    };
    
    #endif
    struct labcomm_signature {
      char *name;
      int (*encoded_size)(void *); /* void* refers to sample_data */
      int size;
      unsigned char *signature; 
      int index;
    #ifndef LABCOMM_NO_TYPEDECL
      int tdsize;
      struct labcomm_signature_data *treedata;
    #endif  
    #ifdef LABCOMM_EXPERIMENTAL_CACHED_ENCODED_SIZE
      int cached_encoded_size; // -1 if not initialized or type is variable size
    #endif
    };
    
    /* a struct for "raw" type_defs, to be used as an intermediate representation
     * between decoder and signature parser
     */
    
    struct labcomm_raw_type_def {
        char *name;
        int index;