mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Refactor verify functions to use const char* for path parameters
This commit is contained in:
@@ -29,8 +29,8 @@ char *byte_array_to_hex_string(const unsigned char *array, int array_size);
|
|||||||
int read(unsigned long long sector_no, char *path);
|
int read(unsigned long long sector_no, char *path);
|
||||||
int printhex(unsigned char *array, unsigned int length, int width, bool color);
|
int printhex(unsigned char *array, unsigned int length, int width, bool color);
|
||||||
int read_long(unsigned long long sector_no, char *path);
|
int read_long(unsigned long long sector_no, char *path);
|
||||||
int verify(char *path);
|
int verify(const char *path);
|
||||||
int verify_sectors(char *path);
|
int verify_sectors(const char *path);
|
||||||
bool check_cd_sector_channel(CdEccContext *context, uint8_t *sector, bool *unknown, bool *has_edc, bool *edc_correct,
|
bool check_cd_sector_channel(CdEccContext *context, uint8_t *sector, bool *unknown, bool *has_edc, bool *edc_correct,
|
||||||
bool *has_ecc_p, bool *ecc_p_correct, bool *has_ecc_q, bool *ecc_q_correct);
|
bool *has_ecc_p, bool *ecc_p_correct, bool *has_ecc_q, bool *ecc_q_correct);
|
||||||
int compare(char *path1, char *path2);
|
int compare(char *path1, char *path2);
|
||||||
|
|||||||
@@ -44,24 +44,24 @@ void draw_progress_bar(int row, int percent)
|
|||||||
|
|
||||||
int compare(char *path1, char *path2)
|
int compare(char *path1, char *path2)
|
||||||
{
|
{
|
||||||
int ret = AARUF_STATUS_OK;
|
int ret = AARUF_STATUS_OK;
|
||||||
aaruformatContext const *ctx1 = NULL;
|
aaruformatContext *ctx1 = NULL;
|
||||||
aaruformatContext const *ctx2 = NULL;
|
aaruformatContext *ctx2 = NULL;
|
||||||
bool imagesAreDifferent = false;
|
bool imagesAreDifferent = false;
|
||||||
char *strBuffer = NULL;
|
char *strBuffer = NULL;
|
||||||
UErrorCode u_error_code = U_ZERO_ERROR;
|
UErrorCode u_error_code = U_ZERO_ERROR;
|
||||||
int lr = 0;
|
int lr = 0;
|
||||||
int rr = 0;
|
int rr = 0;
|
||||||
uintattr_t appVerColor = TB_WHITE;
|
uintattr_t appVerColor = TB_WHITE;
|
||||||
uintattr_t imageVerColor = TB_WHITE;
|
uintattr_t imageVerColor = TB_WHITE;
|
||||||
uintattr_t mediaTypeColor = TB_WHITE;
|
uintattr_t mediaTypeColor = TB_WHITE;
|
||||||
uintattr_t creationTimeColor = TB_WHITE;
|
uintattr_t creationTimeColor = TB_WHITE;
|
||||||
uintattr_t lastWrittenTimeColor = TB_WHITE;
|
uintattr_t lastWrittenTimeColor = TB_WHITE;
|
||||||
uintattr_t partitionsColor = TB_WHITE;
|
uintattr_t partitionsColor = TB_WHITE;
|
||||||
uintattr_t sessionsColor = TB_WHITE;
|
uintattr_t sessionsColor = TB_WHITE;
|
||||||
uintattr_t sectorsColor = TB_WHITE;
|
uintattr_t sectorsColor = TB_WHITE;
|
||||||
uintattr_t sectorSizeColor = TB_WHITE;
|
uintattr_t sectorSizeColor = TB_WHITE;
|
||||||
uintattr_t versionColor = TB_WHITE;
|
uintattr_t versionColor = TB_WHITE;
|
||||||
|
|
||||||
// Initialize termbox2
|
// Initialize termbox2
|
||||||
if(tb_init() != 0) return 1;
|
if(tb_init() != 0) return 1;
|
||||||
|
|||||||
@@ -23,10 +23,10 @@
|
|||||||
|
|
||||||
#include "aaruformattool.h"
|
#include "aaruformattool.h"
|
||||||
|
|
||||||
int verify(char *path)
|
int verify(const char *path)
|
||||||
{
|
{
|
||||||
aaruformatContext *ctx = NULL;
|
aaruformatContext *ctx = NULL;
|
||||||
uint32_t res = 0;
|
uint32_t res = 0;
|
||||||
|
|
||||||
ctx = aaruf_open(path);
|
ctx = aaruf_open(path);
|
||||||
|
|
||||||
@@ -48,20 +48,20 @@ int verify(char *path)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int verify_sectors(char *path)
|
int verify_sectors(const char *path)
|
||||||
{
|
{
|
||||||
aaruformatContext *ctx = NULL;
|
aaruformatContext *ctx = NULL;
|
||||||
uint8_t *buffer = NULL;
|
uint8_t *buffer = NULL;
|
||||||
uint32_t buffer_len = 2352;
|
uint32_t buffer_len = 2352;
|
||||||
int32_t res = 0;
|
int32_t res = 0;
|
||||||
CdEccContext *cd_ecc_context = NULL;
|
CdEccContext *cd_ecc_context = NULL;
|
||||||
ctx = aaruf_open(path);
|
ctx = aaruf_open(path);
|
||||||
bool verify_result = false;
|
bool verify_result = false;
|
||||||
bool has_edc = false, has_ecc_p = false, ecc_p_correct = false, has_ecc_q = false, ecc_q_correct = false;
|
bool has_edc = false, has_ecc_p = false, ecc_p_correct = false, has_ecc_q = false, ecc_q_correct = false;
|
||||||
bool edc_correct = false;
|
bool edc_correct = false;
|
||||||
bool unknown = false;
|
bool unknown = false;
|
||||||
uint64_t errors = 0, unknowns = 0;
|
uint64_t errors = 0, unknowns = 0;
|
||||||
bool any_error = false;
|
bool any_error = false;
|
||||||
|
|
||||||
if(ctx == NULL)
|
if(ctx == NULL)
|
||||||
{
|
{
|
||||||
@@ -80,7 +80,7 @@ int verify_sectors(char *path)
|
|||||||
unknowns = 0;
|
unknowns = 0;
|
||||||
any_error = false;
|
any_error = false;
|
||||||
|
|
||||||
for (uint64_t s = 0; s < ctx->imageInfo.Sectors; s++)
|
for(uint64_t s = 0; s < ctx->imageInfo.Sectors; s++)
|
||||||
{
|
{
|
||||||
printf("\rVerifying sector %llu...", s);
|
printf("\rVerifying sector %llu...", s);
|
||||||
res = aaruf_read_sector_long(ctx, s, buffer, &buffer_len);
|
res = aaruf_read_sector_long(ctx, s, buffer, &buffer_len);
|
||||||
@@ -103,11 +103,11 @@ int verify_sectors(char *path)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_edc && !edc_correct) printf("\rSector %llu has an incorrect EDC value.\n", s);
|
if(has_edc && !edc_correct) printf("\rSector %llu has an incorrect EDC value.\n", s);
|
||||||
|
|
||||||
if (has_ecc_p && !ecc_p_correct) printf("\rSector %llu has an incorrect EDC value.\n", s);
|
if(has_ecc_p && !ecc_p_correct) printf("\rSector %llu has an incorrect EDC value.\n", s);
|
||||||
|
|
||||||
if (has_ecc_q && !ecc_q_correct) printf("\rSector %llu has an incorrect EDC value.\n", s);
|
if(has_ecc_q && !ecc_q_correct) printf("\rSector %llu has an incorrect EDC value.\n", s);
|
||||||
|
|
||||||
errors++;
|
errors++;
|
||||||
any_error = true;
|
any_error = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user