"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libjte/libjte.c" between
xorriso-1.5.2.tar.gz and xorriso-1.5.4.tar.gz

About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.

libjte.c  (xorriso-1.5.2):libjte.c  (xorriso-1.5.4)
skipping to change at line 89 skipping to change at line 89
if (sizeof(off_t) < 8) { if (sizeof(off_t) < 8) {
fprintf(stderr, "libjte: Fatal compile time misconfiguration. sizeof(off _t) = %d too small.\n\n", (int) sizeof(off_t)); fprintf(stderr, "libjte: Fatal compile time misconfiguration. sizeof(off _t) = %d too small.\n\n", (int) sizeof(off_t));
return -1; return -1;
} }
*jte_handle = o = calloc(1, sizeof(struct libjte_env)); *jte_handle = o = calloc(1, sizeof(struct libjte_env));
if (o == NULL) if (o == NULL)
return -1; return -1;
o->jtemplate_out = NULL; o->jtemplate_out = NULL;
o->jjigdo_out = NULL; o->jjigdo_out = NULL;
o->jmd5_list = NULL; o->jchecksum_list = NULL;
o->checksum_algo = CHECK_MD5;
o->jtjigdo = NULL; o->jtjigdo = NULL;
o->jttemplate = NULL; o->jttemplate = NULL;
o->jte_min_size = MIN_JIGDO_FILE_SIZE; o->jte_min_size = MIN_JIGDO_FILE_SIZE;
o->checksum_algo_iso = (CHECK_MD5_USED | \ o->checksum_algo_iso = (CHECK_MD5_USED | \
CHECK_SHA1_USED | \ CHECK_SHA1_USED | \
CHECK_SHA256_USED | \ CHECK_SHA256_USED | \
CHECK_SHA512_USED); CHECK_SHA512_USED);
o->checksum_algo_tmpl = CHECK_MD5_USED; o->checksum_algo_tmpl = (CHECK_MD5_USED | CHECK_SHA256_USED);
o->jte_template_compression = JTE_TEMP_GZIP; o->jte_template_compression = JTE_TEMP_GZIP;
o->exclude_list = NULL; o->exclude_list = NULL;
o->include_list = NULL; o->include_list = NULL;
o->map_list = NULL; o->map_list = NULL;
o->template_size = 0; o->template_size = 0;
o->image_size = 0; o->image_size = 0;
o->iso_context = NULL; o->iso_context = NULL;
o->template_context = NULL; o->template_context = NULL;
o->entry_list = NULL; o->entry_list = NULL;
o->entry_last = NULL; o->entry_last = NULL;
o->t_file = NULL; o->t_file = NULL;
o->j_file = NULL; o->j_file = NULL;
o->num_matches = 0; o->num_matches = 0;
o->num_chunks = 0; o->num_chunks = 0;
o->md5_list = NULL; o->checksum_list = NULL;
o->md5_last = NULL; o->checksum_last = NULL;
o->include_in_jigdo = 0; o->include_in_jigdo = 0;
memset(o->message_buffer, 0, sizeof(o->message_buffer)); memset(o->message_buffer, 0, sizeof(o->message_buffer));
o->error_behavior = 1; /* Print to stderr, do not exit but return -1 */ o->error_behavior = 1; /* Print to stderr, do not exit but return -1 */
o->msg_list = 0; o->msg_list = NULL;
o->uncomp_buf = NULL; o->uncomp_buf = NULL;
o->uncomp_size = 0; o->uncomp_size = 0;
o->uncomp_buf_used = 0; o->uncomp_buf_used = 0;
return 1; return 1;
} }
int libjte_destroy(struct libjte_env **jte_handle) int libjte_destroy(struct libjte_env **jte_handle)
{ {
struct libjte_env *o; struct libjte_env *o;
o = *jte_handle; o = *jte_handle;
if (o == NULL) if (o == NULL)
return 0; return 0;
free(o->outfile); free(o->outfile);
free(o->jtemplate_out); free(o->jtemplate_out);
free(o->jjigdo_out); free(o->jjigdo_out);
free(o->jmd5_list); free(o->jchecksum_list);
if (o->jtjigdo != NULL) if (o->jtjigdo != NULL)
fclose(o->jtjigdo); fclose(o->jtjigdo);
if (o->jttemplate != NULL) if (o->jttemplate != NULL)
fclose(o->jttemplate); fclose(o->jttemplate);
libjte_destroy_path_match_list(o, 0); /* include_list */ libjte_destroy_path_match_list(o, 0); /* include_list */
libjte_destroy_path_match_list(o, 1); /* exclude_list */ libjte_destroy_path_match_list(o, 1); /* exclude_list */
libjte_destroy_path_mapping(o, 0); libjte_destroy_path_mapping(o, 0);
if (o->iso_context != NULL) if (o->iso_context != NULL)
checksum_free_context(o->iso_context); checksum_free_context(o->iso_context);
if (o->template_context != NULL) if (o->template_context != NULL)
checksum_free_context(o->template_context); checksum_free_context(o->template_context);
/* >>> TODO : get rid of the following odd situation /* >>> TODO : get rid of the following odd situation
o->j_file and o->t_file seem to be only copies of o->j_file and o->t_file seem to be only copies of
o->jttemplate and o->jtjigdo */ o->jttemplate and o->jtjigdo */
libjte_destroy_entry_list(o, 0); libjte_destroy_entry_list(o, 0);
libjte_destroy_md5_list(o, 0); libjte_destroy_checksum_list(o, 0);
libjte_clear_msg_list(o, 1 | 2); /* dump pending messages to stderr */ libjte_clear_msg_list(o, 1 | 2); /* dump pending messages to stderr */
free(o->uncomp_buf); free(o->uncomp_buf);
free(o); free(o);
*jte_handle = NULL; *jte_handle = NULL;
return 1; return 1;
} }
/* Setup API */ /* Setup API */
skipping to change at line 177 skipping to change at line 178
{ {
return libjte__set_string(&(o->outfile), outfile, 0); return libjte__set_string(&(o->outfile), outfile, 0);
} }
int libjte_set_verbose(struct libjte_env *o, int verbose) int libjte_set_verbose(struct libjte_env *o, int verbose)
{ {
o->verbose = !!verbose; o->verbose = !!verbose;
return 1; return 1;
} }
int libjte_set_checksum_algorithm(struct libjte_env *o,
char *algorithm,
int *size)
{
int i = 0;
for (i = 0; ; i++)
{
if (check_algos[i].name == NULL)
{
sprintf(o->message_buffer,
"libjte: Unknown checksum algorithm %s", algorithm);
libjte_add_msg_entry(o, o->message_buffer, 0);
return -1;
}
if (!strcmp(algorithm, check_algos[i].name))
break;
}
o->checksum_algo = i;
*size = check_algos[i].raw_bytes;
return 1;
}
int libjte_set_template_path(struct libjte_env *o, char *jtemplate_out) int libjte_set_template_path(struct libjte_env *o, char *jtemplate_out)
{ {
return libjte__set_string(&(o->jtemplate_out), jtemplate_out, 0); return libjte__set_string(&(o->jtemplate_out), jtemplate_out, 0);
} }
int libjte_set_jigdo_path(struct libjte_env *o, char *jjigdo_out) int libjte_set_jigdo_path(struct libjte_env *o, char *jjigdo_out)
{ {
return libjte__set_string(&(o->jjigdo_out), jjigdo_out, 0); return libjte__set_string(&(o->jjigdo_out), jjigdo_out, 0);
} }
int libjte_set_md5_path(struct libjte_env *o, char *jmd5_list) int libjte_set_md5_path(struct libjte_env *o, char *path)
{ {
return libjte__set_string(&(o->jmd5_list), jmd5_list, 0); return libjte_set_checksum_path(o, path);
}
int libjte_set_checksum_path(struct libjte_env *o, char *path)
{
return libjte__set_string(&(o->jchecksum_list), path, 0);
} }
int libjte_set_min_size(struct libjte_env *o, int jte_min_size) int libjte_set_min_size(struct libjte_env *o, int jte_min_size)
{ {
o->jte_min_size = jte_min_size; o->jte_min_size = jte_min_size;
return 1; return 1;
} }
static int libjte_decode_checksum_string(struct libjte_env *o, static int libjte_decode_checksum_string(struct libjte_env *o,
char *checksum_code, int default_algo, char *checksum_code, int default_algo,
skipping to change at line 250 skipping to change at line 278
int checksum_algo_iso = (CHECK_MD5_USED | int checksum_algo_iso = (CHECK_MD5_USED |
CHECK_SHA1_USED | CHECK_SHA1_USED |
CHECK_SHA256_USED | CHECK_SHA256_USED |
CHECK_SHA512_USED); CHECK_SHA512_USED);
ret = libjte_decode_checksum_string(o, checksum_code, checksum_algo_iso, ret = libjte_decode_checksum_string(o, checksum_code, checksum_algo_iso,
&checksum_algo_iso); &checksum_algo_iso);
if (ret <= 0) if (ret <= 0)
return ret; return ret;
o->checksum_algo_iso = checksum_algo_iso; o->checksum_algo_iso = checksum_algo_iso;
/* Maybe have to override - if we're doing a v2 jigdo file based
* around sha256, we always need the sha256 calculated too */
if (o->checksum_algo == CHECK_SHA256)
o->checksum_algo_iso |= CHECK_SHA256_USED;
return 1; return 1;
} }
int libjte_set_checksum_template(struct libjte_env *o, char *checksum_code) int libjte_set_checksum_template(struct libjte_env *o, char *checksum_code)
{ {
int ret; int ret;
int checksum_algo_tmpl = CHECK_MD5_USED; int checksum_algo_tmpl = CHECK_MD5_USED;
ret = libjte_decode_checksum_string(o, checksum_code, checksum_algo_tmpl, ret = libjte_decode_checksum_string(o, checksum_code, checksum_algo_tmpl,
&checksum_algo_tmpl); &checksum_algo_tmpl);
if (ret <= 0) if (ret <= 0)
return ret; return ret;
o->checksum_algo_tmpl = checksum_algo_tmpl; o->checksum_algo_tmpl = checksum_algo_tmpl;
/* Maybe have to override - if we're doing a v2 jigdo file based
* around sha256, we always need the sha256 calculated too */
if (o->checksum_algo == CHECK_SHA256)
o->checksum_algo_tmpl |= CHECK_SHA256_USED;
return 1; return 1;
} }
int libjte_set_compression(struct libjte_env *o, char *compression_code) int libjte_set_compression(struct libjte_env *o, char *compression_code)
{ {
jtc_t compr = JTE_TEMP_GZIP; jtc_t compr = JTE_TEMP_GZIP;
if (strcmp(compression_code, "default") != 0) { if (strcmp(compression_code, "default") != 0) {
if (strcmp(compression_code, "gzip") == 0) if (strcmp(compression_code, "gzip") == 0)
compr = JTE_TEMP_GZIP; compr = JTE_TEMP_GZIP;
skipping to change at line 314 skipping to change at line 354
} }
int libjte_add_md5_demand(struct libjte_env *o, char *pattern) int libjte_add_md5_demand(struct libjte_env *o, char *pattern)
{ {
int ret; int ret;
ret = jte_add_include(o, pattern); ret = jte_add_include(o, pattern);
return !ret; return !ret;
} }
int libjte_add_checksum_demand(struct libjte_env *o, char *pattern)
{
int ret;
ret = jte_add_include(o, pattern);
return !ret;
}
int libjte_add_mapping(struct libjte_env *o, char *arg) int libjte_add_mapping(struct libjte_env *o, char *arg)
{ {
int ret; int ret;
ret = jte_add_mapping(o, arg); ret = jte_add_mapping(o, arg);
return !ret; return !ret;
} }
int libjte_set_image_size(struct libjte_env *o, off_t image_size) int libjte_set_image_size(struct libjte_env *o, off_t image_size)
{ {
skipping to change at line 335 skipping to change at line 383
return 1; return 1;
} }
/* Operation API */ /* Operation API */
int libjte_write_header(struct libjte_env *o) int libjte_write_header(struct libjte_env *o)
{ {
int ret; int ret;
if (o->jtemplate_out == NULL || o->jjigdo_out == NULL || if (o->jtemplate_out == NULL || o->jjigdo_out == NULL ||
o->outfile == NULL || o->jmd5_list == NULL) { o->outfile == NULL || o->jchecksum_list == NULL) {
sprintf(o->message_buffer, sprintf(o->message_buffer,
"Undefined: template_path, jigdo_path, md5_paths, or outfile."); "Undefined: template_path, jigdo_path, checksum_paths, or outfile .");
libjte_add_msg_entry(o, o->message_buffer, 0); libjte_add_msg_entry(o, o->message_buffer, 0);
return 0; return 0;
} }
o->jttemplate = fopen(o->jtemplate_out, "wb"); o->jttemplate = fopen(o->jtemplate_out, "wb");
if (o->jttemplate == NULL) { if (o->jttemplate == NULL) {
sprintf(o->message_buffer, sprintf(o->message_buffer,
"Cannot open template file '%1.1024s' for writing. errno=%d", "Cannot open template file '%1.1024s' for writing. errno=%d",
o->jtemplate_out, errno); o->jtemplate_out, errno);
libjte_add_msg_entry(o, o->message_buffer, 0); libjte_add_msg_entry(o, o->message_buffer, 0);
skipping to change at line 398 skipping to change at line 446
ret = jtwrite(o, buffer, size, count); ret = jtwrite(o, buffer, size, count);
return ret; return ret;
} }
int libjte_write_match_record(struct libjte_env *o, int libjte_write_match_record(struct libjte_env *o,
char *filename, char *mirror_name, int sector_size, char *filename, char *mirror_name, int sector_size,
off_t size, unsigned char md5[16]) off_t size, unsigned char md5[16])
{ {
int ret; int ret;
if (check_algos[o->checksum_algo].type != CHECK_MD5)
{
sprintf(o->message_buffer, "Attempted to call libjte_write_match_record(
) after choosing checksum algorithm '%s'",
check_algos[o->checksum_algo].name);
libjte_add_msg_entry(o, o->message_buffer, 0);
return 0;
}
ret = write_jt_match_record(o, filename, mirror_name, sector_size, size, ret = write_jt_match_record(o, filename, mirror_name, sector_size, size,
md5); md5);
if (ret <= 0) if (ret <= 0)
return ret; return ret;
return 1; return 1;
} }
int libjte_write_match_record2(struct libjte_env *o,
char *filename, char *mirror_name, int sector_size
,
off_t size, unsigned char *checksum)
{
int ret;
ret = write_jt_match_record(o, filename, mirror_name,
sector_size, size, checksum);
if (ret <= 0)
return ret;
return 1;
}
int libjte_decide_file_jigdo(struct libjte_env *o, int libjte_decide_file_jigdo(struct libjte_env *o,
char *filename, off_t size, char **mirror_name, char *filename, off_t size, char **mirror_name,
unsigned char md5[16]) unsigned char md5[16])
{ {
if (check_algos[o->checksum_algo].type != CHECK_MD5)
{
sprintf(o->message_buffer, "Attempted to call libjte_decide_file_jigdo()
after choosing checksum algorithm '%s'",
check_algos[o->checksum_algo].name);
libjte_add_msg_entry(o, o->message_buffer, 0);
return 0;
}
return libjte_decide_file_jigdo2(o, filename, size, mirror_name, md5);
}
int libjte_decide_file_jigdo2(struct libjte_env *o,
char *filename, off_t size, char **mirror_name,
unsigned char *checksum)
{
int ret; int ret;
char *md5_name; char *checksum_name;
*mirror_name = NULL; *mirror_name = NULL;
ret = list_file_in_jigdo(o, filename, size, &md5_name, md5); ret = list_file_in_jigdo(o, filename, size, &checksum_name, checksum);
if (ret <= 0) if (ret <= 0)
return ret; return ret;
*mirror_name = strdup(md5_name); *mirror_name = strdup(checksum_name);
if (*mirror_name == NULL) { if (*mirror_name == NULL) {
libjte_report_no_mem(o, strlen(md5_name) + 1, 0); libjte_report_no_mem(o, strlen(checksum_name) + 1, 0);
return -1; return -1;
} }
return 1; return 1;
} }
/* Simplified Data File API */ /* Simplified Data File API */
int libjte_begin_data_file(struct libjte_env *o, char *filename, int libjte_begin_data_file(struct libjte_env *o, char *filename,
int sector_size, off_t size) int sector_size, off_t size)
{ {
int ret; int ret;
char *mirror_name; char *mirror_name;
unsigned char md5[16]; unsigned char *checksum;
checksum = calloc(1, check_algos[o->checksum_algo].raw_bytes);
if (!checksum)
return -1;
o->include_in_jigdo = 0; o->include_in_jigdo = 0;
ret = list_file_in_jigdo(o, filename, size, &mirror_name, md5); ret = list_file_in_jigdo(o, filename, size, &mirror_name, checksum);
if (ret < 0) if (ret < 0)
{
free(checksum);
return ret; return ret;
}
if (ret == 0) if (ret == 0)
{
free(checksum);
return 2; return 2;
}
write_jt_match_record(o, filename, mirror_name, sector_size, write_jt_match_record(o, filename, mirror_name, sector_size,
size, md5); size, checksum);
o->include_in_jigdo = 1; o->include_in_jigdo = 1;
return 1; return 1;
} }
int libjte_show_data_chunk(struct libjte_env *o, int libjte_show_data_chunk(struct libjte_env *o,
void *buffer, int sector_size, void *buffer, int sector_size,
int count) int count)
{ {
o->image_size += count * sector_size; o->image_size += count * sector_size;
if (o->include_in_jigdo) if (o->include_in_jigdo)
 End of changes. 28 change blocks. 
18 lines changed or deleted 115 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)