InputModelSetting * InputModelSettings::CloneSetting(Messager & messager, InputModelSetting * current_setting, SettingInfo & setting_info) const
	{

		try
		{

			switch (setting_info.setting_class)
			{

#define G_(Y) S_PATH_TO_MODEL_DATABASE##Y
					INPUT_MODEL_CLONE_SETTING__STRING(G_(__2), G_(__5))
#undef G_

				default:
					{
						boost::format msg("Unknown input model backend setting \"%1%\" (\"%2%\") being requested.");
						msg % setting_info.text % setting_info.setting_class;
						messager.AppendMessage(new MessagerWarningMessage(MESSAGER_MESSAGE__INVALID_SETTING_INFO_OBJECT, msg.str()));
					}
					break;

			}

		}
		catch (std::bad_cast & e)
		{
			boost::format msg("Unable to retrieve setting \"%1%\" (\"%2%\"): %3%.");
			msg % setting_info.text % setting_info.setting_class % e.what();
			messager.AppendMessage(new MessagerWarningMessage(MESSAGER_MESSAGE__INVALID_SETTING_INFO_OBJECT, msg.str()));
		}

		return NULL;

	}
Esempio n. 2
0
static void *on_target_key(oop_source *oop,struct gale_key *key,void *x) {
	struct unpack * const ctx = (struct unpack *) x;
	const struct gale_key_assertion * const ass = gale_key_private(key);
	if (0 == ctx->target_count) return OOP_CONTINUE;

	if (NULL != ass
	&&  gale_crypto_open(gale_key_data(ass),&ctx->message->data)) {
		ctx->target_count = 0;
		return on_unsealed(oop,OOP_TIME_NOW,ctx);
	}

	if (0 == --ctx->target_count) {
		const struct gale_text *target;
                struct gale_text err = null_text;
                for (target = gale_crypto_target(ctx->message->data);
		     NULL != target && 0 != target->l; ++target)
                        err = gale_text_concat(3,err,
                                (0 == err.l ? G_(" to ") : G_(", ")),*target);
	        gale_alert(GALE_WARNING,gale_text_concat(2,
                            G_("can't decrypt message"),err),0);
	        return on_unsealed(oop,OOP_TIME_NOW,ctx);
        }

        return OOP_CONTINUE;
}
Esempio n. 3
0
int Rgui_Edit(const char *filename, int enc, const char *title,
	      int modal)
{
    editor c;
    EditorData p;

    if (neditors == MAXNEDITORS) {
	R_ShowMessage(G_("Maximum number of editors reached"));
	return 1;
    }
    c = neweditor();
    if (!c) {
	R_ShowMessage(G_("Unable to create editor window"));
	return 1;
    }
    if (strlen(filename) > 0) {
	editor_load_file(c, filename, enc);
	editor_set_title(c, title);
    }
    else {
	editor_set_title(c, G_("Untitled"));
    }
    show(c);

    p = getdata(getdata(c));
    p->stealconsole = modal;
    if (modal) {
	fix_editor_up = TRUE;
	eventloop(c);
    }
    return 0;
}
	SettingInfo BackendModelInputSetting::GetSettingInfoFromEnum(Messager & messager, int const value__)
	{

		INPUT_MODEL_SETTINGS_NAMESPACE::INPUT_MODEL_SETTINGS const value_ = static_cast<INPUT_MODEL_SETTINGS_NAMESPACE::INPUT_MODEL_SETTINGS const>(value__);

#undef G_

		switch (value_)
		{

#define G_(Y) S_PATH_TO_MODEL_DATABASE##Y
				GET_INPUT_MODEL_SETTING_INFO(G_(__1), G_(__2), G_(__3), G_(__4))
#undef G_

			default:
				{
					boost::format msg("Settings information is not available for INPUT_MODEL_SETTINGS_NAMESPACE::INPUT_MODEL_SETTINGS value %1%.  Using empty setting.");
					msg % value_;
					messager.AppendMessage(new MessagerWarningMessage(MESSAGER_MESSAGE__INVALID_SETTING_ENUM_VALUE, msg.str()));
				}

		}

		return SettingInfo();

	}
	void InputModelSettings::SetPTreeEntry(Messager & messager, INPUT_MODEL_SETTINGS_NAMESPACE::INPUT_MODEL_SETTINGS which_setting, boost::property_tree::ptree & pt)
	{

		SettingsMap::const_iterator theSetting = _settings_map.find(which_setting);

		if (theSetting == _settings_map.cend())
		{
			return;
		}

		SettingInfo setting_info = SettingInfoObject.GetSettingInfoFromEnum(messager, which_setting);

		switch (setting_info.setting_class)
		{

#define G_(Y) S_PATH_TO_MODEL_DATABASE##Y
				INPUT_MODEL_SET_PTREE_ENTRY__STRING(G_(__2), G_(__5))
#undef G_

			default:
				{
					boost::format msg("Unknown input model backend setting \"%1%\" (\"%2%\") being set.");
					msg % setting_info.text % setting_info.setting_class;
					messager.AppendMessage(new MessagerWarningMessage(MESSAGER_MESSAGE__INVALID_SETTING_INFO_OBJECT, msg.str()));
				}
				break;

		}

	}
