示例#1
0
/*
 * Flush and reload data base.
 */
void
db_reload()
{
	dprintf(3, (ddt, "reload()\n"));
	syslog(LOG_NOTICE, "reloading nameserver\n");

	qflush();
	sqflush();
	getnetconf();
#ifdef FORCED_RELOAD
	reloading = 1;     /* to force transfer if secondary and backing up */
#endif
	ns_init(bootfile);
	time(&resettime);
#ifdef FORCED_RELOAD
	reloading = 0;
#endif /* FORCED_RELOAD */

	dprintf(1, (ddt, "Ready to answer queries.\n"));
	syslog(LOG_NOTICE, "Ready to answer queries.\n");
}
示例#2
0
文件: ne.c 项目: AgamAgarwal/minix
/* 
**  Name:	void ne_init(dpeth_t * dep);
**  Function:	Initialize the board making it ready to work.
*/
static void ne_init(dpeth_t * dep)
{
  int ix;

  dep->de_data_port = dep->de_base_port + NE_DATA;
  if (dep->de_16bit) {
	dep->de_ramsize = NE2000_SIZE;
	dep->de_offset_page = NE2000_START / DP_PAGESIZE;
  } else {
	dep->de_ramsize = NE1000_SIZE;
	dep->de_offset_page = NE1000_START / DP_PAGESIZE;
  }

  /* Allocates two send buffers from onboard RAM */
  dep->de_sendq_nr = SENDQ_NR;
  for (ix = 0; ix < SENDQ_NR; ix += 1) {
	dep->de_sendq[ix].sq_sendpage = dep->de_offset_page + ix * SENDQ_PAGES;
  }

  /* Remaining onboard RAM allocated for receiving */
  dep->de_startpage = dep->de_offset_page + ix * SENDQ_PAGES;
  dep->de_stoppage = dep->de_offset_page + dep->de_ramsize / DP_PAGESIZE;

  /* Can't override the default IRQ. */
  dep->de_irq &= NOT(DEI_DEFAULT);

  ns_init(dep);			/* Initialize DP controller */

  printf("%s: NE%d000 (%dkB RAM) at %X:%d - ",
         dep->de_name,
         dep->de_16bit ? 2 : 1,
         dep->de_ramsize / 1024,
         dep->de_base_port, dep->de_irq);
  for (ix = 0; ix < SA_ADDR_LEN; ix += 1)
	printf("%02X%c", dep->de_address.ea_addr[ix], ix < SA_ADDR_LEN - 1 ? ':' : '\n');
  return;
}
示例#3
0
/*
**  Name:	void el2_init(dpeth_t *dep);
**  Function:	Initalize hardware and data structures.
*/
static void el2_init(dpeth_t * dep)
{
  int ix, irq;
  int sendq_nr;
  int cntr;

  /* Map the address PROM to lower I/O address range */
  cntr = inb_el2(dep, EL2_CNTR);
  outb_el2(dep, EL2_CNTR, cntr | ECNTR_SAPROM);

  /* Read station address from PROM */
  for (ix = EL2_EA0; ix <= EL2_EA5; ix += 1)
	dep->de_address.ea_addr[ix] = inb_el2(dep, ix);

  /* Map the 8390 back to lower I/O address range */
  outb_el2(dep, EL2_CNTR, cntr);

  /* Enable memory, but turn off interrupts until we are ready */
  outb_el2(dep, EL2_CFGR, ECFGR_IRQOFF);

  dep->de_data_port = dep->de_dp8390_port = dep->de_base_port;
  dep->de_prog_IO = FALSE;	/* Programmed I/O not yet available */

  /* Check width of data bus */
  outb_el2(dep, DP_CR, CR_PS_P0 | CR_NO_DMA | CR_STP);
  outb_el2(dep, DP_DCR, 0);
  outb_el2(dep, DP_CR, CR_PS_P2 | CR_NO_DMA | CR_STP);
  dep->de_16bit = (inb_el2(dep, DP_DCR) & DCR_WTS) != 0;
  outb_el2(dep, DP_CR, CR_PS_P0 | CR_NO_DMA | CR_STP);

  /* Allocate one send buffer (1.5kb) per 8kb of on board memory. */
  /* Only 8kb of 3c503/16 boards are used to avoid specific routines */
  sendq_nr = dep->de_ramsize / 0x2000;
  if (sendq_nr < 1)
	sendq_nr = 1;
  else if (sendq_nr > SENDQ_NR)
	sendq_nr = SENDQ_NR;

  dep->de_sendq_nr = sendq_nr;
  for (ix = 0; ix < sendq_nr; ix++)
	dep->de_sendq[ix].sq_sendpage = (ix * SENDQ_PAGES) + EL2_SM_START_PG;

  dep->de_startpage = (ix * SENDQ_PAGES) + EL2_SM_START_PG;
  dep->de_stoppage = EL2_SM_STOP_PG;

  outb_el2(dep, EL2_STARTPG, dep->de_startpage);
  outb_el2(dep, EL2_STOPPG, dep->de_stoppage);

  /* Point the vector pointer registers somewhere ?harmless?. */
  outb_el2(dep, EL2_VP2, 0xFF);	/* Point at the ROM restart location    */
  outb_el2(dep, EL2_VP1, 0xFF);	/* 0xFFFF:0000  (from original sources) */
  outb_el2(dep, EL2_VP0, 0x00);	/* - What for protected mode? */

  /* Set interrupt level for 3c503 */
  irq = (dep->de_irq &= ~DEI_DEFAULT);	/* Strip the default flag. */
  if (irq == 9) irq = 2;
  if (irq < 2 || irq > 5) panic(dep->de_name, "bad 3c503 irq configuration", irq);
  outb_el2(dep, EL2_IDCFG, (0x04 << irq));

  outb_el2(dep, EL2_DRQCNT, 0x08);	/* Set burst size to 8 */
  outb_el2(dep, EL2_DMAAH, EL2_SM_START_PG);	/* Put start of TX  */
  outb_el2(dep, EL2_DMAAL, 0x00);	/* buffer in the GA DMA reg */

  outb_el2(dep, EL2_CFGR, ECFGR_NORM);	/* Enable shared memory */

  ns_init(dep);			/* Initialize DP controller */

  printf("%s: Etherlink II%s (%s) at %X:%d:%05lX - ",
	 dep->de_name, dep->de_16bit ? "/16" : "", "3c503",
	 dep->de_base_port, dep->de_irq,
         dep->de_linmem + dep->de_offset_page);
  for (ix = 0; ix < SA_ADDR_LEN; ix += 1)
	printf("%02X%c", dep->de_address.ea_addr[ix],
	       ix < SA_ADDR_LEN - 1 ? ':' : '\n');
  return;
}
示例#4
0
void    nsaction(W_Event * data)
{
  char   *ns_get_nfthresh_s(void);
  int     v;
  register int i;
  register char *cp;

  switch (data->y)
    {

    case NETSTAT_SWITCH:
      if (data->type == W_EV_BUTTON)
  {
    if (netstat)
      {
        netstat = 0;
        W_UnmapWindow(lMeter);
      }
    else
      {
        netstat = 1;
        ns_init(5);
      }
  }
      nsrefresh(NETSTAT_SWITCH);
      break;

    case NETSTAT_RESET:
      if (data->type == W_EV_BUTTON)
  {
    ns_init(0);
    nsrefresh(NETSTAT_TOTAL);
    nsrefresh(NETSTAT_LOCAL);
    nsrefresh(NETSTAT_FAILURES);
  }
      break;

    case NETSTAT_NFTHRESH:
      if (data->type == W_EV_KEY)
  {
    switch (data->key)
      {
      case '\b':
      case '\177':
        cp = ns_get_nfthresh_s();
        i = strlen(cp);
        if (i > 0)
    {
      cp += i - 1;
      *cp = '\0';
    }
        break;
      case '\025':
      case '\030':
        ns_set_nfthresh_s("");
        break;

      default:
        if (data->key >= '0' && data->key <= '9')
    {
      cp = ns_get_nfthresh_s();
      i = strlen(cp);
      if (i < 4)
        {
          cp += i;
          cp[1] = '\0';
          cp[0] = data->key;
        }
    }
        break;
      }
    nsrefresh(NETSTAT_NFTHRESH);
  }
      break;



    case NETSTAT_DONE:
      if (data->type == W_EV_BUTTON)
  {
    if (sscanf(ns_get_nfthresh_s(), "%d", &v) != 1)
      {
        ns_set_nfthresh_s(NETSTAT_DF_NFT_S);
        ns_set_nfthresh(NETSTAT_DF_NFT);
      }
    else
      ns_set_nfthresh(v);

    nsdone();
  }
      break;
    }
}
示例#5
0
int init(int ac, char **av)
{
    int i;
    int openlog_failed = 0, openlog_errno = 0;
    int started_from_term = isatty(0) && isatty(1) && isatty(2);

    /* Imported from main.c */
    extern void sighandler(int signum);


    /* Set file creation mask and group ID. */
#if defined(DEFUMASK) && HAVE_UMASK
    umask(DEFUMASK);
#endif
    if (set_group() < 0)
	return -1;
    
    /* Parse command line for -dir option. */
    parse_dir_options(ac, av);

    /* Chdir to Services data directory. */
    if (chdir(services_dir) < 0) {
	fprintf(stderr, "chdir(%s): %s\n", services_dir, strerror(errno));
	return -1;
    }

    /* Open logfile, and complain if we didn't. */
    if (open_log() < 0) {
	openlog_errno = errno;
	if (started_from_term) {
	    fprintf(stderr, "ATENCION: No puedo abrir el archivo de log %s: %s\n",
			log_filename, strerror(errno));
	} else {
	    openlog_failed = 1;
	}
    }

    /* Read configuration file; exit if there are problems. */
    if (!read_config())
	return -1;

    /* Parse all remaining command-line options. */
    parse_options(ac, av);

    /* Detach ourselves if requested. */
    if (!nofork) {
	if ((i = fork()) < 0) {
	    perror("fork()");
	    return -1;
	} else if (i != 0) {
	    exit(0);
	}
	if (started_from_term) {
	    close(0);
	    close(1);
	    close(2);
	}
	if (setpgid(0, 0) < 0) {
	    perror("setpgid()");
	    return -1;
	}
    }

    /* Write our PID to the PID file. */
    write_pidfile();

    /* Announce ourselves to the logfile. */
    if (debug || readonly || skeleton) {
	log("euskalirc-services-bdd %s (compilados para %s) iniciados (opciones:%s%s%s)",
		version_number, version_protocol,
		debug ? " debug" : "", readonly ? " readonly" : "",
		skeleton ? " skeleton" : "");
    } else {
	log("euskalirc-services-bdd %s (compilados para %s) iniciados.",
		version_number, version_protocol);
    }
    start_time = time(NULL);

    /* If in read-only mode, close the logfile again. */
    if (readonly)
	close_log();

    /* Set signal handlers.  Catch certain signals to let us do things or
     * panic as necessary, and ignore all others.
     */
#ifdef NSIG
    for (i = 1; i <= NSIG; i++)
#else
    for (i = 1; i <= 32; i++)
#endif
	signal(i, SIG_IGN);

    signal(SIGINT, sighandler);
    signal(SIGTERM, sighandler);
    signal(SIGQUIT, sighandler);
    signal(SIGSEGV, sighandler);
    signal(SIGBUS, sighandler);
    signal(SIGQUIT, sighandler);
    signal(SIGHUP, sighandler);
    signal(SIGILL, sighandler);
    signal(SIGTRAP, sighandler);
#ifdef SIGIOT
    signal(SIGIOT, sighandler);
#endif
    signal(SIGFPE, sighandler);

    signal(SIGUSR1, sighandler);  /* This is our "out-of-memory" panic switch */

    /* Initialize multi-language support */
    lang_init();
    if (debug)
	log("debug: Cargando lenguajes");

    /* Initialiize subservices */
    ns_init();
    cs_init();
#ifdef CREGSERV
    cr_init();
#endif    
    ms_init();
    os_init();
    load_spam();
    load_ipv();   /*leyendo datos de frases*/
    /* Load up databases */
    if (!skeleton) {
	load_ns_dbase();
	if (debug)
	    log("debug: Cargando la DB de %s (1/7)", s_NickServ);
	load_cs_dbase();
	if (debug)
	    log("debug: Cargando la DB de %s (2/7)", s_ChanServ);
	    load_cr_dbase();
	if (debug)
	    log("debug: Cargando la DB de %s (3/7)", s_CregServ);
    }
	
    load_os_dbase();
    if (debug)
	log("debug: Cargando la DB de %s (4/7)", s_OperServ);
    load_akill();
    if (debug)
	log("debug: Cargando la DB de GLINES (5/7)");
    load_news();
    if (debug)
	log("debug: Cargando la DB de NOTICIAS (6/7)");
   
    if (debug)
	log("debug: Cargando la DB de SPAM (7/7)");
    load_cr_dbase();
    load_ipv();
    log("Cargadas las bases de datos");

    /* Connect to the remote server */
    servsock = conn(RemoteServer, RemotePort, LocalHost, LocalPort);
    if (servsock < 0)
	fatal_perror("No puedo conectar al servidor");
    send_cmd(NULL, "PASS :%s", RemotePassword);
#ifdef IRC_UNDERNET_P09
    send_cmd(NULL, "SERVER %s 1 %lu %lu P09 :%s",
             ServerName, start_time, start_time, ServerDesc);
#else /* IRC_UNDERNET_P10 */
    send_cmd(NULL, "SERVER %s %d 0 %ld J10 %cD] :%s",
             ServerName, 2, start_time, convert2y[ServerNumerico], ServerDesc); 
#endif
    sgets2(inbuf, sizeof(inbuf), servsock);
    if (strnicmp(inbuf, "ERROR", 5) == 0) {
	/* Close server socket first to stop wallops, since the other
	 * server doesn't want to listen to us anyway */
	disconn(servsock);
	servsock = -1;
	fatal("El servidor ha devuelto: %s", inbuf);
    }


    /* Announce a logfile error if there was one */
    if (openlog_failed) {
	canalopers(NULL, "4ATENCION: No puedo abrir el fichero de log: 12%s",
		strerror(openlog_errno));
    }

    /* Bring in our pseudo-clients */
    introduce_user(NULL);

    send_cmd(ServerName, "SETTIME %lu", time(NULL));
#if HAVE_ALLWILD_NOTICE
    send_cmd(s_OperServ, "NOTICE $*.%s :Establecidos los servicios de la RED.", NETWORK_DOMAIN);
    
#else
# ifdef NETWORK_DOMAIN
    send_cmd(s_OperServ, "NOTICE $*.%s :Establecidos los servicios de la RED.", NETWORK_DOMAIN);
# else
     Go through all common top-level domains.  If you have others,
     * add them here.
     
    send_cmd(s_OperServ, "NOTICE $*.es :Establecidos los servicios de la RED.");
    send_cmd(s_OperServ, "NOTICE $*.com :Establecidos los servicios de la RED.");
    send_cmd(s_OperServ, "NOTICE $*.net :Establecidos los servicios de la RED.");
    send_cmd(s_OperServ, "NOTICE $*.org :Establecidos los servicios de la RED.");    
    send_cmd(s_OperServ, "NOTICE $*.edu :Establecidos los servicios de la RED.");
    send_cmd(s_OperServ, "NOTICE $*.tk :Establecidos los servicios de la RED.");
# endif
#endif
        
    join_chanserv();
      

    /* Success! */
    return 0;
}
示例#6
0
void test_init(int argc, char **argv)
{
	pid_t pid;
	static FILE *pidf;
	char *val;
	struct sigaction sa = {
		.sa_handler	= sig_hand,
		.sa_flags	= SA_RESTART,
	};
	sigemptyset(&sa.sa_mask);

	parseargs(argc, argv);

	val = getenv("ZDTM_NEWNS");
	if (val) {
		unsetenv("ZDTM_NEWNS");
		ns_create(argc, argv);
		exit(1);
	}

	val = getenv("ZDTM_EXE");
	if (val) {
		test_log_init(outfile, "ns");
		redir_stdfds();
		unsetenv("ZDTM_EXE");
		ns_init(argc, argv);
		exit(1);
	}

	val = getenv("ZDTM_GID");
	if (val && (setgid(atoi(val)) == -1)) {
		fprintf(stderr, "Can't set gid: %m");
		exit(1);
	}

	val = getenv("ZDTM_UID");
	if (val && (setuid(atoi(val)) == -1)) {
		fprintf(stderr, "Can't set gid: %m");
		exit(1);
	}

	if (sigaction(SIGTERM, &sa, NULL)) {
		fprintf(stderr, "Can't set SIGTERM handler: %m\n");
		exit(1);
	}

	if (sigaction(SIGCHLD, &sa, NULL)) {
		fprintf(stderr, "Can't set SIGCHLD handler: %m\n");
		exit(1);
	}

	setup_outfile();
	redir_stdfds();

	pidf = fopen(pidfile, "wx");
	if (!pidf) {
		err("Can't create pid file %s: %m\n", pidfile);
		exit(1);
	}

	pid = fork();
	if (pid < 0) {
		err("Daemonizing failed: %m\n");
		exit(1);
	}

	if (pid) {	/* parent will exit when the child is ready */
		test_waitsig();

		if (futex_get(&sig_received) == SIGCHLD) {
			int ret;
			waitpid(pid, &ret, 0);

			if (WIFEXITED(ret)) {
				err("Test exited with unexpectedly with code %d\n", WEXITSTATUS(ret));
				exit(0);
			}
			if (WIFSIGNALED(ret)) {
				err("Test exited on unexpected signal %d\n", WTERMSIG(ret));
				exit(0);
			}
		}

		fprintf(pidf, "%d\n", pid);
		fclose(pidf);
		_exit(0);
	}

	/* record the test pid to remember the ownership of the pidfile */
	master_pid = getpid();

	fclose(pidf);

	sa.sa_handler = SIG_DFL;
	if (sigaction(SIGCHLD, &sa, NULL)) {
		err("Can't reset SIGCHLD handler: %m\n");
		exit(1);
	}

	if (setsid() < 0) {
		err("Can't become session group leader: %m\n");
		exit(1);
	}

	srand48(time(NULL));	/* just in case we need it */
}
示例#7
0
文件: test.c 项目: 0x7f454c46/criu-1
void test_init(int argc, char **argv)
{
	pid_t pid;
	char *val;
	struct sigaction sa = {
		.sa_handler	= sig_hand,
		.sa_flags	= SA_RESTART,
	};
	sigemptyset(&sa.sa_mask);

	parseargs(argc, argv);

	val = getenv("ZDTM_NEWNS");
	if (val) {
		if (!strcmp(val, "1")) {
			ns_create(argc, argv);
			exit(1);
		}

		if (!strcmp(val, "2")) {
			test_log_init(outfile, "ns");
			redir_stdfds();
			ns_init(argc, argv);
		}
	}

	val = getenv("ZDTM_GROUPS");
	if (val) {
		char *tok = NULL;
		unsigned int size = 0, groups[NGROUPS_MAX];

		tok = strtok(val, " ");
		while (tok) {
			size++;
			groups[size - 1] = atoi(tok);
			tok = strtok(NULL, " ");
		}

		if (setgroups(size, groups)) {
			fprintf(stderr, "Can't set groups: %m");
			exit(1);
		}
	}

	val = getenv("ZDTM_GID");
	if (val && (setgid(atoi(val)) == -1)) {
		fprintf(stderr, "Can't set gid: %m");
		exit(1);
	}

	val = getenv("ZDTM_UID");
	if (val && (setuid(atoi(val)) == -1)) {
		fprintf(stderr, "Can't set gid: %m");
		exit(1);
	}

	if (prctl(PR_SET_DUMPABLE, 1)) {
		fprintf(stderr, "Can't set the dumpable flag");
		exit(1);
	}

	if (sigaction(SIGTERM, &sa, NULL)) {
		fprintf(stderr, "Can't set SIGTERM handler: %m\n");
		exit(1);
	}

	if (sigaction(SIGCHLD, &sa, NULL)) {
		fprintf(stderr, "Can't set SIGCHLD handler: %m\n");
		exit(1);
	}

	setup_outfile();
	redir_stdfds();

	pid = fork();
	if (pid < 0) {
		pr_perror("Daemonizing failed");
		exit(1);
	}

	if (pid) {	/* parent will exit when the child is ready */
		test_waitsig();

		if (futex_get(&sig_received) == SIGCHLD) {
			int ret;
			if (waitpid(pid, &ret, 0) != pid) {
				pr_perror("Unable to wait %d, pid");
				exit(1);
			}

			if (WIFEXITED(ret)) {
				pr_err("Test exited unexpectedly with code %d\n", WEXITSTATUS(ret));
				exit(1);
			}
			if (WIFSIGNALED(ret)) {
				pr_err("Test exited on unexpected signal %d\n", WTERMSIG(ret));
				exit(1);
			}
		}

		if (write_pidfile(pid))
			exit(1);

		_exit(0);
	}

	if (setsid() < 0) {
		pr_perror("Can't become session group leader");
		exit(1);
	}

	/* record the test pid to remember the ownership of the pidfile */
	master_pid = getpid();

	sa.sa_handler = SIG_DFL;
	if (sigaction(SIGCHLD, &sa, NULL)) {
		pr_perror("Can't reset SIGCHLD handler");
		exit(1);
	}

	srand48(time(NULL));	/* just in case we need it */
}
示例#8
0
//|=======================================================================================
/// Method name: dspInit()
/// Description: Pre-processing
//|=======================================================================================
void dspInit(void)
{


	//AUDIO_LOGD("Begin %s()", __FUNCTION__);

	core_config_type_g = WB_CFG;

	switch ((int)core_config_type_g)
	{
	case 1:
		Blk_size_i = 160;
		break;
	case 2:
		Blk_size_i = 320;
		break;
	default:
		Blk_size_i = 960;
		break;
	}


	// NS initialisation
	//configuration();

	m_change_temp_min_tracking_b = false;

	/* Retrieve the API parameters ----------------------------------------- */
	ns_flag_g = ON;

	ns_estim_gamma1_g = 6144;
	ns_estim_gamma2_g = 512;
	ns_estim_alpha_max_g = 983;
	ns_estim_beta_min_g = 717;
	ns_estim_rho_g = 717;
	ns_past_snr_weighting_factor_g = 1278;
	ns_present_snr_weighting_factor_g = 20;

	/* Non-stationary noise estimation parameters */
	ns_noise_est_win_len_g = 160;
	ns_noise_est_att_factor_g = 717;
	ns_noise_est_th_ctl_g = 400;

	/* Post-filter parameters */
	ns_post_filter_flag_g = ON;
	ns_post_filter_threshold_g = 640;
	ns_post_filter_length_g = 10;

	/* AGC parameters */
	ns_period_detection_flag_g = ON;
	ns_window_length_seek_max_energy_g = Blk_size_i >> 1;
	ns_step_move_window_g = 2;
	ns_nb_max_window_g = 8;

	/* Default values */
	ns_temporal_min_track_period_g = 8;
	ns_temporal_min_track_depth_g = 5;
	ns_smallest_apriori_snr_g = 20;

	ctrl_s.ns_param_s.ns_flag_es = ns_flag_g;

	ctrl_s.ns_param_s.noise_estim_s.temporal_min_track_period_i = ns_temporal_min_track_period_g;
	ctrl_s.ns_param_s.noise_estim_s.temporal_min_track_depth_i = ns_temporal_min_track_depth_g;
	ctrl_s.ns_param_s.noise_estim_s.gamma1_i = ns_estim_gamma1_g;
	ctrl_s.ns_param_s.noise_estim_s.gamma2_i = ns_estim_gamma2_g;
	ctrl_s.ns_param_s.noise_estim_s.alpha_max_i = ns_estim_alpha_max_g;
	ctrl_s.ns_param_s.noise_estim_s.beta_min_i = ns_estim_beta_min_g;
	ctrl_s.ns_param_s.noise_estim_s.rho_i = ns_estim_rho_g;
	ctrl_s.ns_param_s.noise_estim_s.noise_est_win_len_i = ns_noise_est_win_len_g;
	ctrl_s.ns_param_s.noise_estim_s.noise_est_att_factor_i = ns_noise_est_att_factor_g;
	ctrl_s.ns_param_s.noise_estim_s.noise_est_th_ctl_i = ns_noise_est_th_ctl_g;

	ctrl_s.ns_param_s.noise_filter_s.smallest_apriori_snr_i = ns_smallest_apriori_snr_g;
	ctrl_s.ns_param_s.noise_filter_s.past_snr_weighting_factor_i = ns_past_snr_weighting_factor_g;
	ctrl_s.ns_param_s.noise_filter_s.present_snr_weighting_factor_i = ns_present_snr_weighting_factor_g;


	/* Post filtering */
	ctrl_s.ns_param_s.post_filter_s.ns_post_filter_flag = ns_post_filter_flag_g;
	ctrl_s.ns_param_s.post_filter_s.ns_post_filter_threshold_i = ns_post_filter_threshold_g;
	ctrl_s.ns_param_s.post_filter_s.ns_post_filter_length_i = ns_post_filter_length_g;

	/* Period Detection */
	ctrl_s.ns_param_s.period_detect_s.ns_period_detection_flag = ns_period_detection_flag_g;
	ctrl_s.ns_param_s.period_detect_s.ns_window_len_seek_max_nrj_i = ns_window_length_seek_max_energy_g;
	ctrl_s.ns_param_s.period_detect_s.ns_step_move_window_i = ns_step_move_window_g;
	ctrl_s.ns_param_s.period_detect_s.ns_nb_max_window_i = ns_nb_max_window_g;



	/* Initialization --- */
	ns_init(&ctrl_s.ns_param_s.noise_estim_s, &ctrl_s.ns_param_s.noise_filter_s, &ctrl_s.ns_param_s.post_filter_s, &ctrl_s.ns_param_s.period_detect_s);

	ctrl_s.ns_param_s.first_call_u1 = true;
	for (int j = 0; j < Blk_size_i; j++)
	{
		ctrl_s.ns_in_s.input_signal_pi[j] = 0;
		ctrl_s.ns_out_s.output_signal_pi[j] = 0;
		ctrl_s.ns_out_s.output_noise_gain_pi[j] = 0;
	}

}
示例#9
0
/*
 *	Running in virtual memory, on the interrupt stack.
 *	Does not return.  Dispatches initial thread.
 *
 *	Assumes that master_cpu is set.
 */
