2010-01-26 00:18:02 +01:00
|
|
|
/* This file contains path component name utility functions.
|
|
|
|
*
|
|
|
|
* The entry points into this file are:
|
|
|
|
* normalize_name normalize a path component name for hashing purposes
|
|
|
|
* compare_name check whether two path component names are equivalent
|
|
|
|
*
|
|
|
|
* Created:
|
|
|
|
* April 2009 (D.C. van Moolenbroek)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "inc.h"
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* normalize_name *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void normalize_name(dst, src)
|
2010-01-26 00:18:02 +01:00
|
|
|
char dst[NAME_MAX+1];
|
|
|
|
char *src;
|
|
|
|
{
|
|
|
|
/* Normalize the given path component name, storing the result in the given
|
|
|
|
* buffer.
|
|
|
|
*/
|
|
|
|
size_t i, size;
|
|
|
|
|
|
|
|
size = strlen(src) + 1;
|
|
|
|
|
|
|
|
assert(size <= NAME_MAX+1);
|
|
|
|
|
2012-04-09 18:08:26 +02:00
|
|
|
if (sffs_params->p_case_insens) {
|
2010-01-26 00:18:02 +01:00
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
*dst++ = tolower(*src++);
|
|
|
|
}
|
|
|
|
else memcpy(dst, src, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* compare_name *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int compare_name(name1, name2)
|
2010-01-26 00:18:02 +01:00
|
|
|
char *name1;
|
|
|
|
char *name2;
|
|
|
|
{
|
|
|
|
/* Return TRUE if the given path component names are equivalent, FALSE
|
|
|
|
* otherwise.
|
|
|
|
*/
|
|
|
|
int r;
|
|
|
|
|
2012-04-09 18:08:26 +02:00
|
|
|
if (sffs_params->p_case_insens)
|
2010-01-26 00:18:02 +01:00
|
|
|
r = strcasecmp(name1, name2);
|
|
|
|
else
|
|
|
|
r = strcmp(name1, name2);
|
|
|
|
|
|
|
|
return r ? FALSE : TRUE;
|
|
|
|
}
|