MCPcopy Create free account
hub / github.com/OpenPrinting/cups / valid_path

Function valid_path

systemv/cupstestppd.c:3876–3952  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3874 */
3875
3876static int /* O - Errors found */
3877valid_path(const char *keyword, /* I - Keyword using path */
3878 const char *path, /* I - Path to check */
3879 int errors, /* I - Errors found */
3880 int verbose, /* I - Verbosity level */
3881 int warn) /* I - Warnings only? */
3882{
3883 cups_dir_t *dir; /* Current directory */
3884 cups_dentry_t *dentry; /* Current directory entry */
3885 char temp[1024], /* Temporary path */
3886 *ptr; /* Pointer into temporary path */
3887 const char *prefix; /* WARN/FAIL prefix */
3888
3889
3890 prefix = warn ? " WARN " : "**FAIL**";
3891
3892 /*
3893 * Loop over the components of the path, checking that the entry exists with
3894 * the same capitalization...
3895 */
3896
3897 strlcpy(temp, path, sizeof(temp));
3898
3899 while ((ptr = strrchr(temp, '/')) != NULL)
3900 {
3901 /*
3902 * Chop off the trailing component so temp == dirname and ptr == basename.
3903 */
3904
3905 *ptr++ = '\0';
3906
3907 /*
3908 * Try opening the directory containing the base name...
3909 */
3910
3911 if (temp[0])
3912 dir = cupsDirOpen(temp);
3913 else
3914 dir = cupsDirOpen("/");
3915
3916 if (!dir)
3917 dentry = NULL;
3918 else
3919 {
3920 while ((dentry = cupsDirRead(dir)) != NULL)
3921 {
3922 if (!strcmp(dentry->filename, ptr))
3923 break;
3924 }
3925
3926 cupsDirClose(dir);
3927 }
3928
3929 /*
3930 * Display an error if the filename doesn't exist with the same
3931 * capitalization...
3932 */
3933

Callers 2

check_filtersFunction · 0.85
check_profilesFunction · 0.85

Calls 5

cupsDirOpenFunction · 0.85
cupsDirReadFunction · 0.85
cupsDirCloseFunction · 0.85
_cupsLangPutsFunction · 0.85
_cupsLangPrintfFunction · 0.85

Tested by

no test coverage detected