示例#1
0
/* try_open_joy_device: [primary thread]
 *
 *  Try to open joystick device number NUM, returning the fd on success
 *  or -1 on failure.
 */
static int try_open_joy_device(int num)
{
   const char *device_name = NULL;
   char tmp[128];
   /* char tmp1[128], tmp2[128]; */
   int fd;

   /* XXX use configuration system when we get one */
   device_name = NULL;
#if 0
   /* Check for a user override on the device to use. */
   snprintf(tmp, sizeof(tmp), "joystick_device_%d", num);
   device_name = get_config_string("joystick", tmp, NULL);

   /* Special case for the first joystick. */
   if (!device_name && (num == 0))
      device_name = get_config_string("joystick",
                                      "joystick_device",
                                      NULL);
#endif

   if (device_name)
      fd = open(device_name, O_RDONLY|O_NONBLOCK);
   else {
      snprintf(tmp, sizeof(tmp), "/dev/input/js%d", num);
      tmp[sizeof(tmp)-1] = 0;

      fd = open(tmp, O_RDONLY|O_NONBLOCK);
      if (fd == -1) {
         snprintf(tmp, sizeof(tmp), "/dev/js%d", num);
         tmp[sizeof(tmp)-1] = 0;

         fd = open(tmp, O_RDONLY|O_NONBLOCK);
         if (fd == -1)
	    return -1;
      }
   }

   if (!check_js_api_version(fd)) {
      close(fd);
      return -1;
   }

   return fd;   
}
示例#2
0
/* get_config_int:
 *  Reads an integer from the configuration file.
 */
int get_config_int(char *section, char *name, int def)
{
   char *s = get_config_string(section, name, NULL);

   if ((s) && (*s))
      return strtol(s, NULL, 0);

   return def;
}
示例#3
0
文件: conf.c 项目: cotodevel/SnemulDS
/* get_config_float:
 *  Reads a float from the configuration file.
 */
float get_config_float(char *section, char *name, float def)
{
   char *s = get_config_string(section, name, NULL);

   if ((s) && (*s))
      return atof(s);

   return def;
}
示例#4
0
/* read_keyboard_config:
 *  Reads in the keyboard config tables.
 */
static void read_keyboard_config(void)
{
   char filename[1024], tmp1[128], tmp2[128], *ext, *datafile;
   AL_CONST char* name;

   name = get_config_string(uconvert_ascii("system", tmp1), uconvert_ascii("keyboard", tmp2), _keyboard_layout);

   if ((!name) || (!ugetc(name)))
      return;

   ext = uconvert_ascii(".cfg", tmp1);
   datafile = uconvert_ascii("keyboard.dat", tmp2);

   if (find_allegro_resource(filename, name, ext, datafile, NULL, NULL, NULL, sizeof(filename)) != 0)
      return;

   push_config_state();
   set_config_file(filename);

   read_key_table(custom_key_ascii_table,          standard_key_ascii_table,     "key_ascii");
   read_key_table(custom_key_capslock_table,       standard_key_capslock_table,  "key_capslock");
   read_key_table(custom_key_shift_table,          standard_key_shift_table,     "key_shift");
   read_key_table(custom_key_control_table,        standard_key_control_table,   "key_control");

   /* preserve backward compatibility with former unique key_altgr table */
   read_key_table(custom_key_altgr_lower_table,    standard_key_empty_table,     "key_altgr");
   read_key_table(custom_key_altgr_upper_table,    standard_key_empty_table,     "key_altgr");

   read_key_table(custom_key_altgr_lower_table,    custom_key_altgr_lower_table, "key_altgr_lower");
   read_key_table(custom_key_altgr_upper_table,    custom_key_altgr_upper_table, "key_altgr_upper");

   read_key_table(custom_key_accent1_lower_table,  standard_key_empty_table,     "key_accent1_lower");
   read_key_table(custom_key_accent1_upper_table,  standard_key_empty_table,     "key_accent1_upper");
   read_key_table(custom_key_accent2_lower_table,  standard_key_empty_table,     "key_accent2_lower");
   read_key_table(custom_key_accent2_upper_table,  standard_key_empty_table,     "key_accent2_upper");
   read_key_table(custom_key_accent3_lower_table,  standard_key_empty_table,     "key_accent3_lower");
   read_key_table(custom_key_accent3_upper_table,  standard_key_empty_table,     "key_accent3_upper");
   read_key_table(custom_key_accent4_lower_table,  standard_key_empty_table,     "key_accent4_lower");
   read_key_table(custom_key_accent4_upper_table,  standard_key_empty_table,     "key_accent4_upper");

   _key_accent1 = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent1", tmp2), 0);
   _key_accent2 = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent2", tmp2), 0);
   _key_accent3 = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent3", tmp2), 0);
   _key_accent4 = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent4", tmp2), 0);

   _key_accent1_flag = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent1_flag", tmp2), 0);
   _key_accent2_flag = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent2_flag", tmp2), 0);
   _key_accent3_flag = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent3_flag", tmp2), 0);
   _key_accent4_flag = get_config_int(uconvert_ascii("key_escape", tmp1), uconvert_ascii("accent4_flag", tmp2), 0);

   pop_config_state();

   set_custom_keyboard();

   update_key_descriptions();
}
示例#5
0
/* mouse_init:
 *  Here we open the mouse device, initialise anything that needs it, 
 *  and chain to the framework init routine.
 */
