+static int print_filename(FILE *f, struct ext2_dir_entry *dirent, int options)
+{
+ unsigned char ch;
+ const char *cp = dirent->name;
+ int len = ext2fs_dirent_name_len(dirent);
+ int retlen = 0;
+
+ if ((options & ENCRYPT_OPT) && !(options & RAW_OPT)) {
+ if (f)
+ return fprintf(f, "<encrypted (%d)>", len);
+ else {
+ char tmp[1];
+ return snprintf(tmp, sizeof(tmp),
+ "<encrypted (%d)>", len);
+ }
+ }
+ while (len--) {
+ ch = *cp++;
+ if (ch > 128) {
+ if (f)
+ fputs("M-", f);
+ ch -= 128;
+ retlen += 2;
+ }
+ if ((ch < 32) || (ch == 0x7f)) {
+ if (f)
+ fputc('^', f);
+ ch ^= 0x40; /* ^@, ^A, ^B; ^? for DEL */
+ retlen++;
+ }
+ if (f)
+ fputc(ch, f);
+ retlen++;
+ }
+ return retlen;
+}
+