2
0

string.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * string.h
  3. * string handling helpers
  4. *
  5. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  6. * Portions Copyright (c) 1994, Regents of the University of California
  7. *
  8. * src/include/common/string.h
  9. */
  10. #ifndef COMMON_STRING_H
  11. #define COMMON_STRING_H
  12. struct StringInfoData; /* avoid including stringinfo.h here */
  13. typedef struct PromptInterruptContext
  14. {
  15. /* To avoid including <setjmp.h> here, jmpbuf is declared "void *" */
  16. void *jmpbuf; /* existing longjmp buffer */
  17. volatile bool *enabled; /* flag that enables longjmp-on-interrupt */
  18. bool canceled; /* indicates whether cancellation occurred */
  19. } PromptInterruptContext;
  20. /* functions in src/common/string.c */
  21. extern bool pg_str_endswith(const char *str, const char *end);
  22. extern int strtoint(const char *pg_restrict str, char **pg_restrict endptr,
  23. int base);
  24. extern void pg_clean_ascii(char *str);
  25. extern int pg_strip_crlf(char *str);
  26. extern bool pg_is_ascii(const char *str);
  27. /* functions in src/common/pg_get_line.c */
  28. extern char *pg_get_line(FILE *stream, PromptInterruptContext *prompt_ctx);
  29. extern bool pg_get_line_buf(FILE *stream, struct StringInfoData *buf);
  30. extern bool pg_get_line_append(FILE *stream, struct StringInfoData *buf,
  31. PromptInterruptContext *prompt_ctx);
  32. /* functions in src/common/sprompt.c */
  33. extern char *simple_prompt(const char *prompt, bool echo);
  34. extern char *simple_prompt_extended(const char *prompt, bool echo,
  35. PromptInterruptContext *prompt_ctx);
  36. #endif /* COMMON_STRING_H */