separate dir functions from the plugin init,

put this and some other dirs in the about dialog

svn path=/trunk/; revision=10928
This commit is contained in:
Ulf Lamping 2004-05-20 13:48:25 +00:00
parent 2db4111d3d
commit 957ebcf71d
3 changed files with 107 additions and 42 deletions

View File

@ -1,7 +1,7 @@
/* plugins.c
* plugin routines
*
* $Id: plugins.c,v 1.80 2004/03/04 07:07:01 guy Exp $
* $Id: plugins.c,v 1.81 2004/05/20 13:48:25 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -308,19 +308,16 @@ plugins_scan_dir(const char *dirname)
#endif
}
/*
* init plugins
*/
void
init_plugins(const char *plugin_dir)
/* get the global plugin dir */
/* Return value is malloced so the caller should g_free() it. */
const char *get_plugins_global_dir(const char *plugin_dir)
{
#ifdef WIN32
const char *datafile_dir;
char *install_plugin_dir;
#endif
if (plugin_list == NULL) /* ensure init_plugins is only run once */
{
#ifdef WIN32
/*
* On Windows, the data file directory is the installation
@ -330,10 +327,7 @@ init_plugins(const char *plugin_dir)
* on Windows, the data file directory is the directory
* in which the Ethereal binary resides.
*/
datafile_dir = get_datafile_dir();
install_plugin_dir = g_malloc(strlen(datafile_dir) + strlen("plugins") +
strlen(VERSION) + 3);
sprintf(install_plugin_dir, "%s\\plugins\\%s", datafile_dir, VERSION);
install_plugin_dir = g_strdup_printf("%s\\plugins\\%s", get_datafile_dir(), VERSION);
/*
* Make sure that pathname refers to a directory.
@ -355,24 +349,53 @@ init_plugins(const char *plugin_dir)
* source directory, and copy the plugin DLLs there,
* so that you use the plugins from the build tree?
*/
g_free(install_plugin_dir);
install_plugin_dir =
g_strdup("C:\\Program Files\\Ethereal\\plugins\\" VERSION);
}
/*
* Scan that directory.
*/
plugins_scan_dir(install_plugin_dir);
g_free(install_plugin_dir);
return(install_plugin_dir);
#else
/*
* Scan the plugin directory.
*/
plugins_scan_dir(plugin_dir);
return strdup(plugin_dir);
#endif
if (!user_plug_dir)
user_plug_dir = get_persconffile_path(PLUGINS_DIR_NAME, FALSE);
plugins_scan_dir(user_plug_dir);
}
/* get the personal plugin dir */
/* Return value is malloced so the caller should g_free() it. */
const char *get_plugins_pers_dir(void)
{
return get_persconffile_path(PLUGINS_DIR_NAME, FALSE);
}
/*
* init plugins
*/
void
init_plugins(const char *plugin_dir)
{
#ifdef WIN32
const char *datafile_dir;
#endif
if (plugin_list == NULL) /* ensure init_plugins is only run once */
{
/*
* Scan the global plugin directory.
*/
datafile_dir = get_plugins_global_dir(plugin_dir);
plugins_scan_dir(datafile_dir);
g_free((char *) datafile_dir);
/*
* Scan the users plugin directory.
*/
datafile_dir = get_plugins_pers_dir();
plugins_scan_dir(datafile_dir);
g_free((char *) datafile_dir);
}
}

View File

@ -1,7 +1,7 @@
/* plugins.h
* definitions for plugins structures
*
* $Id: plugins.h,v 1.10 2004/05/09 10:03:40 guy Exp $
* $Id: plugins.h,v 1.11 2004/05/20 13:48:25 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -41,7 +41,15 @@ typedef struct _plugin {
ETH_VAR_IMPORT plugin *plugin_list;
void init_plugins(const char *);
void register_all_plugin_handoffs(void);
extern void init_plugins(const char *);
extern void register_all_plugin_handoffs(void);
/* get the global plugin dir */
/* Return value is g_malloced so the caller should g_free() it. */
extern const char *get_plugins_global_dir(const char *plugin_dir);
/* get the personal plugin dir */
/* Return value is g_malloced so the caller should g_free() it. */
extern const char *get_plugins_pers_dir(void);
#endif /* __PLUGINS_H__ */

View File

@ -1,6 +1,6 @@
/* about_dlg.c
*
* $Id: about_dlg.c,v 1.1 2004/05/20 12:01:12 ulfl Exp $
* $Id: about_dlg.c,v 1.2 2004/05/20 13:48:25 ulfl Exp $
*
* Ulf Lamping <ulf.lamping@web.de>
*
@ -30,9 +30,11 @@
#include <gtk/gtk.h>
#include <epan/filesystem.h>
#include <epan/plugins.h>
#include "ui_util.h"
#include "dlg_utils.h"
#include "compat_macros.h"
#include "globals.h"
extern GString *comp_info_str, *runtime_info_str;
@ -123,30 +125,62 @@ about_dirs_new(void)
gtk_table_set_col_spacings(GTK_TABLE(table), 6);
row = 0;
path = get_persconffile_path("", FALSE);
about_dirs_row(table, row, "Personal configuration:", path,
"\"dfilters\", \"preferences\", ...");
g_free((void *) path);
row++;
path = get_datafile_dir();
about_dirs_row(table, row, "Global configuration and data:", path,
"same as in personal conf.");
/*g_free(path);*/
row++;
path = get_systemfile_dir();
about_dirs_row(table, row, "System:", path,
"\"ethers\", ...");
/*g_free(path);*/
/* "file open" */
about_dirs_row(table, row, "\"File\" dialogs:", last_open_dir,
"capture files");
row++;
/* temp */
path = get_tempfile_path("");
about_dirs_row(table, row, "Temp:", path,
"untitled capture files");
g_free((void *) path);
row++;
/* pers conf */
path = get_persconffile_path("", FALSE);
about_dirs_row(table, row, "Personal configuration:", path,
"\"dfilters\", \"preferences\", \"ethers\", ...");
g_free((void *) path);
row++;
/* global conf */
path = get_datafile_dir();
about_dirs_row(table, row, "Global configuration:", path,
"\"dfilters\", \"preferences\", \"manuf\", ...");
/*g_free(path);*/
row++;
/* system */
path = get_systemfile_dir();
about_dirs_row(table, row, "System:", path,
"\"ethers\", \"ipxnets\"");
/*g_free(path);*/
row++;
/* program */
path = strdup(ethereal_path);
path = get_dirname((char *) path);
about_dirs_row(table, row, "Program:", path,
"program files");
g_free((void *) path);
row++;
/* pers plugins */
path = get_plugins_pers_dir();
about_dirs_row(table, row, "Personal Plugins:", path,
"dissector plugins");
g_free((void *) path);
row++;
/* global plugins */
path = get_plugins_global_dir(PLUGIN_DIR);
about_dirs_row(table, row, "Global Plugins:", path,
"dissector plugins");
g_free((void *) path);
row++;
return table;
}