aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
AgeCommit message (Collapse)AuthorFilesLines
2003-06-13On Win32, say "without WinPcap" rather than "without libpcap" (althoughguy1-1/+5
it's unlikely that somebody would build without WinPcap - they'd currently have to manually tweak config.h.win32; we can do the same trick there that we do with ADNS). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7877 f5534014-38df-0310-8fa8-9805f1628bb7
2003-06-13Do run-time word-wrapping on the "Compiled with" message, rather thanguy1-14/+78
wiring the line boundaries in. On Win32, say "with WinPcap" rather than "with libpcap", and report both on whether we were compiled with WinPcap and whether we were able to load WinPcap. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7876 f5534014-38df-0310-8fa8-9805f1628bb7
2003-06-13Put in a missing comma.guy1-2/+2
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7869 f5534014-38df-0310-8fa8-9805f1628bb7
2003-05-26Add ADNS to the "Compiled with" list. Wrap at the SNMP library part sincegerald1-4/+10
the line was getting long. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7747 f5534014-38df-0310-8fa8-9805f1628bb7
2003-05-23Move the base64_decode() function somewhere where other dissectors cantpot1-1/+34
use it. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7723 f5534014-38df-0310-8fa8-9805f1628bb7
2003-03-12Change the version messages to put the "compiled with" stuff on aguy1-10/+19
separate line, and to put the "running with" info on a separate line from that, to make the output narrower. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7344 f5534014-38df-0310-8fa8-9805f1628bb7
2003-03-08If we have <windows.h>, we need to include it to declare OSVERSIONINFO.guy1-4/+8
Fix some typos. Put the build number after the "szCSDVersion" value; on NT, that makes it show up as "Windows {NT x.y,2000,XP,etc.} Service Pack N, build N", and on OT, it might make it show up as "Windows {95,98,Me} X, build N", where "X" might be "A" or "B" or something such as that. (We might want to omit the space before "szCSDVersion" on Windows OT - I think the "right" name might be something like "Windows 95B", but I'm not sure.) git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7324 f5534014-38df-0310-8fa8-9805f1628bb7
2003-03-08Put the code to get version numbers of various libraries with whichguy1-1/+223
Ethereal/Tethereal was linked into a common routine, and use that in both Ethereal and Tethereal. Add to that routine code to get OS version information. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7320 f5534014-38df-0310-8fa8-9805f1628bb7
2002-08-28Removed trailing whitespaces from .h and .c files using thejmayer1-6/+6
winapi_cleanup tool written by Patrik Stridvall for the wine project. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@6117 f5534014-38df-0310-8fa8-9805f1628bb7
2002-08-02Replace the types from sys/types.h and netinet/in.h by their glib.hjmayer1-5/+1
equivalents for the toplevel directory. The removal of winsock2.h will hopefully not cause any problems under MSVC++, as those files using struct timeval still include wtap.h, which still includes winsock2.h. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5932 f5534014-38df-0310-8fa8-9805f1628bb7
2002-04-08More static-ization. In util.c, I commented out the ASCII-to-EBCDICgram1-1/+3
functions, until that time that we need them. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5130 f5534014-38df-0310-8fa8-9805f1628bb7
2001-11-09Wrap calls to "pcap_datalink()" in a routine that attempts to compensateguy1-302/+2
for AIX 5.x's non-standard libpcap, where "pcap_datalink()" doesn't return DLT_ values, it returns RFC 1573 ifType values. Put that wrapper, and the routine to get the interface list, in a separate file, for packet-capture utility routines, so not everybody who includes "util.h" needs to include <pcap.h>. Fix up the Wiretap hack for dealing with said incompatibility to use the correct ifType value for Token Ring. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4184 f5534014-38df-0310-8fa8-9805f1628bb7
2001-10-26Fix the rest of the signed/unsigned comparison warnings.gram1-2/+2
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4088 f5534014-38df-0310-8fa8-9805f1628bb7
2001-08-21On Windows, use the directory in which the binary resides as theguy1-48/+2
directory in which global data files are stored. If an installed binary is being run, that's the correct directory for them; if a build-tree binary is being run, the "manuf" file will be there, and you can put other data files there as well, if necessary. Do the same with plugins, except that, if there's no "plugins\\{version}" subdirectory of that directory, fall back on the default installation directory, so you at least have a place where you can put plugins for use by build-tree binaries. (Should we, instead, have the Windows build procedure create a subdirectory of the "plugins" source directory, with the plugin version number as its name, and copy the plugins there, so you'd use the build-tree plugin binaries?) Move "test_for_directory()" out of "util.c" and into "epan/filesystem.c", with the other file system access portability wrappers and convenience routines. Fix "util.h" not to declare it - or other routines moved to "epan/filesystem.c" a while ago. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@3858 f5534014-38df-0310-8fa8-9805f1628bb7
2001-04-02"get_home_dir()", in "epan/filesystem.c", usesguy1-92/+1
"find_last_pathname_separator()" on Win32; move the other pathname manipulation routines from "util.c" into "epan/filesystem.c". Remove from "util.h" the declarations of routines not defined in "util.c", and put them into "epan/filesystem.h" if they're not already there. Adjust #includes to make the above work. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@3241 f5534014-38df-0310-8fa8-9805f1628bb7
2001-03-22Throw in a cast to squelch a complaint from Visual C++ 6.0.guy1-2/+2
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@3157 f5534014-38df-0310-8fa8-9805f1628bb7
2001-01-28There's no need for a member of a "capture_file" structure holding aguy1-1/+3
compiled capture filter program, so remove it, and remove the include of <pcap.h> from "file.h"; instead, have local "struct bpf_program" structures where needed, and have those files that need stuff from <pcap.h> include it. This cleans stuff up a bit, and should eliminate a pile of compile warnings with Visual C++ due to <pcap.h> and some GTK+/GLib header file (or files they include) both defining "inline". git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2954 f5534014-38df-0310-8fa8-9805f1628bb7
2000-12-23On Linux, try to open the "any" device and, if we can open it, add it toguy1-1/+18
the end of the list of interfaces on which you can capture. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2774 f5534014-38df-0310-8fa8-9805f1628bb7
2000-10-11Fix it to build on Windows.guy1-2/+2
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2488 f5534014-38df-0310-8fa8-9805f1628bb7
2000-09-28More EPAN-related code movements. Get rid of usage of #include "globals.h"gram1-77/+1
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
2000-09-17libpcap unconditionally includes <net/if.h> on UNIX systems, as that is,guy1-2/+2
as far as I know, the only way to get IFF_UP, IFF_LOOPBACK, "struct ifreq", and "struct ifconf" defined, and those are required in order to get, via SIOCGIFCONF, the interface list, and to exclude interfaces that aren't up and handle loopback interfaces differently from other interfaces. If we're on UNIX and have libpcap, we should do the same; that way, if the system doesn't have <net/if.h> installed, the compile will fail with an "I can't find <net/if.h>" error, rather than the configure indicating that <net/if.h> can't be found, causing "util.c" not to include it, causing it to fail with complaints about IFF_UP, IFF_LOOPBACK, and various structures not being defined - the former tells you the root cause, the latter doesn't. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2442 f5534014-38df-0310-8fa8-9805f1628bb7
2000-09-10Compute and display negative relative and delta time stamps correctly,guy1-1/+45
just in case time goes backwards (yes, it sometimes does happen in captures). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2407 f5534014-38df-0310-8fa8-9805f1628bb7
2000-09-07Always use "g_free()" to free "ifc.ifc_buf"; it's set to a valueguy1-2/+2
allocated by "g_malloc()", and one should always use "g_free()" to free stuff allocated with "g_malloc()" (using "free()" works if GLib isn't compiled with any special memory allocator debugging/profiling options, but doesn't work if it is compiled with those options). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2393 f5534014-38df-0310-8fa8-9805f1628bb7
2000-08-31The interface list will now be get into an dynamic growing buffer and notgirlich1-14/+33
the (too big) buffer for 1024 network cards. The code comes directly after the ideas in Steven's book (UNIX network programming). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2385 f5534014-38df-0310-8fa8-9805f1628bb7
2000-08-11Miscellaneous code cleaningdeniel1-6/+1
- add <stdarg.h> or <varargs.h> in snprintf.h and remove those inclusions in the other #ifdef NEED_SNPRINTF_H codes - remove the check of multiple inclusions in source (.c) code (there is a bit loss of _cpp_ performance, but I prefer the gain of code reading and maintenance; and nowadays, disk caches and VM are correctly optimized ;-). - protect all (well almost) header files against multiple inclusions - add header (i.e. GPL license) in some include files - reorganize a bit the way header files are included: First: #include <system_include_files> #include <external_package_include_files (e.g. gtk, glib etc.)> Then #include "ethereal_include_files" with the correct HAVE_XXX or NEED_XXX protections. - add some HAVE_XXX checks before including some system header files - add the same HAVE_XXX in wiretap as in ethereal Please forgive me, if I break something (I've only compiled and regression tested on Linux). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2254 f5534014-38df-0310-8fa8-9805f1628bb7
2000-07-31Add a routine to check whether a file is a directory or not.guy1-1/+46
To test whether a file the user selected to be opened from the file selection box is really a directory (so that we can point the file selection box at it, rather than trying to open the directory as a capture file, which wouldn't work), use the routine in question. To make the GTK+ file selection box start out in the last directory from which we opened a file, use "gtk_file_selection_complete()", rather than "chdir()"ing to that directory. Those changes keep us from "chdir()"ing all over the place; that way, if Ethereal dumps core, the core dump shows up in the directory from which it was run, rather than in the directory from which you last opened or into which you last saved a file. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2190 f5534014-38df-0310-8fa8-9805f1628bb7
2000-03-21Paul Welchinski's changes to, on Win32 systems:guy1-14/+35
properly handle ASCII vs. Unicode in the list of interfaces; initialize Winsock before starting a capture, so that the code in the Win32 libpcap to get the IP address and netmask by translating the host name to an IP address works. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1737 f5534014-38df-0310-8fa8-9805f1628bb7
2000-03-14On Windows, when getting the user's home directory, don't look at theguy1-18/+56
HOME environment variable; instead, look at HOMEDRIVE and HOMEPATH. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1718 f5534014-38df-0310-8fa8-9805f1628bb7
2000-02-22In Tethereal, allow capture filters and read filters either to beguy1-1/+41
specifies with "-f" and "-R" flags, respectively, or specified with non-flag command-line arguments, as tcpdump and snoop allow. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1663 f5534014-38df-0310-8fa8-9805f1628bb7
2000-02-09Integrate Ed Meaney's <emeaney@altiga.com> changes for using libpcapgram1-1/+29
from WinDump with Ethereal. We now have packet capturing on Win32. :) git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1612 f5534014-38df-0310-8fa8-9805f1628bb7
2000-01-31Add a semicolon in a win32 block of code.gram1-2/+2
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1587 f5534014-38df-0310-8fa8-9805f1628bb7
2000-01-29Just pass the return value of "getuid()" directly on to "getpwuid()";guy1-4/+2
don't stuff it into a variable. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1582 f5534014-38df-0310-8fa8-9805f1628bb7
2000-01-29Fix #ifndef line whose symbol had been omitted.guy1-2/+2
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1581 f5534014-38df-0310-8fa8-9805f1628bb7
2000-01-29Don't put "get_home_dir()" inside #ifdef HAVE_LIBPCAP/#endif.guy1-10/+26
On UNIX, if "$HOME" isn't set, try getting the user ID and the password entry for that user ID, and, if that succeeds, get the home directory from the password entry, otherwise use "/tmp". On NT, it may be possible to do something similar (get the user name, and append that to "C:\winnt\profiles\"); I'm not sure whether there's anything that can be done on Windows 9x. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1580 f5534014-38df-0310-8fa8-9805f1628bb7
2000-01-29Remove instances of getenv("HOME") and provide a get_home_dir() functiongram1-1/+30
which provides a default value if "HOME" is not set. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1579 f5534014-38df-0310-8fa8-9805f1628bb7
2000-01-26In Win32, treat both '/' and '\' as pathname separators.guy1-8/+16
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1566 f5534014-38df-0310-8fa8-9805f1628bb7
2000-01-25Provide a "get_dirname()" routine, that takes a pathname and returnsguy1-8/+54
either a pointer to the directory part of the pathname (after stomping on the pathname separator with a '\0', so don't use this on pathnames you plan to use afterwards), or NULL if the pathname contains no directory part, and make it handle Win32 pathnames on Win32 systems. Use it to get the containing directory of the currently open file, so that the "chdir()" stuff we do to cause the "File:Open" dialog box to show you files in the directory in which you last looked works on Win32 systems. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1555 f5534014-38df-0310-8fa8-9805f1628bb7
2000-01-25Encapsulate the code to take a pointer to a pathname and return aguy1-1/+38
pointer to the name of the file to which it refers (i.e., to the last component of the pathname) in a "get_basename()" routine, and have the code in "file.c" call it. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1552 f5534014-38df-0310-8fa8-9805f1628bb7
2000-01-16Move the routine to get a list of the network interfaces on the systemguy1-1/+209
to "util.c", and provide a routine to free that list as well. When picking an interface on which to do a capture (if no "-i" flag was specified), use that routine, and pick the first interface on the list. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1495 f5534014-38df-0310-8fa8-9805f1628bb7
2000-01-15Merge in the final code to make Ethereal run on Win32, compiledgram1-1/+5
with MSVC 6.0 and 'nmake', the make tool that comes with MSVC. It compiles, links, and runs. It doesn't run correctly. There's a problem when reading files. I'm getting short reads. I'm not linking in zlib or libsnmp because it first needs to be debugged. I changed the plugin code to use gmodule instead of libltdl, but the Unix build still links ethereal against libltdl. I'll fix that tonight; sorry about leaving it in such a sad state, but I wanted to check in this code before I left work on a Friday night. Ethereal still works, but the building is less than optimal. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1479 f5534014-38df-0310-8fa8-9805f1628bb7
2000-01-10Some initial changes for win32 support, but not all.gram1-1/+6
Added lots of #ifdef HAVE_*_H wrappers. Added some #defines in config.h.win32 Check for more headers in configure.in Added prototype for inet_aton() in inet_v6defs.h. Changed "BYTE" token (i.e., #define) in ascend-gramamr.y because it conflicts with a windows definition. Use HEXBYTE instead. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1448 f5534014-38df-0310-8fa8-9805f1628bb7
1999-12-09Move the GTK+ implementations of various UI utilities out of "util.c"guy1-131/+1
into "gtk/ui_util.c", and move the declarations of those UI utilities out of "util.h" into "ui_util.h". (The header file is in the top-level directory, rather than the "gtk" directory, because it declares window-system-independent interfaces to routines with window-system-dependent implementations.) Add to "gtk/ui_util.c" a routine to set the window and icon title. Use that routine to make the title of an Ethereal top-level window be {filename} - Ethereal if there's a capture open, and have "{filename}" be "<capture>" if it's a temporary capture file. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1255 f5534014-38df-0310-8fa8-9805f1628bb7
1999-11-22A "character encoding" variable is now set per packet. The existencegram1-71/+83
of SNA in a packet changes the character encoding from the default ASCII to EBCDIC. The hex-printing routines in the GUI code and in the printing code convert to EBCDIC if appropriate. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1089 f5534014-38df-0310-8fa8-9805f1628bb7
1999-10-19Add ASCII/EBCDIC conversion to TCP Follow window. Also add Close buttongram1-1/+101
for ease-of-use with window managers w/o "destroy" buttons (twm). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@884 f5534014-38df-0310-8fa8-9805f1628bb7
1999-09-24In "try_tempfile()", if the buffer is too short for the temporary fileguy1-1/+5
name, stuff as much of the name as will fit into the buffer before returning an error, so the error message that gets displayed isn't completely mangled. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@716 f5534014-38df-0310-8fa8-9805f1628bb7
1999-09-23Fix the calculation of the temporary file name length inguy1-2/+2
"try_tempfile()" - the first component of the name comes from the "dir" argument, so use its length, not the length of the string in the buffer it should fill in (said buffer may contain garbage, which may not *be* a C string). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@705 f5534014-38df-0310-8fa8-9805f1628bb7
1999-08-23The Single UNIX Specification doesn't say that "mkstemp()" creates theguy1-2/+22
temporary file with mode rw-------, so we won't assume that all UNIXes will do so; instead, we set the umask to 0077 to take away all group and other permissions, attempt to create the file, and then put the umask back (puts into "try_tempfile()", called by "create_tempfile()" to create temporary files, the "umask()" calls that Gilbert put into "capture.c" to deal with the same problem). git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@553 f5534014-38df-0310-8fa8-9805f1628bb7
1999-08-18Small change to create_tempfile, initializing static vars.gram1-7/+8
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@511 f5534014-38df-0310-8fa8-9805f1628bb7
1999-08-18Make a "create_tempfile()" routine that constructs the template to beguy1-1/+87
used by "mkstemp()" into a buffer supplied as an argument, trying several directories for the tempfile, in the same fashion that the BSD (and probably other) "tempnam()" routines do. Have that routine cope with temporary-file directory names that don't end with "/", as "P_tmpdir" doesn't necessarily end with "/" (and doesn't, in GNU "libc" 2.x, at least on Linux); thanks to Gilbert Ramirez for catching this one, and supplying the code to cope with that. Have the code that creates the temporary file for the "Follow TCP Stream" text use it. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@507 f5534014-38df-0310-8fa8-9805f1628bb7
1999-07-09Added the ability to create a read-only ethereal, i.e., one thatgram1-2/+2
doesn't link with libpcap, so no packet captures can be made. The "--disable-pcap" option has been added to the configure script. Docs have been updated. And the string buffer size in the simple_dialog() has been doubled so that Johan's e-mail address in the "About" dialogue window doesn't get chopped off. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@351 f5534014-38df-0310-8fa8-9805f1628bb7