<commit_before>////////////////////////////////////////////////////////////////////////////////
//
// This file contains the definition for class DaemonCore. This is the
// central structure for every daemon in condor. The daemon core triggers
// preregistered handlers for corresponding events. class Service is the base
// class of the classes that daemon_core can serve. In order to use a class
// with the DaemonCore, it has to be a derived class of Service.
//
// <NAME>
//
////////////////////////////////////////////////////////////////////////////////

#ifndef _CONDOR_DAEMON_CORE_H_
#define _CONDOR_DAEMON_CORE_H_

#if defined(Solaris)
#define __EXTENSIONS__
#endif
#include <sys/types.h>
#include <sys/time.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#if defined(Solaris)
#undef __EXTENSIONS__
#endif
#include "condor_timer_manager.h"

const	int	 MAXDC	= 5; 

// Users pass this enum type to Register functions to identify what type of
// functions to register.
enum{SIGNAL, REQUEST, TIMER};

// these are for internal use.
typedef	int	  	(*SReqHandler)(Service*, XDR*, struct sockaddr_in*); 
typedef	int	  	(*ReqHandler)(XDR*, struct sockaddr_in*); 
typedef	void	(*SSigHandler)(Service*, int, int, void*);
typedef	void	(*SigHandler)(int, int, void*);
typedef void	(*SFunction)(Service*);
typedef void	(*Function)();

class DaemonCore
{
	public:
		
		DaemonCore(int, int, int);
		~DaemonCore();

		void				Register(Service*, int, void*, int);
		int					Register(Service*, time_t, void*, time_t, int);
		void				Register(Service*, void*);
		void				Delete(int);
		
		int					OpenTcp(char*, u_short = 0);
		int					OpenUdp(char*, u_short = 0);
		
		void				Dump(int, char*);

		void				Driver();

	private:

		struct ReqHandlerEnt
		{
		    int				no;
		    void*			handler;
			Service*		service; 
		};
		struct SigHandlerEnt 
		{
		    int				no;
		    void*			handler;
			Service*		service; 
		};
		struct FunctionEnt
		{
		    void*			func;
			Service*		service; 
		};

		void				DumpSigHandlerTable(int, char* = "");
		void				DumpReqHandlerTable(int, char* = "");
		void				DumpTimerList(int, char* = "");
		void				HandleReq(int, char);
		friend	void		HandleSig(int, int, void*); 
		int					SigHandled(int, int, void*);
		void				Register(Service*, int, SigHandler);
		void				Register(Service*, int, ReqHandler);
		
		int					maxSig;			// max number of signal handlers
		int					nSig;			// number of signal handlers
		SigHandlerEnt*		sigTable;		// signal handler table

		int					maxReq;			// max number of request handlers
		int					nReq;			// number of request handlers
		ReqHandlerEnt*		reqTable;		// request handler table

		int					maxFunc;		// to be executed between select
		int					nFunc;			// to be executed between select
		FunctionEnt*		funcTable;		// to be executed between select

		u_short				ports[32];
		int					nPorts; 
		fd_set				readfds; 
		int					tcpSds[32];		// tcp socket descriptors
		int					nTcp;
		int					udpSds[32];		// udp socket descriptors
		int					nUdp;
};

#endif








<commit_msg>Added condor_io functionality to daemon core<commit_after>////////////////////////////////////////////////////////////////////////////////
//
// This file contains the definition for class DaemonCore. This is the
// central structure for every daemon in condor. The daemon core triggers
// preregistered handlers for corresponding events. class Service is the base
// class of the classes that daemon_core can serve. In order to use a class
// with the DaemonCore, it has to be a derived class of Service.
//
// <NAME>
//
////////////////////////////////////////////////////////////////////////////////

#ifndef _CONDOR_DAEMON_CORE_H_
#define _CONDOR_DAEMON_CORE_H_

#if defined(Solaris)
#define __EXTENSIONS__
#endif
#include <sys/types.h>
#include <sys/time.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include "condor_io.h"
#if defined(Solaris)
#undef __EXTENSIONS__
#endif
#include "condor_timer_manager.h"

const	int	 MAXDC	= 5; 

// Users pass this enum type to Register functions to identify what type of
// functions to register.
enum{SIGNAL, REQUEST, TIMER};

// need to specify which type of Tcp or Udp socket we want to use
enum{XDR_SOCK, CONDOR_IO_SOCK};

// these are for internal use.
typedef int     (*SReqHandler)(Service*, void*, struct sockaddr_in*);
typedef	int	  	(*XDR_SReqHandler)(Service*, XDR*, struct sockaddr_in*); 
typedef	int	  	(*IO_SReqHandler)(Service*, Stream*, struct sockaddr_in*);
typedef int		(*ReqHandler)(void*, struct sockaddr_in*);
typedef	int	  	(*XDR_ReqHandler)(XDR*, struct sockaddr_in*); 
typedef	int	  	(*IO_ReqHandler)(Stream*, struct sockaddr_in*);
typedef	void	(*SSigHandler)(Service*, int, int, void*);
typedef	void	(*SigHandler)(int, int, void*);
typedef void	(*SFunction)(Service*);
typedef void	(*Function)();

class DaemonCore
{
	public:
		
		DaemonCore(int, int, int);
		~DaemonCore();

		void				Register(Service*, int, void*, int);
		int					Register(Service*, time_t, void*, time_t, int);
		void				Register(Service*, void*);
		void				Delete(int);
		
		int					OpenTcp(char*, u_short = 0, int = XDR_SOCK);
		int					OpenUdp(char*, u_short = 0, int = XDR_SOCK);
		
		void				Dump(int, char*);

		void				Driver();

	private:

		struct ReqHandlerEnt
		{
		    int				no;
		    void*			handler;
			Service*		service; 
		};
		struct SigHandlerEnt 
		{
		    int				no;
		    void*			handler;
			Service*		service; 
		};
		struct FunctionEnt
		{
		    void*			func;
			Service*		service; 
		};

		void				DumpSigHandlerTable(int, char* = "");
		void				DumpReqHandlerTable(int, char* = "");
		void				DumpTimerList(int, char* = "");
		void				HandleReq(int, char, int);
		friend	void		HandleSig(int, int, void*); 
		int					SigHandled(int, int, void*);
		void				Register(Service*, int, SigHandler);
		void				Register(Service*, int, ReqHandler);
		
		int					maxSig;			// max number of signal handlers
		int					nSig;			// number of signal handlers
		SigHandlerEnt*		sigTable;		// signal handler table

		int					maxReq;			// max number of request handlers
		int					nReq;			// number of request handlers
		ReqHandlerEnt*		reqTable;		// request handler table

		int					maxFunc;		// to be executed between select
		int					nFunc;			// to be executed between select
		FunctionEnt*		funcTable;		// to be executed between select

		u_short				ports[32];
		int					nPorts; 
		fd_set				readfds; 
		int					tcp_XdrOrIo[32];// is the socket xdr or condor_io
		int					tcpSds[32];		// tcp socket descriptors
		int					nTcp;
		int					udp_XdrOrIo[32];// is the socket xdr or condor_io
		int					udpSds[32];		// udp socket descriptors
		int					nUdp;
};

#endif









{'fraction_non_alphanumeric': 0.15277151870211808, 'fraction_numerical': 0.0033047919483250713, 'mean_word_length': 2.5699731903485254, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1445955', 'n_tokens_mistral': 2644, 'n_tokens_neox': 2213, 'n_words': 678}