2 * PROJECT: ReactOS Standard Print Processor
3 * LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software Foundation
4 * PURPOSE: Main functions
5 * COPYRIGHT: Copyright 2015 Colin Finck <colin@reactos.org>
10 PCWSTR pwszDatatypes
[] = {
16 * @name EnumPrintProcessorDatatypesW
18 * Obtains an array of all datatypes supported by this Print Processor.
21 * Server Name. Ignored here, because every caller of EnumPrintProcessorDatatypesW is interested in this Print Processor's information.
23 * @param pPrintProcessorName
24 * Print Processor Name. Ignored here, because every caller of EnumPrintProcessorDatatypesW is interested in this Print Processor's information.
27 * The level of the structure supplied through pDatatypes. This must be 1.
30 * Pointer to the buffer that receives an array of DATATYPES_INFO_1W structures.
31 * Can be NULL if you just want to know the required size of the buffer.
34 * Size of the buffer you supplied for pDatatypes, in bytes.
37 * Pointer to a variable that receives the required size of the buffer for pDatatypes, in bytes.
38 * This parameter mustn't be NULL!
41 * Pointer to a variable that receives the number of elements of the DATATYPES_INFO_1W array.
42 * This parameter mustn't be NULL!
45 * TRUE if we successfully copied the array into pDatatypes, FALSE otherwise.
46 * A more specific error code can be obtained through GetLastError.
49 EnumPrintProcessorDatatypesW(LPWSTR pName
, LPWSTR pPrintProcessorName
, DWORD Level
, LPBYTE pDatatypes
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
)
52 DWORD dwOffsets
[_countof(pwszDatatypes
)];
53 PCWSTR
* pCurrentDatatype
;
54 PDWORD pCurrentOffset
= dwOffsets
;
57 if (Level
!= 1 || !pcbNeeded
|| !pcReturned
)
60 // Count the required buffer size and the number of datatypes.
64 for (pCurrentDatatype
= pwszDatatypes
; *pCurrentDatatype
; pCurrentDatatype
++)
66 cbDatatype
= (wcslen(*pCurrentDatatype
) + 1) * sizeof(WCHAR
);
67 *pcbNeeded
+= sizeof(DATATYPES_INFO_1W
) + cbDatatype
;
69 // Also calculate the offset in the output buffer of the pointer to this datatype string.
70 *pCurrentOffset
= *pcReturned
* sizeof(DATATYPES_INFO_1W
) + FIELD_OFFSET(DATATYPES_INFO_1W
, pName
);
76 // Check if the supplied buffer is large enough.
77 if (cbBuf
< *pcbNeeded
)
79 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
83 // Check if a buffer was supplied at all.
86 SetLastError(ERROR_INVALID_PARAMETER
);
90 // Copy over all datatypes.
91 *pCurrentOffset
= MAXDWORD
;
92 PackStrings(pwszDatatypes
, pDatatypes
, dwOffsets
, &pDatatypes
[*pcbNeeded
]);