canonicalize.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Return the canonical absolute name of a given file.
  2. Copyright (C) 1996-2007 Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. #ifndef CANONICALIZE_H_
  14. # define CANONICALIZE_H_
  15. # if GNULIB_CANONICALIZE
  16. enum canonicalize_mode_t
  17. {
  18. /* All components must exist. */
  19. CAN_EXISTING = 0,
  20. /* All components excluding last one must exist. */
  21. CAN_ALL_BUT_LAST = 1,
  22. /* No requirements on components existence. */
  23. CAN_MISSING = 2
  24. };
  25. typedef enum canonicalize_mode_t canonicalize_mode_t;
  26. /* Return a malloc'd string containing the canonical absolute name of
  27. the named file. This acts like canonicalize_file_name, except that
  28. whether components must exist depends on the canonicalize_mode_t
  29. argument. */
  30. char *canonicalize_filename_mode (const char *, canonicalize_mode_t);
  31. # endif
  32. # if HAVE_DECL_CANONICALIZE_FILE_NAME
  33. # include <stdlib.h>
  34. # else
  35. /* Return a malloc'd string containing the canonical absolute name of
  36. the named file. If any file name component does not exist or is a
  37. symlink to a nonexistent file, return NULL. A canonical name does
  38. not contain any `.', `..' components nor any repeated file name
  39. separators ('/') or symlinks. */
  40. char *canonicalize_file_name (const char *);
  41. # endif
  42. #endif /* !CANONICALIZE_H_ */