ReactOS 0.4.15-dev-5669-g09dde2c
nbcmdqueue.c File Reference
#include "netapi32.h"
Include dependency graph for nbcmdqueue.c:

Go to the source code of this file.

Classes

struct  NBCmdQueue
 

Macros

#define CANCEL_EVENT_PTR(ncb)   (PHANDLE)((ncb)->ncb_reserve)
 
#define NEXT_PTR(ncb)   (PNCB *)((ncb)->ncb_reserve + sizeof(HANDLE))
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (netbios)
 
struct NBCmdQueueNBCmdQueueCreate (HANDLE heap)
 
UCHAR NBCmdQueueAdd (struct NBCmdQueue *queue, PNCB ncb)
 
static PNCBNBCmdQueueFindNBC (struct NBCmdQueue *queue, PNCB ncb)
 
UCHAR NBCmdQueueCancel (struct NBCmdQueue *queue, PNCB ncb)
 
UCHAR NBCmdQueueComplete (struct NBCmdQueue *queue, PNCB ncb, UCHAR retcode)
 
UCHAR NBCmdQueueCancelAll (struct NBCmdQueue *queue)
 
void NBCmdQueueDestroy (struct NBCmdQueue *queue)
 

Macro Definition Documentation

◆ CANCEL_EVENT_PTR

#define CANCEL_EVENT_PTR (   ncb)    (PHANDLE)((ncb)->ncb_reserve)

Definition at line 29 of file nbcmdqueue.c.

◆ NEXT_PTR

#define NEXT_PTR (   ncb)    (PNCB *)((ncb)->ncb_reserve + sizeof(HANDLE))

Definition at line 30 of file nbcmdqueue.c.

Function Documentation

◆ NBCmdQueueAdd()

UCHAR NBCmdQueueAdd ( struct NBCmdQueue queue,
PNCB  ncb 
)

Definition at line 70 of file nbcmdqueue.c.

71{
72 UCHAR ret;
73
74 TRACE(": queue %p, ncb %p\n", queue, ncb);
75
76 if (!queue)
77 return NRC_BADDR;
78 if (!ncb)
79 return NRC_INVADDRESS;
80
81 *CANCEL_EVENT_PTR(ncb) = NULL;
83 *NEXT_PTR(ncb) = queue->head;
84 queue->head = ncb;
87 TRACE("returning 0x%02x\n", ret);
88 return ret;
89}
Definition: _queue.h:67
#define NULL
Definition: types.h:112
#define NRC_BADDR
Definition: nb30.h:57
#define NRC_GOODRET
Definition: nb30.h:52
#define NRC_INVADDRESS
Definition: nb30.h:85
#define NEXT_PTR(ncb)
Definition: nbcmdqueue.c:30
#define CANCEL_EVENT_PTR(ncb)
Definition: nbcmdqueue.c:29
#define TRACE(s)
Definition: solgame.cpp:4
int ret
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by nbDispatch().

◆ NBCmdQueueCancel()

UCHAR NBCmdQueueCancel ( struct NBCmdQueue queue,
PNCB  ncb 
)

Definition at line 106 of file nbcmdqueue.c.

107{
108 UCHAR ret;
109 PNCB *spot;
110
111 TRACE(": queue %p, ncb %p\n", queue, ncb);
112
113 if (!queue)
114 return NRC_BADDR;
115 if (!ncb)
116 return NRC_INVADDRESS;
117
119 spot = NBCmdQueueFindNBC(queue, ncb);
120 if (spot)
121 {
125 *spot = *NEXT_PTR(*spot);
126 if (ncb->ncb_retcode == NRC_CMDCAN)
127 ret = NRC_CMDCAN;
128 else
130 }
131 else
134 TRACE("returning 0x%02x\n", ret);
135 return ret;
136}
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INFINITE
Definition: serial.h:102
#define NRC_CMDCAN
Definition: nb30.h:61
#define NRC_CANOCCR
Definition: nb30.h:77
static PNCB * NBCmdQueueFindNBC(struct NBCmdQueue *queue, PNCB ncb)
Definition: nbcmdqueue.c:91
Definition: nb30.h:148
UCHAR ncb_retcode
Definition: nb30.h:150
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651

