Author: jcrouse Date: 2008-08-29 01:11:29 +0200 (Fri, 29 Aug 2008) New Revision: 3550
Modified: trunk/payloads/libpayload/include/libpayload.h trunk/payloads/libpayload/libc/readline.c Log: [PATCH]: libpayload: Document readline
No code changes.
Signed-off-by: Jordan Crouse jordan.crouse@amd.com Acked-by: Jordan Crouse jordan.crouse@amd.com
Modified: trunk/payloads/libpayload/include/libpayload.h =================================================================== --- trunk/payloads/libpayload/include/libpayload.h 2008-08-28 23:10:55 UTC (rev 3549) +++ trunk/payloads/libpayload/include/libpayload.h 2008-08-28 23:11:29 UTC (rev 3550) @@ -418,6 +418,9 @@
/** * @defgroup readline Readline Functions + * This interface provides a simple implementation of the standard + * readline and getline functions. They are suitable for reading a + * line of input from the console. * @{ */ char * readline(const char * prompt);
Modified: trunk/payloads/libpayload/libc/readline.c =================================================================== --- trunk/payloads/libpayload/libc/readline.c 2008-08-28 23:10:55 UTC (rev 3549) +++ trunk/payloads/libpayload/libc/readline.c 2008-08-28 23:11:29 UTC (rev 3550) @@ -27,16 +27,26 @@ * SUCH DAMAGE. */
+/** @file libc/readline.c + * @brief Simple readline implementation + */ + #include <libpayload.h>
static char * readline_buffer; static int readline_bufferlen;
/** - * This readline implementation is rather simple, but it does more than the - * original readline() because it allows us to have a pre-filled buffer. To - * pre-fill the buffer, use the getline() function. + * @brief Read a line from the terminal and return it + * @param prompt A prompt to display on the line + * @return A pointer to the input string + * + * Read a line from the terminal and return it. This readline implementation + * is rather simple, but it does more than the original readline() because + * it allows us to have a pre-filled buffer. To pre-fill the buffer, use the + * getline() function. */ + char * readline(const char * prompt) { char *buffer; @@ -50,7 +60,7 @@ }
buffer = readline_buffer; - + /* print prompt */ if (prompt) { current = 0; @@ -140,6 +150,18 @@ return buffer; }
+/** + * @brief Read a line from the input and store it in a buffer + * @param prompt A buffer to store the line in + * @param len Length of the buffer + * @return The final length of the string + * This function allows the user to pass a predefined buffer to + * readline(). The buffer may be filled with a default value + * which will be displayed by readline and can be edited as normal. + * The final input string returned by readline will be returned in + * the buffer and the function will return the length of the string. + */ + int getline(char *buffer, int len) { readline_buffer = buffer;