* Subroutine for parse_connection_string * * Deal with a string containing key=value pairs. */
| 5692 | * Deal with a string containing key=value pairs. |
| 5693 | */ |
| 5694 | static PQconninfoOption * |
| 5695 | conninfo_parse(const char *conninfo, PQExpBuffer errorMessage, |
| 5696 | bool use_defaults) |
| 5697 | { |
| 5698 | char *pname; |
| 5699 | char *pval; |
| 5700 | char *buf; |
| 5701 | char *cp; |
| 5702 | char *cp2; |
| 5703 | PQconninfoOption *options; |
| 5704 | |
| 5705 | /* Make a working copy of PQconninfoOptions */ |
| 5706 | options = conninfo_init(errorMessage); |
| 5707 | if (options == NULL) |
| 5708 | return NULL; |
| 5709 | |
| 5710 | /* Need a modifiable copy of the input string */ |
| 5711 | if ((buf = strdup(conninfo)) == NULL) |
| 5712 | { |
| 5713 | appendPQExpBufferStr(errorMessage, |
| 5714 | libpq_gettext("out of memory\n")); |
| 5715 | PQconninfoFree(options); |
| 5716 | return NULL; |
| 5717 | } |
| 5718 | cp = buf; |
| 5719 | |
| 5720 | while (*cp) |
| 5721 | { |
| 5722 | /* Skip blanks before the parameter name */ |
| 5723 | if (isspace((unsigned char) *cp)) |
| 5724 | { |
| 5725 | cp++; |
| 5726 | continue; |
| 5727 | } |
| 5728 | |
| 5729 | /* Get the parameter name */ |
| 5730 | pname = cp; |
| 5731 | while (*cp) |
| 5732 | { |
| 5733 | if (*cp == '=') |
| 5734 | break; |
| 5735 | if (isspace((unsigned char) *cp)) |
| 5736 | { |
| 5737 | *cp++ = '\0'; |
| 5738 | while (*cp) |
| 5739 | { |
| 5740 | if (!isspace((unsigned char) *cp)) |
| 5741 | break; |
| 5742 | cp++; |
| 5743 | } |
| 5744 | break; |
| 5745 | } |
| 5746 | cp++; |
| 5747 | } |
| 5748 | |
| 5749 | /* Check that there is a following '=' */ |
| 5750 | if (*cp != '=') |
| 5751 | { |
no test coverage detected