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