string_utils.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*-------------------------------------------------------------------------
  2. *
  3. * String-processing utility routines for frontend code
  4. *
  5. * Utility functions that interpret backend output or quote strings for
  6. * assorted contexts.
  7. *
  8. *
  9. * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
  10. * Portions Copyright (c) 1994, Regents of the University of California
  11. *
  12. * src/include/fe_utils/string_utils.h
  13. *
  14. *-------------------------------------------------------------------------
  15. */
  16. #ifndef STRING_UTILS_H
  17. #define STRING_UTILS_H
  18. #include "libpq-fe.h"
  19. #include "pqexpbuffer.h"
  20. #define atooid(x) ((Oid) strtoul((x), NULL, 10))
  21. /* Global variables controlling behavior of fmtId() and fmtQualifiedId() */
  22. extern int quote_all_identifiers;
  23. extern PQExpBuffer (*getLocalPQExpBuffer) (void);
  24. /* Functions */
  25. extern const char *fmtId(const char *identifier);
  26. extern const char *fmtQualifiedId(int remoteVersion,
  27. const char *schema, const char *id);
  28. extern char *formatPGVersionNumber(int version_number, bool include_minor,
  29. char *buf, size_t buflen);
  30. extern void appendStringLiteral(PQExpBuffer buf, const char *str,
  31. int encoding, bool std_strings);
  32. extern void appendStringLiteralConn(PQExpBuffer buf, const char *str,
  33. PGconn *conn);
  34. extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
  35. const char *dqprefix);
  36. extern void appendByteaLiteral(PQExpBuffer buf,
  37. const unsigned char *str, size_t length,
  38. bool std_strings);
  39. extern void appendShellString(PQExpBuffer buf, const char *str);
  40. extern void appendConnStrVal(PQExpBuffer buf, const char *str);
  41. extern void appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname);
  42. extern bool parsePGArray(const char *atext, char ***itemarray, int *nitems);
  43. extern bool appendReloptionsArray(PQExpBuffer buffer, const char *reloptions,
  44. const char *prefix, int encoding, bool std_strings);
  45. extern bool processSQLNamePattern(PGconn *conn, PQExpBuffer buf,
  46. const char *pattern,
  47. bool have_where, bool force_escape,
  48. const char *schemavar, const char *namevar,
  49. const char *altnamevar, const char *visibilityrule);
  50. #endif /* STRING_UTILS_H */