Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on mktclapp
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/mktclapp.e>
#           or at <http://angg.twu.net/e/mktclapp.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######




# «.mktclapp.debs»	(to "mktclapp.debs")
# «.mktclapp.signing»	(to "mktclapp.signing")
# «.mktclapp_demo»	(to "mktclapp_demo")
# «.shared»		(to "shared")
# «.debugging_.sos»	(to "debugging_.sos")
# «.vtutil.so»		(to "vtutil.so")
# «.zHeader_zTail»	(to "zHeader_zTail")





#####
#
# Debianizing mktclapp (again)
# 2000nov26
#
#####

# «mktclapp.debs»  (to ".mktclapp.debs")
# (find-es "debiandev" "mktclapp_dh_make")
# (find-es "debiandev" "mktclapp")
# (find-es "debiandev" "mktclapp-3.9-fupl")
# (find-es "gpg" "gpg")

# (find-shttpw3 "www.hwaci.com/sw/mktclapp/")
# (find-fline "$S/http/www.hwaci.com/sw/mktclapp/mktclapp.tar.gz")
# Hm, the tgz hasn't been updated to version 3.10... But I won't mind now.
psne http://www.hwaci.com/sw/mktclapp/
psne http://www.hwaci.com/sw/mktclapp/mktclapp.tar.gz

#*
rm -v /usr/src/mktclapp*
rm -v /usr/src/mktclapp_3.9-*
rm -v /usr/src/mktclapp_3.9.orig.tar.gz

(cd /usr/src/; laf -d mktclapp*)

rm -Rv /usr/src/mktclapp-3.9.orig/
mkdir /usr/src/mktclapp-3.9.orig/
cd /usr/src/mktclapp-3.9.orig/
tar -xvzf $S/http/www.hwaci.com/sw/mktclapp/mktclapp.tar.gz

rm -Rv /usr/src/mktclapp-3.9/
mkdir /usr/src/mktclapp-3.9/
cd /usr/src/mktclapp-3.9/
tar -xvzf $S/http/www.hwaci.com/sw/mktclapp/mktclapp.tar.gz

# (find-mtafile "")
# (find-fline "~/mktclapp-3.9/")
# (find-fline "~/mktclapp-3.9/.files")

cd /usr/src/mktclapp-3.9/
mkdir debian examples
for i in $(<~/mktclapp-3.9/.files); do
  cp -ipv ~/mktclapp-3.9/$i $i
done


# «mktclapp.signing»  (to ".mktclapp.signing")
cd /usr/src/mktclapp-3.9/
# dpkg-buildpackage	|& tee odbp
# sh -x /usr/bin/dpkg-buildpackage.orig	|& tee odbpo
#
cat > $EEG <<'---'
TestPasswd
TestPasswd
---
eeg sh -x /usr/bin/dpkg-buildpackage.orig	|& tee odbpo


(cd /usr/src/; laf -d mktclapp*)

#*
cd /usr/src/
mv -v mktclapp*.deb .debs/
mv -v mktclapp*.dsc     .dscs/
mv -v mktclapp*.gz      .dscs/
mv -v mktclapp*.changes .dscs/
aptu-local-i386

#*

# (find-fline "/usr/bin/dh_builddeb")


# dpkg-deb: building package `mktclapp' in `../mktclapp_3.9-1_i386.deb'.
#  signfile mktclapp_3.9-1.dsc
# gpg: skipped `Eduardo Ochs <edrx@mat.puc-rio.br>': secret key not available
# gpg: [stdin]: clearsign failed: secret key not available

# (find-fline "/usr/src/mktclapp_3.9-1_i386.deb")
dpkg -i /usr/src/mktclapp_3.9-1_i386.deb

# (find-fline "/usr/src/mktclapp-3.9/")
# (find-fline "/usr/src/mktclapp-3.9/odbp")
# (find-fline "/usr/src/mktclapp-3.9/debian/tmp/")
# (find-fline "/usr/src/mktclapp-3.9/debian/tmp/DEBIAN/")

# (find-status "mktclapp")
# (find-vldifile "mktclapp.list")
# (find-vldifile "" "mktclapp.list")
# (find-vldifile "mktclapp.postinst")
# (find-vldifile "tkdiff.postinst")
# (find-fline "/usr/doc/mktclapp/")
# (find-fline "/usr/share/doc/mktclapp/")

# (find-fline "~/mktclapp-3.9/debian/")
# (find-fline "~/mktclapp-3.9/debian/rules")
# (eeman "dh_installexamples")
# (eeman "dh_installdocs")
# (eeman "dh_installdocs" "postinst")
# (eeman "dh_installdeb")

laf -d /usr/doc/mktclapp /usr/share/doc/mktclapp
laf -d /usr/doc/tkdiff   /usr/share/doc/tkdiff






