ls.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef VSF_LS_H
  2. #define VSF_LS_H
  3. struct mystr;
  4. struct mystr_list;
  5. struct vsf_sysutil_dir;
  6. /* vsf_ls_populate_dir_list()
  7. * PURPOSE
  8. * Given a directory handle, populate a formatted directory entry list (/bin/ls
  9. * format). Also optionally populate a list of subdirectories.
  10. * PARAMETERS
  11. * p_list - the string list object for the result list of entries
  12. * p_subdir_list - the string list object for the result list of
  13. * subdirectories. May be 0 if client is not interested.
  14. * p_dir - the directory object to be listed
  15. * p_base_dir_str - the directory name we are listing, relative to current
  16. * p_option_str - the string of options given to the LIST/NLST command
  17. * p_filter_str - the filter string given to LIST/NLST - e.g. "*.mp3"
  18. * is_verbose - set to 1 for LIST, 0 for NLST
  19. */
  20. void vsf_ls_populate_dir_list(struct mystr_list* p_list,
  21. struct mystr_list* p_subdir_list,
  22. struct vsf_sysutil_dir* p_dir,
  23. const struct mystr* p_base_dir_str,
  24. const struct mystr* p_option_str,
  25. const struct mystr* p_filter_str,
  26. int is_verbose);
  27. /* vsf_filename_passes_filter()
  28. * PURPOSE
  29. * Determine whether the given filename is matched by the given filter string.
  30. * The format of the filter string is a small subset of a regular expression.
  31. * Currently, just * and ? are supported.
  32. * PARAMETERS
  33. * p_filename_str - the filename to match
  34. * p_filter_str - the filter to match against
  35. * iters - pointer to a zero-seeded int which prevents the match
  36. * loop from running an excessive number of times
  37. * RETURNS
  38. * Returns 1 if there is a match, 0 otherwise.
  39. */
  40. int vsf_filename_passes_filter(const struct mystr* p_filename_str,
  41. const struct mystr* p_filter_str,
  42. unsigned int* iters);
  43. #endif /* VSF_LS_H */