iPXE
params.h
Go to the documentation of this file.
1 #ifndef _IPXE_PARAMS_H
2 #define _IPXE_PARAMS_H
3 
4 /** @file
5  *
6  * Request parameters
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <ipxe/list.h>
13 #include <ipxe/refcnt.h>
14 
15 /** A request parameter list */
16 struct parameters {
17  /** Reference count */
18  struct refcnt refcnt;
19  /** List of all parameter lists */
20  struct list_head list;
21  /** Name */
22  const char *name;
23  /** Parameters */
25 };
26 
27 /** A request parameter */
28 struct parameter {
29  /** List of request parameters */
30  struct list_head list;
31  /** Key */
32  const char *key;
33  /** Value */
34  const char *value;
35  /** Flags */
36  unsigned int flags;
37 };
38 
39 /** Request parameter is a form parameter */
40 #define PARAMETER_FORM 0x0001
41 
42 /** Request parameter is a header parameter */
43 #define PARAMETER_HEADER 0x0002
44 
45 /**
46  * Increment request parameter list reference count
47  *
48  * @v params Parameter list, or NULL
49  * @ret params Parameter list as passed in
50  */
51 static inline __attribute__ (( always_inline )) struct parameters *
52 params_get ( struct parameters *params ) {
53  ref_get ( &params->refcnt );
54  return params;
55 }
56 
57 /**
58  * Decrement request parameter list reference count
59  *
60  * @v params Parameter list, or NULL
61  */
62 static inline __attribute__ (( always_inline )) void
63 params_put ( struct parameters *params ) {
64  ref_put ( &params->refcnt );
65 }
66 
67 /**
68  * Claim ownership of request parameter list
69  *
70  * @v params Parameter list
71  * @ret params Parameter list
72  */
73 static inline __attribute__ (( always_inline )) struct parameters *
74 claim_parameters ( struct parameters *params ) {
75 
76  /* Remove from list of parameter lists */
77  list_del ( &params->list );
78 
79  return params;
80 }
81 
82 /** Iterate over all request parameters in a list */
83 #define for_each_param( param, params ) \
84  list_for_each_entry ( (param), &(params)->entries, list )
85 
86 extern struct parameters * find_parameters ( const char *name );
87 extern struct parameters * create_parameters ( const char *name );
88 extern struct parameter * add_parameter ( struct parameters *params,
89  const char *key, const char *value,
90  unsigned int flags );
91 
92 #endif /* _IPXE_PARAMS_H */
const char * name
Definition: ath9k_hw.c:1984
struct parameters * find_parameters(const char *name)
Find request parameter list by name.
Definition: params.c:68
A request parameter list.
Definition: params.h:16
unsigned int flags
Flags.
Definition: params.h:36
struct parameters * create_parameters(const char *name)
Create request parameter list.
Definition: params.c:86
A doubly-linked list entry (or list head)
Definition: list.h:18
A reference counter.
Definition: refcnt.h:26
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct refcnt refcnt
Reference count.
Definition: params.h:18
struct parameter * add_parameter(struct parameters *params, const char *key, const char *value, unsigned int flags)
Add request parameter.
Definition: params.c:129
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
Linked lists.
uint8_t flags
Flags.
Definition: ena.h:18
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
struct list_head entries
Parameters.
Definition: params.h:24
struct list_head list
List of request parameters.
Definition: params.h:30
const char * name
Name.
Definition: params.h:22
struct list_head list
List of all parameter lists.
Definition: params.h:20
static __attribute__((always_inline)) struct parameters *params_get(struct parameters *params)
Increment request parameter list reference count.
Definition: params.h:51
Reference counting.
const char * value
Value.
Definition: params.h:34
A request parameter.
Definition: params.h:28
const char * key
Key.
Definition: params.h:32
union @383 key
Sense key.
Definition: scsi.h:18
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106