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  * Form 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 form 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 form parameter */
28 struct parameter {
29  /** List of form parameters */
30  struct list_head list;
31  /** Key */
32  const char *key;
33  /** Value */
34  const char *value;
35 };
36 
37 /**
38  * Increment form parameter list reference count
39  *
40  * @v params Parameter list, or NULL
41  * @ret params Parameter list as passed in
42  */
43 static inline __attribute__ (( always_inline )) struct parameters *
44 params_get ( struct parameters *params ) {
45  ref_get ( &params->refcnt );
46  return params;
47 }
48 
49 /**
50  * Decrement form parameter list reference count
51  *
52  * @v params Parameter list, or NULL
53  */
54 static inline __attribute__ (( always_inline )) void
55 params_put ( struct parameters *params ) {
56  ref_put ( &params->refcnt );
57 }
58 
59 /**
60  * Claim ownership of form parameter list
61  *
62  * @v params Parameter list
63  * @ret params Parameter list
64  */
65 static inline __attribute__ (( always_inline )) struct parameters *
66 claim_parameters ( struct parameters *params ) {
67 
68  /* Remove from list of parameter lists */
69  list_del ( &params->list );
70 
71  return params;
72 }
73 
74 /** Iterate over all form parameters in a list */
75 #define for_each_param( param, params ) \
76  list_for_each_entry ( (param), &(params)->entries, list )
77 
78 extern struct parameters * find_parameters ( const char *name );
79 extern struct parameters * create_parameters ( const char *name );
80 extern struct parameter * add_parameter ( struct parameters *params,
81  const char *key, const char *value );
82 
83 #endif /* _IPXE_PARAMS_H */
const char * name
Definition: ath9k_hw.c:1984
struct parameters * find_parameters(const char *name)
Find form parameter list by name.
Definition: params.c:68
A form parameter list.
Definition: params.h:16
struct parameters * create_parameters(const char *name)
Create form 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
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
Linked lists.
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 form 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 form parameter list reference count.
Definition: params.h:43
Reference counting.
struct parameter * add_parameter(struct parameters *params, const char *key, const char *value)
Add form parameter.
Definition: params.c:128
const char * value
Value.
Definition: params.h:34
A form parameter.
Definition: params.h:28
const char * key
Key.
Definition: params.h:32
union @375 key
Sense key.
Definition: scsi.h:18
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106