static int mouse_init (void)
{
   char tmp1[128], tmp2[128];
   AL_CONST char *udevice;

   /* Set the current tool */
   current_tool = default_tool;

   /* Find the device filename */
   udevice = get_config_string (uconvert_ascii ("mouse", tmp1),
                                uconvert_ascii ("mouse_device", tmp2),
                                NULL);

   /* Open mouse device.  Devices are cool. */
   if (udevice) {
      TRACE(PREFIX_I "Trying %s device\n", udevice);
      intdrv.device = open_mouse_device (uconvert_toascii (udevice, tmp1));
      if (intdrv.device < 0) {
         uszprintf (allegro_error, ALLEGRO_ERROR_SIZE, get_config_text ("Unable to open %s: %s"),
                    udevice, ustrerror (errno));
         return -1;
      }
   }
   else {
      /* If not specified in the config file, try several /dev/input/event<n>
       * devices. */
      const char *device_name[] = { "/dev/input/event0",
                                    "/dev/input/event1",
                                    "/dev/input/event2",
                                    "/dev/input/event3",
                                    NULL };
      int i;

      TRACE(PREFIX_I "Trying /dev/input/event[0-3] devices\n");

      for (i=0; device_name[i]; i++) {
         intdrv.device = open_mouse_device (device_name[i]);
         if (intdrv.device >= 0) {
	    break;
         }
      }

      if (!device_name[i]) {
	 uszprintf (allegro_error, ALLEGRO_ERROR_SIZE, get_config_text ("Unable to open a mouse device: %s"),
		    ustrerror (errno));
	 return -1;
      }
   }

   intdrv.num_buttons = get_num_buttons(intdrv.device);
   /* Init the tablet data */
   init_tablet(intdrv.device);

   return __al_linux_mouse_init (&intdrv);
}
示例#6
0
文件: mmain.cpp 项目: Yurand/tw-light
void NormalGame::init(Log *_log)
{
	STACKTRACE;
	Game::init(_log);

	team_table_size = 0;

	view->window->locate(0,0,0,0,0,0.9,0,1);

	tw_delete_file(home_ini_full_path("tmp.ini"));
	tw_delete_file(home_ini_full_path("fleets.tmp"));
	tw_set_config_file(home_ini_full_path("tmp.ini"));
	set_config_string (NULL, "Ignorethis", "");
	if (!log->playback) init_players();
	log_file(home_ini_full_path("tmp.ini"));
	if (log->playback) {
		for (int i = 0; true; i += 1) {
			char buffy[64];
			sprintf(buffy, "Player%d", i + 1);
			log_file(home_ini_full_path("tmp.ini"));
			const char *type = get_config_string(buffy, "Type", NULL);
			if (!type) break;
			const char *name = get_config_string(buffy, "Name", buffy);
			int channel = get_config_int(buffy, "Channel", -2);
			int ti = get_config_int(buffy, "Team", 0);
			add_player(create_control(channel, type), ti, name, buffy);
			player_fleet[i]->load(NULL, buffy);
			player_fleet[i]->save("fleets.tmp", buffy);
		}
	}

	prepare();
	init_objects();

	next_choose_new_ships_time = game_time + 200;

	// team and health indicators.
	indteamtoggle = 0;
	indhealthtoggle = 0;

	return;
}
示例#7
0
bool SqlParser::setDefaultLimit() {
    static const char *defaultLimit = NULL;
    if (defaultLimit == NULL) {
        defaultLimit = get_config_string("DEFAULT_SELECT_LIMIT");
        if (defaultLimit == NULL)
            defaultLimit = "500";
    }

    int limitPos;
    if (!findToken(1, getTokensLen(), TK_SQL_LIMIT, &limitPos)) {
        g_string_append(inputSql, " LIMIT ");
        g_string_append(inputSql, defaultLimit);
        network_mysqld_proto_set_header_len((unsigned char *) (inputSql->str), inputSql->len - NET_HEADER_SIZE);

        return true;
    }

    if (limitPos + 3 > getTokensLen() - 1) // no offset
        return true;

    if (limitPos + 3 < getTokensLen() - 1) {
        printTokens("only queries with LIMIT at the last field is supported now!");
        return false;
    }

    int offset, rowCount;
    if (getTokenId(limitPos + 2) == TK_COMMA) {
        offset = atoi(getTokenStr(limitPos + 1).c_str());
        rowCount = atoi(getTokenStr(limitPos + 3).c_str());
    } else if (getTokenId(limitPos + 2) == TK_SQL_OFFSET) {
        offset = atoi(getTokenStr(limitPos + 3).c_str());
        rowCount = atoi(getTokenStr(limitPos + 1).c_str());
    } else {
        printTokens("Unrecognized LIMIT OFFSET format:");
        return false;
    }

    // TODO: the tokenizer needs to have the field offset info
    // for now, we search LIMIT from the end
    char *p = inputSql->str + inputSql->len - 1;
    while (toupper(*p) != 'L') p--;

    // remove the old LIMIT OFFSET info
    //
    g_string_truncate(inputSql, p - inputSql->str);

    // add new LIMIT OFFSET info
    char buff[128];
    snprintf(buff, sizeof (buff), "LIMIT %d", offset + rowCount);
    g_string_append(inputSql, buff);
    network_mysqld_proto_set_header_len((unsigned char *) (inputSql->str), inputSql->len - NET_HEADER_SIZE);

    return true;
}
示例#8
0
void
read_joy_mapping (void)
{
# if 0 //LUDO: TO_BE_DONE !
  char tmp_str[10], tmp_str2[10], section_name[10];
  unsigned char x, y, z;
  unsigned short temp_val;

  Log ("--[ JOYPAD MAPPING ]-------------------------------\n");
  Log ("Loading default values\n");

  memset (tmp_str, 0, 10);

  strcpy (section_name, "CONFIG1");
  for (z = 0; z < 16; z++)
    {
      if (z < 10)
	section_name[6] = '0' + z;
      else
	section_name[6] = (z - 10) + 'a';

      Log (" * Looking for section %s\n", section_name);

      for (x = 0; x < 5; x++)
	{			// for each player

	  config[z].individual_config[x].joydev = 0;
	  strcpy (tmp_str2, "joydev1");
	  tmp_str2[6] = '0' + x;

	  strncpy (tmp_str, get_config_string (section_name, tmp_str2, "0"),
		   10);
	  config[z].individual_config[x].joydev = atoi (tmp_str);

	  for (y = 0; y < J_MAX; y++)
	    {
	      strncpy (tmp_str, joymap_reverse[y], 10);
	      tmp_str[strlen (tmp_str) + 1] = 0;
	      tmp_str[strlen (tmp_str)] = '0' + x;
	      temp_val = get_config_int (section_name, tmp_str, 0xffff);
	      
	      if (0xffff != temp_val)
	      {
	      	config[z].individual_config[x].joy_mapping[y] = temp_val;
	      	Log ("    %s set to %d\n", joymap_reverse[y], temp_val);
	      }
	    }

	}
    }

  Log ("End of joypad mapping\n\n");
# endif
}
示例#9
0
文件: keys.cpp 项目: Fomka/ufo2000
void keyswitch(int keyswitch_lang)
{
	push_config_state();
	set_config_file(F("$(home)/ufo2000.ini"));

	switch (keyswitch_lang) {
		case 0: {
			const char *current_keyboard = get_config_string("system", "keyboard", "us");
			const char *primary_keyboard = get_config_string("system", "primary_keyboard", "us");
			const char *secondary_keyboard = get_config_string("system", "secondary_keyboard", "ru");
			if (strcmp(current_keyboard, primary_keyboard) == 0)
				set_config_string("system", "keyboard", secondary_keyboard);
			else
				set_config_string("system", "keyboard", primary_keyboard);
			break;
		}
		case KEY_E: 
			set_config_string("system", "keyboard", "us"); 
			break;
		case KEY_R: 
			set_config_string("system", "keyboard", "ru"); 
			break;
		case KEY_B: 
			set_config_string("system", "keyboard", "by"); 
			break;
		case KEY_P: 
			set_config_string("system", "keyboard", "pl"); 
			break;
		case KEY_D: 
			set_config_string("system", "keyboard", "de"); 
			break;
		default: 
			pop_config_state(); 
			return;
	}
	
	clear_keybuf();
	remove_keyboard();
	install_keyboard();
	pop_config_state();
}
示例#10
0
RecentFiles::RecentFiles()
  : m_files(16)
  , m_paths(16)
{
  char buf[512];

  for (int c=m_files.limit()-1; c>=0; c--) {
    sprintf(buf, "Filename%02d", c);

    const char* filename = get_config_string("RecentFiles", buf, NULL);
    if (filename && *filename && base::file_exists(filename))
      m_files.addItem(filename);
  }

  for (int c=m_paths.limit()-1; c>=0; c--) {
    sprintf(buf, "Path%02d", c);

    const char* path = get_config_string("RecentPaths", buf, NULL);
    if (path && *path)
      m_paths.addItem(path);
  }

  // Create recent list of paths from filenames (for backward
  // compatibility with previous versions of ASEPRITE).
  if (m_paths.empty()) {
    std::set<std::string> included;

    // For each recent file...
    const_iterator it = files_begin();
    const_iterator end = files_end();
    for (; it != end; ++it) {
      base::string path = base::get_file_path(*it);

      // Check if the path was not already included in the list
      if (included.find(path) == included.end()) {
        included.insert(path);
        m_paths.addItem(path);
      }
    }
  }
}
示例#11
0
CFStringRef AoEProperties::get_targets_config_string(int nTargetNumber)
{
	int n, nNum;
	
	// Iterate over the list of targets, checking which one is the target number we are looking for
	nNum = number_of_targets();
	for(n=0; n<nNum; n++)
		if ( nTargetNumber==get_target_number(n) )
			return get_config_string(n);

	return NULL;
}
示例#12
0
文件: conf.c 项目: cotodevel/SnemulDS
/* get_config_oct:
 *  Reads a octal integer from the configuration file.
 */
