/*
* Read the next packet, in chronological order, from the set of files
- * to be merged. Return a pointer to the merge_in_file_t for the file
- * from which the packet was read on success, or NULL on EOF or error.
- * On EOF, *err is 0; on an error, it's an error code.
+ * to be merged.
+ *
+ * On success, set *err to 0 and return a pointer to the merge_in_file_t
+ * for the file from which the packet was read.
+ *
+ * On a read error, set *err to the error and return a pointer to the
+ * merge_in_file_t for the file on which we got an error.
+ *
+ * On an EOF (meaning all the files are at EOF), set *err to 0 and return
+ * NULL.
*/
merge_in_file_t *
merge_read_packet(int in_file_count, merge_in_file_t in_files[],
/*
* Read the next packet, in file sequence order, from the set of files
- * to be merged. Return a pointer to the merge_in_file_t for the file
- * from which the packet was read on success, or NULL on EOF or error.
- * On EOF, *err is 0; on an error, it's an error code.
+ * to be merged.
+ *
+ * On success, set *err to 0 and return a pointer to the merge_in_file_t
+ * for the file from which the packet was read.
+ *
+ * On a read error, set *err to the error and return a pointer to the
+ * merge_in_file_t for the file on which we got an error.
+ *
+ * On an EOF (meaning all the files are at EOF), set *err to 0 and return
+ * NULL.
*/
merge_in_file_t *
merge_append_read_packet(int in_file_count, merge_in_file_t in_files[],
if (*err != 0) {
/* Read error - quit immediately. */
in_files[i].state = GOT_ERROR;
- return NULL;
+ return &in_files[i];
}
/* EOF - flag this file as being at EOF, and try the next one. */
in_files[i].state = AT_EOF;
}
/* Return the ordinal of the file from which the packet was read. */
+ *err = 0;
return &in_files[i];
}