- Update address of Free Software Foundation.
[reactos.git] / reactos / subsystems / win32 / win32k / ntuser / useratom.c
1 /*
2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /*
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * PURPOSE: User Atom helper routines
23 * FILE: subsys/win32k/ntuser/useratom.c
24 * PROGRAMER: Filip Navara <xnavara@volny.cz>
25 */
26
27 #include <w32k.h>
28
29 #define NDEBUG
30 #include <debug.h>
31
32 RTL_ATOM FASTCALL
33 IntAddAtom(LPWSTR AtomName)
34 {
35 NTSTATUS Status = STATUS_SUCCESS;
36 PTHREADINFO pti;
37 RTL_ATOM Atom;
38
39 pti = PsGetCurrentThreadWin32Thread();
40 if (pti->Desktop == NULL)
41 {
42 SetLastNtError(Status);
43 return (RTL_ATOM)0;
44 }
45
46 Status = RtlAddAtomToAtomTable(gAtomTable, AtomName, &Atom);
47
48 if (!NT_SUCCESS(Status))
49 {
50 SetLastNtError(Status);
51 return (RTL_ATOM)0;
52 }
53 return Atom;
54 }
55
56 ULONG FASTCALL
57 IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize)
58 {
59 NTSTATUS Status = STATUS_SUCCESS;
60 PTHREADINFO pti;
61 ULONG Size = nSize;
62
63 pti = PsGetCurrentThreadWin32Thread();
64 if (pti->Desktop == NULL)
65 {
66 SetLastNtError(Status);
67 return 0;
68 }
69
70 Status = RtlQueryAtomInAtomTable(gAtomTable, nAtom, NULL, NULL, lpBuffer, &Size);
71
72 if (Size < nSize)
73 *(lpBuffer + Size) = 0;
74 if (!NT_SUCCESS(Status))
75 {
76 SetLastNtError(Status);
77 return 0;
78 }
79 return Size;
80 }
81
82 RTL_ATOM FASTCALL
83 IntAddGlobalAtom(LPWSTR lpBuffer, BOOL PinAtom)
84 {
85 RTL_ATOM Atom;
86 NTSTATUS Status = STATUS_SUCCESS;
87
88 Status = RtlAddAtomToAtomTable(gAtomTable, lpBuffer, &Atom);
89
90 if (!NT_SUCCESS(Status))
91 {
92 DPRINT1("Error init Global Atom.\n");
93 return 0;
94 }
95
96 if ( Atom && PinAtom ) RtlPinAtomInAtomTable(gAtomTable, Atom);
97
98 return Atom;
99 }
100
101 /* EOF */