#####
#
# running the mktclapp demo README
# 2000dec06
#
#####

# «mktclapp_demo»  (to ".mktclapp_demo")
# (find-fline "/usr/doc/mktclapp/")
# (find-fline "/usr/doc/mktclapp/examples/")
# (find-fline "/usr/doc/mktclapp/examples/README")
# (find-fline "/usr/doc/mktclapp/examples/Makefile")
# (find-es "make" "environment")
# (find-vldifile "" " tcl")
# (find-node "(make)Setting" "FOO ?= bar")
# (find-node "(make)Origin Function")
# (find-node "(bash)Simple Command Expansion" "Otherwise")

#*
cd /usr/doc/mktclapp/examples/
rm -Rv /tmp/mktclapp/
TCL=8.2 TK=8.2 sh README	|& tee ~/o
#sh README TCL=8.2 TK=8.2	|& tee ~/o
#sh README TCL=8.3 TK=8.3

#*

# (find-fline "~/o")
# (find-fline "/tmp/mktclapp/")





#####
#
# more about making ".so"s
# 2000dec07
#
#####

# «shared»  (to ".shared")
# (find-fline "~/mktclapp-3.9/examples/")
# (find-fline "~/mktclapp-3.9/examples/README" "but now as a Tcl extension:")
# (find-fline "~/mktclapp-3.9/examples/Makefile" "factor.so:")
# (find-fline "/usr/doc/mktclapp/examples/")
#*
rm -Rv /tmp/mta/
mkdir  /tmp/mta/
cd     /tmp/mta/

cat > factor.c <<'---'
#include "mktclapp.h"
int ET_COMMAND_factor(ET_TCLARGS){
  int i, n;
  if( argc!=3 ){
    Et_ResultF(interp,"wrong # args: should be \"%s NUM PROC\"",argv[0]);
    return TCL_ERROR;
  }
  n = atoi(argv[1]);
  for(i=1; i<=n; i++){
    if( (n/i)*i!=n ) continue;
    if( Et_EvalF(interp, "%s %d", argv[2], i)!=TCL_OK ){
      return TCL_ERROR;
    }
  }
  return TCL_OK;
}
---

mktclapp -header > mktclapp.h
mktclapp -notk -extension Factor factor.c > factor_e.c
gcc -c -g -o factor.o factor.c
gcc -c -g -o factor_e.o factor_e.c
gcc -shared -o factor.so  factor_e.o factor.o

cat > factor2.tcl <<'---'
load ./factor.so
factor 12 puts
---
tclsh factor2.tcl

laf

#*
# «debugging_.sos»  (to ".debugging_.sos")
# (find-fline "~/TCL/attachgdb")
# You need to execute the block above before executing this!
cd /tmp/mta/

cat > factor3 <<'---'
#!/usr/bin/tclsh8.2
 # load ./factor.so
 puts [exec pstree]

  load /tmp/mta/factor.so
  # Full path for the .so; gdb would get confused with just "load ./factor.so"
  # (find-fline "~/TCL/attachgdb")
  puts [exec $env(HOME)/TCL/attachgdb {
          gdbk-gdb tclsh8.2 [ancestorpid factor3]
         }]

 puts hello
 factor 12 puts
 puts bye
---
chmod 755 factor3

cat > $EEG <<'---'
br ET_COMMAND_factor
cont
p argv[1]
bt
---

./factor3
#*




#####
#
# vtutil.so
# 2000jan07
#
#####

# «vtutil.so»  (to ".vtutil.so")
# (find-fline "~/MTA/")
#*
cd ~/MTA/
mktclapp -header > mktclapp.h
mktclapp -notk -extension Vtutil vtutilsh.c > vtutilsh_e.c
gcc -c -o vtutilsh_e.o vtutilsh_e.c
gcc -c -o vtutilsh.o   vtutilsh.c
gcc -shared -o vtutilsh.so  vtutilsh_e.o vtutilsh.o
expect -c '
  load ./vtutilsh.so Vtutil
  puts [join [lsort [info commands]] "\n"]
'
#*


#*
# (eev-bounded)
cd ~/MTA/
make veryclean
# make vtutilsh.so CFLAGS=-g
# make vtutilsh.so CFLAGS=-g TCLVERSION=8.0
# make vtutilsh.so vtutilsh CFLAGS=-g TCLVERSION=8.2
make vtutilsh.so vtutilsh CFLAGS="-g -I/usr/include/tcl8.3" TCLVERSION=8.3

cd ~/MTA/
./vtutil setfont 256 8 math1.8  /dev/tty0
# tclsh8.3 ./vtutil setfont 256 8 math1.8  /dev/tty0

