30 #if defined(_USE_WIN_API) 46 int iCnt = 1, iBracket = 0;
49 *chSplit = (
char*)malloc(strlen(chSrc) + 1);
50 if(*chSplit == NULL)
return -1;
52 strcpy(*chSplit, chSrc);
55 while(*chPos !=
'\0') {
100 char *chSplit, *chPos, *chTmp, *chNext;
105 if((chSrc == NULL) || (pvargDest == NULL)) {
116 chSplit = (
char*)malloc(strlen(chSrc) + 1);
118 strcpy(chSplit, chSrc);
128 for(i = 0, chPos = chSplit;
132 chNext = chPos + strlen(chPos) + 1;
134 chTmp = strchr(chPos,
'(');
138 if(strspn(chPos,
" ") != (chTmp - chPos)) {
145 chTmp = strrchr(chPos,
')');
149 if(*(chTmp + 1) !=
'\0') {
150 if(strspn(chTmp + 1,
" ") != strlen(chTmp + 1)) {
156 chTmp = strchr(chPos,
',');
160 if(strspn(chPos,
" 0123456789") != (chTmp - chPos)) {
176 for(i = 0, chPos = chSplit;
178 i++, chPos += strlen(chPos) + 1)
183 if(vt == (
VT_BSTR | VT_ARRAY)) {
241 char chTmp[10], *chPoint;
246 cnt = ubnd - lbnd + 1;
249 for(i = 0; i < cnt; i++) {
251 if(
FAILED(hr)) {
if(*chDest != NULL) { free(*chDest); }
break; }
253 len += sprintf(chTmp,
"%d,", pvarTmp[i].vt);
254 len += strlen(chPoint) + ((i == cnt - 1) ? 3 : 4);
255 *chDest = (
char*)realloc(*chDest, len);
256 if(*chDest == NULL) { hr =
E_OUTOFMEMORY; free(chPoint);
break; }
258 if(i == 0) *chDest[0] =
'\0';
260 strcat(*chDest,
"(");
261 strcat(*chDest, chTmp);
262 strcat(*chDest, chPoint);
263 strcat(*chDest, (i == cnt - 1) ?
")" :
"),");
278 cnt = ubnd - lbnd + 1;
282 for(i = 0; i < cnt; i++) {
286 len += strlen(chPoint) + ((i == cnt - 1) ? 1 : 2);
287 *chDest = (
char*)realloc(*chDest, len);
288 if(*chDest == NULL) { hr =
E_OUTOFMEMORY; free(chPoint);
break; }
290 if(i == 0) *chDest[0] =
'\0';
292 strcat(*chDest, chPoint);
293 strcat(*chDest, (i == cnt - 1) ?
"" :
",");
301 memset(pvarTmp, 0,
sizeof(
VARIANT) * cnt);
302 for(i = 0; i < cnt; i++) {
311 for(i = 0; i < cnt; i++) {
315 len += strlen(chPoint) + ((i == cnt - 1) ? 1 : 2);
316 *chDest = (
char*)realloc(*chDest, len);
317 if(*chDest == NULL) { hr =
E_OUTOFMEMORY; free(chPoint);
break; }
319 if(i == 0) *chDest[0] =
'\0';
321 strcat(*chDest, chPoint);
322 strcat(*chDest, (i == cnt - 1) ?
"" :
",");
328 for(i = 0; i < cnt; i++) {
HRESULT ConvertRacStr2Variant(uint16_t vt, const char *chSrc, VARIANT *pvargDest)
Converts RAC string to VARIANT.
_DN_EXP_COMMON HRESULT SafeArrayUnaccessData(SAFEARRAY *psa)
Unaccesses the SAFEARRAY.
_DN_EXP_COMMON HRESULT SafeArrayGetLBound(SAFEARRAY *psa, uint16_t nDim, int32_t *plLbound)
Gets the lower bound of SAFEARRAY.
static int SplitRacStr(const char *chSrc, char **chSplit)
Splits RAC string.
#define FAILED(hr)
A macro that returns TRUE/FALSE. If hr is less than zero, then returns TRUE.
RAC(Robot Action Command) String API file.
#define E_INVALIDARG
Failed because some arguments are invalid.
_DN_EXP_COMMON HRESULT SafeArrayGetUBound(SAFEARRAY *psa, uint16_t nDim, int32_t *plUbound)
Gets the upper bound of SAFEARRAY.
HRESULT ConvertVariant2RacStr(VARIANT varSrc, char **chDest)
Converts VARIANT to RAC string.
#define E_OUTOFMEMORY
Failed because there is no enough memory space.
#define SUCCEEDED(hr)
A macro that returns TRUE/FALSE. If hr is zero or more, then returns TRUE.
_DN_EXP_COMMON void VariantInit(VARIANT *pvarg)
Initializes the VARIANT.
_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.
A type definition for the multi type variable.
_DN_EXP_COMMON BSTR SysAllocString(const wchar_t *sz)
Allocates and returns BSTR.
_DN_EXP_COMMON void VariantClear(VARIANT *pvarg)
Clears the VARIANT.
_DN_EXP_COMMON char * ConvertWideChar2MultiByte(const wchar_t *chSrc)
Converts wide string to string.
_DN_EXP_COMMON SAFEARRAY * SafeArrayCreateVector(uint16_t vt, int32_t lLbound, uint32_t cElements)
Allocates and returns SAFEARRAY.
_DN_EXP_COMMON wchar_t * ConvertMultiByte2WideChar(const char *chSrc)
Converts string to wide string.
_DN_EXP_COMMON HRESULT SafeArrayAccessData(SAFEARRAY *psa, void **ppvData)
Accesses the SAFEARRAY and gets the pointer of array data.