return decode(in);
}
-char *extract_attribute_setting(const char *str, const char *attr, BOOL ref_comment)
-{
- const char *cptr, *sptr = NULL;
- char *rptr;
- BOOL allowed_cmd = TRUE, in_quote = FALSE, in_comment = FALSE;
- int step = 0, skiplen;
- size_t len = 0, attrlen = strlen(attr);
-
- if (!str) return; /* for safety */
- for (cptr = str; *cptr; cptr++)
- {
- if (in_quote)
- {
- if (LITERAL_QUOTE == *cptr)
- {
- if (4 == step)
- {
- len = cptr - sptr;
- step++;
- }
- in_quote = FALSE;
- }
- continue;
- }
- else if (in_comment)
- {
- if ('*' == *cptr &&
- '/' == cptr[1])
- {
- if (4 == step)
- {
- len = cptr - sptr;
- step++;
- }
- in_comment = FALSE;
- cptr++;
- continue;
- }
- if (!ref_comment)
- continue;
- }
- else if ('/' == *cptr &&
- '*' == cptr[1])
- {
- in_comment = TRUE;
- cptr++;
- continue;
- }
- if (';' == *cptr)
- {
- if (4 == step)
- {
- len = cptr - sptr;
- }
- allowed_cmd = TRUE;
- step = 0;
- continue;
- }
- if (!allowed_cmd)
- continue;
- if (isspace((unsigned char) *cptr))
- {
- if (4 == step)
- {
- len = cptr - sptr;
- step++;
- }
- continue;
- }
- switch (step)
- {
- case 0:
- if (0 != strnicmp(cptr, "set", 3))
- {
- allowed_cmd = FALSE;
- continue;
- }
- step++;
- cptr += 3;
- break;
- case 1:
- if (0 != strnicmp(cptr, attr, attrlen))
- {
- allowed_cmd = FALSE;
- continue;
- }
- step++;
- cptr += (attrlen - 1);
- break;
- case 2:
- skiplen = 0;
- if (0 != strnicmp(cptr, "=", 1))
- {
- skiplen = (int) strlen("to");
- if (0 != strnicmp(cptr, "to", 2))
- {
- allowed_cmd = FALSE;
- continue;
- }
- }
- step++;
- cptr += skiplen;
- break;
- case 3:
- if (LITERAL_QUOTE == *cptr)
- {
- cptr++;
- sptr = cptr;
- }
- else
- sptr = cptr;
- step++;
- break;
- }
- }
- if (!sptr)
- return NULL;
- rptr = malloc(len + 1);
- memcpy(rptr, sptr, len);
- rptr[len] = '\0';
- mylog("extracted a %s '%s' from %s\n", attr, rptr, str);
- return rptr;
-}
-
/*
* extract the specified attribute from the comment part.
* attribute=[']value[']
int changeDriverNameOfaDSN(const char *dsn, const char *driver_name, DWORD *errcode);
UInt4 getExtraOptions(const ConnInfo *);
BOOL setExtraOptions(ConnInfo *, const char *str, const char *format);
-char *extract_attribute_setting(const char *str, const char *attr, BOOL ref_comment);
char *extract_extra_attribute_setting(const pgNAME setting, const char *attr);
#ifdef __cplusplus