8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-27 05:23:02 +01:00
firebird-mirror/src/jrd/svc.h

177 lines
4.9 KiB
C
Raw Normal View History

2001-05-23 15:26:42 +02:00
/*
* PROGRAM: JRD access method
* MODULE: svc.h
* DESCRIPTION: Service manager declarations
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef JRD_SVC_H
#define JRD_SVC_H
2001-12-24 03:51:06 +01:00
// TMN: To be removed once the C++ conversion is completed
#ifdef INCLUDE_OLD_FB_BLK
#error You can not include both old_fb_blk.h and this file
#endif
#include "../jrd/jrd_pwd.h"
2001-05-23 15:26:42 +02:00
#include "../jrd/isc.h"
#include "../jrd/svc_undoc.h"
#include "../jrd/svc_proto.h"
#include "../jrd/isc_s_proto.h"
2001-12-24 03:51:06 +01:00
#include "../jrd/jrd_blks.h"
#include "../include/fb_blk.h"
2001-05-23 15:26:42 +02:00
#define SERVICE_VERSION 2
#define SVC_STDOUT_BUFFER_SIZE 1024
/* Flag of capabilities supported by the server */
//#define WAL_SUPPORT 0x1L /* Write Ahead Log */
2001-05-24 16:54:26 +02:00
#define MULTI_CLIENT_SUPPORT 0x2L /* SuperServer model (vs. multi-inet) */
#define REMOTE_HOP_SUPPORT 0x4L /* Server can connect to other server */
#define NO_SVR_STATS_SUPPORT 0x8L /* Does not support statistics */
#define NO_DB_STATS_SUPPORT 0x10L /* Does not support statistics */
#define LOCAL_ENGINE_SUPPORT 0x20L /* The local 16 bit engine */
#define NO_FORCED_WRITE_SUPPORT 0x40L /* Can not configure sync writes */
#define NO_SHUTDOWN_SUPPORT 0x80L /* Can not shutdown/restart databases */
2001-05-23 15:26:42 +02:00
#define NO_SERVER_SHUTDOWN_SUPPORT 0x100L /* Can not shutdown server */
2001-05-24 16:54:26 +02:00
#define SERVER_CONFIG_SUPPORT 0x200L /* Can configure server */
#define QUOTED_FILENAME_SUPPORT 0x400L /* Can pass quoted filenames in */
2001-05-23 15:26:42 +02:00
/* Range definitions for service actions. Any action outside of
this range is not supported */
#define isc_action_min 1
#define isc_action_max 14
/* Range definitions for service actions. Any action outside of
this range is not supported */
#define isc_info_min 50
#define isc_info_max 67
/* switches for username and password used when a username and/or password
* is specified by the client application
*/
#define USERNAME_SWITCH "-USER"
#define PASSWORD_SWITCH "-PASSWORD"
#if defined ( SUPERSERVER ) || defined ( SUPERCLIENT )
2001-05-23 15:26:42 +02:00
#define SERVICE_THD_PARAM "-svc_thd"
#else
#define SERVICE_THD_PARAM "-svc"
#endif
2001-05-23 15:26:42 +02:00
/* Macro used to store services thread specific data */
/* Currently we store empty string, see bug #10394 */
#ifdef SUPERSERVER
#define SVC_PUTSPECIFIC_DATA {\
char t_data[] = {'\0'};\
THD_putspecific_data((void*)t_data);\
}
#else
#define SVC_PUTSPECIFIC_DATA /* nothing */
#endif
2002-10-26 14:34:46 +02:00
2003-04-10 08:49:16 +02:00
void SVC_STATUS_ARG(ISC_STATUS*& status, USHORT type, const void* value);
2001-05-23 15:26:42 +02:00
struct serv_entry; // forward decl.
2001-05-23 15:26:42 +02:00
/* Service manager block */
2001-12-24 03:51:06 +01:00
class svc : public pool_alloc<type_svc>
2001-05-24 16:54:26 +02:00
{
2001-12-24 03:51:06 +01:00
public:
2001-05-24 16:54:26 +02:00
SLONG svc_handle; /* "handle" of process/thread running service */
ISC_STATUS* svc_status; /* status vector for svc_handle */
2001-05-24 16:54:26 +02:00
void* svc_input; /* input to service */
void* svc_output; /* output from service */
ULONG svc_stdout_head;
ULONG svc_stdout_tail;
UCHAR* svc_stdout;
TEXT** svc_argv;
ULONG svc_argc;
event_t svc_start_event[1]; /* fired once service has started successfully */
serv_entry* svc_service;
2001-05-24 16:54:26 +02:00
UCHAR* svc_resp_buf;
UCHAR* svc_resp_ptr;
USHORT svc_resp_buf_len;
USHORT svc_resp_len;
USHORT svc_flags;
USHORT svc_user_flag;
USHORT svc_spb_version;
BOOLEAN svc_do_shutdown;
TEXT svc_username[33];
TEXT svc_enc_password[MAX_PASSWORD_ENC_LENGTH];
TEXT svc_reserved[1];
TEXT* svc_switches;
void svc_started();
2001-12-24 03:51:06 +01:00
};
2001-05-23 15:26:42 +02:00
/* Bitmask values for the svc_flags variable */
2001-05-24 16:54:26 +02:00
#define SVC_eof 1
#define SVC_timeout 2
#define SVC_forked 4
2001-05-23 15:26:42 +02:00
#define SVC_detached 8
#define SVC_finished 16
2001-05-24 16:54:26 +02:00
#define SVC_thd_running 32
#define SVC_evnt_fired 64
2001-05-23 15:26:42 +02:00
// Method used to signify that the service started has done basic
// initialization and can be considered a successful startup.
2004-02-02 12:02:12 +01:00
#ifndef SUPERSERVER
inline void svc::svc_started()
2004-02-02 12:02:12 +01:00
{
// null definition, no overhead.
}
#else /* SUPERSERVER */
inline void svc::svc_started()
2004-02-02 12:02:12 +01:00
{
event_t* evnt_ptr = svc_start_event;
if (!(svc_flags & SVC_evnt_fired)) {
svc_flags |= SVC_evnt_fired;
2004-02-02 12:02:12 +01:00
ISC_event_post(evnt_ptr);
}
}
#endif /* SUPERSERVER */
typedef int (*pfn_svc_main) (svc*);
typedef int (*pfn_svc_output)(svc*, const UCHAR*);
2004-02-02 12:02:12 +01:00
struct serv_entry
2004-02-02 12:02:12 +01:00
{
USHORT serv_action;
const TEXT* serv_name;
const TEXT* serv_std_switches;
const TEXT* serv_executable;
2004-02-02 12:02:12 +01:00
pfn_svc_main serv_thd;
bool* serv_in_use;
};
#endif // JRD_SVC_H