🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #12140

Re: fork(), pipes,... no mentero

#12140
From: Claudio S. Suarez
Date: Thu, 30 Aug 2001 18:19
46 lines
2582 bytes
El Tue, 21 Aug 2001 15:46:10 GMT, Joan escribi�:

>Resulta que quiero hacer que mi programa controle a otro de
>forma interactiva. Asi puedo ejecutar el wish y usar tcl/tk
>desde C.

  Quiz� no sepas que para manejar Tcl/Tk desde C no necesitas forks ni
  dups... y si ya lo sabes aqu� queda para quien le pueda interesar.
  libtcl es una librer�a que te permite cargar y ejecutar scripts de tcl
  claro. Tk es un toolkit que tambi�n puede ser usado desde C.

  Las funciones b�sicas de Tcl son:
  Tcl_Interp *Tcl_CreateInterp(void) -> crea un interprete.
  void Tcl_DeleteInterp(Tcl_Interp *in) -> lo destruye.
  int Tcl_Eval(Tcl_Interp *in, char *script) -> evalua el script
     de un modo similar a como se har�a con tclsh.
  int Tcl_EvalFile(Tcl_Interp *in, char *archivo) -> lo mismo pero
     el script est� contenido en el archivo.
  void Tcl_CreateCommand(Tcl_Interp *in, char *nombre, Tcl_CmdProc
     *proc, ClientData *datos, Tcl_DeleteProc *pr_dest) -> crea un
     comando de Tcl
  
  etc.
  Por ejemplo:
  #include <stdio.h>
  #include <stdlib.h>
  #include <tcl.h>
  
  int main(int argc, char **argv) {
    Tcl_Interp *interp;
    int cod;
    
    if (argc!=2) {
      fprintf(stderr,"Uso: %s fichero\n", argv[0]);
      exit(1);
    }
    
    interp = Tcl_CreateInterp();
    cod = Tcl_EvalFile(interp, argv[1]);
    exit( cod == TCL_OK ? 0 : 1 ):
  }

  compilas incluyendo -ltcl en la l�ne ade comandos

Un saludo.
--claudio--
Technical Details
Message-ID: <slrn9ot0sq.6m.claudio@cacho.celta>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!skynet.be!skynet.be!Amsterdam.Infonet!News.Amsterdam.UnisourceCS!newsinternetskywayteltow!post.skyway.de!news.jazztel.es!ningun.host!claudio
References: <6nvg7.24112$322.414183@telenews.teleline.es>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,6b0d03b6e42024c5
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2001-08-30 14:46:01 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!skynet.be!skynet.be!Amsterdam.Infonet!News.Amsterdam.UnisourceCS!newsinternetskywayteltow!post.skyway.de!news.jazztel.es!ningun.host!claudio
From: claudio@ningun.sitio.es (Claudio S. Suarez)
Newsgroups: es.comp.os.linux.programacion
Subject: Re: fork(), pipes,... no mentero
Lines: 45
Message-ID: <slrn9ot0sq.6m.claudio@cacho.celta>
References: <6nvg7.24112$322.414183@telenews.teleline.es>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Server-Date: 30 Aug 2001 18:19:06 GMT
X-Newsreader: slrn (0.9.4.3 UNIX)
Date: 30 Aug 2001 18:19:06 GMT
NNTP-Posting-Host: 212.106.244.14
X-Complaints-To: newsmaster@jazztel.com
X-Trace: news.jazztel.es 999206866 212.106.244.14 (Thu, 30 Aug 2001 23:27:46 CEST)
NNTP-Posting-Date: Thu, 30 Aug 2001 23:27:46 CEST
Organization: Jazztel