/* print info for a file or folder thread */
static void record_print_thread(hfsp_cat_thread* entry)
{
    char buf[255]; // mh this _might_ overflow
    unicode_uni2asc(buf, &entry->nodeName, 255);
    printf("parent cnid :\t%ld\n", entry->parentID);
    printf("name        :\t%s\n" , buf);
}
/* print the key of a record */
static void record_print_key(hfsp_cat_key* key)
{
    char buf[255]; // mh this _might_ overflow
    unicode_uni2asc(buf, &key->name, 255);
    printf("parent cnid :    %ld\n",   key->parent_cnid);
    printf("name        :    %s\n", buf);
}
Beispiel #3
0
static int
match_file( record *r, record *parent, const void *match_data, hfsp_file_t *pt )
{
        const char *p = (const char*)match_data;
	char name[256];
	int ret=1;

	if( r->record.type != HFSP_FILE )
		return 1;

	(void) unicode_uni2asc(name, &r->key.name, sizeof(name));
	if( !(ret=strcasecmp(p, name)) && pt )
		pt->rec = *r;

	return ret;
}
Beispiel #4
0
static int
match_path( record *r, record *par, const void *match_data, hfsp_file_t *pt )
{
	char name[256], *s, *next, *org;
	int ret=1;

 	next = org = strdup( (char*)match_data );
	while( (s=strsep( &next, "\\/" )) && !strlen(s) )
		;
	if( !s ) {
		free( org );
		return 1;
	}

	if( *s == ':' && strlen(s) == 5 ) {
		if( r->record.type == HFSP_FILE && !next ) {
			/* match type */
			hfsp_cat_file *file = &r->record.u.file;
			FInfo *fi = &file->user_info;
			int i, type=0;
			for( i=1; s[i] && i<=4; i++ )
				type = (type << 8) | s[i];
			/* printk("fi->fdType: %s / %s\n", s+1, b ); */
			if( fi->fdType == type ) {
				if( pt )
					pt->rec = *r;
				ret = 0;
			}
		}
	} else {
		(void) unicode_uni2asc(name, &r->key.name, sizeof(name));

		if( !strcasecmp(s, name) ) {
			if( r->record.type == HFSP_FILE && !next ) {
				if( pt )
					pt->rec = *r;
				ret = 0;
			} else /* must be a directory */
				ret = search_files( r, 0, match_path, next, pt );
		}
	}
	free( org );
	return ret;
}
Beispiel #5
0
static int
match_rom( record *r, record *par, const void *match_data, hfsp_file_t *pt )
{
	hfsp_cat_file *file = &r->record.u.file;
	FInfo *fi = &file->user_info;
	int ret = 1;
	char buf[256];

	if( r->record.type == HFSP_FILE && fi->fdCreator == MAC_OS_ROM_CREATOR && fi->fdType == MAC_OS_ROM_TYPE ) {
		ret = search_files( par, 0, match_file, "System", NULL )
			|| search_files( par, 0, match_file, "Finder", NULL );

		(void) unicode_uni2asc(buf, &r->key.name, sizeof(buf));
		if( !strcasecmp("BootX", buf) )
			return 1;

		if( !ret && pt )
			pt->rec = *r;
	}
	return ret;
}
Beispiel #6
0
static int
search_files( record *par, int recursive, match_proc_t proc, const void *match_data, hfsp_file_t *pt )
{
	hfsp_file_t t;
	record r;
	int ret = 1;

	t.path = NULL;

	record_init_parent( &r, par );
	do{
		if( r.record.type == HFSP_FOLDER || r.record.type == HFSP_FILE )
			ret = (*proc)( &r, par, match_data, &t );

		if( ret && r.record.type == HFSP_FOLDER && recursive )
			ret = search_files( &r, 1, proc, match_data, &t );

	} while( ret && !record_next(&r) );

	if( !ret && pt ) {
                char name[256];
                const char *s2 = t.path ? t.path : "";

		unicode_uni2asc( name, &r.key.name, sizeof(name));

		pt->rec = t.rec;
		pt->path = malloc( strlen(name) + strlen(s2) + 2 );
		strcpy( pt->path, name );
		if( strlen(s2) ) {
			strcat( pt->path, "\\" );
			strcat( pt->path, s2 );
		}
	}

	if( t.path )
		free( t.path );

	return ret;
}