Esempio n. 6
0
PROTECTED
void handle_findreplace(HWND hwnd, LPFINDREPLACE pfr)
{
    CHARRANGE sel;
    int matchcase=0, wholeword=0, down=0;
    char buf[100];
    if (pfr->Flags & FR_MATCHCASE) matchcase = 1;
    if (pfr->Flags & FR_WHOLEWORD) wholeword = 1;
    if (pfr->Flags & FR_DOWN) down = 1;

    if (pfr->Flags & FR_FINDNEXT) {
	if (!richeditfind(hwnd, pfr->lpstrFindWhat, matchcase, wholeword, down)) {
	    snprintf(buf, 100, G_("\"%s\" not found"), pfr->lpstrFindWhat);
	    askok(buf);
	}
    }
    else if (pfr->Flags & FR_REPLACE) {
	if (!richeditreplace(hwnd, pfr->lpstrFindWhat, pfr->lpstrReplaceWith, matchcase, wholeword, down)) {
	    snprintf(buf, 100, G_("\"%s\" not found"), pfr->lpstrFindWhat);
	    askok(buf);
	}
    }
    else if (pfr->Flags & FR_REPLACEALL) {
	/* replace all in the whole buffer then return to original selection state */
	sendmessage (hwnd, EM_EXGETSEL, 0, &sel) ;
	sendmessage (hwnd, EM_SETSEL, 0, 0) ;
	while ( richeditreplace(hwnd, pfr->lpstrFindWhat, pfr->lpstrReplaceWith, matchcase, wholeword, down) ) ;
	sendmessage (hwnd, EM_EXSETSEL, 0, &sel) ;
    }

    else if (pfr->Flags & FR_DIALOGTERM)
	hModelessDlg = NULL;
}
Esempio n. 7
0
static void
warn_ref_binding (tree reftype, tree intype, tree decl)
{
  tree ttl = TREE_TYPE (reftype);

  if (!CP_TYPE_CONST_NON_VOLATILE_P (ttl))
    {
      const char *msg;

      if (CP_TYPE_VOLATILE_P (ttl) && decl)
	msg = G_("initialization of volatile reference type %q#T from "
	         "rvalue of type %qT");
      else if (CP_TYPE_VOLATILE_P (ttl))
	msg = G_("conversion to volatile reference type %q#T "
	         "from rvalue of type %qT");
      else if (decl)
	msg = G_("initialization of non-const reference type %q#T from "
	         "rvalue of type %qT");
      else
	msg = G_("conversion to non-const reference type %q#T from "
	         "rvalue of type %qT");

      permerror (input_location, msg, reftype, intype);
    }
}
Esempio n. 8
0
int copystringtoclipboard(char *str)
{
    HGLOBAL hglb;
    char *s;
    int ll = strlen(str) + 1;

    if (!(hglb = GlobalAlloc(GHND, ll))){
        R_ShowMessage(G_("Insufficient memory: cell not copied to the clipboard"));
	return 1;
    }
    if (!(s = (char *)GlobalLock(hglb))){
        R_ShowMessage(G_("Insufficient memory: cell not copied to the clipboard"));
	return 1;
    }
    strcpy(s, str);
    GlobalUnlock(hglb);
    if (!OpenClipboard(NULL) || !EmptyClipboard()) {
        R_ShowMessage(G_("Unable to open the clipboard"));
        GlobalFree(hglb);
        return 1;
    }
    SetClipboardData(CF_TEXT, hglb);
    CloseClipboard();
    return 0;
}
Esempio n. 9
0
/* FIXME: only one level of sub-menu - no checks -*/
static int addmenuitemarray(menu m,MenuItem a[])
{
    menu ma  = m;
    int i = 0;
    while (a[i].nm) {
	if (!strcmp(a[i].nm,"@STARTMENU")) {
	    i += 1;
	    ma = newsubmenu(m, G_(a[i].nm));
	}
	else if (!strcmp(a[i].nm,"@ENDMENU")) {
	    i += 1;
	    ma = m;
	}
	else if (!strcmp(a[i].nm,"@STARTSUBMENU")) {
	    i += 1;
	    newsubmenu(ma,a[i].nm);
	}
	else if (!strcmp(a[i].nm,"@ENDSUBMENU")) {
	    i += 1;
	}
	else if (!strcmp(a[i].nm,"@MDIMENU")) {
	    if (!(a[i].m = newmdimenu())) return 0;
	    ma = a[i].m;
	}
	else {
	    if (!(a[i].m = newmenuitem(G_(a[i].nm), a[i].key, a[i].fn))) return 0;
	}
	i += 1;
    }
    return 1;
}
Esempio n. 10
0
int
plugin_init (struct plugin_name_args *plugin_info,
             struct plugin_gcc_version *version)
{
  struct plugin_pass pass_info;
  const char *plugin_name = plugin_info->base_name;
  int argc = plugin_info->argc;
  struct plugin_argument *argv = plugin_info->argv;
  char *ref_pass_name = NULL;
  int ref_instance_number = 0;
  int i;

