Skip to content
Browse files

Initial revision

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@2 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
0 parents commit 21abc5ba8d8491b20a85e5211618541cd4ffccea @klacke committed
Showing with 5,440 additions and 0 deletions.
  1. +20 −0 Makefile
  2. +41 −0 bin/yaws
  3. BIN ebin/bassert.beam
  4. +1,180 −0 ebin/erl_crash.dump
  5. +8 −0 ebin/ewww.app
  6. BIN ebin/ewww.beam
  7. BIN ebin/ewww_app.beam
  8. BIN ebin/ewww_config.beam
  9. BIN ebin/ewww_server.beam
  10. BIN ebin/ewww_sup.beam
  11. +8 −0 ebin/yaws.app
  12. BIN ebin/yaws.beam
  13. BIN ebin/yaws_api.beam
  14. BIN ebin/yaws_app.beam
  15. BIN ebin/yaws_config.beam
  16. BIN ebin/yaws_debug.beam
  17. BIN ebin/yaws_log.beam
  18. BIN ebin/yaws_ls.beam
  19. BIN ebin/yaws_server.beam
  20. BIN ebin/yaws_sup.beam
  21. +47 −0 include.mk
  22. +131 −0 include.mk.in
  23. +49 −0 include/yaws_api.hrl
  24. +99 −0 priv/mime.types
  25. +14 −0 scripts/Makefile
  26. +8 −0 scripts/mangle
  27. +8 −0 scripts/yaws.conf
  28. +10 −0 scripts/yaws.conf.template
  29. +41 −0 scripts/yaws.ss
  30. +46 −0 src/Makefile
  31. +8 −0 src/yaws.app.src
  32. +20 −0 src/yaws.conf
  33. +501 −0 src/yaws.erl
  34. +49 −0 src/yaws.hrl
  35. +149 −0 src/yaws_api.erl
  36. +23 −0 src/yaws_app.erl
  37. +292 −0 src/yaws_config.erl
  38. +120 −0 src/yaws_debug.erl
  39. +75 −0 src/yaws_debug.hrl
  40. +163 −0 src/yaws_log.erl
  41. +121 −0 src/yaws_ls.erl
  42. +1,264 −0 src/yaws_server.erl
  43. +39 −0 src/yaws_sup.erl
  44. +1 −0 vsn.mk
  45. +5 −0 www/.xvpics/hyber.org.gif
  46. +5 −0 www/.xvpics/hyber_org.jpg
  47. +70 −0 www/EXHEAD
  48. +51 −0 www/HEAD
  49. +20 −0 www/TOPTAB
  50. +62 −0 www/configuration.yaws
  51. +116 −0 www/dynamic.yaws
  52. +18 −0 www/examples.yaws
  53. +40 −0 www/form.yaws
  54. BIN www/icons/PythonPowered.png
  55. +158 −0 www/icons/README
  56. BIN www/icons/a.gif
  57. BIN www/icons/alert.black.gif
  58. BIN www/icons/alert.red.gif
  59. BIN www/icons/apache_pb.gif
  60. BIN www/icons/back.gif
  61. BIN www/icons/ball.gray.gif
  62. BIN www/icons/ball.red.gif
  63. BIN www/icons/binary.gif
  64. BIN www/icons/binhex.gif
  65. BIN www/icons/blank.gif
  66. BIN www/icons/bomb.gif
  67. BIN www/icons/box1.gif
  68. BIN www/icons/box2.gif
  69. BIN www/icons/broken.gif
  70. BIN www/icons/burst.gif
  71. BIN www/icons/c.gif
  72. BIN www/icons/comp.blue.gif
  73. BIN www/icons/comp.gray.gif
  74. BIN www/icons/compressed.gif
  75. BIN www/icons/continued.gif
  76. BIN www/icons/dir.gif
  77. BIN www/icons/down.gif
  78. BIN www/icons/dvi.gif
  79. BIN www/icons/erl.gif
  80. BIN www/icons/f.gif
  81. BIN www/icons/folder.gif
  82. BIN www/icons/folder.open.gif
  83. BIN www/icons/folder.sec.gif
  84. BIN www/icons/forward.gif
  85. BIN www/icons/generic.gif
  86. BIN www/icons/generic.red.gif
  87. BIN www/icons/generic.sec.gif
  88. BIN www/icons/gnu-head-tiny.jpg
  89. BIN www/icons/hand.right.gif
  90. BIN www/icons/hand.up.gif
  91. BIN www/icons/hrl.gif
  92. BIN www/icons/icon.sheet.gif
  93. BIN www/icons/image1.gif
  94. BIN www/icons/image2.gif
  95. BIN www/icons/image3.gif
  96. BIN www/icons/index.gif
  97. BIN www/icons/layout.gif
  98. BIN www/icons/left.gif
  99. BIN www/icons/link.gif
  100. BIN www/icons/mailman-large.jpg
  101. BIN www/icons/mailman.jpg
  102. BIN www/icons/movie.gif
  103. BIN www/icons/p.gif
  104. BIN www/icons/patch.gif
  105. BIN www/icons/pdf.gif
  106. BIN www/icons/php4.gif
  107. BIN www/icons/pie0.gif
  108. BIN www/icons/pie1.gif
  109. BIN www/icons/pie2.gif
  110. BIN www/icons/pie3.gif
  111. BIN www/icons/pie4.gif
  112. BIN www/icons/pie5.gif
  113. BIN www/icons/pie6.gif
  114. BIN www/icons/pie7.gif
  115. BIN www/icons/pie8.gif
  116. BIN www/icons/portal.gif
  117. BIN www/icons/ps.gif
  118. BIN www/icons/quill.gif
  119. BIN www/icons/right.gif
  120. BIN www/icons/screw1.gif
  121. BIN www/icons/screw2.gif
  122. BIN www/icons/script.gif
  123. +6 −0 www/icons/small/README.txt
  124. BIN www/icons/small/back.gif
  125. BIN www/icons/small/binary.gif
  126. BIN www/icons/small/binhex.gif
  127. BIN www/icons/small/blank.gif
  128. BIN www/icons/small/broken.gif
  129. BIN www/icons/small/burst.gif
  130. BIN www/icons/small/comp1.gif
  131. BIN www/icons/small/comp2.gif
  132. BIN www/icons/small/compressed.gif
  133. BIN www/icons/small/continued.gif
  134. BIN www/icons/small/dir.gif
  135. BIN www/icons/small/dir2.gif
  136. BIN www/icons/small/doc.gif
  137. BIN www/icons/small/forward.gif
  138. BIN www/icons/small/generic.gif
  139. BIN www/icons/small/generic2.gif
  140. BIN www/icons/small/generic3.gif
  141. BIN www/icons/small/image.gif
  142. BIN www/icons/small/image2.gif
  143. BIN www/icons/small/index.gif
  144. BIN www/icons/small/key.gif
  145. BIN www/icons/small/movie.gif
  146. BIN www/icons/small/patch.gif
  147. BIN www/icons/small/ps.gif
  148. BIN www/icons/small/rainbow.gif
  149. BIN www/icons/small/sound.gif
  150. BIN www/icons/small/sound2.gif
  151. BIN www/icons/small/tar.gif
  152. BIN www/icons/small/text.gif
  153. BIN www/icons/small/transfer.gif
  154. BIN www/icons/small/unknown.gif
  155. BIN www/icons/small/uu.gif
  156. BIN www/icons/sound1.gif
  157. BIN www/icons/sound2.gif
  158. BIN www/icons/sphere1.gif
  159. BIN www/icons/sphere2.gif
  160. BIN www/icons/tar.gif
  161. BIN www/icons/tex.gif
  162. BIN www/icons/text.gif
  163. BIN www/icons/transfer.gif
  164. BIN www/icons/unknown.gif
  165. BIN www/icons/up.gif
  166. BIN www/icons/uu.gif
  167. BIN www/icons/uuencoded.gif
  168. BIN www/icons/world1.gif
  169. BIN www/icons/world2.gif
  170. BIN www/icons/yaws.gif
  171. BIN www/icons/yawsY.gif
  172. BIN www/icons/yaws_head.gif
  173. BIN www/icons/yaws_pb.gif
  174. +89 −0 www/index.html
  175. +41 −0 www/index.yaws
  176. +24 −0 www/motivation.yaws
  177. +40 −0 www/post.yaws
  178. +52 −0 www/simple.yaws
  179. +6 −0 www/simple_ex1.yaws
  180. +11 −0 www/simple_ex2.yaws
  181. BIN www/spacer.gif
  182. +46 −0 www/todo.yaws
  183. +45 −0 www/top.yaws
