More EPAN-related code movements. Get rid of usage of #include "globals.h"
authorgram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 28 Sep 2000 03:16:29 +0000 (03:16 +0000)
committergram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 28 Sep 2000 03:16:29 +0000 (03:16 +0000)
and #include "util.h" from epan code. Move get_home_dir() into epan/filesystem.c
as it's used by plugins.c.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2461 f5534014-38df-0310-8fa8-9805f1628bb7

13 files changed:
epan/Makefile.am
epan/dfilter.c
epan/epan.h
epan/filesystem.c [new file with mode: 0644]
epan/filesystem.h [new file with mode: 0644]
epan/pint.h
epan/plugins.c
epan/strutil.h
globals.h
gtk/colors.c
gtk/filter_prefs.c
prefs.c
util.c

index da1e3c9e2a308996673af48e8c21ad4e65cffbdb..8d267d80597eda2202447d8a5d833851adf7310f 100644 (file)
@@ -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                  \
index 73fe5253e023c5fa2e9468009a9609091a5b0d10..9911fd600c44f7a6a6116733b055321745c03a8d 100644 (file)
@@ -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"
 
index 87463449ead50332de423be1c6ea416515380880..649627c44e8063fdf0a3bcd675e3b13d96a198f0 100644 (file)
@@ -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 */
diff --git a/epan/filesystem.c b/epan/filesystem.c
new file mode 100644 (file)
index 0000000..bd89677
--- /dev/null
@@ -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;
+}
diff --git a/epan/filesystem.h b/epan/filesystem.h
new file mode 100644 (file)
index 0000000..e8345da
--- /dev/null
@@ -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
index 38f9201ffc52a65c3e9f657e0741cd6db86c76cd..cb0be3a30ce512291f121e6feef014ca1c65e93f 100644 (file)
@@ -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>
 #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 */
index 8ef880084446021391128482aef234468ec90939..fa50b9faf54868bfb1ef15d112b23c164674d495 100644 (file)
@@ -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"
index fdd95ca891cf2d6e5a2323f4ec700b3c9d72a3bc..6464500d73251ce9bf58c642d3ff126bc2112fc5 100644 (file)
@@ -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>
index b7ac278696a71b39593f1e69ed0273ecda315545..748bea4317e16c0ae8d238d3d25e880d7fde8457 100644 (file)
--- 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 <gerald@zing.org>
 #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
index ba229427037a4109febca5bc6eb32e81c5e25ebc..44da72220ab3a1e36c16a741a94f8fccd938d6a6 100644 (file)
@@ -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"
index f00c49473bd7490170202e09695ab83bbab7b2d1..28277cd28f142aa8f509a40c0ec5b3cffbfa5b2c 100644 (file)
@@ -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"
diff --git a/prefs.c b/prefs.c
index be822e5437332feec67618304dfcd188aa855ee3..ed9ba8f9aed9a032f4816e5aed1855f84ed22302 100644 (file)
--- 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 <gerald@zing.org>
@@ -48,6 +48,7 @@
 #include <sys/stat.h>
 #endif
 
+#include <epan.h>
 #include "globals.h"
 #include "packet.h"
 #include "file.h"
diff --git a/util.c b/util.c
index 22a4dc3bb0ec2a68b85fe85c9c30bce74b20eb59..8f2add4462a002bc5365d9daf0736075e9cd4d6e 100644 (file)
--- 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 <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