Rev 8849 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8849 | Rev 12474 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | char opt_user[MAX_FNAME+1]; |
24 | char opt_user[MAX_FNAME+1]; |
25 | 25 | ||
26 | /* returns -1 if error */ |
26 | /* returns -1 if error */ |
27 | int options(void) |
27 | int options(void) |
28 | { |
28 | { |
29 |
|
29 | int i; |
30 |
|
30 | char c, *p1, *p2, *p3; |
31 |
|
31 | opt_class[0]=opt_module[0]=opt_session[0]=opt_user[0]=0; |
32 |
|
32 | for(i=0, p1=find_word_start(textptr); *p1=='-'; p1=find_word_start(p2),i++) { |
33 |
|
33 | p1++; c=*p1++; p1=find_word_start(p1); |
34 |
|
34 | p2=find_word_end(p1); if(*p2) *p2++=0; |
35 |
|
35 | switch(c) { |
36 |
|
36 | case 'c': { /* class */ |
37 |
|
37 | if(cwdtype!=dir_home) { |
38 |
|
38 | sockerror(2,"option_conflict"); return -1; |
39 |
|
39 | } |
40 |
|
40 | if(strlen(p1)>=MAX_CLASSLEN || !myisdigit(*p1) || strstr(p1,"..")!=NULL) { |
41 | strstr(p1,"..")!=NULL) { |
- | |
42 |
|
41 | sockerror(2,"illegal_fname %s",p1); |
43 |
|
42 | return -1; |
44 |
|
43 | } |
45 |
|
44 | (void)chdir(classd); if(chdir(p1)<0) { |
46 |
|
45 | sockerror(2,"bad_class %s",p1); |
47 |
|
46 | return -1; |
48 |
|
47 | } |
49 |
|
48 | mystrncpy(opt_class,p1,sizeof(opt_class)); |
50 |
|
49 | cwdtype=dir_class; break; |
51 |
|
50 | } |
52 |
|
51 | case 'm': { /* module */ |
53 |
|
52 | if(cwdtype!=dir_home) { |
54 |
|
53 | sockerror(2,"option_conflict"); return -1; |
55 |
|
54 | } |
56 |
|
55 | if(strlen(p1)>MAX_FNAME || *p1=='/' || strstr(p1,"..")!=NULL) { |
57 |
|
56 | sockerror(2,"illegal_fname %s",p1); |
58 |
|
57 | return -1; |
59 |
|
58 | } |
60 |
|
59 | (void)chdir(modd); if(chdir(p1)<0) { |
61 |
|
60 | sockerror(2,"bad_module:%s",p1); |
62 |
|
61 | return -1; |
63 |
|
62 | } |
64 |
|
63 | mystrncpy(opt_module,p1,sizeof(opt_module)); |
65 |
|
64 | cwdtype=dir_module; break; |
66 |
|
65 | } |
67 |
|
66 | case 's': { /* session */ |
68 |
|
67 | if(cwdtype!=dir_home) { |
69 |
|
68 | sockerror(2,"option_conflict"); return -1; |
70 |
|
69 | } |
71 |
|
70 | if(strlen(p1)>=MAX_CLASSLEN || *p1=='/' || strstr(p1,"..")!=NULL) { |
72 |
|
71 | sockerror(2,"illegal_fname:%s",p1); |
73 |
|
72 | return -1; |
74 |
|
73 | } |
75 |
|
74 | (void)chdir(sesd); if(chdir(p1)<0) { |
76 |
|
75 | sockerror(2,"bad_session:%s",p1); |
77 |
|
76 | return -1; |
78 |
|
77 | } |
79 |
|
78 | mystrncpy(opt_session,p1,sizeof(opt_session)); |
80 |
|
79 | cwdtype=dir_session; break; |
81 |
|
80 | } |
82 |
|
81 | case 'u': { /* user definition */ |
83 |
|
82 | if(strchr(p1,'/')!=NULL) { |
84 |
|
83 | sockerror(2,"illegal_fname %s",p1); |
85 |
|
84 | return -1; |
86 |
|
85 | } |
87 |
|
86 | mystrncpy(opt_user,p1,sizeof(opt_user)); |
88 |
|
87 | for(p3=strchr(opt_user,'.'); p3!=NULL; p3=strchr(p3,'.')) *p3++='@'; |
89 |
|
88 | break; |
90 |
|
89 | } |
91 |
|
90 | default: { |
92 |
|
91 | sockerror(2,"bad_option"); return -1; |
93 | } |
- | |
94 | } |
92 | } |
95 | } |
93 | } |
- | 94 | } |
|
96 |
|
95 | textptr=p1; return i; |
97 | } |
96 | } |
98 | - |