mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 06:15:37 +00:00
Move read_timing_record() into libsudo_iolog
This commit is contained in:
@@ -166,37 +166,6 @@ client_closure_free(struct client_closure *closure)
|
||||
debug_return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the next record from the timing file.
|
||||
* Return 0 on success, 1 on EOF and -1 on error.
|
||||
* TODO: share with logsrvd
|
||||
*/
|
||||
int
|
||||
read_timing_record(struct iolog_file *iol, struct timing_closure *timing)
|
||||
{
|
||||
char line[LINE_MAX];
|
||||
const char *errstr;
|
||||
debug_decl(read_timing_record, SUDO_DEBUG_UTIL)
|
||||
|
||||
/* Read next record from timing file. */
|
||||
if (iolog_gets(iol, line, sizeof(line), &errstr) == NULL) {
|
||||
/* EOF or error reading timing file, we are done. */
|
||||
if (iolog_eof(iol))
|
||||
debug_return_int(1);
|
||||
sudo_warnx(U_("error reading timing file: %s"), errstr);
|
||||
debug_return_int(-1);
|
||||
}
|
||||
|
||||
/* Parse timing file record. */
|
||||
line[strcspn(line, "\n")] = '\0';
|
||||
if (!parse_timing(line, timing)) {
|
||||
sudo_warnx(U_("invalid timing file line: %s"), line);
|
||||
debug_return_int(-1);
|
||||
}
|
||||
|
||||
debug_return_int(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the next I/O buffer as described by closure->timing.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user