wireshark/util.h
Guy Harris 3d20d56999 Add a routine to check whether a file is a directory or not.
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.

svn path=/trunk/; revision=2190
2000-07-31 04:53:40 +00:00

92 lines
2.4 KiB
C

/* util.h
* Utility definitions
*
* $Id: util.h,v 1.20 2000/07/31 04:53:32 guy 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 __UTIL_H__
#define __UTIL_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* Given a pathname, return:
*
* the errno, if an attempt to "stat()" the file fails;
*
* EISDIR, if the attempt succeeded and the file turned out
* to be a directory;
*
* 0, if the attempt succeeded and the file turned out not
* to be a directory.
*/
int test_for_directory(const char *);
/*
* Given a pathname, return the last component.
*/
char *get_basename(char *);
/*
* Given a pathname, return a string containing everything but the
* last component. NOTE: this overwrites the pathname handed into
* it....
*/
char *get_dirname(char *);
int create_tempfile(char *, int, const char *);
/* 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);
/*
* Collect command-line arguments as a string consisting of the arguments,
* separated by spaces.
*/
char *get_args_as_string(int argc, char **argv, int optind);
void ASCII_to_EBCDIC(guint8 *buf, guint bytes);
guint8 ASCII_to_EBCDIC1(guint8 c);
void EBCDIC_to_ASCII(guint8 *buf, guint bytes);
guint8 EBCDIC_to_ASCII1(guint8 c);
#ifdef HAVE_LIBPCAP
GList *get_interface_list(int *err, char *err_str);
/* Error values from "get_interface_list()". */
#define CANT_GET_INTERFACE_LIST 0 /* error getting list */
#define NO_INTERFACES_FOUND 1 /* list is empty */
void free_interface_list(GList *if_list);
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __UTIL_H__ */