Пример #1
0
TEST(ConnectionPoolTest, Limit) {
  log4cpp::Priority::PriorityLevel level = log4cpp::Priority::ERROR;
  log4cpp::Category& log = logging_init(level);

  ConnectionPool *pool = new ConnectionPool(&log, 200);
  ASSERT_EQ(pool->GetLimit(), 200);
}
Пример #2
0
/*------------------------------------------------- main -----
  |  Function main
  |
  |  Purpose:  Reads input from STDIN, iterates over it and passes
  |            it to the printOctal function.
  |
  |  Parameters: argc (IN) -- Doesn't really do anything with this
  |              argv (IN) -- Doesn't really do anything with this.
  |                
  |
  |  Returns:  Only success
  *-------------------------------------------------------------------*/
int main(int argc, char ** argv) {
  context = logging_init("prog03p2");

  unsigned int data;
  int status;
  int section_index = -1;
  
  status = scanf("%o", &data);
  while (status > 0) {
      section_index++;
      if (section_index % 9 == 0) {
          status = scanf(OCTAL_FMT, &data);
          continue;
      }

      unsigned int next;
      
      // Check for more bytes in the stream
      if ((status = scanf(OCTAL_FMT, &next)) > 0) { 
          // Handle data here
          printOctal(data);
      }
      else {
          // data is just a length. Do nothing.
          debug("Found EOF");
      }
      
      // Copy next over data
      data = next;
  }
  
  logging_dest(context);
  return EXIT_SUCCESS;
}
Пример #3
0
int main()
{
    pic_init();
    logging_init();
    button_init();
    bumper_init();
    pwm_init();
    motor_timer_init();
    button_timer_init();
    sound_config_timer_init();

    //put_str_ln("Initialising DMA...");
    //init_DMA();

    //put_str_ln("Initialising ADC...");
    init_ADC();

    // setup des interrupts
    INTCONSET = _INTCON_MVEC_MASK;
    __builtin_enable_interrupts();

    if (VERBOSE_PIC_STATUS)
        put_str_ln("Ready.");

    while (1)
    {
        WDTCONbits.WDTCLR = 1;  // ecrire un 1 dans ce bit force la reinitialisation du watchdog
    }
}
Пример #4
0
/*------------------------------------------------- main -----
  |  Function main
  |
  |  Purpose:  Reads input from STDIN using getchar(), iterates over 
  |            each character and determines whether the character
  |            denotes the end of a sentence or word. After reaching
  |            EOF, prints output of flesch kincaid algorithm results
  |            and exits.
  |       
  |
  |  Parameters: argc (IN) -- number of arguments
  |              argv (IN) -- Expects the program name, image file, and triples
  |                
  |
  |  Returns:  Only success
  *-------------------------------------------------------------------*/
int main(int argc, char ** argv) {
    context = logging_init("prog08");
    
    if (argc < 5) {
        error("Incorrect number of arguments. Need a file name and at least one triple");
        usage(*argv);
        exit(EXIT_FAILURE);
    }

    if ((argc - 2) % 3) {
        error("Incorrect number of arguments. Triples have 3 values hence the name");
        usage(*argv);
        exit(EXIT_FAILURE);
    }
    
    char * image_file_name = chararr_get(argv, 1);
    FILE * image_file = fopen(image_file_name, "r");
    Image * image = image_file_init(image_file);

    printf("Original Image:\n\n");
    image_print(image);

    int changed = each_triple(argc, argv, image, image_fill);

    printf("A total of %d pixels were changed\n", changed);

    fclose(image_file);
    free(image_file_name);
    image_free(image);
    logging_dest(context);
    return EXIT_SUCCESS;
}
Пример #5
0
TEST(ConnectionPoolTest, Available) {
  log4cpp::Priority::PriorityLevel level = log4cpp::Priority::ERROR;
  log4cpp::Category& log = logging_init(level);

  ConnectionPool *pool = new ConnectionPool(&log);
  ASSERT_EQ(pool->GetLimit(), 100);
  ASSERT_EQ(pool->GetAvailable(), 0);

  int fd = open("/dev/null", O_APPEND);
  if (fd == -1) {
    log.error("Open failed: %s", strerror(errno));
    ASSERT_NE(fd, -1);
  }

  connection *conn = pool->Checkout(fd);

  ASSERT_EQ(pool->GetAvailable(), 0);

  
  int result = pool->Return(conn);
  ASSERT_EQ(result, 0);

  int available = pool->GetAvailable();
  log.warn("asfasfdasf");

  ASSERT_EQ(available, 1);
};
Пример #6
0
int main(int argc, char ** argv) {
  context = logging_init("prog02p3");
  unsigned int limit = 0;
  int status = scanf("%d", &limit);
  
  logging_dest(context);
  return EXIT_SUCCESS;
}
Пример #7
0
/*------------------------------------------------- main -----
  |  Function main
  |
  |  Purpose:  Reads input from STDIN using getchar(), iterates over 
  |            each character and determines whether the character
  |            denotes the end of a sentence or word. After reaching
  |            EOF, prints output of flesch kincaid algorithm results
  |            and exits.
  |       
  |
  |  Parameters: argc (IN) -- Doesn't really do anything with this
  |              argv (IN) -- Doesn't really do anything with this.
  |                
  |
  |  Returns:  Only success
  *-------------------------------------------------------------------*/
int main(int argc, char ** argv) {
  context = logging_init("prog07");

  int word_cnt = 0;
  int sent_cnt = 0;
  int syll_cnt = 0;
  char buffer[MAX_BUFFER];
  buffer[0] = '\0';
  debug("Does this work");
  char c;
  boolean eos = false;
  while ((c = getchar()) != EOF) {
      if (iseos(c)) {
          eos = true;
          sent_cnt++;
      }

      if (iseow(c) || eos) {
          // reset the buffer, this is a word
          if (strlen(buffer) > 0) {
              int syllcnt = 0;
              syllcnt = syll_count(buffer);
              debug("Counted %d syllables for %s\n", syllcnt, buffer);
              word_cnt++;
              syll_cnt++;
          }
          buffer[0] = '\0';
      }
      else {
          // Keep reading the buffer
          concat(buffer, c);
      }
  }

  if (strlen(buffer) > 0) {
      int syllcnt = 0;
      syllcnt = syll_count(buffer);
      debug("Counted %d syllables for %s\n", syllcnt, buffer);
      word_cnt++;
      syll_cnt++;
  }

  // Never got the last end of sentence character
  if (!eos) {
      sent_cnt++;
  }
  
  debug("mspw = %.2f", mspw(syll_cnt, word_cnt)); 
  debug("mwps = %.2f", mwps(word_cnt, sent_cnt));
  printf("%d sentences\n", sent_cnt);
  printf("%d words\n", word_cnt);
  printf("%d syllables\n", syll_cnt);
  printf("%.2f is the text’s grade level\n", 
         0.39 * mwps(word_cnt, sent_cnt) + 11.8 * mspw(syll_cnt, word_cnt) - 15.5);
  
  logging_dest(context);
  return EXIT_SUCCESS;
}
Пример #8
0
int main(__unused int argc, __unused char *argv[])
{
    logging_init(argv[0], LOG_DEBUG, 1);
    Suite *s = hdf5_suite();
    SRunner *sr = srunner_create(s);
    srunner_run_all(sr, CK_NORMAL);
    int n_failed = srunner_ntests_failed(sr);
    srunner_free(sr);
    unlink(H5FILE);
    return n_failed == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
Пример #9
0
int logging(struct soap *soap, struct soap_plugin *p, void *arg)
{ p->id = logging_id;
  p->data = (void*)malloc(sizeof(struct logging_data));
  p->fdelete = logging_delete;
  if (p->data)
    if (logging_init(soap, (struct logging_data*)p->data))
    { free(p->data); /* error: could not init */
      return SOAP_EOM; /* return error */
    }
  return SOAP_OK;
}
Пример #10
0
int
main (int argc, char **argv)
{
        char *path = NULL;
        dev_t dev = -1;
        int frmdir = 0;
        int timeout = 30;
        int f;

        while ((f = getopt (argc, argv, "d:rt:")) != -1) {
                switch (f) {
                case 'p':
                        path = optarg;
                        break;
                case 'd':
                        dev = strtoll (optarg, NULL, 10);
                        break;
                case 't':
                        timeout = atoi (optarg);
                        break;
                case 'r':
                        frmdir = 1;
                        break;
                default:
                        usage ();
                        break;
                }
        }

        argc -= optind;
        argv += optind;

        if (argc != 1)
                usage ();

        path = argv[0];

        if (logging_init () != 0)
                exit (EXIT_FAILURE);

        if (sanity_check (path, &dev) != 0)
                exit (EXIT_FAILURE);

        if (daemon (0, 0) != 0)
                exit (EXIT_FAILURE);

        if (umountd_async (path, dev, frmdir, timeout) != 0)
                exit (EXIT_FAILURE);

        return EXIT_SUCCESS;
}
Пример #11
0
int main(int argc, char **argv) {
  logging_init("cli.log");

  void *ctx = zmq_init(1);
  void *socket = zmq_socket(ctx, ZMQ_DEALER);

  int rc = zmq_connect(socket, "tcp://127.0.0.1:9999");
  // use below for when this is a router socket
  // int rc = zmq_bind(socket, "tcp://127.0.0.1:9999");
  assert(rc == 0);

  zmq_msg_t msg;
  size_t msg_size = sizeof(int);
  int x = 99;

  boost::posix_time::ptime start_ptime(
      boost::posix_time::microsec_clock::local_time());
  sleep(3);

#ifdef ZC
  // with zerocopy
  rc = zmq_msg_init_data(&msg, (void *)&x, msg_size, NULL, NULL);
  assert(rc == 0);
#else
  // without zerocopy
  pan::log_DEBUG("NOT using zerocopy");
  rc = zmq_msg_init_size(&msg, msg_size);
  assert(rc == 0);
  memcpy(zmq_msg_data(&msg), (void *)&x, msg_size);
#endif

  // use below line for router socket
  // must be the same identity as the receiving socket has set
  // s_sendmore(socket, "A");
  rc = zmq_send(socket, &msg, 0);
  assert(rc == 0);
  zmq_msg_close(&msg);
  pan::log_DEBUG("Receiving message");
  zmq_msg_init(&msg);
  rc = zmq_recv(socket, &msg, 0);
  pan::log_DEBUG("Received msg: ", pan::integer(*(int *)zmq_msg_data(&msg)));
  zmq_close(&msg);

  boost::posix_time::ptime stop_ptime(
      boost::posix_time::microsec_clock::local_time());
  boost::posix_time::time_duration ptime_duration(stop_ptime - start_ptime);
  std::cerr << ptime_duration << "\n";
  zmq_close(socket);
  zmq_term(ctx);
}
Пример #12
0
/*------------------------------------------------- main -----
  |  Function main
  |
  |  Purpose:  Reads input from STDIN using getchar(), iterates over 
  |            each character and determines whether the character
  |            denotes the end of a sentence or word. After reaching
  |            EOF, prints output of flesch kincaid algorithm results
  |            and exits.
  |       
  |
  |  Parameters: argc (IN) -- number of arguments
  |              argv (IN) -- Expects the program name, image file, and triples
  |                
  |
  |  Returns:  Only success
  *-------------------------------------------------------------------*/
int main(int argc, char ** argv) {
    context = logging_init("prog10");

    if (argc < 3) {
        error("Incorrect number of arguments. Need number of worms and size.");
        usage(*argv);
        exit(EXIT_FAILURE);
    }

    int worm_cnt = atoi(argv[1]);
    int worm_size = atoi(argv[2]);
    Worm worms[worm_cnt];
    
    int rows, cols;
    initscr();                   /* set up ncurses */
    refresh();                /* clear screen */

    getmaxyx(stdscr, rows, cols);
    
    debug("Got dimentions %d,%d", rows, cols);

    debug("Have %d rows ", rows);
    debug("Worm count is %d ", worm_cnt);
    debug("Worm size is %d ", worm_size);

    Grid grid = grid_new(cols, rows);
    time_t now = time(NULL);
    srand(localtime(&now)->tm_sec); // Set the seed for random numbers to the current second of the minute

    int i;
    for (i = 0; i < worm_cnt; i++) {
        info("Printing worm %d", i);
        worms[i] = worm_new(grid, worm_size);
    }

    /*
      while(1) {
        for (i = 0; i < worm_cnt; i++) {
            worm_move(worms[i]);
        }        
        }*/


    // usleep(PAUSE*10);              /* wait for a bit */
    free(grid);                 // Free the grid!!!!
    
    endwin();
    logging_dest(context);
    return EXIT_SUCCESS;
}
Пример #13
0
int main(void) {
  logging_init();
  if (inet_aton(IP_STRING, &IP) == -1) {
    lput_str("[*] failed to parse IP string\r\n");
    return 0;
  }
  lput_str("[*] my ip: 0x");
  lput16_hex((IP >> 16) & 0xffff);
  lput16_hex(IP & 0xffff);
  lput_str("\r\n[*] net initialized;\r\n");
  ether_set_addr(MAC_ADDRESS);
  ether_loop(&read_packet);
  return 0;
}
Пример #14
0
int
main (int argc, char *argv[])
{
    glusterfs_ctx_t  *ctx = NULL;
    int               ret = -1;

    ret = glusterfs_globals_init ();
    if (ret)
        return ret;

    ctx = glusterfs_ctx_get ();
    if (!ctx)
        return ENOMEM;

    ret = glusterfs_ctx_defaults_init (ctx);
    if (ret)
        goto out;

    ret = parse_cmdline (argc, argv, ctx);
    if (ret)
        goto out;

    ret = logging_init (ctx);
    if (ret)
        goto out;

    gf_proc_dump_init();

    ret = create_fuse_mount (ctx);
    if (ret)
        goto out;

    ret = daemonize (ctx);
    if (ret)
        goto out;

    ret = glusterfs_volumes_init (ctx);
    if (ret)
        goto out;

    ret = event_dispatch (ctx->event_pool);

out:
//        glusterfs_ctx_destroy (ctx);

    return ret;
}
Пример #15
0
int main(int argc, char *argv[])
{
	const char *node = NULL;
	int i;
	int export = 0;
	int fd;
	int rc = 0;
	int result;

	logging_init("cdrom_id");

	for (i = 1 ; i < argc; i++) {
		char *arg = argv[i];

		if (strcmp(arg, "--export") == 0) {
			export = 1;
		} else
Пример #16
0
/*
 * blissc_init
 *
 * Initializes the driver, setting up the context block.
 * This should be first routine called by a driver program.
 */
blissc_driverctx_t
blissc_init (jmp_buf retenv)
{
    blissc_driverctx_t ctx;

    ctx = malloc(sizeof(struct blissc_driverctx_s));
    if (ctx == 0) return 0;
    memset(ctx, 0, sizeof(struct blissc_driverctx_s));
    ctx->strctx = strings_init();
    ctx->logctx = logging_init(retenv);
    ctx->fioctx = fileio_init(ctx->logctx);
    ctx->outtype = BLISS_K_OUTPUT_OBJECT;
    ctx->optlevel = -1; // unset

    return ctx;

} /* blissc_init */
Пример #17
0
 /* plugin registry function, invoked by soap_register_plugin */
 int logging(struct soap *soap, struct soap_plugin *p, void *arg)
 {
     p->id = logging_id;
     /* create local plugin data */
     p->data = (void*)SOAP_MALLOC(soap, sizeof(struct logging_data));
     /* register the destructor */
     p->fdelete = logging_delete;
     /* if OK then initialize */
     if (p->data)
     {
         if (logging_init(soap, (struct logging_data*)p->data))
         {
             SOAP_FREE(soap, p->data); /* error: could not init */
             return SOAP_EOM; /* return error */
         }
     }
     return SOAP_OK;
 }
int
main(int argc, char **argv)
{
	logging_init("test_config_server.log");
   
    ::testing::InitGoogleTest(&argc, argv);
    GOOGLE_PROTOBUF_VERIFY_VERSION; 

	ctx = zmq_init(1);
	boost::posix_time::ptime start_ptime(boost::posix_time::microsec_clock::local_time()); 
    
    int result = RUN_ALL_TESTS();
   	boost::posix_time::ptime stop_ptime(boost::posix_time::microsec_clock::local_time()); 
	boost::posix_time::time_duration ptime_duration(stop_ptime - start_ptime); 
	std::cerr << ptime_duration << "\n";
	zmq_term(ctx);

    return result;
}
Пример #19
0
int main(int argc, char *argv[], char *envp[])
{
	char dirname[NAME_SIZE];
	const char *devname;
	const char *my_devname;
	const char *subsystem;
	int fd;

	devname = getenv("DEVNAME");
	if (devname == NULL)
		exit(0);
	/*
	 * Hack, we are assuming that the device nodes are in /dev,
	 * if not, this will not work, but you should be using the
	 * RUN= rule anyway...
	 */
	my_devname = strstr(devname, "/dev/");
	if (my_devname != NULL)
		my_devname = &my_devname[5];
	else
		my_devname = devname;

	subsystem = argv[1];
	logging_init("udev_run_devd");

	fd = open("/dev/null", O_RDWR);
	if (fd >= 0) {
		dup2(fd, STDOUT_FILENO);
		dup2(fd, STDIN_FILENO);
		dup2(fd, STDERR_FILENO);
		close(fd);
	}
	dbg("running dev.d directory");

	sprintf(dirname, "/etc/dev.d/%s", my_devname);
	run_directory(dirname, ".dev", subsystem);
	sprintf(dirname, "/etc/dev.d/%s", subsystem);
	run_directory(dirname, ".dev", subsystem);
	run_directory("/etc/dev.d/default", ".dev", subsystem);

	exit(0);
}
Пример #20
0
int main(int argc, char *argv[])
{
	struct sigaction sa;

	xmlrpc_env env;

	if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
		crit("could not ignore SIGPIPE");

	sa.sa_handler = sighandler;
	sa.sa_flags = 0;
	sigemptyset (&sa.sa_mask);
	sigaction (SIGHUP, &sa, NULL);
	sigaction (SIGALRM, &sa, NULL);
	sigaction (SIGCHLD, &sa, NULL);

	set_progname(argv[0]);
	parse_cmdline(argc, argv);
	logging_init();
#ifdef HAVE_LIBPCAP
	fg_pcap_init();
#endif /* HAVE_LIBPCAP */
	if (log_type == LOGTYPE_SYSLOG) {
		/* Need to call daemon() before creating the thread because
		 * it internally calls fork() which does not copy threads. */
		if (daemon(0, 0) == -1)
			crit("daemon() failed");
		logging_log(LOG_NOTICE, "flowgrindd daemonized");
	}

	if (cpu >= 0)
		set_affinity(cpu);

	create_daemon_thread();

	xmlrpc_env_init(&env);

	run_rpc_server(&env, port);

	critx("control should never reach end of main()");
}
Пример #21
0
/**
 * Init function called by the Contiki netstack
 */
static void dtn_network_init(void) 
{
	/* Set up log domains */
	logging_init();
	logging_domain_level_set(LOGD_DTN, LOG_NET, LOGLEVEL);
	logging_domain_level_set(LOGD_DTN, LOG_BUNDLE, LOGLEVEL);
	logging_domain_level_set(LOGD_DTN, LOG_ROUTE, LOGLEVEL);
	logging_domain_level_set(LOGD_DTN, LOG_STORE, LOGLEVEL);
	logging_domain_level_set(LOGD_DTN, LOG_SDNV, LOGLEVEL);
	logging_domain_level_set(LOGD_DTN, LOG_SLOTS, LOGLEVEL);
	logging_domain_level_set(LOGD_DTN, LOG_AGENT, LOGLEVEL);
	logging_domain_level_set(LOGD_DTN, LOG_CL, LOGLEVEL);
	logging_domain_level_set(LOGD_DTN, LOG_DISCOVERY, LOGLEVEL);

	/* Clear the packet buffer */
	packetbuf_clear();

	/* Initialize logging */
	LOG(LOGD_DTN, LOG_NET, LOGL_DBG, "init");

	/* Start the agent */
	agent_init();
}
Пример #22
0
int main(int argc, char **argv)
{
	struct drcom_handle *h;
	int daemon = 1;
	int i;

	if(argc > 2)
		usage();

	for (i = 1 ; i < argc; i++) {
		char *arg = argv[i];
		if (strcmp(arg, "--nodaemon") == 0 || strcmp(arg, "-n") == 0) {
			printf("%s: log to stderr.\n", argv[0]);
			daemon = 0;
		}
	}

	/* Initialize the handle for the lifetime of the daemon */
	h = drcom_create_handle();
	if(drcom_init(h)<0){
		logerr("conf file err\n");
		exit(-1);
	}

	load_kernel_module();

	if (daemon)
		daemonize();

	logging_init("drcomd", daemon);

	drcomd_daemon(h);

	logging_close();

	return 0;
}
Пример #23
0
static void fuse_initialised() {
	logging_init();
	
	musicfs_configuration_t *configuration = configuration_get();
	
	logging_set_destination(configuration->logfile);
	logging_set_level(configuration->log_level);
	logging_set_timestamp_printed(configuration->log_timestamp_use);
	
	http_init();
	providers_init();
	
	// Register built-in providers
	skreemr_init();
	
	// Set default search provider
	provider_t *provider = providers_find(configuration->provider_name);
	if(!provider)
		logging_log(MODULE, LOGGING_LEVEL_CRITICAL, "'%s' is not a known search provider.", configuration->provider_name);
	else searcher_provider_set(provider);
	
	logging_log(MODULE, LOGGING_LEVEL_INFO, "fuse_initialised()");
	downloader_init();
}
/*********************************************************************
* @brief        Function used to initialize various system components
*               Each component is initialized using a proper API
*
* @param[in]    NA
*
* @retval       NA
*
* @note         NA
*
* @end
*********************************************************************/
void system_init()
{
 
  /* Initialize platform */
  VENDOR_PLATFORM_INIT(); 

  /*Initialize logging, Not handling error as openlog() does not return anything*/ 
  logging_init();

  /*Initialize Module manager*/ 
  if (modulemgr_init() != BVIEW_STATUS_SUCCESS)
  {
    LOG_POST (BVIEW_LOG_CRITICAL, "Failed to initialize Module Manager\r\n");
  }  
  /*Initialize south-bound plugin*/ 
  if (sb_redirector_init() != BVIEW_STATUS_SUCCESS)
  {
    LOG_POST (BVIEW_LOG_CRITICAL, "Failed to initialize south-bound plugin\r\n");
  }  
  /*Initialize south-bound BST plugin*/ 
  if (sbplugin_common_init() != BVIEW_STATUS_SUCCESS)
  {
    LOG_POST (BVIEW_LOG_CRITICAL, "Failed to initialize south-bound BST plugin r\n");
  }  
  /*Initialize BST application*/ 
  if (bst_main() != BVIEW_STATUS_SUCCESS)
  {
    LOG_POST (BVIEW_LOG_CRITICAL, "Failed to initialize BST application\r\n");
  }  
  /*Initialize REST*/ 
  if (rest_init() != BVIEW_STATUS_SUCCESS)
  {
    LOG_POST (BVIEW_LOG_CRITICAL, "Failed to initialize REST \n All components must be De-initialized\r\n");
    system_deinit();
  }  
} 
Пример #25
0
int main(int argc, char *argv[], char *envp[])
{
	char dirname[NAME_SIZE];
	const char *subsystem;
	int fd;

	subsystem = argv[1];
	logging_init("udev_run_hotplugd");

	fd = open("/dev/null", O_RDWR);
	if (fd >= 0) {
		dup2(fd, STDOUT_FILENO);
		dup2(fd, STDIN_FILENO);
		dup2(fd, STDERR_FILENO);
		close(fd);
	}

	dbg("running hotplug.d directory");

	sprintf(dirname, "/etc/hotplug.d/%s", subsystem);
	run_directory(dirname, ".hotplug", subsystem);
	run_directory("/etc/hotplug.d/default", ".hotplug", subsystem);
	exit(0);
}
Пример #26
0
Файл: main.c Проект: neeohw/spop
/**********************
 *** Initialization ***
 **********************/
int main(int argc, char** argv) {
    gboolean daemon_mode = TRUE;
    const char* username;
    const char* password;
    GMainLoop* main_loop;

    /* Parse command line options */
    int opt;
    while ((opt = getopt(argc, argv, "dfhv")) != -1) {
        switch (opt) {
        case 'd':
            debug_mode = TRUE;
        case 'v':
            verbose_mode = TRUE;
        case 'f':
            daemon_mode = FALSE; break;
        default:
            printf("Usage: spopd [options]\n"
                   "Options:\n"
                   "  -d        debug mode (implies -f and -v)\n"
                   "  -f        run in foreground (default: fork to background)\n"
                   "  -v        verbose mode (implies -f)\n"
                   "  -h        display this message\n");
            return 0;
        }
    }

    g_set_application_name("spop " SPOP_VERSION);
    g_set_prgname("spop");

    /* PulseAudio properties */
    g_setenv("PULSE_PROP_application.name", "spop " SPOP_VERSION, TRUE);
    g_setenv("PULSE_PROP_media.role", "music", TRUE);
    //g_setenv("PULSE_PROP_application.icon_name", "music", TRUE);

    printf("%s\n", copyright_notice);

    /* Log handler */
    logging_init();

    if (!daemon_mode) {
        /* Stay in foreground: do everything here */
        if (debug_mode)
            g_info("Running in debug mode");
    }
    else {
        /* Run in daemon mode: fork to background */
        printf("Switching to daemon mode...\n");
        if (daemon(0, 0) != 0)
            g_error("Error while forking process: %s", g_strerror(errno));

    }

    /* Init essential stuff */
    main_loop = g_main_loop_new(NULL, FALSE);
    exit_handler_init();

    /* Read username and password */
    username = config_get_string("spotify_username");
    password = config_get_string("spotify_password");

    /* Init plugins */
    plugins_init();

    /* Init login */
    session_init();
    session_login(username, password);

    /* Init various subsystems */
    interface_init();

    /* Event loop */
    g_main_loop_run(main_loop);

    return 0;
}
Пример #27
0
int 
main()
{
	zmq::context_t ctx(1);
	logging_init("rep.log");
	zmq::socket_t recv_sock(ctx, ZMQ_DEALER);

	int zero = 0;
	recv_sock.setsockopt(ZMQ_LINGER, &zero, sizeof(zero)); 
	// use below when "client" is a router
	//recv_sock.setsockopt(ZMQ_IDENTITY, "A",  strlen("A"));
	
	recv_sock.bind("tcp://127.0.0.1:9999");
	// use below when "client" is a router
	//recv_sock.connect("tcp://127.0.0.1:9999");

			
	while(1) {
		zmq::message_t m1;
		zmq::message_t m2;
		zmq::message_t m3;
		//zmq::message_t msg;
		int64_t more = 0;
		size_t more_size = sizeof(more);	
		bool rc;

		pan::log_DEBUG("---------------->");
		do {
			rc = recv_sock.recv(&m1, 0);
			rc = recv_sock.recv(&m2, 0);
			assert(rc);
			size_t msg_size = m2.size();
			pan::log_DEBUG("Received msg size: ", pan::integer(msg_size));
			recv_sock.getsockopt(ZMQ_RCVMORE, &more, &more_size);
		} while (more);	

			m3.rebuild(4);
			int s = 9999; 
			memcpy(m3.data(), &s, sizeof(int));
		//pan::log_DEBUG("Sending msg: ", pan::integer(*(int*)m1.data()));
		pan::log_DEBUG("Sending msg: ", pan::integer(*(int*)m3.data()));
		//recv_sock.send(m1, ZMQ_SNDMORE);
		recv_sock.send(m3, 0);
		pan::log_DEBUG("<----------------");
/*
		pan::log_DEBUG("---------------->");
		do {
			rc = recv_sock.recv(&msg, 0);
			assert(rc);
			size_t msg_size = msg.size();
			char* s = new char[msg_size];
			memset(s, 0, msg_size);
			memcpy(s, msg.data(), msg_size);
			pan::log_DEBUG("Received msg size: ", pan::integer(msg_size));
			recv_sock.getsockopt(ZMQ_RCVMORE, &more, &more_size);
		} while (more);	
		recv_sock.send(msg, 0);
		pan::log_DEBUG("<----------------");
*/
	}	
		
}
Пример #28
0
static void real_main2 (int argc, char **argv)
{
#if defined (NATMEM_OFFSET) && defined( _WIN32 ) && !defined( NO_WIN32_EXCEPTION_HANDLER )
    extern int EvalException ( LPEXCEPTION_POINTERS blah, int n_except );
    __try
#endif
    {

    if (! graphics_setup ()) {
	exit (1);
    }

    if (restart_config[0]) {
#ifdef FILESYS
	free_mountinfo (currprefs.mountinfo);
        currprefs.mountinfo = alloc_mountinfo ();
#endif
	default_prefs (&currprefs, 0);
	fix_options ();
    }

#ifdef NATMEM_OFFSET
    init_shm ();
#endif

#ifdef FILESYS
    rtarea_init ();
    hardfile_install ();
#endif

    if (restart_config[0])
        parse_cmdline_and_init_file (argc, argv);
    else
	currprefs = changed_prefs;

    uae_inithrtimer ();
    sleep_test ();

    machdep_init ();

    if (! setup_sound ()) {
	write_log ("Sound driver unavailable: Sound output disabled\n");
	currprefs.produce_sound = 0;
    }
    inputdevice_init ();

    changed_prefs = currprefs;
    no_gui = ! currprefs.start_gui;

    if (restart_program == 2)
	no_gui = 1;
    else if (restart_program == 3)
	no_gui = 0;

    if (! no_gui) {
	int err = gui_init ();
	struct uaedev_mount_info *mi = currprefs.mountinfo;
	currprefs = changed_prefs;
	currprefs.mountinfo = mi;
	if (err == -1) {
	    write_log ("Failed to initialize the GUI\n");
	    if (restart_program == 3) {
	       restart_program = 0;
	       return;
	    }
	} else if (err == -2) {
	    restart_program = 0;
	    return;
	}
    }

    restart_program = 0;

#ifdef JIT
    if (!(( currprefs.cpu_level >= 2 ) && ( currprefs.address_space_24 == 0 ) && ( currprefs.cachesize )))
	canbang = 0;
#endif

#ifdef _WIN32
    logging_init(); /* Yes, we call this twice - the first case handles when the user has loaded
		       a config using the cmd-line.  This case handles loads through the GUI. */
#endif
    fix_options ();
    changed_prefs = currprefs;

#ifdef SAVESTATE
    savestate_init ();
#endif
#ifdef SCSIEMU
    scsidev_install ();
#endif
#ifdef AUTOCONFIG
    /* Install resident module to get 8MB chipmem, if requested */
    rtarea_setup ();
#endif

    keybuf_init (); /* Must come after init_joystick */

#ifdef AUTOCONFIG
    expansion_init ();
#endif
    memory_init ();
    memory_reset ();

#ifdef FILESYS
    filesys_install ();
#endif
#ifdef AUTOCONFIG
    bsdlib_install ();
    emulib_install ();
    uaeexe_install ();
    native2amiga_install ();
#endif

    if (custom_init ()) { /* Must come after memory_init */
#ifdef SERIAL_PORT
	serial_init ();
#endif
	DISK_init ();

	reset_frame_rate_hack ();
	init_m68k(); /* must come after reset_frame_rate_hack (); */

	gui_update ();

	if (graphics_init ()) {

#ifdef DEBUGGER
	    setup_brkhandler ();

	    if (currprefs.start_debugger && debuggable ())
		activate_debugger ();
#endif

#ifdef WIN32
#ifdef FILESYS
	    filesys_init (); /* New function, to do 'add_filesys_unit()' calls at start-up */
#endif
#endif
	    if (sound_available && currprefs.produce_sound > 1 && ! init_audio ()) {
		write_log ("Sound driver unavailable: Sound output disabled\n");
		currprefs.produce_sound = 0;
	    }

	    start_program ();
	}
    }

    }
#if defined (NATMEM_OFFSET) && defined( _WIN32 ) && !defined( NO_WIN32_EXCEPTION_HANDLER )
    __except( EvalException( GetExceptionInformation(), GetExceptionCode() ) )
    {
	// EvalException does the good stuff...
    }
#endif
}
Пример #29
0
int main(void) {
  logging_init();
  lput_str("[*] packet_dump initialized; waiting for packet\r\n");
  ether_loop(&get_packet);
  return 0;
}
Пример #30
0
void main(uint32_t magic, struct multiboot_info *mbi, 
          uintptr_t esp, uintptr_t stack_end)
{
    stack_start = esp;
    stack_size = stack_end - stack_start;

    vga_driver = vga_init();
    com_driver = serial_init();
    logging_init(vga_driver, com_driver);
        
    assert(magic == MULTIBOOT_MAGIC);
    assert(mbi->flags & MULTIBOOT_LOADER);
    kprintf(INFO, "\033\012Toutatis kernel booting from %s\033\017\n", 
            (char *)(mbi->boot_loader_name + (uint32_t)&kernel_voffset));

    arch_init();

    initrd_init(mbi); 

    assert(mbi->flags & MULTIBOOT_MEMINFO);
    paging_init((mbi->mem_lower + mbi->mem_upper) * 1024);
    paging_mark_reserved((uint32_t)mbi - (uint32_t)&kernel_voffset);

    assert(mbi->flags & MULTIBOOT_MMAP);
    for (mmap_entry_t *mmap = (mmap_entry_t *)(mbi->mmap_addr + (uint32_t)&kernel_voffset);
        (uint32_t)mmap < mbi->mmap_addr + (uint32_t)&kernel_voffset + mbi->mmap_length;
        mmap = (mmap_entry_t *)((uint32_t)mmap + mmap->size + sizeof(mmap->size))) {
        if (mmap->type == 2) {
            for (uint64_t i = 0; i < mmap->length; i += FRAME_SIZE) {
                paging_mark_reserved((mmap->addr + i) & 0xfffff000);
            }
        }
    }
    paging_finalize();

    void *p1 = kmalloc(8);
    void *p2 = kmalloc(8);
    *((char *)p1) = 'a';
    kprintf(INFO, "p1 @ 0x%x\n", (uint32_t)p1);
    kprintf(INFO, "p2 @ 0x%x\n", (uint32_t)p2);
    kfree(p2);
    kfree(p1);
    void *p3 = kmalloc(16);
    kprintf(INFO, "p3 @ 0x%x\n", (uint32_t)p3);
    uintptr_t phys;
    void *p4 = kmalloc_ap(0x1a0000, &phys);
    memset(p4, 0, 0x1a0000);
    *((char *)p4) = 'z';
    kprintf(INFO, "p4 @ 0x%x phys = %x\n", (uint32_t)p4, phys);
    void *p5 = kmalloc(0x02);
    kprintf(INFO, "p5 @ 0x%x\n", (uint32_t)p5);
    kfree(p5);
    kfree(p4);
    kfree(p3);

    print_mmap(mbi);

    syscall_init();

    scheduling_init();

    keyboard_init();

    process_t *proc1 = create_process("Process 1", 1);
    process_t *proc2 = create_process("Process 2", 1);
    process_t *proc3 = create_process("Process 3", 1);

    process_t *procs[] = { proc1, proc2, proc3 };
            
    unsigned int k = 0;
    unsigned int off = 0;
    for (k = 0; k < 10; ++k) {
        if (!create_thread(procs[k % 3], func2, (void *)(off + 80*2), 1, 0, 0)) {
            kprintf(INFO, "Oups\n");
            stop();
        }
        if (!create_thread(procs[k % 3], func1, (void *)k, 1, 1, 0)) {
            kprintf(INFO, "Oups\n");
            stop();
        }
        off += 2;
    }

    //create_thread(proc1, func3, (void *)0, 1, 1, 1);

    k = 0;
    unsigned int i = 0;
    off = 0;
    for (;;) {
        uint16_t *video = (uint16_t *)(0xc00b8000 + 80);
        *video = (uint16_t)alph[i++ % sizeof(alph)] | 0x0f00;
        
        if (k % 1 == 0) {
            //set_pos(0, 23);
            //vga_print_dec(k);
            //kprintf(INFO, "mem used: %6x num threads:%3d   \n", mem_used(kheap), get_num_threads());
        }
        /*
        if (!create_thread(proc1, func2, (void *)(off + 80*2), 1, 0, 0)) {
            kprintf(INFO, "Oups\n");
            break;
        }
        off += 2;
        off %= (60 * (25-2));
        */
        char c = keyboard_lastchar();
        if (c == 'u') {
            create_thread(proc1, func1, (void *)5, 1, 1, 0);
        } else if (c == 'k') {
            create_thread(proc1, func2, (void *)off, 1, 0, 0);
            off += 2;
        }
        ++k;
    }

    serial_terminate();
    stop();
}