summaryrefslogtreecommitdiff
path: root/dix/dixutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'dix/dixutils.c')
-rw-r--r--dix/dixutils.c70
1 files changed, 49 insertions, 21 deletions
diff --git a/dix/dixutils.c b/dix/dixutils.c
index 40f80d348..5bd5841a9 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -152,6 +152,22 @@ ClientTimeToServerTime(c)
* beware of too-small buffers
*/
+static unsigned char
+ISOLatin1ToLower (unsigned char source)
+{
+ unsigned char dest;
+ if ((source >= XK_A) && (source <= XK_Z))
+ dest = source + (XK_a - XK_A);
+ else if ((source >= XK_Agrave) && (source <= XK_Odiaeresis))
+ dest = source + (XK_agrave - XK_Agrave);
+ else if ((source >= XK_Ooblique) && (source <= XK_Thorn))
+ dest = source + (XK_oslash - XK_Ooblique);
+ else
+ dest = source;
+ return dest;
+}
+
+
void
CopyISOLatin1Lowered(dest, source, length)
register unsigned char *dest, *source;
@@ -160,17 +176,27 @@ CopyISOLatin1Lowered(dest, source, length)
register int i;
for (i = 0; i < length; i++, source++, dest++)
+ *dest = ISOLatin1ToLower (*source);
+ *dest = '\0';
+}
+
+int
+CompareISOLatin1Lowered(unsigned char *s1, int s1len,
+ unsigned char *s2, int s2len)
+{
+ unsigned char c1, c2;
+
+ for (;;)
{
- if ((*source >= XK_A) && (*source <= XK_Z))
- *dest = *source + (XK_a - XK_A);
- else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis))
- *dest = *source + (XK_agrave - XK_Agrave);
- else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn))
- *dest = *source + (XK_oslash - XK_Ooblique);
- else
- *dest = *source;
+ /* note -- compare against zero so that -1 ignores len */
+ c1 = s1len-- ? *s1++ : '\0';
+ c2 = s2len-- ? *s2++ : '\0';
+ if (!c1 ||
+ (c1 != c2 &&
+ (c1 = ISOLatin1ToLower (c1)) != (c2 = ISOLatin1ToLower (c2))))
+ break;
}
- *dest = '\0';
+ return (int) c1 - (int) c2;
}
#ifdef XCSECURITY
@@ -321,13 +347,14 @@ LookupClient(rid, client)
int
-AlterSaveSetForClient(client, pWin, mode)
- ClientPtr client;
- WindowPtr pWin;
- unsigned mode;
+AlterSaveSetForClient(ClientPtr client,
+ WindowPtr pWin,
+ unsigned mode,
+ Bool toRoot,
+ Bool remap)
{
int numnow;
- pointer *pTmp = NULL;
+ SaveSetElt *pTmp = NULL;
int j;
numnow = client->numSaved;
@@ -335,7 +362,7 @@ AlterSaveSetForClient(client, pWin, mode)
if (numnow)
{
pTmp = client->saveSet;
- while ((j < numnow) && (pTmp[j] != (pointer)pWin))
+ while ((j < numnow) && (SaveSetWindow(pTmp[j]) != (pointer)pWin))
j++;
}
if (mode == SetModeInsert)
@@ -343,12 +370,14 @@ AlterSaveSetForClient(client, pWin, mode)
if (j < numnow) /* duplicate */
return(Success);
numnow++;
- pTmp = (pointer *)xrealloc(client->saveSet, sizeof(pointer) * numnow);
+ pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow);
if (!pTmp)
return(BadAlloc);
client->saveSet = pTmp;
client->numSaved = numnow;
- client->saveSet[numnow - 1] = (pointer)pWin;
+ SaveSetAssignWindow(client->saveSet[numnow - 1], pWin);
+ SaveSetAssignToRoot(client->saveSet[numnow - 1], toRoot);
+ SaveSetAssignRemap(client->saveSet[numnow - 1], remap);
return(Success);
}
else if ((mode == SetModeDelete) && (j < numnow))
@@ -361,15 +390,14 @@ AlterSaveSetForClient(client, pWin, mode)
numnow--;
if (numnow)
{
- pTmp = (pointer *)xrealloc(client->saveSet,
- sizeof(pointer) * numnow);
+ pTmp = (SaveSetElt *)xrealloc(client->saveSet, sizeof(*pTmp) * numnow);
if (pTmp)
client->saveSet = pTmp;
}
else
{
xfree(client->saveSet);
- client->saveSet = (pointer *)NULL;
+ client->saveSet = (SaveSetElt *)NULL;
}
client->numSaved = numnow;
return(Success);
@@ -388,7 +416,7 @@ DeleteWindowFromAnySaveSet(pWin)
{
client = clients[i];
if (client && client->numSaved)
- (void)AlterSaveSetForClient(client, pWin, SetModeDelete);
+ (void)AlterSaveSetForClient(client, pWin, SetModeDelete, FALSE, TRUE);
}
}