Gave up adjustability of Signature Word "AA" in specs and implementation.

This commit is contained in:
2009-01-30 18:58:11 +01:00
parent b600757649
commit 84c100c2f5
11 changed files with 47 additions and 109 deletions

View File

@@ -51,7 +51,6 @@ static int aaip_encode_pair(char *name, size_t attr_length, char *attr,
/* Convert an array of Arbitrary Attributes into a series of AAIP fields.
@param aa_name The 2 byte SUSP Signature Word of the fields
@param num_attrs Number of attributes
@param names Array of pointers to 0 terminated name strings
@param value_lengths Array of byte lengths for each value
@@ -65,8 +64,7 @@ static int aaip_encode_pair(char *name, size_t attr_length, char *attr,
@return >0 is the number of SUSP fields generated,
0 means error
*/
size_t aaip_encode(char aa_name[2],
size_t num_attrs, char **names,
size_t aaip_encode(size_t num_attrs, char **names,
size_t *value_lengths, char **values,
size_t *result_len, unsigned char **result, int flag)
{
@@ -107,8 +105,8 @@ size_t aaip_encode(char aa_name[2],
/* write the field headers */
for(i= 0; i < number_of_fields; i++) {
(*result)[i * 255 + 0]= aa_name[0];
(*result)[i * 255 + 1]= aa_name[1];
(*result)[i * 255 + 0]= 'A';
(*result)[i * 255 + 1]= 'A';
if(i < number_of_fields - 1 || (mem_size % 255) == 0)
(*result)[i * 255 + 2]= 255;
else
@@ -776,7 +774,6 @@ int aaip_add_acl_st_mode(char *acl_text, mode_t st_mode, int flag)
struct aaip_state {
/* AA field status */
unsigned char aa_name[2];
int aa_head_missing; /* number of bytes needed to complete AA field header */
int aa_missing; /* number of bytes needed to complete current AA field */
int aa_ends; /* 0= still AA fields expected, 1= last AA being processed,
@@ -835,30 +832,14 @@ size_t aaip_count_bytes(unsigned char *data, int flag)
}
int aaip_set_signature(char aa_name[2], unsigned char *data, int flag)
{
int done = 0;
unsigned char *aapt;
for(aapt= data; !done; aapt += aapt[2]) {
done = !(aapt[4] & 1);
aapt[0] = aa_name[0];
aapt[1] = aa_name[1];
}
return(1);
}
size_t aaip_sizeof_aaip_state(void)
{
return((size_t) sizeof(struct aaip_state));
}
int aaip_init_aaip_state(struct aaip_state *aaip, char aa_name[2], int flag)
int aaip_init_aaip_state(struct aaip_state *aaip, int flag)
{
aaip->aa_name[0]= aa_name[0];
aaip->aa_name[1]= aa_name[1];
aaip->aa_head_missing= 5;
aaip->aa_missing= 0;
@@ -1152,8 +1133,7 @@ static int aaip_consume_aa_head(struct aaip_state *aaip,
aaip->aa_head_missing-= todo;
if(aaip->aa_head_missing == 0) {
aaip_read_from_recs(aaip, aaip->recs_fill - 5, aa_head, 5, 0);
if(aa_head[0] != aaip->aa_name[0] || aa_head[1] != aaip->aa_name[1] ||
aa_head[3] != 1)
if(aa_head[0] != 'A' || aa_head[1] != 'A' || aa_head[3] != 1)
return(-1);
aaip->aa_missing= aa_head[2];
aaip->aa_ends= !(aa_head[4] & 1);
@@ -1601,7 +1581,6 @@ static int aaip_enlarge_buf(struct aaip_state *aaip, size_t memory_limit,
*handle == NULL. This handle has to be the same as long
as decoding goes on and finally has to be freed by a
call with bit15.
@param aa_name The Signature Word (advised is "AA")
@param memory_limit Maximum number of bytes to allocate
@param num_attr_limit Maximum number of name-value pairs to allocate
@param data The raw data to decode
@@ -1623,7 +1602,7 @@ static int aaip_enlarge_buf(struct aaip_state *aaip, size_t memory_limit,
enlarge memory_limit or call with bit15 and give up
4 limit exceeded, call aaip_get_decoded_attrs() and try again
*/
int aaip_decode_attrs(struct aaip_state **handle, char aa_name[2],
int aaip_decode_attrs(struct aaip_state **handle,
size_t memory_limit, size_t num_attr_limit,
unsigned char *data, size_t num_data, size_t *consumed,
int flag)
@@ -1656,7 +1635,7 @@ int aaip_decode_attrs(struct aaip_state **handle, char aa_name[2],
aaip= *handle= calloc(1, sizeof(struct aaip_state));
if(*handle == NULL)
return(-1);
aaip_init_aaip_state(*handle, aa_name, 0);
aaip_init_aaip_state(*handle, 0);
}
if(aaip->list_names == NULL || aaip->list_values == NULL ||
aaip->list_value_lengths == NULL) {

View File

@@ -18,7 +18,6 @@
/* --------------------------------- Encoder ---------------------------- */
/* Convert an array of Arbitrary Attributes into a series of AAIP fields.
@param aa_name The 2 byte SUSP Signature Word of the fields
@param num_attrs Number of attributes
@param names Array of pointers to 0 terminated name strings
@param value_lengths Array of byte lengths for each value
@@ -32,7 +31,7 @@
@return >0 is the number of SUSP fields generated,
0 means error
*/
size_t aaip_encode(char aa_name[2], size_t num_attrs, char **names,
size_t aaip_encode(size_t num_attrs, char **names,
size_t *value_lengths, char **values,
size_t *result_len, unsigned char **result, int flag);
@@ -216,17 +215,6 @@ int aaip_get_attr_list(char *path, size_t *num_attrs, char ***names,
size_t aaip_count_bytes(unsigned char *data, int flag);
/* Set the Signature Words of all fields in the AA string to the given
two byte values.
@param aa_name The Signature Word to be set (advised is "AA").
@param data An arbitrary number of bytes beginning with the
complete chain of AA fields. Trailing trash is ignored.
@param flag Unused yet. Submit 0.
@return 1 means succes, <=0 means error
*/
int aaip_set_signature(char aa_name[2], unsigned char *data, int flag);
/* The AAIP decoder context.
*/
struct aaip_state;
@@ -241,12 +229,11 @@ size_t aaip_sizeof_aaip_state(void);
This has to be done before the first AA field of a node is processed.
The caller has to provide the storage of the struct aaip_state.
@param aaip The AAIP decoder context to be initialized
@param aa_name The Signature Word (advised is "AA")
@param flag Bitfield for control purposes
submit 0
@return <=0 error , >0 ok
*/
int aaip_init_aaip_state(struct aaip_state *aaip, char aa_name[2], int flag);
int aaip_init_aaip_state(struct aaip_state *aaip, int flag);
/* ------------------------- Component Level Interface ------------------- */
@@ -383,7 +370,6 @@ unsigned int aaip_get_pairs_skipped(struct aaip_state *aaip, int flag);
*handle == NULL. This handle has to be the same as long
as decoding goes on and finally has to be freed by a
call with bit15.
@param aa_name The Signature Word (advised is "AA")
@param memory_limit Maximum number of bytes to allocate
@param num_attr_limit Maximum number of name-value pairs to allocate
@param data The raw data to decode
@@ -399,7 +385,7 @@ unsigned int aaip_get_pairs_skipped(struct aaip_state *aaip, int flag);
3 limit exceeded, not complete yet, call with bit15 and give up
4 limit exceeded, call aaip_get_decoded_attrs() and try again
*/
int aaip_decode_attrs(struct aaip_state **handle, char aa_name[2],
int aaip_decode_attrs(struct aaip_state **handle,
size_t memory_limit, size_t num_attr_limit,
unsigned char *data, size_t num_data, size_t *consumed,
int flag);

View File

@@ -194,10 +194,6 @@ int default_create_node(IsoNodeBuilder *builder, IsoImage *image,
1 | (image->builder_ignore_acl << 1) |
(image->builder_ignore_ea << 2 ));
if (ret == 1 && aa_string != NULL) {
/* >>> change field signatures to eventual libisofs non-"AA" setting */;
/* (for now everything is "AA" anyway) */
ret = iso_node_add_xinfo(new, aaip_xinfo_func, aa_string);
if (ret < 0)
return ret;

View File

@@ -977,7 +977,6 @@ int ifs_get_aa_string(IsoFileSource *src, unsigned char **aa_string, int flag)
if (*aa_string == NULL)
return ISO_OUT_OF_MEM;
memcpy(*aa_string, data->aa_string, len);
aaip_set_signature("AA", *aa_string, 0); /* libisofs.h demands so */
}
return 1;
}
@@ -1339,7 +1338,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
} else if (SUSP_SIG(sue, 'A', 'A') && fsdata->aaip_load == 1) {
ret = read_aaip_AA(sue, "AA", &aa_string, &aa_size, &aa_len,
ret = read_aaip_AA(sue, &aa_string, &aa_size, &aa_len,
&prev_field, &aa_done, 0);
if (ret < 0) {
/* notify and continue */
@@ -2584,10 +2583,6 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
/* obtain ownership of eventual AA string */
ret = iso_file_source_get_aa_string(src, &aa_string, 1);
if (ret == 1 && aa_string != NULL) {
/* >>> change field signatures to eventual libisofs non-"AA" setting */;
/* (for now everything is "AA" anyway) */
ret = iso_node_add_xinfo(new, aaip_xinfo_func, aa_string);
if (ret < 0)
return ret;

View File

@@ -512,7 +512,7 @@ int lfs_get_aa_string(IsoFileSource *src, unsigned char **aa_string, int flag)
if (num_attrs == 0)
result = NULL;
else {
sret = aaip_encode("AA", num_attrs, names,
sret = aaip_encode(num_attrs, names,
value_lengths, values, &result_len, &result, 0);
if (sret == 0) {
ret = ISO_OUT_OF_MEM;

View File

@@ -702,7 +702,6 @@ struct IsoFileSource_Iface
* bit2= No need to get EA (no guarantee of exclusion)
* @param aa_string Returns a pointer to the AA string data. If no AA
* string is available, *aa_string becomes NULL.
* Field signature will be "AA".
* (See doc/susp_aaip_0_2.txt for the meaning of AA and
* libisofs/aaip_0_2.h for encoding and decoding.)
* The caller is responsible for finally calling free()
@@ -3757,7 +3756,6 @@ int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz);
* @param src The file source object to be inquired.
* @param aa_string Returns a pointer to the AA string data. If no AA
* string is available, *aa_string becomes NULL.
* Field signature will be "AA".
* (See doc/susp_aaip_0_2.txt for the meaning of AA and
* libisofs/aaip_0_2.h for encoding and decoding.)
* The caller is responsible for finally calling free()

View File

@@ -1394,7 +1394,7 @@ int iso_node_get_attrs(IsoNode *node, size_t *num_attrs,
return ISO_AAIP_BAD_AASTRING;
}
/* Allow 1 million bytes of memory consumption, 100,000 attributes */
ret = aaip_decode_attrs(&aaip, "AA", (size_t) 1000000, (size_t) 100000,
ret = aaip_decode_attrs(&aaip, (size_t) 1000000, (size_t) 100000,
rpt, todo, &consumed, first_round);
rpt+= consumed;
first_round= 0;
@@ -1449,7 +1449,7 @@ int iso_node_set_attrs(IsoNode *node, size_t num_attrs, char **names,
return ret;
return 1;
}
sret = aaip_encode("AA", num_attrs, names, value_lengths, values,
sret = aaip_encode(num_attrs, names, value_lengths, values,
&result_len, &result, 0);
if (sret == 0)
return ISO_OUT_OF_MEM;

View File

@@ -630,7 +630,7 @@ int rrip_add_ER(Ecma119Image *t, struct susp_info *susp)
static
int aaip_add_ER(Ecma119Image *t, struct susp_info *susp, char aa[2], int flag)
int aaip_add_ER(Ecma119Image *t, struct susp_info *susp, int flag)
{
unsigned char *AA;
@@ -648,11 +648,9 @@ int aaip_add_ER(Ecma119Image *t, struct susp_info *susp, char aa[2], int flag)
AA[6] = 62;
AA[7] = 1;
memcpy(AA + 8, "AAIP_0002", 9);
AA[17] = aa[0];
AA[18] = aa[1];
memcpy(AA + 19,
" PROVIDES VIA AAIP 0.2 SUPPORT FOR ARBITRARY FILE ATTRIBUTES"
" IN ISO 9660 IMAGES", 79);
memcpy(AA + 17,
"AA PROVIDES VIA AAIP 0.2 SUPPORT FOR ARBITRARY FILE ATTRIBUTES"
" IN ISO 9660 IMAGES", 81);
memcpy(AA + 98,
"PLEASE CONTACT THE LIBBURNIA PROJECT VIA LIBBURNIA-PROJECT.ORG",
62);
@@ -1799,7 +1797,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
#endif /* ! Libisofs_with_aaip_dummY */
ret = aaip_add_ER(t, info, "AA", 0);
ret = aaip_add_ER(t, info, 0);
if (ret < 0) {
goto add_susp_cleanup;
}

View File

@@ -288,9 +288,6 @@ int read_rr_PN(struct susp_sys_user_entry *pn, struct stat *st);
/**
* Collects the AA field string from single AA fields.
* (see doc/susp_aaip_0_2.txt)
* @param aa Signature of fields for inner representation. It will
* replace the signature of of the submitted SUSP field.
* Advised is "AA".
* @param aa_string Storage location of the emerging string.
* Begin with *aa_string == NULL, or own malloc() storage.
* @param aa_size Current allocated size of aa_string.
@@ -304,16 +301,23 @@ int read_rr_PN(struct susp_sys_user_entry *pn, struct stat *st);
* Begin with *is_done == 0
* @param flag Unused yet. Submit 0.
*/
int read_aaip_AA(struct susp_sys_user_entry *sue, char aa[2],
int read_aaip_AA(struct susp_sys_user_entry *sue,
unsigned char **aa_string, size_t *aa_size, size_t *aa_len,
size_t *prev_field, int *is_done, int flag);
#ifdef NIX
/* <<< is now in libisofs.h */
/**
* Function to identify and manage AA strings as xinfo of IsoNode
* See libisofs.h iso_node_xinfo_func
*/
int aaip_xinfo_func(void *data, int flag);
#endif /* NIX */
#endif /* Libisofs_with_aaiP */

View File

@@ -438,7 +438,7 @@ int read_rr_PN(struct susp_sys_user_entry *pn, struct stat *st)
#ifdef Libisofs_with_aaiP
int read_aaip_AA(struct susp_sys_user_entry *sue, char aa[2],
int read_aaip_AA(struct susp_sys_user_entry *sue,
unsigned char **aa_string, size_t *aa_size, size_t *aa_len,
size_t *prev_field, int *is_done, int flag)
{
@@ -469,8 +469,8 @@ int read_aaip_AA(struct susp_sys_user_entry *sue, char aa[2],
/* Compose new SUSP header with signature aa[], cont == 0 */
aapt = *aa_string + *aa_len;
aapt[0] = aa[0];
aapt[1] = aa[1];
aapt[0] = 'A';
aapt[1] = 'A';
aapt[2] = sue->len_sue[0];
aapt[3] = 1;
aapt[4] = 0;