File: threadNs.c

package info (click to toggle)
tclthread3 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,752 kB
  • sloc: ansic: 8,259; tcl: 1,711; sh: 436; makefile: 38
file content (88 lines) | stat: -rw-r--r-- 2,177 bytes parent folder | download | duplicates (3)
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
/*
 * threadNs.c --
 *
 * Adds interface for loading the extension into the NaviServer/AOLserver.
 *
 * Copyright (c) 2002 by Zoran Vasiljevic.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * ---------------------------------------------------------------------------
 */

#ifdef NS_AOLSERVER
#include <ns.h>
#include "tclThreadInt.h"

int Ns_ModuleVersion = 1;

/*
 *----------------------------------------------------------------------------
 *
 * NsThread_Init --
 *
 *    Loads the package for the first time, i.e. in the startup thread.
 *
 * Results:
 *    Standard Tcl result
 *
 * Side effects:
 *    Package initialized. Tcl commands created.
 *
 *----------------------------------------------------------------------------
 */

static int
NsThread_Init(Tcl_Interp *interp, const void *cd)
{
    NsThreadInterpData *md = (NsThreadInterpData *)cd;
    int ret = Thread_Init(interp);

    if (ret != TCL_OK) {
	Ns_Log(Warning, "can't load module %s: %s", md->modname,
		Tcl_GetString(Tcl_GetObjResult(interp)));
	return TCL_ERROR;
    }
    Tcl_SetAssocData(interp, "thread:nsd", NULL, md);

    return TCL_OK;
}

/*
 *----------------------------------------------------------------------------
 *
 * Ns_ModuleInit --
 *
 *    Called by the NaviServer/AOLserver when loading shared object file.
 *
 * Results:
 *    Standard NaviServer/AOLserver result
 *
 * Side effects:
 *    Many. Depends on the package.
 *
 *----------------------------------------------------------------------------
 */

int
Ns_ModuleInit(char *srv, char *mod)
{
    NsThreadInterpData *md = NULL;

    md = (NsThreadInterpData *)ns_malloc(sizeof(NsThreadInterpData));
    md->modname = strcpy(ns_malloc(strlen(mod) + 1), mod);
    md->server  = strcpy(ns_malloc(strlen(srv) + 1), srv);

    return Ns_TclRegisterTrace(srv, NsThread_Init, md, NS_TCL_TRACE_CREATE);
}

#endif /* NS_AOLSERVER */

/* EOF $RCSfile: aolstub.cpp,v $ */

/* Emacs Setup Variables */
/* Local Variables:      */
/* mode: C               */
/* indent-tabs-mode: nil */
/* c-basic-offset: 4     */
/* End:                  */