20 Makefile
@@ -0,0 +1,20 @@
+SUBDIRS = src scripts
+
+
+all:
+ @set -e ; \
+ for d in $(SUBDIRS) ; do \
+ if [ -f $$d/Makefile ]; then ( cd $$d && $(MAKE) ) || exit 1 ; fi ; \
+ done
+
+clean:
+ @for d in $(SUBDIRS) ; do \
+ if [ -f $$d/Makefile ]; then ( cd $$d && $(MAKE) clean ) fi ; \
+ done
+
+
+install:
+ @for d in $(SUBDIRS) ; do \
+ if [ -f $$d/Makefile ]; then ( cd $$d && $(MAKE) clean ) fi ; \
+ done
+
41 bin/yaws
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+
+yawsdir=/home/klacke/yaws/scripts/../ebin
+erl=/usr/local/r8/bin/erl
+
+
+help()
+{
+ echo "usage: yaws -i -- interactive (no daemon) mode"
+ echo " yaws -d -- debug mode"
+ echo " yaws -c file -- set config file"
+ exit 1
+}
+
+
+debug=false
+daemon=" -daemon "
+
+while [ $# -gt 0 ]
+do
+ arg=$1
+ shift;
+ case $arg in
+ -i)
+ daemon=""
+ break;;
+ -d)
+ debug=true
+ break;;
+ -c)
+ conf=$1
+ shift
+ break;;
+ *)
+ help
+ esac
+done
+
+exec $erl $daemon -pa $yawsdir -s yaws -yaws conf xx$conf debug xx$debug
+
BIN ebin/bassert.beam
Binary file not shown.
1,180 ebin/erl_crash.dump
@@ -0,0 +1,1180 @@
+<Erlang crash dump>
+Mon Jan 28 21:38:24 2002
+
+Slogan: init terminating in do_boot ()
+
+
+Erlang (BEAM) emulator version 5.1
+Compiled on Wed Nov 14 00:37:35 2001
+
+Process Information
+--------------------------------------------------
+<0.0.0> Running. Registered as: init
+Spawned as: otp_ring0:start/2
+Message buffer data: 7 words
+Link list: [<0.2.0>]
+Reductions 106 stack+heap 233 old_heap_sz=144
+Heap unused=5 OldHeap unused=144
+Stack dump:
+program counter = 0x81c25c4 (init:boot_loop/2 + 32)
+cp = 0x81c2444 (init:things_to_string/1 + 68)
+
+0x81d4740 Return addr 0x8114B48 (<terminate process normally>)
+--------------------------------------------------
+<0.2.0> Waiting. Registered as: erl_prim_loader
+Spawned as: erl_prim_loader:start_it/4
+Message buffer data: 0 words
+Link list: [<0.0.0>,#Port<0.1>]
+Reductions 1277 stack+heap 610 old_heap_sz=0
+Heap unused=452 OldHeap unused=0
+Stack dump:
+program counter = 0x81cf0f4 (erl_prim_loader:loop/3 + 52)
+cp = 0x8114b48 (<terminate process normally>)
+arity = 0
+
+0x81b2ffc Return addr 0x8114B48 (<terminate process normally>)
+y(0) ["."]
+y(1) <0.1.0>
+y(2) {state,[],none,get_from_port_efile,efile_stop_port,exit_port,#Port<0.1>,infinity,dummy_in_handler}
+y(3) infinity
+--------------------------------------------------
+
+Zombie Process Information
+Processes kept: 0
+--------------------------------------------------
+
+Port Information
+--------------------------------------------------
+<1>
+Connected: <0.2.0>
+Links: <0.2.0>
+Port controls linked-in driver: efile
+--------------------------------------------------
+
+Internal Table Information
+--------------------------------------------------
+Hash Table(atom_tab), size(2411), used(862), objs(1051), depth(4)
+Index Table(atom_tab), size(3000), limit(1048576), used(1051), rate(100)
+Atom space 4966/32772
+Hash Table(module_code), size(47), used(5), objs(5), depth(1)
+Index Table(module_code), size(50), limit(65536), used(5), rate(10)
+Hash Table(export_list), size(397), used(267), objs(420), depth(5)
+Index Table(export_list), size(500), limit(65536), used(420), rate(100)
+Hash Table(process_reg), size(11), used(2), objs(2), depth(1)
+Hash Table(fun_table), size(23), used(6), objs(6), depth(1)
+Mmap chunks 0
+Mmap size 0/0
+Allocated binary data 0
+Allocated by process_desc 5520
+Allocated by table_desc 1520
+Allocated by link_desc 720
+Allocated by atom_desc 25440
+Allocated by export_desc 20160
+Allocated by module_desc 800
+Allocated by preg_desc 400
+Allocated by erts_fun_desc 1040
+--------------------------------------------------
+
+ETS tables
+--------------------------------------------------
+
+Timers
+--------------------------------------------------
+--------------------------------------------------
+
+Distribution Information
+Not alive
+
+Loaded Modules Information
+--------------------------------------------------
+otp_ring0 481
+init 28268
+prim_inet 34816
+prim_file 25290
+erl_prim_loader 14031
+
+Totals. Current code = 102886 Old code = 0
+--------------------------------------------------
+
+Fun table
+--------------------------------------------------
+module=init uniq=62364181 index=1:
+ address=0x81c82c0
+ refc=1
+
+module=init uniq=63089527 index=3:
+ address=0x81c8288
+ refc=1
+
+module=init uniq=51435543 index=2:
+ address=0x81c82a4
+ refc=1
+
+module=prim_file uniq=117922883 index=1:
+ address=0x81ce6c4
+ refc=2
+
+module=init uniq=63592022 index=0:
+ address=0x81c82dc
+ refc=1
+
+module=prim_file uniq=10167612 index=0:
+ address=0x81ce6e0
+ refc=1
+
+
+Atoms
+--------------------------------------------------
+false
+true
+'_'
+'nonode@nohost'
+'$end_of_table'
+fun
+infinity
+timeout
+normal
+call
+return
+'DOWN'
+'EXIT'
+all
+allocated
+allocated_areas
+allocator
+atom_desc
+atom_space
+atom_table
+and
+andalso
+andthen
+arity
+attributes
+backtrace
+backtrace_depth
+badarg
+badarith
+badarity
+badcookie
+badfile
+badmatch
+badsig
+badfun
+bag
+band
+binary
+bnot
+bor
+bxor
+breakpoint
+bsl
+bsr
+caller
+case_clause
+catchlevel
+cd
+clear
+close
+closed
+command
+compile
+compressed
+connect
+connected
+const
+context_switches
+current_function
+data
+debug_flags
+dexit
+depth
+dgroup_leader
+dictionary
+disable_trace
+display_items
+dist
+'/'
+div
+dlink
+dmonitor_node
+dmonitor_p
+'$$'
+'$_'
+'$dictionary'
+dsend
+dunlink
+duplicate_bag
+elib_malloc
+emulator
+enable_trace
+env
+eof
+eol
+'=:='
+'=='
+erlang
+'ERROR'
+error
+error_handler
+error_logger
+exit_status
+existing
+exiting
+export_desc
+export_table
+exports
+fd
+fix_alloc
+fixed_deletion_desc
+flags
+fullsweep_after
+fullsweep_if_old_binaries
+function
+functions
+function_clause
+garbage_collection
+gc_end
+gc_start
+'>='
+generational
+get_seq_token
+get_tcw
+getenv
+getting_linked
+getting_unlinked
+glibc
+global
+'>'
+heap_size
+heap_sizes
+hidden
+hide
+high
+hipe_architecture
+id
+if_clause
+imports
+in
+index
+initial_call
+input
+internal_error
+instruction_counts
+invalid
+is_seq_trace
+io
+keep_zombies
+keypos
+kill
+killed
+known
+label
+last_calls
+'=<'
+line
+link_desc
+links
+loaded_code
+local
+low
+'<'
+machine
+match_spec
+max
+maximum
+max_tables
+max_processes
+mbuf_size
+memory
+mesg_desc
+message
+message_queue_len
+messages
+min_heap_size
+'-'
+mmap
+mmap_blocks_size
+mmap_chunks
+mmap_chunks_size
+mmap_max
+mmap_table
+mmap_threshold
+module
+module_desc
+module_info
+module_table
+monitored_by
+monitors
+more
+name
+named_table
+native_addresses
+'=/='
+'/='
+net_kernel
+new
+new_index
+new_uniq
+nocatch
+noconnection
+nocookie
+node
+nodedown
+noeol
+nofile
+noproc
+not
+not_purged
+notalive
+nouse_stdio
+objects
+old_heap_size
+on_load
+or
+ordered_set
+orelse
+os_type
+os_version
+out
+output
+owner
+packet
+plist_desc
+'+'
+pid
+port
+preg_desc
+print
+priority
+private
+process
+process_desc
+process_count
+process_limit
+process_dump
+procs
+protected
+protection
+public
+purify
+quantify
+receive
+recent_size
+reductions
+register
+register_table
+registered_name
+refc
+rem
+return_from
+return_to
+return_trace
+run_queue
+runnable
+running
+runtime
+save_calls
+see_zombies
+sequential_tracer
+sequential_trace_token
+serial
+set
+set_on_first_link
+set_on_first_spawn
+set_on_link
+set_on_spawn
+set_seq_token
+set_tcw
+silent
+size
+sl_alloc
+stack_size
+start
+static
+status
+stderr_to_stdout
+stop
+stream
+suspend
+suspended
+system_limit
+system_version
+'SYSTEM'
+table
+table_desc
+this
+thread_pool_size
+'THROW'
+timeout_value
+'*'
+timestamp
+top_pad
+total
+trace
+trace_ts
+traced
+trace_control_word
+tracer
+trap_exit
+trim_threshold
+type
+undef
+undefined
+undefined_function
+undefined_lambda
+unregister
+ultrasparc_read_pic1
+ultrasparc_read_tick1
+ultrasparc_read_pic2
+ultrasparc_read_tick2
+ultrasparc_set_pcr
+use_mmap_table
+use_stdio
+used
+uniq
+value
+version
+visible
+waiting
+wall_clock
+xor
+abs
+append
+apply
+atom_to_list
+binary_to_list
+binary_to_term
+check_process_code
+concat_binary
+date
+delete_module
+display
+display_string
+display_nl
+element
+erase
+exit
+external_size
+float
+float_to_list
+fun_info
+function_exported
+garbage_collect
+get
+get_keys
+group_leader
+halt
+hash
+phash
+hd
+info
+integer_to_list
+is_alive
+length
+link
+list_to_atom
+list_to_binary
+list_to_float
+list_to_integer
+list_to_pid
+list_to_tuple
+load_module
+loaded
+localtime
+localtime_to_universaltime
+make_ref
+md5
+md5_init
+md5_update
+md5_final
+module_loaded
+monitor_node
+nodes
+now
+open_port_prim
+pid_to_list
+port_info
+ports
+pre_loaded
+process_flag
+process_info
+processes
+purge_module
+put
+registered
+round
+self
+send
+setelement
+spawn
+spawn_link
+split_binary
+statistics
+subtract
+term_to_binary
+throw
+time
+tl
+trunc
+tuple_to_list
+universaltime
+universaltime_to_localtime
+unlink
+whereis
+spawn_opt
+setnode
+dist_exit
+dist_unlink
+dist_link
+port_call
+port_command
+port_control
+port_close
+port_connect
+port_set_data
+port_get_data
+trace_pattern
+trace_info
+suspend_process
+resume_process
+yield
+bump_reductions
+math
+cos
+cosh
+sin
+sinh
+tan
+tanh
+acos
+acosh
+asin
+asinh
+atan
+atanh
+erf
+erfc
+exp
+log
+log10
+sqrt
+atan2
+pow
+old_binary_to_term
+start_timer
+send_after
+cancel_timer
+read_timer
+make_tuple
+append_element
+seq_trace
+seq_trace_info
+seq_trace_print
+system_flag
+system_info
+ref_to_list
+port_to_list
+fun_to_list
+monitor
+demonitor
+process_display
+is_process_alive
+fault
+is_builtin
+'!'
+'++'
+'--'
+is_atom
+is_list
+is_tuple
+is_constant
+is_float
+is_integer
+is_number
+is_pid
+is_port
+is_reference
+is_binary
+is_function
+is_record
+match_spec_test
+'$put'
+'$get'
+'$get_keys'
+'$erase'
+ets
+db_delete
+delete
+delete_all_objects
+delete_object
+first
+fixtable
+lookup
+lookup_element
+db_info
+last
+match
+match_object
+member
+next
+prev
+insert
+rename
+safe_fixtable
+slot
+update_counter
+select
+select_reverse
+select_delete
+match_spec_compile
+match_spec_run
+os
+putenv
+getpid
+lists
+reverse
+keymember
+keysearch
+vector
+from_list
+to_list
+erts_debug
+disassemble
+make_fun
+same
+flat_size
+code
+get_chunk
+module_md5
+make_stub_module
+is_module_native
+delete_trap
+select_trap
+ok
+tcp
+tcp_closed
+tcp_error
+udp
+udp_closed
+udp_error
+inet_async
+inet_reply
+empty_out_q
+http_eoh
+http_header
+http_request
+http_response
+http_error
+abs_path
+absoluteURI
+http
+https
+scheme
+'Cache-Control'
+'Connection'
+'Date'
+'Pragma'
+'Transfer-Encoding'
+'Upgrade'
+'Via'
+'Accept'
+'Accept-Charset'
+'Accept-Encoding'
+'Accept-Language'
+'Authorization'
+'From'
+'Host'
+'If-Modified-Since'
+'If-Match'
+'If-None-Match'
+'If-Range'
+'If-Unmodified-Since'
+'Max-Forwards'
+'Proxy-Authorization'
+'Range'
+'Referer'
+'User-Agent'
+'Age'
+'Location'
+'Proxy-Authenticate'
+'Public'
+'Retry-After'
+'Server'
+'Vary'
+'Warning'
+'Www-Authenticate'
+'Allow'
+'Content-Base'
+'Content-Encoding'
+'Content-Language'
+'Content-Length'
+'Content-Location'
+'Content-Md5'
+'Content-Range'
+'Content-Type'
+'Etag'
+'Expires'
+'Last-Modified'
+'Accept-Ranges'
+'Set-Cookie'
+'Set-Cookie2'
+'X-Forwarded-For'
+'Cookie'
+'Keep-Alive'
+'Proxy-Connection'
+'OPTIONS'
+'GET'
+'HEAD'
+'POST'
+'PUT'
+'DELETE'
+'TRACE'
+otp_ring0
+boot
+init
+run
+fatal
+get_arguments
+get_plain_arguments
+get_argument
+script_id
+bs2as
+bs2ss
+get_args
+get_flag
+get_flags
+get_status
+fetch_loaded
+ensure_loaded
+make_permanent
+request
+restart
+reboot
+prepare_run_args
+s
+b2a
+b2s
+map
+values_to_atoms_again
+flags_to_atoms_again
+starting
+state
+to_string
+things_to_string
+halt_string
+crash
+boot_loop
+progress
+started
+garb_boot_loop
+new_kernelpid
+ignore
+loop
+not_allowed
+handle_msg
+new_state
+do_handle_msg
+notfound
+user
+'-boot'
+'-config'
+set_flag
+stopping
+do_stop
+clear_system
+stop_heart
+shutdown
+shutdown_pids
+get_heart
+heart
+shutdown_kernel_pid
+shutdown_loop
+shutdown_timeout
+resend
+kill_all_pids
+alive_processes
+filter
+get_pids
+kill_em
+kill_all_ports
+unload
+do_unload
+sub
+del
+terminate
+kernel_pid
+sleep
+start_prim_loader
+erl_prim_loader
+set_path
+add_to_kernel
+prim_load_flags
+'-loader'
+'-hosts'
+none
+'-id'
+'-path'
+do_boot
+'-root'
+'-mode'
+'-init_debug'
+'-boot_var'
+bootfile
+path_flags
+'-pa'
+'-pz'
+get_boot
+not_found
+'can not get bootfile'
+'bootfile format error'
+get_file
+script
+eval_script
+kernel_load_completed
+embedded
+path
+primLoad
+preLoaded
+kernelProcess
+debug
+load_modules
+fix_path
+add_var
+extract_var
+get_var_value
+get_var_val
+start_in_kernel
+start_em
+start_it
+load_mod
+shutdown_timer
+'-shutdown_time'
+timer
+flush_timout
+parse_boot_args
+arg
+start_extra_arg
+end_args
+start_arg
+start_arg2
+flag
+check
+get_flag_list
+get_flag_args
+to_strings
+get_argument1
+set_argument
+concat
+search
+extension
+'-values_to_atoms_again/1-fun-0-'
+'-boot/1-fun-0-'
+'-bs2ss/1-fun-0-'
+'-bs2as/1-fun-0-'
+'can not load'
+'unexpected command in bootfile'
+prim_inet
+open
+inet6
+inet
+einval
+fdopen
+open1
+fdopen1
+open0
+dgram
+udp_inet
+tcp_inet
+subs_empty_out_q
+close_pend_loop
+send_pend
+bind
+connect0
+async_connect
+accept
+accept0
+accept_opts
+keepalive
+nodelay
+active
+async_accept
+listen
+sendto
+recv
+recv0
+async_recv
+recvfrom
+recvfrom0
+peername
+setpeername
+sockname
+setsockname
+setopt
+setopts
+getopt
+getopts
+getiflist
+ifget
+ifset
+subscribe
+getstat
+getfd
+getindex
+gettype
+getstatus
+gethostname
+getservbyname
+getservbyname1
+getservbyport
+getservbyport1
+unrecv
+detach
+attach
+is_sockopt_val
+enc_opt
+send_timeout
+bit8
+low_watermark
+high_watermark
+exit_on_close
+deliver
+mode
+header
+buffer
+drop_membership
+add_membership
+multicast_loop
+multicast_ttl
+multicast_if
+recbuf
+sndbuf
+broadcast
+linger
+dontroute
+reuseaddr
+dec_opt
+type_opt
+httph
+tpkt
+fcgi
+cdr
+asn1
+sunrm
+raw
+enum
+off
+on
+once
+term
+list
+ip
+bool
+int
+uint
+type_value
+bitenumlist
+ether
+enc_value
+loopback
+any
+dec_value
+borlist
+enum_vals
+enum_names
+enum_val
+enum_name
+encode_opt_val
+enc_opt_val
+encode_opts
+enc_opts
+decode_opt_val
+dec_opt_val
+type_ifopt
+netmask
+addr
+broadaddr
+dstaddr
+mtu
+hwaddr
+multicast
+no_pointtopoint
+pointtopoint
+no_broadcast
+down
+up
+enc_ifopt
+dec_ifopt
+decode_ifopts
+encode_ifopts
+encode_ifopt_val
+encode_subs
+enc_subs
+decode_subs
+dec_subs
+encode_stats
+enc_stats
+send_oct
+recv_oct
+send_avg
+send_max
+send_cnt
+recv_dvi
+recv_avg
+recv_max
+recv_cnt
+decode_stats
+dec_stats
+dec_status
+bound
+connecting
+accepting
+listening
+busy
+enc_time
+encode_ifname
+build_iflist
+rev
+ip_to_bytes
+ip4_to_bytes
+ip6_to_bytes
+get_ip
+get_ip4
+get_ip6
+ctl_cmd
+internal
+prim_file
+efile
+open_int
+open_int_setopts
+file_descriptor
+write
+pwrite
+pwrite_int
+sync
+read
+enomem
+pread
+pread_int
+position
+truncate
+copy
+file
+copy_opened
+ipread_s32bu_p32bu
+read_file
+write_file
+get_cwd
+get_cwd_int
+set_cwd
+set_cwd_int
+vxworks
+filename
+absname
+delete_int
+rename_int
+make_dir
+make_dir_int
+del_dir
+del_dir_int
+read_file_info
+read_file_info_int
+write_file_info
+write_file_info_int
+file_info
+make_link
+make_link_int
+make_symlink
+make_symlink_int
+read_link
+read_link_int
+read_link_info
+read_link_info_int
+list_dir
+list_dir_int
+drv_open
+emfile
+drv_close
+drv_command
+drv_get_response
+port_died
+drv_get_responses
+open_mode
+read_ahead
+delayed_write
+lseek_position
+bof
+cur
+translate_response
+bad_response_from_port
+transform_ints
+file_type
+symlink
+regular
+directory
+device
+other
+file_access
+read_write
+int_to_bytes
+date_to_bytes
+i32
+getints
+transform_ldata
+lists_split
+premature_end_of_list
+'-drv_command/2-fun-0-'
+'-list_dir_int/2-fun-0-'
+get_from_port_inet
+stop_port
+inet_exit_port
+dummy_in_handler
+get_from_port_efile
+efile_stop_port
+exit_port
+get_from_port
+init_ack
+get_path
+handle_input
+get_from_port1
+'prim_load port died'
+die
+get_from_port_efile1
+find_master
+connect_master
+ebusy
+find_loop
+find_collect
+noport
+badrecord
+inet_in_handler
+get_from_port_inet1
+tcp_options
+tcp_timeout
+udp_options
+ll_tcp_connect
+ll_udp_open
+ll_open_set_bind
+ll_close
+port_error
+absolute_filename
+win32
+send_all
+keysort
+keyins
+to_strs
+ipv4_list
+einal
+ipv4_address
+ipv4_addr
+'-progname'
+'-home'
+'no -loader flag'
+'no -hosts flag'
+'no -id flag'
+'no -path flag'
+unix
+linux
+enoent
+'start-sasl.boot'
+
+<End of Erlang crash dump>
8 ebin/ewww.app
@@ -0,0 +1,8 @@
+{application,ewww,
+ [{description,"E WWW server"},
+ {vsn,""},
+ {modules,[ewww, ewww_app, bassert, ewww_config, ewww_server, ewww_sup]},
+ {registered, []},
+ {mod,{ewww_app,[]}},
+ {env, []},
+ {applications,[kernel,stdlib]}]}.
BIN ebin/ewww.beam
Binary file not shown.
BIN ebin/ewww_app.beam
Binary file not shown.
BIN ebin/ewww_config.beam
Binary file not shown.
BIN ebin/ewww_server.beam
Binary file not shown.
BIN ebin/ewww_sup.beam
Binary file not shown.
8 ebin/yaws.app
@@ -0,0 +1,8 @@
+{application,yaws,
+ [{description,"yaws WWW server"},
+ {vsn,"0.2"},
+ {modules,[yaws, yaws_app, yaws_config, yaws_server, yaws_sup, yaws_api, yaws_log, yaws_ls, yaws_debug]},
+ {registered, []},
+ {mod,{yaws_app,[]}},
+ {env, []},
+ {applications,[kernel,stdlib]}]}.
BIN ebin/yaws.beam
Binary file not shown.
BIN ebin/yaws_api.beam
Binary file not shown.
BIN ebin/yaws_app.beam
Binary file not shown.
BIN ebin/yaws_config.beam
Binary file not shown.
BIN ebin/yaws_debug.beam
Binary file not shown.
BIN ebin/yaws_log.beam
Binary file not shown.
BIN ebin/yaws_ls.beam
Binary file not shown.
BIN ebin/yaws_server.beam
Binary file not shown.
BIN ebin/yaws_sup.beam
Binary file not shown.
47 include.mk
@@ -0,0 +1,47 @@
+###-*-makefile-*- ; force emacs to enter makefile-mode
+
+
+INSTALLPREFIX=/usr/local
+ERL=erl
+ERLC=erlc
+
+
+## don't edit below here
+
+EMULATOR=beam
+ifdef debug
+ ERLC_FLAGS+=-Ddebug
+endif
+
+ifdef trace
+ ERLC_FLAGS=+trace
+endif
+
+ifdef export_all
+ ERLC_FLAGS+=-Dexport_all
+endif
+
+
+INSTALL=install -c
+INSTALL_DATA=${INSTALL} -m 644
+
+
+# Hmm, don't know if you are supposed to like this better... ;-)
+APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/%VSN%/$$vsn/; s/%MODULES%/$$mods/; print; }'
+
+# Targets
+
+../ebin/%.app: %.app.src ../vsn.mk Makefile
+ perl -e $(APPSCRIPT) "$(VSN)" $(MODULES) < $< > $@
+
+../ebin/%.appup: %.appup
+ cp $< $@
+
+../ebin/%.$(EMULATOR): %.erl
+ $(ERLC) -b $(EMULATOR) $(ERLC_FLAGS) -o ../ebin $<
+
+%.$(EMULATOR): %.erl
+ $(ERLC) -b $(EMULATOR) $(ERLC_FLAGS) $<
+
+
+
131 include.mk.in
@@ -0,0 +1,131 @@
+###-*-makefile-*- ; force emacs to enter makefile-mode
+
+
+ERL=@ERL@
+ERLC=@ERLC@
+
+EMULATOR=beam
+
+
+ifdef debug
+ ERLC_FLAGS+=-Ddebug
+endif
+
+ifdef trace
+ ERLC_FLAGS=+trace
+endif
+
+ifdef export_all
+ ERLC_FLAGS+=-Dexport_all
+endif
+
+SYSTEM_NAME=bir
+SYSTEM_VSN=2.3$(SERIALNO)
+
+# changed by the make OS thingie on a per branch bases
+ISD_OS_VSN=1.3.3
+
+ISDA_SYSTEM_VSN=1.0$(SERIALNO)
+ISDA_SYSTEM_NAME=isda
+ISDA_PRODUCT_NAME=AKA
+# which version of the OS does this isda need
+ISDA_OS_VSN=$(ISD_OS_VSN)
+
+ISDM_SYSTEM_VSN=1.1$(SERIALNO)
+ISDM_SYSTEM_NAME=isdm
+ISDM_PRODUCT_NAME=BMR
+# which version of the OS does this isdm need
+ISDM_OS_VSN=$(ISD_OS_VSN)
+
+ISDSSL_SYSTEM_VSN=3.0.2$(SERIALNO)
+ISDSSL_SYSTEM_NAME=isdssl
+ISDSSL_PRODUCT_NAME=SSL
+# which version of the OS does this isdssl need
+ISDSSL_OS_VSN=$(ISD_OS_VSN)
+
+ISDO_SYSTEM_VSN=1.1.6$(SERIALNO)
+ISDO_SYSTEM_NAME=isdo
+ISDO_PRODUCT_NAME=IOP
+# which version of the OS does this isda need
+ISDO_OS_VSN=$(ISD_OS_VSN)
+
+DNS_SYSTEM_VSN=0.99
+
+CC=@CC@
+CFLAGS=@CFLAGS@
+LINKER=@LINKER@
+LDFLAGS=@LDFLAGS@
+WIN32=@WIN32@
+BSDI=@BSDI@
+EXE=@EXE@
+DLL=@DLL@
+OBJ=@OBJ@
+OUT=@OUT@
+FPIC=@FPIC@
+ERL_DLL_LIB=@ERL_DLL_LIB@
+OS=@OS@
+STRIP=@STRIP@
+LIBS=@LIBS@
+SSL_LIB_DIR=@SSL_LIB_DIR@
+SSL_INC_DIR=@SSL_INC_DIR@
+SWIFT=@SWIFT@
+
+ERLDIR=@ERLDIR@
+ERL_INTERFACE_LIB=@ERL_INTERFACE_LIB@
+ERL_INTERFACE_LIBS=@ERL_INTERFACE_LIBS@
+ERL_INTERFACE_INCLUDE=@ERL_INTERFACE_INCLUDE@
+
+LD_SHARED=@LD_SHARED@
+
+LDFLAGS +=-L$(ERL_INTERFACE_LIB)
+
+INSTALL=@INSTALL@
+INSTALL_DATA=@INSTALL_DATA@
+
+JAVAC=javac
+CLASSPATH=.:/usr/local/pgm/swing/swing.jar:/usr/local/pgm/jdk/lib/classes.zip:/opt/local/pgm/swing/swing.jar:/opt/local/pgm/jdk/lib/classes.zip
+JAVAC_FLAGS=-classpath $(CLASSPATH)
+
+# Hmm, don't know if you are supposed to like this better... ;-)
+APPSCRIPT = '$$vsn=shift; $$mods=""; while(@ARGV){ $$_=shift; s/^([A-Z].*)$$/\'\''$$1\'\''/; $$mods.=", " if $$mods; $$mods .= $$_; } while(<>) { s/%VSN%/$$vsn/; s/%MODULES%/$$mods/; print; }'
+
+# Targets
+
+../ebin/%.app: %.app.src ../vsn.mk Makefile
+ perl -e $(APPSCRIPT) "$(VSN)" $(MODULES) < $< > $@
+
+../ebin/%.appup: %.appup
+ cp $< $@
+
+../ebin/%.$(EMULATOR): %.erl
+ $(ERLC) -b $(EMULATOR) $(ERLC_FLAGS) -o ../ebin $<
+
+%.$(EMULATOR): %.erl
+ $(ERLC) -b $(EMULATOR) $(ERLC_FLAGS) $<
+
+%.obj: %.c
+ $(CC) $(CFLAGS) -c $<
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $<
+
+../priv/%.class: %.java
+ $(JAVAC) $(JAVAC_FLAGS) -d ../priv $<
+
+iSD_%_rdt.erl: %.rdt
+ $(ERL) -noinput -pa ../../reg/ebin -pa ../../misc/ebin -s reg_xml to_module_halt $<
+
+../priv/iSD_%_cli.beam: %.cli ../../cli/src/cli.hrl
+ $(ERL) -noinput -pa ../../misc/ebin -pa ../../cli/ebin -s cli_xml_parse cmdline compile $< ../priv
+
+../priv/iSD_%_csp.beam: %.csp
+ $(ERL) -noinput -pa ../../misc/ebin -pa ../../cli/ebin -s cli_xml_parse cmdline compile_csp $< ../priv
+
+%_clnt.erl: %.x
+ ../../rpc/priv/erpcgen -a '[clnt]' $<
+
+%_svc.erl: %.x
+ ../../rpc/priv/erpcgen -a '[svc]' $<
+
+%_xdr.erl: %.x
+ ../../rpc/priv/erpcgen -a '[xdr]' $<
49 include/yaws_api.hrl
@@ -0,0 +1,49 @@
+%%%----------------------------------------------------------------------
+%%% File : yaws_api.hrl
+%%% Author : Claes Wikstrom <klacke@hyber.org>
+%%% Purpose :
+%%% Created : 24 Jan 2002 by Claes Wikstrom <klacke@hyber.org>
+%%%----------------------------------------------------------------------
+
+-author('klacke@hyber.org').
+
+
+-record(arg, {
+ clisock, %% the socket leading to the peer client
+ h, %% headers
+ req, %% request
+ clidata, %% The client data (as a binary in POST requests)
+ querydata, %% Was the URL on the form of ....?query (GET reqs)
+ docroot %% where's the data
+
+ }).
+
+
+
+
+-record(http_request, {method,
+ path,
+ version}).
+
+
+-record(headers, {
+ connection,
+ accept,
+ host,
+ if_modified_since,
+ if_match,
+ if_none_match,
+ if_range,
+ if_unmodified_since,
+ range,
+ referer,
+ user_agent,
+ accept_ranges,
+ cookie = [],
+ keep_alive,
+ content_length}).
+
+
+
+
+
99 priv/mime.types
@@ -0,0 +1,99 @@
+# This is a comment. I love comments.
+
+application/activemessage
+application/andrew-inset
+application/applefile
+application/atomicmail
+application/dca-rft
+application/dec-dx
+application/mac-binhex40 hqx
+application/mac-compactpro cpt
+application/macwriteii
+application/msword doc
+application/news-message-id
+application/news-transmission
+application/octet-stream bin dms lha lzh exe class
+application/oda oda
+application/pdf pdf
+application/postscript ai eps ps
+application/powerpoint ppt
+application/remote-printing
+application/rtf rtf
+application/slate
+application/wita
+application/wordperfect5.1
+application/x-bcpio bcpio
+application/x-cdlink vcd
+application/x-compress Z
+application/x-cpio cpio
+application/x-csh csh
+application/x-director dcr dir dxr
+application/x-dvi dvi
+application/x-gtar gtar
+application/x-gzip gz
+application/x-hdf hdf
+application/x-httpd-cgi cgi
+application/x-koan skp skd skt skm
+application/x-latex latex
+application/x-mif mif
+application/x-netcdf nc cdf
+application/x-sh sh
+application/x-shar shar
+application/x-stuffit sit
+application/x-sv4cpio sv4cpio
+application/x-sv4crc sv4crc
+application/x-tar tar
+application/x-tcl tcl
+application/x-tex tex
+application/x-texinfo texinfo texi
+application/x-troff t tr roff
+application/x-troff-man man
+application/x-troff-me me
+application/x-troff-ms ms
+application/x-ustar ustar
+application/x-wais-source src
+application/zip zip
+audio/basic au snd
+audio/mpeg mpga mp2
+audio/x-aiff aif aiff aifc
+audio/x-pn-realaudio ram
+audio/x-pn-realaudio-plugin rpm
+audio/x-realaudio ra
+audio/x-wav wav
+chemical/x-pdb pdb xyz
+image/gif gif
+image/ief ief
+image/jpeg jpeg jpg jpe
+image/png png
+image/tiff tiff tif
+image/x-cmu-raster ras
+image/x-portable-anymap pnm
+image/x-portable-bitmap pbm
+image/x-portable-graymap pgm
+image/x-portable-pixmap ppm
+image/x-rgb rgb
+image/x-xbitmap xbm
+image/x-xpixmap xpm
+image/x-xwindowdump xwd
+message/external-body
+message/news
+message/partial
+message/rfc822
+multipart/alternative
+multipart/appledouble
+multipart/digest
+multipart/mixed
+multipart/parallel
+text/html html htm
+text/x-server-parsed-html shtml
+text/plain txt
+text/richtext rtx
+text/tab-separated-values tsv
+text/x-setext etx
+text/x-sgml sgml sgm
+video/mpeg mpeg mpg mpe
+video/quicktime qt mov
+video/x-msvideo avi
+video/x-sgi-movie movie
+x-conference/x-cooltalk ice
+x-world/x-vrml wrl vrml
14 scripts/Makefile
@@ -0,0 +1,14 @@
+include ../include.mk
+
+
+all: yaws.ss
+ sh ./mangle `pwd`/../ebin $(ERL) ../bin/yaws
+
+clean:
+ rm -f ../bin/yaws
+
+install: all
+ sh ./mangle $(INSTALLPREFIX)/lib/yaws/ebin $(ERL) \
+ $(INSTALLPREFIX)/bin/yaws
+ [ -f /etc/yaws.conf ] && mv -f /etc/yaws.conf /etc/yaws.conf.bak
+ $(INSTALL_DATA) yaws.conf.template /etc/yaws.conf
8 scripts/mangle
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+d=$1
+e=$2
+t=$3
+
+sed -e "s;%yawsdir%;$d;" -e "s;%erl%;$e;" yaws.ss > $t
+chmod +x $3
8 scripts/yaws.conf
@@ -0,0 +1,8 @@
+
+# configuartion template for yaws
+
+
+port = 80
+listen = 127.0.0.1
+logdir =
+
10 scripts/yaws.conf.template
@@ -0,0 +1,10 @@
+
+# conf for yaws
+
+# YAWSDIR = /usr/local/lib/yaws
+
+port = 80
+listen = 127.0.0.1
+logdir = /var/log/yaws
+docroot = $(YAWSDIR)/www
+
41 scripts/yaws.ss
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+
+yawsdir=%yawsdir%
+erl=%erl%
+
+
+help()
+{
+ echo "usage: yaws -i -- interactive (no daemon) mode"
+ echo " yaws -d -- debug mode"
+ echo " yaws -c file -- set config file"
+ exit 1
+}
+
+
+debug=false
+daemon=" -daemon "
+
+while [ $# -gt 0 ]
+do
+ arg=$1
+ shift;
+ case $arg in
+ -i)
+ daemon=""
+ break;;
+ -d)
+ debug=true
+ break;;
+ -c)
+ conf=$1
+ shift
+ break;;
+ *)
+ help
+ esac
+done
+
+exec $erl $daemon -pa $yawsdir -s yaws -yaws conf xx$conf debug xx$debug
+
46 src/Makefile
@@ -0,0 +1,46 @@
+include ../include.mk
+
+ifeq ($(TYPE),debug)
+DEBUG_FLAGS = -Ddebug
+else
+DEBUG_FLAGS =
+endif
+
+include ../vsn.mk
+VSN=$(YAWS_VSN)
+MODULES=yaws \
+ yaws_app \
+ yaws_config \
+ yaws_server \
+ yaws_sup \
+ yaws_api \
+ yaws_log \
+ yaws_ls \
+ yaws_debug
+
+EBIN_FILES=$(MODULES:%=../ebin/%.$(EMULATOR)) ../ebin/yaws.app
+
+ERLC_FLAGS+=-W $(DEBUG_FLAGS) -pa ../../yaws
+
+#
+# Targets
+#
+
+
+
+all: $(EBIN_FILES)
+
+debug:
+ $(MAKE) TYPE=debug
+
+clean:
+ rm -f $(EBIN_FILES)
+
+install: all
+ install -d $(INSTALLPREFIX)/lib/yaws
+ install -d /var/log/yaws
+ install -d /var/yaws/www
+ install -d /val/yaws/ebin
+ (cd ..; tar cz ebin --) | (cd $(INSTALLPREFIX)/lib/yaws; tar xz -- )
+ (cd ..; tar cz www --) | (cd /var/yaws; tar xz -- )
+ (cd ../examples; tar cz ebin --) | (cd /var/yaws; tar xz -- )
8 src/yaws.app.src
@@ -0,0 +1,8 @@
+{application,yaws,
+ [{description,"yaws WWW server"},
+ {vsn,"%VSN%"},
+ {modules,[%MODULES%]},
+ {registered, []},
+ {mod,{yaws_app,[]}},
+ {env, []},
+ {applications,[kernel,stdlib]}]}.
20 src/yaws.conf
@@ -0,0 +1,20 @@
+
+# conf for yaws
+
+# first we have a set of globals
+
+# logdir = .
+# ebin_dir = .
+# include_dir = .
+# keep_alive_timeout = 15000
+
+#end then a set of servers
+
+<server flinta.hyber.org>
+ port = 8000
+ listen = 192.168.128.24
+ docroot = /home/klacke/yaws/www
+</server>
+
+
+
501 src/yaws.erl
@@ -0,0 +1,501 @@
+%%%----------------------------------------------------------------------
+%%% File : yaws.erl
+%%% Author : Claes Wikstrom <klacke@bluetail.com>
+%%% Purpose :
+%%% Created : 16 Jan 2002 by Claes Wikstrom <klacke@bluetail.com>
+%%%----------------------------------------------------------------------
+
+-module(yaws).
+-author('klacke@bluetail.com').
+-include ("yaws.hrl").
+-include_lib("kernel/include/file.hrl").
+
+-compile(export_all).
+%%-export([Function/Arity, ...]).
+
+
+start() ->
+ application:start(yaws).
+stop() ->
+ application:stop(yaws).
+
+restart() ->
+ stop(),
+ load(),
+ start().
+
+
+modules() ->
+ application:load(yaws),
+ M = case application:get_all_key(yaws) of
+ {ok, L} ->
+ case lists:keysearch(modules, 1, L) of
+ {value, {modules, Mods}} ->
+ Mods;
+ _ ->
+ []
+ end;
+ _ ->
+ []
+ end,
+ M.
+
+
+load() ->
+ load(modules()).
+load(M) ->
+ lists:foreach(fun(Mod) ->
+ ?Debug("Load ~p~n", [Mod]),
+ c:l(Mod)
+ end, M).
+
+%%% misc funcs
+first(F, []) ->
+ false;
+first(F, [H|T]) ->
+ case F(H) of
+ {ok, Val} ->
+ {ok, Val, H};
+ _ ->
+ first(F, T)
+ end.
+
+
+elog(F, As) ->
+ error_logger:format(F, As).
+
+
+
+filesize(Fname) ->
+ case file:read_file_info(Fname) of
+ {ok, FI} when FI#file_info.type == regular ->
+ {ok, FI#file_info.size};
+ {ok, FI} ->
+ {error, FI#file_info.type};
+ Err ->
+ Err
+ end.
+%%
+upto(0, []) ->
+ [];
+upto(I, []) ->
+ [];
+upto(0, _) ->
+ " ....";
+upto(I, [0|_]) ->
+ " ....";
+upto(I,[H|T]) ->
+ [H|upto(I-1, T)].
+zip([H1|T1], [H2|T2]) ->
+ [{H1, H2} |zip(T1, T2)];
+zip([], []) ->
+ [].
+
+
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Date and Time functions
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+date_and_time() ->
+ case catch erlang:now() of
+ {'EXIT', _} -> % We don't have info about UTC
+ short_time(calendar:local_time());
+ Now ->
+ UTC = calendar:now_to_universal_time(Now),
+ Local = calendar:universal_time_to_local_time(UTC),
+ date_and_time(Local, UTC)
+ end.
+
+date_and_time(Local, UTC) ->
+ DiffSecs = calendar:datetime_to_gregorian_seconds(Local) -
+ calendar:datetime_to_gregorian_seconds(UTC),
+ short_time(Local) ++ diff(DiffSecs).
+
+%% short_time
+
+short_time({{Y,M,D},{H,Mi,S}}) ->
+ [y1(Y), y2(Y), M, D, H, Mi, S].
+
+%% Format date according to ISO 8601
+date_and_time_to_string(DAT) ->
+ case validate_date_and_time(DAT) of
+ true ->
+ dat2str(DAT);
+ false ->
+ exit({badarg, {?MODULE, date_and_time_to_string, [DAT]}})
+ end.
+
+universal_time_to_string(UTC) ->
+ Local = calendar:universal_time_to_local_time(UTC),
+ DT = local_time_to_date_and_time(Local),
+ date_and_time_to_string(DT).
+
+
+dat2str([Y1,Y2, Mo, D, H, M, S | Diff]) ->
+ lists:flatten(
+ io_lib:format("~s ~w-~2.2.0w-~2.2.0w,~2.2.0w:~2.2.0w:~2.2.0w",
+ [weekday(Y1,Y2,Mo,D), y(Y1,Y2),Mo,D,H,M,S]) ++
+ case Diff of
+ [Sign,Hd,Md] ->
+ io_lib:format("~c~2.2.0w~2.2.0w",
+ [Sign,Hd,Md]);
+ _ -> []
+ end).
+
+weekday(Y1,Y2,Mo,D) ->
+ int_to_wd(calendar:day_of_the_week(Y1*256+Y2,Mo,D)).
+
+int_to_wd(1) ->
+ "Mon";
+int_to_wd(2) ->
+ "Tue";
+int_to_wd(3) ->
+ "Wed";
+int_to_wd(4) ->
+ "Thu";
+int_to_wd(5) ->
+ "Fri";
+int_to_wd(6) ->
+ "Sat";
+int_to_wd(7) ->
+ "Sun".
+
+y1(Y) -> (Y bsr 8) band 255.
+y2(Y) -> Y band 255.
+
+y(Y1, Y2) -> 256 * Y1 + Y2.
+
+diff(Secs) ->
+ case calendar:seconds_to_daystime(Secs) of
+ {0, {H, M,_}} ->
+ [$+, H, M];
+ {-1, _} ->
+ {0, {H, M, _}} = calendar:seconds_to_daystime(-Secs),
+ [$-, H, M]
+ end.
+
+universal_time_to_date_and_time(UTC) ->
+ short_time(UTC) ++ [$+, 0, 0].
+
+local_time_to_date_and_time(Local) ->
+ UTC = calendar:local_time_to_universal_time(Local),
+ date_and_time(Local, UTC).
+
+date_and_time_to_universal_time([Y1,Y2, Mo, D, H, M, S]) ->
+ %% Local time specified, convert to UTC
+ Local = {{y(Y1,Y2), Mo, D}, {H, M, S}},
+ calendar:local_time_to_universal_time(Local);
+date_and_time_to_universal_time([Y1,Y2, Mo, D, H, M, S, Sign, Hd, Md]) ->
+ %% Time specified as local time + diff from UTC. Conv to UTC.
+ Local = {{y(Y1,Y2), Mo, D}, {H, M, S}},
+ LocalSecs = calendar:datetime_to_gregorian_seconds(Local),
+ Diff = (Hd*60 + Md)*60,
+ UTCSecs = if Sign == $+ -> LocalSecs - Diff;
+ Sign == $- -> LocalSecs + Diff
+ end,
+ calendar:gregorian_seconds_to_datetime(UTCSecs).
+
+validate_date_and_time([Y1,Y2, Mo, D, H, M, S | Diff])
+ when 0 =< Y1, 0 =< Y2, 0 < Mo, Mo < 13, 0 < D, D < 32, 0 =< H,
+ H < 24, 0 =< M, M < 60, 0 =< S, S < 61 ->
+ case check_diff(Diff) of
+ true ->
+ calendar:valid_date(y(Y1,Y2), Mo, D);
+ false ->
+ false
+ end;
+validate_date_and_time(_) -> false.
+
+check_diff([]) -> true;
+check_diff([$+, H, M]) when 0 =< H, H < 12, 0 =< M, M < 60 -> true;
+check_diff([$-, H, M]) when 0 =< H, H < 12, 0 =< M, M < 60 -> true;
+check_diff(_) -> false.
+
+
+
+%% to_string
+
+to_string(X) when float(X) ->
+ io_lib:format("~.2.0f",[X]);
+to_string(X) when integer(X) ->
+ integer_to_list(X);
+to_string(X) when atom(X) ->
+ atom_to_list(X);
+to_string(X) ->
+ lists:concat([X]).
+
+%%
+
+
+to_list(L) when list(L) ->
+ L;
+to_list(A) when atom(A) ->
+ atom_to_list(A).
+
+
+lowercase([C|S]) -> [lowercase(C)|S];
+lowercase(C) when C>=$A, C=<$Z -> C+32;
+lowercase(C) -> C.
+
+%%
+
+uppercase([C|S]) -> [uppercase(C)|S];
+uppercase(C) when C>=$a, C=<$z -> C-32;
+uppercase(C) -> C.
+
+%%
+
+lowercase_string(String) ->
+ lists:map(fun(X) -> lowercase(X) end, String).
+
+%% integer_to_hex
+
+integer_to_hex(I) when I<10 ->
+ integer_to_list(I);
+integer_to_hex(I) when I<16 ->
+ [I-10+$A];
+integer_to_hex(I) when I>=16 ->
+ N = trunc(I/16),
+ integer_to_hex(N) ++ integer_to_hex(I rem 16).
+
+%% hex_to_integer
+
+hex_to_integer(Hex) ->
+ DEHEX = fun (H) when H >= $a, H =< $f -> H - $a + 10;
+ (H) when H >= $A, H =< $F -> H - $A + 10;
+ (H) when H >= $0, H =< $9 -> H - $0
+ end,
+ lists:foldl(fun(E, Acc) -> Acc*16+DEHEX(E) end, 0, Hex).
+
+%% string_to_hex
+
+string_to_hex(String) ->
+ HEXC = fun (D) when D > 9 -> $a + D - 10;
+ (D) -> $0 + D
+ end,
+ lists:foldr(fun (E, Acc) ->
+ [HEXC(E div 16),HEXC(E rem 16)|Acc]
+ end, [],
+ String).
+
+
+%% hex_to_string
+
+hex_to_string(Hex) ->
+ DEHEX = fun (H) when H >= $a -> H - $a + 10;
+ (H) when H >= $A -> H - $A + 10;
+ (H) -> H - $0
+ end,
+ {String, _} =
+ lists:foldr(fun (E, {Acc, nolow}) ->
+ {Acc, DEHEX(E)};
+ (E, {Acc, LO}) ->
+ {[DEHEX(E)*16+LO|Acc], nolow}
+ end, {[], nolow},
+ Hex),
+ String.
+
+
+%% mk_list
+
+mk_list([]) ->
+ [];
+mk_list([X]) ->
+ to_string(X);
+mk_list([X|Rest]) ->
+ [to_string(X)," ",mk_list(Rest)].
+
+
+
+universal_time_as_string() ->
+ time_to_string(calendar:universal_time(), "GMT").
+
+time_to_string( {{Year, Month, Day}, {Hour, Min, Sec}}, Zone) ->
+ io_lib:format("~s, ~s ~s ~w ~s:~s:~s ~s",
+ [day(Year, Month, Day),
+ mk2(Day), month(Month), Year,
+ mk2(Hour), mk2(Min), mk2(Sec), Zone]).
+
+
+
+mk2(I) when I < 10 ->
+ [$0 | integer_to_list(I)];
+mk2(I) ->
+ integer_to_list(I).
+
+day(Year, Month, Day) ->
+ int_to_wd(calendar:day_of_the_week(Year, Month, Day)).
+
+month(1) ->
+ "Jan";
+month(2) ->
+ "Feb";
+month(3) ->
+ "Mar";
+month(4) ->
+ "Apr";
+month(5) ->
+ "May";
+month(6) ->
+ "Jun";
+month(7) ->
+ "Jul";
+month(8) ->
+ "Aug";
+month(9) ->
+ "Sep";
+month(10) ->
+ "Oct";
+month(11) ->
+ "Nov";
+month(12) ->
+ "Dec".
+
+
+
+month_str_to_int("Jan") ->
+ 1;
+month_str_to_int("Jun") ->
+ 6;
+month_str_to_int("Jul") ->
+ 7;
+month_str_to_int("Feb") ->
+ 2;
+month_str_to_int("Mar") ->
+ 3;
+month_str_to_int("Apr") ->
+ 4;
+month_str_to_int("May") ->
+ 5;
+month_str_to_int("Aug") ->
+ 8;
+month_str_to_int("Sep") ->
+ 7;
+month_str_to_int("Oct") ->
+ 10;
+month_str_to_int("Nov") ->
+ 11;
+month_str_to_int("Dec") ->
+ 12.
+
+
+
+day_str_to_int("Mon") ->
+ 1;
+day_str_to_int("Tue") ->
+ 2;
+day_str_to_int("Wed") ->
+ 3;
+day_str_to_int("Thu") ->
+ 4;
+day_str_to_int("Fri") ->
+ 5;
+day_str_to_int("Sat") ->
+ 6;
+day_str_to_int("Sun") ->
+ 7.
+
+
+%% Wed, 23 Jan 2002 19:07:44 GMT
+
+stringdate_to_datetime([$ |T]) ->
+ stringdate_to_datetime(T);
+stringdate_to_datetime([D1, D2, D3, $\,, $ |Tail]) ->
+ stringdate_to_datetime1(Tail).
+
+stringdate_to_datetime1([A, B, $\s |T]) ->
+ stringdate_to_datetime2(T, list_to_integer([A,B]));
+
+stringdate_to_datetime1([A, $\s |T]) ->
+ stringdate_to_datetime2(T, list_to_integer([A])).
+
+
+
+stringdate_to_datetime2([M1, M2, M3, $\s , Y1, Y2, Y3, Y4, $\s ,
+ H1, H2, $:, Min1, Min2,$:,
+ S1, S2,$\s ,$G, $M, $T|_], Day) ->
+ {{list_to_integer([Y1,Y2,Y3,Y4]),
+ month_str_to_int([M1, M2, M3]), Day},
+ {list_to_integer([H1, H2]),
+ list_to_integer([Min1, Min2]),
+ list_to_integer([S1, S2])}}.
+
+
+
+
+%% used by If-Modified-Since header code
+is_modified_p(FI, UTC_string) ->
+ case catch stringdate_to_datetime(UTC_string) of
+ {'EXIT', _ } ->
+ true;
+ UTC ->
+ Mtime = FI#file_info.mtime,
+ MtimeUTC = calendar:local_time_to_universal_time(Mtime),
+ MtimeUTC > UTC
+ end.
+
+
+
+
+ticker(Time) ->
+ S = self(),
+ spawn_link(yaws, ticker, [Time, S]).
+ticker(Time, To) ->
+ process_flag(trap_exit, true),
+ ticker2(Time, To).
+
+ticker2(Time, To) ->
+ receive
+ {'EXIT', _} ->
+ exit(normal)
+ after Time ->
+ To ! tick
+ end,
+ ticker2(Time, To).
+
+fmt_ip({A,B,C,D}) ->
+ [integer_to_list(A), $.,
+ integer_to_list(B), $.,
+ integer_to_list(C), $.,
+ integer_to_list(D)].
+
+
+
+parse_ip(Val) ->