xref: /netbsd-src/external/bsd/libevent/dist/include/event2/keyvalq_struct.h (revision 805a1ce9000bc0ec0951bf35f7e52b85cafb37e2)
1*805a1ce9Schristos /*	$NetBSD: keyvalq_struct.h,v 1.1.1.3 2017/01/31 21:14:53 christos Exp $	*/
26ecf6635Schristos /*
36ecf6635Schristos  * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
46ecf6635Schristos  * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
56ecf6635Schristos  *
66ecf6635Schristos  * Redistribution and use in source and binary forms, with or without
76ecf6635Schristos  * modification, are permitted provided that the following conditions
86ecf6635Schristos  * are met:
96ecf6635Schristos  * 1. Redistributions of source code must retain the above copyright
106ecf6635Schristos  *    notice, this list of conditions and the following disclaimer.
116ecf6635Schristos  * 2. Redistributions in binary form must reproduce the above copyright
126ecf6635Schristos  *    notice, this list of conditions and the following disclaimer in the
136ecf6635Schristos  *    documentation and/or other materials provided with the distribution.
146ecf6635Schristos  * 3. The name of the author may not be used to endorse or promote products
156ecf6635Schristos  *    derived from this software without specific prior written permission.
166ecf6635Schristos  *
176ecf6635Schristos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
186ecf6635Schristos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
196ecf6635Schristos  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
206ecf6635Schristos  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
216ecf6635Schristos  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
226ecf6635Schristos  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236ecf6635Schristos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246ecf6635Schristos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256ecf6635Schristos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
266ecf6635Schristos  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276ecf6635Schristos  */
28*805a1ce9Schristos #ifndef EVENT2_KEYVALQ_STRUCT_H_INCLUDED_
29*805a1ce9Schristos #define EVENT2_KEYVALQ_STRUCT_H_INCLUDED_
306ecf6635Schristos 
316ecf6635Schristos #ifdef __cplusplus
326ecf6635Schristos extern "C" {
336ecf6635Schristos #endif
346ecf6635Schristos 
356ecf6635Schristos /* Fix so that people don't have to run with <sys/queue.h> */
366ecf6635Schristos /* XXXX This code is duplicated with event_struct.h */
376ecf6635Schristos #ifndef TAILQ_ENTRY
38*805a1ce9Schristos #define EVENT_DEFINED_TQENTRY_
396ecf6635Schristos #define TAILQ_ENTRY(type)						\
406ecf6635Schristos struct {								\
416ecf6635Schristos 	struct type *tqe_next;	/* next element */			\
426ecf6635Schristos 	struct type **tqe_prev;	/* address of previous next element */	\
436ecf6635Schristos }
446ecf6635Schristos #endif /* !TAILQ_ENTRY */
456ecf6635Schristos 
466ecf6635Schristos #ifndef TAILQ_HEAD
47*805a1ce9Schristos #define EVENT_DEFINED_TQHEAD_
486ecf6635Schristos #define TAILQ_HEAD(name, type)			\
496ecf6635Schristos struct name {					\
506ecf6635Schristos 	struct type *tqh_first;			\
516ecf6635Schristos 	struct type **tqh_last;			\
526ecf6635Schristos }
536ecf6635Schristos #endif
546ecf6635Schristos 
556ecf6635Schristos /*
566ecf6635Schristos  * Key-Value pairs.  Can be used for HTTP headers but also for
576ecf6635Schristos  * query argument parsing.
586ecf6635Schristos  */
596ecf6635Schristos struct evkeyval {
606ecf6635Schristos 	TAILQ_ENTRY(evkeyval) next;
616ecf6635Schristos 
626ecf6635Schristos 	char *key;
636ecf6635Schristos 	char *value;
646ecf6635Schristos };
656ecf6635Schristos 
666ecf6635Schristos TAILQ_HEAD (evkeyvalq, evkeyval);
676ecf6635Schristos 
686ecf6635Schristos /* XXXX This code is duplicated with event_struct.h */
69*805a1ce9Schristos #ifdef EVENT_DEFINED_TQENTRY_
706ecf6635Schristos #undef TAILQ_ENTRY
716ecf6635Schristos #endif
726ecf6635Schristos 
73*805a1ce9Schristos #ifdef EVENT_DEFINED_TQHEAD_
746ecf6635Schristos #undef TAILQ_HEAD
756ecf6635Schristos #endif
766ecf6635Schristos 
776ecf6635Schristos #ifdef __cplusplus
786ecf6635Schristos }
796ecf6635Schristos #endif
806ecf6635Schristos 
816ecf6635Schristos #endif
82