  /* Process the plugin arguments. This plugin takes the following arguments:
     ref-pass-name=<PASS_NAME> and ref-pass-instance-num=<NUM>.  */
  for (i = 0; i < argc; ++i)
    {
      if (!strcmp (argv[i].key, "ref-pass-name"))
        {
          if (argv[i].value)
            ref_pass_name = argv[i].value;
          else
            warning (0, G_("option '-fplugin-arg-%s-ref-pass-name'"
                           " requires a pass name"), plugin_name);
        }
      else if (!strcmp (argv[i].key, "ref-pass-instance-num"))
        {
          if (argv[i].value)
            ref_instance_number = strtol (argv[i].value, NULL, 0);
          else
            warning (0, G_("option '-fplugin-arg-%s-ref-pass-instance-num'"
                           " requires an integer value"), plugin_name);
        }
      else
        warning (0, G_("plugin %qs: unrecognized argument %qs ignored"),
                 plugin_name, argv[i].key);
    }

  if (!ref_pass_name)
    {
      error (G_("plugin %qs requires a reference pass name"), plugin_name);
      return 1;
    }

  pass_info.pass = &pass_dumb_plugin_example.pass;
  pass_info.reference_pass_name = ref_pass_name;
  pass_info.ref_pass_instance_number = ref_instance_number;
  pass_info.pos_op = PASS_POS_INSERT_AFTER;

  register_callback (plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);

  register_callback (plugin_name, PLUGIN_FINISH_TYPE, handle_struct, NULL);

  register_callback (plugin_name, PLUGIN_CXX_CP_PRE_GENERICIZE,
                     handle_pre_generic, NULL);

