aboutsummaryrefslogtreecommitdiff
path: root/options.h
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-12-04 17:53:56 +0100
committerPetr Machata <pmachata@redhat.com>2013-03-08 22:55:27 +0100
commit418584d25da07c5a9f7a61b74cfe713c1f8d7085 (patch)
tree0f10e7cb859cd2beb126e6f2ba2ed4104bd6e160 /options.h
parent9af3f3ab7a8c44d94f944f15ece10109e6492930 (diff)
downloadltrace-418584d25da07c5a9f7a61b74cfe713c1f8d7085.tar.gz
Convert opt_F_t to support directories as well as files, store in vector
Also allow parsing colon-separated lists into opt_F. This will be useful for -F as well as for parsing some environment variables. This removes bits related to default directories to look into. This will eventually be moved to os_get_config_dirs, currently it's simply disabled. The code in libltrace.c is currently incompatible with opt_F being a vector, so it's disabled as well. Revamp of the whole configury shebang underway.
Diffstat (limited to 'options.h')
-rw-r--r--options.h39
1 files changed, 32 insertions, 7 deletions
diff --git a/options.h b/options.h
index 56f263e..f5b2c2c 100644
--- a/options.h
+++ b/options.h
@@ -27,6 +27,7 @@
#include <sys/time.h>
#include "forward.h"
+#include "vect.h"
struct options_t {
int align; /* -a: default alignment column for results */
@@ -65,16 +66,40 @@ struct opt_p_t {
struct opt_p_t *next;
};
-struct opt_F_t
-{
- struct opt_F_t *next;
- char *filename;
- int own_filename : 1;
+extern struct opt_p_t *opt_p; /* attach to process with a given pid */
+
+enum opt_F_kind {
+ OPT_F_UNKNOWN = 0,
+ OPT_F_BROKEN,
+ OPT_F_FILE,
+ OPT_F_DIR,
};
-extern struct opt_p_t *opt_p; /* attach to process with a given pid */
+struct opt_F_t {
+ char *pathname;
+ int own_pathname : 1;
+ enum opt_F_kind kind : 2;
+};
+
+/* If entry->kind is OPT_F_UNKNOWN, figure out whether it should be
+ * OPT_F_FILE or OPT_F_DIR, cache the result, and return it. Return
+ * OPT_F_BROKEN on failure. Error message will have been printed in
+ * that case. */
+enum opt_F_kind opt_F_get_kind(struct opt_F_t *entry);
+
+/* Destroy and release any memory associated with ENTRY (but don't
+ * free ENTRY itself). */
+void opt_F_destroy(struct opt_F_t *entry);
+
+/* PATHS contains colon-separated list of values, akin to enviroment
+ * variables PATH, PYTHONPATH, and others. No escaping is possible.
+ * The list is split and added to VEC, which shall be a vector
+ * initialized like VECT_INIT(VEC, struct opt_F_t); Returns 0 on
+ * success or a negative value on failure. */
+int parse_colon_separated_list(const char *paths, struct vect *vec);
-extern struct opt_F_t *opt_F; /* alternate configuration file(s) */
+/* Vector of struct opt_F_t. */
+extern struct vect opt_F;
struct opt_c_struct {
int count;