1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
/* -*- c -*-
* init.c --
*
* Implements the C level procedures handling the initialization of
* this package
*
*
* Copyright (c) 1996-1999 Andreas Kupries (a.kupries@westend.com)
* Copyright (c) 2000-2005 Andreas Kupries (akupries@shaw.ca)
* All rights reserved.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL I LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
* INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS
* SOFTWARE AND ITS DOCUMENTATION, EVEN IF I HAVE BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* I SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
* I HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
* ENHANCEMENTS, OR MODIFICATIONS.
*
* CVS: $Id: init.c,v 1.11 2005/06/08 17:47:59 andreas_kupries Exp $
*/
/*#include <stdlib.h>*/
#include "memchanInt.h"
#include "buf.h"
extern BufStubs bufStubs;
char *
Buf_InitStubs _ANSI_ARGS_((Tcl_Interp *interp, CONST char *version, int exact));
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION MEMCHAN_VERSION
#endif
#ifndef PACKAGE_NAME
#define PACKAGE_NAME "Memchan"
#endif
/*
*------------------------------------------------------*
*
* Memchan_Init --
*
* ------------------------------------------------*
* Standard procedure required by 'load'.
* Initializes this extension.
* ------------------------------------------------*
*
* Sideeffects:
* As of 'Tcl_CreateCommand'.
*
* Result:
* A standard Tcl error code.
*
*------------------------------------------------------*
*/
int Memchan_Init (interp)
Tcl_Interp* interp;
{
#if GT81
if (Tcl_InitStubs (interp, "8.1", 0) == NULL) {
return TCL_ERROR;
}
#endif
Tcl_CreateObjCommand (interp, "memchan",
&MemchanCmd,
(ClientData) NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateObjCommand (interp, "fifo",
&MemchanFifoCmd,
(ClientData) NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateObjCommand (interp, "fifo2",
&MemchanFifo2Cmd,
(ClientData) NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateObjCommand (interp, "null",
&MemchanNullCmd,
(ClientData) NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateObjCommand (interp, "random",
&MemchanRandomCmd,
(ClientData) NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateObjCommand (interp, "zero",
&MemchanZeroCmd,
(ClientData) NULL,
(Tcl_CmdDeleteProc*) NULL);
#if GT81
/* register extension and its interfaces as now available package
*/
Tcl_PkgProvideEx (interp, PACKAGE_NAME, PACKAGE_VERSION, (ClientData) &bufStubs);
#ifndef __WIN32__
Buf_InitStubs (interp, PACKAGE_VERSION, 0);
#endif
#else
/* register memory channels as available package */
Tcl_PkgProvide (interp, PACKAGE_NAME, PACKAGE_VERSION);
#endif
Buf_Init (interp);
return TCL_OK;
}
/*
*------------------------------------------------------*
*
* Memchan_SafeInit --
*
* ------------------------------------------------*
* Standard procedure required by 'load'.
* Initializes this extension for a safe interpreter.
* ------------------------------------------------*
*
* Sideeffects:
* As of 'Memchan_Init'
*
* Result:
* A standard Tcl error code.
*
*------------------------------------------------------*
*/
int Memchan_SafeInit (interp)
Tcl_Interp* interp;
{
return Memchan_Init (interp);
}
|