Exemplo n.º 1
0
TEST(FirstPass, add_symbol) {
    sglib_hashed_Symbol_init(symbol_table);
    char s1[] = "START";
    char s2[] = "END";
    Symbol *result;
    add_symbol(s1, 0x144, false, true);
    add_symbol(s2, 0x164, true, false);
    result = get_symbol_by_name(symbol_table, "END");
    EXPECT_EQ(result -> address, 0x164);
    
}
Exemplo n.º 2
0
 LOCAL_EXTERN int get_action_info_by_name(const gchar *key, const gchar **names, const gchar **values, gchar **name, UI_CALLBACK *info)
 {
	static const struct _action
	{
		const gchar	* name;				/**< Name of the action */
		GCallback	  callback;			/**< Callback for "activated/toggled" signal */
	}
	action[] =
	{
		// Offline actions
		{	"Connect",			G_CALLBACK(action_connect)			},
		{	"LoadScreenDump",	G_CALLBACK(action_loadscreendump)	},
		{ 	"SetHostname",		G_CALLBACK(action_sethostname)		},
		{	"TestPattern",		G_CALLBACK(lib3270_testpattern)		},

		// Online actions
		{	"Redraw",			G_CALLBACK(action_redraw)			},
		{	"SaveScreen",		G_CALLBACK(action_savescreen)		},
		{	"PrintScreen",		G_CALLBACK(action_printscreen)		},
		{	"DumpScreen",		G_CALLBACK(action_dumpscreen)		},
		{	"Disconnect",		G_CALLBACK(action_disconnect)		},

		// Select actions
		{	"SelectField",		G_CALLBACK(action_selectfield)		},

		{ 	"SelectRight",		G_CALLBACK(action_selectright)		},
		{ 	"SelectLeft",		G_CALLBACK(action_selectleft)		},
		{ 	"SelectUp",			G_CALLBACK(action_selectup)			},
		{ 	"SelectDown",		G_CALLBACK(action_selectdown)		},

		{	"SelectionRight",	G_CALLBACK(action_selectionright)	},
		{	"SelectionLeft",	G_CALLBACK(action_selectionleft)	},
		{	"SelectionUp",		G_CALLBACK(action_selectionup)		},
		{	"SelectionDown",	G_CALLBACK(action_selectiondown)	},

		// Cursor Movement
		{ 	"CursorRight",		G_CALLBACK(action_Right)			},
		{ 	"CursorLeft",		G_CALLBACK(action_Left)				},
		{ 	"CursorUp",			G_CALLBACK(action_Up)				},
		{ 	"CursorDown",		G_CALLBACK(action_Down)				},
		{ 	"Newline",			G_CALLBACK(action_Newline)			},

		{	"NextField",		G_CALLBACK(lib3270_tab)				},
		{	"PreviousField",	G_CALLBACK(lib3270_backtab)			},

		{	"kpadd",			G_CALLBACK(action_kpadd)			},
		{	"kpsubtract",		G_CALLBACK(action_kpsubtract)		},

		// Edit actions
		{	"PasteNext",		G_CALLBACK(action_pastenext)		},
		{	"PasteTextFile",	G_CALLBACK(action_pastetextfile)	},
		{	"Reselect",			G_CALLBACK(action_reselect)				},
		{	"SelectAll",		G_CALLBACK(action_selectall)		},
		{	"EraseInput",		G_CALLBACK(erase_input_action)		},
		{	"Clear",			G_CALLBACK(clear_action)			},

		{	"Reset",			G_CALLBACK(action_Reset)			},
		{	"Escape",			G_CALLBACK(action_Reset)			},

		// File-transfer actions
		{	"Download",			G_CALLBACK(action_download)			},
		{	"Upload",   		G_CALLBACK(action_upload)			},

		// Selection actions
		{	"Append",			G_CALLBACK(action_append)			},
		{	"Unselect",			G_CALLBACK(action_unselect)			},
		{	"Copy",				G_CALLBACK(action_copy)				},
		{	"CopyAsTable",		G_CALLBACK(action_copyastable)		},

		{	"CopyAsImage",		G_CALLBACK(action_copyasimage)		},

		{	"PrintSelected",	G_CALLBACK(action_printselected)	},
		{	"SaveSelected",		G_CALLBACK(action_saveselected)		},

		{	"PrintClipboard",	G_CALLBACK(action_printclipboard)	},
		{	"SaveClipboard",	G_CALLBACK(action_saveclipboard)	},
		{	"Paste",			G_CALLBACK(action_paste)			},

		{	"FileMenu",			NULL								},
		{	"FTMenu",			NULL								},
		{	"NetworkMenu",		NULL								},
		{	"HelpMenu",			NULL								},
		{	"EditMenu",			NULL								},
		{	"OptionsMenu",		NULL								},
		{	"SettingsMenu",		NULL								},
		{	"ScriptsMenu",		NULL								},
		{	"ViewMenu",			NULL								},
		{	"InputMethod",		NULL								},
		{	"ToolbarMenu",		NULL								},
		{	"DebugMenu",		NULL								},
		{	"FontSettings",		NULL								},
		{	"Preferences",		NULL								},
		{	"Network",			NULL								},
		{	"Properties",		NULL								},
		{	"ScreenSizes",		NULL								},
		{	"About",			G_CALLBACK(action_about)			},
		{	"Quit",				G_CALLBACK(action_quit)				},
		{	"SelectColors",		G_CALLBACK(action_selectcolors)		},

		{	"Save",				NULL								},

		{ 	"Return",			G_CALLBACK(action_enter)			},
		{ 	"Enter",			G_CALLBACK(action_enter)			},

		// Lib3270 calls
		{ "EraseEOF",			G_CALLBACK(lib3270_eraseeof)		},
		{ "EraseEOL",			G_CALLBACK(lib3270_eraseeol)		},
		{ "Home",				G_CALLBACK(lib3270_firstfield)		},
		{ "DeleteWord",			G_CALLBACK(lib3270_deleteword)		},
		{ "EraseField",			G_CALLBACK(lib3270_deletefield)		},
		{ "Delete",				G_CALLBACK(lib3270_delete)			},
		{ "Erase",				G_CALLBACK(lib3270_erase)			},
		{ "SysREQ",				G_CALLBACK(lib3270_sysreq)			},
		{ "Attn",				G_CALLBACK(lib3270_attn)			},
		{ "Break",				G_CALLBACK(lib3270_break)			},
		{ "Dup",				G_CALLBACK(lib3270_dup)				},

		{ "FirstField",			G_CALLBACK(lib3270_firstfield)		},

	};

	int			f;

	if(name)
		*name = NULL;

	memset(info,0,sizeof(UI_CALLBACK));

	if(!g_ascii_strcasecmp(key,"pfkey"))
	{
		info->type 		= UI_CALLBACK_TYPE_DEFAULT;
		info->label		= "pfkey";
		info->callback	= G_CALLBACK(action_pfkey);
		info->user_data = (gpointer) atoi(get_xml_attribute(names, values, "id"));
		if(name)
			*name = g_strdup_printf("pf%02d",(int) info->user_data);
		return 0;
	}

	if(!g_ascii_strcasecmp(key,"pakey"))
	{
		info->type 		= UI_CALLBACK_TYPE_DEFAULT;
		info->label		= "pakey";
		info->callback	= G_CALLBACK(action_pakey);
		info->user_data = (gpointer) atoi(get_xml_attribute(names, values, "id"));
		if(name)
			*name = g_strdup_printf("pa%02d",(int) info->user_data);
		return 0;
	}

	if(!g_ascii_strcasecmp(key,"toggle"))
	{
		// Check for lib3270 toggles
		const gchar *id = get_xml_attribute(names, values, "id");

		for(f=0;f<N_TOGGLES;f++)
		{
			if(!g_ascii_strcasecmp(id,get_toggle_name(f)))
			{
				info->type 		= UI_CALLBACK_TYPE_TOGGLE;
				info->callback	= G_CALLBACK(toggle_action);
				info->user_data = (gpointer) f;
				if(name)
					*name = g_strconcat("Toggle",get_toggle_name(f),NULL);
				return 0;
			}
		}

		// Check for GUI toggles
		for(f=0;f<G_N_ELEMENTS(gui_toggle_info);f++)
		{
			if(!g_ascii_strcasecmp(id,gui_toggle_info[f].name))
			{
				info->type 		= UI_CALLBACK_TYPE_TOGGLE;
				info->callback	= G_CALLBACK(toggle_gui);
				info->user_data = (gpointer) f;
				if(name)
					*name = g_strconcat("Toggle",gui_toggle_info[f].name,NULL);
				return 0;
			}
		}

		if(!g_ascii_strcasecmp(id,"gdkdebug"))
		{
			info->type 		= UI_CALLBACK_TYPE_TOGGLE;
			info->callback	= G_CALLBACK(action_ToggleGDKDebug);
			info->user_data = (gpointer) f;
			if(name)
				*name = g_strdup("ToggleGDKDebug");
			return 0;
		}

		return EINVAL;
	}

	if(!g_ascii_strcasecmp(key,"toggleset"))
	{
		const gchar *id = get_xml_attribute(names, values, "id");

		for(f=0;f<N_TOGGLES;f++)
		{
			if(!g_ascii_strcasecmp(id,get_toggle_name(f)))
			{
				info->type 		= UI_CALLBACK_TYPE_DEFAULT;
//				info->label		= toggle_info[f].set_label ? toggle_info[f].set_label : toggle_info[f].do_label;
				info->callback	= G_CALLBACK(toggle_set_action);
				info->user_data = (gpointer) f;
				if(name)
					*name = g_strconcat("ToggleSet",get_toggle_name(f),NULL);
				return 0;
			}
		}
		return EINVAL;
	}

	if(!g_ascii_strcasecmp(key,"togglereset"))
	{
		const gchar *id = get_xml_attribute(names, values, "id");

		for(f=0;f<N_TOGGLES;f++)
		{
			if(!g_ascii_strcasecmp(id,get_toggle_name(f)))
			{
				info->type 		= UI_CALLBACK_TYPE_DEFAULT;
//				info->label		= toggle_info[f].reset_label ? toggle_info[f].reset_label : toggle_info[f].do_label;
				info->callback	= G_CALLBACK(toggle_reset_action);
				info->user_data = (gpointer) f;
				if(name)
					*name = g_strconcat("ToggleReset",get_toggle_name(f),NULL);
				return 0;
			}
		}
		return EINVAL;
	}

	// Search internal actions
	for(f=0;f<G_N_ELEMENTS(action);f++)
	{
		if(!g_ascii_strcasecmp(key,action[f].name))
		{
			info->type = UI_CALLBACK_TYPE_DEFAULT;
//			info->label = action[f].label;
			info->callback = action[f].callback;
			return 0;
		}
	}

	// Search for plugin actions
	if(strchr(key,'.'))
	{
		gchar	*plugin_name = g_strdup(key);
		gchar	*entry_name	 = strchr(plugin_name,'.');
		GModule *plugin;

		*(entry_name++) = 0;

		plugin = get_plugin_by_name(plugin_name);
		if(plugin)
		{
			gpointer cbk;

			if(get_symbol_by_name(plugin,&cbk,"action_%s_activated",entry_name))
			{
				info->type 		= UI_CALLBACK_TYPE_DEFAULT;
				info->callback	= (GCallback) cbk;
				info->user_data	= (gpointer) topwindow;

			}
			else if(get_symbol_by_name(plugin,&cbk,"action_%s_toggled",entry_name))
			{
				info->type		= UI_CALLBACK_TYPE_TOGGLE;
				info->callback	= (GCallback) cbk;
				info->user_data	= (gpointer) topwindow;

			}
		}

		g_free(plugin_name);
		if(info->callback)
			return 0;
	}

	// Check if it's an external program action
	if(!g_ascii_strncasecmp(key,"call",4) && strlen(key) > 5 && g_ascii_isspace(*(key+4)))
	{

	}

	return ENOENT;
 }