Back to index

extremetuxracer  0.5beta
Defines | Functions
tcl_util.h File Reference
#include "etracer.h"
#include "ppgltk/ppgltk.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define NEXT_ARG   argc -=1; argv += 1
#define CHECK_ARG(name_str, err_string, bail_label)

Functions

int get_tcl_tuple (Tcl_Interp *ip, const char *inList, double *p, int n)
int get_tcl_int_tuple (Tcl_Interp *ip, const char *inList, int *p, int n)
void setup_tcl_std_channels ()
 Sets the Tcl stderr and stdout channels to be the same as the C stderr and stdout streams.

Define Documentation

#define CHECK_ARG (   name_str,
  err_string,
  bail_label 
)
Value:
if ( *argv == NULL ) { \
    (err_string) = "No argument supplied for " name_str; \
    goto bail_label; \
}

Definition at line 38 of file tcl_util.h.

#define NEXT_ARG   argc -=1; argv += 1

Definition at line 35 of file tcl_util.h.


Function Documentation

int get_tcl_int_tuple ( Tcl_Interp *  ip,
const char *  inList,
int *  p,
int  n 
)

Definition at line 67 of file tcl_util.cpp.

{
    CONST84 char **indices;
    int tmp;
    int num_ints;
    int rtn;
    char s[100];
    int i;

    rtn = Tcl_SplitList(ip, inList, &num_ints, &indices);

    if ((TCL_OK != rtn) || (n != num_ints)) {
       sprintf(s,"%d",n);
       Tcl_AppendResult(ip, 
                      "Expected a tuple of ", s, " integers.\n",
                      (char *) 0
           );
       Tcl_Free((char *)indices);
       return TCL_ERROR;
    }

    for (i = 0; i < n; i++) {
       if (TCL_OK != Tcl_GetInt(ip, indices[i], &tmp)) {
           Tcl_Free((char *)indices);
           sprintf(s,"%d",n);
           Tcl_AppendResult(ip, 
                          "Expected a tuple of ", s, " integers.\n",
                          (char *) 0
              );
           return TCL_ERROR;
       }
       p[i] = tmp;
    }
    Tcl_Free((char *)indices);
    return TCL_OK;
}

Here is the caller graph for this function:

int get_tcl_tuple ( Tcl_Interp *  ip,
const char *  inList,
double *  p,
int  n 
)

Definition at line 28 of file tcl_util.cpp.

{
    CONST84 char **indices;
    double tmp;
    int num_doubles;
    int rtn;
    char s[100];
    int i;

    rtn = Tcl_SplitList(ip, inList, &num_doubles, &indices);

    if ((TCL_OK != rtn) || (n != num_doubles)) {
       sprintf(s,"%d",n);
       Tcl_AppendResult(ip, 
                      "Expected a tuple of ", s, " doubles.\n",
                      (char *) 0
           );
       Tcl_Free((char *)indices);
       return TCL_ERROR;
    }

    for (i = 0; i < n; i++) {
       if (TCL_OK != Tcl_GetDouble(ip, indices[i], &tmp)) {
           Tcl_Free((char *)indices);
           sprintf(s,"%d",n);
           Tcl_AppendResult(ip, 
                          "Expected a tuple of ", s, " doubles.\n",
                          (char *) 0
              );
           return TCL_ERROR;
       }
       p[i] = tmp;
    }
    Tcl_Free((char *)indices);
    return TCL_OK;

}

Here is the caller graph for this function:

Sets the Tcl stderr and stdout channels to be the same as the C stderr and stdout streams.

Author:
jfpatry

Definition at line 112 of file tcl_util.cpp.

{
    /* Only need to do this under Win32 */
#if defined( NATIVE_WIN32_COMPILER )
    Tcl_Channel stdout_chnl, stderr_chnl;

    /* I'm not sure why the _dup is necessary under Windows.  

       See the Tcl_SetStdChannel manpage for more info.
    */
    
    /* Create new stdout channel */
    Tcl_SetStdChannel( NULL, TCL_STDOUT );
    
    stdout_chnl = Tcl_MakeFileChannel( 
       (ClientData) _get_osfhandle( _dup( _fileno(stdout) ) ),
       TCL_WRITABLE );
    
    check_assertion( stdout_chnl, "Couldn't create new stdout channel" );
    
    
    /* Create a new stderr channel */
    Tcl_SetStdChannel( NULL, TCL_STDERR );
    
    stderr_chnl = Tcl_MakeFileChannel( 
       (ClientData) _get_osfhandle( _dup( _fileno(stderr) ) ),
       TCL_WRITABLE );
    
    check_assertion( stderr_chnl, "Couldn't create new stderr channel" );
#endif
}

Here is the caller graph for this function: