-
Notifications
You must be signed in to change notification settings - Fork 0
/
argsparse.c
103 lines (77 loc) · 2.39 KB
/
argsparse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* WINHOMEFS This is a filesystem use for mouting
* and sharing a windows home directory with a linux
* instance without creating the big mess.
*
* This file system is written by John-Charles D. Sokolow
* Copyright (C) 2011-1012 John-Charles D. Sokolow <john.charles.sokolow@gmail.com>
*
* Based heavily on the example fuse file system "fusexmp_fh.c"
* Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
*
*
* License: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by
* the Free Software Foundation; Version 2 This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*/
#include <fuse_opt.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include "utilities.h"
char * preparse_opts( int * argc, char * argv[], list_t * fuse_args ){
if ( *argc < 3 ){
puts("Sorry invalid number of arguments...");
puts("Expecting exec_name /path/to/source/directory /path/to/mountpoint");
exit(1);
}
char * root = 0;
int i;
list_t_append( fuse_args, argv[0] );
for( i = 1; i < *argc; i++ ){
if( strcmp( argv[i], "-o" ) == 0 ){
list_t_append( fuse_args, "-o" );
list_t_append( fuse_args, argv[i+1] );
i++;
/* skip this option */
} else if( argv[i][0] == '-' ){
list_t_append( fuse_args, argv[i] );
} else if( root == 0 ){
root = cat( argv[i], "", 0 );
} else {
list_t_append( fuse_args, argv[i] );
}
}
list_t_print( fuse_args );
return root;
}
// char * map_dir = 0;
// int i;
// for (i = 1; (i < argc) && (argv[i][0] == '-'); i++){
// if (argv[i][1] == 'o'){
// i++;
// // -o takes a parameter; need to
// // skip it too. This doesn't
// // handle "squashed" parameters
// } else if ((argc - i) != 2){
// puts("Error parsing command arguments...");
// return 0;
// } else {
//
//
//
// map_dir = argv[i];
// argv[i] = argv[i + 1];
// argc--;
//
// }
//
// for(i = 0; i < argc; i++ ){
// puts( argv[i] );
// }
struct fuse_args * parse( int argc, char * argv[] ){
return 0;
}