Expanded new API call iso_write_opts_set_scdbackup_tag

This commit is contained in:
Thomas Schmitt 2009-09-17 16:41:54 +02:00
parent c992687200
commit 6bf538ff40
4 changed files with 32 additions and 8 deletions

View File

@ -1135,6 +1135,7 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
target->md5_file_checksums = opts->md5_file_checksums;
target->md5_session_checksum = opts->md5_session_checksum;
strcpy(target->scdbackup_tag_parm, opts->scdbackup_tag_parm);
target->scdbackup_tag_written = opts->scdbackup_tag_written;
target->checksum_idx_counter = 0;
target->checksum_ctx = NULL;
target->checksum_counter = 0;
@ -1630,6 +1631,7 @@ int iso_write_opts_new(IsoWriteOpts **opts, int profile)
if (wopts == NULL) {
return ISO_OUT_OF_MEM;
}
wopts->scdbackup_tag_written = NULL;
switch (profile) {
case 0:
@ -1870,7 +1872,8 @@ int iso_write_opts_set_record_md5(IsoWriteOpts *opts, int session, int files)
}
int iso_write_opts_set_scdbackup_tag(IsoWriteOpts *opts,
char *name, char *timestamp)
char *name, char *timestamp,
char *tag_written)
{
#ifdef Libisofs_with_checksumS
@ -1897,6 +1900,10 @@ int iso_write_opts_set_scdbackup_tag(IsoWriteOpts *opts,
sprintf(opts->scdbackup_tag_parm, "%s %s", eff_name, eff_time);
opts->scdbackup_tag_written = tag_written;
if (tag_written != NULL)
tag_written[0] = 0;
#endif /* Libisofs_with_checksumS */
return ISO_SUCCESS;

View File

@ -290,6 +290,13 @@ struct iso_write_opts {
* position.
*/
char scdbackup_tag_parm[100];
/* If not NULL: A pointer to an application provided array with
at least 512 characters. The effectively written scdbackup tag
will be copied to this memory location.
*/
char *scdbackup_tag_written;
};
typedef struct ecma119_image Ecma119Image;
@ -473,7 +480,8 @@ struct ecma119_image
is submitted with ecma119_image_new() ?
*/
char scdbackup_tag_parm[96];
char scdbackup_tag_parm[100];
char *scdbackup_tag_written;
#endif /* Libisofs_with_checksumS */

View File

@ -1459,19 +1459,25 @@ int iso_write_opts_set_record_md5(IsoWriteOpts *opts, int session, int files);
* @param timestamp
* A string of 13 characters YYMMDD.hhmmss (e.g. A90831.190324).
* A9 = 2009, B0 = 2010, B1 = 2011, ... C0 = 2020, ...
* @param tag_written
* Either NULL or the address of an array with at least 512 characters.
* In the latter case the eventually produced scdbackup tag will be
* copied to this array when the image gets written. This call sets
* scdbackup_tag_written[0] = 0 to mark its preliminary invalidity.
* @return
* 1 indicates success, <0 is error
*
* @since 0.6.24
*/
int iso_write_opts_set_scdbackup_tag(IsoWriteOpts *opts,
char *name, char *timestamp);
char *name, char *timestamp,
char *tag_written);
/**
* Whether to set default values for files and directory permissions, gid and
* uid. All these take one of three values: 0, 1 or 2.
*
* If 0, the corresponding attribute will be kept as setted in the IsoNode.
* If 0, the corresponding attribute will be kept as set in the IsoNode.
* Unless you have changed it, it corresponds to the value on disc, so it
* is suitable for backup purposes. If set to 1, the corresponding attrib.
* will be changed by a default suitable value. Finally, if you set it to

View File

@ -707,7 +707,7 @@ int iso_md5_write_scdbackup_tag(Ecma119Image *t, char *tag_block, int flag)
void *ctx = NULL;
off_t pos = 0, line_start;
int record_len, block_len, res, i;
char postext[20], md5[16], record[160];
char postext[40], md5[16], record[160];
line_start = strlen(tag_block);
iso_md5_compute(t->checksum_ctx, tag_block, line_start);
@ -721,14 +721,14 @@ int iso_md5_write_scdbackup_tag(Ecma119Image *t, char *tag_block, int flag)
sprintf(postext, "%u%9.9u", (unsigned int) (pos / 1000000000),
(unsigned int) (pos % 1000000000));
else
sprintf(postext, "%u", (unsigned int) pos),
sprintf(postext, "%u", (unsigned int) pos);
sprintf(record, "%s %s ", t->scdbackup_tag_parm, postext);
record_len = strlen(record);
for (i = 0; i < 16; i++)
sprintf(record + record_len + 2 * i,
"%2.2x", ((unsigned char *) md5)[i]);
record_len += 32;
res = iso_md5_start(&ctx);
if (res < 0)
goto ex;
@ -744,6 +744,9 @@ int iso_md5_write_scdbackup_tag(Ecma119Image *t, char *tag_block, int flag)
block_len+= 32;
tag_block[block_len++]= '\n';
if (t->scdbackup_tag_written != NULL)
strncpy(t->scdbackup_tag_written, tag_block + line_start,
block_len - line_start);
res = ISO_SUCCESS;
ex:;
if (ctx != NULL)