Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
5.0 KiB

  1. /*
  2. * INTERNAL.H
  3. *
  4. * Point-of-Sale Control Panel Applet
  5. *
  6. * Author: Ervin Peretz
  7. *
  8. * (c) 2001 Microsoft Corporation
  9. */
  10. #define USE_OVERLAPPED_IO FALSE
  11. typedef struct posDevice {
  12. #define POSCPL_SIG 'CsoP'
  13. DWORD sig;
  14. LIST_ENTRY listEntry;
  15. /*
  16. * Device type, identified by dialog
  17. * id for the device type
  18. * (e.g. IDD_POS_CASHDRAWER_DLG).
  19. */
  20. DWORD dialogId;
  21. PHIDP_PREPARSED_DATA hidPreparsedData;
  22. HIDD_ATTRIBUTES hidAttrib;
  23. HIDP_CAPS hidCapabilities;
  24. HWND hDlg;
  25. HANDLE hThread;
  26. PUCHAR readBuffer;
  27. PUCHAR writeBuffer;
  28. HANDLE devHandle;
  29. WCHAR pathName[MAX_PATH];
  30. #if USE_OVERLAPPED_IO
  31. OVERLAPPED overlappedReadInfo;
  32. NTSTATUS overlappedReadStatus;
  33. DWORD overlappedReadLen;
  34. HANDLE overlappedReadEvent;
  35. OVERLAPPED overlappedWriteInfo;
  36. NTSTATUS overlappedWriteStatus;
  37. DWORD overlappedWriteLen;
  38. HANDLE overlappedWriteEvent;
  39. #endif
  40. } posDevice;
  41. /*
  42. * These are non-standard vendor usage values and codes
  43. * used by APG Cash Drawer.
  44. */
  45. #define USAGE_PAGE_CASH_DEVICE 0x0F0
  46. #define USAGE_CASH_DRAWER 0x0F1
  47. #define USAGE_CASH_DRAWER_NUMBER 0x0F2
  48. #define USAGE_CASH_DRAWER_SET 0x0F3
  49. #define USAGE_CASH_DRAWER_STATUS 0x0F4
  50. enum cashDrawerStates {
  51. DRAWER_STATE_OPEN = 1,
  52. DRAWER_STATE_CLOSED_READY = 2,
  53. DRAWER_STATE_CLOSED_CHARGING = 3,
  54. DRAWER_STATE_LOCKED = 4,
  55. };
  56. /*
  57. * List macros -- not defined in winnt.h for some reason.
  58. */
  59. #define InitializeListHead(ListHead) (\
  60. (ListHead)->Flink = (ListHead)->Blink = (ListHead))
  61. #define IsListEmpty(ListHead) \
  62. ((ListHead)->Flink == (ListHead))
  63. #define RemoveHeadList(ListHead) \
  64. (ListHead)->Flink;\
  65. {RemoveEntryList((ListHead)->Flink)}
  66. #define RemoveTailList(ListHead) \
  67. (ListHead)->Blink;\
  68. {RemoveEntryList((ListHead)->Blink)}
  69. #define RemoveEntryList(Entry) {\
  70. PLIST_ENTRY _EX_Blink;\
  71. PLIST_ENTRY _EX_Flink;\
  72. _EX_Flink = (Entry)->Flink;\
  73. _EX_Blink = (Entry)->Blink;\
  74. _EX_Blink->Flink = _EX_Flink;\
  75. _EX_Flink->Blink = _EX_Blink;\
  76. }
  77. #define InsertTailList(ListHead,Entry) {\
  78. PLIST_ENTRY _EX_Blink;\
  79. PLIST_ENTRY _EX_ListHead;\
  80. _EX_ListHead = (ListHead);\
  81. _EX_Blink = _EX_ListHead->Blink;\
  82. (Entry)->Flink = _EX_ListHead;\
  83. (Entry)->Blink = _EX_Blink;\
  84. _EX_Blink->Flink = (Entry);\
  85. _EX_ListHead->Blink = (Entry);\
  86. }
  87. #define InsertHeadList(ListHead,Entry) {\
  88. PLIST_ENTRY _EX_Flink;\
  89. PLIST_ENTRY _EX_ListHead;\
  90. _EX_ListHead = (ListHead);\
  91. _EX_Flink = _EX_ListHead->Flink;\
  92. (Entry)->Flink = _EX_Flink;\
  93. (Entry)->Blink = _EX_ListHead;\
  94. _EX_Flink->Blink = (Entry);\
  95. _EX_ListHead->Flink = (Entry);\
  96. }
  97. /*
  98. * Function prototypes
  99. */
  100. VOID LaunchPOSDialog(HWND hwndCPl);
  101. INT_PTR APIENTRY POSDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  102. INT_PTR APIENTRY NullPOSDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  103. posDevice *NewPOSDevice(DWORD dialogId, HANDLE devHandle, PWCHAR devPath, PHIDP_PREPARSED_DATA pHidPreparsedData, PHIDD_ATTRIBUTES pHidAttrib, HIDP_CAPS *pHidCapabilities);
  104. VOID DestroyPOSDevice(posDevice *posDev);
  105. VOID EnqueuePOSDevice(posDevice *posDev);
  106. VOID DequeuePOSDevice(posDevice *posDev);
  107. VOID OpenAllHIDPOSDevices();
  108. VOID IntToWChar(WCHAR *buf, DWORD x);
  109. VOID HexToWChar(WCHAR *buf, DWORD x);
  110. ULONG WStrNCpy(WCHAR *dest, const WCHAR *src, ULONG maxWChars);
  111. ULONG AsciiToWChar(WCHAR *dest, const char *src, ULONG maxChars);
  112. posDevice *GetDeviceByHDlg(HWND hDlg);
  113. VOID LaunchDeviceInstanceThread(posDevice *posDev);
  114. DWORD __stdcall DeviceInstanceThread(void *context);
  115. BOOL SetCashDrawerState(posDevice *posDev, enum cashDrawerStates newState);
  116. #if USE_OVERLAPPED_IO
  117. VOID CALLBACK OverlappedReadCompletionRoutine(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped);
  118. VOID CALLBACK OverlappedWriteCompletionRoutine(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped);
  119. #endif
  120. /*
  121. * Externs
  122. */
  123. extern HANDLE g_hInst;
  124. extern ULONG numDeviceInstances;
  125. extern LIST_ENTRY allPOSDevicesList;