Fixes to allow versionless packages on cd
[minix3.git] / servers / hgfs / name.c
blob39aa54063f489a54d9b8ea3c1bbc1c05cdd1269e
1 /* This file contains path component name utility functions.
3 * The entry points into this file are:
4 * normalize_name normalize a path component name for hashing purposes
5 * compare_name check whether two path component names are equivalent
7 * Created:
8 * April 2009 (D.C. van Moolenbroek)
9 */
11 #include "inc.h"
13 #include <ctype.h>
15 /*===========================================================================*
16 * normalize_name *
17 *===========================================================================*/
18 PUBLIC void normalize_name(dst, src)
19 char dst[NAME_MAX+1];
20 char *src;
22 /* Normalize the given path component name, storing the result in the given
23 * buffer.
25 size_t i, size;
27 size = strlen(src) + 1;
29 assert(size <= NAME_MAX+1);
31 if (opt.case_insens) {
32 for (i = 0; i < size; i++)
33 *dst++ = tolower(*src++);
35 else memcpy(dst, src, size);
38 /*===========================================================================*
39 * compare_name *
40 *===========================================================================*/
41 PUBLIC int compare_name(name1, name2)
42 char *name1;
43 char *name2;
45 /* Return TRUE if the given path component names are equivalent, FALSE
46 * otherwise.
48 int r;
50 if (opt.case_insens)
51 r = strcasecmp(name1, name2);
52 else
53 r = strcmp(name1, name2);
55 return r ? FALSE : TRUE;