Qt: Remove an unneeded function.
[metze/wireshark/wip.git] / ui / persfilepath_opt.c
1 /* persfilepath_opt.c
2  * Routines to handle command-line options to set paths for directories
3  * containing personal files (configuration, saved captures)
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  */
11
12 #include "config.h"
13
14 #include <string.h>
15 #include <errno.h>
16
17 #include <glib.h>
18
19 #include <wsutil/filesystem.h>
20
21 #include "ui/persfilepath_opt.h"
22
23 /*
24  * process command line option that affects the paths of the directories
25  * used for personal files (configuration, saved captures)
26  */
27 gboolean
28 persfilepath_opt(int opt _U_, const char *optstr)
29 {
30     gchar *p, *colonp;
31
32     colonp = strchr(optstr, ':');
33     if (colonp == NULL) {
34         return FALSE;
35     }
36
37     p = colonp;
38     *p++ = '\0';
39
40     /*
41     * Skip over any white space (there probably won't be any, but
42     * as we allow it in the preferences file, we might as well
43     * allow it here).
44     */
45     while (g_ascii_isspace(*p))
46         p++;
47     if (*p == '\0') {
48         /*
49          * Put the colon back, so if our caller uses, in an
50          * error message, the string they passed us, the message
51          * looks correct.
52          */
53         *colonp = ':';
54         return FALSE;
55     }
56
57     /* directory should be existing */
58     /* XXX - is this a requirement? */
59     if(test_for_directory(p) != EISDIR) {
60         /*
61          * Put the colon back, so if our caller uses, in an
62          * error message, the string they passed us, the message
63          * looks correct.
64          */
65         *colonp = ':';
66         return FALSE;
67     }
68
69     if (strcmp(optstr,"persconf") == 0) {
70         set_persconffile_dir(p);
71     } else if (strcmp(optstr,"persdata") == 0) {
72         set_persdatafile_dir(p);
73     } else {
74         /* XXX - might need to add the temp file path */
75         return FALSE;
76     }
77     *colonp = ':'; /* put the colon back */
78     return TRUE;
79 }
80
81 /*
82  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
83  *
84  * Local variables:
85  * c-basic-offset: 4
86  * tab-width: 8
87  * indent-tabs-mode: nil
88  * End:
89  *
90  * vi: set shiftwidth=4 tabstop=8 expandtab:
91  * :indentSize=4:tabSize=8:noTabs=true:
92  */