Put Vizzini's "csq.h" in the Public Domain with permission from the author:
[reactos.git] / reactos / include / ddk / csq.h
index d3d2d3e..99056f6 100644 (file)
@@ -1,7 +1,17 @@
 /*
  * Cancel-Safe Queue Library
- * Copyright (c) 2004, Vizzini (vizzini@plasmic.com)
- * Licensed under the GNU GPL for the ReactOS project
+ * Created in 2004 by Vizzini (vizzini@plasmic.com)
+ *
+ * THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ * This source code is offered for use in the public domain. You may
+ * use, modify or distribute it freely.
+ *
+ * This code is distributed in the hope that it will be useful but
+ * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ * DISCLAIMED. This includes but is not limited to warranties of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
  *
  * This header defines the interface to the ReactOS Cancel-Safe Queue library.
  * This interface is based on and is similar to the Microsoft Cancel-Safe
@@ -34,8 +44,8 @@
  *
  * USAGE
  *
- * This library follows exactly the same interface as the Microsoft Cancel-Safe Queue
- * routines (IoCsqXxx()).  As such, the authoritative reference is the
+ * This library follows exactly the same interface as the Microsoft Cancel-Safe
+ * Queue routines (IoCsqXxx()).  As such, the authoritative reference is the
  * current DDK.  There is also a DDK sample called "cancel" that has an
  * example of how to use this code.  I have also provided a sample driver
  * that makes use of this queue. Finally, please do read the header and the
 #ifndef _REACTOS_CSQ_H
 #define _REACTOS_CSQ_H
 
+/*
+ * Prevent including the CSQ definitions twice. They're present in NTDDK
+ * now too, except the *_EX versions.
+ */
+#ifndef IO_TYPE_CSQ_IRP_CONTEXT
+
 struct _IO_CSQ;
 
 
@@ -62,7 +78,7 @@ struct _IO_CSQ;
  * Function to insert an IRP in the queue.  No need to worry about locking;
  * just tack it onto your list or something.
  *
- * Sample implementation: 
+ * Sample implementation:
  *
        VOID NTAPI CsqInsertIrp(PIO_CSQ Csq, PIRP Irp)
        {
@@ -75,24 +91,6 @@ typedef VOID (NTAPI *PIO_CSQ_INSERT_IRP) (struct _IO_CSQ *Csq,
                                           PIRP Irp);
 
 
-/*
- * Function to insert an IRP into the queue with extended context information.
- * This is useful if you need to be able to de-queue particular IRPs more
- * easily in some cases.
- *
- * Same deal as above; sample implementation:
- *
-       NTSTATUS NTAPI CsqInsertIrpEx(PIO_CSQ Csq, PIRP Irp, PVOID InsertContext)
-       {
-               CsqInsertIrp(Csq, Irp);
-               return STATUS_PENDING;
-       }
- *
- */
-typedef NTSTATUS (NTAPI *PIO_CSQ_INSERT_IRP_EX) (struct _IO_CSQ *Csq,
-                                                 PIRP Irp,
-                                                 PVOID InsertContext);
-
 /*
  * Function to remove an IRP from the queue.
  *
@@ -163,7 +161,7 @@ typedef VOID (NTAPI *PIO_CSQ_RELEASE_LOCK) (struct _IO_CSQ *Csq,
 /*
  * Finally, this is called by the queue library when it wants to complete
  * a canceled IRP.
- * 
+ *
  * Sample:
  *
        VOID NTAPI CsqCompleteCancelledIrp(PIO_CSQ Csq, PIRP Irp)
@@ -188,7 +186,6 @@ typedef VOID (NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP) (struct _IO_CSQ *Csq,
  */
 #define IO_TYPE_CSQ_IRP_CONTEXT 1
 #define IO_TYPE_CSQ 2
-#define IO_TYPE_CSQ_EX 3
 
 /*
  * IO_CSQ - Queue control structure
@@ -213,6 +210,28 @@ typedef struct _IO_CSQ_IRP_CONTEXT {
        PIO_CSQ Csq;
 } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT;
 
+#endif /* IO_TYPE_CSQ_IRP_CONTEXT */
+
+/* See IO_TYPE_CSQ_* above */
+#define IO_TYPE_CSQ_EX 3
+
+/*
+ * Function to insert an IRP into the queue with extended context information.
+ * This is useful if you need to be able to de-queue particular IRPs more
+ * easily in some cases.
+ *
+ * Same deal as above; sample implementation:
+ *
+       NTSTATUS NTAPI CsqInsertIrpEx(PIO_CSQ Csq, PIRP Irp, PVOID InsertContext)
+       {
+               CsqInsertIrp(Csq, Irp);
+               return STATUS_PENDING;
+       }
+ *
+ */
+typedef NTSTATUS (NTAPI *PIO_CSQ_INSERT_IRP_EX) (struct _IO_CSQ *Csq,
+                                                 PIRP Irp,
+                                                 PVOID InsertContext);
 
 /*
  * CANCEL-SAFE QUEUE DDIs
@@ -228,6 +247,7 @@ typedef struct _IO_CSQ_IRP_CONTEXT {
  * As long as the Csq struct and the functions you pass in are resident,
  * there are no IRQL restrictions.
  */
+NTKERNELAPI
 NTSTATUS NTAPI IoCsqInitialize(PIO_CSQ Csq,
                                PIO_CSQ_INSERT_IRP CsqInsertIrp,
                                PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
@@ -241,6 +261,7 @@ NTSTATUS NTAPI IoCsqInitialize(PIO_CSQ Csq,
  * CsqInsertIrp.  This eventually allows you to supply extra tracking
  * information for use with the queue.
  */
+NTKERNELAPI
 NTSTATUS NTAPI IoCsqInitializeEx(PIO_CSQ Csq,
                                  PIO_CSQ_INSERT_IRP_EX CsqInsertIrpEx,
                                  PIO_CSQ_REMOVE_IRP CsqRemoveIrp,
@@ -252,6 +273,7 @@ NTSTATUS NTAPI IoCsqInitializeEx(PIO_CSQ Csq,
 /*
  * Insert an IRP into the queue
  */
+NTKERNELAPI
 VOID NTAPI IoCsqInsertIrp(PIO_CSQ Csq,
                           PIRP Irp,
                           PIO_CSQ_IRP_CONTEXT Context);
@@ -260,6 +282,7 @@ VOID NTAPI IoCsqInsertIrp(PIO_CSQ Csq,
  * Insert an IRP into the queue, with special context maintained that
  * makes it easy to find IRPs in the queue
  */
+NTKERNELAPI
 NTSTATUS NTAPI IoCsqInsertIrpEx(PIO_CSQ Csq,
                                 PIRP Irp,
                                 PIO_CSQ_IRP_CONTEXT Context,
@@ -268,12 +291,14 @@ NTSTATUS NTAPI IoCsqInsertIrpEx(PIO_CSQ Csq,
 /*
  * Remove a particular IRP from the queue
  */
+NTKERNELAPI
 PIRP NTAPI IoCsqRemoveIrp(PIO_CSQ Csq,
                           PIO_CSQ_IRP_CONTEXT Context);
 
 /*
- * Remove the next IRP from the queue 
+ * Remove the next IRP from the queue
  */
+NTKERNELAPI
 PIRP NTAPI IoCsqRemoveNextIrp(PIO_CSQ Csq,
                               PVOID PeekContext);