|
From: <oh...@ma...> - 2008-12-23 09:52:06
|
Author: oharboe
Date: 2008-12-23 09:52:02 +0100 (Tue, 23 Dec 2008)
New Revision: 1272
Added:
trunk/src/server/httpd/httpd.tcl
Removed:
trunk/src/server/httpd/httpd.tcl
Modified:
trunk/src/server/httpd.c
trunk/src/server/httpd/build.sh
trunk/src/server/httpd/erase.tcl
trunk/src/server/httpd/menu.xml
trunk/src/server/httpd/openocd.tcl
Log:
httpd wip
Modified: trunk/src/server/httpd/build.sh
===================================================================
--- trunk/src/server/httpd/build.sh 2008-12-22 15:24:35 UTC (rev 1271)
+++ trunk/src/server/httpd/build.sh 2008-12-23 08:52:02 UTC (rev 1272)
@@ -1,3 +1,5 @@
set e
java -classpath ../../../../zy1000/build/xalan.jar\;. Stylizer menu.xsl menu.xml .
find . -regex ".*\.tcl" -type f -exec sh html2tcl.sh {} {} \;
+echo "Copy .tcl files to /usr/local/lib/openocd/httpd/"
+cp *.tcl /usr/local/lib/openocd/httpd/
\ No newline at end of file
Modified: trunk/src/server/httpd/erase.tcl
===================================================================
--- trunk/src/server/httpd/erase.tcl 2008-12-22 15:24:35 UTC (rev 1271)
+++ trunk/src/server/httpd/erase.tcl 2008-12-23 08:52:02 UTC (rev 1272)
@@ -161,7 +161,7 @@
set form_length 0x10000
}
if {[string compare $form_address ""]==0} {
- if {[catch {[zy1000_flash]} result]==0} {
+ if {[catch {[first_flash_base]} result]==0} {
set form_address "0x[tohex $result]"
}
}
Deleted: trunk/src/server/httpd/httpd.tcl
===================================================================
--- trunk/src/server/httpd/httpd.tcl 2008-12-22 15:24:35 UTC (rev 1271)
+++ trunk/src/server/httpd/httpd.tcl 2008-12-23 08:52:02 UTC (rev 1272)
@@ -1,113 +0,0 @@
-# some dummy proc's to get things going for test purposes
-
-
-
-proc ip {} {
-return 10.0.0.55
-}
-
-proc start_chunked {a} {
- global httpdata
- global httpmime
- set httpmime $a
- set httpdata ""
-}
-
-proc write_chunked {a} {
- global httpdata
- append httpdata $a
-}
-
-proc end_chunked {} {
-}
-
-
-
-#proc formfetch {a} {
-# global httppostdata
- #catch {
-# echo "$a=$httppostdata($a)"
- #return $httppostdata($a)
- #}
-#
- #return ""
-#}
-
-
-
-
-proc tohex {a} {
- set r ""
- while 1 {
-
- set rem [expr $a%16]
- set a [expr $a/16]
- set r [string index "0123456789abcdef" $rem]$r
- if ($a==0) then break
- }
- return $r
-}
-
-# encode text
-proc encode {a} {
- return [string map {\n <br/> { } { } \t { } > > < < / /} $a]
-}
-
-#stubs that can be overriden to save between sessions
-proc load_var {a} {
- global glob_var
- catch {
- return $glob_var($a)
- }
- return ""
-}
-#stubs that can be overriden to save between sessions
-proc save_var {a b} {
- catch {
- set glob_var($a) $b
- return ""
- } err
- set glob_var($a) ""
- return ""
-}
-
-
-
-proc to_textarea {a} {
- return [string map {& & > > < < / /} $a]
-}
-
-proc from_textarea {a} {
- return [string map {> > < < & & / /} $a]
-}
-
-proc lunion {a b} {
- foreach e $a {
- set x($e) {}
- }
- foreach e $b {
- if {![info exists x($e)]} {
- lappend a $e
- }
- }
- return $a
-}
-
-
-# encode text
-proc encode {a} {
- return [string map {\n <br/> { } { } \t { } > > < < / /} $a]
-}
-
-# catch any exceptions, capture output and return it
-proc capture_catch {a} {
- catch {
- return [eval {capture $a}]
- } result
- return $result
-}
-
-proc zy1000_flash {} {
- set t [lindex 0 [ocd_flash_banks]]
- return $t(base)
-}
Copied: trunk/src/server/httpd/httpd.tcl (from rev 1271, trunk/src/server/httpd/httpd.tcl)
===================================================================
--- trunk/src/server/httpd/httpd.tcl 2008-12-22 15:24:35 UTC (rev 1271)
+++ trunk/src/server/httpd/httpd.tcl 2008-12-23 08:52:02 UTC (rev 1272)
@@ -0,0 +1,113 @@
+# some dummy proc's to get things going for test purposes
+
+
+
+proc ip {} {
+return 10.0.0.55
+}
+
+proc start_chunked {a} {
+ global httpdata
+ global httpmime
+ set httpmime $a
+ set httpdata ""
+}
+
+proc write_chunked {a} {
+ global httpdata
+ append httpdata $a
+}
+
+proc end_chunked {} {
+}
+
+
+
+#proc formfetch {a} {
+# global httppostdata
+ #catch {
+# echo "$a=$httppostdata($a)"
+ #return $httppostdata($a)
+ #}
+#
+ #return ""
+#}
+
+
+
+
+proc tohex {a} {
+ set r ""
+ while 1 {
+
+ set rem [expr $a%16]
+ set a [expr $a/16]
+ set r [string index "0123456789abcdef" $rem]$r
+ if ($a==0) then break
+ }
+ return $r
+}
+
+# encode text
+proc encode {a} {
+ return [string map {\n <br/> { } { } \t { } > > < < / /} $a]
+}
+
+#stubs that can be overriden to save between sessions
+proc load_var {a} {
+ global glob_var
+ catch {
+ return $glob_var($a)
+ }
+ return ""
+}
+#stubs that can be overriden to save between sessions
+proc save_var {a b} {
+ catch {
+ set glob_var($a) $b
+ return ""
+ } err
+ set glob_var($a) ""
+ return ""
+}
+
+
+
+proc to_textarea {a} {
+ return [string map {& & > > < < / /} $a]
+}
+
+proc from_textarea {a} {
+ return [string map {> > < < & & / /} $a]
+}
+
+proc lunion {a b} {
+ foreach e $a {
+ set x($e) {}
+ }
+ foreach e $b {
+ if {![info exists x($e)]} {
+ lappend a $e
+ }
+ }
+ return $a
+}
+
+
+# encode text
+proc encode {a} {
+ return [string map {\n <br/> { } { } \t { } > > < < / /} $a]
+}
+
+# catch any exceptions, capture output and return it
+proc capture_catch {a} {
+ catch {
+ capture {uplevel $a}
+ } result
+ return $result
+}
+
+proc first_flash_base {} {
+ set t [lindex 0 [ocd_flash_banks]]
+ return $t(base)
+}
Property changes on: trunk/src/server/httpd/httpd.tcl
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/src/server/httpd/menu.xml
===================================================================
--- trunk/src/server/httpd/menu.xml 2008-12-22 15:24:35 UTC (rev 1271)
+++ trunk/src/server/httpd/menu.xml 2008-12-23 08:52:02 UTC (rev 1272)
@@ -438,7 +438,7 @@
set form_length 0x10000
}
if {[string compare $form_address ""]==0} {
- if {[catch {[zy1000_flash]} result]==0} {
+ if {[catch {[first_flash_base]} result]==0} {
set form_address "0x[tohex $result]"
}
}
@@ -794,8 +794,8 @@
set form_command [formfetch form_command]
set form_edittext ""
- if {[string length $form_command]>0} {
- catch {capture_catch {eval "$form_command"}} form_edittext
+ if {[string length $form_command]>0} {
+ set form_edittext [capture_catch {eval $form_command}]
}
append buffer {<form action="openocd.tcl" method="post">} "\n"
Modified: trunk/src/server/httpd/openocd.tcl
===================================================================
--- trunk/src/server/httpd/openocd.tcl 2008-12-22 15:24:35 UTC (rev 1271)
+++ trunk/src/server/httpd/openocd.tcl 2008-12-23 08:52:02 UTC (rev 1272)
@@ -154,8 +154,8 @@
set form_command [formfetch form_command]
set form_edittext ""
- if {[string length $form_command]>0} {
- catch {capture_catch {eval "$form_command"}} form_edittext
+ if {[string length $form_command]>0} {
+ set form_edittext [capture_catch {eval $form_command}]
}
append buffer {<form action="openocd.tcl" method="post">} "\n"
Modified: trunk/src/server/httpd.c
===================================================================
--- trunk/src/server/httpd.c 2008-12-22 15:24:35 UTC (rev 1271)
+++ trunk/src/server/httpd.c 2008-12-23 08:52:02 UTC (rev 1272)
@@ -429,9 +429,14 @@
}
static struct MHD_Daemon * d;
+static pthread_mutex_t mutex;
+
int httpd_start(void)
{
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_init( &attr );
+ pthread_mutex_init( &mutex, &attr );
int port = 8888;
LOG_USER("Launching httpd server on port %d", port);
@@ -461,15 +466,16 @@
void httpd_stop(void)
{
MHD_stop_daemon(d);
+ pthread_mutex_destroy( &mutex );
}
void openocd_sleep_prelude(void)
{
- /* FIX!!!! add locking here!!!! */
+ pthread_mutex_unlock( &mutex );
}
void openocd_sleep_postlude(void)
{
- /* FIX!!!! add locking here!!!! */
+ pthread_mutex_lock( &mutex );
}
|