diff --git a/epan/Makefile.am b/epan/Makefile.am index da1e3c9e2a..8d267d8059 100644 --- a/epan/Makefile.am +++ b/epan/Makefile.am @@ -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 @@ -46,6 +46,8 @@ libepan_a_SOURCES = \ except.c \ except.h \ exception.h \ + filesystem.c \ + filesystem.h \ packet.c \ packet.h \ pint.h \ diff --git a/epan/dfilter.c b/epan/dfilter.c index 73fe5253e0..9911fd600c 100644 --- a/epan/dfilter.c +++ b/epan/dfilter.c @@ -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 @@ -41,7 +41,6 @@ #include "proto.h" #include "dfilter.h" -#include "util.h" #include "dfilter-int.h" #include "dfilter-grammar.h" diff --git a/epan/epan.h b/epan/epan.h index 87463449ea..649627c44e 100644 --- a/epan/epan.h +++ b/epan/epan.h @@ -6,6 +6,7 @@ #ifndef EPAN_H +#include 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 */ diff --git a/epan/filesystem.c b/epan/filesystem.c new file mode 100644 index 0000000000..bd89677f90 --- /dev/null +++ b/epan/filesystem.c @@ -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 + * 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 +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifndef WIN32 +#include +#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; +} diff --git a/epan/filesystem.h b/epan/filesystem.h new file mode 100644 index 0000000000..e8345daf3c --- /dev/null +++ b/epan/filesystem.h @@ -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 + * 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 diff --git a/epan/pint.h b/epan/pint.h index 38f9201ffc..cb0be3a30c 100644 --- a/epan/pint.h +++ b/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 @@ -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 */ diff --git a/epan/plugins.c b/epan/plugins.c index 8ef8800844..fa50b9faf5 100644 --- a/epan/plugins.c +++ b/epan/plugins.c @@ -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 @@ -27,6 +27,7 @@ # include "config.h" #endif +#include #include "plugins.h" #ifdef HAVE_PLUGINS @@ -43,6 +44,7 @@ #include #include +#include #ifdef HAVE_SYS_STAT_H #include @@ -60,8 +62,7 @@ #include #endif -#include "globals.h" -#include "util.h" +#include "filesystem.h" #ifdef PLUGINS_NEED_ADDRESS_TABLE #include "plugins/plugin_table.h" diff --git a/epan/strutil.h b/epan/strutil.h index fdd95ca891..6464500d73 100644 --- a/epan/strutil.h +++ b/epan/strutil.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 diff --git a/globals.h b/globals.h index b7ac278696..748bea4317 100644 --- a/globals.h +++ b/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 @@ -27,43 +27,11 @@ #define __GLOBALS_H__ #include -#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 diff --git a/gtk/colors.c b/gtk/colors.c index ba22942703..44da72220a 100644 --- a/gtk/colors.c +++ b/gtk/colors.c @@ -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 @@ -39,6 +39,7 @@ #include #endif +#include #include "gtk/main.h" #include "packet.h" #include "colors.h" diff --git a/gtk/filter_prefs.c b/gtk/filter_prefs.c index f00c49473b..28277cd28f 100644 --- a/gtk/filter_prefs.c +++ b/gtk/filter_prefs.c @@ -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 @@ -46,6 +46,7 @@ #include #endif +#include #include "gtk/main.h" #include "filter_prefs.h" #include "packet.h" diff --git a/prefs.c b/prefs.c index be822e5437..ed9ba8f9ae 100644 --- a/prefs.c +++ b/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 @@ -48,6 +48,7 @@ #include #endif +#include #include "globals.h" #include "packet.h" #include "file.h" diff --git a/util.c b/util.c index 22a4dc3bb0..8f2add4462 100644 --- a/util.c +++ b/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 @@ -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