  register_callback (plugin_name, PLUGIN_FINISH_UNIT,
                     handle_end_of_compilation_unit, NULL);
  return 0;
}
Esempio n. 11
0
File: pager.c Progetto: edzer/cxxr
/*
   To be fixed: during creation, memory is allocated two times
   (faster for small files but a big waste otherwise)
*/
static xbuf file2xbuf(const char *name, int enc, int del)
{
    HANDLE f;
    DWORD rr, vv;
    char *p;
    xlong dim, cnt;
    xint  ms;
    xbuf  xb;
    wchar_t *wp, *q;

    if (enc == CE_UTF8) {
	wchar_t wfn[MAX_PATH+1];
	Rf_utf8towcs(wfn, name, MAX_PATH+1);
	f = CreateFileW(wfn, GENERIC_READ, FILE_SHARE_READ,
			NULL, OPEN_EXISTING, 0, NULL);
    } else
	f = CreateFile(name, GENERIC_READ, FILE_SHARE_READ,
		       NULL, OPEN_EXISTING, 0, NULL);
    if (f == INVALID_HANDLE_VALUE) {
	R_ShowMessage(G_("Error opening file"));
	return NULL;
    }
    vv = GetFileSize(f, NULL);
    p = (char *) malloc((size_t) vv + 1);
    if (!p) {
	CloseHandle(f);
	R_ShowMessage(G_("Insufficient memory to display file in internal pager"));
	return NULL;
    }
    ReadFile(f, p, vv, &rr, NULL);
    CloseHandle(f);
    if (del) DeleteFile(name);
    p[rr] = '\0';
    cnt = mbstowcs(NULL, p, 0);
    wp = (wchar_t *) malloc((cnt+1) * sizeof(wchar_t));
    mbstowcs(wp, p, cnt+1);
    for (q = wp, ms = 1, dim = cnt; *q; q++) {
	if (*q == '\t')
	    dim += TABSIZE;
	else if (*q == '\n') {
	    dim++;
	    ms++;
	}
    }
    free(p);
    if ((xb = newxbuf(dim + 1, ms + 1, 1)))
	for (q = wp, ms = 0; *q; q++) {
	    if (*q == L'\r') continue;
	    if (*q == L'\n') {
		ms++;
		xbufaddxc(xb, *q);
		/* next line interprets underlining in help files */
		if (q[1] ==  L'_' && q[2] == L'\b') xb->user[ms] = -2;
	    } else xbufaddxc(xb, *q);
	}
    free(wp);
    return xb;
}
Esempio n. 12
0
File: rui.c Progetto: Maxsl/r-source
menuItems *wingetmenuitems(const char *mname, char *errmsg) {
    menuItems *items;
    char mitem[1002], *p, *q, *r;
    int i,j = 0;

    q = (char *)malloc(1000 * sizeof(char));
    r = (char *)malloc(1000 * sizeof(char));

    if (strlen(mname) > 1000) {
	strcpy(errmsg, G_("'mname' is limited to 1000 bytes"));
	return NULL;
    }

    items = (menuItems *)malloc(sizeof(menuItems));
    if(nitems > 0)
	items->mItems = (Uitem *)malloc(alloc_items * sizeof(Uitem));

    strcpy(mitem, mname); strcat(mitem, "/");

    for (i = 0; i < nitems; i++) {
	p = strstr(umitems[i]->name, mitem);

	if (p == NULL)
	    continue;
	/* the 'mitem' pattern might be showing up */
	/* as a substring in another valid name.  Make sure */
	/* this isn't the case */
	if (strlen(p) != strlen(umitems[i]->name))
	    continue;

	strcpy(q, p+strlen(mitem));
	/* Due to the way menu items are stored, it can't be */
	/* determined if this is say item 'foo' from menu 'Blah/bar' */
	/* or item 'bar/foo' from menu 'Blah'.  Check this manually */
	/* by adding the item label to the menu we're looking for. */
	snprintf(r, 1000, "%s%s", mitem, umitems[i]->m->text);
	if (strcmp(r, p) != 0)
	    continue;

	items->mItems[j] = (Uitem)malloc(sizeof(uitem));
	items->mItems[j]->name = (char *)malloc((strlen(q) + 1) * sizeof(char));
	items->mItems[j]->action = (char *)malloc((strlen(umitems[i]->action) + 1) * sizeof(char));

	strcpy(items->mItems[j]->name, q);
	strcpy(items->mItems[j]->action, umitems[i]->action);
	j++;
    }
    free(q);
    free(r);

    items->numItems = j;
    if (j == 0) sprintf(errmsg, G_("menu %s does not exist"), mname);

    return(items);
}
Esempio n. 13
0
__visible int plugin_init(struct plugin_name_args *plugin_info,
			  struct plugin_gcc_version *version)
{
	const char * const plugin_name = plugin_info->base_name;
	const int argc = plugin_info->argc;
	const struct plugin_argument *argv = plugin_info->argv;
	int tso = 0;
	int i;

