aboutsummaryrefslogtreecommitdiffstats
path: root/src/word.h
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2024-07-04 13:57:22 -0400
committerEugene Triguba <eugenetriguba@gmail.com>2024-07-04 13:57:22 -0400
commit4ddc17ed9c1778aef0320304801492ad9c30450e (patch)
treec76c72f43b78f5720c08d159aa75d1631b35373f /src/word.h
parentTweak linebuffer (diff)
downloadcli-4ddc17ed9c1778aef0320304801492ad9c30450e.zip
Tweak tests and read_word impl
Diffstat (limited to 'src/word.h')
-rw-r--r--src/word.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/word.h b/src/word.h
index 327116e..b5d94b5 100644
--- a/src/word.h
+++ b/src/word.h
@@ -3,9 +3,16 @@
#include <stdio.h>
+#define READ_WORD_ERR_READ -1
+#define READ_WORD_ERR_EOF 0
+#define READ_WORD_SUCCESS 1
+
/**
* Read in a word from a file up to size length.
*
+ * If there is any leading whitespace, it will be discarded
+ * before starting to read in a word.
+ *
* @param[in] fp The file to read a word from.
* @param[out] word The word that was read as a null-terminated string.
* @param[in] length The length of the word to read in.
@@ -13,6 +20,8 @@
* @note `length` should be the number of characters you'd
* like to read in plus one to take into account the
* null terminator.
+ *
+ * @returns < 0 on read error; 0 on EOF; > 0 on success.
*/
int read_word(FILE *fp, char *word, size_t length);