forked from osmocom/wireshark
More EPAN-related code movements. Get rid of usage of #include "globals.h"
and #include "util.h" from epan code. Move get_home_dir() into epan/filesystem.c as it's used by plugins.c. svn path=/trunk/; revision=2461
This commit is contained in:
parent
cba2930d6b
commit
9d9850f209
|
@ -2,7 +2,7 @@
|
|||
# Automake file for the EPAN library
|
||||
# (Ethereal Protocol ANalyzer Library)
|
||||
#
|
||||
# $Id: Makefile.am,v 1.3 2000/09/27 05:18:05 gram Exp $
|
||||
# $Id: Makefile.am,v 1.4 2000/09/28 03:16:15 gram Exp $
|
||||
#
|
||||
# Ethereal - Network traffic analyzer
|
||||
# By Gerald Combs <gerald@zing.org>
|
||||
|
@ -46,6 +46,8 @@ libepan_a_SOURCES = \
|
|||
except.c \
|
||||
except.h \
|
||||
exception.h \
|
||||
filesystem.c \
|
||||
filesystem.h \
|
||||
packet.c \
|
||||
packet.h \
|
||||
pint.h \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* dfilter.c
|
||||
* Routines for display filters
|
||||
*
|
||||
* $Id: dfilter.c,v 1.1 2000/09/27 04:54:48 gram Exp $
|
||||
* $Id: dfilter.c,v 1.2 2000/09/28 03:16:15 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -41,7 +41,6 @@
|
|||
|
||||
#include "proto.h"
|
||||
#include "dfilter.h"
|
||||
#include "util.h"
|
||||
#include "dfilter-int.h"
|
||||
#include "dfilter-grammar.h"
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#ifndef EPAN_H
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
void epan_init(void);
|
||||
void epan_cleanup(void);
|
||||
|
@ -46,4 +47,9 @@ epan_dissect_new(epan_t*, guint8* data, guint len, guint32 wtap_encap,
|
|||
void
|
||||
epan_dissect_free(epan_t*, epan_dissect_t*);
|
||||
|
||||
/* Should this be ".libepan"? For backwards-compatibility, I'll keep
|
||||
* it ".ethereal" for now.
|
||||
*/
|
||||
#define PF_DIR ".ethereal"
|
||||
|
||||
#endif /* EPAN_H */
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/* filesystem.c
|
||||
* Filesystem utility routines
|
||||
*
|
||||
* $Id: filesystem.c,v 1.1 2000/09/28 03:16:16 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include "filesystem.h"
|
||||
|
||||
const char*
|
||||
get_home_dir(void)
|
||||
{
|
||||
static const char *home = NULL;
|
||||
#ifdef WIN32
|
||||
char *homedrive, *homepath;
|
||||
char *homestring;
|
||||
char *lastsep;
|
||||
#else
|
||||
struct passwd *pwd;
|
||||
#endif
|
||||
|
||||
/* Return the cached value, if available */
|
||||
if (home)
|
||||
return home;
|
||||
#ifdef WIN32
|
||||
/*
|
||||
* XXX - should we use USERPROFILE anywhere in this process?
|
||||
* Is there a chance that it might be set but one or more of
|
||||
* HOMEDRIVE or HOMEPATH isn't set?
|
||||
*/
|
||||
homedrive = getenv("HOMEDRIVE");
|
||||
if (homedrive != NULL) {
|
||||
homepath = getenv("HOMEPATH");
|
||||
if (homepath != NULL) {
|
||||
/*
|
||||
* This is cached, so we don't need to worry about
|
||||
* allocating multiple ones of them.
|
||||
*/
|
||||
homestring =
|
||||
g_malloc(strlen(homedrive) + strlen(homepath) + 1);
|
||||
strcpy(homestring, homedrive);
|
||||
strcat(homestring, homepath);
|
||||
|
||||
/*
|
||||
* Trim off any trailing slash or backslash.
|
||||
*/
|
||||
lastsep = find_last_pathname_separator(homestring);
|
||||
if (lastsep != NULL && *(lastsep + 1) == '\0') {
|
||||
/*
|
||||
* Last separator is the last character
|
||||
* in the string. Nuke it.
|
||||
*/
|
||||
*lastsep = '\0';
|
||||
}
|
||||
home = homestring;
|
||||
} else
|
||||
home = homedrive;
|
||||
} else {
|
||||
/*
|
||||
* Try using "windir?
|
||||
*/
|
||||
home = "C:";
|
||||
}
|
||||
#else
|
||||
home = getenv("HOME");
|
||||
if (home == NULL) {
|
||||
/*
|
||||
* Get their home directory from the password file.
|
||||
* If we can't even find a password file entry for them,
|
||||
* use "/tmp".
|
||||
*/
|
||||
pwd = getpwuid(getuid());
|
||||
if (pwd != NULL) {
|
||||
/*
|
||||
* This is cached, so we don't need to worry
|
||||
* about allocating multiple ones of them.
|
||||
*/
|
||||
home = g_strdup(pwd->pw_dir);
|
||||
} else
|
||||
home = "/tmp";
|
||||
}
|
||||
#endif
|
||||
|
||||
return home;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/* filesystem.h
|
||||
* Filesystem utility definitions
|
||||
*
|
||||
* $Id: filesystem.h,v 1.1 2000/09/28 03:16:16 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef FILESYSTEM_H
|
||||
#define FILESYSTEM_H
|
||||
|
||||
/* Returns the user's home directory, via the HOME environment
|
||||
* variable, or a default directory if HOME is not set */
|
||||
const char* get_home_dir(void);
|
||||
|
||||
#endif FILESYSTEM_H
|
13
epan/pint.h
13
epan/pint.h
|
@ -2,7 +2,7 @@
|
|||
* Definitions for extracting and translating integers safely and portably
|
||||
* via pointers.
|
||||
*
|
||||
* $Id: pint.h,v 1.1 2000/09/27 04:54:50 gram Exp $
|
||||
* $Id: pint.h,v 1.2 2000/09/28 03:16:16 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -112,4 +112,15 @@
|
|||
#define htolel(l) (l)
|
||||
#endif
|
||||
|
||||
/* Byte ordering */
|
||||
#ifndef BYTE_ORDER
|
||||
# define LITTLE_ENDIAN 4321
|
||||
# define BIG_ENDIAN 1234
|
||||
# ifdef WORDS_BIGENDIAN
|
||||
# define BYTE_ORDER BIG_ENDIAN
|
||||
# else
|
||||
# define BYTE_ORDER LITTLE_ENDIAN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* PINT_H */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* plugins.c
|
||||
* plugin routines
|
||||
*
|
||||
* $Id: plugins.c,v 1.1 2000/09/27 04:54:50 gram Exp $
|
||||
* $Id: plugins.c,v 1.2 2000/09/28 03:16:16 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -27,6 +27,7 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <epan.h>
|
||||
#include "plugins.h"
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
|
@ -43,6 +44,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
|
@ -60,8 +62,7 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "globals.h"
|
||||
#include "util.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
#ifdef PLUGINS_NEED_ADDRESS_TABLE
|
||||
#include "plugins/plugin_table.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* util.h
|
||||
* Utility definitions
|
||||
/* strutil.h
|
||||
* String utility definitions
|
||||
*
|
||||
* $Id: strutil.h,v 1.1 2000/09/27 04:54:53 gram Exp $
|
||||
* $Id: strutil.h,v 1.2 2000/09/28 03:16:17 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
|
37
globals.h
37
globals.h
|
@ -1,7 +1,7 @@
|
|||
/* globals.h
|
||||
* Global defines, etc.
|
||||
*
|
||||
* $Id: globals.h,v 1.21 2000/08/20 07:53:30 guy Exp $
|
||||
* $Id: globals.h,v 1.22 2000/09/28 03:16:05 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -27,43 +27,11 @@
|
|||
#define __GLOBALS_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include "packet.h"
|
||||
#include "file.h"
|
||||
#include "timestamp.h"
|
||||
|
||||
#define MIN_PACKET_SIZE 68 /* minimum amount of packet data we can read */
|
||||
|
||||
/* Byte swapping routines */
|
||||
#define SWAP16(x) \
|
||||
( (((x) & 0x00ff) << 8) | \
|
||||
(((x) & 0xff00) >> 8) )
|
||||
#define SWAP32(x) \
|
||||
( (((x) & 0x000000ff) << 24) | \
|
||||
(((x) & 0x0000ff00) << 8) | \
|
||||
(((x) & 0x00ff0000) >> 8) | \
|
||||
(((x) & 0xff000000) >> 24) )
|
||||
|
||||
/* Byte ordering */
|
||||
#ifndef BYTE_ORDER
|
||||
# define LITTLE_ENDIAN 4321
|
||||
# define BIG_ENDIAN 1234
|
||||
# ifdef WORDS_BIGENDIAN
|
||||
# define BYTE_ORDER BIG_ENDIAN
|
||||
# else
|
||||
# define BYTE_ORDER LITTLE_ENDIAN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* From the K&R book, p. 89 */
|
||||
#ifndef MAX
|
||||
# define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
extern packet_info pi;
|
||||
extern capture_file cfile;
|
||||
extern guint main_ctx, file_ctx;
|
||||
extern gchar comp_info_str[256];
|
||||
|
@ -71,11 +39,8 @@ extern gchar *ethereal_path;
|
|||
extern gchar *last_open_dir;
|
||||
extern gboolean auto_scroll_live;
|
||||
extern int g_resolving_actif;
|
||||
extern gboolean g_ip_dscp_actif;
|
||||
extern field_info *finfo_selected;
|
||||
|
||||
extern ts_type timestamp_type;
|
||||
|
||||
#define PF_DIR ".ethereal"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* colors.c
|
||||
* Definitions for color structures and routines
|
||||
*
|
||||
* $Id: colors.c,v 1.5 2000/08/11 13:33:13 deniel Exp $
|
||||
* $Id: colors.c,v 1.6 2000/09/28 03:16:29 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -39,6 +39,7 @@
|
|||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <epan.h>
|
||||
#include "gtk/main.h"
|
||||
#include "packet.h"
|
||||
#include "colors.h"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* (This used to be a notebook page under "Preferences", hence the
|
||||
* "prefs" in the file name.)
|
||||
*
|
||||
* $Id: filter_prefs.c,v 1.17 2000/08/23 06:55:41 guy Exp $
|
||||
* $Id: filter_prefs.c,v 1.18 2000/09/28 03:16:29 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -46,6 +46,7 @@
|
|||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
#include <epan.h>
|
||||
#include "gtk/main.h"
|
||||
#include "filter_prefs.h"
|
||||
#include "packet.h"
|
||||
|
|
3
prefs.c
3
prefs.c
|
@ -1,7 +1,7 @@
|
|||
/* prefs.c
|
||||
* Routines for handling preferences
|
||||
*
|
||||
* $Id: prefs.c,v 1.41 2000/09/12 06:41:56 guy Exp $
|
||||
* $Id: prefs.c,v 1.42 2000/09/28 03:16:05 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -48,6 +48,7 @@
|
|||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include <epan.h>
|
||||
#include "globals.h"
|
||||
#include "packet.h"
|
||||
#include "file.h"
|
||||
|
|
78
util.c
78
util.c
|
@ -1,7 +1,7 @@
|
|||
/* util.c
|
||||
* Utility routines
|
||||
*
|
||||
* $Id: util.c,v 1.45 2000/09/17 03:20:05 guy Exp $
|
||||
* $Id: util.c,v 1.46 2000/09/28 03:16:06 gram Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -728,82 +728,6 @@ free_interface_list(GList *if_list)
|
|||
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
|
||||
const char*
|
||||
get_home_dir(void)
|
||||
{
|
||||
static const char *home = NULL;
|
||||
#ifdef WIN32
|
||||
char *homedrive, *homepath;
|
||||
char *homestring;
|
||||
char *lastsep;
|
||||
#else
|
||||
struct passwd *pwd;
|
||||
#endif
|
||||
|
||||
/* Return the cached value, if available */
|
||||
if (home)
|
||||
return home;
|
||||
#ifdef WIN32
|
||||
/*
|
||||
* XXX - should we use USERPROFILE anywhere in this process?
|
||||
* Is there a chance that it might be set but one or more of
|
||||
* HOMEDRIVE or HOMEPATH isn't set?
|
||||
*/
|
||||
homedrive = getenv("HOMEDRIVE");
|
||||
if (homedrive != NULL) {
|
||||
homepath = getenv("HOMEPATH");
|
||||
if (homepath != NULL) {
|
||||
/*
|
||||
* This is cached, so we don't need to worry about
|
||||
* allocating multiple ones of them.
|
||||
*/
|
||||
homestring =
|
||||
g_malloc(strlen(homedrive) + strlen(homepath) + 1);
|
||||
strcpy(homestring, homedrive);
|
||||
strcat(homestring, homepath);
|
||||
|
||||
/*
|
||||
* Trim off any trailing slash or backslash.
|
||||
*/
|
||||
lastsep = find_last_pathname_separator(homestring);
|
||||
if (lastsep != NULL && *(lastsep + 1) == '\0') {
|
||||
/*
|
||||
* Last separator is the last character
|
||||
* in the string. Nuke it.
|
||||
*/
|
||||
*lastsep = '\0';
|
||||
}
|
||||
home = homestring;
|
||||
} else
|
||||
home = homedrive;
|
||||
} else {
|
||||
/*
|
||||
* Try using "windir?
|
||||
*/
|
||||
home = "C:";
|
||||
}
|
||||
#else
|
||||
home = getenv("HOME");
|
||||
if (home == NULL) {
|
||||
/*
|
||||
* Get their home directory from the password file.
|
||||
* If we can't even find a password file entry for them,
|
||||
* use "/tmp".
|
||||
*/
|
||||
pwd = getpwuid(getuid());
|
||||
if (pwd != NULL) {
|
||||
/*
|
||||
* This is cached, so we don't need to worry
|
||||
* about allocating multiple ones of them.
|
||||
*/
|
||||
home = g_strdup(pwd->pw_dir);
|
||||
} else
|
||||
home = "/tmp";
|
||||
}
|
||||
#endif
|
||||
|
||||
return home;
|
||||
}
|
||||
|
||||
/* Compute the difference between two seconds/microseconds time stamps. */
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue