Implemented reading of AA field string from iso_node_get_xinfo().
(No AA strings get submitted as xinfo yet.)
This commit is contained in:
parent
3294dd5e94
commit
3c91c2f333
@ -478,6 +478,17 @@ struct aaip_state {
|
||||
/* ------- functions ------ */
|
||||
|
||||
|
||||
size_t aaip_count_bytes(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);
|
||||
return((size_t) (aapt - data));
|
||||
}
|
||||
|
||||
|
||||
size_t aaip_sizeof_aaip_state(void)
|
||||
{
|
||||
return((size_t) sizeof(struct aaip_state));
|
||||
|
@ -117,6 +117,17 @@ int aaip_get_attr_list(char *path, size_t *num_attrs, char ***names,
|
||||
*/
|
||||
|
||||
|
||||
/* This function expects to get submitted a complete chain of AA fields and
|
||||
determines its size by interpeting the SUSP structure..
|
||||
@param aa_name The Signature Word (advised is "AA") to be looked for
|
||||
@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 The number of bytes of the AA field chain.
|
||||
*/
|
||||
size_t aaip_count_bytes(char aa_name[2], unsigned char *data, int flag);
|
||||
|
||||
|
||||
/* The AAIP decoder context.
|
||||
*/
|
||||
struct aaip_state;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "writer.h"
|
||||
#include "messages.h"
|
||||
#include "image.h"
|
||||
#include "aaip_0_2.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -661,6 +662,22 @@ int susp_add_SP(Ecma119Image *t, struct susp_info *susp)
|
||||
return susp_append(t, susp, SP);
|
||||
}
|
||||
|
||||
|
||||
#ifdef Libisofs_with_aaiP
|
||||
/* ts A90114 */
|
||||
|
||||
static
|
||||
int aaip_xinfo_func(void *data, int flag)
|
||||
{
|
||||
if (flag & 1) {
|
||||
free(data);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_aaiP */
|
||||
|
||||
|
||||
/**
|
||||
* Compute the length needed for write all RR and SUSP entries for a given
|
||||
* node.
|
||||
@ -682,8 +699,9 @@ size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space,
|
||||
|
||||
#ifdef Libisofs_with_aaiP
|
||||
/* ts A90112 */
|
||||
uint8_t *aapt;
|
||||
void *xipt;
|
||||
size_t num_aapt = 0, sua_free = 0;
|
||||
int ret;
|
||||
#endif
|
||||
|
||||
/* space min is 255 - 33 - 37 = 185
|
||||
@ -849,23 +867,35 @@ size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space,
|
||||
|
||||
#ifdef Libisofs_with_aaiP
|
||||
/* ts A90112 */
|
||||
aapt = NULL;
|
||||
xipt = NULL;
|
||||
|
||||
#ifdef Libisofs_with_aaip_dummY
|
||||
|
||||
num_aapt = 28;
|
||||
aaip_xinfo_func(NULL, 0); /* to avoid compiler warning */
|
||||
|
||||
#else /* Libisofs_with_aaip_dummY */
|
||||
|
||||
/* >>> obtain num_aapt from node */;
|
||||
/* obtain num_aapt from node */
|
||||
num_aapt = 0;
|
||||
|
||||
/* >>> if AAIP is enabled */
|
||||
if (1) {
|
||||
|
||||
ret = iso_node_get_xinfo(n->node, aaip_xinfo_func, &xipt);
|
||||
if (ret == 1) {
|
||||
num_aapt = aaip_count_bytes("AA", (unsigned char *) xipt, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ! Libisofs_with_aaip_dummY */
|
||||
|
||||
/* let the expert decide where to add num_aapt */
|
||||
if (num_aapt > 0) {
|
||||
sua_free = space - su_size;
|
||||
aaip_add_AA(NULL, NULL, NULL, num_aapt, &sua_free, ce, 1);
|
||||
su_size = space - sua_free;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_aaiP */
|
||||
|
||||
@ -887,18 +917,21 @@ size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space,
|
||||
|
||||
#ifdef Libisofs_with_aaip_dummY
|
||||
|
||||
if (1) {
|
||||
#else /* Libisofs_with_aaip_dummY */
|
||||
|
||||
*ce += 160; /* ER of AAIP */
|
||||
/* >>> if AAIP is enabled */
|
||||
if (1) {
|
||||
|
||||
#endif /* ! Libisofs_with_aaip_dummY */
|
||||
|
||||
/* >>> if AAIP is enabled */
|
||||
/* >>> *ce += 160; */; /* ER of AAIP */
|
||||
*ce += 160; /* ER of AAIP */
|
||||
|
||||
#endif /* Libisofs_with_aaiP */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -957,6 +990,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
||||
#ifdef Libisofs_with_aaiP
|
||||
/* ts A90112 */
|
||||
uint8_t *aapt;
|
||||
void *xipt;
|
||||
size_t num_aapt= 0;
|
||||
#endif
|
||||
size_t aaip_er_len= 0;
|
||||
@ -1280,8 +1314,9 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_aaiP
|
||||
/* ts A90112 */
|
||||
|
||||
#ifdef Libisofs_with_aaip_dummY
|
||||
/* ts A90112 */
|
||||
|
||||
{
|
||||
static uint8_t dummy_aa[28]= {
|
||||
@ -1300,21 +1335,44 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
||||
memcpy(aapt, dummy_aa, num_aapt);
|
||||
|
||||
ret = aaip_add_AA(t, info, aapt, num_aapt, &sua_free, &ce_len, 0);
|
||||
|
||||
}
|
||||
|
||||
#else /* Libisofs_with_aaip_dummY */
|
||||
|
||||
/* >>> obtain aapt and num_aapt from node */;
|
||||
aapt = NULL;
|
||||
num_aapt = 0;
|
||||
ret = ISO_SUCCESS;
|
||||
|
||||
#endif /* ! Libisofs_with_aaip_dummY */
|
||||
|
||||
if (ret < 0) {
|
||||
goto add_susp_cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* Libisofs_with_aaip_dummY */
|
||||
/* ts A90114 */
|
||||
|
||||
/* Obtain AA field string from node
|
||||
and write it to directory entry or CE area.
|
||||
*/
|
||||
aapt = NULL;
|
||||
ret = ISO_SUCCESS;
|
||||
num_aapt = 0;
|
||||
|
||||
/* >>> if AAIP is enabled */
|
||||
if (1) {
|
||||
|
||||
ret = iso_node_get_xinfo(n->node, aaip_xinfo_func, &xipt);
|
||||
if (ret == 1) {
|
||||
num_aapt = aaip_count_bytes("AA", (unsigned char *) xipt, 0);
|
||||
if (num_aapt > 0) {
|
||||
aapt = malloc(num_aapt);
|
||||
if (aapt == NULL) {
|
||||
ret = ISO_OUT_OF_MEM;
|
||||
goto add_susp_cleanup;
|
||||
}
|
||||
memcpy(aapt, xipt, num_aapt);
|
||||
ret = aaip_add_AA(t, info, aapt, num_aapt,
|
||||
&sua_free, &ce_len, 0);
|
||||
if (ret < 0) {
|
||||
goto add_susp_cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ! Libisofs_with_aaip_dummY */
|
||||
|
||||
#endif /* Libisofs_with_aaiP */
|
||||
|
||||
@ -1340,15 +1398,18 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
||||
|
||||
#ifdef Libisofs_with_aaip_dummY
|
||||
|
||||
aaip_er_len = 160;
|
||||
if (1) {
|
||||
|
||||
#else /* Libisofs_with_aaip_dummY */
|
||||
|
||||
/* >>> if AAIP is enabled */
|
||||
/* aaip_er_len = 160; */
|
||||
if (1) {
|
||||
|
||||
#endif /* ! Libisofs_with_aaip_dummY */
|
||||
|
||||
aaip_er_len = 160;
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_aaiP */
|
||||
|
||||
ret = susp_add_CE(t, 182 + aaip_er_len, info);
|
||||
@ -1362,22 +1423,25 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
||||
}
|
||||
|
||||
#ifdef Libisofs_with_aaiP
|
||||
/* ts A90113 */
|
||||
|
||||
#ifdef Libisofs_with_aaip_dummY
|
||||
|
||||
/* ts A90113 */
|
||||
ret = aaip_add_ER(t, info, "AA", 0);
|
||||
if (ret < 0) {
|
||||
goto add_susp_cleanup;
|
||||
}
|
||||
if (1) {
|
||||
|
||||
#else /* Libisofs_with_aaip_dummY */
|
||||
|
||||
/* >>> if AAIP is enabled */
|
||||
/* >>> write the ER entry of AAIP : aaip_add_ER() */;
|
||||
if (1) {
|
||||
|
||||
#endif /* ! Libisofs_with_aaip_dummY */
|
||||
|
||||
ret = aaip_add_ER(t, info, "AA", 0);
|
||||
if (ret < 0) {
|
||||
goto add_susp_cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Libisofs_with_aaiP */
|
||||
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ int read_rr_PN(struct susp_sys_user_entry *pn, struct stat *st);
|
||||
|
||||
/* ts A90112
|
||||
<<< write dummy AAIP fields with any node
|
||||
# define Libisofs_with_aaip_dummY yes
|
||||
*/
|
||||
#define Libisofs_with_aaip_dummY yes
|
||||
|
||||
#endif /* LIBISO_ROCKRIDGE_H */
|
||||
|
Loading…
Reference in New Issue
Block a user