Lines Matching defs:path
66 #define isstdin(path) ((path)[0] == '-' && !(path)[1])
77 static int ckdist(const char *path, int type);
78 static int chkmd5(FILE * fp, const char *path);
79 static int chkinf(FILE * fp, const char *path);
80 static int report(const char *path, const char *name, int error);
81 static const char *distname(const char *path, const char *name,
83 static const char *stripath(const char *path);
84 static int distfile(const char *path);
86 static int fail(const char *path, const char *msg);
184 ckdist(const char *path, int type)
189 if (isstdin(path)) {
190 path = "(stdin)";
192 } else if ((fp = fopen(path, "r")) == NULL)
193 return fail(path, NULL);
196 type = distfile(path);
205 rval = chkmd5(fp, path);
208 rval = chkinf(fp, path);
211 rval = report(path, NULL, E_UNKNOWN);
214 warn("%s", path);
216 err(2, "%s", path);
221 chkmd5(FILE * fp, const char *path)
243 if ((dname = distname(path, name, NULL)) == NULL)
258 rval |= report(path, dname, error);
266 chkinf(FILE * fp, const char *path)
293 else if ((dname = distname(fp == stdin ? NULL : path, NULL,
313 rval |= report(path, dname, error);
321 report(const char *path, const char *name, int error)
327 printf("%s: Unknown format\n", path);
330 printf("%s: Invalid MD5 format\n", path);
333 printf("%s: Invalid .inf format\n", path);
336 printf("%s: Can't derive component name\n", path);
339 printf("%s: %s: Size mismatch\n", path, name);
342 printf("%s: %s: Checksum mismatch\n", path, name);
345 printf("%s: %s: %s\n", path, name, sys_errlist[errno]);
348 printf("%s: %s: OK\n", path, name);
354 distname(const char *path, const char *name, const char *ext)
363 if (!path)
365 name = stripath(path);
372 path = opt_dir;
373 plen = strlen(path);
375 plen = path && (s = strrchr(path, '/')) != NULL ?
376 (size_t)(s - path) : 0;
381 memcpy(s, path, plen);
397 stripath(const char *path)
401 return ((s = strrchr(path, '/')) != NULL && s[1] ?
402 s + 1 : path);
406 distfile(const char *path)
411 if ((type = disttype(path)) == DISTMD5 ||
412 ((s = strrchr(path, '.')) != NULL && s > path &&
431 fail(const char *path, const char *msg)
435 warnx("%s: %s", path, msg ? msg : sys_errlist[errno]);