nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 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 | * This program is free software; you can redistribute it and/or |
||
10 | * modify it under the terms of the GNU General Public License |
||
11 | * as published by the Free Software Foundation; either version 2 |
||
12 | * of the License, or (at your option) any later version. |
||
13 | * |
||
14 | * This program is distributed in the hope that it will be useful, |
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
17 | * GNU General Public License for more details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU General Public License |
||
20 | * along with this program; if not, write to the Free Software |
||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
22 | */ |
||
23 | |||
24 | #include "config.h" |
||
25 | |||
26 | #include <string.h> |
||
27 | #include <errno.h> |
||
28 | |||
29 | #include <glib.h> |
||
30 | |||
31 | #include <wsutil/filesystem.h> |
||
32 | |||
33 | #include "ui/persfilepath_opt.h" |
||
34 | |||
35 | /* |
||
36 | * process command line option that affects the paths of the directories |
||
37 | * used for personal files (configuration, saved captures) |
||
38 | */ |
||
39 | gboolean |
||
40 | persfilepath_opt(int opt _U_, const char *optstr) |
||
41 | { |
||
42 | gchar *p, *colonp; |
||
43 | |||
44 | colonp = strchr(optstr, ':'); |
||
45 | if (colonp == NULL) { |
||
46 | return FALSE; |
||
47 | } |
||
48 | |||
49 | p = colonp; |
||
50 | *p++ = '\0'; |
||
51 | |||
52 | /* |
||
53 | * Skip over any white space (there probably won't be any, but |
||
54 | * as we allow it in the preferences file, we might as well |
||
55 | * allow it here). |
||
56 | */ |
||
57 | while (g_ascii_isspace(*p)) |
||
58 | p++; |
||
59 | if (*p == '\0') { |
||
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 | /* directory should be existing */ |
||
70 | /* XXX - is this a requirement? */ |
||
71 | if(test_for_directory(p) != EISDIR) { |
||
72 | /* |
||
73 | * Put the colon back, so if our caller uses, in an |
||
74 | * error message, the string they passed us, the message |
||
75 | * looks correct. |
||
76 | */ |
||
77 | *colonp = ':'; |
||
78 | return FALSE; |
||
79 | } |
||
80 | |||
81 | if (strcmp(optstr,"persconf") == 0) { |
||
82 | set_persconffile_dir(p); |
||
83 | } else if (strcmp(optstr,"persdata") == 0) { |
||
84 | set_persdatafile_dir(p); |
||
85 | } else { |
||
86 | /* XXX - might need to add the temp file path */ |
||
87 | return FALSE; |
||
88 | } |
||
89 | *colonp = ':'; /* put the colon back */ |
||
90 | return TRUE; |
||
91 | } |
||
92 | |||
93 | /* |
||
94 | * Editor modelines - http://www.wireshark.org/tools/modelines.html |
||
95 | * |
||
96 | * Local variables: |
||
97 | * c-basic-offset: 4 |
||
98 | * tab-width: 8 |
||
99 | * indent-tabs-mode: nil |
||
100 | * End: |
||
101 | * |
||
102 | * vi: set shiftwidth=4 tabstop=8 expandtab: |
||
103 | * :indentSize=4:tabSize=8:noTabs=true: |
||
104 | */ |