# (find-fline "~/MTA/vtutil" "attachgdb")
#load /home/root/MTA/vtutilsh.so Vtutil
#  # (find-es "mktclapp" "debugging_.sos")
#  # (find-fline "~/TCL/attachgdb")
#  puts [exec /home/root/TCL/attachgdb {
#    gdbk-gdb tclsh8.2 [ancestorpid vtutil] 
#  }]

#*
cd ~/MTA/
make veryclean
# make vtutilsh.so vtutilsh CFLAGS="-g -I/usr/include/tcl8.3" TCLVERSION=8.3
make CFLAGS="-g -I/usr/include/tcl8.3" TCLVERSION=8.3
#*

# (gdbk-gdb t "/home/root/MTA/vtutilsh")
set args vtutil modifyfont 256 8 ega1.8  math1.8
set env LD_LIBRARY_PATH /usr/src/tcl8.3-8.3.1/unix
# br main
# br ET_OBJCOMMAND_setfont
br ET_OBJCOMMAND_change_char
run
# p objv[4][0]
p objv[5][0]

#*


# (gdbk-gdb t "/usr/bin/tclsh8.3")
# set args /home/root/MTA/vtutil setfont 256 8 math1.8  /dev/tty0








# I'm not in a debugging mood now, so I'm making this silly hack:
#catch {exec setfont  $env(HOME)/MTA/math1.8}
#catch {exec loadkeys $env(HOME)/MTA/math850.map}
#exit

# (find-es "mktclapp" "debugging_.sos")
# (find-fline "~/TCL/attachgdb")
#puts [exec /home/root/TCL/attachgdb {
#  gdbk-gdb tclsh8.2 [ancestorpid vtutil] 
#}]

# (find-status "tcl8.2-dev")
# (find-vldifile "tcl8.0-dev.list")
# (find-vldifile "tcl8.2-dev.list")
# (find-vldifile "tcl8.3-dev.list")
# (find-fline "/usr/doc/tcl8.2-dev/")

# (eeg-bounded 'once)
# (find-es "gdb" "zcatinfo-gdb")

#*
ldd /usr/bin/tclsh
LD_LIBRARY_PATH=/usr/src/tcl8.3-8.3.1/debian/tcl8.3/usr/lib: \
  ldd /usr/bin/tclsh

#*

# (gdbk-gdb t "/usr/bin/tclsh8.2")
cd /home/root/MTA/
set args vtutil modifyfont 256 8 ega1.8  math1.8

# (eev-bounded 'once)


#*
cat > $EEG <<'---'
br ET_OBJCOMMAND_change_char
cont
p objv[3][0]
p objv[5][0]
---

cd ~/MTA/
./vtutil modifyfont 256 8 ega1.8  math1.8
#*

# (find-fline "~/MTA/vtutil")
# (find-fline "~/MTA/vtutil" "proc modifyfont")



# share vtutilsh.so
# br main
# run

# (find-fline "~/MTA/vtutilsh.c")
# (find-fline "~/MTA/vtutil")
# (find-fline "~/TCL/")

symbol-file /usr/bin/tclsh8.2
add-symbol-file /home/root/MTA/vtutilsh.so

# set args /home/root/MTA/vtutil










#####
#
# mktclapp: fiddling with the zHeader and zTail strings
# 00feb13
#
#####

# «zHeader_zTail»  (to ".zHeader_zTail")

cd /usr/src/mktclapp-3.8/
sed -e 's/^int main/int oldmain/' mktclapp.c > mktclapp0.c
cat >> mktclapp0.c <<'---'
int main(int argc, char **argv){
  switch( argv[1][0] ){
    case '0': printf("%s", zHeader); break;
    case '1': printf("%s", zTail); break;
    default: exit(1);
  }
  return 0;
}
---
gcc -v -o mktclapp0 mktclapp0.c
mktclapp0 0 > zHeader
mktclapp0 1 > zTail

l zHeader zTail

# (find-mtafile "mktclapp.c" "int main")
# (find-mtafile "mktclapp0.c" "int oldmain")
# (find-mtafile "mktclapp0.c" "\nint main")

# (find-mtafile "mktclapp.c" "static char zHeader[] =")
# (find-mtafile "mktclapp.c" "static char zTail[] =")

# (find-mtafile "zHeader")
# (find-mtafile "zTail")





#####
#
# mail about zHeader and zTail
# 00feb10
#
#####

mail -s 'Re: Character array in mktclapp.c is too long' \
  mktclapp@egroups.com <<'---'
D. Richard Hipp wrote:

> OK.  There is now zTail[] of size 17235 bytes and zTail2[] of
> size 48764 bytes.  Please try the beta copy at
>
>     http://www.hwaci.com/sw/mktclapp/mktclapp.c-3.10b3
>
> and let me know if it works any better.
>
> Another approach would be to strip comments from the generated
> code.  This would make the output of mktclapp less readable,
> but it would probably also get the string down below 64K.
> Thoughts anyone?

