diff options
author | Роман Донченко <dpb@corrigendum.ru> | 2018-04-08 01:00:46 +0300 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2018-05-07 06:44:24 +0000 |
commit | fc5ebe217fc2712b60dfaa5d96b66386a041dd42 (patch) | |
tree | 68def96e81714a495f5870222ff7866dc1743491 /wiretap/file_wrappers.h | |
parent | 282eb96e6396970d4e4ff85912b87f2f84341bc9 (diff) |
wiretap: Add a file_gets variant that returns a pointer to the NUL terminator
When using file_gets it's very difficult to determine how many characters
were read, because you can't distinguish between an embedded NUL and
a short line (note that the last line in a file may not have an LF at the
end). While it's still possible to do it via prefilling the buffer with
non-zero values, doing that is cumbersome, inefficient and error-prone.
This new function makes the task much easier.
The "p" in the name is meant to be reminiscent of the "p" in stpcpy.
Change-Id: I468d5ee71e3b6289925860651ba61b369301b3c9
Reviewed-on: https://code.wireshark.org/review/27333
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'wiretap/file_wrappers.h')
-rw-r--r-- | wiretap/file_wrappers.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/wiretap/file_wrappers.h b/wiretap/file_wrappers.h index 64e0b6b166..40fe9c9788 100644 --- a/wiretap/file_wrappers.h +++ b/wiretap/file_wrappers.h @@ -26,6 +26,7 @@ WS_DLL_PUBLIC int file_read(void *buf, unsigned int count, FILE_T file); WS_DLL_PUBLIC int file_peekc(FILE_T stream); WS_DLL_PUBLIC int file_getc(FILE_T stream); WS_DLL_PUBLIC char *file_gets(char *buf, int len, FILE_T stream); +WS_DLL_PUBLIC char *file_getsp(char *buf, int len, FILE_T stream); WS_DLL_PUBLIC int file_eof(FILE_T stream); WS_DLL_PUBLIC int file_error(FILE_T fh, gchar **err_info); extern void file_clearerr(FILE_T stream); |