iPXE
editstring.h
Go to the documentation of this file.
00001 #ifndef _IPXE_EDITSTRING_H
00002 #define _IPXE_EDITSTRING_H
00003 
00004 /** @file
00005  *
00006  * Editable strings
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 /** An editable string */
00013 struct edit_string {
00014         /** Buffer for string */
00015         char *buf;
00016         /** Size of buffer (including terminating NUL) */
00017         size_t len;
00018         /** Cursor position */
00019         unsigned int cursor;
00020 
00021         /* The following items are the edit history */
00022 
00023         /** Last cursor position */
00024         unsigned int last_cursor;
00025         /** Start of modified portion of string */
00026         unsigned int mod_start;
00027         /** End of modified portion of string */
00028         unsigned int mod_end;
00029 };
00030 
00031 /**
00032  * Initialise editable string
00033  *
00034  * @v string            Editable string
00035  * @v buf               Buffer for string
00036  * @v len               Length of buffer
00037  */
00038 static inline void init_editstring ( struct edit_string *string, char *buf,
00039                                      size_t len ) {
00040         string->buf = buf;
00041         string->len = len;
00042 }
00043 
00044 extern void replace_string ( struct edit_string *string,
00045                              const char *replacement ) __nonnull;
00046 extern int edit_string ( struct edit_string *string, int key ) __nonnull;
00047 
00048 #endif /* _IPXE_EDITSTRING_H */