[PD-cvs] SF.net SVN: pure-data:[10524] branches/pd-devel/0.41.4/src

eighthave at users.sourceforge.net eighthave at users.sourceforge.net
Tue Jan 13 02:19:49 CET 2009


Revision: 10524
          http://pure-data.svn.sourceforge.net/pure-data/?rev=10524&view=rev
Author:   eighthave
Date:     2009-01-13 01:19:49 +0000 (Tue, 13 Jan 2009)

Log Message:
-----------
purged all traces of Tcl/Tk from the C side of things, it is no longer needed, pd-gui is pure Tcl/Tk

Modified Paths:
--------------
    branches/pd-devel/0.41.4/src/configure.in
    branches/pd-devel/0.41.4/src/g_all_guis.c
    branches/pd-devel/0.41.4/src/g_bang.c
    branches/pd-devel/0.41.4/src/g_graph.c
    branches/pd-devel/0.41.4/src/g_hdial.c
    branches/pd-devel/0.41.4/src/g_hslider.c
    branches/pd-devel/0.41.4/src/g_mycanvas.c
    branches/pd-devel/0.41.4/src/g_numbox.c
    branches/pd-devel/0.41.4/src/g_rtext.c
    branches/pd-devel/0.41.4/src/g_text.c
    branches/pd-devel/0.41.4/src/g_toggle.c
    branches/pd-devel/0.41.4/src/g_vdial.c
    branches/pd-devel/0.41.4/src/g_vslider.c
    branches/pd-devel/0.41.4/src/g_vumeter.c
    branches/pd-devel/0.41.4/src/makefile.in

Removed Paths:
-------------
    branches/pd-devel/0.41.4/src/t_main.c
    branches/pd-devel/0.41.4/src/t_tk.h
    branches/pd-devel/0.41.4/src/t_tkcmd.c

Modified: branches/pd-devel/0.41.4/src/configure.in
===================================================================
--- branches/pd-devel/0.41.4/src/configure.in	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/configure.in	2009-01-13 01:19:49 UTC (rev 10524)
@@ -7,22 +7,16 @@
 AC_SUBST(portmidi, no)
 AC_SUBST(binarymode, -m755)
 AC_SUBST(fftw, no)
-AC_SUBST(tk, yes)
 AC_SUBST(PDLIB)
 AC_SUBST(CPPFLAGS)
 AC_SUBST(MORECFLAGS)
 AC_SUBST(EXT)
 AC_SUBST(USE_DEBUG_CFLAGS, no)
 AC_SUBST(SYSSRC)
-AC_SUBST(TCLTK_FRAMEWORKS_PATH)
-AC_SUBST(TCLTK_FRAMEWORKS_PATH)
 AC_SUBST(STRIPFLAG)
-AC_SUBST(GUINAME)
-AC_SUBST(GUIFLAGS)
 AC_SUBST(OSNUMBER)
 AC_SUBST(EXTERNTARGET)
 AC_SUBST(ASIOSRC)
-AC_SUBST(GUISRC)
 
 dnl other defaults
 
@@ -46,8 +40,6 @@
     fftw=$enableval)
 AC_ARG_ENABLE(fat,      [  --disable-fat           build fat binary on Mac OS X], 
     fat=$enableval, fat="yes")
-AC_ARG_ENABLE(tk,       [  --disable-tk            build without tcl/tk-GUI],
-    tk=$enableval)
 
 dnl Checks for programs.
 AC_PROG_CC
@@ -99,80 +91,6 @@
     echo "fftw package not found - using built-in FFT"; fftw=no)
 fi
 
