Esempio n. 1
0
int ident(char *fn)
{
   int l;

   if (!is_directory(fn)) {
      l = strlen(fn);
      if (l>4) {
         if (strcmp(&fn[l-4], ".ZIP") == 0) {
            ident_zip(fn);
         } else {
            ident_file(".", fn, -1);
         }
      } else {
         ident_file(".", fn, -1);
      };
   } else {
      ident_dir(fn);
   };
};
Esempio n. 2
0
static char* get_pathname(blk_t inode_nr, char* i_pathname, char *magic_buf, unsigned char* buf){
	struct found_data_t 		*help_data = NULL;
	int				str_len;
	__u32				name_len;
	char				*c;
	int				def_len = 22;
	char				name_str[22];
	__u32				scan = 0;

	help_data = malloc(sizeof(struct found_data_t));
	if (!help_data) return NULL;
	memset (help_data,0, sizeof(struct found_data_t));

	if ( ident_file(help_data,&scan,magic_buf,buf)){
	help_data->type = scan;
	str_len = strlen(magic_buf) + 1;
	c = strpbrk(magic_buf,";:, ");
	if (c){	
		*c = 0;
		name_len = c - magic_buf + def_len;
	} 
	else
		name_len = str_len + def_len;
	
	help_data->scan_result = malloc(str_len);
	help_data->name	 = malloc(name_len);
	if((!help_data->name) || (!help_data->scan_result)){
		free_file_data( help_data );
		fprintf(stderr,"ERROR: allocate memory\n");
	}
	else{
		strcpy(help_data->scan_result,magic_buf);
		strncpy(help_data->name, magic_buf , name_len - def_len+1);
		sprintf(name_str,"/I_%010lu",(long unsigned int)inode_nr);
		strcat(help_data->name,name_str);
		get_file_property(help_data);
	}
	i_pathname = malloc(name_len);
	if (i_pathname)
		strncpy (i_pathname,help_data->name,name_len); 
	}
	free_file_data(help_data);
return i_pathname;
}