Thoughts:

I would be nice to include a small "mktclapp hacker's guide" in the
mktclapp distribution, showing which scripts are used to extract the
text in zTail and zHeader and to put them back in mktclapp.c after
modification; by tweaking these scripts just a bit, a big file with
some delimiter lines ("/*--split here if needed--*/", say) would
become, say, zTail, zTail2, zTail3..., or zTail[0], zTail[1], ...,
instead of just zTail (we don't need much generality here: users
playing with this can (*) fix what they break).

With this, people who want to strip off the comments will be able to
do it easily with some grepping on the intermediate files, but that
would not be standard practice, and wouldn't be needed.

  Cheers,
    Edrx
    edrx@inx.com.br
    http://angg.twu.net/mktclapp.html
    http://angg.twu.net/a/mktclapp-3.8/examples/README

(*): :-)
---





#####
#
# on not resetting ttys
#
#####

# (find-fline "~/MTA/")
# (find-fline "~/MTA/vtutilsh.c")



k22glimpse VT_GETSTATE

# (find-k22file "include/linux/tty.h" "VT_GETSTATE")
# (find-k22file "include/linux/tty.h" "struct tty_struct {")
#sub-structs:
# (find-k22tag "tty_driver")
# (find-k22tag "tty_ldisc")
# (find-k22tag "termios")
# (find-k22tag "winsize")
# (find-k22tag "tty_struct")
# (find-k22tag "fasync_struct")
# (find-k22tag "tty_flip_buffer")
# (find-k22tag "wait_queue")
# (find-k22tag "wait_queue")
# (find-k22tag "tq_struct")
# (find-k22tag "semaphore")

# (find-k22file "drivers/char/vt.c" "vt_stat")
# (find-k22file "Documentation/devices.txt" "Current virtual console")

cd /dev; laf tty? tty1?

# (find-fline "~/MTA/Makefile" "math:")

cd ~root/MTA/
./vtutil setfont  256 8 math1.8  /dev/tty
./vtutil setfont  256 16 math1.16  /dev/tty0

# Ops: se eu abro /dev/tty ao invés de um terminal específico os ls
# deixam de vir com crs implícitos.

math1.16: ega1.16 vtutil vtutilsh
	./vtutil modifyfont 256 16 ega1.16 math1.16
math16: math1.16 math850.map vtutil vtutilsh


/*
 * vtgetstate
 * Removed from vtutilsh because of crlf problems...
 * (eeman "console_ioctls" "VT_GETSTATE")
 * (find-k22tag "vt_stat")
 * (find-k22file "include/linux/vt.h")
 * (find-k22file "include/linux/vt.h" "struct vt_stat")
 * (find-k22file "include/linux/kd.h")
 * (find-fline "~/MTA/vtutilsh.c")
 * (find-fline "~/MTA/vtutilsh.c" "file%d")
 */

#include <linux/vt.h>

int ET_OBJCOMMAND_vtgetstate(ET_OBJARGS) {
  int f;
  struct vt_stat vtstat;
  if (objc != 2)
    ET_OARGSERROR("CHANNEL");
  if (sscanf(OARGV_STRING(1, 0), "file%d", &f) != 1)
    ET_ERROR("CHANNEL must be a file descriptor");
  if (ioctl(f, VT_GETSTATE, &vtstat))
    ET_ERROR1("VT_GETSTATE error: %s", strerror(errno));
  Et_ResultF(interp, "%d %d %d",
	     vtstat.v_active, vtstat.v_signal, vtstat.v_state);
  return TCL_OK;
}

# Removed from vtutil...

proc showvtstate {devfname} {
  set devfile [open $devfname {RDONLY NOCTTY NONBLOCK}]
  puts [vtgetstate $devfile]
  close $devfile
}




# (find-fline "~/MTA/vtutilsh.c" "VT_GETSTATE")
# (find-fline "~/MTA/vtutil")
# (find-fline "~/MTA/Makefile")
math
cd ~/MTA/
./vtutil showvtstate /dev/tty
ls


ls
cd ~/MTA/
./vtutil showvtstate thistty
ls





#####
#
# ?
#
#####

# (find-k22file "scripts/Configure" "if [")
# (find-fline "~/mktclapp-3.8/examples/README")

sh ~/mktclapp-3.8/examples/README
sh ~/mktclapp-3.8/examples/README TCL=99
sh ~/mktclapp-3.8/examples/README TCL=99 TK=aaa

cp -v ~/mktclapp-3.8/examples/Makefile /usr/doc/mktclapp/examples/
sh ~/mktclapp-3.8/examples/README TCL=4.0 TK=4.0

TCL=99







#  Local Variables:
#  coding:               utf-8-unix
#  End: