Added max id for unix_fs_driver + better macros
This commit is contained in:
@@ -53,12 +53,20 @@ main(int argc, char *argv[])
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
UnixFsDriverData driver_data = { path };
|
||||
|
||||
int max_id = unix_fs_driver_get_max_id(&driver_data);
|
||||
if (max_id <= 0) {
|
||||
fprintf(stderr, "Warning: failed to get id of last comment\n");
|
||||
} else if (id >= max_id) {
|
||||
fprintf(stderr, "Last comment has id %d, which is less than %d\n", max_id - 1, id);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
CommentHeader *header = malloc(sizeof(CommentHeader));
|
||||
header->user_sid = malloc(BUF_SZ);
|
||||
header->user_displayname = malloc(BUF_SZ);
|
||||
|
||||
UnixFsDriverData driver_data = { path };
|
||||
|
||||
if (driver->get_header(&driver_data, header, id) < 0) {
|
||||
fprintf(stderr, "failed to get header of comment, are you sure it exists?\n");
|
||||
exit(EXIT_FAILURE);
|
||||
|
Reference in New Issue
Block a user