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 SERVER_H
10#define SERVER_H
11#ifdef HAVE_MAPI
12/* #define DEBUG_SERVER */
13
14#include "mal_client.h"
15#include "mal_session.h"
16#include "mal_exception.h"
17#include "mal_interpreter.h"
18#include "mal_authorize.h"
19#include "msabaoth.h"
20#include "mcrypt.h"
21#include "stream.h"
22#include "streams.h" /* for Stream */
23
24
25#define NEW_ARRAY( type, size ) (type*)GDKmalloc((size)*sizeof(type))
26#define STREQ(a, b) (strcmp(a, b)==0)
27
28#define SERVERPORT 50000
29#define SERVERMAXUSERS 5
30
31mal_export str SERVERlisten_default(int *ret);
32mal_export str SERVERlisten_port(int *ret, int *pid);
33mal_export str SERVERlisten_usock(int *ret, str *usock);
34mal_export str SERVERstop(void *ret);
35mal_export str SERVERsuspend(void *ret);
36mal_export str SERVERresume(void *ret);
37
38mal_export str SERVERconnect(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pc);
39mal_export str SERVERdisconnectWithAlias(int *ret, str *db_alias);
40mal_export str SERVERdisconnectALL(int *ret);
41mal_export str SERVERreconnectAlias(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pc);
42mal_export str SERVERreconnectWithoutAlias(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pc);
43mal_export str SERVERtrace(void *ret, int *mid, int *flag);
44mal_export str SERVERdisconnect(void *ret, int *mid);
45mal_export str SERVERsetAlias(void *ret, int *mid, str *dbalias);
46mal_export str SERVERlookup(int *ret, str *dbalias);
47mal_export str SERVERdestroy(void *ret, int *mid);
48mal_export str SERVERreconnect(void *ret, int *mid);
49mal_export str SERVERping(int *ret, int *mid);
50mal_export str SERVERquery(int *ret, int *mid, str *qry);
51mal_export str SERVERquery_handle(int *ret, int *mid, str *qry);
52mal_export str SERVERquery_array(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pc);
53mal_export str SERVERprepare(int *ret, int *key, str *qry);
54mal_export str SERVERfinish(int *ret, int *idx);
55mal_export str SERVERrows_affected(lng *ret, int *idx);
56mal_export str SERVERget_row_count(lng *ret, int *idx);
57mal_export str SERVERget_field_count(int *ret, int *idx);
58mal_export str SERVERfetch_row(int *ret, int *idx);
59mal_export str SERVERfetch_all_rows(lng *ret, int *idx);
60mal_export str SERVERfetch_field_str(str *ret, int *idx, int *fnr);
61mal_export str SERVERfetch_field_int(int *ret, int *idx, int *fnr);
62mal_export str SERVERfetch_field_lng(lng *ret, int *idx, int *fnr);
63#ifdef HAVE_HGE
64mal_export str SERVERfetch_field_hge(hge *ret, int *idx, int *fnr);
65#endif
66mal_export str SERVERfetch_field_sht(sht *ret, int *idx, int *fnr);
67mal_export str SERVERfetch_field_void(void *ret, int *idx, int *fnr);
68mal_export str SERVERfetch_field_oid(oid *ret, int *idx, int *fnr);
69mal_export str SERVERfetch_field_bte(bte *ret, int *idx, int *fnr);
70mal_export str SERVERfetch_line(str *ret, int *key);
71mal_export str SERVERnext_result(int *ret, int *key);
72mal_export str SERVERfetch_reset(int *ret, int *key);
73mal_export str SERVERfetch_field_bat(bat *bid, int *idx);
74mal_export str SERVERerror(int *ret, int *idx);
75mal_export str SERVERgetError(str *ret, int *idx);
76mal_export str SERVERexplain(str *ret, int *idx);
77mal_export str SERVERmapi_rpc_single_row(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
78mal_export str SERVERmapi_rpc_single_bat(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
79mal_export str SERVERput(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
80mal_export str SERVERputLocal(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
81mal_export str SERVERbindBAT(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
82mal_export str SERVERclient(void *res, const Stream *In, const Stream *Out);
83mal_export str SERVERmapi_rpc_bat(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
84
85#endif /* HAVE_MAPI */
86#endif /* SERVER_H */
87