<commit_before>/* 
** Copyright 1986, 1987, 1988, 1989, 1990, 1991 by the Condor Design Team
** 
** Permission to use, copy, modify, and distribute this software and its
** documentation for any purpose and without fee is hereby granted,
** provided that the above copyright notice appear in all copies and that
** both that copyright notice and this permission notice appear in
** supporting documentation, and that the names of the University of
** Wisconsin and the Condor Design Team not be used in advertising or
** publicity pertaining to distribution of the software without specific,
** written prior permission.  The University of Wisconsin and the Condor
** Design Team make no representations about the suitability of this
** software for any purpose.  It is provided "as is" without express
** or implied warranty.
** 
** THE UNIVERSITY OF WISCONSIN AND THE CONDOR DESIGN TEAM DISCLAIM ALL
** WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE UNIVERSITY OF
** WISCONSIN OR THE CONDOR DESIGN TEAM BE LIABLE FOR ANY SPECIAL, INDIRECT
** OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
** OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
** OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
** OR PERFORMANCE OF THIS SOFTWARE.
** 
** Authors:  <NAME> and <NAME>,
** 	         University of Wisconsin, Computer Sciences Dept.
**
** Modified by : <NAME>
**               University of Wisconsin, Computer Sciences Dept.
** Uses <IP:PORT> rather than hostnames
**
** Modified by <NAME>
**			User condor_daemon_core 
*/

#define _POSIX_SOURCE
#include "condor_common.h"

#include <netdb.h>
#include <pwd.h>

#if defined(IRIX331)
#define __EXTENSIONS__
#include <signal.h>
#define BADSIG SIG_ERR
#undef __EXTENSIONS__
#else
#include <signal.h>
#endif

#include <sys/socket.h>
#include <sys/param.h>
#include <sys/file.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/utsname.h>

#include "condor_fix_wait.h"

#if defined(HPUX9)
#include "fake_flock.h"
#endif

#if defined(Solaris)
#include "fake_flock.h"
#endif

#include <sys/stat.h>
#include <netinet/in.h>
#include "debug.h"
#include "trace.h"
#include "except.h"
#include "sched.h"
#include "clib.h"
#include "exit.h"
#include "dgram_io_handle.h" /* defines DRAM_IO_HANDLE */

#include "condor_fdset.h"

#include "condor_daemon_core.h"
#include "condor_qmgr.h"
#include "scheduler.h"

#if defined(BSD43) || defined(DYNIX)
#	define WEXITSTATUS(x) ((x).w_retcode)
#	define WTERMSIG(x) ((x).w_termsig)
#endif

extern "C"
{
	void	_EXCEPT_(char*...);
	void	dprintf_config(char*, int);
	void	dprintf(int, char*...);
	int		set_condor_euid();
	void	config(char*, CONTEXT*);
	char*	param(char*);
	int		boolean(char*, char*);
	int		SetSyscalls() {}
	int		ReadLog(char*);
	void	config_from_server(char*, CONTEXT*, char*); 
}
extern	void	mark_jobs_idle();

static char *_FileName_ = __FILE__;		/* Used by EXCEPT (see except.h)     */

// global variables to control the daemon's running and logging
char*		Log;							// log directory
char*		Spool;							// spool directory
int			Foreground = 0;
extern int	Termlog;

// global objects
Scheduler	scheduler;
DaemonCore	core(10, 10, 10);
char*		myName;
Scheduler*	sched = &scheduler;		// for non-member functions to access data
CONTEXT*	MachineContext;

void	Init();

void usage(char* name)
{
	dprintf( D_ALWAYS, "Usage: %s [-f] [-t] [-n schedd_name] [-c config_file_name]", name); 
	exit( 1 );
}

