* PQconninfoParse * * Parse a string like PQconnectdb() would do and return the * resulting connection options array. NULL is returned on failure. * The result contains only options specified directly in the string, * not any possible default values. * * If errmsg isn't NULL, *errmsg is set to NULL on success, or a malloc'd * string on failure (use PQfreemem to free it). In out-of-memor
| 5576 | * be freed when no longer needed via PQconninfoFree(). |
| 5577 | */ |
| 5578 | PQconninfoOption * |
| 5579 | PQconninfoParse(const char *conninfo, char **errmsg) |
| 5580 | { |
| 5581 | PQExpBufferData errorBuf; |
| 5582 | PQconninfoOption *connOptions; |
| 5583 | |
| 5584 | if (errmsg) |
| 5585 | *errmsg = NULL; /* default */ |
| 5586 | initPQExpBuffer(&errorBuf); |
| 5587 | if (PQExpBufferDataBroken(errorBuf)) |
| 5588 | return NULL; /* out of memory already :-( */ |
| 5589 | connOptions = parse_connection_string(conninfo, &errorBuf, false); |
| 5590 | if (connOptions == NULL && errmsg) |
| 5591 | *errmsg = errorBuf.data; |
| 5592 | else |
| 5593 | termPQExpBuffer(&errorBuf); |
| 5594 | return connOptions; |
| 5595 | } |
| 5596 | |
| 5597 | /* |
| 5598 | * Build a working copy of the constant PQconninfoOptions array. |