fts_debg.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* $MirOS: contrib/hosted/fwcf/fts_debg.c,v 1.2 2006/09/23 23:21:04 tg Exp $ */
  2. /*-
  3. * Copyright (c) 2006
  4. * Thorsten Glaser <tg@mirbsd.de>
  5. *
  6. * Licensee is hereby permitted to deal in this work without restric-
  7. * tion, including unlimited rights to use, publicly perform, modify,
  8. * merge, distribute, sell, give away or sublicence, provided all co-
  9. * pyright notices above, these terms and the disclaimer are retained
  10. * in all redistributions or reproduced in accompanying documentation
  11. * or other materials provided with binary redistributions.
  12. *
  13. * Licensor offers the work "AS IS" and WITHOUT WARRANTY of any kind,
  14. * express, or implied, to the maximum extent permitted by applicable
  15. * law, without malicious intent or gross negligence; in no event may
  16. * licensor, an author or contributor be held liable for any indirect
  17. * or other damage, or direct damage except proven a consequence of a
  18. * direct error of said person and intended use of this work, loss or
  19. * other issues arising in any way out of its use, even if advised of
  20. * the possibility of such damage or existence of a defect.
  21. */
  22. #include <sys/param.h>
  23. #include <sys/stat.h>
  24. #include <stdio.h>
  25. #include "defs.h"
  26. #include "fts_subs.h"
  27. __RCSID("$MirOS: contrib/hosted/fwcf/fts_debg.c,v 1.2 2006/09/23 23:21:04 tg Exp $");
  28. void
  29. ftsf_debugent(ftsf_entry *e)
  30. {
  31. fprintf(stderr,
  32. "%s @%08X %06o %2u %u %06llX %lu:%lu %s/\033[1m%s\033[0m%c\n",
  33. (e->etype == FTSF_DIR ? "DIR" : e->etype == FTSF_FILE ? "REG" :
  34. e->etype == FTSF_SYMLINK ? "SYM" : "OTH"),
  35. (unsigned)e->statp->st_ino, (unsigned)e->statp->st_mode,
  36. e->statp->st_nlink, (unsigned)e->statp->st_mtime,
  37. (uint64_t)e->statp->st_size, (u_long)e->statp->st_uid,
  38. (u_long)e->statp->st_gid, ftsf_prefix, e->pathname,
  39. ((e->statp->st_mode & S_IFMT) == S_IFDIR ? '/' :
  40. (e->statp->st_mode & S_IFMT) == S_IFIFO ? '|' :
  41. (e->statp->st_mode & S_IFMT) == S_IFLNK ? '@' :
  42. (e->statp->st_mode & S_IFMT) == S_IFSOCK ? '=' :
  43. (e->statp->st_mode & S_IFMT) == S_IFBLK ? '&' :
  44. (e->statp->st_mode & S_IFMT) == S_IFCHR ? '%' :
  45. (e->statp->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) ? '*' : '_'));
  46. }