diff options
author | Kjetil Ørbekk <orbekk@pvv.ntnu.no> | 2007-12-25 01:06:12 +0100 |
---|---|---|
committer | Kjetil Ørbekk <orbekk@pvv.ntnu.no> | 2007-12-25 01:06:12 +0100 |
commit | 057a40463753a55f48007d6eb21ed1afb0439208 (patch) | |
tree | 364bfd2318dc764819cd3ad5b74f6f9da7cbbcee | |
parent | cdc6a068f2e8a320f8beeee5b2b950b57645325b (diff) |
- Added *basic* option parsing. (So we can play with a source dir)
-rw-r--r-- | src/mp3_opt_parse.c | 16 | ||||
-rwxr-xr-x | src/mp3fs.c | 13 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/mp3_opt_parse.c b/src/mp3_opt_parse.c new file mode 100644 index 0000000..6419c72 --- /dev/null +++ b/src/mp3_opt_parse.c @@ -0,0 +1,16 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +#include <fuse_opt.h> + +extern char *sourcedir; + +static int mp3fs_opt_proc (void *data, const char *arg, int key, + struct fuse_args *outargs) +{ + if (key == FUSE_OPT_KEY_NONOPT && !sourcedir) { + /* The source directory isn't already set, let's do it */ + sourcedir = arg; + return (0); + } + else + return (1); +} diff --git a/src/mp3fs.c b/src/mp3fs.c index 1a46841..f8e4cba 100755 --- a/src/mp3fs.c +++ b/src/mp3fs.c @@ -1,16 +1,27 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ #define FUSE_USE_VERSION 26 +#include <stdlib.h> #include <stdio.h> #include <fuse.h> + #include "mp3_vnops.c" +#include "mp3_opt_parse.c" /* static struct fuse_module mp3_mod { */ /* .name = "MP3FS" */ /* }; */ +/* Just for testing the argument parsing. TODO: fix something better */ +char *sourcedir = NULL; + int main(int argc, char **argv) { - return fuse_main (argc, argv, &mp3_oper); + struct fuse_args args = FUSE_ARGS_INIT (argc, argv); + + if (fuse_opt_parse(&args, NULL, NULL, mp3fs_opt_proc) != 0) + exit (1); + + return (fuse_main (args.argc, args.argv, &mp3_oper, NULL)); } |