iPXE
editstring.h
Go to the documentation of this file.
1 #ifndef _IPXE_EDITSTRING_H
2 #define _IPXE_EDITSTRING_H
3 
4 /** @file
5  *
6  * Editable strings
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 /** An editable string */
13 struct edit_string {
14  /** Buffer for string */
15  char *buf;
16  /** Size of buffer (including terminating NUL) */
17  size_t len;
18  /** Cursor position */
19  unsigned int cursor;
20 
21  /* The following items are the edit history */
22 
23  /** Last cursor position */
24  unsigned int last_cursor;
25  /** Start of modified portion of string */
26  unsigned int mod_start;
27  /** End of modified portion of string */
28  unsigned int mod_end;
29 };
30 
31 /**
32  * Initialise editable string
33  *
34  * @v string Editable string
35  * @v buf Buffer for string
36  * @v len Length of buffer
37  */
38 static inline void init_editstring ( struct edit_string *string, char *buf,
39  size_t len ) {
40  string->buf = buf;
41  string->len = len;
42 }
43 
44 extern void replace_string ( struct edit_string *string,
45  const char *replacement ) __nonnull;
46 extern int edit_string ( struct edit_string *string, int key ) __nonnull;
47 
48 #endif /* _IPXE_EDITSTRING_H */
unsigned int cursor
Cursor position.
Definition: editstring.h:19
size_t len
Size of buffer (including terminating NUL)
Definition: editstring.h:17
unsigned int last_cursor
Last cursor position.
Definition: editstring.h:24
#define __nonnull
Declare a function's pointer parameters as non-null - i.e.
Definition: compiler.h:592
static void init_editstring(struct edit_string *string, char *buf, size_t len)
Initialise editable string.
Definition: editstring.h:38
uint32_t len
Length.
Definition: ena.h:14
int edit_string(struct edit_string *string, int key) __nonnull
Edit editable string.
Definition: editstring.c:195
An editable string.
Definition: editstring.h:13
unsigned int mod_start
Start of modified portion of string.
Definition: editstring.h:26
unsigned int mod_end
End of modified portion of string.
Definition: editstring.h:28
void replace_string(struct edit_string *string, const char *replacement) __nonnull
Replace editable string.
Definition: editstring.c:173
union @375 key
Sense key.
Definition: scsi.h:18
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
char * buf
Buffer for string.
Definition: editstring.h:15