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
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13/** An editable string */
15 /** Dynamically allocated string buffer */
16 char **buf;
17 /** Cursor position */
18 unsigned int cursor;
19
20 /* The following items are the edit history */
21
22 /** Last cursor position */
23 unsigned int last_cursor;
24 /** Start of modified portion of string */
25 unsigned int mod_start;
26 /** End of modified portion of string */
27 unsigned int mod_end;
28};
29
30/**
31 * Initialise editable string
32 *
33 * @v string Editable string
34 * @v buf Dynamically allocated string buffer
35 *
36 * The @c buf parameter must be the address of a caller-provided
37 * pointer to a NUL-terminated string allocated using malloc() (or
38 * equivalent, such as strdup()). Any edits made to the string will
39 * realloc() the string buffer as needed.
40 *
41 * The caller may choose leave the initial string buffer pointer as @c
42 * NULL, in which case it will be allocated upon the first attempt to
43 * insert a character into the buffer. If the caller does this, then
44 * it must be prepared to find the pointer still @c NULL after
45 * editing, since the user may never attempt to insert any characters.
46 */
47static inline __nonnull void init_editstring ( struct edit_string *string,
48 char **buf ) {
49
50 string->buf = buf;
51}
52
53extern __attribute__ (( nonnull ( 1 ) )) int
54replace_string ( struct edit_string *string, const char *replacement );
55
56extern __nonnull int edit_string ( struct edit_string *string, int key );
57
58#endif /* _IPXE_EDITSTRING_H */
union @162305117151260234136356364136041353210355154177 key
Sense key.
Definition scsi.h:3
int replace_string(struct edit_string *string, const char *replacement)
Replace editable string.
Definition editstring.c:229
const char * replacement
Definition editstring.h:54
static __nonnull void init_editstring(struct edit_string *string, char **buf)
Initialise editable string.
Definition editstring.h:47
#define __nonnull
Declare a function's pointer parameters as non-null - i.e.
Definition compiler.h:592
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
An editable string.
Definition editstring.h:14
unsigned int mod_end
End of modified portion of string.
Definition editstring.h:27
unsigned int last_cursor
Last cursor position.
Definition editstring.h:23
char ** buf
Dynamically allocated string buffer.
Definition editstring.h:16
unsigned int mod_start
Start of modified portion of string.
Definition editstring.h:25
unsigned int cursor
Cursor position.
Definition editstring.h:18