Kerberos: add kerberos_inject_longterm_key() helper function
[wireshark-sm.git] / ui / persfilepath_opt.c
blobee0d420f395d65f5638d20cec9397224b07c869d
1 /* persfilepath_opt.c
2 * Routines to handle command-line options to set paths for directories
3 * containing personal files (configuration, saved captures)
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <string.h>
15 #include <errno.h>
17 #include <glib.h>
19 #include <wsutil/filesystem.h>
21 #include "ui/persfilepath_opt.h"
24 * process command line option that affects the paths of the directories
25 * used for personal files (configuration, saved captures)
27 bool
28 persfilepath_opt(int opt _U_, const char *optstr)
30 char *p, *colonp;
32 colonp = strchr(optstr, ':');
33 if (colonp == NULL) {
34 return false;
37 p = colonp;
38 *p++ = '\0';
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).
45 while (g_ascii_isspace(*p))
46 p++;
47 if (*p == '\0') {
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.
53 *colonp = ':';
54 return false;
57 /* directory should be existing */
58 /* XXX - is this a requirement? */
59 if(test_for_directory(p) != EISDIR) {
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.
65 *colonp = ':';
66 return false;
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;
77 *colonp = ':'; /* put the colon back */
78 return true;