bgp route refresh/MP capability option.
[obnox/wireshark/wip.git] / util.h
1 /* util.h
2  * Utility definitions
3  *
4  * $Id: util.h,v 1.22 2000/10/11 07:35:00 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 a pointer to the last pathname separator
48  * character in the pathname, or NULL if the pathname contains no
49  * separators.
50  */
51 char *find_last_pathname_separator(char *);
52
53 /*
54  * Given a pathname, return the last component.
55  */
56 char *get_basename(char *);
57
58 /*
59  * Given a pathname, return a string containing everything but the
60  * last component.  NOTE: this overwrites the pathname handed into
61  * it....
62  */
63 char *get_dirname(char *);
64
65 int create_tempfile(char *, int, const char *);
66
67 /* Returns the user's home directory, via the HOME environment
68  * variable, or a default directory if HOME is not set */
69 const char* get_home_dir(void);
70
71 /*
72  * Collect command-line arguments as a string consisting of the arguments,
73  * separated by spaces.
74  */
75 char *get_args_as_string(int argc, char **argv, int optind);
76
77 void ASCII_to_EBCDIC(guint8 *buf, guint bytes);
78 guint8 ASCII_to_EBCDIC1(guint8 c);
79 void EBCDIC_to_ASCII(guint8 *buf, guint bytes);
80 guint8 EBCDIC_to_ASCII1(guint8 c);
81
82 #ifdef HAVE_LIBPCAP
83
84 GList *get_interface_list(int *err, char *err_str);
85
86 /* Error values from "get_interface_list()". */
87 #define CANT_GET_INTERFACE_LIST 0       /* error getting list */
88 #define NO_INTERFACES_FOUND     1       /* list is empty */
89
90 void free_interface_list(GList *if_list);
91
92 #endif
93
94 /* Compute the difference between two seconds/microseconds time stamps. */
95 void compute_timestamp_diff(gint *, gint *, guint32, guint32, guint32, guint32);
96
97 #ifdef __cplusplus
98 }
99 #endif /* __cplusplus */
100
101 #endif /* __UTIL_H__ */