Common API file. More...
#include <wchar.h>
#include <time.h>
Go to the source code of this file.
Classes | |
struct | SAFEARRAY |
A type definition for the array. More... | |
struct | SAFEARRAYBOUND |
A type definition for the bound of SAFEARRAY. More... | |
union | tagCY |
A type definition for the signed 64bit integer. More... | |
struct | VARIANT |
A type definition for the multi type variable. More... | |
Defines | |
#define | _HRESULT_TYPEDEF_(_sc) ((HRESULT)_sc) |
A macro that defines a new HRESULT. | |
#define | DISP_E_BADINDEX _HRESULT_TYPEDEF_(0x8002000BL) |
Failed because the index is invalid. | |
#define | DISP_E_BADVARTYPE _HRESULT_TYPEDEF_(0x80020008L) |
Failed because bad variable type. | |
#define | DISP_E_OVERFLOW _HRESULT_TYPEDEF_(0x8002000AL) |
Failed because out of range. | |
#define | DISP_E_TYPEMISMATCH _HRESULT_TYPEDEF_(0x80020005L) |
Failed because the type mismatch. | |
#define | E_ACCESSDENIED _HRESULT_TYPEDEF_(0x80070005L) |
Failed because the resource is not ready. | |
#define | E_ALREADY_REGISTER _HRESULT_TYPEDEF_(0x80000906L) |
Failed because the packet is too much. | |
#define | E_FAIL _HRESULT_TYPEDEF_(0x80004005L) |
Failed because unspecified error occurs. | |
#define | E_HANDLE _HRESULT_TYPEDEF_(0x80070006L) |
Failed because the handle is invalid. | |
#define | E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L) |
Failed because some arguments are invalid. | |
#define | E_MAX_CONNECT _HRESULT_TYPEDEF_(0x8000090BL) |
Failed because the number of connection is too much. | |
#define | E_MAX_OBJECT _HRESULT_TYPEDEF_(0x80000905L) |
Failed because the packet is too much. | |
#define | E_NOT_CONNECTED _HRESULT_TYPEDEF_(0x80000902L) |
Failed because the connection is not established. | |
#define | E_NOTIMPL _HRESULT_TYPEDEF_(0x80004001L) |
Failed because the function is not implemented. | |
#define | E_OUTOFMEMORY _HRESULT_TYPEDEF_(0x8007000EL) |
Failed because there is no enough memory space. | |
#define | E_TIMEOUT _HRESULT_TYPEDEF_(0x80000900L) |
Failed because the communication timed out. | |
#define | E_TOO_MUCH_DATA _HRESULT_TYPEDEF_(0x80000909L) |
Failed because the packet is too much. | |
#define | E_UNEXPECTED _HRESULT_TYPEDEF_(0x8000FFFFL) |
Failed because unexpected error happens. | |
#define | FAILED(hr) ((HRESULT)hr < 0) |
A macro that returns TRUE/FALSE. If hr is less than zero, then returns TRUE. | |
#define | FORMAT_DATE2BSTR "%Y/%m/%d %H:%M:%S" |
A definition for the format string converting DATE to BSTR. | |
#define | OSERR2HRESULT(err) (((err) & 0x0000FFFF) | 0x80910000) |
A macro that returns HREUSLT(0x8091) which means OS error. | |
#define | S_FALSE ((HRESULT)1L) |
Succeeded but some processes may remain. | |
#define | S_OK ((HRESULT)0L) |
Succeeded. | |
#define | SUCCEEDED(hr) ((HRESULT)hr >= 0) |
A macro that returns TRUE/FALSE. If hr is zero or more, then returns TRUE. | |
#define | VARIANT_FALSE ((VARIANT_BOOL) 0) |
FALSE for VARIANT. | |
#define | VARIANT_TRUE ((VARIANT_BOOL)-1) |
TRUE for VARIANT. | |
Typedefs | |
typedef wchar_t * | BSTR |
typedef union tagCY | CY |
typedef time_t | DATE |
typedef struct SAFEARRAY | SAFEARRAY |
typedef struct SAFEARRAYBOUND | SAFEARRAYBOUND |
typedef struct VARIANT | VARIANT |
typedef int16_t | VARIANT_BOOL |
Enumerations | |
enum | VARENUM { VT_EMPTY = 0, VT_NULL = 1, VT_I2 = 2, VT_I4 = 3, VT_R4 = 4, VT_R8 = 5, VT_CY = 6, VT_DATE = 7, VT_BSTR = 8, VT_ERROR = 10, VT_BOOL = 11, VT_VARIANT = 12, VT_UI1 = 17, VT_UI2 = 18, VT_UI4 = 19, VT_I8 = 20, VT_UI8 = 21, VT_ARRAY = 0x2000 } |
Variant type. More... | |
Functions | |
_DN_EXP_COMMON uint32_t | ChangeVarType (VARIANT varSrc, uint16_t vt, void *pDest, uint32_t dwSize) |
Changes the variant to destination value with the indicated type. | |
_DN_EXP_COMMON wchar_t * | ConvertMultiByte2WideChar (const char *chSrc) |
Converts string to wide string. | |
_DN_EXP_COMMON char * | ConvertWideChar2MultiByte (const wchar_t *chSrc) |
Converts wide string to string. | |
_DN_EXP_COMMON HRESULT | GetOptionValue (BSTR bstrSrc, BSTR bstrKey, uint16_t vt, VARIANT *pvarDest) |
Searchs the key string from source string and sets the value to the destination variant with the indicated type. | |
_DN_EXP_COMMON HRESULT | SafeArrayAccessData (SAFEARRAY *psa, void **ppvData) |
Accesses the SAFEARRAY and gets the pointer of array data. | |
_DN_EXP_COMMON SAFEARRAY * | SafeArrayCreateVector (uint16_t vt, int32_t lLbound, uint32_t cElements) |
Allocates and returns SAFEARRAY. | |
_DN_EXP_COMMON HRESULT | SafeArrayDestroy (SAFEARRAY *psa) |
Releases the memory of SAFEARRAY. | |
_DN_EXP_COMMON uint16_t | SafeArrayGetDim (SAFEARRAY *psa) |
Gets and returns the dimension of SAFEARRAY. | |
_DN_EXP_COMMON uint32_t | SafeArrayGetElemsize (SAFEARRAY *psa) |
Gets and returns the size of an element. | |
_DN_EXP_COMMON HRESULT | SafeArrayGetLBound (SAFEARRAY *psa, uint16_t nDim, int32_t *plLbound) |
Gets the lower bound of SAFEARRAY. | |
_DN_EXP_COMMON HRESULT | SafeArrayGetUBound (SAFEARRAY *psa, uint16_t nDim, int32_t *plUbound) |
Gets the upper bound of SAFEARRAY. | |
_DN_EXP_COMMON HRESULT | SafeArrayGetVartype (SAFEARRAY *psa, uint16_t *pvt) |
Gets the variant type of SAFEARRAY. | |
_DN_EXP_COMMON HRESULT | SafeArrayUnaccessData (SAFEARRAY *psa) |
Unaccesses the SAFEARRAY. | |
_DN_EXP_COMMON BSTR | SysAllocString (const wchar_t *sz) |
Allocates and returns BSTR. | |
_DN_EXP_COMMON BSTR | SysAllocStringLen (const wchar_t *pch, uint16_t cch) |
Allocates and returns BSTR. | |
_DN_EXP_COMMON void | SysFreeString (BSTR bstr) |
Releases the memory of BSTR. | |
_DN_EXP_COMMON uint16_t | SysStringLen (BSTR bstr) |
Gets and returns the number of characters of BSTR. | |
_DN_EXP_COMMON HRESULT | VariantChangeType (VARIANT *pvargDest, VARIANT *pvarSrc, uint16_t wFlags, uint16_t vt) |
Changes the source variant to destination variant with the indicated type. | |
_DN_EXP_COMMON void | VariantClear (VARIANT *pvarg) |
Clears the VARIANT. | |
_DN_EXP_COMMON HRESULT | VariantCopy (VARIANT *pvargDest, const VARIANT *pvargSrc) |
Copies the source variant to destination variant. | |
_DN_EXP_COMMON void | VariantInit (VARIANT *pvarg) |
Initializes the VARIANT. |
Common API file.
Defines some types, macros and functions to be compatible with Windows.
Software License Agreement (MIT License)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Definition in file dn_common.h.
#define _HRESULT_TYPEDEF_ | ( | _sc | ) | ((HRESULT)_sc) |
A macro that defines a new HRESULT.
Definition at line 83 of file dn_common.h.
#define DISP_E_BADINDEX _HRESULT_TYPEDEF_(0x8002000BL) |
Failed because the index is invalid.
Definition at line 161 of file dn_common.h.
#define DISP_E_BADVARTYPE _HRESULT_TYPEDEF_(0x80020008L) |
Failed because bad variable type.
Definition at line 149 of file dn_common.h.
#define DISP_E_OVERFLOW _HRESULT_TYPEDEF_(0x8002000AL) |
Failed because out of range.
Definition at line 155 of file dn_common.h.
#define DISP_E_TYPEMISMATCH _HRESULT_TYPEDEF_(0x80020005L) |
Failed because the type mismatch.
Definition at line 143 of file dn_common.h.
#define E_ACCESSDENIED _HRESULT_TYPEDEF_(0x80070005L) |
Failed because the resource is not ready.
Definition at line 113 of file dn_common.h.
#define E_ALREADY_REGISTER _HRESULT_TYPEDEF_(0x80000906L) |
Failed because the packet is too much.
Definition at line 187 of file dn_common.h.
#define E_FAIL _HRESULT_TYPEDEF_(0x80004005L) |
Failed because unspecified error occurs.
Definition at line 107 of file dn_common.h.
#define E_HANDLE _HRESULT_TYPEDEF_(0x80070006L) |
Failed because the handle is invalid.
Definition at line 119 of file dn_common.h.
#define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L) |
Failed because some arguments are invalid.
Definition at line 131 of file dn_common.h.
#define E_MAX_CONNECT _HRESULT_TYPEDEF_(0x8000090BL) |
Failed because the number of connection is too much.
Definition at line 199 of file dn_common.h.
#define E_MAX_OBJECT _HRESULT_TYPEDEF_(0x80000905L) |
Failed because the packet is too much.
Definition at line 181 of file dn_common.h.
#define E_NOT_CONNECTED _HRESULT_TYPEDEF_(0x80000902L) |
Failed because the connection is not established.
Definition at line 175 of file dn_common.h.
#define E_NOTIMPL _HRESULT_TYPEDEF_(0x80004001L) |
Failed because the function is not implemented.
Definition at line 101 of file dn_common.h.
#define E_OUTOFMEMORY _HRESULT_TYPEDEF_(0x8007000EL) |
Failed because there is no enough memory space.
Definition at line 125 of file dn_common.h.
#define E_TIMEOUT _HRESULT_TYPEDEF_(0x80000900L) |
Failed because the communication timed out.
Definition at line 169 of file dn_common.h.
#define E_TOO_MUCH_DATA _HRESULT_TYPEDEF_(0x80000909L) |
Failed because the packet is too much.
Definition at line 193 of file dn_common.h.
#define E_UNEXPECTED _HRESULT_TYPEDEF_(0x8000FFFFL) |
Failed because unexpected error happens.
Definition at line 137 of file dn_common.h.
#define FAILED | ( | hr | ) | ((HRESULT)hr < 0) |
A macro that returns TRUE/FALSE. If hr is less than zero, then returns TRUE.
Definition at line 77 of file dn_common.h.
#define FORMAT_DATE2BSTR "%Y/%m/%d %H:%M:%S" |
A definition for the format string converting DATE to BSTR.
Definition at line 56 of file dn_common.h.
#define OSERR2HRESULT | ( | err | ) | (((err) & 0x0000FFFF) | 0x80910000) |
A macro that returns HREUSLT(0x8091) which means OS error.
Definition at line 205 of file dn_common.h.
#define S_FALSE ((HRESULT)1L) |
Succeeded but some processes may remain.
Definition at line 95 of file dn_common.h.
#define S_OK ((HRESULT)0L) |
Succeeded.
Definition at line 89 of file dn_common.h.
#define SUCCEEDED | ( | hr | ) | ((HRESULT)hr >= 0) |
A macro that returns TRUE/FALSE. If hr is zero or more, then returns TRUE.
Definition at line 71 of file dn_common.h.
#define VARIANT_FALSE ((VARIANT_BOOL) 0) |
FALSE for VARIANT.
Definition at line 273 of file dn_common.h.
#define VARIANT_TRUE ((VARIANT_BOOL)-1) |
TRUE for VARIANT.
Definition at line 267 of file dn_common.h.
typedef wchar_t* BSTR |
Definition at line 239 of file dn_common.h.
typedef time_t DATE |
Definition at line 259 of file dn_common.h.
typedef struct SAFEARRAYBOUND SAFEARRAYBOUND |
typedef int16_t VARIANT_BOOL |
Definition at line 261 of file dn_common.h.
enum VARENUM |
Variant type.
Definition at line 213 of file dn_common.h.
uint32_t ChangeVarType | ( | VARIANT | varSrc, |
uint16_t | vt, | ||
void * | pDest, | ||
uint32_t | dwSize | ||
) |
Changes the variant to destination value with the indicated type.
[in] | varSrc | The source variant. |
[in] | vt | The variant type. |
[out] | pDest | The pointer of the destination value. |
[in] | dwSize | The maximum number of changed values. |
wchar_t * ConvertMultiByte2WideChar | ( | const char * | chSrc | ) |
Converts string to wide string.
[in] | chSrc | The source string. |
char * ConvertWideChar2MultiByte | ( | const wchar_t * | chSrc | ) |
Converts wide string to string.
[in] | chSrc | The source string. |
HRESULT GetOptionValue | ( | BSTR | bstrSrc, |
BSTR | bstrKey, | ||
uint16_t | vt, | ||
VARIANT * | pvarDest | ||
) |
Searchs the key string from source string and sets the value to the destination variant with the indicated type.
[in] | bstrSrc | The source string. |
[in] | bstrKey | The key string. |
[in] | vt | The variant type. |
[out] | pvarDest | The destination variant. |
HRESULT SafeArrayAccessData | ( | SAFEARRAY * | psa, |
void ** | ppvData | ||
) |
Accesses the SAFEARRAY and gets the pointer of array data.
[in] | psa | SAFEARRAY to be accessed. |
[out] | ppvData | The gotten pointer. |
Definition at line 336 of file dn_common.c.
SAFEARRAY * SafeArrayCreateVector | ( | uint16_t | vt, |
int32_t | lLbound, | ||
uint32_t | cElements | ||
) |
Allocates and returns SAFEARRAY.
[in] | vt | Variant type. |
[in] | lLbound | The lower bound of array. This should be 0. |
[in] | cElements | The number of elements. |
Definition at line 138 of file dn_common.c.
HRESULT SafeArrayDestroy | ( | SAFEARRAY * | psa | ) |
Releases the memory of SAFEARRAY.
[in,out] | psa | SAFEARRAY to be freed. |
Definition at line 212 of file dn_common.c.
uint16_t SafeArrayGetDim | ( | SAFEARRAY * | psa | ) |
Gets and returns the dimension of SAFEARRAY.
[in] | psa | SAFEARRAY to be gotten. |
Definition at line 248 of file dn_common.c.
uint32_t SafeArrayGetElemsize | ( | SAFEARRAY * | psa | ) |
Gets and returns the size of an element.
[in] | psa | SAFEARRAY to be gotten. |
Definition at line 262 of file dn_common.c.
HRESULT SafeArrayGetLBound | ( | SAFEARRAY * | psa, |
uint16_t | nDim, | ||
int32_t * | plLbound | ||
) |
Gets the lower bound of SAFEARRAY.
[in] | psa | SAFEARRAY to be gotten. |
[in] | nDim | The target dimension. |
[out] | plLbound | The gotten lower bound. |
Definition at line 278 of file dn_common.c.
HRESULT SafeArrayGetUBound | ( | SAFEARRAY * | psa, |
uint16_t | nDim, | ||
int32_t * | plUbound | ||
) |
Gets the upper bound of SAFEARRAY.
[in] | psa | SAFEARRAY to be gotten. |
[in] | nDim | The target dimension. |
[out] | plUbound | The gotten upper bound. |
Definition at line 298 of file dn_common.c.
HRESULT SafeArrayGetVartype | ( | SAFEARRAY * | psa, |
uint16_t * | pvt | ||
) |
Gets the variant type of SAFEARRAY.
[in] | psa | SAFEARRAY to be gotten. |
[out] | pvt | The gotten variant type. |
Definition at line 318 of file dn_common.c.
HRESULT SafeArrayUnaccessData | ( | SAFEARRAY * | psa | ) |
Unaccesses the SAFEARRAY.
[in] | psa | SAFEARRAY to be unaccessed. |
Definition at line 353 of file dn_common.c.
BSTR SysAllocString | ( | const wchar_t * | sz | ) |
Allocates and returns BSTR.
[in] | sz | Unicode string to be copied. This must be NULL terminated. |
Definition at line 61 of file dn_common.c.
BSTR SysAllocStringLen | ( | const wchar_t * | pch, |
uint16_t | cch | ||
) |
Allocates and returns BSTR.
[in] | pch | Unicode string to be copied. This must be NULL terminated. |
[in] | cch | The number of characters to be copied. |
Definition at line 77 of file dn_common.c.
void SysFreeString | ( | BSTR | bstr | ) |
Releases the memory of BSTR.
[in,out] | bstr | Unicode string to be freed. |
Definition at line 104 of file dn_common.c.
uint16 SysStringLen | ( | BSTR | bstr | ) |
Gets and returns the number of characters of BSTR.
[in] | bstr | Unicode string to be gotten. This must be NULL terminated. |
Definition at line 118 of file dn_common.c.
HRESULT VariantChangeType | ( | VARIANT * | pvargDest, |
VARIANT * | pvarSrc, | ||
uint16_t | wFlags, | ||
uint16_t | vt | ||
) |
Changes the source variant to destination variant with the indicated type.
[out] | pvargDest | The destination variant to be changed. |
[in] | pvarSrc | The source variant. |
[in] | wFlags | Flags. |
[in] | vt | The variant type. |
void VariantClear | ( | VARIANT * | pvarg | ) |
Clears the VARIANT.
[in,out] | pvarg | VARIANT to be cleared. |
Definition at line 382 of file dn_common.c.
HRESULT VariantCopy | ( | VARIANT * | pvargDest, |
const VARIANT * | pvargSrc | ||
) |
Copies the source variant to destination variant.
[out] | pvargDest | The destination variant to be changed. |
[in] | pvarSrc | The source variant. |
void VariantInit | ( | VARIANT * | pvarg | ) |
Initializes the VARIANT.
[in,out] | pvarg | VARIANT to be initialized. |
Definition at line 368 of file dn_common.c.