1 | /* |
2 | * This Source Code Form is subject to the terms of the Mozilla Public |
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
5 | * |
6 | * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
7 | */ |
8 | |
9 | #ifndef _MEROVINGIAN_H |
10 | #define _MEROVINGIAN_H 1 |
11 | |
12 | #include <netinet/in.h> /* struct sockaddr_in */ |
13 | #include <pthread.h> /* pthread_mutex_t */ |
14 | #include <signal.h> /* sig_atomic_t */ |
15 | |
16 | #include "utils/utils.h" /* confkeyval */ |
17 | |
18 | #define MERO_PORT "50000" |
19 | #define MERO_SOCK ".s.monetdb." |
20 | #define CONTROL_SOCK ".s.merovingian." |
21 | |
22 | #define SOCKPTR struct sockaddr * |
23 | #ifdef HAVE_SOCKLEN_T |
24 | #define SOCKLEN socklen_t |
25 | #else |
26 | #define SOCKLEN int |
27 | #endif |
28 | |
29 | typedef char* err; |
30 | |
31 | #define freeErr(X) free(X) |
32 | #define getErrMsg(X) X |
33 | #define NO_ERR (err)0 |
34 | |
35 | /* when not writing to stderr, one has to flush, make it easy to do so */ |
36 | #define Mfprintf(S, ...) \ |
37 | do { \ |
38 | if (S) { \ |
39 | fprintf(S, __VA_ARGS__); \ |
40 | fflush(S); \ |
41 | } \ |
42 | } while (0) |
43 | |
44 | typedef enum _mtype { |
45 | MERO = 1, |
46 | MERODB, |
47 | MEROFUN |
48 | } mtype; |
49 | |
50 | typedef struct _dpair { |
51 | int out; /* where to read stdout messages from */ |
52 | int err; /* where to read stderr messages from */ |
53 | mtype type; /* type of process */ |
54 | short flag; /* flag internal to logListener */ |
55 | pid_t pid; /* this process' id */ |
56 | char *dbname; /* the database that this server serves */ |
57 | struct _dpair* next; |
58 | }* dpair; |
59 | |
60 | char *newErr(_In_z_ _Printf_format_string_ const char *fmt, ...) |
61 | __attribute__((__format__(__printf__, 1, 2))); |
62 | void terminateProcess(pid_t pid, char *dbname, mtype type, int lock); |
63 | void logFD(int fd, char *type, char *dbname, long long int pid, FILE *stream, int rest); |
64 | |
65 | extern char *_mero_mserver; |
66 | extern dpair _mero_topdp; |
67 | extern pthread_mutex_t _mero_topdp_lock; |
68 | extern volatile int _mero_keep_logging; |
69 | extern volatile sig_atomic_t _mero_keep_listening; |
70 | extern FILE *_mero_logfile; |
71 | extern unsigned short _mero_port; |
72 | extern FILE *_mero_discout; |
73 | extern FILE *_mero_discerr; |
74 | extern unsigned short _mero_controlport; |
75 | extern FILE *_mero_ctlout; |
76 | extern FILE *_mero_ctlerr; |
77 | extern int _mero_broadcastsock; |
78 | extern const struct in6_addr ipv6_any_addr; |
79 | extern struct sockaddr_in _mero_broadcastaddr; |
80 | extern char _mero_hostname[128]; |
81 | extern confkeyval *_mero_db_props; |
82 | extern confkeyval *_mero_props; |
83 | |
84 | #endif |
85 | |
86 | /* vim:set ts=4 sw=4 noexpandtab: */ |
87 | |