Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8255537

Browse files
committed
missed adding a new include file
1 parent 8e9d69d commit 8255537

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

src/include/utils/ps_status.h

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* ps_status.h--
4+
*
5+
* Defines macros to show backend status on the ps status line.
6+
* Unfortunately this is system dpendent.
7+
*
8+
*-------------------------------------------------------------------------
9+
*/
10+
11+
#ifndef PS_STATUS_H
12+
#define PS_STATUS_H
13+
14+
#ifdef linux
15+
16+
#include <stdio.h>
17+
#include <string.h>
18+
#include "utils/trace.h"
19+
20+
extern char *ps_status_buffer;
21+
22+
#define PS_DEFINE_BUFFER \
23+
char *ps_status_buffer = NULL;
24+
25+
#define PS_INIT_STATUS(argc, argv, execname, username, hostname, dbname) \
26+
{ \
27+
int i; \
28+
for (i = 0; i < (argc); i++) { \
29+
memset((argv)[i], 0, strlen((argv)[i])); \
30+
} \
31+
ps_status_buffer = (argv)[0]; \
32+
sprintf(ps_status_buffer, "%s %s %s %s ", execname, username, hostname, dbname); \
33+
ps_status_buffer += strlen(ps_status_buffer); \
34+
}
35+
36+
#define PS_CLEAR_STATUS() \
37+
{ if (ps_status_buffer) memset(ps_status_buffer, 0, strlen(ps_status_buffer)); }
38+
39+
#define PS_SET_STATUS(status) \
40+
{ \
41+
if (ps_status_buffer) \
42+
{ \
43+
PS_CLEAR_STATUS(); \
44+
strcat(ps_status_buffer, status); \
45+
} \
46+
}
47+
48+
#define PS_STATUS (ps_status_buffer ? ps_status_buffer : "")
49+
50+
#else /* !linux */
51+
52+
extern const char **ps_status;
53+
54+
#define PS_DEFINE_BUFFER \
55+
const char **ps_status = NULL;
56+
57+
#define PS_INIT_STATUS(argc, argv, execname, username, hostname, dbname) \
58+
{ \
59+
int i; \
60+
Assert(argc >= 5); \
61+
argv[0] = execname; \
62+
argv[1] = hostname; \
63+
argv[2] = username; \
64+
argv[3] = dbname; \
65+
ps_status = (const char **)&argv[4]; \
66+
for (i = 4; i < argc; i++) \
67+
argv[i] = ""; /* blank them */ \
68+
}
69+
70+
#define PS_CLEAR_STATUS() \
71+
{ if (ps_status) *ps_status = ""; }
72+
73+
#define PS_SET_STATUS(status) \
74+
{ if (ps_status) *ps_status = (status); }
75+
76+
#define PS_STATUS (ps_status ? *ps_status : "")
77+
#endif
78+
79+
#ifdef DONT_HAVE_PS_STATUS
80+
#define PS_DEFINE_BUFFER
81+
#define PS_INIT_STATUS(argc, argv, execname, username, hostname, dbname)
82+
#define PS_CLEAR_STATUS()
83+
#define PS_SET_STATUS(status) { if ((status)); }
84+
#define PS_STATUS ""
85+
#endif /* !linux */
86+
87+
#endif /* PS_STATUS_H */

0 commit comments

Comments
 (0)