1133 |
Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>\\<td title=\\\"Incoming directory is always shared\\\" class=\\\"srb\\\"\\>Incoming\\</td\\> |
Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>\\<td title=\\\"Incoming directory is always shared\\\" class=\\\"srb\\\"\\>Incoming\\</td\\> |
1134 |
\\<td class=\\\"sr ar\\\"\\>0\\</td\\>\\<td title=\\\"Incoming\\\" class=\\\"sr\\\"\\>%s\\</td\\>\\</tr\\>" !!incoming_directory; |
\\<td class=\\\"sr ar\\\"\\>0\\</td\\>\\<td title=\\\"Incoming\\\" class=\\\"sr\\\"\\>%s\\</td\\>\\</tr\\>" !!incoming_directory; |
1135 |
|
|
1136 |
List.iter (fun (dir, prio) -> |
List.iter (fun shared_dir -> |
1137 |
incr counter; |
incr counter; |
1138 |
Printf.bprintf buf "\\<tr class=\\\"%s\\\"\\> |
Printf.bprintf buf "\\<tr class=\\\"%s\\\"\\> |
1139 |
\\<td title=\\\"Click to unshare this directory\\\" |
\\<td title=\\\"Click to unshare this directory\\\" |
1145 |
class=\\\"srb\\\"\\>Unshare\\</td\\> |
class=\\\"srb\\\"\\>Unshare\\</td\\> |
1146 |
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
1147 |
\\<td class=\\\"sr\\\"\\>%s\\</td\\>\\</tr\\>" |
\\<td class=\\\"sr\\\"\\>%s\\</td\\>\\</tr\\>" |
1148 |
(if !counter mod 2 == 0 then "dl-1" else "dl-2") dir prio dir; |
(if !counter mod 2 == 0 then "dl-1" else "dl-2") |
1149 |
|
shared_dir.shdir_dirname |
1150 |
|
shared_dir.shdir_priority |
1151 |
|
shared_dir.shdir_dirname; |
1152 |
) |
) |
1153 |
!!shared_directories; |
!!shared_directories; |
1154 |
|
|
1159 |
|
|
1160 |
Printf.bprintf buf "Shared directories:\n"; |
Printf.bprintf buf "Shared directories:\n"; |
1161 |
Printf.bprintf buf " %d %s\n" !!incoming_directory_prio !!incoming_directory; |
Printf.bprintf buf " %d %s\n" !!incoming_directory_prio !!incoming_directory; |
1162 |
List.iter (fun (dir, prio) -> Printf.bprintf buf " %d %s\n" prio dir) |
List.iter (fun sd -> |
1163 |
|
Printf.bprintf buf " %d %s\n" |
1164 |
|
sd.shdir_priority sd.shdir_dirname) |
1165 |
!!shared_directories; |
!!shared_directories; |
1166 |
|
|
1167 |
end; |
end; |
1169 |
), ":\t\t\t\tprint shared directories"; |
), ":\t\t\t\tprint shared directories"; |
1170 |
|
|
1171 |
"share", Arg_multiple (fun args o -> |
"share", Arg_multiple (fun args o -> |
1172 |
let (prio, arg) = match args with |
let (prio, arg, strategy) = match args with |
1173 |
[prio; arg] -> int_of_string prio, arg |
| [prio; arg; strategy] -> int_of_string prio, arg, strategy |
1174 |
| [arg] -> 0, arg |
| [prio; arg] -> int_of_string prio, arg, "only_directory" |
1175 |
|
| [arg] -> 0, arg, "only_directory" |
1176 |
| _ -> failwith "Bad number of arguments" |
| _ -> failwith "Bad number of arguments" |
1177 |
in |
in |
1178 |
|
|
1179 |
|
let shdir = { |
1180 |
|
shdir_dirname = arg; |
1181 |
|
shdir_priority = prio; |
1182 |
|
shdir_networks = []; |
1183 |
|
shdir_strategy = strategy; |
1184 |
|
} in |
1185 |
|
|
1186 |
if Unix2.is_directory arg then |
if Unix2.is_directory arg then |
1187 |
if not (List.mem_assoc arg !!shared_directories) then begin |
if not (List.mem shdir !!shared_directories) then begin |
1188 |
shared_directories =:= (arg, prio) :: !!shared_directories; |
shared_directories =:= shdir :: !!shared_directories; |
1189 |
shared_add_directory (arg, prio); |
shared_add_directory shdir; |
1190 |
"directory added" |
"directory added" |
1191 |
end else if not (List.mem (arg, prio) !!shared_directories) then begin |
end (* else |
1192 |
|
if not (List.mem (arg, prio) !!shared_directories) then begin |
1193 |
shared_directories =:= (arg, prio) :: List.remove_assoc arg !!shared_directories; |
shared_directories =:= (arg, prio) :: List.remove_assoc arg !!shared_directories; |
1194 |
shared_add_directory (arg, prio); |
shared_add_directory (arg, prio); |
1195 |
"prio changed" |
"prio changed" |
1196 |
end else |
end *) else |
1197 |
"directory already shared" |
"directory already shared" |
1198 |
else |
else |
1199 |
"no such directory" |
"no such directory" |
1200 |
), "<prio> <dir> :\t\t\tshare directory <dir> with <prio>"; |
), "<priority> <dir> [<strategy>] :\t\t\tshare directory <dir> with <priority> [and sharing strategy <strategy>]"; |
1201 |
|
|
1202 |
"unshare", Arg_one (fun arg o -> |
"unshare", Arg_one (fun arg o -> |
1203 |
if List.mem_assoc arg !!shared_directories then begin |
|
1204 |
shared_directories =:= List.remove_assoc arg !!shared_directories; |
let found = ref false in |
1205 |
|
shared_directories =:= List.filter (fun sd -> |
1206 |
|
let diff = sd.shdir_dirname <> arg in |
1207 |
|
if not diff then found := true; |
1208 |
|
diff |
1209 |
|
) !!shared_directories; |
1210 |
|
if !found then begin |
1211 |
CommonShared.shared_check_files (); |
CommonShared.shared_check_files (); |
1212 |
"directory removed" |
"directory removed" |
1213 |
end else |
end else |
1767 |
|
|
1768 |
"log", Arg_none (fun o -> |
"log", Arg_none (fun o -> |
1769 |
let buf = o.conn_buf in |
let buf = o.conn_buf in |
1770 |
(try |
log_to_buffer buf; |
|
while true do |
|
|
let s = Fifo.take lprintf_fifo in |
|
|
decr lprintf_size; |
|
|
Buffer.add_string buf s |
|
|
done |
|
|
with _ -> ()); |
|
1771 |
"------------- End of log" |
"------------- End of log" |
1772 |
), ":\t\t\t\t\tdump current log state to console"; |
), ":\t\t\t\t\tdump current log state to console"; |
1773 |
|
|
1792 |
"stdout", Arg_one (fun arg o -> |
"stdout", Arg_one (fun arg o -> |
1793 |
let buf = o.conn_buf in |
let buf = o.conn_buf in |
1794 |
let b = bool_of_string arg in |
let b = bool_of_string arg in |
1795 |
lprintf_to_stdout := b; |
set_logging b; |
1796 |
Printf.sprintf "log to stdout %s" |
Printf.sprintf "log to stdout %s" |
1797 |
(if b then "enabled" else "disabled") |
(if b then "enabled" else "disabled") |
1798 |
), "<true|false> :\t\t\treactivate log to stdout"; |
), "<true|false> :\t\t\treactivate log to stdout"; |
1838 |
|
|
1839 |
"log_file", Arg_one (fun arg o -> |
"log_file", Arg_one (fun arg o -> |
1840 |
let oc = open_out arg in |
let oc = open_out arg in |
1841 |
(match !lprintf_output with |
log_to_file oc; |
|
Some oc when oc != stdout -> close_out oc |
|
|
| _ -> ()); |
|
|
lprintf_output := Some oc; |
|
|
lprintf_to_stdout := true; |
|
1842 |
"log started" |
"log started" |
1843 |
), "<file> :\t\t\tstart logging in file <file>"; |
), "<file> :\t\t\tstart logging in file <file>"; |
1844 |
|
|
1845 |
"close_log", Arg_none (fun o -> |
"close_log", Arg_none (fun o -> |
1846 |
(match !lprintf_output with |
close_log (); |
|
None -> () | Some oc -> close_out oc); |
|
|
lprintf_output := None; |
|
|
lprintf_to_stdout := false; |
|
1847 |
"log stopped" |
"log stopped" |
1848 |
), ":\t\t\t\tclose logging to file"; |
), ":\t\t\t\tclose logging to file"; |
1849 |
|
|