#include #include #define EOL (-1) extern int getword2(char *lbuf, char *buf, size_t size, int first(char c), int rest(char c)); /* reads the next `word' from the string lbuf and stores it as a null-terminated string in buf[0..size-1] and returns the number of characters read from the buffer NOTE THAT THIS DIFFERS FROM getword, in that it returns the number of characters actually read, not the number of characters returned. When getword2 reaches the end of the string lbuf without consuming a word, it returns EOL. If a word is longer than size-1 characters, the excess characters are ignored. Excess characters are still counted in the return value, however. first and rest identify the characters that comprise a word: A word is a contiguous sequence of characters that begins with a character for which first returns nonzero followed by zero or more character for which rest returns nonzero. It is a checked runtime error for lbuf, buf, first, or rest to be NULL or for size to be 0. */