	if (!plugin_default_version_check(version, &gcc_version)) {
		error(G_("incompatible gcc/plugin versions"));
		return 1;
	}

	for (i = 0; i < argc; ++i) {
		if (!strcmp(argv[i].key, "disable"))
			return 0;

		/* all remaining options require a value */
		if (!argv[i].value) {
			error(G_("no value supplied for option '-fplugin-arg-%s-%s'"),
			      plugin_name, argv[i].key);
			return 1;
		}

		if (!strcmp(argv[i].key, "tso")) {
			tso = atoi(argv[i].value);
			continue;
		}

		if (!strcmp(argv[i].key, "offset")) {
			canary_offset = atoi(argv[i].value);
			continue;
		}
		error(G_("unknown option '-fplugin-arg-%s-%s'"),
		      plugin_name, argv[i].key);
		return 1;
	}

	/* create the mask that produces the base of the stack */
	sp_mask = ~((1U << (12 + tso)) - 1);

	PASS_INFO(arm_pertask_ssp_rtl, "expand", 1, PASS_POS_INSERT_AFTER);

	register_callback(plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP,
			  NULL, &arm_pertask_ssp_rtl_pass_info);

#if BUILDING_GCC_VERSION >= 9000
	register_callback(plugin_info->base_name, PLUGIN_START_UNIT,
			  arm_pertask_ssp_start_unit, NULL);
#endif

	return 0;
}
Esempio n. 14
0
static void follow_key(oop_source *oop,const struct find *find) {
	struct find *next;
	struct gale_fragment frag;
	struct gale_location *base;
	struct gale_text name = gale_key_name(find->loc->key);
	struct gale_data name_data = gale_text_as_data(name);

	assert(NULL != find->func && find->is_found);

	if (!gale_group_lookup(
		gale_key_data(gale_key_public(find->loc->key,find->now)),
		G_("key.redirect"),frag_text,&frag)
	|| (NULL != find->map && NULL != gale_map_find(find->map,name_data)))
	{
		key_i_graph(oop,
			find->loc->key,
			find->flags,
			G_("key.member"),
			on_graph,(void *) find);
		return;
	}

	gale_create(next);
	*next = *find;
	next->count = 0;
	next->is_found = 0;

	if (NULL == next->map) next->map = gale_make_map(0);
	gale_map_add(next->map,name_data,find->loc->key);

	base = client_i_get(gale_key_name(find->loc->key));
	next->loc = client_i_get(frag.value.text);
	if (base != find->loc) {
		assert(base->at_part <= find->loc->at_part
		    && base->at_part > 0 && !gale_text_compare(
			G_("*"),
			base->parts[base->at_part - 1]));

		next->loc = client_i_get(gale_text_concat(4,
			gale_text_concat_array(
				next->loc->at_part,
				next->loc->parts),
			G_("."),
			gale_text_concat_array(
				find->loc->at_part - base->at_part + 1,
				find->loc->parts + base->at_part - 1),
			gale_text_concat_array(
				next->loc->part_count - next->loc->at_part,
				next->loc->parts + next->loc->at_part)));
	}

	find_key(oop,next);
}
Esempio n. 15
0
menu newmdimenu()
{
    menu m ;
    if (!ismdi()) return NULL;
    m = newmenu(G_("Windows"));
    setvalue(newmenuitem(G_("Cascade"),0,mdimenu),1);
    setvalue(newmenuitem(G_("Tile &Horizontally"),0,mdimenu),2);
    setvalue(newmenuitem(G_("Tile &Vertically"),0,mdimenu),3);
    setvalue(newmenuitem(G_("Arrange Icons"),0,mdimenu),4);
    current_menubar->menubar = m;
    return m;
}
Esempio n. 16
0
static struct gale_encoding *get_charset(
	struct gale_text name,
	struct gale_encoding *fallback) 
{
	const struct gale_text enc = gale_var(name);
	struct gale_encoding * const ret = gale_make_encoding(enc);
	if (NULL == ret && 0 != enc.l)
		gale_alert(GALE_WARNING,gale_text_concat(4,
			G_("unknown encoding \""),enc,
			G_("\" for "),name),0);

