Cope with some of the *other* oddities that Linux ISDN appears to stick
[obnox/wireshark/wip.git] / util.h
1 /* util.h
2  * Utility definitions
3  *
4  * $Id: util.h,v 1.20 2000/07/31 04:53:32 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * 
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  * 
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifndef __UTIL_H__
27 #define __UTIL_H__
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
33 /*
34  * Given a pathname, return:
35  *
36  *      the errno, if an attempt to "stat()" the file fails;
37  *
38  *      EISDIR, if the attempt succeeded and the file turned out
39  *      to be a directory;
40  *
41  *      0, if the attempt succeeded and the file turned out not
42  *      to be a directory.
43  */
44 int test_for_directory(const char *);
45
46 /*
47  * Given a pathname, return the last component.
48  */
49 char *get_basename(char *);
50
51 /*
52  * Given a pathname, return a string containing everything but the
53  * last component.  NOTE: this overwrites the pathname handed into
54  * it....
55  */
56 char *get_dirname(char *);
57
58 int create_tempfile(char *, int, const char *);
59
60 /* Returns the user's home directory, via the HOME environment
61  * variable, or a default directory if HOME is not set */
62 const char* get_home_dir(void);
63
64 /*
65  * Collect command-line arguments as a string consisting of the arguments,
66  * separated by spaces.
67  */
68 char *get_args_as_string(int argc, char **argv, int optind);
69
70 void ASCII_to_EBCDIC(guint8 *buf, guint bytes);
71 guint8 ASCII_to_EBCDIC1(guint8 c);
72 void EBCDIC_to_ASCII(guint8 *buf, guint bytes);
73 guint8 EBCDIC_to_ASCII1(guint8 c);
74
75 #ifdef HAVE_LIBPCAP
76
77 GList *get_interface_list(int *err, char *err_str);
78
79 /* Error values from "get_interface_list()". */
80 #define CANT_GET_INTERFACE_LIST 0       /* error getting list */
81 #define NO_INTERFACES_FOUND     1       /* list is empty */
82
83 void free_interface_list(GList *if_list);
84
85 #endif
86
87 #ifdef __cplusplus
88 }
89 #endif /* __cplusplus */
90
91 #endif /* __UTIL_H__ */