void
setup_main(void)
{
	thread_t		startup_thread;

	printf_init();
	panic_init();

	sched_init();
	vm_mem_bootstrap();
	ipc_bootstrap();
	vm_mem_init();
	ipc_init();

	/*
	 * As soon as the virtual memory system is up, we record
	 * that this CPU is using the kernel pmap.
	 */
	PMAP_ACTIVATE_KERNEL(master_cpu);

	init_timers();
	timeout_init();

#if	CDLI > 0
	ns_init();	/* Initialize CDLI */
#endif	/* CDLI > 0 */

	dev_lookup_init();
	timeout_init();
	machine_init();

	machine_info.max_cpus = NCPUS;
	machine_info.memory_size = mem_size;
	machine_info.avail_cpus = 0;
	machine_info.major_version = KERNEL_MAJOR_VERSION;
	machine_info.minor_version = KERNEL_MINOR_VERSION;

#if	XPR_DEBUG
	xprbootstrap();
#endif	/* XPR_DEBUG */

	/*
	 *	Initialize the IPC, task, and thread subsystems.
	 */
	clock_init();
	utime_init();
        ledger_init();
#if	THREAD_SWAPPER
	thread_swapper_init();
#endif	/* THREAD_SWAPPER */
#if	TASK_SWAPPER
	task_swapper_init();
#endif	/* TASK_SWAPPER */
	task_init();
	act_init();
	thread_init();
	subsystem_init();
#if	TASK_SWAPPER
	task_swappable(&realhost, kernel_task, FALSE);
#endif	/* TASK_SWAPPER */
#if	MACH_HOST
	pset_sys_init();
#endif	/* MACH_HOST */

	/*
	 *	Kick off the time-out driven routines by calling
	 *	them the first time.
	 */
	recompute_priorities();
	compute_mach_factor();

	/*
	 *	Initialize the Event Trace Analysis Package.
	 * 	Dynamic Phase: 2 of 2
	 */
	etap_init_phase2();
	
	/*
	 *	Create a kernel thread to start the other kernel
	 *	threads.  Thread_resume (from kernel_thread) calls
	 *	thread_setrun, which may look at current thread;
	 *	we must avoid this, since there is no current thread.
	 */

	/*
	 * Create the thread, and point it at the routine.
	 */
	(void) thread_create_at(kernel_task, &startup_thread,
							start_kernel_threads);
#if	NCPUS > 1 && PARAGON860
	thread_bind(startup_thread, cpu_to_processor(master_cpu));
#endif
	/*
	 * Pretend it is already running, and resume it.
	 * Since it looks as if it is running, thread_resume
	 * will not try to put it on the run queues.
	 *
	 * We can do all of this without locking, because nothing
	 * else is running yet.
	 */
	startup_thread->state |= TH_RUN;
	(void) thread_resume(startup_thread->top_act);

	/*
	 * Start the thread.
	 */
	cpu_launch_first_thread(startup_thread);
	/*NOTREACHED*/
	panic("cpu_launch_first_thread returns!");
}
int ns_create(adnc_pfx_effect_t *effect)
{
    ALOGV("ns_create %p", effect);

    return ns_init (effect);
}
示例#11
0
文件: init.c 项目: goXXip/K9
int init(int ac, char **av)
{

/* temporary
ChannelInfo *ci;
NickInfo *ni;
*/

    int i;
    int openlog_failed = 0, openlog_errno = 0;
    int started_from_term = isatty(0) && isatty(1) && isatty(2);


    /* Initialize pseudo-random number generator. */
    srand(time(NULL) ^ getppid() ^ getpid()<<16);

    /* Set file creation mask and group ID. */
#if defined(DEFUMASK) && HAVE_UMASK
    umask(DEFUMASK);
#endif
    if (set_group() < 0)
	return -1;

    /* Parse command-line options; exit if an error occurs. */
    if (parse_options(ac, av) < 0)
	return -1;

    /* Chdir to Services data directory. */
    if (chdir(services_dir) < 0) {
	fprintf(stderr, "chdir(%s): %s\n", services_dir, strerror(errno));
	return -1;
    }

    /* Open logfile, and complain if we didn't. */
    if (open_log() < 0) {
	openlog_errno = errno;
	if (started_from_term) {
	    fprintf(stderr, "Warning: unable to open log file %s: %s\n",
			log_filename, strerror(errno));
	} else {
	    openlog_failed = 1;
	}
    }

    /* Read configuration file; exit if there are problems. */
    if (!read_config())
	return -1;

    /* Re-parse command-line options (to override configuration file). */
    parse_options(ac, av);

    /* Detach ourselves if requested. */
    if (!nofork) {
	if ((i = fork()) < 0) {
	    perror("fork()");
	    return -1;
	} else if (i != 0) {
	    exit(0);
	}
	if (started_from_term) {
	    close(0);
	    close(1);
	    close(2);
	}
	if (setpgid(0, 0) < 0) {
	    perror("setpgid()");
	    return -1;
	}
    }

#ifdef MEMCHECKS
    /* Account for runtime memory.  Do this after forking to avoid a bogus
     * "XXX bytes leaked on exit" message when the parent exits. */
    init_memory();
#endif

    /* Write our PID to the PID file. */
    write_pidfile();

    /* Announce ourselves to the logfile. */
    if (debug || readonly || skeleton || noexpire) {
	log("Services %s (compiled for %s) starting up (options:%s%s%s%s)",
	    version_number, version_protocol,
	    debug ? " debug" : "",
	    readonly ? " readonly" : "",
	    skeleton ? " skeleton" : "",
	    noexpire ? " noexpire" : "");
    } else {
	log("Services %s (compiled for %s) starting up",
	    version_number, version_protocol);
    }
    start_time = time(NULL);

    /* If in read-only mode, close the logfile again. */
    if (readonly)
	close_log();

    /* Set signal handlers.  Catch certain signals to let us do things or
     * panic as necessary, and ignore all others.
     */
#ifdef NSIG
    for (i = 1; i <= NSIG; i++) {
#else
    for (i = 1; i <= 32; i++) {
#endif
	if (i != SIGPROF)
	    signal(i, SIG_IGN);
    }

    signal(SIGINT, weirdsig_handler);
    signal(SIGTERM, weirdsig_handler);
    signal(SIGQUIT, weirdsig_handler);
#ifndef DUMPCORE
    signal(SIGSEGV, weirdsig_handler);
#endif
    signal(SIGBUS, weirdsig_handler);
    signal(SIGQUIT, weirdsig_handler);
    signal(SIGHUP, weirdsig_handler);
    signal(SIGILL, weirdsig_handler);
    signal(SIGTRAP, weirdsig_handler);
    signal(SIGFPE, weirdsig_handler);
#ifdef SIGIOT
    signal(SIGIOT, weirdsig_handler);
#endif

    /* This is our "out-of-memory" panic switch */
    signal(SIGUSR1, weirdsig_handler);

    /* Initialize multi-language support */
    lang_init();
    if (debug)
	log("debug: Loaded languages");

    /* Initialiize subservices */
    ns_init();
    cs_init();

#ifdef USE_MYSQL
    if(!db_connect(1))
      fatal("could not connect to mysql database");
#endif

    /* Load up databases */
    if (!skeleton) {

        db_load_ns();
	//load_ns_dbase();

	if (debug)
	    log("debug: Loaded %s database (1/7)", s_NickServ);

        db_load_cs();
	//load_cs_dbase();

	if (debug)
	    log("debug: Loaded %s database (2/7)", s_ChanServ);

/* start: temporary code */

/*
    for (ni = firstnick(); ni; ni = nextnick()) {
      genpass(ni->pass);
      email_pass(ni->email ? ni->email : "invalid", ni->pass, ni->nick);
      log("debug: genpass for [%s]", ni->nick);
#ifdef USE_ENCRYPTION
      encrypt_in_place(ni->pass, PASSMAX - 1);
#endif
      db_nick_set(ni, "pass", ni->pass);
    }

    for(ci = cs_firstchan(); ci; ci = cs_nextchan()) {
      genpass(ci->founderpass);
      email_pass(ci->email ? ci->email : "invalid", ci->founderpass, ci->name);
      log("debug: genpass for [%s]", ci->name);
#ifdef USE_ENCRYPTION
      encrypt_in_place(ci->founderpass, PASSMAX - 1);
#endif
      db_chan_set(ci, "founderpass", ci->founderpass);
    }

    exit(0);
*/

/*
    for (ni = firstnick(); ni; ni = nextnick()) {
       if(db_add_nick(ni) == -1)
         log("dberror: while adding nicks. continuing");
    }

    for(ci = cs_firstchan(); ci; ci = cs_nextchan()) {
      if(db_add_channel(ci) == -1)
        log("dberror: while adding channels. continuing");
    }

    exit(1);
*/

/* end: temporary code */

    }
    log("Databases loaded");

    /* Connect to the remote server */
    servsock = conn(RemoteServer, RemotePort, LocalHost, LocalPort);
    if (servsock < 0)
	fatal_perror("Can't connect to server");
    send_server();
    sgets2(inbuf, sizeof(inbuf), servsock);
    if (strnicmp(inbuf, "ERROR", 5) == 0) {
	/* Close server socket first to stop wallops, since the other
	 * server doesn't want to listen to us anyway */
	disconn(servsock);
	servsock = -1;
	fatal("Remote server returned: %s", inbuf);
    }

    /* Announce a logfile error if there was one */
    if (openlog_failed) {
	wallops(NULL, "Warning: couldn't open logfile: %s",
		strerror(openlog_errno));
    }

    /* Bring in our pseudo-clients */
    introduce_user(NULL);

    /* Success! */
    return 0;
}