	return ret ? ret : fallback;
}
Esempio n. 17
0
File: rui.c Progetto: Maxsl/r-source
int winaddmenu(const char *name, char *errmsg)
{
    const char *submenu = name;
    char *p, start[501];
    menu parent;

    if (getMenu(name))
	return 0;	/* Don't add repeats */

    if (nmenus >= alloc_menus) {
	if(alloc_menus <= 0) {
	    alloc_menus = 10;
	    usermenus = (menu *) malloc(sizeof(menu) * alloc_menus);
	    usermenunames = (char **) malloc(sizeof(char *) * alloc_menus);
	} else {
	    alloc_menus += 10;
	    usermenus = (menu *) realloc(usermenus, sizeof(menu) * alloc_menus);
	    usermenunames = (char **) realloc(usermenunames,
					      sizeof(char *) * alloc_menus);
	}
    }
    if (strlen(name) > 500) {
	strcpy(errmsg, G_("'menu' is limited to 500 bytes"));
	return 5;
    }
    p = Rf_strrchr(name, '/');
    if (p) {
	submenu = p + 1;
	strcpy(start, name);
	*Rf_strrchr(start, '/') = '\0';
	parent = getMenu(start);
	if (!parent) {
	    strcpy(errmsg, G_("base menu does not exist"));
	    return 3;
	}
	m = newsubmenu(parent, submenu);
    } else {
	addto(RMenuBar);
	m = newmenu(submenu);
    }
    if (m) {
	usermenus[nmenus] = m;
	usermenunames[nmenus] = strdup(name);
	nmenus++;
	show(RConsole);
	return 0;
    } else {
	strcpy(errmsg, G_("failed to allocate menu"));
	return 1;
    }
}
Esempio n. 18
0
static void editor_set_title(editor c, const char *title)
{
    char wtitle[EDITORMAXTITLE+1];
    textbox t = getdata(c);
    EditorData p = getdata(t);
    strncpy(wtitle, title, EDITORMAXTITLE);
    wtitle[EDITORMAXTITLE] = '\0';
    strcpy(p->title, wtitle);
    if (strlen(wtitle) + strlen(G_("R Editor")) + 3 < EDITORMAXTITLE) {
	strcat(wtitle, " - ");
	strcat(wtitle, G_("R Editor"));
    }
    settext(c, wtitle);
}
Esempio n. 19
0
/** Extract the public components of a key.
 *  \param key A key which may contain private data.
 *  \return The same key with all private data expunged.
 *  \sa gale_crypto_generate() */
struct gale_group gale_crypto_public(struct gale_group key) {
	struct gale_group filtered = key;
	while (!gale_group_null(key)) {
		struct gale_fragment frag = gale_group_first(key);
		key = gale_group_rest(key);

		if (gale_text_compare(G_("rsa.private"),frag.name) <= 0
		&&  gale_text_compare(G_("rsa.private.~"),frag.name) > 0) {
			gale_group_remove(&filtered,frag.name,frag.type);
			key = filtered;
		}
	}

	return filtered;
}
Esempio n. 20
0
static struct gale_packet *cat_filter(struct gale_packet *msg,void *d) {
	struct directed *dir = (struct directed *) d;
	struct gale_packet *rewrite;
	struct gale_text cat = null_text;
	int do_transmit = 0;

	gale_create(rewrite);
	rewrite->routing = null_text;
	rewrite->content = msg->content;
	while (gale_text_token(msg->routing,':',&cat)) {
		struct gale_text base,host;
		int orig_flag;
		int flag = is_directed(cat,&orig_flag,&base,&host) && orig_flag
			&& !gale_text_compare(host,dir->host);
		base = category_escape(base,flag);
		do_transmit |= flag;
                rewrite->routing = 
			gale_text_concat(3,rewrite->routing,G_(":"),base);
        }

	if (!do_transmit) {
		gale_dprintf(5,"*** no positive categories; dropped message\n");
		return NULL;
	}

        /* strip leading colon */
        if (rewrite->routing.l > 0) 
		rewrite->routing = gale_text_right(rewrite->routing,-1);
	gale_dprintf(5,"*** \"%s\": rewrote categories to \"%s\"\n",
	             gale_text_to(gale_global->enc_console,dir->host),
	             gale_text_to(gale_global->enc_console,rewrite->routing));
	return rewrite;
}
Esempio n. 21
0
/** Low-level signature verification.
 *  \param key_count Number of keys in the \a keys array 
 *         and number fo signatures in the \a sigs array.
 *  \param keys Array of keys.  The keys must include public key data.
 *  \param sigs Array of signatures, as returned from gale_crypto_sign_raw().
 *  \param data Data to verify against signatures.
 *  \return Nonzero iff the all signatures are valid. */
int gale_crypto_verify_raw(int key_count,
        const struct gale_group *keys,
        const struct gale_data *sigs,
        struct gale_data data)
{
	int i,is_valid = 1;
	EVP_MD_CTX *context = EVP_MD_CTX_new();
	RSA *rsa;

	EVP_VerifyInit(context,EVP_md5());
	EVP_VerifyUpdate(context,data.p,data.l);
	for (i = 0; is_valid && i < key_count; ++i) {
		EVP_PKEY *key = EVP_PKEY_new();
		EVP_PKEY_assign_RSA(key,RSA_new());
		rsa = EVP_PKEY_get0_RSA(key);
		crypto_i_rsa(keys[i],rsa);
		if (!crypto_i_public_valid(rsa)) {
			gale_alert(GALE_WARNING,G_("invalid public key"),0);
			is_valid = 0;
			goto cleanup;
		}

		if (!EVP_VerifyFinal(context,sigs[i].p,sigs[i].l,key)) {
			crypto_i_error();
			is_valid = 0;
			goto cleanup;
		}

	cleanup:
		EVP_PKEY_free(key);
	}

	return is_valid;
}
Esempio n. 22
0
void askchangedir()
{
    char *s, msg[MAX_PATH + 40];

/* set cod to current directory */
    GetCurrentDirectory(MAX_PATH, cod);
    s = askcdstring(G_(" Change working directory to:"), cod);
    if (s && (SetCurrentDirectory(s) == FALSE)) {
	snprintf(msg, MAX_PATH + 40,
		 G_("Unable to set '%s' as working directory"), s);
	askok(msg);
    }
    /* in every case reset cod (to new directory if all went ok
       or to old since user may have edited it) */
    GetCurrentDirectory(MAX_PATH, cod);
}
Esempio n. 23
0
File: pager.c Progetto: edzer/cxxr
static void pagercopy(control m)
{
    control c = getdata(m);

    if (consolecancopy(c)) consolecopy(c);
    else R_ShowMessage(G_("No selection"));
}
Esempio n. 24
0
		int vertex_connectivity()
		{
			Graph_List<Edge_Flow<int> > G_(2*G.V(), false); // on double les sommets
			Graph_List<Edge>::iterator_all it(G);
			for(Edge *e = it.beg(); !it.end(); e = it.nxt())
				G_.insert(new Edge_Flow<>(G.V() + e->v(), e->w(), G_.V()*G_.V()));
			for(int i = 0; i < G.V(); i++)
				G_.insert(new Edge_Flow<>(i, G.V() + i, 1));
	
			int min_flow = -1;
			for(int s = G.V(); s < G_.V(); s++)
				for(int t = 0; t < G.V(); t++)
				{
					if(s == t) continue;
					Graph_List<Edge_Flow<int> >::iterator_all it(G_);
					for(Edge_Flow<int> *e = it.beg(); !it.end(); e = it.nxt())
						e->set_flow(0);

					//IO<Edge_Flow<int>, Graph_List<Edge_Flow<int> >>::show_capR(G_);
					NoNullCap<> noNull(G_.V(), t); 
					Fulkerson<int, Edge_Flow<> > ful(G_, noNull, s, t);
					ful(0);
					int flow = ful.get_outflow();
					//IO<Edge_Flow<int>, Graph_List<Edge_Flow<int> >>::show_flow(G_);
					if(min_flow == -1 || min_flow > flow)
						min_flow = flow;
					/*if(flow < 3)
						cout<<s<<"-"<<t<<endl;*/
				}
			return min_flow;
		}
