~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina5/tina-tools/tinatool/wdgts/tcl/wdgtsTcl_tw_sglobal.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * This file is part of the TINA Open Source Image Analysis Environment
  4  * henceforth known as TINA
  5  *
  6  * TINA is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU Lesser General Public License as 
  8  * published by the Free Software Foundation.
  9  *
 10  * TINA is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  * GNU Lesser General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU Lesser General Public License
 16  * along with TINA; if not, write to the Free Software Foundation, Inc., 
 17  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  *
 19  **********
 20  * 
 21  * Program :    TINA
 22  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/wdgts/tcl/wdgtsTcl_tw_sglobal.c,v $
 23  * Date    :  $Date: 2007/02/15 01:55:50 $
 24  * Version :  $Revision: 1.4 $
 25  * CVS Id  :  $Id: wdgtsTcl_tw_sglobal.c,v 1.4 2007/02/15 01:55:50 paul Exp $
 26  *
 27  * Author  : Legacy TINA
 28  *
 29  * Notes :
 30  *
 31  *********
 32 */
 33 
 34 #include "wdgtsTcl_tw_sglobal.h"
 35 
 36 #if HAVE_CONFIG_H
 37 #   include <config.h>
 38 #endif
 39 
 40 #include <stdio.h>
 41 #include <tcl.h>
 42 
 43 #include <tinatool/wdgts/tcl/wdgts_TclDef.h>
 44 #include <tinatool/wdgts/tcl/wdgts_TclPro.h>
 45 #include "wdgtsTcl_tw_command.h"
 46 
 47 static void sglobal_call(Tw_callback *twc)
 48 {
 49 }
 50 
 51 
 52 static void sglobal_cmnd(Tw_callback * twc, char *args)
 53 {
 54     char  *ptr = (char *)twc->data1;
 55 
 56     (void) sscanf(args, "%*s %s", ptr);
 57 }
 58 
 59 
 60 static void sglobal_prnt(FILE * fp, Tw_callback * twc)
 61 {
 62     char *s = (char *) twc->data1;
 63 
 64     (void) fprintf(fp, "%s %s\n", twc->name, s);
 65 }
 66 
 67 
 68 /*
 69  *  Mods to read char by char and avoid scanf problems with spaces in the command line
 70  *  GAB 13 Jan 2003
 71  */
 72 static char *ttcl_writetrace_sglobal(ClientData cdata, Tcl_Interp *interp,
 73                                                         char *name1, char *name2, int flags)
 74 {
 75     Tw_callback *twc = (Tw_callback *)cdata;
 76     char        *ptr = (char *)twc->data1;
 77     char        *tclvalue;
 78     char         nextChar;
 79 
 80     tclvalue = Tcl_GetVar2(interp, name1, name2, flags);
 81     if (tclvalue == NULL)
 82         return ("variable update failed");
 83 
 84     (void) sscanf(tclvalue, "%c", &nextChar);
 85 
 86     while (nextChar != '\0')
 87     {
 88         *ptr++ = nextChar;
 89         nextChar = *(++tclvalue);
 90     }
 91     *ptr++ = '\0';
 92 
 93     return(NULL);
 94 }
 95 
 96 
 97 static char *ttcl_readtrace_sglobal(ClientData cdata, Tcl_Interp *interp,
 98                                                         char *name1, char *name2, int flags)
 99 {
100     Tw_callback *twc = (Tw_callback *)cdata;
101     char        *ptr = (char *)twc->data1;
102 
103     if (!Tcl_SetVar2(interp, name1, name2, ptr, flags))
104         return ("variable update failed");
105     return(NULL);
106 }
107 
108 
109 Tw_callback *tw_sglobal(char *name, char *ptr, int nchars)
110 {
111     Tcl_Interp  *interp;
112     Tw_callback *twc;
113     char        *fullname = tw_extend_fullname(tw_get_toolname(), name);
114     char        *tclname;
115         
116     if ((interp = ttcl_get_interp()) == NULL)
117         return;
118 
119     twc = tw_callback_make(fullname, 0, sglobal_call, sglobal_cmnd,
120                              sglobal_prnt, (void (*)()) NULL, (void *)ptr, NULL);
121 
122     tclname = ttcl_mkshellname(fullname, TTCLSGLOBAL);
123 
124     Tcl_SetVar(interp, tclname, ptr, 0);
125     Tcl_TraceVar(interp, tclname, TCL_TRACE_WRITES, ttcl_writetrace_sglobal, 
126                    (ClientData)twc);
127     Tcl_TraceVar(interp, tclname, TCL_TRACE_READS, ttcl_readtrace_sglobal, 
128                    (ClientData)twc);
129 
130     rfree(tclname);
131     return (twc);
132 }
133 
134 void tw_sglobal_reset(Tw_callback * twc)
135 {
136 }
137 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.