changeset 560:17183d85ab62

urllog: Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 09 Jul 2020 12:49:48 +0300
parents 06d984a92a28
children bdccc83a1c22
files urllog.tcl
diffstat 1 files changed, 51 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/urllog.tcl	Thu Jul 09 12:47:39 2020 +0300
+++ b/urllog.tcl	Thu Jul 09 12:49:48 2020 +0300
@@ -33,17 +33,18 @@
 ##########################################################################
 # No need to look below this line
 ##########################################################################
+package require sqlite3
+package require http
+
 set urllog_name "URLLog"
 set urllog_version "2.4.3"
+set urllog_message "$urllog_name v$urllog_version (C) 2000-2020 ccr/TNSP"
+
 
 set urllog_tld_list [split $urllog_tld_list ","]
 set urllog_httprep [split "\@|%40|{|%7B|}|%7D|\[|%5B|\]|%5D" "|"]
 
 
-### Require packages
-package require sqlite3
-package require http
-
 ### Binding initializations
 bind pub - !urlfind urllog_pub_cmd_urlfind
 bind msg - !urlfind urllog_msg_cmd_urlfind
@@ -51,55 +52,14 @@
 bind topc - *.* urllog_check_line
 
 
-### Initialization messages
-set urllog_message "$urllog_name v$urllog_version (C) 2000-2020 ccr/TNSP"
-putlog "$urllog_message"
-
-### Miscellaneous init messages
-if {$urllog_extra_checks != 0} {
-  putlog " - Additional URL validity checks enabled."
-}
-
-if {$urllog_check_tld != 0} {
-  putlog " - Check TLD enabled."
-}
-
-if {$urllog_verbose != 0} {
-  putlog " - Verbose mode enabled."
-}
-
-### HTTP module initialization
-if {[info exists http_user_agent] && $http_user_agent != ""} {
-  ::http::config -useragent $http_user_agent
-} else {
-  ::http::config -useragent "$urllog_name/$urllog_version"
-}
-
-if {[info exists http_use_proxy] && $http_use_proxy != 0} {
-  ::http::config -proxyhost $http_proxy_host -proxyport $http_proxy_port
-  putlog " - Using proxy $http_proxy_host:$http_proxy_port"
-}
-
-if {[info exists http_tls_support] && $http_tls_support != 0} {
-  package require tls
-  ::http::register https 443 [list ::tls::socket -request true -require true -ssl2 false -ssl3 false -tls1 true -tls1.1 true -tls1.2 true -cadir $http_tls_cadir -autoservername true]
-  putlog " - TLS/SSL support enabled."
-}
-
-### SQLite database initialization
-if {[catch {sqlite3 urldb $urllog_db_file} uerrmsg]} {
-  putlog "Could not open SQLite3 database '$urllog_db_file': $uerrmsg"
-  exit 2
-}
-
 
 #-------------------------------------------------------------------------
 ### Utility functions
-proc urllog_log {arg} {
+proc urllog_log {umsg} {
   global urllog_log_enable urllog_name
 
   if {$urllog_log_enable != 0} {
-    putlog "$urllog_name: $arg"
+    putlog "$urllog_name: $umsg"
   }
 }
 
@@ -629,4 +589,48 @@
   return 0
 }
 
+
+#-------------------------------------------------------------------------
+# Script initialization
+#-------------------------------------------------------------------------
+putlog "$urllog_message"
+
+if {$urllog_extra_checks != 0} {
+  putlog " - Additional URL validity checks enabled."
+}
+
+if {$urllog_check_tld != 0} {
+  putlog " - Check TLD enabled."
+}
+
+if {$urllog_verbose != 0} {
+  putlog " - Verbose mode enabled."
+}
+
+### HTTP module initialization
+if {[info exists http_user_agent] && $http_user_agent != ""} {
+  ::http::config -useragent $http_user_agent
+} else {
+  ::http::config -useragent "$urllog_name/$urllog_version"
+}
+
+if {[info exists http_use_proxy] && $http_use_proxy != 0} {
+  ::http::config -proxyhost $http_proxy_host -proxyport $http_proxy_port
+  putlog " - Using proxy $http_proxy_host:$http_proxy_port"
+}
+
+if {[info exists http_tls_support] && $http_tls_support != 0} {
+  package require tls
+  ::http::register https 443 [list ::tls::socket -request true -require true -ssl2 false -ssl3 false -tls1 true -tls1.1 true -tls1.2 true -cadir $http_tls_cadir -autoservername true]
+  putlog " - TLS/SSL support enabled."
+}
+
+
+### SQLite database initialization
+if {[catch {sqlite3 urldb $urllog_db_file} uerrmsg]} {
+  putlog "Could not open SQLite3 database '$urllog_db_file': $uerrmsg"
+  exit 2
+}
+
+
 # end of script