static _INLINE_ void expand_percent_expression(FILE *f, ext2_filsys fs, char ch, int width, int *first, struct problem_context *ctx) { e2fsck_t e2fsck_ctx = fs ? (e2fsck_t) fs->priv_data : NULL; const char *m; if (!ctx) goto no_context; switch (ch) { case '%': fputc('%', f); break; case 'b': #ifdef EXT2_NO_64_TYPE fprintf(f, "%*u", width, (unsigned long) ctx->blk); #else fprintf(f, "%*llu", width, (unsigned long long) ctx->blk); #endif break; case 'B': if (ctx->blkcount == BLOCK_COUNT_IND) m = _("indirect block"); else if (ctx->blkcount == BLOCK_COUNT_DIND) m = _("double indirect block"); else if (ctx->blkcount == BLOCK_COUNT_TIND) m = _("triple indirect block"); else if (ctx->blkcount == BLOCK_COUNT_TRANSLATOR) m = _("translator block"); else m = _("block #"); if (*first && islower(m[0])) fputc(toupper(*m++), f); fputs(m, f); if (ctx->blkcount >= 0) { #ifdef EXT2_NO_64_TYPE fprintf(f, "%d", ctx->blkcount); #else fprintf(f, "%lld", (long long) ctx->blkcount); #endif } break; case 'c': #ifdef EXT2_NO_64_TYPE fprintf(f, "%*u", width, (unsigned long) ctx->blk2); #else fprintf(f, "%*llu", width, (unsigned long long) ctx->blk2); #endif break; case 'd': fprintf(f, "%*u", width, ctx->dir); break; case 'g': fprintf(f, "%*u", width, ctx->group); break; case 'i': fprintf(f, "%*u", width, ctx->ino); break; case 'j': fprintf(f, "%*u", width, ctx->ino2); break; case 'm': fprintf(f, "%*s", width, error_message(ctx->errcode)); break; case 'N': #ifdef EXT2_NO_64_TYPE fprintf(f, "%*u", width, ctx->num); #else fprintf(f, "%*llu", width, (long long)ctx->num); #endif break; case 'p': print_pathname(f, fs, ctx->ino, 0); break; case 'P': print_pathname(f, fs, ctx->ino2, ctx->dirent ? ctx->dirent->inode : 0); break; case 'q': print_pathname(f, fs, ctx->dir, 0); break; case 'Q': print_pathname(f, fs, ctx->dir, ctx->ino); break; case 'r': #ifdef EXT2_NO_64_TYPE fprintf(f, "%*d", width, ctx->blkcount); #else fprintf(f, "%*lld", width, (long long) ctx->blkcount); #endif break; case 'S': fprintf(f, "%llu", get_backup_sb(NULL, fs, NULL, NULL)); break; case 's': fprintf(f, "%*s", width, ctx->str ? ctx->str : "NULL"); break; case 't': print_time(f, (time_t) ctx->num); break; case 'T': print_time(f, e2fsck_ctx ? e2fsck_ctx->now : time(0)); break; case 'x': fprintf(f, "0x%0*x", width, ctx->csum1); break; case 'X': #ifdef EXT2_NO_64_TYPE fprintf(f, "0x%0*x", width, ctx->num); #else fprintf(f, "0x%0*llx", width, (long long)ctx->num); #endif break; case 'y': fprintf(f, "0x%0*x", width, ctx->csum2); break; default: no_context: fprintf(f, "%%%c", ch); break; } }
static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch, struct problem_context *ctx) { if (!ctx) goto no_context; switch (ch) { case '%': fputc('%', stdout); break; case 'b': printf("%u", ctx->blk); break; case 'B': #ifdef EXT2_NO_64_TYPE printf("%d", ctx->blkcount); #else printf("%lld", (long long)ctx->blkcount); #endif break; case 'c': printf("%u", ctx->blk2); break; case 'd': printf("%u", ctx->dir); break; case 'g': printf("%d", ctx->group); break; case 'i': printf("%u", ctx->ino); break; case 'j': printf("%u", ctx->ino2); break; case 'm': printf("%s", error_message(ctx->errcode)); break; case 'N': #ifdef EXT2_NO_64_TYPE printf("%u", ctx->num); #else printf("%llu", (long long)ctx->num); #endif break; case 'p': print_pathname(fs, ctx->ino, 0); break; case 'P': print_pathname(fs, ctx->ino2, ctx->dirent ? ctx->dirent->inode : 0); break; case 'q': print_pathname(fs, ctx->dir, 0); break; case 'Q': print_pathname(fs, ctx->dir, ctx->ino); break; case 'S': printf("%u", get_backup_sb(NULL, fs, NULL, NULL)); break; case 's': printf("%s", ctx->str ? ctx->str : "NULL"); break; case 'X': #ifdef EXT2_NO_64_TYPE printf("0x%x", ctx->num); #else printf("0x%llx", (long long)ctx->num); #endif break; default: no_context: printf("%%%c", ch); break; } }