main(int argc, char* argv[])
{
	char**		ptr; 
	ClassAd*	myAd; 
	char		job_queue_name[_POSIX_PATH_MAX];
	char		Name[MAXHOSTNAMELEN];
	int		ScheddName = 0;
	struct		utsname	name;
	char		config_file[MAXPATHLEN] = "";
 
	myName = argv[0];
	if(getuid() == 0)
	{
	#ifdef NFSFIX
		// Must be condor to write to log files.
		set_condor_euid(__FILE__,__LINE__);
	#endif NFSFIX
	}
	
	if(argc > 7)
	{
		usage(argv[0]);
	}
	for(ptr = argv + 1; *ptr; ptr++)
	{
		if(ptr[0][0] != '-')
		{
			usage(argv[0]);
		}
		switch(ptr[0][1])
		{
		  case 'f':
			Foreground = 1;
			break;
		  case 't':
			Termlog = 1;
			break;
		  case 'b':
			Foreground = 0;
			break;
		  case 'n':
			strcpy(Name, *(++ptr));
			++ptr;
			ScheddName++;
			break;
		case 'c':
			strcpy(config_file, *(++ptr));
			++ptr;
			break; 
		  default:
			usage(argv[0]);
		}
	}
	
	MachineContext = create_context();
	if(config_file[0] == '\0')
	{
		config(argv[0], MachineContext);
	}
	else
	{
		config_from_server(argv[0], MachineContext, config_file);
	}
	
	myAd = new ClassAd(MachineContext); 
	Init();

	// if a name if not specified, assume the name of the machine
	if(!ScheddName)
	{
		uname(&name);
		strcpy(Name, name.nodename);
	}

	// throw the name into the machine ad
	{
		char	expr[200];

		sprintf(expr, "Name = %s", Name);<commit_msg>config_from_sever arguments order wrong<commit_after>/* 
** Copyright 1986, 1987, 1988, 1989, 1990, 1991 by the Condor Design Team
** 
** Permission to use, copy, modify, and distribute this software and its
** documentation for any purpose and without fee is hereby granted,
** provided that the above copyright notice appear in all copies and that
** both that copyright notice and this permission notice appear in
** supporting documentation, and that the names of the University of
** Wisconsin and the Condor Design Team not be used in advertising or
** publicity pertaining to distribution of the software without specific,
** written prior permission.  The University of Wisconsin and the Condor
** Design Team make no representations about the suitability of this
** software for any purpose.  It is provided "as is" without express
** or implied warranty.
** 
** THE UNIVERSITY OF WISCONSIN AND THE CONDOR DESIGN TEAM DISCLAIM ALL
** WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE UNIVERSITY OF
** WISCONSIN OR THE CONDOR DESIGN TEAM BE LIABLE FOR ANY SPECIAL, INDIRECT
** OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
** OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
** OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
** OR PERFORMANCE OF THIS SOFTWARE.
** 
** Authors:  <NAME> and <NAME>,
** 	         University of Wisconsin, Computer Sciences Dept.
**
** Modified by : <NAME>
**               University of Wisconsin, Computer Sciences Dept.
** Uses <IP:PORT> rather than hostnames
**
** Modified by <NAME>
**			User condor_daemon_core 
*/

#define _POSIX_SOURCE
#include "condor_common.h"

#include <netdb.h>
#include <pwd.h>

#if defined(IRIX331)
#define __EXTENSIONS__
#include <signal.h>
#define BADSIG SIG_ERR
#undef __EXTENSIONS__
#else
#include <signal.h>
#endif

#include <sys/socket.h>
#include <sys/param.h>
#include <sys/file.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/utsname.h>

#include "condor_fix_wait.h"

#if defined(HPUX9)
#include "fake_flock.h"
#endif

#if defined(Solaris)
#include "fake_flock.h"
#endif

#include <sys/stat.h>
#include <netinet/in.h>
#include "debug.h"
#include "trace.h"
#include "except.h"
#include "sched.h"
#include "clib.h"
#include "exit.h"
#include "dgram_io_handle.h" /* defines DRAM_IO_HANDLE */

#include "condor_fdset.h"

#include "condor_daemon_core.h"
#include "condor_qmgr.h"
#include "scheduler.h"

#if defined(BSD43) || defined(DYNIX)
#	define WEXITSTATUS(x) ((x).w_retcode)
#	define WTERMSIG(x) ((x).w_termsig)
#endif

extern "C"
{
	void	_EXCEPT_(char*...);
	void	dprintf_config(char*, int);
	void	dprintf(int, char*...);
	int		set_condor_euid();
	void	config(char*, CONTEXT*);
	char*	param(char*);
	int		boolean(char*, char*);
	int		SetSyscalls() {}
	int		ReadLog(char*);
	void	config_from_server(char*, char*, CONTEXT*); 
}
extern	void	mark_jobs_idle();

static char *_FileName_ = __FILE__;		/* Used by EXCEPT (see except.h)     */

// global variables to control the daemon's running and logging
char*		Log;							// log directory
char*		Spool;							// spool directory
int			Foreground = 0;
extern int	Termlog;

// global objects
Scheduler	scheduler;
DaemonCore	core(10, 10, 10);
char*		myName;
Scheduler*	sched = &scheduler;		// for non-member functions to access data
CONTEXT*	MachineContext;

void	Init();

void usage(char* name)
{
	dprintf( D_ALWAYS, "Usage: %s [-f] [-t] [-n schedd_name] [-c config_file_name]", name); 
	exit( 1 );
}

main(int argc, char* argv[])
{
	char**		ptr; 
	ClassAd*	myAd; 
	char		job_queue_name[_POSIX_PATH_MAX];
	char		Name[MAXHOSTNAMELEN];
	int		ScheddName = 0;
	struct		utsname	name;
	char		config_file[MAXPATHLEN] = "";
 
	myName = argv[0];
	if(getuid() == 0)
	{
	#ifdef NFSFIX
		// Must be condor to write to log files.
		set_condor_euid(__FILE__,__LINE__);
	#endif NFSFIX
	}
	
	if(argc > 7)
	{
		usage(argv[0]);
	}
	for(ptr = argv + 1; *ptr; ptr++)
	{
		if(ptr[0][0] != '-')
		{
			usage(argv[0]);
		}
		switch(ptr[0][1])
		{
		  case 'f':
			Foreground = 1;
			break;
		  case 't':
			Termlog = 1;
			break;
		  case 'b':
			Foreground = 0;
			break;
		  case 'n':
			strcpy(Name, *(++ptr)); 
			ScheddName++;
			break;
		  case 'c':
			strcpy(config_file, *(++ptr));
			break; 
		  default:
			usage(argv[0]);
		}
	}
	
	MachineContext = create_context();
	if(config_file[0] == '\0')
	{
		config(argv[0], MachineContext);
	}
	else
	{
		config_from_server(config_file, argv[0], MachineContext);
	}
	
	myAd = new ClassAd(MachineContext); 
	Init();

	// if a name if not specified, assume the name of the machine
	if(!ScheddName)
	{
		uname(&name);
		strcpy(Name, name.nodename);
	}

	// throw the name into the machine ad
	{
		char	expr[200];

		sprintf(expr, "Name = %s", Name);
{'fraction_non_alphanumeric': 0.13049267643142476, 'fraction_numerical': 0.01229130390248899, 'mean_word_length': 4.061689994815967, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 41, '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': '1864989', 'n_tokens_mistral': 3793, 'n_tokens_neox': 3472, 'n_words': 1088}