Esempio n. 25
0
void
handle_struct (void *event_data, void *data)
{
  tree type = (tree) event_data;
  warning (0, G_("Process struct %s"),
           IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
}
Esempio n. 26
0
void
handle_pre_generic (void *event_data, void *data)
{
  tree fndecl = (tree) event_data;
  warning (0, G_("Before genericizing function %s"),
           IDENTIFIER_POINTER (DECL_NAME (fndecl)));
}
Esempio n. 27
0
void copytoclipboard(drawing sb)
{
    HBITMAP hbmpOldDest, hbmpNew;
    HDC     hdcSrc, hdcDest;
    rect r;

    r = getrect(sb);
    hdcSrc =  get_context((object)sb);
    hdcDest = CreateCompatibleDC(hdcSrc);

    hbmpNew = CreateCompatibleBitmap(hdcSrc, r.width, r.height);
    hbmpOldDest = SelectObject(hdcDest, hbmpNew);
    BitBlt(hdcDest, 0, 0, r.width, r.height, hdcSrc, 0, 0, SRCCOPY);
    SelectObject(hdcDest, hbmpOldDest);
    DeleteDC(hdcDest);

    if (!OpenClipboard(NULL) || !EmptyClipboard()) {
	R_ShowMessage(G_("Unable to open the clipboard"));
	DeleteObject(hbmpNew);
	return;
    }
    SetClipboardData(CF_BITMAP, hbmpNew);
    CloseClipboard();
    return;
}
Esempio n. 28
0
static unsigned int
execute_dumb_plugin_example (void)
{
  warning (0, G_("Analyze function %s"),
           IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
  return 0;
}
Esempio n. 29
0
static void editor_save_file(editor c, const char *name, int enc)
{
    textbox t = getdata(c);
    FILE *f;
    char buf[MAX_PATH+30];
    const char *sname;

    if (name == NULL)
	return;
    else {
	if(enc == CE_UTF8) {
	    wchar_t wname[MAX_PATH+1];
	    Rf_utf8towcs(wname, name, MAX_PATH+1);
	    sname = reEnc(name, CE_UTF8, CE_NATIVE, 3);
	    f = R_wfopen(wname, L"w");
	} else {
	    sname = name;
	    f = R_fopen(sname, "w");
	}
	if (f == NULL) {
	    snprintf(buf, MAX_PATH+30, G_("Could not save file '%s'"), sname);
	    askok(buf);
	    return;
	}
	fprintf(f, "%s", gettext(t));
	fclose(f);
    }
}
__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
{
	int i;
	const char * const plugin_name = plugin_info->base_name;
	const int argc = plugin_info->argc;
	const struct plugin_argument * const argv = plugin_info->argv;

	PASS_INFO(cyc_complexity, "ssa", 1, PASS_POS_INSERT_AFTER);

	if (!plugin_default_version_check(version, &gcc_version)) {
		error_gcc_version(version);
		return 1;
	}

	for (i = 0; i < argc; ++i) {
		if (!strcmp(argv[i].key, "log_file")) {
			has_log_file = true;
			continue;
		}

		error(G_("unknown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
	}

	register_callback(plugin_name, PLUGIN_START_UNIT,
				&cyc_complexity_start_unit, NULL);
	register_callback (plugin_name, PLUGIN_FINISH_UNIT,
				&cyc_complexity_finish_unit, NULL);
	register_callback(plugin_name, PLUGIN_INFO, NULL,
				&cyc_complexity_plugin_info);
	register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL,
				&cyc_complexity_pass_info);

	return 0;
}