Source code of Windows XP (NT5)
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.

285 lines
5.0 KiB

  1. #include <windows.h>
  2. #include <commctrl.h>
  3. #include <tapi.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <tchar.h>
  7. #include <faxdev.h>
  8. //#include <faxutil.h>
  9. #include "resource.h"
  10. #include <ncfiles.h>
  11. #include <ncutils.h>
  12. #include <user.hpp>
  13. #include <conn.hpp>
  14. #include <ncstatus.h>
  15. #include <ncmsg.h>
  16. #include <fax.hpp>
  17. #include <acct.hpp>
  18. #define StringSize(_s) (( _s ) ? (_tcslen( _s ) + 1) * sizeof(TCHAR) : 0)
  19. #define REGKEY_PROVIDER L"Software\\Microsoft\\Fax\\Device Providers\\NetCentric"
  20. #define REGVAL_SERVER L"Server"
  21. #define REGVAL_USERNAME L"UserName"
  22. #define REGVAL_PASSWORD L"Password"
  23. #define JobInfo(_fh) ((PJOB_INFO)(_fh))
  24. #define NCFAX_ID "Micsosoft Personal Fax for Windows"
  25. #define NCFAX_CLIENTID 0
  26. #define NCFAX_MAJOR 0
  27. #define NCFAX_MINOR 9
  28. #define NCFAX_RELEASE 1
  29. #define NCFAX_PATCH 13
  30. #define PRODUCTION_KEY "Microsoft"
  31. #define TAPI_VERSION 0x00020000
  32. #define LT_SERVER_NAME 64
  33. #define LT_FIRST_NAME 64
  34. #define LT_LAST_NAME 64
  35. #define LT_EMAIL 64
  36. #define LT_AREA_CODE 64
  37. #define LT_PHONE_NUMBER 64
  38. #define LT_ADDRESS 64
  39. #define LT_CITY 64
  40. #define LT_STATE 2
  41. #define LT_ZIP 11
  42. #define LT_ACCOUNT_NAME 64
  43. #define LT_PASSWORD 64
  44. #define LT_CREDIT_CARD 64
  45. #define LT_EXPIRY_MM 64
  46. #define LT_EXPIRY_YY 64
  47. #define LT_CC_NAME 64
  48. #define LVIS_GCNOCHECK 0x1000
  49. #define LVIS_GCCHECK 0x2000
  50. #define IS_DONE_STATUS(code) \
  51. (((code) != ST_STATUS_QUEUED) && \
  52. ((code) != ST_STATUS_PENDING) && \
  53. ((code) != ST_STATUS_ACTIVE))
  54. typedef struct _JOB_INFO {
  55. CNcFaxJob *faxJob;
  56. CNcConnectionInfo *connInfo;
  57. CNcUser *sender;
  58. CNcUser *recipient;
  59. HLINE LineHandle;
  60. DWORD DeviceId;
  61. HANDLE CompletionPortHandle;
  62. DWORD CompletionKey;
  63. LONG ServerId;
  64. LONG JobId;
  65. } JOB_INFO, *PJOB_INFO;
  66. typedef struct _CONFIG_DATA {
  67. LPWSTR ServerName;
  68. LPWSTR UserName;
  69. LPWSTR Password;
  70. } CONFIG_DATA, *PCONFIG_DATA;
  71. extern HANDLE MyHeapHandle;
  72. extern HINSTANCE MyhInstance;
  73. extern CONFIG_DATA ConfigData;
  74. BOOL
  75. GetNcConfig(
  76. PCONFIG_DATA ConfigData
  77. );
  78. BOOL
  79. SetNcConfig(
  80. PCONFIG_DATA ConfigData
  81. );
  82. VOID
  83. InitializeStringTable(
  84. VOID
  85. );
  86. LPWSTR
  87. GetString(
  88. DWORD ResourceId
  89. );
  90. int
  91. PopUpMsg(
  92. HWND hwnd,
  93. DWORD ResourceId,
  94. BOOL Error,
  95. DWORD Type
  96. );
  97. BOOL
  98. ParsePhoneNumber(
  99. LPWSTR PhoneNumber,
  100. LPSTR *CountryCode,
  101. LPSTR *AreaCode,
  102. LPSTR *SubscriberNumber
  103. );
  104. int
  105. PopUpMsgString(
  106. HWND hwnd,
  107. LPSTR String,
  108. BOOL Error,
  109. DWORD Type
  110. );
  111. LPWSTR
  112. AnsiStringToUnicodeString(
  113. LPSTR AnsiString
  114. );
  115. LPSTR
  116. UnicodeStringToAnsiString(
  117. LPWSTR UnicodeString
  118. );
  119. LPWSTR
  120. StringDup(
  121. LPWSTR String
  122. );
  123. //
  124. // debugging information
  125. //
  126. #if DBG
  127. #define Assert(exp) if(!(exp)) {AssertError(TEXT(#exp),TEXT(__FILE__),__LINE__);}
  128. #define DebugPrint(_x_) dprintf _x_
  129. #else
  130. #define Assert(exp)
  131. #define DebugPrint(_x_)
  132. #endif
  133. extern BOOL ConsoleDebugOutput;
  134. void
  135. dprintf(
  136. LPTSTR Format,
  137. ...
  138. );
  139. VOID
  140. AssertError(
  141. LPTSTR Expression,
  142. LPTSTR File,
  143. ULONG LineNumber
  144. );
  145. //
  146. // memory allocation
  147. //
  148. #define HEAP_SIZE (1024*1024)
  149. #ifdef FAX_HEAP_DEBUG
  150. #define HEAP_SIG 0x69696969
  151. typedef struct _HEAP_BLOCK {
  152. LIST_ENTRY ListEntry;
  153. ULONG Signature;
  154. ULONG Size;
  155. ULONG Line;
  156. #ifdef UNICODE
  157. WCHAR File[22];
  158. #else
  159. CHAR File[20];
  160. #endif
  161. } HEAP_BLOCK, *PHEAP_BLOCK;
  162. #define MemAlloc(s) pMemAlloc(s,__LINE__,__FILE__)
  163. #define MemFree(p) pMemFree(p,__LINE__,__FILE__)
  164. #define MemFreeForHeap(h,p) pMemFreeForHeap(h,p,__LINE__,__FILE__)
  165. #define CheckHeap(p) pCheckHeap(p,__LINE__,__FILE__)
  166. #else
  167. #define MemAlloc(s) pMemAlloc(s)
  168. #define MemFree(p) pMemFree(p)
  169. #define MemFreeForHeap(h,p) pMemFreeForHeap(h,p)
  170. #define CheckHeap(p)
  171. #endif
  172. typedef LPVOID (WINAPI *PMEMALLOC) (DWORD);
  173. typedef VOID (WINAPI *PMEMFREE) (LPVOID);
  174. #define HEAPINIT_NO_VALIDATION 0x00000001
  175. #define HEAPINIT_NO_STRINGS 0x00000002
  176. HANDLE
  177. HeapInitialize(
  178. HANDLE hHeap,
  179. PMEMALLOC pMemAlloc,
  180. PMEMFREE pMemFree,
  181. DWORD Flags
  182. );
  183. BOOL
  184. HeapExistingInitialize(
  185. HANDLE hExistHeap
  186. );
  187. BOOL
  188. HeapCleanup(
  189. VOID
  190. );
  191. #ifdef FAX_HEAP_DEBUG
  192. VOID
  193. pCheckHeap(
  194. PVOID MemPtr,
  195. ULONG Line,
  196. LPSTR File
  197. );
  198. VOID
  199. PrintAllocations(
  200. VOID
  201. );
  202. #else
  203. #define PrintAllocations()
  204. #endif
  205. PVOID
  206. pMemAlloc(
  207. ULONG AllocSize
  208. #ifdef FAX_HEAP_DEBUG
  209. ,ULONG Line
  210. ,LPSTR File
  211. #endif
  212. );
  213. VOID
  214. pMemFree(
  215. PVOID MemPtr
  216. #ifdef FAX_HEAP_DEBUG
  217. ,ULONG Line
  218. ,LPSTR File
  219. #endif
  220. );
  221. VOID
  222. pMemFreeForHeap(
  223. HANDLE hHeap,
  224. PVOID MemPtr
  225. #ifdef FAX_HEAP_DEBUG
  226. ,ULONG Line
  227. ,LPSTR File
  228. #endif
  229. );