xschem tcp interface: accept whole multiline text input from clients, (no more limit to 1 line text input), hier_psprint(): do not descend to subcircuit schematic if file not existing

This commit is contained in:
stefan schippers 2023-04-07 23:38:33 +02:00
parent 34800870fe
commit 705f279a23
2 changed files with 39 additions and 36 deletions

View File

@ -47,6 +47,7 @@ void hier_psprint(char **res, int what) /* netlister driver */
char *subckt_name;
char filename[PATH_MAX];
char *abs_path = NULL;
struct stat buf;
Str_hashtable subckt_table = {NULL, 0};
if((what & 1) && !ps_draw(1)) return; /* prolog */
@ -87,17 +88,19 @@ void hier_psprint(char **res, int what) /* netlister driver */
{
str_hash_lookup(&subckt_table, subckt_name, "", XINSERT);
get_sch_from_sym(filename, xctx->sym + i);
/* for printing we go down to bottom regardless of spice_stop attribute */
load_schematic(1,filename, 0, 1);
zoom_full(0, 0, 1, 0.97);
if(what & 1) ps_draw(2); /* page */
if(what & 2) { /* print cellname */
my_strcat(_ALLOC_ID_, res, hier_psprint_mtime(xctx->sch[xctx->currsch]));
my_strcat(_ALLOC_ID_, res, " {");
my_strcat(_ALLOC_ID_, res, xctx->sch[xctx->currsch]);
my_strcat(_ALLOC_ID_, res, "}\n");
if(!stat(filename, &buf)) {
/* for printing we go down to bottom regardless of spice_stop attribute */
load_schematic(1,filename, 0, 1);
zoom_full(0, 0, 1, 0.97);
if(what & 1) ps_draw(2); /* page */
if(what & 2) { /* print cellname */
my_strcat(_ALLOC_ID_, res, hier_psprint_mtime(xctx->sch[xctx->currsch]));
my_strcat(_ALLOC_ID_, res, " {");
my_strcat(_ALLOC_ID_, res, xctx->sch[xctx->currsch]);
my_strcat(_ALLOC_ID_, res, "}\n");
}
dbg(1,"--> %s\n", skip_dir( xctx->sch[xctx->currsch]) );
}
dbg(1,"--> %s\n", skip_dir( xctx->sch[xctx->currsch]) );
}
}
}

View File

@ -1255,33 +1255,33 @@ proc bespice_getdata {sock} {
proc xschem_getdata {sock} {
global xschem_server_getdata tclcmd_puts
if {[eof $sock] || [catch {gets $sock xschem_server_getdata(line,$sock)}]} {
close $sock ;# close due to client shutdown
puts "Close $xschem_server_getdata(addr,$sock)"
unset xschem_server_getdata(addr,$sock)
unset xschem_server_getdata(line,$sock)
unset xschem_server_getdata(res,$sock)
} else {
puts "tcp<-- $xschem_server_getdata(line,$sock)"
# xschem command must be executed at global scope...
redef_puts
uplevel #0 [list catch $xschem_server_getdata(line,$sock) tclcmd_puts]
rename puts {}
rename ::tcl::puts puts
puts "tcp--> $tclcmd_puts"
if {![regexp {\n$} $tclcmd_puts]} {
set xschem_server_getdata(res,$sock) "$tclcmd_puts\n"
while {1} {
if {[gets $sock line] < 0} {
break
} else {
set xschem_server_getdata(res,$sock) "$tclcmd_puts"
append xschem_server_getdata(line,$sock) $line \n
}
puts -nonewline $sock "$xschem_server_getdata(res,$sock)"
flush $sock
close $sock ;# server closes
puts "Close $xschem_server_getdata(addr,$sock)"
unset xschem_server_getdata(addr,$sock)
unset xschem_server_getdata(line,$sock)
unset xschem_server_getdata(res,$sock)
}
puts "tcp<-- $xschem_server_getdata(line,$sock)"
# xschem command must be executed at global scope...
redef_puts
uplevel #0 [list catch $xschem_server_getdata(line,$sock) tclcmd_puts]
rename puts {}
rename ::tcl::puts puts
puts "tcp--> $tclcmd_puts"
if {![regexp {\n$} $tclcmd_puts]} {
set xschem_server_getdata(res,$sock) "$tclcmd_puts\n"
} else {
set xschem_server_getdata(res,$sock) "$tclcmd_puts"
}
puts -nonewline $sock "$xschem_server_getdata(res,$sock)"
flush $sock
close $sock ;# server closes
puts "Close $xschem_server_getdata(addr,$sock)"
unset xschem_server_getdata(addr,$sock)
unset xschem_server_getdata(line,$sock)
unset xschem_server_getdata(res,$sock)
}
proc bespice_server {sock addr port} {
@ -1295,12 +1295,12 @@ proc bespice_server {sock addr port} {
}
}
proc xschem_server {sock addr port} {
global xschem_server_getdata
puts "Accept $sock from $addr port $port"
fconfigure $sock -buffering line
fconfigure $sock -buffering line -blocking 0
set xschem_server_getdata(addr,$sock) [list $addr $port]
set xschem_server_getdata(line,$sock) {}
fileevent $sock readable [list xschem_getdata $sock]
}