codekingpro/portable-devtools
115k
1/*2 * string.h3 * string handling helpers4 *5 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group6 * Portions Copyright (c) 1994, Regents of the University of California7 *8 * src/include/common/string.h9 */10#ifndef COMMON_STRING_H11#define COMMON_STRING_H12 13#include <signal.h>14 15struct StringInfoData; /* avoid including stringinfo.h here */16 17typedef struct PromptInterruptContext18{19 /* To avoid including <setjmp.h> here, jmpbuf is declared "void *" */20 void *jmpbuf; /* existing longjmp buffer */21 volatile sig_atomic_t *enabled; /* flag that enables longjmp-on-interrupt */22 bool canceled; /* indicates whether cancellation occurred */23} PromptInterruptContext;24 25/* functions in src/common/string.c */26extern bool pg_str_endswith(const char *str, const char *end);27extern int strtoint(const char *pg_restrict str, char **pg_restrict endptr,28 int base);29extern char *pg_clean_ascii(const char *str, int alloc_flags);30extern int pg_strip_crlf(char *str);31extern bool pg_is_ascii(const char *str);32 33/* functions in src/common/pg_get_line.c */34extern char *pg_get_line(FILE *stream, PromptInterruptContext *prompt_ctx);35extern bool pg_get_line_buf(FILE *stream, struct StringInfoData *buf);36extern bool pg_get_line_append(FILE *stream, struct StringInfoData *buf,37 PromptInterruptContext *prompt_ctx);38 39/* functions in src/common/sprompt.c */40extern char *simple_prompt(const char *prompt, bool echo);41extern char *simple_prompt_extended(const char *prompt, bool echo,42 PromptInterruptContext *prompt_ctx);43 44#endif /* COMMON_STRING_H */45 