Annotation of embedaddon/mpd/src/contrib/libpdel/structs/type/struct.h, revision 1.1
1.1 ! misho 1:
! 2: /*
! 3: * Copyright (c) 2001-2002 Packet Design, LLC.
! 4: * All rights reserved.
! 5: *
! 6: * Subject to the following obligations and disclaimer of warranty,
! 7: * use and redistribution of this software, in source or object code
! 8: * forms, with or without modifications are expressly permitted by
! 9: * Packet Design; provided, however, that:
! 10: *
! 11: * (i) Any and all reproductions of the source or object code
! 12: * must include the copyright notice above and the following
! 13: * disclaimer of warranties; and
! 14: * (ii) No rights are granted, in any manner or form, to use
! 15: * Packet Design trademarks, including the mark "PACKET DESIGN"
! 16: * on advertising, endorsements, or otherwise except as such
! 17: * appears in the above copyright notice or in the software.
! 18: *
! 19: * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
! 20: * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
! 21: * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
! 22: * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
! 23: * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
! 24: * OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
! 25: * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
! 26: * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
! 27: * RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE
! 28: * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
! 29: * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
! 30: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
! 31: * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
! 32: * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
! 33: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 34: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
! 35: * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
! 36: * THE POSSIBILITY OF SUCH DAMAGE.
! 37: *
! 38: * Author: Archie Cobbs <archie@freebsd.org>
! 39: */
! 40:
! 41: #ifndef _PDEL_STRUCTS_TYPE_STRUCT_H_
! 42: #define _PDEL_STRUCTS_TYPE_STRUCT_H_
! 43:
! 44: /*********************************************************************
! 45: STRUCTURE TYPES
! 46: *********************************************************************/
! 47:
! 48: /* This structure describes one field in a structure */
! 49: struct structs_field {
! 50: const char *name;
! 51: const struct structs_type *type;
! 52: u_int16_t size;
! 53: u_int16_t offset;
! 54: };
! 55:
! 56: /* Use this to describe a field and name it with the field's C name */
! 57: #define STRUCTS_STRUCT_FIELD(sname, fname, ftype) \
! 58: { #fname, ftype, sizeof(((struct sname *)0)->fname), \
! 59: offsetof(struct sname, fname) }
! 60:
! 61: /* Use this to describe a field and give it a different name */
! 62: #define STRUCTS_STRUCT_FIELD2(sname, fname, dname, ftype) \
! 63: { dname, ftype, sizeof(((struct sname *)0)->fname), \
! 64: offsetof(struct sname, fname) }
! 65:
! 66: /* This macro terminates a list of 'struct structs_field' structures */
! 67: #define STRUCTS_STRUCT_FIELD_END { NULL, NULL, 0, 0 }
! 68:
! 69: /*
! 70: *
! 71: * Macro arguments:
! 72: * name Structure name (as in 'struct name')
! 73: * [const struct structs_field *] List of structure fields, terminated
! 74: * by an entry with name == NULL.
! 75: */
! 76: #define STRUCTS_STRUCT_TYPE(sname, flist) { \
! 77: sizeof(struct sname), \
! 78: "structure", \
! 79: STRUCTS_TYPE_STRUCTURE, \
! 80: structs_struct_init, \
! 81: structs_struct_copy, \
! 82: structs_struct_equal, \
! 83: structs_notsupp_ascify, \
! 84: structs_notsupp_binify, \
! 85: structs_struct_encode, \
! 86: structs_struct_decode, \
! 87: structs_struct_free, \
! 88: { { (void *)(flist) }, { NULL }, { NULL } } \
! 89: }
! 90:
! 91: __BEGIN_DECLS
! 92:
! 93: extern structs_init_t structs_struct_init;
! 94: extern structs_copy_t structs_struct_copy;
! 95: extern structs_equal_t structs_struct_equal;
! 96: extern structs_encode_t structs_struct_encode;
! 97: extern structs_decode_t structs_struct_decode;
! 98: extern structs_uninit_t structs_struct_free;
! 99:
! 100: __END_DECLS
! 101:
! 102: #endif /* _PDEL_STRUCTS_TYPE_STRUCT_H_ */
! 103:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>