ntdll / kernel32: #52

Robert Shearman rob at codeweavers.com
Sat Dec 11 10:47:16 CST 2004


Eric Pouech wrote:

> Moving atom implementation to:
> - dlls/kernel32/atom16.c for the 16 bit part
> - dlls/ntdll/ntdll.c for the 32 bit part
>
> A+
>
>------------------------------------------------------------------------
>
>Name:          ntkrnl_52
>ChangeLog:     
>	- moved 16 bit atom support in (16bit) dlls/kernel/atom16.c
>	- added atom support to NTDLL
>	- made 32 bit atom support in kernel32 call ntdll's brand new one
>	- copied the atom tests for global atom so that we can test local atoms too
>License:       X11
>GenDate:       2004/12/11 12:59:19 UTC
>ModifiedFiles: dlls/kernel/Makefile.in dlls/kernel/atom.c dlls/kernel/tests/atom.c dlls/ntdll/Makefile.in dlls/ntdll/ntdll.spec include/winternl.h server/protocol.def server/atom.c
>AddedFiles:    dlls/kernel/atom16.c dlls/ntdll/atom.c
>  
>
...


>--- /dev/null	1970-01-01 01:00:00.000000000 +0100
>+++ dlls/ntdll/atom.c	2004-12-04 15:31:03.000000000 +0100
>@@ -0,0 +1,331 @@
>+/*
>+ * Atom table functions
>+ *
>+ * Copyright 1993, 1994, 1995 Alexandre Julliard
>+ * Copyright 2004 Eric Pouech
>+ *
>+ * This library is free software; you can redistribute it and/or
>+ * modify it under the terms of the GNU Lesser General Public
>+ * License as published by the Free Software Foundation; either
>+ * version 2.1 of the License, or (at your option) any later version.
>+ *
>+ * This library is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with this library; if not, write to the Free Software
>+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>+ */
>+
>+#include "config.h"
>+#include "wine/port.h"
>+
>+#include <stdlib.h>
>+#include <stdarg.h>
>+#include <stdio.h>
>+#include <string.h>
>+#include <ctype.h>
>+
>+#include "windef.h"
>+#include "winbase.h"
>+#include "ntstatus.h"
>+
>+#include "wine/server.h"
>+#include "wine/unicode.h"
>+
>+#include "wine/debug.h"
>+
>+WINE_DEFAULT_DEBUG_CHANNEL(atom);
>+
>+#define DEFAULT_ATOMTABLE_SIZE    37
>+#define MAX_ATOM_LEN              255
>+
>+/******************************************************************
>+ *		is_integral_atom
>+ * Returns STATUS_SUCCESS if integral atom and 'pAtom' is filled
>+ *         STATUS_INVALID_PARAMETER if 'atomstr' is too long
>+ *         STATUS_MORE_ENTRIES otherwise
>+ */
>+static NTSTATUS is_integral_atom( LPCWSTR atomstr, ATOM* pAtom )
>+{
>+    ATOM atom;
>+
>+    if (HIWORD( atomstr ))
>+    {
>+        const WCHAR* ptr = atomstr;
>+        if (*ptr++ == '#')
>+        {
>+            atom = 0;
>+            while (*ptr >= '0' && *ptr <= '9')
>+            {
>+                atom = atom * 10 + *ptr++ - '0';
>+            }
>+            if (ptr > atomstr + 1 && !*ptr) goto done;
>+        }
>+        if (strlenW( atomstr ) > MAX_ATOM_LEN) return STATUS_INVALID_PARAMETER;
>+        return STATUS_MORE_ENTRIES;
>+    }
>+    else atom = LOWORD( atomstr );
>+done:
>+    if (atom >= MAXINTATOM) return STATUS_INVALID_PARAMETER;
>+    *pAtom = atom;
>+    return STATUS_SUCCESS;
>+}
>+
>+/******************************************************************
>+ *		RtlDeleteAtomFromAtomTable (NTDLL.@)
>+ */
>+NTSTATUS WINAPI RtlDeleteAtomFromAtomTable( void* table, ATOM atom )
>+{
>+    NTSTATUS    status;
>+
>+    TRACE( "%p %x\n", table, atom );
>+    SERVER_START_REQ( delete_atom )
>+    {
>+        req->atom = atom;
>+        req->table = table;
>+        status = wine_server_call( req );
>+    }
>+    SERVER_END_REQ;
>+    return status;
>+}
>  
>

Rtl* functions should generally avoid doing server calls. You should 
implement the Rtl* functions on top of the Nt* functions, not the other 
way around.

...

>+/******************************************************************
>+ *		NtDeleteAtom (NTDLL.@)
>+ */
>+NTSTATUS WINAPI NtDeleteAtom(ATOM atom)
>+{
>+    return RtlDeleteAtomFromAtomTable( GLOBAL_ATOM_TABLE, atom );
>+}
>  
>

Rob



More information about the wine-devel mailing list