New (yet inofficial) -find tests -has_hfs_crtp, has_hfs_bless

This commit is contained in:
Thomas Schmitt 2012-05-31 07:04:46 +00:00
parent 50ce43b470
commit 8907406e5b
5 changed files with 145 additions and 22 deletions

View File

@ -948,6 +948,51 @@ int Findjob_set_filter_filter(struct FindjoB *o, int value, int flag)
}
int Findjob_set_crtp_filter(struct FindjoB *o, char *creator, char *hfs_type,
int flag)
{
struct ExprtesT *t;
int ret;
ret= Findjob_default_and(o, 0);
if(ret <= 0)
return(ret);
t= o->cursor->test;
t->test_type= 18;
t->arg1= calloc(1, strlen(creator) + 1);
t->arg2= calloc(1, strlen(hfs_type) + 1);
if(t->arg1 == NULL || t->arg2 == NULL)
return(-1);
strcpy(t->arg1, creator);
strcpy(t->arg2, hfs_type);
return(1);
}
int Findjob_set_bless_filter(struct XorrisO *xorriso, struct FindjoB *o,
char *blessing, int flag)
{
struct ExprtesT *t;
int ret;
ret= Findjob_default_and(o, 0);
if(ret <= 0)
return(ret);
t= o->cursor->test;
t->test_type= 19;
t->arg1= calloc(1, sizeof(int));
if(t->arg1 == NULL)
return(-1);
ret= Xorriso_hfsplus_bless(xorriso, "", NULL, blessing, 4 | 8);
if(ret <= 0)
return(ret);
*((int *) t->arg1)= ret - 1;
return(1);
}
int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag)
{
struct ExprtesT *t;

View File

@ -46,8 +46,8 @@ struct ExprtesT {
15= -has_md5
16= -disk_name char *arg1 (regex_t in *arg2)
17= -hidden int *arg1 (bit0=iso_rr, bit1=joliet)
>>> -has_hfs_crtp
>>> -has_hfs_bless blessing|any
18= -has_hfs_crtp char *creator char *type
19= -has_hfs_bless int bless_index
*/
int test_type;
@ -223,6 +223,12 @@ int Findjob_set_damage_filter(struct FindjoB *o, int value, int flag);
int Findjob_set_test_hidden(struct FindjoB *o, int mode, int flag);
int Findjob_set_crtp_filter(struct FindjoB *o, char *creator, char *hfs_type,
int flag);
int Findjob_set_bless_filter(struct XorrisO *xorriso, struct FindjoB *o,
char *blessing, int flag);
int Findjob_set_decision(struct FindjoB *o, char *decision, int flag);

View File

@ -2647,15 +2647,16 @@ return:
3 = immediate decision : does match
*/
{
int value=0, ret, start_lba, end_lba;
int value=0, ret, start_lba, end_lba, bless_idx;
int lba_count, *file_end_lbas= NULL, *file_start_lbas= NULL, i, mask;
void *arg1, *arg2;
char ft, *decision, md5[16];
char ft, *decision, md5[16], bless_code[17];
regmatch_t name_match;
off_t damage_start, damage_end, size;
void *xinfo_dummy;
IsoNode *node;
IsoStream *stream;
struct iso_hfsplus_xinfo_data *hfsplus_xinfo;
if(ftest == NULL)
return(1);
@ -2835,6 +2836,32 @@ return:
if((!!(mask & 3)) ^ (!!(ret & LIBISO_HIDE_ON_HFSPLUS)))
value= 0;
break; case 18: /* -has_hfs_crtp char *creator char *type */
ret= iso_node_get_xinfo(node, iso_hfsplus_xinfo_func,
(void **) &hfsplus_xinfo);
value= 0;
if(ret < 0) {
Xorriso_process_msg_queues(xorriso, 0);
ret= 0;
} else if(ret == 1) {
if((strlen(arg1) == 1 ||
(strncmp(arg1, (char *) hfsplus_xinfo->creator_code, 4) == 0 &&
strlen(arg1) == 4)) &&
(strlen(arg2) == 1 ||
(strncmp(arg2, (char *) hfsplus_xinfo->type_code, 4) == 0 &&
strlen(arg2) == 4)))
value= 1;
}
break; case 19: /* -has_hfs_bless int bless_index */
value= 0;
ret= Xorriso_get_blessing(xorriso, node, &bless_idx, bless_code, 0);
if (ret > 0) {
if(*((int *) arg1) == (int) ISO_HFSPLUS_BLESS_MAX ||
*((int *) arg1) == bless_idx)
value= 1;
}
break; default:
/* >>> complain about unknown test type */;
@ -3516,6 +3543,7 @@ set_error:;
/* @param flag bit0= only check creator and hfs_type for compliance.
bit1= with bit0: check for search rather than for setting
*/
int Xorriso_hfsplus_file_creator_type(struct XorrisO *xorriso, char *path,
void *in_node,
@ -3533,6 +3561,15 @@ int Xorriso_hfsplus_file_creator_type(struct XorrisO *xorriso, char *path,
node= (IsoNode *) in_node;
if((creator[0] == 0 && hfs_type[0] == 0) ||
strcmp(creator, "--delete") == 0) {
if(flag & 2) {
strcpy(xorriso->info_text,
"HFS+ file creator code for deletion shall be used for searching");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
strcpy(xorriso->info_text,
"Suitable are strings of length 4 or length 1");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
return(0);
}
if(flag & 1)
return(1);
ret= iso_node_remove_xinfo(node, iso_hfsplus_xinfo_func);
@ -3544,11 +3581,19 @@ int Xorriso_hfsplus_file_creator_type(struct XorrisO *xorriso, char *path,
goto failure;
}
return(1);
} else if(strlen(creator) != 4 || strlen(hfs_type) != 4) {
strcat(xorriso->info_text,
} else if((strlen(creator) != 4 && !(strlen(creator) == 1 &&
(flag & 3) == 3)) ||
(strlen(hfs_type) != 4 && !(strlen(hfs_type) == 1 &&
(flag & 3) == 3))) {
if(flag & 2) {
strcpy(xorriso->info_text,
"HFS+ file creator code or type code for searching are not exactly 1 or 4 characters long");
} else {
strcpy(xorriso->info_text,
"HFS+ file creator code or type code are not exactly 4 characters long");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
if(flag & 1)
return(1);
@ -3599,7 +3644,8 @@ failure:
bit1= Revoke any blessing of the node, regardless of parameter
blessing. If node is NULL, then revoke all blessings in opts.
bit2= Only check parameter blessing.
Return 1 instead of issueing the blessing.
Return blessing index + 1 instead of issueing the blessing.
bit3= Allow blessing "any" and map to index ISO_HFSPLUS_BLESS_MAX
*/
int Xorriso_hfsplus_bless(struct XorrisO *xorriso, char *path,
void *in_node, char *blessing, int flag)
@ -3609,16 +3655,6 @@ int Xorriso_hfsplus_bless(struct XorrisO *xorriso, char *path,
IsoImage *volume= NULL;
enum IsoHfsplusBlessings bless_code = ISO_HFSPLUS_BLESS_MAX; /* = invalid */
if(in_node == NULL && path[0]) {
ret= Xorriso_node_from_path(xorriso, NULL, path, &node, 0);
if(ret <= 0)
return(ret);
} else
node= (IsoNode *) in_node;
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret <= 0)
return(ret);
if(strcmp(blessing, "ppc_bootdir") == 0 ||
strcmp(blessing, "p") == 0 || strcmp(blessing, "P") == 0)
bless_code= ISO_HFSPLUS_BLESS_PPC_BOOTDIR;
@ -3634,15 +3670,28 @@ int Xorriso_hfsplus_bless(struct XorrisO *xorriso, char *path,
else if(strcmp(blessing, "osx_folder") == 0 ||
strcmp(blessing, "x") == 0 || strcmp(blessing, "X") == 0)
bless_code= ISO_HFSPLUS_BLESS_OSX_FOLDER;
else if((flag & 8) && (flag & 4) &&
(strcmp(blessing, "any") == 0 ||
strcmp(blessing, "a") == 0 || strcmp(blessing, "A") == 0))
bless_code= ISO_HFSPLUS_BLESS_MAX;
else {
sprintf(xorriso->info_text, "Unknown blessing type ");
Text_shellsafe(blessing, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
if(flag & 4)
return(1);
return(1 + bless_code);
if(in_node == NULL && path[0]) {
ret= Xorriso_node_from_path(xorriso, NULL, path, &node, 0);
if(ret <= 0)
return(ret);
} else
node= (IsoNode *) in_node;
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret <= 0)
return(ret);
ret= iso_image_hfsplus_bless(volume, bless_code, node, flag & 3);
Xorriso_process_msg_queues(xorriso, 0);
@ -3705,6 +3754,7 @@ int Xorriso_get_blessing(struct XorrisO *xorriso, IsoNode *node,
break; default:
strcpy(bless_code, "unknown_blessing");
}
*bless_idx= i;
return(1);
}
}

View File

@ -796,6 +796,28 @@ not_enough_arguments:;
goto sorry_ex;
}
}
} else if(strcmp(argv[i], "-has_hfs_crtp")==0) {
if(i + 2 >= end_idx)
goto not_enough_arguments;
i+= 2;
ret= Xorriso_hfsplus_file_creator_type(xorriso, "", NULL,
argv[i - 1], argv[i], 3);
ret= Findjob_set_crtp_filter(job, argv[i - 1], argv[i], 0);
if(ret <= 0) {
sprintf(xorriso->info_text, "-findi: cannot setup -has_hfs_crtp test");
goto sorry_ex;
}
} else if(strcmp(argv[i], "-has_hfs_bless")==0) {
if(i + 1 >= end_idx)
goto not_enough_arguments;
i+= 1;
ret= Findjob_set_bless_filter(xorriso, job, argv[i], 0);
if(ret <= 0) {
sprintf(xorriso->info_text, "-findi: cannot setup -has_hfs_bless test");
goto sorry_ex;
}
} else if(strcmp(argv[i], "-true") == 0) {
ret= Findjob_set_false(job, -1, 0);
} else if(strcmp(argv[i], "-false") == 0) {

View File

@ -1 +1 @@
#define Xorriso_timestamP "2012.05.30.153449"
#define Xorriso_timestamP "2012.05.31.070528"