int get_config_oct(char *section, char *name, int def)
{
   char *s = get_config_string(section, name, NULL);
   int i;

   if ((s) && (*s)) {
      i = strtol(s, NULL, 8);
      return i;
   }

   return def;
}
示例#13
0
文件: conf.c 项目: cotodevel/SnemulDS
/* get_config_hex:
 *  Reads a hexadecimal integer from the configuration file.
 */
int get_config_hex(char *section, char *name, int def)
{
   char *s = get_config_string(section, name, NULL);
   int i;

   if ((s) && (*s)) {
      i = strtol(s, NULL, 16);
      if ((i == 0x7FFFFFFF) && (stricmp(s, "7FFFFFFF") != 0))
	 i = -1;
      return i;
   }

   return def;
}
示例#14
0
文件: inidriv.c 项目: neiderm/turaco
// it seems get_config_argv will only give a max argc of 16.
// we require far more than this for palette reading.
// This function takes an array of ints and fills it given
// a section and label name. 
// returns - true if everything ok or false if section/label doesn't
// exist
BOOL get_config_int_array(char * Section, char * Label,
                          int * PaletteVals, int * argc)
{
   char * Buffer;
   char * p;
   int ArgcVal = 0;

   // clear this incase false is returned
   *argc = 0;
   
   Buffer = get_config_string(Section, Label, "None");
   if (strcmp(Buffer, "None") == 0)
      return FALSE;

   p = Buffer;
   
   for (;;)
   {
      char NumBuf[10];
      int pos = 0;
      
      // skip any leading spaces
      while((*p == ' ') && (*p != 0)) p++;

      // fall out?
      if (*p == 0) break;

      // copy string out until next space
      while ((*p != ' ') && (*p != 0))
      {
         NumBuf[pos] = *p;
         pos++;
         p++;
      }

      // any number to convert?
      if ((pos == 0) && (*p == 0))
         break;
          
      // null terminate and convert to a number in the main array
      NumBuf[pos] = 0;
      PaletteVals[ArgcVal] = atol(NumBuf);
      ArgcVal++;
   }

   *argc = ArgcVal;

   return TRUE;
}
示例#15
0
char *get_name(meshlink_handle_t *mesh) {
	char *name = NULL;

	get_config_string(lookup_config(mesh->config, "Name"), &name);

	if(!name)
		return NULL;

	if(!check_id(name)) {
		logger(mesh, MESHLINK_ERROR, "Invalid name for mesh->self!");
		free(name);
		return NULL;
	}

	return name;
}
示例#16
0
文件: sleep.c 项目: cravo/damp
void sleep_init(int mins)
{
   char txt[256];

   LOCK_FUNCTION(sleep_timeout);
   LOCK_FUNCTION(sleep_fadeout);

   /* See if fading is required */

   sprintf(txt,get_config_string("[options]","sleep_fade","yes"));

   if(stricmp(txt,"YES") == 0)
      sleep_want_fade = TRUE;

   install_int_ex(sleep_timeout, SECS_TO_TIMER(mins*60));
}
示例#17
0
/* alsa_rawmidi_detect:
 *  ALSA RawMIDI detection.
 */
static int alsa_rawmidi_detect(int input)
{
#if ALLEGRO_ALSA_VERSION == 9
   const char *device = NULL;
#else  /* ALLEGRO_ALSA_VERSION == 5 */
   int card = -1;
   int device = -1;
#endif
   int ret = FALSE, err;
   char tmp1[128], tmp2[128], temp[256];
   snd_rawmidi_t *handle = NULL;

   if (input) {
      ret = FALSE;
   }
   else {
#if ALLEGRO_ALSA_VERSION == 9
      device = get_config_string(uconvert_ascii("sound", tmp1),
				 uconvert_ascii("alsa_rawmidi_device", tmp2),
				 "default");

      err = snd_rawmidi_open(NULL, &handle, device, 0);
#else  /* ALLEGRO_ALSA_VERSION == 5 */
      card = get_config_int(uconvert_ascii("sound", tmp1),
			    uconvert_ascii("alsa_rawmidi_card", tmp2),
			    snd_defaults_rawmidi_card());

      device = get_config_int(uconvert_ascii("sound", tmp1),
			      uconvert_ascii("alsa_rawmidi_device", tmp2),
			      snd_defaults_rawmidi_device());

      err = snd_rawmidi_open(&handle, card, device, SND_RAWMIDI_OPEN_OUTPUT_APPEND);
#endif
      if (err) {
	 snprintf(temp, sizeof(temp), "Could not open card/rawmidi device: %s", snd_strerror(err));
	 ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text(temp));
	 ret = FALSE;
      }
      else {
	 snd_rawmidi_close(handle);
	 ret = TRUE;
      }
   }

   return ret;
}
void CSerialPortItem::ReloadContents()
{
    char buf[32];
    char setting[1024];
    CArgs args;
    sprintf(buf, "PORT%d", m_PortNo);
    if(!get_config_string(&key, "ports", buf, setting, sizeof(setting), 500)){
        return;
    }
    utils_debug("Port%d on %s: %s\n", m_PortNo, (char*)CNodeName(key), setting);
    parse_arg_ex(setting, &args, ",");
    if(args.argc != 4){
        return;
    }
    m_baud = atoi(args.argv[0]);
    if( m_baud != 4800 &&
        m_baud != 9600 &&
        m_baud != 19200 &&
        m_baud != 38400 &&
        m_baud != 57600 &&
        m_baud != 115200
    ){
        m_baud = 57600;
    }

    m_checkmode = *args.argv[1];
    if(!strchr("mbeon", m_checkmode) ){
        m_checkmode = 'm';
    }

    m_databits = atoi(args.argv[2]);
    if(m_databits < 6 || m_databits>8){
        m_databits = 8;
    }

    if( !strcmp(args.argv[3], "1") ){
        m_stopbits = 1;
    }else if(!strcmp(args.argv[3], "2") ){
        m_stopbits = 2;
    }else if(!strcmp(args.argv[3], "1.5") ){
        m_stopbits = 3;
    }else{
        m_stopbits = 1;
    }
}
void send_confstartendupdate(connection_t *c, int start) {
	char rawconf[MAX_STRING_SIZE];
	char rawdgst[MAX_STRING_SIZE], b64dgst[MAX_STRING_SIZE];
	size_t slen, dlen, rlen;
	char *fname;
	bool choice = false;

	/* test if we're are authorized to broadcast the data */
	if(!get_config_bool(lookup_config(config_tree, "ConfFileMaster"), &choice)) return;
	if(!choice) return;

	if(c->node && c->node->sentupdates) return;

	if(get_config_string(lookup_config(config_tree, "ConfFileTemplate"), &fname)) free(fname);
	else return;

	/* Start update session */
	dlen = RSA_size(myself->connection->rsa_key);
	if (dlen > sizeof(rawdgst)/2) {
		logger(LOG_ERR, "Could not %s config update session due to digest overflow",
		start ? "start" : "end");

		return;
	}

	snprintf(rawconf, sizeof(rawconf), "%s %s 0 %zd",
		myself->name, start ? "START" : "END", dlen);
	rlen = strlen(rawconf);
	if (!EVP_sign(myself->connection->rsa_key, rawconf, rlen, rawdgst, &dlen)) {
		logger(LOG_ERR,
		"Could not %s config update session due to signing error (probably OOM)",
		start ? "start" : "end");

		return;
	}
	if (base64_enclen(dlen) >= MAX_STRING_SIZE) {
		logger(LOG_ERR,
		"Could not %s config update session, base64 digest overflow",
		start ? "start" : "end");

		return;
	}
	base64_encode(rawdgst, dlen, b64dgst, sizeof(b64dgst)-1);
	send_request(c, "%d %s %s", CONFUPDATE, rawconf, b64dgst);
}
示例#20
0
/* jack_detect:
 *  Detects driver presence.
 */
static int jack_detect(int input)
{ 
   if (input) {
      ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text(
         "Input is not supported"));
      return FALSE;
   }

   if (!jack_client)
   {
      jack_client_name = get_config_string("sound", "jack_client_name",
	 jack_client_name); 
      jack_client = jack_client_new(jack_client_name);
      if (!jack_client)
	 return FALSE;
   }
   return TRUE;
}
示例#21
0
/* alsa_detect:
 *  Detects driver presence.
 */
static int alsa_detect(int input)
{
   int ret = FALSE;
   char tmp1[128], tmp2[128];

   alsa_device = get_config_string(uconvert_ascii("sound", tmp1),
				   uconvert_ascii("alsa_device", tmp2),
				   alsa_device);

   ret = snd_pcm_open(&pcm_handle, alsa_device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
   if (ret < 0) {
      ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Can not open card/pcm device"));
      return FALSE;
   }

   snd_pcm_close(pcm_handle);
   pcm_handle = NULL;
   return TRUE;
}
示例#22
0
文件: Level.cpp 项目: stevenvi/lander
void Level::loadCore(int level)
{
	set_config_file("core.ini");

	char section[256];
	sprintf(section,"level%02d",level);

	zoom2x = get_config_int(section,"zoom2x",-1);
	zoom2y = get_config_int(section,"zoom2y",-1);
	zoom5x = get_config_int(section,"zoom5x",-1);
	zoom5y = get_config_int(section,"zoom5y",-1);
	zoom10x = get_config_int(section,"zoom10x",-1);
	zoom10y = get_config_int(section,"zoom10y",-1);

	pad2x1 = get_config_int(section,"pad2x1",-1);
	pad2x2 = get_config_int(section,"pad2x2",-1);
	pad2y = get_config_int(section,"pad2y",-1);

	pad5x1 = get_config_int(section,"pad5x1",-1);
	pad5x2 = get_config_int(section,"pad5x2",-1);
	pad5y = get_config_int(section,"pad5y",-1);

	pad10x1 = get_config_int(section,"pad10x1",-1);
	pad10x2 = get_config_int(section,"pad10x2",-1);
	pad10y = get_config_int(section,"pad10y",-1);

	label2x = get_config_int(section,"label2x",-1);
	label2y = get_config_int(section,"label2y",-1);

	label5x = get_config_int(section,"label5x",-1);
	label5y = get_config_int(section,"label5y",-1);

	label10x = get_config_int(section,"label10x",-1);
	label10y = get_config_int(section,"label10y",-1);

	brandx = get_config_int(section,"brandx",-1);
	brandy = get_config_int(section,"brandy",-1);

	const char *tmp = get_config_string(section,"name","name not specified");
	sprintf(name,tmp);

	levelNumber = level;
}
示例#23
0
文件: lcd.c 项目: cravo/damp
void lcd_init(void)
{
   set_config_file(damp_ini_file);

   /* Load the driver */

   lcd_load_driver(get_config_string("[lcd]","driver","NONE"));

   /* Call the driver's init function */

   lcd_external_function("lcd_driver_init");

   /* Read LCD variables from the ini file */

   lcd_scroll_speed = get_config_int("[lcd]","scroll_speed",4);
   lcd_display_width = get_config_int("[lcd]","display_width",16);
   lcd_display_lines = get_config_int("[lcd]","display_lines",2);
   lcd_require_update = FALSE;

   /* Set up the scroller */

   lcd_scroll_pos = 0;
   sprintf(lcd_scroll_text,"%*c\n",lcd_display_width,' ');

   LOCK_FUNCTION(lcd_scroll);
   LOCK_VARIABLE(lcd_scroll_pos);
   LOCK_VARIABLE(lcd_require_update);
   install_int_ex(lcd_scroll,BPS_TO_TIMER(lcd_scroll_speed));

   /* Display driver details */

   printf("======================================================================\n");
   printf("DAMP LCD Driver\n");
   printf("======================================================================\n");
   printf("Driver name        : %s\n",lcd_driver_name);
   printf("Driver version     : %.2f\n",lcd_driver_version);
   printf("Author name        : %s\n",lcd_driver_author);
   printf("Author email       : %s\n",lcd_driver_author_email);
   printf("Driver description : %s\n",lcd_driver_description);
   printf("\n\n");

}
示例#24
0
文件: net_setup.c 项目: dotmark/tinc
char *get_name(void) {
	char *name = NULL;

	get_config_string(lookup_config(config_tree, "Name"), &name);

	if(!name)
		return NULL;

	if(*name == '$') {
		char *envname = getenv(name + 1);
		char hostname[32] = "";
		if(!envname) {
			if(strcmp(name + 1, "HOST")) {
				fprintf(stderr, "Invalid Name: environment variable %s does not exist\n", name + 1);
				free(name);
				return false;
			}
			if(gethostname(hostname, sizeof hostname) || !*hostname) {
				fprintf(stderr, "Could not get hostname: %s\n", strerror(errno));
				free(name);
				return false;
			}
			hostname[31] = 0;
			envname = hostname;
		}
		free(name);
		name = xstrdup(envname);
		for(char *c = name; *c; c++)
			if(!isalnum(*c))
				*c = '_';
	}

	if(!check_id(name)) {
		logger(LOG_ERR, "Invalid name for myself!");
		free(name);
		return false;
	}

	return name;
}
示例#25
0
bool read_ecdsa_public_key(meshlink_handle_t *mesh, connection_t *c) {
	if(ecdsa_active(c->ecdsa))
		return true;

	char *p;

	if(!c->config_tree) {
		init_configuration(&c->config_tree);
		if(!read_host_config(mesh, c->config_tree, c->name))
			return false;
	}

	/* First, check for simple ECDSAPublicKey statement */

	if(get_config_string(lookup_config(c->config_tree, "ECDSAPublicKey"), &p)) {
		c->ecdsa = ecdsa_set_base64_public_key(p);
		free(p);
		return c->ecdsa;
	}

	return false;
}
示例#26
0
bool node_read_devclass(meshlink_handle_t *mesh, node_t *n) {
	
	splay_tree_t *config_tree;
	char *p;

	init_configuration(&config_tree);
	if(!read_host_config(mesh, config_tree, n->name))
		goto exit;

	if(get_config_string(lookup_config(config_tree, "DeviceClass"), &p))
	{
		n->devclass = atoi(p);
		free(p);
	}

	if(n->devclass < 0 || n->devclass > _DEV_CLASS_MAX)
		{ n->devclass = _DEV_CLASS_MAX; }

exit:
	exit_configuration(&config_tree);
	return n->devclass != 0;
}
示例#27
0
bool node_read_ecdsa_public_key(meshlink_handle_t *mesh, node_t *n) {
	if(ecdsa_active(n->ecdsa))
		return true;

	splay_tree_t *config_tree;
	char *p;

	init_configuration(&config_tree);
	if(!read_host_config(mesh, config_tree, n->name))
		goto exit;

	/* First, check for simple ECDSAPublicKey statement */

	if(get_config_string(lookup_config(config_tree, "ECDSAPublicKey"), &p)) {
		n->ecdsa = ecdsa_set_base64_public_key(p);
		free(p);
	}

exit:
	exit_configuration(&config_tree);
	return n->ecdsa;
}
示例#28
0
/* mouse_init:
 *  Here we open the mouse device, initialise anything that needs it, 
 *  and chain to the framework init routine.
 */
static int mouse_init (void)
{
	char tmp1[128], tmp2[128], tmp3[128];
	AL_CONST char *udevice;

	/* Find the device filename */
	udevice = get_config_string (uconvert_ascii ("mouse", tmp1),
				     uconvert_ascii ("mouse_device", tmp2),
				     uconvert_ascii (DEVICE_FILENAME, tmp3));

	/* Open mouse device.  Devices are cool. */
	intdrv.device = open (uconvert_toascii (udevice, tmp1), O_RDONLY | O_NONBLOCK);
	if (intdrv.device < 0) {
		uszprintf (allegro_error, ALLEGRO_ERROR_SIZE, get_config_text ("Unable to open %s: %s"),
			   udevice, ustrerror (errno));
		return -1;
	}

	/* Discard any garbage, so the next thing we read is a packet header */
	sync_mouse (intdrv.device);

	return __al_linux_mouse_init (&intdrv);
}
示例#29
0
文件: conf.c 项目: cotodevel/SnemulDS
/* get_config_int:
 *  Reads an integer from the configuration file.
 */
int get_config_int(char *section, char *name, int def)
{
   CONFIG_HOOK *hook;
   char section_name[256];
   char *s;

   prettify_section_name(section, section_name);

   /* check for hooked sections */
   hook = config_hook;

   while (hook) {
      if (stricmp(section_name, hook->section) == 0) {
	 if (hook->intgetter) {
	    return hook->intgetter(name, def);
	 }
	 else if (hook->stringgetter) {
	    s = hook->stringgetter(name, NULL);
	    if ((s) && (*s))
	       return strtol(s, NULL, 0);
	    else
	       return def;
	 }
	 else
	    return def;
      }
      hook = hook->next;
   }

   /* read normal data */
   s = get_config_string(section_name, name, NULL);

   if ((s) && (*s))
      return strtol(s, NULL, 0);

   return def;
}
示例#30
0
void try_outgoing_connections(void) {
	static config_t *cfg = NULL;
	char *name;
	outgoing_t *outgoing;
	
	outgoing_list = list_alloc((list_action_t)free_outgoing);
			
	for(cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) {
		get_config_string(cfg, &name);

		if(!check_id(name)) {
			logger(LOG_ERR,
				   "Invalid name for outgoing connection in %s line %d",
				   cfg->file, cfg->line);
			free(name);
			continue;
		}

		outgoing = xmalloc_and_zero(sizeof(*outgoing));
		outgoing->name = name;
		list_insert_tail(outgoing_list, outgoing);
		setup_outgoing_connection(outgoing);
	}
}