Esempio n. 1
0
std::string
impl::check_requirements(const atf::tests::vars_map& metadata,
                         const atf::tests::vars_map& config)
{
    std::string failure_reason = "";

    for (atf::tests::vars_map::const_iterator iter = metadata.begin();
         failure_reason.empty() && iter != metadata.end(); iter++) {
        const std::string& name = (*iter).first;
        const std::string& value = (*iter).second;
        INV(!value.empty()); // Enforced by application/X-atf-tp parser.

        if (name == "require.arch")
            failure_reason = check_arch(value);
        else if (name == "require.config")
            failure_reason = check_config(value, config);
        else if (name == "require.machine")
            failure_reason = check_machine(value);
        else if (name == "require.progs")
            failure_reason = check_progs(value);
        else if (name == "require.user")
            failure_reason = check_user(value, config);
        else {
            // Unknown require.* properties are forbidden by the
            // application/X-atf-tp parser.
            INV(failure_reason.find("require.") != 0);
        }
    }

    return failure_reason;
}
Esempio n. 2
0
/*****************************************************************************
	全サーボ設定
*****************************************************************************/
bool CGainer::SetServoAll(const std::vector<WORD> &data)
{
	check_config();

	int limit = 8;
	if ( m_config != 8 ) { return false; }

	std::string c("P");
	char buf[32];

	size_t n = data.size();
	if ( n > limit ) {
		n = limit;
	}

	for ( size_t i = 0 ; i < n ; ++i ) {
		sprintf(buf,"%02X",data[i]);
		c += buf;
	}

	int diff = limit - n;
	while ( diff > 0 ) {
		c += "00";
		--diff;
	}
	c += "*";

	return command_send(c).size() != 0;
}
Esempio n. 3
0
/*
 * main:
 * -----
 */
int main123(int argc, char **argv)
{
  time_t end_time;
  int raw = 0;
  int mono_from_stereo = 0;

  printf("Shine v1.08 19/06/03\n");

  time(&config.start_time);
  set_defaults();

  if (!parse_command(argc, argv, &raw, &mono_from_stereo))
    print_usage();

  wave_open(raw, mono_from_stereo); /* prints wave (input) configuration */

  check_config(); /* prints mpeg (output) configuration */

  printf("Encoding \"%s\" to \"%s\"\n", config.infile, config.outfile);

  L3_compress();

  wave_close();

  time(&end_time);
  end_time -= config.start_time;
  printf(" Finished in %2ld:%2ld:%2ld\n",
            end_time/3600,(end_time/60)%60,end_time%60);

  return 0;
}
Esempio n. 4
0
File: main.c Progetto: Glideh/jfrec
static AS3_Val init(void * self, AS3_Val args)
{
	void * ref;
	void * src;
	void * dest;
	
	AS3_ArrayValue(args, "AS3ValType, AS3ValType, AS3ValType", &ref, &src, &dest);
	
	flashErrorsRef = (AS3_Val)ref;
	
	config.wave.file	= funopen((void *)src, readByteArray, writeByteArray, seekByteArray, closeByteArray);
	config.wave.output	= funopen((void *)dest, readByteArray, writeByteArray, seekByteArray, closeByteArray);
	
	if (config.wave.file == NULL || config.wave.output == NULL) {
		ERROR("Unable to set bytes arrays");
	}
	
	wave_open();
	
	set_defaults();
    check_config();
		
	start_compress();
	
	return AS3_Int(1);
}
Esempio n. 5
0
bool CGainer::ScanLine(size_t row,BYTE data[GAINER_LED_MATRIX])
{
	check_config();

	if ( m_config != 7 ) { return false; }
	if ( row > GAINER_LED_MATRIX-1 ) { return false; }

	//最適化:前と同じなら実行しない
	if ( ScanLineCompare(data,m_LEDMatrixOutputs[row]) ) {
		return true;
	}

	std::string c = "a";
	size_t i;
	char buf[32];

	sprintf(buf,"%u",row);
	c += buf;

	for ( i = 0 ; i < GAINER_LED_MATRIX ; ++i ) {
		if ( data[i] > 15 ) {
			data[i] = 15;
		}
		sprintf(buf,"%01X",data[i]);
		c += buf;
	}
	c += "*";

	command_send(c,true);

	memcpy(m_LEDMatrixOutputs[row],data,sizeof(m_LEDMatrixOutputs[row]));

	return true;
}
Esempio n. 6
0
int load_config(const char *filename, config *conf)
{
    FILE* fp;
    char line[1024];

    memset(conf, 0, sizeof(config));

    /* Open config file */
    fp = fopen(filename, "r+");
    if (fp == NULL)
    {
        perror("Config file open failed!");
        return EXIT_FAILURE;
    }

    /* Read config file */
    while (fgets(line, 1024, fp))
    {
        if ( (parse_line(line, conf)) != EXIT_SUCCESS)
        {
            fprintf(stderr, "Config file structure is not appropriate");
            return EXIT_FAILURE;
        }
    } /* end while */

    fclose(fp);

    return check_config(*conf);
}
Esempio n. 7
0
	CRefresher::CRefresher(const char * rconfig_file)
	{		  
	   //by cm   
		config_error = false;	
		if( !rconfig.init(rconfig_file) )
		{
#ifdef _TEST
			cout << "config error" << endl
			     << "please check your config file" << endl;
#endif
			config_error = true;
		}
		else
		{	
			//compute file suffix:
			float tmp = log10((float(rconfig.max_timeout))/(float(rconfig.min_timeout))) / log10(float(rconfig.step));
			float suffix = tmp -(int)tmp;
			int file_num;
			if(suffix >= 0.5) //sometimes tmp == 4.9999....so have to do this
				file_num = 2 + (int)tmp;
			else
				file_num = 1 + (int)tmp;
	   
			filesuffix = new FileSuffix( file_num );
/*
			changelog = fopen("log.change","a");
			deletelog = fopen("log.delete","a");
			newlog = fopen("log.new","a");
*/
			config_changed = false;	
			if(check_config())
				config_changed = true;
			init();
		}
	}
Esempio n. 8
0
ret_code_t fs_store(fs_config_t const *       p_config,
                    uint32_t    const *       p_addr,
                    uint32_t    const * const p_data,
                    fs_length_t               length_words)
{
    if ((m_flags & FS_FLAG_INIT) == 0)
    {
        return NRF_ERROR_INVALID_STATE;
    }

    if (!check_config(p_config))
    {
        return NRF_ERROR_FORBIDDEN;
    }

    if (!is_word_aligned(p_addr))
    {
        return NRF_ERROR_INVALID_ADDR;
    }

    // Check that the erase operation is on pages owned by this user (configuration).
    if ((p_addr < p_config->p_start_addr) || ((p_addr + length_words) > p_config->p_end_addr))
    {
        return NRF_ERROR_INVALID_ADDR;
    }

    return cmd_enqueue(p_config, FS_OP_STORE, p_addr, p_data, length_words);
}
Esempio n. 9
0
void load_config(char * path)
{
	int i;
	char *p;

	//__android_log_print(ANDROID_LOG_DEBUG, "org.rin", "path in load_config: %s",path);

	jfile fd = jfopen(env_game_thread, path, JF_MODE_READ, NULL, 0);

	if(!fd)
	{
		init_config();
		return;
	}
	
	memset(&setting, 0, sizeof(setting));
	jfread(env_game_thread, fd, &setting, sizeof(setting));
	jfclose(env_game_thread, fd);

	tmpsetting = setting;
	memcpy(m_pal16[PAL_CUSTOM_LOCAL],setting.custom_palette, sizeof(short)*4*3);
	check_config();
	set_gb_type();
	set_speed(setting.speed);
	
}
Esempio n. 10
0
/*****************************************************************************
	全アナログ設定
*****************************************************************************/
bool CGainer::SetAnalogAll(const std::vector<WORD> &data)
{
	int limit = CONFIG[m_config][AOUT];
	if ( ! limit ) {
		return false;
	}

	check_config();

	std::string c("A");
	char buf[32];

	size_t n = data.size();
	if ( n > limit ) {
		n = limit;
	}

	for ( size_t i = 0 ; i < n ; ++i ) {
		sprintf(buf,"%02X",data[i]);
		c += buf;
	}

	int diff = limit - n;
	while ( diff > 0 ) {
		c += "00";
		--diff;
	}
	c += "*";

	return command_send(c).size() != 0;
}
Esempio n. 11
0
ret_code_t fs_erase(fs_config_t const *       p_config,
                    uint32_t          * const p_addr,
                    fs_length_t const         length_words)
{
    if ((m_flags & FS_FLAG_INIT) == 0)
    {
        return NRF_ERROR_INVALID_STATE;
    }

    if (!check_config(p_config))
    {
        return NRF_ERROR_FORBIDDEN;
    }

    /** Check that the address is aligned on a page boundary and the length to erase
     *  is a multiple of the page size. */
    if (((uint32_t)p_addr & (FS_PAGE_SIZE - 1)) ||
        (length_words     & (FS_PAGE_SIZE_WORDS - 1)))
    {
        return NRF_ERROR_INVALID_ADDR;
    }

    // Check that the erase operation is on pages owned by this user (configuration).
    if ((p_addr < p_config->p_start_addr) || ((p_addr + length_words) > p_config->p_end_addr))
    {
        return NRF_ERROR_INVALID_ADDR;
    }

    return cmd_enqueue(p_config, FS_OP_ERASE, p_addr, NULL, length_words);
}
Esempio n. 12
0
static void inotify_handler(int fd, short args, void *cbdata)
{
    struct {
        struct inotify_event ev;
        char filename_buffer[4096];
    } data;
    int sz;
    struct timespec tp={0, 100000};

    sz= read(fd, &data, sizeof(data));

    if (sz >= sizeof(data.ev)) {

        OPAL_OUTPUT_VERBOSE((2, orcm_cfgi_base.output,
                             "%s Inotify Event: name %s type %d",
                             ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
                             data.ev.name, data.ev.mask));
        /* if the event involves a typical editor swap
         * file, ignore it
         */
        if (NULL != strstr(data.ev.name, ".swp") ||
            NULL != strchr(data.ev.name, '~')) {
            /* vi swap */
            OPAL_OUTPUT_VERBOSE((2, orcm_cfgi_base.output,
                                 "%s Inotify Event: Ignoring .swp file",
                                 ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
            return;
        }
        if ('.' == data.ev.name[0]) {
            /* special file */
            OPAL_OUTPUT_VERBOSE((2, orcm_cfgi_base.output,
                                 "%s Inotify Event: Ignoring dot-file",
                                 ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
            return;
        }
        if ('#' == data.ev.name[0]) {
            /* emacs auto-save */
            OPAL_OUTPUT_VERBOSE((2, orcm_cfgi_base.output,
                                 "%s Ignoring emacs auto-save file",
                                 ORTE_NAME_PRINT(ORTE_PROC_MY_NAME)));
            return;
        }
        /* ensure that editors have a chance to cleanly
         * exit before reading the config so we don't
         * destabilize the parser
         */
        nanosleep(&tp, NULL);
        check_config(0, 0, NULL);
    } else if (sz < 0) {
        OPAL_OUTPUT_VERBOSE((2, orcm_cfgi_base.output,
                             "%s Inotify Event: READ ERROR",
                             ORTE_NAME_PRINT(ORTE_PROC_MY_NAME))); /* EINVAL: short of space */
        return;
    } else {
        OPAL_OUTPUT_VERBOSE((2, orcm_cfgi_base.output,
                             "%s Inotify Event: Short read: %d", 
                             ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), sz));
    }
}
Esempio n. 13
0
int main(int argc, char *argv[])
{
    char ch;
    int ret = EXIT_FAILURE;
    struct sc_config config;

    config.in_place = 0;
    config.file[FILE_DIC] = DEFAULT_DICTIONARY;
    while ((ch = getopt(argc, argv, "d:hi:o:pv")) != -1) {
        switch (ch) {
        case 'd':
            config.file[FILE_DIC] = optarg;
            break;
        case 'h':
            print_content(SC_FILE_HELP);
            return EXIT_SUCCESS;
        case 'i':
            config.file[FILE_DOC] = optarg;
            break;
        case 'o':
            if (config.in_place) {
                log_fatal("output file cannot be specified "
                          "if in-place edit is asked for");
                return EXIT_FAILURE;
            }
            config.file[FILE_OUT] = optarg;
            break;
        case 'p':
            if (config.file[FILE_OUT]) {
                log_fatal("document cannot be edited in place "
                          "if output file is specified");
                return EXIT_FAILURE;
            }
            config.in_place = 1;
            break;
        case 'v':
            print_content(SC_FILE_VERSION);
            return EXIT_SUCCESS;
        default:
            print_content(SC_FILE_HELP);
            return EXIT_FAILURE;
        }
    }

    if (check_config(&config, argc, argv)) {
        print_content(SC_FILE_HELP);
        goto ERROR;
    }

    if (spell_check(&config))
        goto ERROR;
    print_content(SC_FILE_BANNER);
    ret = EXIT_SUCCESS;

ERROR:
    if (config.file[FILE_OUT])
        free(config.file[FILE_OUT]);
    return ret;
}
Esempio n. 14
0
/**
 * Create the connection to the resolver service.
 *
 * @param cfg configuration to use
 */
void
GNUNET_RESOLVER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
{
  GNUNET_assert (NULL != cfg);
  backoff = GNUNET_TIME_UNIT_MILLISECONDS;
  resolver_cfg = cfg;
  check_config ();
}
Esempio n. 15
0
int main(int argc, char **argv) {
	(void) argc;
	(void) argv;

	check_config();

	setbuf(stdout, NULL);
	setbuf(stderr, NULL);
	log("tuerd (rev " GIT_REV  ") starting up");

	if(getenv("TUERD_DEBUG"))
		debug = 1;

	debug("Debugging enabled. This allows people to be tracked!");

	// initialize git
	git_init();

	// initialize nfc
	nfc_device *nfc_dev = rfid_init();
	if(!nfc_dev)
		die("rfid_init failed");

	// initialize watchdog handler
	struct sigaction sa;
	sa.sa_handler = sigalarm;
	sigemptyset(&sa.sa_mask);
	sa.sa_flags = 0;

	sigaction(SIGALRM, &sa, NULL);

	while(1) {
		debug("-----------------");
		debug("waiting for event");

		if(!rfid_poll(nfc_dev))
			die("rfid_poll failed");

		debug("successfully got target");

		alarm(10);

		if(rfid_authenticate_any(nfc_dev, get_key_git)) {
			debug("auth succeeded, opening door");
			open_door();
			alarm(0);

			sleep(10);
		} else {
			debug("auth failed");
			alarm(0);

			sleep(1);
		}
	}

	return EXIT_SUCCESS;
}
Esempio n. 16
0
fs_ret_t fs_store(fs_config_t const * const p_config,
                  uint32_t    const * const p_dest,
                  uint32_t    const * const p_src,
                  uint16_t    const         length_words)
{
    fs_op_t * p_op;

    if (!(m_flags & FS_FLAG_INITIALIZED))
    {
        return FS_ERR_NOT_INITIALIZED;
    }

    if (!check_config(p_config))
    {
        return FS_ERR_INVALID_CFG;
    }

    if ((p_src == NULL) || (p_dest == NULL))
    {
        return FS_ERR_NULL_ARG;
    }

    // Check that both pointers are word aligned.
    if (((uint32_t)p_src  & 0x03) ||
        ((uint32_t)p_dest & 0x03))
    {
        return FS_ERR_UNALIGNED_ADDR;
    }

    // Check that the operation doesn't go outside the client's memory boundaries.
    if ((p_config->p_start_addr > p_dest) ||
        (p_config->p_end_addr   < (p_dest + length_words)))
    {
        return FS_ERR_INVALID_ADDR;
    }

    if (length_words == 0)
    {
        return FS_ERR_INVALID_ARG;
    }

    if (!queue_get_next_free(&p_op))
    {
        return FS_ERR_QUEUE_FULL;
    }

    // Initialize the operation.
    p_op->p_config           = p_config;
    p_op->op_code            = FS_OP_STORE;
    p_op->store.p_src        = p_src;
    p_op->store.p_dest       = p_dest;
    p_op->store.length_words = length_words;

    queue_start();

    return FS_SUCCESS;
}
Esempio n. 17
0
/**
 * Get an IP address as a string.
 *
 * @param sa host address
 * @param salen length of host address in @a sa
 * @param do_resolve use #GNUNET_NO to return numeric hostname
 * @param timeout how long to try resolving
 * @param callback function to call with hostnames
 *        last callback is NULL when finished
 * @param cls closure for @a callback
 * @return handle that can be used to cancel the request
 */
struct GNUNET_RESOLVER_RequestHandle *
GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa,
                              socklen_t salen,
                              int do_resolve,
                              struct GNUNET_TIME_Relative timeout,
                              GNUNET_RESOLVER_HostnameCallback callback,
                              void *cls)
{
    struct GNUNET_RESOLVER_RequestHandle *rh;
    size_t ip_len;
    const void *ip;

    check_config ();
    switch (sa->sa_family)
    {
    case AF_INET:
        GNUNET_assert (salen == sizeof (struct sockaddr_in));
        ip_len = sizeof (struct in_addr);
        ip = &((const struct sockaddr_in*)sa)->sin_addr;
        break;
    case AF_INET6:
        GNUNET_assert (salen == sizeof (struct sockaddr_in6));
        ip_len = sizeof (struct in6_addr);
        ip = &((const struct sockaddr_in6*)sa)->sin6_addr;
        break;
    default:
        GNUNET_break (0);
        return NULL;
    }
    rh = GNUNET_malloc (sizeof (struct GNUNET_RESOLVER_RequestHandle) + salen);
    rh->name_callback = callback;
    rh->cls = cls;
    rh->af = sa->sa_family;
    rh->timeout = GNUNET_TIME_relative_to_absolute (timeout);
    memcpy (&rh[1], ip, ip_len);
    rh->data_len = ip_len;
    rh->direction = GNUNET_YES;
    rh->received_response = GNUNET_NO;
    if (GNUNET_NO == do_resolve)
    {
        rh->task = GNUNET_SCHEDULER_add_now (&numeric_reverse, rh);
        return rh;
    }
    GNUNET_CONTAINER_DLL_insert_tail (req_head,
                                      req_tail,
                                      rh);
    rh->was_queued = GNUNET_YES;
    if (NULL != s_task)
    {
        GNUNET_SCHEDULER_cancel (s_task);
        s_task = NULL;
    }
    process_requests ();
    return rh;
}
Esempio n. 18
0
/*****************************************************************************
	Continuous系
*****************************************************************************/
void CGainer::ExecuteContinuousDigital(DWORD period)
{
	check_config();

	if ( ! CONFIG[m_config][DIN] ) {
		return;
	}

	m_digital_period = period;
	command_send("r*",true);
}
Esempio n. 19
0
/*
 * setup() - performs all ONE TIME setup for this test
 */
void setup(void)
{

	tst_sig(NOFORK, DEF_HANDLER, cleanup);

	check_config(TEST_NODES);
	/* Pause if that option was specified
	 * TEST_PAUSE contains the code to fork the test with the -c option.
	 */
	TEST_PAUSE;
}
Esempio n. 20
0
fs_ret_t fs_erase(fs_config_t const * const p_config,
                  uint32_t    const * const p_page_addr,
                  uint16_t    const         num_pages)
{
    fs_op_t * p_op;

    if (!(m_flags & FS_FLAG_INITIALIZED))
    {
        return FS_ERR_NOT_INITIALIZED;
    }

    if (!check_config(p_config))
    {
        return FS_ERR_INVALID_CFG;
    }

    if (p_page_addr == NULL)
    {
        return FS_ERR_NULL_ARG;
    }

    // Check that the page is aligned to a page boundary.
    if (((uint32_t)p_page_addr % FS_PAGE_SIZE) != 0)
    {
        return FS_ERR_UNALIGNED_ADDR;
    }

    // Check that the operation doesn't go outside the client's memory boundaries.
    if ((p_page_addr < p_config->p_start_addr) ||
        (p_page_addr + (FS_PAGE_SIZE_WORDS * num_pages) > p_config->p_end_addr))
    {
        return FS_ERR_INVALID_ADDR;
    }

    if (num_pages == 0)
    {
        return FS_ERR_INVALID_ARG;
    }

    if (!queue_get_next_free(&p_op))
    {
        return FS_ERR_QUEUE_FULL;
    }

    // Initialize the operation.
    p_op->p_config             = p_config;
    p_op->op_code              = FS_OP_ERASE;
    p_op->erase.page           = ((uint32_t)p_page_addr / FS_PAGE_SIZE);
    p_op->erase.pages_to_erase = num_pages;

    queue_start();

    return FS_SUCCESS;
}
Esempio n. 21
0
/*****************************************************************************
	単独サーボ設定
*****************************************************************************/
bool CGainer::SetServoSingle(int port,BYTE value)
{
	check_config();

	int limit = 8;
	if ( m_config != 8 ) { return false; }

	char buf[64];
	sprintf(buf,"p%d%02X*",port,value);
	return command_send(buf).size() != 0;
}
Esempio n. 22
0
/*****************************************************************************
	LED(h/l)
*****************************************************************************/
bool CGainer::SetLED(bool isOn)
{
	check_config();

	if ( isOn ) {
		return command_send("h*").size() != 0;
	}
	else {
		return command_send("l*").size() != 0;
	}
}
Esempio n. 23
0
void CGainer::ExecuteContinuousAnalog(DWORD period)
{
	check_config();

	if ( ! CONFIG[m_config][AIN] ) {
		return;
	}

	m_analog_period = period;
	command_send("i*",true);
}
Esempio n. 24
0
static int config_init(const char *file)
{
	GKeyFile *config;

	config = load_config(file);
	check_config(config);
	parse_config(config);
	if (config != NULL)
		g_key_file_free(config);

	return 0;
}
Esempio n. 25
0
static gboolean sep_setconf_ind(struct avdtp *session,
						struct avdtp_local_sep *sep,
						struct avdtp_stream *stream,
						GSList *caps,
						avdtp_set_configuration_cb cb,
						void *user_data)
{
	struct a2dp_endpoint *endpoint = user_data;
	struct a2dp_device *dev;
	struct a2dp_preset *preset = NULL;

	DBG("");

	dev = find_device_by_session(session);
	if (!dev) {
		error("Unable to find device for session %p", session);
		return FALSE;
	}

	for (; caps != NULL; caps = g_slist_next(caps)) {
		struct avdtp_service_capability *cap = caps->data;
		struct avdtp_media_codec_capability *codec;

		if (cap->category == AVDTP_DELAY_REPORTING)
			return FALSE;

		if (cap->category != AVDTP_MEDIA_CODEC)
			continue;

		codec = (struct avdtp_media_codec_capability *) cap->data;

		if (codec->media_codec_type != endpoint->codec)
			return FALSE;

		preset = g_new0(struct a2dp_preset, 1);
		preset->len = cap->length - sizeof(*codec);
		preset->data = g_memdup(codec->data, preset->len);

		if (check_config(endpoint, preset) < 0) {
			preset_free(preset);
			return FALSE;
		}
	}

	if (!preset)
		return FALSE;

	setup_add(dev, endpoint, preset, stream);

	cb(session, stream, NULL);

	return TRUE;
}
Esempio n. 26
0
bool CGainer::ScanMatrix(BYTE data[GAINER_LED_MATRIX][GAINER_LED_MATRIX])
{
	check_config();

	if ( m_config != 7 ) { return false; }

	for ( size_t row = 0 ; row < GAINER_LED_MATRIX ; ++row ) {
		ScanLine(row,data[row]);
	}

	return true;
}
Esempio n. 27
0
/*****************************************************************************
	単独アナログ設定
*****************************************************************************/
bool CGainer::SetAnalogSingle(int port,BYTE value)
{
	if ( ! CONFIG[m_config][AOUT] ) {
		return false;
	}

	check_config();

	char buf[64];
	sprintf(buf,"a%d%02X*",port,value);
	return command_send(buf).size() != 0;
}
Esempio n. 28
0
/*****************************************************************************
	全デジタル設定
*****************************************************************************/
bool CGainer::SetDigitalAll(int value)
{
	if ( ! CONFIG[m_config][DOUT] ) {
		return false;
	}

	check_config();

	char c[32];
	sprintf(c,"D%04X*",value);
	return command_send(c).size() != 0;
}
Esempio n. 29
0
/*****************************************************************************
	全デジタル取得
*****************************************************************************/
bool CGainer::GetDigitalAll(WORD &result,size_t &bits)
{
	check_config();

	if ( ! CONFIG[m_config][DIN] ) {
		return false;
	}

	std::string r = command_send("R*");
	result = m_digitalInputs;
	bits = CONFIG[m_config][DIN];
	return r.size() != 0;
}
Esempio n. 30
0
static int setup_config(int type)
{
	int rv;

	rv = read_config(cl.configfile, type);
	if (rv < 0)
		goto out;

	if (is_auth_req()) {
		rv = read_authkey();
		if (rv < 0)
			goto out;
#if HAVE_LIBGCRYPT
		if (!gcry_check_version(NULL)) {
			log_error("gcry_check_version");
			rv = -ENOENT;
			goto out;
		}
		gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
		gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
	}

	/* Set "local" pointer, ignoring errors. */
	if (cl.type == DAEMON && cl.site[0]) {
		if (!find_site_by_name(cl.site, &local, 1)) {
			log_error("Cannot find \"%s\" in the configuration.",
					cl.site);
			return -EINVAL;
		}
		local->local = 1;
	} else
		find_myself(NULL, type == CLIENT || type == GEOSTORE);


	rv = check_config(type);
	if (rv < 0)
		goto out;


	/* Per default the PID file name is derived from the
	 * configuration name. */
	if (!cl.lockfile[0]) {
		snprintf(cl.lockfile, sizeof(cl.lockfile)-1,
				"%s/%s.pid", BOOTH_RUN_DIR, booth_conf->name);
	}

out:
	return rv;
}