/*
 * File : example_wrap.c
 * Thu Apr  4 13:11:45 1996
 *
 * This file was automatically generated by :
 * Simplified Wrapper and Interface Generator (SWIG)
 * 
 * Copyright (c) 1995,1996
 * The Regents of the University of California and
 * The University of Utah
 *
 */

/* Implementation : TCL */

#define INCLUDE_TCL    
#define INCLUDE_TK     
#include INCLUDE_TCL
#include 
#include 
static void _swig_make_hex(char *_c, void *_ptr, char *type) {
static char _hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
			'a', 'b', 'c', 'd', 'e', 'f' };
  unsigned long _p,_s;
  char     _result[128], *_r;
  _r = _result;
  _p = (unsigned long) _ptr;
  if (_p > 0) {
     while (_p > 0) {
        _s = _p & 0xf;
        *(_r++) = _hex[_s];
        _p = _p >> 4;
     } 
     *_r = '_';
     while (_r >= _result) *(_c++) = *(_r--);
  } else {
     strcpy(_c,"NULL");
  }
  if (_ptr) strcpy(_c,type);
}
static char *_swig_get_hex(char *_c, void **ptr, char *_t) {
  unsigned long _p;
  char *_tt;
  _p = 0;
  if (*_c == '_') { 
     _c++;
     while (*_c) {
       if ((*_c >= '0') && (*_c <= '9')) _p = (_p << 4) + (*_c - '0');
       else if ((*_c >= 'a') && (*_c <= 'f')) _p = (_p << 4) + ((*_c - 'a') + 10);
       else break; 
       _c++;
     }
     if (_p == 0) {
         return (char *) _c;
     }
     _tt = _c;
     if (_t) {
        if (strcmp(_c,_t)) return _tt;
     }
     *ptr = (void *) _p;
      return (char *) 0;
   } else {
      if (strcmp(_c,"NULL") == 0) {
         *ptr = (void *) 0;
         return (char *) 0;
      }
      else
         return _c;
  }
}

#define SWIG_init    Wrap_Init




/* A TCL_AppInit() function that lets you build a new copy
 * of tclsh.
 *
 * The macro WG_init contains the name of the initialization
 * function in the wrapper file.
 */

#ifndef SWIG_RcFileName
char *SWIG_RcFileName = "~/.myapprc";
#endif

#if TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION >= 4
int main(int argc, char **argv) {

  Tcl_Main(argc, argv, Tcl_AppInit);
  return(0);

}
#else
extern int main();
#endif

int Tcl_AppInit(Tcl_Interp *interp){
  int SWIG_init(Tcl_Interp *);  /* Forward reference */

  if (Tcl_Init(interp) == TCL_ERROR) 
    return TCL_ERROR;

  /* Now initialize our functions */

  if (SWIG_init(interp) == TCL_ERROR)
    return TCL_ERROR;

  tcl_RcFileName = SWIG_RcFileName;
  return TCL_OK;
}

extern double   My_variable;
extern int  fact(int  );
extern int  mod(int  ,int  );
extern char * get_time();
int _wrap_tcl_fact(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) {
	 int  _result;
	 int _arg0;

	 if (argc != 2) {
		 Tcl_SetResult(interp, "Wrong # args  int  : fact n ",TCL_STATIC);
		 return TCL_ERROR;
	}
	 _arg0 = (int ) atol(argv[1]);
	 _result = fact(_arg0);
	 sprintf(interp->result,"%ld", (long) _result);
	 return TCL_OK;
}
int _wrap_tcl_mod(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) {
	 int  _result;
	 int _arg0;
	 int _arg1;

	 if (argc != 3) {
		 Tcl_SetResult(interp, "Wrong # args  int  : mod x y ",TCL_STATIC);
		 return TCL_ERROR;
	}
	 _arg0 = (int ) atol(argv[1]);
	 _arg1 = (int ) atol(argv[2]);
	 _result = mod(_arg0,_arg1);
	 sprintf(interp->result,"%ld", (long) _result);
	 return TCL_OK;
}
int _wrap_tcl_get_time(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) {
	 char * _result;

	 if (argc != 1) {
		 Tcl_SetResult(interp, "Wrong # args  char * : get_time ",TCL_STATIC);
		 return TCL_ERROR;
	}
	 _result = get_time();
	 Tcl_SetResult(interp, _result, TCL_VOLATILE);
	 return TCL_OK;
}
int Wrap_Init(Tcl_Interp *interp) {
	 if (interp == 0) 
		 return TCL_ERROR;
	 Tcl_LinkVar(interp, "My_variable", (char *) &My_variable, TCL_LINK_DOUBLE);
	 Tcl_CreateCommand(interp, "fact", _wrap_tcl_fact, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
	 Tcl_CreateCommand(interp, "mod", _wrap_tcl_mod, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
	 Tcl_CreateCommand(interp, "get_time", _wrap_tcl_get_time, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
	 return TCL_OK;
}