PostgreSQL Source Code  git master
string.h
Go to the documentation of this file.
1 /*
2  * string.h
3  * string handling helpers
4  *
5  * Portions Copyright (c) 1996-2024, 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 
13 #include <signal.h>
14 
15 struct StringInfoData; /* avoid including stringinfo.h here */
16 
17 typedef struct PromptInterruptContext
18 {
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 */
24 
25 /* functions in src/common/string.c */
26 extern bool pg_str_endswith(const char *str, const char *end);
27 extern int strtoint(const char *pg_restrict str, char **pg_restrict endptr,
28  int base);
29 extern char *pg_clean_ascii(const char *str, int alloc_flags);
30 extern int pg_strip_crlf(char *str);
31 extern bool pg_is_ascii(const char *str);
32 
33 /* functions in src/common/pg_get_line.c */
34 extern char *pg_get_line(FILE *stream, PromptInterruptContext *prompt_ctx);
35 extern bool pg_get_line_buf(FILE *stream, struct StringInfoData *buf);
36 extern bool pg_get_line_append(FILE *stream, struct StringInfoData *buf,
37  PromptInterruptContext *prompt_ctx);
38 
39 /* functions in src/common/sprompt.c */
40 extern char *simple_prompt(const char *prompt, bool echo);
41 extern char *simple_prompt_extended(const char *prompt, bool echo,
42  PromptInterruptContext *prompt_ctx);
43 
44 #endif /* COMMON_STRING_H */
static char * buf
Definition: pg_test_fsync.c:73
char * simple_prompt_extended(const char *prompt, bool echo, PromptInterruptContext *prompt_ctx)
Definition: sprompt.c:53
bool pg_get_line_buf(FILE *stream, struct StringInfoData *buf)
char * pg_get_line(FILE *stream, PromptInterruptContext *prompt_ctx)
Definition: pg_get_line.c:59
int pg_strip_crlf(char *str)
Definition: string.c:155
bool pg_is_ascii(const char *str)
Definition: string.c:133
bool pg_get_line_append(FILE *stream, struct StringInfoData *buf, PromptInterruptContext *prompt_ctx)
int strtoint(const char *pg_restrict str, char **pg_restrict endptr, int base)
Definition: string.c:51
bool pg_str_endswith(const char *str, const char *end)
Definition: string.c:32
char * pg_clean_ascii(const char *str, int alloc_flags)
Definition: string.c:86
struct PromptInterruptContext PromptInterruptContext
char * simple_prompt(const char *prompt, bool echo)
Definition: sprompt.c:38
volatile sig_atomic_t * enabled
Definition: string.h:21