reactos/rosapps/smartpdf/fitz/samus/sa_misc.c
Klemens Friedl 435a566751 SmartPDF - lightweight pdf viewer app for rosapps
* sumatrapdf - vendor import
* everything compiles (libjpeg, poppler, fitz, sumatrapdf)
* does NOT link

(remove the comment tags in the parent directory.rbuild file (rosapps dir) to build it)

svn path=/trunk/; revision=29295
2007-09-29 08:39:35 +00:00

56 lines
1 KiB
C

#include "fitz.h"
#include "samus.h"
/*
* Create a new canonical absolute path given both
* a base url (current directory) and a relative or absolute name.
*/
char *
sa_resolvepath(char *dst, char *baseurl, char *parturl, int dstlen)
{
char *end;
if (parturl[0] == '/')
{
strlcpy(dst, parturl, dstlen);
}
else
{
strlcpy(dst, baseurl, dstlen);
end = strrchr(dst, '/');
if (end)
end[1] = 0;
strlcat(dst, parturl, dstlen);
cleanname(dst);
}
return dst;
}
/*
* Test part names for equivalence.
*
* What we *should* do here (according to the spec) is...
* - Convert part name to a Unicode string by un-escaping UTF-8 octets.
* - Convert this to upper case.
* - Normalize to NFC.
*
* But all we do is a case insensitive ASCII string comparison.
*/
static inline int toupper(int c)
{
if (c >= 'a' && c <= 'z')
return c + 'A' - 'a';
return c;
}
int sa_strcmp(char *a, char *b)
{
while (toupper(*a) == toupper(*b++))
if (*a++ == 0)
return 0;
return toupper(*a) - toupper(*(b-1));
}