-dnl look for tcl 8.x... do I really have to go through all this!?
-
-foundit=no
-if test $foundit = "no";
-then
-    AC_CHECK_HEADER(tcl.h,foundit=yes,)
-fi
-if test $foundit = "no";
-then
-    AC_CHECK_HEADER(tcl8.7/tcl.h,
-        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.7";foundit=yes,)
-fi
-if test $foundit = "no";
-then
-    AC_CHECK_HEADER(tcl8.6/tcl.h,
-        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.6";foundit=yes,)
-fi
-if test $foundit = "no";
-then
-    AC_CHECK_HEADER(tcl8.5/tcl.h,
-        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.5";foundit=yes,)
-fi
-if test $foundit = "no";
-then
-    AC_CHECK_HEADER(tcl8.4/tcl.h,
-        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.4";foundit=yes,)
-fi
-if test $foundit = "no";
-then
-    AC_CHECK_HEADER(tcl8.4/tcl.h,
-        GUIFLAGS="$GUIFLAGS -I/usr/local/include/tcl8.4";foundit=yes,)
-fi
-if test $foundit = "no";
-then
-    AC_CHECK_HEADER(tcl8.3/tcl.h,
-        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.3";foundit=yes,)
-fi
-if test $foundit = "no";
-then
-    AC_CHECK_HEADER(tcl8.2/tcl.h,
-        GUIFLAGS="$GUIFLAGS -I/usr/include/tcl8.2";foundit=yes,)
-fi
-if test $foundit = "no";
-then
-    echo no tcl header found
-         echo bolding trying without...
-#    exit -1
-fi
-
-AC_CHECK_LIB(tcl85, main,,
-        AC_CHECK_LIB(tcl8.5, main,,
-        AC_CHECK_LIB(tcl84, main,,
-            AC_CHECK_LIB(tcl8.4, main,,
-                AC_CHECK_LIB(tcl8.3, main,,
-                    AC_CHECK_LIB(tcl8.2, main,,
-                                    AC_CHECK_LIB(tcl8.0, main,,
-                            echo no tcl library found; exit 1)))))))
-
-AC_CHECK_LIB(tk85, main,,
-        AC_CHECK_LIB(tk8.5, main,,
-       AC_CHECK_LIB(tk84, main,,
-            AC_CHECK_LIB(tk8.4, main,,
-                AC_CHECK_LIB(tk8.3, main,,
-                    AC_CHECK_LIB(tk8.2, main,,
-                                    AC_CHECK_LIB(tk8.0, main,,
-                            echo no tk library found; exit 1)))))))
-
-
-if test x$tk != "xno"; then
-GUISRC="t_main.c t_tkcmd.c"
-else
-GUISRC=
-fi
-
 if test `uname -s` = Linux;
 then
     dnl Ckecking for ALSA
@@ -247,7 +165,6 @@
         binarymode="-m4755"
     fi
     STRIPFLAG=-s
-    GUINAME="pd-gui"
     if test x$USE_DEBUG_CFLAGS = "xyes";
     then
         MORECFLAGS=$MORECFLAGS" -g"
@@ -319,25 +236,7 @@
         ../portmidi/pm_common/portmidi.c \
         ../portmidi/porttime/ptmacosx_cf.c "
     STRIPFLAG=""
-    GUINAME="libPdTcl.dylib"
 
-# find the Tcl/Tk Frameworks
-         if test -d "../../Frameworks";
-    then
-        # Miller's location
-        TCLTK_FRAMEWORKS_PATH="../../Frameworks"
-         elif test -d "/Library/Frameworks";
-         then
-        # get it from the default install location
-        TCLTK_FRAMEWORKS_PATH="/Library/Frameworks"
-    else
-        # Panther has Tcl here; Tiger has Tcl and Tk here
-        TCLTK_FRAMEWORKS_PATH="/System/Library/Frameworks"
-    fi           
-    GUIFLAGS="-F$TCLTK_FRAMEWORKS_PATH -framework Tcl -framework Tk \
-        -I$TCLTK_FRAMEWORKS_PATH/Tk.framework/Versions/Current/Headers \
-        -I$TCLTK_FRAMEWORKS_PATH/Tcl.framework/Versions/Current/Headers \
-        -I$TCLTK_FRAMEWORKS_PATH/Tcl.framework/Versions/8.4/PrivateHeaders"
     if test x$USE_DEBUG_CFLAGS = "xyes";
     then
         MORECFLAGS=$MORECFLAGS" -g"
@@ -388,8 +287,6 @@
          ../portaudio/src/hostapi/pa_asio/asio.cpp ../asio/asio.cpp \
          ../asio/asiodrivers.cpp ../asio/asiolist.cpp"
     STRIPFLAG="--strip-unneeded"
-    GUINAME="pdtcl.dll"
-    GUIFLAGS=
 fi
 
 # support for jack, on either linux or darwin:

Modified: branches/pd-devel/0.41.4/src/g_all_guis.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_all_guis.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_all_guis.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -12,7 +12,7 @@
 #include <ctype.h>
 #include "m_pd.h"
 #include "g_canvas.h"
-#include "t_tk.h"
+
 #include "g_all_guis.h"
 #include <math.h>
 

Modified: branches/pd-devel/0.41.4/src/g_bang.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_bang.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_bang.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -12,7 +12,7 @@
 #include <ctype.h>
 #include "m_pd.h"
 #include "g_canvas.h"
-#include "t_tk.h"
+
 #include "g_all_guis.h"
 #include <math.h>
 

Modified: branches/pd-devel/0.41.4/src/g_graph.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_graph.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_graph.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -8,7 +8,7 @@
 
 #include <stdlib.h>
 #include "m_pd.h"
-#include "t_tk.h"
+
 #include "g_canvas.h"
 #include "s_stuff.h"    /* for sys_hostfontsize */
 #include <stdio.h>

Modified: branches/pd-devel/0.41.4/src/g_hdial.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_hdial.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_hdial.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -14,7 +14,7 @@
 #include <ctype.h>
 #include "m_pd.h"
 #include "g_canvas.h"
-#include "t_tk.h"
+
 #include "g_all_guis.h"
 #include <math.h>
 

Modified: branches/pd-devel/0.41.4/src/g_hslider.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_hslider.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_hslider.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -12,7 +12,7 @@
 #include <ctype.h>
 #include "m_pd.h"
 #include "g_canvas.h"
-#include "t_tk.h"
+
 #include "g_all_guis.h"
 #include <math.h>
 

Modified: branches/pd-devel/0.41.4/src/g_mycanvas.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_mycanvas.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_mycanvas.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -12,7 +12,7 @@
 #include <ctype.h>
 #include "m_pd.h"
 #include "g_canvas.h"
-#include "t_tk.h"
+
 #include "g_all_guis.h"
 #include <math.h>
 

Modified: branches/pd-devel/0.41.4/src/g_numbox.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_numbox.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_numbox.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -10,7 +10,7 @@
 #include <ctype.h>
 #include "m_pd.h"
 #include "g_canvas.h"
-#include "t_tk.h"
+
 #include "g_all_guis.h"
 #include <math.h>
 

Modified: branches/pd-devel/0.41.4/src/g_rtext.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_rtext.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_rtext.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -13,8 +13,8 @@
 #include "m_pd.h"
 #include "s_stuff.h"
 #include "g_canvas.h"
-#include "t_tk.h"
 
+
 #define LMARGIN 2
 #define RMARGIN 2
 /* for some reason, it draws text 1 pixel lower on Mac OS X (& linux too?) */

Modified: branches/pd-devel/0.41.4/src/g_text.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_text.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_text.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -10,7 +10,7 @@
 #include "m_pd.h"
 #include "m_imp.h"
 #include "s_stuff.h"
-#include "t_tk.h"
+
 #include "g_canvas.h"
 #include <stdio.h>
 #include <string.h>

Modified: branches/pd-devel/0.41.4/src/g_toggle.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_toggle.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_toggle.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -12,7 +12,7 @@
 #include <ctype.h>
 #include "m_pd.h"
 #include "g_canvas.h"
-#include "t_tk.h"
+
 #include "g_all_guis.h"
 #include <math.h>
 

Modified: branches/pd-devel/0.41.4/src/g_vdial.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_vdial.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_vdial.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -13,7 +13,7 @@
 #include <ctype.h>
 #include "m_pd.h"
 #include "g_canvas.h"
-#include "t_tk.h"
+
 #include "g_all_guis.h"
 #include <math.h>
 

Modified: branches/pd-devel/0.41.4/src/g_vslider.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_vslider.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_vslider.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -12,7 +12,7 @@
 #include <ctype.h>
 #include "m_pd.h"
 #include "g_canvas.h"
-#include "t_tk.h"
+
 #include "g_all_guis.h"
 #include <math.h>
 

Modified: branches/pd-devel/0.41.4/src/g_vumeter.c
===================================================================
--- branches/pd-devel/0.41.4/src/g_vumeter.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/g_vumeter.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -12,7 +12,7 @@
 #include <ctype.h>
 #include "m_pd.h"
 #include "g_canvas.h"
-#include "t_tk.h"
+
 #include "g_all_guis.h"
 #include <math.h>
 

Modified: branches/pd-devel/0.41.4/src/makefile.in
===================================================================
--- branches/pd-devel/0.41.4/src/makefile.in	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/makefile.in	2009-01-13 01:19:49 UTC (rev 10524)
@@ -3,7 +3,6 @@
 BIN_DIR = ../bin
 PDEXEC = $(BIN_DIR)/pd
 EXT= @EXT@
-GUINAME= @GUINAME@
 
 prefix = @prefix@
 exec_prefix = @exec_prefix@
@@ -59,10 +58,7 @@
 
 OBJ = $(SRC:.c=.o) 
 
-GSRC =  @GUISRC@
 
-GOBJ = $(GSRC:.c=.o)
-
 # get version from m_pd.h to use in doc/1.manual/1.introduction.txt
 PD_MAJOR_VERSION := $(shell grep PD_MAJOR_VERSION m_pd.h | \
 	sed 's|^.define *PD_MAJOR_VERSION *\([0-9]*\).*|\1|' )
@@ -123,9 +119,6 @@
 $(PDEXEC): $(OBJ) $(BIN_DIR)
 	cd ../obj;  $(CC) $(LDFLAGS) $(DBG_CFLAGS) -o $(PDEXEC) $(OBJ) $(LIB)
 
-$(BIN_DIR)/pd-gui: $(GOBJ) $(GSRC)
-	cd ../obj; $(CC) $(INCLUDE) -o $(BIN_DIR)/$(GUINAME) $(GOBJ) $(GLIB)
-
 $(BIN_DIR)/pd.tk: $(wildcard *.tcl) $(wildcard locale/*.tcl) $(BIN_DIR)
 	install pd.tk $(BIN_DIR)/pd.tk
 	install *.tcl $(BIN_DIR)/
@@ -133,25 +126,6 @@
 	install locale/*.tcl $(BIN_DIR)/locale
 	touch -r makefile.dependencies $(BIN_DIR)
 
-#this is for Max OSX only...
-$(BIN_DIR)/libPdTcl.dylib: $(GOBJ) $(GSRC)
-	cd ../obj && $(CC) $(CFLAGS) -dynamiclib -read_only_relocs warning  \
-		-o $(BIN_DIR)/libPdTcl.dylib $(GOBJ)  \
-		-F at TCLTK_FRAMEWORKS_PATH@ \
-		-framework Tcl  -framework Tk  -framework System  \
-		-Wl,-install_name, at executable_path/../Resources/bin/libPdTcl.dylib
-	install_name_tool -change @TCLTK_FRAMEWORKS_PATH@/Tcl.framework/Versions/8.4/Tcl\
-		 @executable_path/../Frameworks/Tcl.framework/Versions/8.4/Tcl \
-		 -change @TCLTK_FRAMEWORKS_PATH@/Tk.framework/Versions/8.4/Tk \
-		 @executable_path/../Frameworks/Tk.framework/Versions/8.4/Tk \
-		../bin/libPdTcl.dylib
-
-# this is for Windows/MinGW (only?)
-$(BIN_DIR)/pdtcl.dll: $(GOBJ)
-	cd $(BIN_DIR); dllwrap --export-all-symbols --output-def pdtcl.def \
-	--output-lib=pdtcl.a --dllname=$(GUINAME) $(OBJ_DIR)/t_tkcmd.o $(LIB) $(GLIB)
-	strip --strip-unneeded $(BIN_DIR)/pdtcl.dll
-
 externs: 
 	make -C ../extra/bonk~    @EXTERNTARGET@
 	make -C ../extra/choice   @EXTERNTARGET@

Deleted: branches/pd-devel/0.41.4/src/t_main.c
===================================================================
--- branches/pd-devel/0.41.4/src/t_main.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/t_main.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -1,115 +0,0 @@
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
-
-/* This file should be compared with the corresponding thing in the TK
-* distribution whenever updating to newer versions of TCL/TK. */
-
-/* 
- * Copyright (c) 1993 The Regents of the University of California.
- * Copyright (c) 1994 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-
-
-#ifndef __APPLE__     /* linux and IRIX only; in __APPLE__ we don't link this in */
-#include "tk.h"
-#include <stdlib.h>
-
-/*
- *----------------------------------------------------------------------
- *
- * main --
- *
- *      This is the main program for the application.
- *
- * Results:
- *      None: Tk_Main never returns here, so this procedure never
- *      returns either.
- *
- * Side effects:
- *      Whatever the application does.
- *
- *----------------------------------------------------------------------
- */
-
-void pdgui_startup(Tcl_Interp *interp);
-void pdgui_setname(char *name);
-void pdgui_setsock(int port);
-void pdgui_sethost(char *name);
-
-int
-main(int argc, char **argv)
-{
-    pdgui_setname(argv[0]);
-    if (argc >= 2)
-    {
-        pdgui_setsock(atoi(argv[1]));
-        argc--; argv++;
-        argv[0] = "Pd";
-    }
-    if (argc >= 2)
-    {
-        pdgui_sethost(argv[1]);
-        argc--; argv++;
-        argv[0] = "Pd";
-    }
-    Tk_Main(argc, argv, Tcl_AppInit);
-    return 0;                   /* Needed only to prevent compiler warning. */
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_AppInit --
- *
- *      This procedure performs application-specific initialization.
- *      Most applications, especially those that incorporate additional
- *      packages, will have their own version of this procedure.
- *
- * Results:
- *      Returns a standard Tcl completion code, and leaves an error
- *      message in interp->result if an error occurs.
- *
- * Side effects:
- *      Depends on the startup script.
- *
- *----------------------------------------------------------------------
- */
-
-
-int
-Tcl_AppInit(interp)
-    Tcl_Interp *interp;         /* Interpreter for application. */
-{
-    Tk_Window mainwindow;
-
-    if (Tcl_Init(interp) == TCL_ERROR) {
-        return TCL_ERROR;
-    }
-    if (Tk_Init(interp) == TCL_ERROR) {
-        return TCL_ERROR;
-    }
-
-    /* setup specific to pd-gui: */
-
-    pdgui_startup(interp);
-
-    /*
-     * Specify a user-specific startup file to invoke if the application
-     * is run interactively.  Typically the startup file is "~/.apprc"
-     * where "app" is the name of the application.  If this line is deleted
-     * then no user-specific startup file will be run under any conditions.
-     */
-
-#if 0
-    tcl_RcFileName = "~/.apprc";
-#endif
-
-    return TCL_OK;
-}
-
-#endif  /* __APPLE__ */

Deleted: branches/pd-devel/0.41.4/src/t_tk.h
===================================================================
--- branches/pd-devel/0.41.4/src/t_tk.h	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/t_tk.h	2009-01-13 01:19:49 UTC (rev 10524)
@@ -1,10 +0,0 @@
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
-
-void pdgui_vmess(char *fmt, ...);
-void pdgui_mess(char *s);
-
-void pdgui_evalfile(char *s);
-
-#define GUISTRING 1000

Deleted: branches/pd-devel/0.41.4/src/t_tkcmd.c
===================================================================
--- branches/pd-devel/0.41.4/src/t_tkcmd.c	2009-01-13 00:01:34 UTC (rev 10523)
+++ branches/pd-devel/0.41.4/src/t_tkcmd.c	2009-01-13 01:19:49 UTC (rev 10524)
@@ -1,647 +0,0 @@
-/* Copyright (c) 1997-1999 Miller Puckette.
-* For information on usage and redistribution, and for a DISCLAIMER OF ALL
-* WARRANTIES, see the file, "LICENSE.txt," in this distribution.  */
-
-#ifndef MSW     /* in unix this only works first; in MSW it only works last. */
-#include "tk.h"
-#endif
-
-#include "t_tk.h"
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <sys/types.h>
-
-#ifndef MSW
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <netdb.h>
-#ifdef HAVE_BSTRING_H
-#include <bstring.h>
-#endif
-#include <sys/time.h>
-#include <errno.h>
-#include <fcntl.h>
-#endif
-#ifdef MSW
-#include <winsock.h>
-#include <io.h>
-#endif
-
-/* These pragmas are only used for MSVC, not MinGW or Cygwin <hans at at.or.at> */
-#ifdef _MSC_VER
-#pragma warning( disable : 4305 )  /* uncast const double to float */
-#pragma warning( disable : 4244 )  /* uncast double to float */
-#pragma warning( disable : 4101 )  /* unused local variables */
-#endif
-
-#ifdef MSW
-#include "tk.h"
-#endif
-
-#ifdef __APPLE__
-#define STARTGUI
-#endif
-
-#ifdef __linux__
-#define STARTGUI
-#endif
-
-#define FIRSTPORTNUM 5600
-
-void tcl_mess(char *s);
-static Tcl_Interp *tk_pdinterp;
-static int pd_portno = 0;
-
-
-/***************** the socket setup code ********************/
-
-/* If this is reset by pdgui_setsock(), it's the port number Pd will try to
-connect to; but if zero, that means we should set it and start Pd ourselves. */
-
-
-        /* some installations of linux don't know about "localhost" so give
-        the loopback address; NT, on the other hand, can't understand the
-        hostname "127.0.0.1". */
-char hostname[100] =
-#ifdef __linux__
-    "127.0.0.1";
-#else
-    "localhost";
-#endif
-
-void pdgui_setsock(int port)
-{
-    pd_portno = port;
-}
-
-    /* why is this here??? probably never used (see t_main.c). */
-void pdgui_sethost(char *name)
-{
-    strncpy(hostname, name, 100);
-    hostname[99] = 0;
-}
-
-static void pdgui_sockerror(char *s)
-{
-#ifdef MSW
-    int err = WSAGetLastError();
-#endif
-#ifndef MSW
-    int err = errno;
-#endif
-
-    fprintf(stderr, "%s: %s (%d)\n", s, strerror(err), err);
-    tcl_mess("exit\n");
-    exit(1);
-}
-
-static int sockfd;
-
-/* The "pd_readsocket" command, which polls the socket. */
-
-#define CHUNKSIZE 20000 /* chunks to allocate memory for reading socket */
-#define READSIZE 10000  /* size of read to issue */
-
-static char *pd_tkbuf = 0;      /* buffer for reading */
-static int pd_tkbufsize = 0;    /* current buffer size */
-static int pd_buftail = 0;      /* number of bytes already in buffer */
-static int pd_bufhead = 0;    /* index of first byte to read */
-
-    /* mask argument unused but is here to follow tcl's prototype. */
-static void pd_readsocket(ClientData cd, int mask)
-{
-    fd_set readset, writeset, exceptset;
-    struct timeval timout;
-
-    timout.tv_sec = 0;
-    timout.tv_usec = 0;
-    FD_ZERO(&writeset);
-    FD_ZERO(&readset);
-    FD_ZERO(&exceptset);
-    FD_SET(sockfd, &readset);
-    FD_SET(sockfd, &exceptset);
-    if (!pd_tkbuf)
-    {
-        if (!(pd_tkbuf = malloc(CHUNKSIZE)))
-        {
-            fprintf(stderr, "pd-gui: out of memory\n");
-            tcl_mess("exit\n");
-        }
-        pd_tkbufsize = CHUNKSIZE;
-    }
-    if (pd_buftail + READSIZE + 1 > pd_tkbufsize)
-    {   
-        int newsize = pd_tkbufsize + CHUNKSIZE;
-        char *newbuf = realloc(pd_tkbuf, newsize);
-        if (!newbuf)
-        {
-            fprintf(stderr, "pd-gui: out of memory\n");
-            tcl_mess("exit\n");
-        }
-        pd_tkbuf = newbuf;
-        pd_tkbufsize = newsize;     
-    }
-    if (select(sockfd+1, &readset, &writeset, &exceptset, &timout) < 0)
-        perror("select");
-    if (FD_ISSET(sockfd, &exceptset) || FD_ISSET(sockfd, &readset))
-    {
-        int ret;
-        ret = recv(sockfd, pd_tkbuf + pd_buftail, READSIZE, 0);
-        if (ret < 0)
-            pdgui_sockerror("socket receive error");
-        else if (ret == 0)
-        {
-            /* fprintf(stderr, "read %d\n", SOCKSIZE - pd_buftail); */
-            fprintf(stderr, "pd_gui: pd process exited\n");
-            tcl_mess("exit\n");
-        }
-        else
-        {
-            pd_buftail += ret;
-            while (1)
-            {
-                char lastc = 0, *gotcr = 0, *bp = pd_tkbuf + pd_bufhead,
-                    *ep = pd_tkbuf + pd_buftail;
-                int brace = 0;
-                    /* search for locations that terminate a complete TK
-                    command.  These are carriage returns which are not inside
-                    any braces.  Braces can be escaped with backslashes (but
-                    backslashes themselves can't.) */
-                while (bp < ep)
-                {
-                    char c = *bp;
-                    if (c == '}' && brace)
-                        brace--;
-                    else if (c == '{')
-                        brace++;
-                    else if (!brace && c == '\n' && lastc != '\\')
-                    {
-                        gotcr = bp;
-                        break;
-                    }
-                    lastc = c;
-                    bp++;
-                }
-                    /* if gotcr is set there is at least one complete TK
-                    command in the buffer, and gotcr terminates the first one.
-                    Because sending the command to tcl may cause this code to
-                    be reentered, we first copy the command and take it out of
-                    the buffer, then execute the command.
-                    Execute it and slide any
-                    extra bytes to beginning of the buffer. */
-                if (gotcr)
-                {
-                    int bytesincmd = (gotcr - (pd_tkbuf+pd_bufhead)) + 1;
-                    char smallcmdbuf[1000], *realcmdbuf;
-                    if (gotcr - (pd_tkbuf+pd_bufhead) < 998)
-                        realcmdbuf = smallcmdbuf;
-                    else realcmdbuf = malloc(bytesincmd+1);
-                    if (realcmdbuf)
-                    {
-                        strncpy(realcmdbuf, pd_tkbuf+pd_bufhead, bytesincmd);
-                        realcmdbuf[bytesincmd] = 0;
-                    }
-                    pd_bufhead += bytesincmd;
-                    if (realcmdbuf)
-                    {
-                        tcl_mess(realcmdbuf);
-                        if (realcmdbuf != smallcmdbuf)
-                            free(realcmdbuf);
-                    }
-                    if (pd_buftail < pd_bufhead)
-                        fprintf(stderr, "tkcmd bug\n");
-                }
-                else break;
-            }
-            if (pd_bufhead)
-            {
-                if (pd_buftail > pd_bufhead)
-                    memmove(pd_tkbuf, pd_tkbuf + pd_bufhead,
-                        pd_buftail-pd_bufhead);
-                pd_buftail  -= pd_bufhead;
-                pd_bufhead = 0;
-            }
-        }
-    }
-}
-
-#ifdef MSW
-    /* if we're in Gatesland, we add a tcl command to poll the
-    socket for data.  */
-static int pd_pollsocketCmd(ClientData cd, Tcl_Interp *interp,
-    int argc, char **argv)
-{
-    pd_readsocket(cd, 0);
-    return (TCL_OK);
-}
-#endif
-
-static void pd_sockerror(char *s)
-{
-#ifdef MSW
-    int err = WSAGetLastError();
-    if (err == 10054) return;
-    else if (err == 10044)
-    {
-        fprintf(stderr,
-            "Warning: you might not have TCP/IP \"networking\" turned on\n");
-        fprintf(stderr, "which is needed for Pd to talk to its GUI layer.\n");
-    }
-#else
-    int err = errno;
-#endif
-    fprintf(stderr, "%s: %s (%d)\n", s, strerror(err), err);
-}
-
-static void pdgui_connecttosocket(void)
-{
-    struct sockaddr_in server;
-    struct hostent *hp;
-#ifndef MSW
-    int retry = 10;
-#else
-    int retry = 1;
-#endif
-#ifdef MSW
-    short version = MAKEWORD(2, 0);
-    WSADATA nobby;
-
-    if (WSAStartup(version, &nobby)) pdgui_sockerror("setup");
-#endif
-
-    /* create a socket */
-    sockfd = socket(AF_INET, SOCK_STREAM, 0);
-    if (sockfd < 0) pdgui_sockerror("socket");
-
-    /* connect socket using hostname provided in command line */
-    server.sin_family = AF_INET;
-
-    hp = gethostbyname(hostname);
-
-    if (hp == 0)
-    {
-        fprintf(stderr,
-            "localhost not found (inet protocol not installed?)\n");
-        exit(1);
-    }
-    memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length);
-
-    /* assign client port number */
-    server.sin_port = htons((unsigned short)pd_portno);
-
-        /* try to connect */
-    while (1)
-    {
-        if (connect(sockfd, (struct sockaddr *) &server, sizeof (server)) >= 0)
-            goto gotit;
-        retry--;
-        if (retry <= 0)
-            break;
-          /* In unix there's a race condition; the child won't be
-          able to connect before the parent (pd) has shed its
-          setuid-ness.  In case this is the problem, sleep and
-          retry. */
-        else
-        {
-#ifndef MSW
-            fd_set readset, writeset, exceptset;
-            struct timeval timout;
-
-            timout.tv_sec = 0;
-            timout.tv_usec = 100000;
-            FD_ZERO(&writeset);
-            FD_ZERO(&readset);
-            FD_ZERO(&exceptset);
-            fprintf(stderr, "retrying connect...\n");
-            if (select(1, &readset, &writeset, &exceptset, &timout) < 0)
-                perror("select");
-#endif /* !MSW */
-        }
-    }
-    pdgui_sockerror("connecting stream socket");
-gotit: ;
-#ifndef MSW
-        /* normally we ask TK to call us back; but in MSW we have to poll. */
-    Tk_CreateFileHandler(sockfd, TK_READABLE | TK_EXCEPTION,
-        pd_readsocket, 0);
-#endif /* !MSW */
-}
-
-#ifdef STARTGUI
-
-/* #define DEBUGCONNECT */
-
-#ifdef DEBUGCONNECT
-static FILE *debugfd;
-#endif
-
-
-static void pd_startfromgui( void)
-{
-    pid_t childpid;
-    char cmdbuf[1000], pdbuf[1000], *lastchar;
-    const char *arg0;
-    struct sockaddr_in server;
-    int msgsock;
-    int len = sizeof(server), nchar;
-    int ntry = 0, portno = FIRSTPORTNUM;
-    int xsock = -1;
-    char morebuf[256];
-#ifdef MSW
-    short version = MAKEWORD(2, 0);
-    WSADATA nobby;
-    char scriptbuf[1000], wishbuf[1000], portbuf[80];
-    int spawnret;
-    char intarg;
-#else
-    int intarg;
-#endif
-
-    arg0 = Tcl_GetVar(tk_pdinterp, "argv0", 0);
-    if (!arg0)
-    {
-        fprintf(stderr, "Pd-gui: can't get arg 0\n");
-        return;
-    }
-    lastchar = strrchr(arg0, '/');
-    if (lastchar)
-        snprintf(pdbuf, lastchar - arg0 + 1, "%s", arg0);
-    else strcpy(pdbuf, ".");
-    strcat(pdbuf, "/../bin/pd");
-#ifdef DEBUGCONNECT     
-    fprintf(stderr, "pdbuf is %s\n", pdbuf);
-#endif
-
-#ifdef MSW
-    if (WSAStartup(version, &nobby))
-        pd_sockerror("WSAstartup");
-#endif
-
-    /* create a socket */
-    xsock = socket(AF_INET, SOCK_STREAM, 0);
-    if (xsock < 0) pd_sockerror("socket");
-    intarg = 1;
-    if (setsockopt(xsock, IPPROTO_TCP, TCP_NODELAY,
-        &intarg, sizeof(intarg)) < 0)
-            fprintf(stderr, "setsockopt (TCP_NODELAY) failed\n");
-
-    server.sin_family = AF_INET;
-    server.sin_addr.s_addr = INADDR_ANY;
-
-    /* assign server port number */
-    server.sin_port =  htons((unsigned short)portno);
-
-        /* name the socket */
-    while (bind(xsock, (struct sockaddr *)&server, sizeof(server)) < 0)
-    {
-#ifdef MSW
-        int err = WSAGetLastError();
-#else
-        int err = errno;
-#endif
-        if ((ntry++ > 20) || (err != EADDRINUSE))
-        {
-            perror("bind");
-            fprintf(stderr,
-                "couldn't open GUI-to-pd network connection\n");
-            return;
-        }
-        portno++;
-        server.sin_port = htons((unsigned short)(portno));
-    }
-
-#ifdef DEBUGCONNECT     
-    fprintf(debugfd, "port %d\n", portno);
-        fflush(debugfd);
-#endif
-
-#ifdef UNISTD
-    sprintf(cmdbuf, "\"%s\" -guiport %d\n", pdbuf, portno);
-    childpid = fork();
-    if (childpid < 0)
-    {
-        if (errno) perror("sys_startgui");
-        else fprintf(stderr, "sys_startgui failed\n");
-        return;
-    }
-    else if (!childpid)                 /* we're the child */
-    {
-#ifdef DEBUGCONNECT     
-        fprintf(debugfd, "%s", cmdbuf);
-        fflush(debugfd);
-#endif
-        execl("/bin/sh", "sh", "-c", cmdbuf, (char*)0);
-        perror("pd: exec");
-        _exit(1);
-    }
-#endif /* UNISTD */
-
-#ifdef MSW       
-
-#error not yet used.... sys_bashfilename() not filled in here
-
-    strcpy(cmdbuf, pdcmd);
-    strcat(cmdbuf, "/pd.exe");
-    sys_bashfilename(scriptbuf, scriptbuf);
-
-    sprintf(portbuf, "%d", portno);
-
-    spawnret = _spawnl(P_NOWAIT, cmdbuf, "pd.exe", "-port", portbuf, 0);
-    if (spawnret < 0)
-    {
-        perror("spawnl");
-        fprintf(stderr, "%s: couldn't start\n", cmdbuf);
-        return;
-    }
-
-#endif /* MSW */
-
-#ifdef DEBUGCONNECT
-        fprintf(stderr, "Waiting for connection request... \n");
-#endif
-    if (listen(xsock, 5) < 0) pd_sockerror("listen");
-    sockfd = accept(xsock, (struct sockaddr *) &server, (unsigned int *)&len);
-    if (sockfd < 0) pd_sockerror("accept");
-#ifdef DEBUGCONNECT
-        fprintf(stderr, "... connected\n");
-#endif
-
-#ifndef MSW
-        /* normally we ask TK to call us back; but in MSW we have to poll. */
-    Tk_CreateFileHandler(sockfd, TK_READABLE | TK_EXCEPTION,
-        pd_readsocket, 0);
-#endif /* !MSW */
-}
-
-#endif /* STARTGUI */
-
-static void pdgui_setupsocket(void)
-{
-#ifdef MSW
-        pdgui_connecttosocket();
-#else
-    if (pd_portno)
-        pdgui_connecttosocket();
-    else pd_startfromgui() ;
-#endif
-}
-
-/**************************** commands ************************/
-static char *pdgui_path;
-
-/* The "pd" command, which cats its args together and throws the result
-* at the Pd interpreter.
-*/
-#define MAXWRITE 1024
-
-static int pdCmd(ClientData cd, Tcl_Interp *interp, int argc,  char **argv)
-{
-    if (argc == 2)
-    {
-        int n = strlen(argv[1]);
-        if (send(sockfd, argv[1], n, 0) < n)
-        {
-            perror("stdout");
-            tcl_mess("exit\n");
-        }
-    }
-    else
-    {
-        int i;
-        char buf[MAXWRITE];
-        buf[0] = 0;
-        for (i = 1; i < argc; i++)
-        {
-            if (strlen(argv[i]) + strlen(buf) + 2 > MAXWRITE)
-            {
-                interp->result = "pd: arg list too long";
-                return (TCL_ERROR);     
-            }
-            if (i > 1) strcat(buf, " ");
-            strcat(buf, argv[i]);
-        }
-        if (send(sockfd, buf, strlen(buf), 0) < 0)
-        {
-            perror("stdout");
-            tcl_mess("exit\n");
-        }
-    }
-    return (TCL_OK);
-}
-
-/***********  "c" level access to tk functions. ******************/
-
-void tcl_mess(char *s)
-{
-    int result;
-    result = Tcl_Eval(tk_pdinterp,  s);
-    if (result != TCL_OK)
-    {
-        if (*tk_pdinterp->result) printf("%s\n",  tk_pdinterp->result);
-    }
-}
-
-    /* in linux, we load the tk code from here (in MSW and MACOS, this
-    is done by passing the name of the file as a startup argument to
-    the wish shell.) */
-#if !defined(MSW) && !defined(__APPLE__)
-void pdgui_doevalfile(Tcl_Interp *interp, char *s)
-{
-    char buf[GUISTRING];
-    sprintf(buf, "set pd_guidir \"%s\"\n", pdgui_path);
-    tcl_mess(buf);
-    strcpy(buf, pdgui_path);
-    strcat(buf, "/bin/");
-    strcat(buf, s);
-    if (Tcl_EvalFile(interp, buf) != TCL_OK)
-    {
-        char buf2[1000];
-        sprintf(buf2, "puts [concat tcl: %s: can't open script]\n",
-            buf);
-        tcl_mess(buf2);
-    }
-}
-
-void pdgui_evalfile(char *s)
-{
-    pdgui_doevalfile(tk_pdinterp, s);
-}
-#endif
-
-void pdgui_startup(Tcl_Interp *interp)
-{
-        /* save pointer to the main interpreter */
-    tk_pdinterp = interp;
-
-        /* add our own TK commands */
-    Tcl_CreateCommand(interp, "pd",  (Tcl_CmdProc*)pdCmd, (ClientData)NULL, 
-        (Tcl_CmdDeleteProc *)NULL); 
-#ifdef MSW
-    Tcl_CreateCommand(interp, "pd_pollsocket",(Tcl_CmdProc*)  pd_pollsocketCmd,
-        (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
-#endif
-    pdgui_setupsocket();
-        /* read in the startup file */
-#if !defined(MSW) && !defined(__APPLE__)
-    pdgui_evalfile("pd.tk");
-#endif
-}
-
-#ifndef MSW
-void pdgui_setname(char *s)
-{
-    char *t;
-    char *str;
-    int n;
-    if (t = strrchr(s, '/')) str = s, n = (t-s) + 1;
-    else str = "./", n = 2;
-    if (n > GUISTRING-100) n = GUISTRING-100;
-    pdgui_path = malloc(n+9);
-
-    strncpy(pdgui_path, str, n);
-    while (strlen(pdgui_path) > 0 && pdgui_path[strlen(pdgui_path)-1] == '/')
-        pdgui_path[strlen(pdgui_path)-1] = 0;
-    if (t = strrchr(pdgui_path, '/'))
-        *t = 0;
-}
-#endif
-
-    /* this is called when an off-the-shelf "wish" has to "load" this module
-    at runtime.  In Linux, this module is linked in and Pdtcl_Init() is not
-    called; instead, the code in t_main.c calls pdgui_setsock() and
-    pdgui_startup(). */ 
-
-int Pdtcl_Init(Tcl_Interp *interp)
-{
-    const char *argv = Tcl_GetVar(interp, "argv", 0);
-    int portno, argno = 0;
-    if (argv && (portno = atoi(argv)) > 1)
-        pdgui_setsock(portno);
-#ifdef DEBUGCONNECT
-        pd_portno = portno;
-    debugfd = fopen("/tmp/bratwurst", "w");
-    fprintf(debugfd, "turning stderr back on\n");
-    fflush(debugfd);
-    dup2(fileno(debugfd), 2);
-    fprintf(stderr, "duped to stderr?\n");
-    fprintf(stderr, "portno %d\n", pd_portno);
-    fprintf(stderr, "argv %s\n", argv);
-#endif
-    tk_pdinterp = interp;
-    pdgui_startup(interp);
-    interp->result = "loaded pdtcl_init";
-
-    return (TCL_OK);
-}
-
-#if 0
-int Pdtcl_SafeInit(Tcl_Interp *interp) {
-    fprintf(stderr, "Pdtcl_Safeinit 51\n");
-        return (TCL_OK);
-}
-#endif
-


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list