コード例 #1
0
ファイル: panel.c プロジェクト: SpartanJ/bmpanel2
static int load_panel_theme(struct panel_theme *theme, struct config_format_tree *tree)
{
	CLEAR_STRUCT(theme);
	struct config_format_entry *e = find_config_format_entry(&tree->root, "panel");
	if (!e)
		return XERROR("Failed to find 'panel' section in theme format file");


	theme->position = PANEL_POSITION_TOP; /* default */
	const char *v = find_config_format_entry_value(e, "position");
	if (v)
		theme->position = parse_position(v);

	theme->background = parse_image_part_named("background", e, tree, 1);
	if (!theme->background)
		return -1;

	theme->separator = parse_image_part_named("separator", e, tree, 0);
	theme->transparent = parse_bool("transparent", e);
	theme->align = parse_align("align", e);
	theme->height = parse_int("height", e, -1);
	theme->width = parse_int_or_percents("width", e, -1,
					     &theme->width_in_percents);
	return 0;
}
コード例 #2
0
ファイル: softlist.cpp プロジェクト: marioaugustorama/mame
void softlist_parser::end_handler(void *data, const char *name)
{
	// reset the text destination and bump the position down
	softlist_parser *state = reinterpret_cast<softlist_parser *>(data);
	state->m_pos = parse_position(state->m_pos - 1);

	// switch off of the new position
	switch (state->m_pos)
	{
		case POS_ROOT:
			break;

		case POS_MAIN:
			state->m_current_info = nullptr;
			break;

		case POS_SOFT:
			state->parse_soft_end(name);
			state->m_current_part = nullptr;
			break;

		case POS_PART:
			break;

		case POS_DATA:
			break;
	}

	// stop accumulating
	state->m_data_accum_expected = false;
	state->m_data_accum.clear();
}
コード例 #3
0
ファイル: softlist.cpp プロジェクト: marioaugustorama/mame
void softlist_parser::start_handler(void *data, const char *tagname, const char **attributes)
{
	// switch off the current state
	softlist_parser *state = reinterpret_cast<softlist_parser *>(data);
	switch (state->m_pos)
	{
		case POS_ROOT:
			state->parse_root_start(tagname, attributes);
			break;

		case POS_MAIN:
			state->parse_main_start(tagname, attributes);
			break;

		case POS_SOFT:
			state->parse_soft_start(tagname, attributes);
			break;

		case POS_PART:
			state->parse_part_start(tagname, attributes);
			break;

		case POS_DATA:
			state->parse_data_start(tagname, attributes);
			break;
	}

	// increment the state since this is a tag start
	state->m_pos = parse_position(state->m_pos + 1);
}
コード例 #4
0
static int
_get_position_fb(void *self, char *filename)
{
    plugin_t *plugin = (plugin_t *) self;
    if(!plugin->cache)
        parse_position(&plugin->cache, filename,
                        plugin->state_file);
    return position_cache_find(plugin->cache, filename);
}
コード例 #5
0
ファイル: pvs.c プロジェクト: jff/mathspad
static void handle_pvs_loc(unsigned char *buffer)
{
  /* buffer contains "dir&file&place" */
  if (fields(buffer)==3 && pvs_open_pvs_files) {
    int sl,sc,el,ec;
    char filename[1024];
    if (field[0]!=NILstr) {
      strcpy(filename, field[0]);
    } else {
      filename[0]=0;
    }
    strcat(filename,field[1]);
    parse_position(field[2],sl,sc,el,ec);
    open_temporary_file(filename, filename, 0,sl);
  }
}
コード例 #6
0
ファイル: protocol.cpp プロジェクト: lazydroid/gambit-fruit
static void loop_step() {

   char string[65536];

   // read a line

   get(string,65536);

   // parse

   if (false) {

   } else if (string_start_with(string,"debug ")) {

      // dummy

   } else if (string_start_with(string,"go ")) {

      if (!Searching && !Delay) {
         init();
         parse_go(string);
      } else {
         ASSERT(false);
      }

   } else if (string_equal(string,"isready")) {

      if (!Searching && !Delay) {
         init();
      }

      send("readyok"); // no need to wait when searching (dixit SMK)

   } else if (string_equal(string,"ponderhit")) {

      if (Searching) {

         ASSERT(Infinite);

         SearchInput->infinite = false;
         Infinite = false;

      } else if (Delay) {

         send_best_move();
         Delay = false;

      } else {

         ASSERT(false);
      }

   } else if (string_start_with(string,"position ")) {

      if (!Searching && !Delay) {
         init();
         parse_position(string);
      } else {
         ASSERT(false);
      }

   } else if (string_equal(string,"quit")) {

      ASSERT(!Searching);
      ASSERT(!Delay);

      exit(EXIT_SUCCESS);

   } else if (string_start_with(string,"setoption ")) {

      if (!Searching && !Delay) {
         parse_setoption(string);
      } else {
         ASSERT(false);
      }

   } else if (string_equal(string,"stop")) {

      if (Searching) {

         SearchInfo->stop = true;
         Infinite = false;

      } else if (Delay) {

         send_best_move();
         Delay = false;
      }

   } else if (string_equal(string,"uci")) {

      ASSERT(!Searching);
      ASSERT(!Delay);

      send("id name Gambit Fruit " VERSION);
      send("id author Ryan Benitez, Thomas Gaksch and Fabien Letouzey");

      option_list();

      send("uciok");

   } else if (string_equal(string,"ucinewgame")) {

      if (!Searching && !Delay && Init) {
         trans_clear(Trans);
      } else {
         ASSERT(false);
      }
   }
}
コード例 #7
0
static bool
parse_command_line( int argc, char *argv[] )
{
    int n;

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

        if (strcmp (arg, "-h") == 0 || strcmp (arg, "--help") == 0) {
            print_usage (argv[0]);
            return false;
        }

        if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) {
            fprintf (stderr, "dfbg version %s\n", DIRECTFB_VERSION);
            return false;
        }

        if (strcmp (arg, "-T") == 0 || strcmp (arg, "--top-level") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_id( argv[n], &m_toplevel_id ))
                return false;

            continue;
        }

        if (strcmp (arg, "-W") == 0 || strcmp (arg, "--wait-at-end") == 0) {
            m_wait_at_end = DFB_TRUE;
            continue;
        }

        if (strcmp (arg, "-r") == 0 || strcmp (arg, "--run") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_test( argv[n], false ))
                return false;

            continue;
        }

        if (strcmp (arg, "-p") == 0 || strcmp (arg, "--pos") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_position( argv[n], &m_desc_top.posx, &m_desc_top.posy ))
                return false;

            continue;
        }

        if (strcmp (arg, "-s") == 0 || strcmp (arg, "--size") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_size( argv[n], &m_desc_top.width, &m_desc_top.height ))
                return false;

            continue;
        }

        if (strcmp (arg, "-f") == 0 || strcmp (arg, "--format") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_format( argv[n], &m_desc_top.pixelformat ))
                return false;

            continue;
        }

        if (strcmp (arg, "-c") == 0 || strcmp (arg, "--caps") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_caps( argv[n], &m_desc_top.caps ))
                return false;

            continue;
        }

        if (strcmp (arg, "-l") == 0 || strcmp (arg, "--color") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_color( argv[n], &m_topcolor.color ))
                return false;

            m_topcolor.valid = true;
            continue;
        }

        if (strcmp (arg, "-o") == 0 || strcmp (arg, "--option") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_option( argv[n], &m_desc_top.options ))
                return false;

            continue;
        }

        if (strcmp (arg, "-a") == 0 || strcmp (arg, "--associate") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_id( argv[n], &m_desc_top.parent_id ))
                return false;

//               m_desc_top.flags   |= DWDESC_PARENT;
            m_desc_top.options |= DWOP_FOLLOW_BOUNDS;

            continue;
        }

        if (strcmp (arg, "-R") == 0 || strcmp (arg, "--sub-run") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_test( argv[n], true ))
                return false;

            continue;
        }

        if (strcmp (arg, "-P") == 0 || strcmp (arg, "--sub-pos") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_position( argv[n], &m_desc_sub.posx, &m_desc_sub.posy ))
                return false;

            continue;
        }

        if (strcmp (arg, "-S") == 0 || strcmp (arg, "--sub-size") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_size( argv[n], &m_desc_sub.width, &m_desc_sub.height ))
                return false;

            continue;
        }

        if (strcmp (arg, "-F") == 0 || strcmp (arg, "--sub-format") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_format( argv[n], &m_desc_sub.pixelformat ))
                return false;

            continue;
        }

        if (strcmp (arg, "-C") == 0 || strcmp (arg, "--sub-caps") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_caps( argv[n], &m_desc_sub.caps ))
                return false;

            continue;
        }

        if (strcmp (arg, "-L") == 0 || strcmp (arg, "--sub-color") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_color( argv[n], &m_subcolor.color ))
                return false;

            m_subcolor.valid = true;
            continue;
        }

        if (strcmp (arg, "-O") == 0 || strcmp (arg, "--sub-option") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_option( argv[n], &m_desc_sub.options ))
                return false;

            continue;
        }

        if (strcmp (arg, "-A") == 0 || strcmp (arg, "--sub-associate") == 0) {
            if (++n == argc) {
                print_usage (argv[0]);
                return false;
            }

            if (!parse_id( argv[n], &m_desc_sub.parent_id ))
                return false;

//               m_desc_sub.flags   |= DWDESC_PARENT;
            m_desc_sub.options |= DWOP_FOLLOW_BOUNDS;

            continue;
        }

        print_usage (argv[0]);

        return false;
    }

    return true;
}
コード例 #8
0
void loop_step(const char * input) {

   char string[65536];
   char buffer[256];

   // read a line

   if (input != NULL) {
      get_local(string,65536,input);
   } else {
      get_stdin(string,65536);
   }

   // parse

   if (false) {

   } else if (string_start_with(string,"debug ")) {

      if (!Searching) {
         parse_debug(string);
      } else {
         ASSERT(false);
      }

   } else if (string_start_with(string,"go ")) {

      if (!Searching && !Delay) {
         init();
         parse_go(string);
      } else {
         ASSERT(false);
      }

   } else if (string_equal(string,"isready")) {

      if (!Searching && !Delay) {
         init();
      }

      send("readyok"); // no need to wait when searching (fixit SMK)

   } else if (string_equal(string,"ponderhit")) {

      if (Searching) {

         ASSERT(Infinite);

         SearchInput->infinite = false;
         Infinite = false;

      } else if (Delay) {

         send_best_move();
         Delay = false;

      } else {

         ASSERT(false);
      }

   } else if (string_start_with(string,"position ")) {

      if (!Searching && !Delay) {
         init();
         parse_position(string);
      } else {
         ASSERT(false);
      }

   } else if (string_equal(string,"quit")) {

      ASSERT(!Searching); // violated by Arena UI
      ASSERT(!Delay);

      if (Searching && option_get_int("Threads") > 1) {

         // Arena issue

         SearchInfo->stop = true;
         Infinite = false;

         smp_sleep();
      }

      trans_free();
      tb_close();
      egbb_close();
      smp_close();

      exit(EXIT_SUCCESS);

   } else if (string_start_with(string,"setoption ")) {

      if (!Searching && !Delay) {
         parse_setoption(string);
      } else {
         ASSERT(false);
      }

   } else if (string_equal(string,"stop")) {

      if (Searching) {

         SearchInfo->stop = true;
         Infinite = false;

      } else if (Delay) {

         send_best_move();
         Delay = false;
      }

   } else if (string_equal(string,"uci")) {

      ASSERT(!Searching);
      ASSERT(!Delay);

      send("id name Fruit reloaded %s", my_version(buffer));
      send("id author Fabien Letouzey, Ryan Benitez and Daniel Mehrmann");

      option_list();

      send("uciok");

   } else if (string_equal(string,"ucinewgame")) {

      if (!Searching && !Delay && Init) {
         trans_clear();
         pawn_clear();
         material_clear();
      } else {
         ASSERT(false);
      }
   }
}
コード例 #9
0
ファイル: ipc.c プロジェクト: Hummer12007/sway
static void ipc_parse_config(struct config *config, const char *payload) {
	json_object *bar_config = json_tokener_parse(payload);
	json_object *markup, *mode, *hidden_bar, *position, *status_command;
	json_object *font, *bar_height, *wrap_scroll, *workspace_buttons, *strip_workspace_numbers;
	json_object *binding_mode_indicator, *verbose, *colors, *sep_symbol, *outputs;
#ifdef ENABLE_TRAY
	json_object *tray_output, *icon_theme, *tray_padding, *activate_button, *context_button;
	json_object *secondary_button;
	json_object_object_get_ex(bar_config, "tray_output", &tray_output);
	json_object_object_get_ex(bar_config, "icon_theme", &icon_theme);
	json_object_object_get_ex(bar_config, "tray_padding", &tray_padding);
	json_object_object_get_ex(bar_config, "activate_button", &activate_button);
	json_object_object_get_ex(bar_config, "context_button", &context_button);
	json_object_object_get_ex(bar_config, "secondary_button", &secondary_button);
#endif
	json_object_object_get_ex(bar_config, "mode", &mode);
	json_object_object_get_ex(bar_config, "hidden_bar", &hidden_bar);
	json_object_object_get_ex(bar_config, "position", &position);
	json_object_object_get_ex(bar_config, "status_command", &status_command);
	json_object_object_get_ex(bar_config, "font", &font);
	json_object_object_get_ex(bar_config, "bar_height", &bar_height);
	json_object_object_get_ex(bar_config, "wrap_scroll", &wrap_scroll);
	json_object_object_get_ex(bar_config, "workspace_buttons", &workspace_buttons);
	json_object_object_get_ex(bar_config, "strip_workspace_numbers", &strip_workspace_numbers);
	json_object_object_get_ex(bar_config, "binding_mode_indicator", &binding_mode_indicator);
	json_object_object_get_ex(bar_config, "verbose", &verbose);
	json_object_object_get_ex(bar_config, "separator_symbol", &sep_symbol);
	json_object_object_get_ex(bar_config, "colors", &colors);
	json_object_object_get_ex(bar_config, "outputs", &outputs);
	json_object_object_get_ex(bar_config, "pango_markup", &markup);

	if (status_command) {
		free(config->status_command);
		config->status_command = strdup(json_object_get_string(status_command));
	}

	if (position) {
		config->position = parse_position(json_object_get_string(position));
	}

	if (font) {
		free(config->font);
		config->font = parse_font(json_object_get_string(font));
	}

	if (sep_symbol) {
		free(config->sep_symbol);
		config->sep_symbol = strdup(json_object_get_string(sep_symbol));
	}

	if (strip_workspace_numbers) {
		config->strip_workspace_numbers = json_object_get_boolean(strip_workspace_numbers);
	}

	if (binding_mode_indicator) {
		config->binding_mode_indicator = json_object_get_boolean(binding_mode_indicator);
	}

	if (wrap_scroll) {
		config->wrap_scroll = json_object_get_boolean(wrap_scroll);
	}

	if (workspace_buttons) {
		config->workspace_buttons = json_object_get_boolean(workspace_buttons);
	}

	if (bar_height) {
		config->height = json_object_get_int(bar_height);
	}

	if (markup) {
		config->pango_markup = json_object_get_boolean(markup);
	}

#ifdef ENABLE_TRAY
	if (tray_output) {
		free(config->tray_output);
		config->tray_output = strdup(json_object_get_string(tray_output));
	}

	if (icon_theme) {
		free(config->icon_theme);
		config->icon_theme = strdup(json_object_get_string(icon_theme));
	}

	if (tray_padding) {
		config->tray_padding = json_object_get_int(tray_padding);
	}

	if (activate_button) {
		config->activate_button = json_object_get_int(activate_button);
	}

	if (context_button) {
		config->context_button = json_object_get_int(context_button);
	}

	if (secondary_button) {
		config->secondary_button = json_object_get_int(secondary_button);
	}
#endif

	// free previous outputs list
	int i;
	for (i = 0; i < config->outputs->length; ++i) {
		free(config->outputs->items[i]);
	}
	list_free(config->outputs);
	config->outputs = create_list();

	if (outputs) {
		int length = json_object_array_length(outputs);
		json_object *output;
		const char *output_str;
		for (i = 0; i < length; ++i) {
			output = json_object_array_get_idx(outputs, i);
			output_str = json_object_get_string(output);
			if (strcmp("*", output_str) == 0) {
				config->all_outputs = true;
				break;
			}
			list_add(config->outputs, strdup(output_str));
		}
	} else {
		config->all_outputs = true;
	}

	if (colors) {
		json_object *background, *statusline, *separator;
		json_object *focused_background, *focused_statusline, *focused_separator;
		json_object *focused_workspace_border, *focused_workspace_bg, *focused_workspace_text;
		json_object *inactive_workspace_border, *inactive_workspace_bg, *inactive_workspace_text;
		json_object *active_workspace_border, *active_workspace_bg, *active_workspace_text;
		json_object *urgent_workspace_border, *urgent_workspace_bg, *urgent_workspace_text;
		json_object *binding_mode_border, *binding_mode_bg, *binding_mode_text;
		json_object_object_get_ex(colors, "background", &background);
		json_object_object_get_ex(colors, "statusline", &statusline);
		json_object_object_get_ex(colors, "separator", &separator);
		json_object_object_get_ex(colors, "focused_background", &focused_background);
		json_object_object_get_ex(colors, "focused_statusline", &focused_statusline);
		json_object_object_get_ex(colors, "focused_separator", &focused_separator);
		json_object_object_get_ex(colors, "focused_workspace_border", &focused_workspace_border);
		json_object_object_get_ex(colors, "focused_workspace_bg", &focused_workspace_bg);
		json_object_object_get_ex(colors, "focused_workspace_text", &focused_workspace_text);
		json_object_object_get_ex(colors, "active_workspace_border", &active_workspace_border);
		json_object_object_get_ex(colors, "active_workspace_bg", &active_workspace_bg);
		json_object_object_get_ex(colors, "active_workspace_text", &active_workspace_text);
		json_object_object_get_ex(colors, "inactive_workspace_border", &inactive_workspace_border);
		json_object_object_get_ex(colors, "inactive_workspace_bg", &inactive_workspace_bg);
		json_object_object_get_ex(colors, "inactive_workspace_text", &inactive_workspace_text);
		json_object_object_get_ex(colors, "urgent_workspace_border", &urgent_workspace_border);
		json_object_object_get_ex(colors, "urgent_workspace_bg", &urgent_workspace_bg);
		json_object_object_get_ex(colors, "urgent_workspace_text", &urgent_workspace_text);
		json_object_object_get_ex(colors, "binding_mode_border", &binding_mode_border);
		json_object_object_get_ex(colors, "binding_mode_bg", &binding_mode_bg);
		json_object_object_get_ex(colors, "binding_mode_text", &binding_mode_text);
		if (background) {
			config->colors.background = parse_color(json_object_get_string(background));
		}

		if (statusline) {
			config->colors.statusline = parse_color(json_object_get_string(statusline));
		}

		if (separator) {
			config->colors.separator = parse_color(json_object_get_string(separator));
		}

		if (focused_background) {
			config->colors.focused_background = parse_color(json_object_get_string(focused_background));
		}

		if (focused_statusline) {
			config->colors.focused_statusline = parse_color(json_object_get_string(focused_statusline));
		}

		if (focused_separator) {
			config->colors.focused_separator = parse_color(json_object_get_string(focused_separator));
		}

		if (focused_workspace_border) {
			config->colors.focused_workspace.border = parse_color(json_object_get_string(focused_workspace_border));
		}

		if (focused_workspace_bg) {
			config->colors.focused_workspace.background = parse_color(json_object_get_string(focused_workspace_bg));
		}

		if (focused_workspace_text) {
			config->colors.focused_workspace.text = parse_color(json_object_get_string(focused_workspace_text));
		}

		if (active_workspace_border) {
			config->colors.active_workspace.border = parse_color(json_object_get_string(active_workspace_border));
		}

		if (active_workspace_bg) {
			config->colors.active_workspace.background = parse_color(json_object_get_string(active_workspace_bg));
		}

		if (active_workspace_text) {
			config->colors.active_workspace.text = parse_color(json_object_get_string(active_workspace_text));
		}

		if (inactive_workspace_border) {
			config->colors.inactive_workspace.border = parse_color(json_object_get_string(inactive_workspace_border));
		}

		if (inactive_workspace_bg) {
			config->colors.inactive_workspace.background = parse_color(json_object_get_string(inactive_workspace_bg));
		}

		if (inactive_workspace_text) {
			config->colors.inactive_workspace.text = parse_color(json_object_get_string(inactive_workspace_text));
		}

		if (binding_mode_border) {
			config->colors.binding_mode.border = parse_color(json_object_get_string(binding_mode_border));
		}

		if (binding_mode_bg) {
			config->colors.binding_mode.background = parse_color(json_object_get_string(binding_mode_bg));
		}

		if (binding_mode_text) {
			config->colors.binding_mode.text = parse_color(json_object_get_string(binding_mode_text));
		}
	}

	json_object_put(bar_config);
}