Referenced by nbCancel(), and NBCmdQueueCancelAll().

◆ NBCmdQueueCancelAll()

UCHAR NBCmdQueueCancelAll ( struct NBCmdQueue queue)

Definition at line 167 of file nbcmdqueue.c.

168{
169 UCHAR ret;
170
171 TRACE(": queue %p\n", queue);
172
173 if (!queue)
174 return NRC_BADDR;
175
177 while (queue->head)
178 {
179 TRACE(": waiting for ncb %p (command 0x%02x)\n", queue->head,
180 queue->head->ncb_command);
182 }
185 TRACE("returning 0x%02x\n", ret);
186 return ret;
187}
UCHAR NBCmdQueueCancel(struct NBCmdQueue *queue, PNCB ncb)
Definition: nbcmdqueue.c:106

Referenced by NBCmdQueueDestroy(), nbReset(), and nbShutdownAdapter().

◆ NBCmdQueueComplete()

UCHAR NBCmdQueueComplete ( struct NBCmdQueue queue,
PNCB  ncb,
UCHAR  retcode 
)

Definition at line 138 of file nbcmdqueue.c.

139{
140 UCHAR ret;
141 PNCB *spot;
142
143 TRACE(": queue %p, ncb %p\n", queue, ncb);
144
145 if (!queue)
146 return NRC_BADDR;
147 if (!ncb)
148 return NRC_INVADDRESS;
149
151 spot = NBCmdQueueFindNBC(queue, ncb);
152 if (spot)
153 {
154 if (*CANCEL_EVENT_PTR(*spot))
155 SetEvent(*CANCEL_EVENT_PTR(*spot));
156 else
157 *spot = *NEXT_PTR(*spot);
159 }
160 else
163 TRACE("returning 0x%02x\n", ret);
164 return ret;
165}
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733

Referenced by nbDispatch().

◆ NBCmdQueueCreate()

struct NBCmdQueue * NBCmdQueueCreate ( HANDLE  heap)

Definition at line 53 of file nbcmdqueue.c.

54{
55 struct NBCmdQueue *queue;
56
57 if (heap == NULL)
59 queue = HeapAlloc(heap, 0, sizeof(struct NBCmdQueue));
60 if (queue)
61 {
62 queue->heap = heap;
64 queue->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": NBCmdQueue.cs");
65 queue->head = NULL;
66 }
67 return queue;
68}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
static HANDLE heap
Definition: heap.c:65
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define DWORD_PTR
Definition: treelist.c:76

Referenced by NetBIOSRegisterAdapter().

◆ NBCmdQueueDestroy()

void NBCmdQueueDestroy ( struct NBCmdQueue queue)

Definition at line 189 of file nbcmdqueue.c.

190{
191 TRACE(": queue %p\n", queue);
192
193 if (queue)
194 {
196 queue->cs.DebugInfo->Spare[0] = 0;
198 HeapFree(queue->heap, 0, queue);
199 }
200}
#define HeapFree(x, y, z)
Definition: compat.h:735
UCHAR NBCmdQueueCancelAll(struct NBCmdQueue *queue)
Definition: nbcmdqueue.c:167
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by nbShutdownAdapter().

◆ NBCmdQueueFindNBC()

static PNCB * NBCmdQueueFindNBC ( struct NBCmdQueue queue,
PNCB  ncb 
)
static

Definition at line 91 of file nbcmdqueue.c.

92{
93 PNCB *ret;
94
95 if (!queue || !ncb)
96 ret = NULL;
97 else
98 {
99 ret = &queue->head;
100 while (ret && *ret != ncb)
101 ret = NEXT_PTR(*ret);
102 }
103 return ret;
104}

Referenced by NBCmdQueueCancel(), and NBCmdQueueComplete().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( netbios  )