Skip to content

Commit

Permalink
Complete yaws:setup_gconf/2 and yaws:setup_sconf/3
Browse files Browse the repository at this point in the history
In embedded mode, these functions are used to populate #gconf and #sconf
records. Now, all fields can be setup.
  • Loading branch information
Christopher Faulet committed May 3, 2012
1 parent 457d941 commit 02930c9
Showing 1 changed file with 83 additions and 95 deletions.
178 changes: 83 additions & 95 deletions src/yaws.erl
Expand Up @@ -181,46 +181,45 @@ ssl_cachetimeout(S, Cachetimeout) -> S#ssl{cachetimeout = Cachetimeo

setup_gconf([], GC) -> GC;
setup_gconf(GL, GC) ->
#gconf{yaws_dir = lkup(yaws_dir, GL,
GC#gconf.yaws_dir),
trace = lkup(trace, GL,
GC#gconf.trace),
flags = set_gc_flags(lkup(flags, GL, []),
GC#gconf.flags),
logdir = lkup(logdir, GL,
GC#gconf.logdir),
ebin_dir = lkup(ebin_dir, GL,
GC#gconf.ebin_dir),
runmods = lkup(runmods, GL,
GC#gconf.runmods),
keepalive_timeout = lkup(keepalive_timeout, GL,
GC#gconf.keepalive_timeout),
max_num_cached_files = lkup(max_num_cached_files, GL,
GC#gconf.max_num_cached_files),
max_num_cached_bytes = lkup(max_num_cached_bytes, GL,
GC#gconf.max_num_cached_bytes),
max_size_cached_file = lkup(max_size_cached_file, GL,
GC#gconf.max_size_cached_file),
#gconf{yaws_dir = lkup(yaws_dir, GL, GC#gconf.yaws_dir),
trace = lkup(trace, GL, GC#gconf.trace),
flags = set_gc_flags(lkup(flags, GL, []),
GC#gconf.flags),
logdir = lkup(logdir, GL, GC#gconf.logdir),
ebin_dir = lkup(ebin_dir, GL, GC#gconf.ebin_dir),
runmods = lkup(runmods, GL, GC#gconf.runmods),
keepalive_timeout = lkup(keepalive_timeout, GL,
GC#gconf.keepalive_timeout),
keepalive_maxuses = lkup(keepalive_maxuses, GL,
GC#gconf.keepalive_maxuses),
max_num_cached_files = lkup(max_num_cached_files, GL,
GC#gconf.max_num_cached_files),
max_num_cached_bytes = lkup(max_num_cached_bytes, GL,
GC#gconf.max_num_cached_bytes),
max_size_cached_file = lkup(max_size_cached_file, GL,
GC#gconf.max_size_cached_file),
max_connections = lkup(max_connections, GL,
GC#gconf.max_connections),
process_options = lkup(process_options, GL,
GC#gconf.process_options),
large_file_chunk_size = lkup(large_file_chunk_size, GL,
GC#gconf.large_file_chunk_size),
log_wrap_size = lkup(log_wrap_size, GL,
GC#gconf.log_wrap_size),
cache_refresh_secs = lkup(cache_refresh_secs, GL,
GC#gconf.cache_refresh_secs),
mnesia_dir = lkup(mnesia_dir, GL,
GC#gconf.mnesia_dir),
include_dir = lkup(include_dir, GL,
GC#gconf.include_dir),
phpexe = lkup(phpexe, GL,
GC#gconf.phpexe),
yaws = lkup(yaws, GL,
GC#gconf.yaws),
id = lkup(id, GL,
GC#gconf.id),
enable_soap = lkup(enable_soap, GL,
GC#gconf.enable_soap),
soap_srv_mods = lkup(soap_srv_mods, GL,
GC#gconf.soap_srv_mods)
mnesia_dir = lkup(mnesia_dir, GL, GC#gconf.mnesia_dir),
log_wrap_size = lkup(log_wrap_size, GL,
GC#gconf.log_wrap_size),
cache_refresh_secs = lkup(cache_refresh_secs, GL,
GC#gconf.cache_refresh_secs),
include_dir = lkup(include_dir, GL, GC#gconf.include_dir),
phpexe = lkup(phpexe, GL, GC#gconf.phpexe),
yaws = lkup(yaws, GL, GC#gconf.yaws),
id = lkup(id, GL, GC#gconf.id),
enable_soap = lkup(enable_soap, GL, GC#gconf.enable_soap),
soap_srv_mods = lkup(soap_srv_mods, GL,
GC#gconf.soap_srv_mods),
ysession_mod = lkup(ysession_mod, GL,
GC#gconf.ysession_mod),
acceptor_pool_size = lkup(acceptor_pool_size, GL,
GC#gconf.acceptor_pool_size)
}.

set_gc_flags([{tty_trace, Bool}|T], Flags) ->
Expand Down Expand Up @@ -248,65 +247,54 @@ set_gc_flags([], Flags) ->


setup_sconf(DocRoot, D, SL) ->
#sconf{port = lkup(port, SL,
D#sconf.port),
flags = set_sc_flags(lkup(flags, SL, []),
?SC_DEF),
redirect_map = lkup(redirect_map, SL,
D#sconf.redirect_map),
rhost = lkup(rhost, SL,
D#sconf.rhost),
rmethod = lkup(rmethod, SL,
D#sconf.rmethod),
docroot = case lkup(docroot, SL, D#sconf.docroot) of
undefined ->
DocRoot;
DR ->
DR
end,
xtra_docroots = lkup(xtra_docroots, SL,
D#sconf.xtra_docroots),
listen = lkup(listen, SL,
D#sconf.listen),
servername = lkup(servername, SL,
D#sconf.servername),
yaws = lkup(yaws, SL,
D#sconf.yaws),
ets = lkup(ets, SL,
D#sconf.ets),
ssl = setup_sconf_ssl(SL, D#sconf.ssl),
authdirs = lkup(authdirs, expand_auth(SL),
D#sconf.authdirs),
partial_post_size = lkup(partial_post_size, SL,
D#sconf.partial_post_size),
appmods = lkup(appmods, SL,
D#sconf.appmods),
errormod_401 = lkup(errormod_401, SL,
D#sconf.errormod_401),
errormod_404 = lkup(errormod_404, SL,
D#sconf.errormod_404),
errormod_crash = lkup(errormod_crash, SL,
D#sconf.errormod_crash),
arg_rewrite_mod = lkup(arg_rewrite_mod, SL,
D#sconf.arg_rewrite_mod),
opaque = lkup(opaque, SL,
D#sconf.opaque),
start_mod = lkup(start_mod, SL,
D#sconf.start_mod),
allowed_scripts = lkup(allowed_scripts, SL,
D#sconf.allowed_scripts),
#sconf{port = lkup(port, SL, D#sconf.port),
flags = set_sc_flags(lkup(flags, SL, []),
D#sconf.flags),
redirect_map = lkup(redirect_map, SL, D#sconf.redirect_map),
rhost = lkup(rhost, SL, D#sconf.rhost),
rmethod = lkup(rmethod, SL, D#sconf.rmethod),
docroot = case lkup(docroot, SL, D#sconf.docroot) of
undefined -> DocRoot;
DR -> DR
end,
xtra_docroots = lkup(xtra_docroots, SL,
D#sconf.xtra_docroots),
listen = lkup(listen, SL, D#sconf.listen),
servername = lkup(servername, SL, D#sconf.servername),
yaws = lkup(yaws, SL, D#sconf.yaws),
ets = lkup(ets, SL, D#sconf.ets),
ssl = setup_sconf_ssl(SL, D#sconf.ssl),
authdirs = lkup(authdirs, expand_auth(SL),
D#sconf.authdirs),
partial_post_size = lkup(partial_post_size, SL,
D#sconf.partial_post_size),
appmods = lkup(appmods, SL, D#sconf.appmods),
expires = lkup(expires, SL, D#sconf.expires),
errormod_401 = lkup(errormod_401, SL, D#sconf.errormod_401),
errormod_404 = lkup(errormod_404, SL, D#sconf.errormod_404),
errormod_crash = lkup(errormod_crash, SL,
D#sconf.errormod_crash),
arg_rewrite_mod = lkup(arg_rewrite_mod, SL,
D#sconf.arg_rewrite_mod),
logger_mod = lkup(logger_mod, SL, D#sconf.logger_mod),
opaque = lkup(opaque, SL, D#sconf.opaque),
start_mod = lkup(start_mod, SL, D#sconf.start_mod),
allowed_scripts = lkup(allowed_scripts, SL,
D#sconf.allowed_scripts),
tilde_allowed_scripts = lkup(tilde_allowed_scripts, SL,
D#sconf.tilde_allowed_scripts),
revproxy = lkup(revproxy, SL,
D#sconf.revproxy),
soptions = lkup(soptions, SL,
D#sconf.soptions),
extra_cgi_vars = lkup(extra_cgi_vars, SL,
D#sconf.extra_cgi_vars),
stats = lkup(stats, SL, D#sconf.stats),
fcgi_app_server = lkup(fcgi_app_server, SL,
D#sconf.fcgi_app_server),
php_handler = lkup(php_handler, SL, D#sconf.php_handler)}.
revproxy = lkup(revproxy, SL, D#sconf.revproxy),
soptions = lkup(soptions, SL, D#sconf.soptions),
extra_cgi_vars = lkup(extra_cgi_vars, SL,
D#sconf.extra_cgi_vars),
stats = lkup(stats, SL, D#sconf.stats),
fcgi_app_server = lkup(fcgi_app_server, SL,
D#sconf.fcgi_app_server),
php_handler = lkup(php_handler, SL, D#sconf.php_handler),
shaper = lkup(shaper, SL, D#sconf.shaper),
deflate_options = lkup(deflate_options, SL,
D#sconf.deflate_options)
}.

expand_auth(SL) ->
case [A || {auth, A} <- SL] of
Expand Down

0 comments on commit 02930c9

Please sign in to comment.