There are no available options for this view.

Parent Directory Parent Directory | Revision <a href="/cvs/aolserver/aolserver/nsd/log.c#A_Log">Log</a> Revision <a href="/cvs/aolserver/aolserver/nsd/log.c#A_Log">Log</a>

Revision 1.1 - (show annotations) (download) (as text)
Tue Dec 8 04:12:20 2009 UTC (8 years ago) by jgdavidson
Branch: MAIN
CVS Tags: aolserver_v45_r2_rc0, HEAD
Branch point for: aolserver_v45_r2
File MIME type: text/x-chdr
Added read and write filters, fixed bugs with pre-queue filters and
que-wait callbacks, added ns_tls, ns_cls, and ns_quewait commands.
1 /*
2 * The contents of this file are subject to the AOLserver Public License
3 * Version 1.1 (the "License"); you may not use this file except in
4 * compliance with the License. You may obtain a copy of the License at
5 * http://aolserver.com/.
6 *
7 * Software distributed under the License is distributed on an "AS IS"
8 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9 * the License for the specific language governing rights and limitations
10 * under the License.
11 *
12 * The Original Code is AOLserver Code and related documentation
13 * distributed by AOL.
14 *
15 * The Initial Developer of the Original Code is America Online,
16 * Inc. Portions created by AOL are Copyright (C) 1999 America Online,
17 * Inc. All Rights Reserved.
18 *
19 * Alternatively, the contents of this file may be used under the terms
20 * of the GNU General Public License (the "GPL"), in which case the
21 * provisions of GPL are applicable instead of those above. If you wish
22 * to allow use of your version of this file only under the terms of the
23 * GPL and not to allow others to use your version of this file under the
24 * License, indicate your decision by deleting the provisions above and
25 * replace them with the notice and other provisions required by the GPL.
26 * If you do not delete the provisions above, a recipient may use your
27 * version of this file under either the License or the GPL.
28 */
29
30 /*
31 * tclstore.c --
32 *
33 * Thread and connection local storage Tcl commands.
34 */
35
36 static const char *RCSID = "@(#) $Header: /cvsroot-fuse/aolserver/aolserver/nsd/tclstore.c,v 1.1 2009/12/08 04:12:20 jgdavidson Exp $, compiled: " __DATE__ " " __TIME__;
37
38 #include "nsd.h"
39
40 /*
41 * Static functions defined in this file.
42 */
43
44 static int <a href="/cvs/aolserver/aolserver/nsd/tclstore.c#A_StoreObjCmd">StoreObjCmd</a>(ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj **objv, int tls);
45
46
47 /*
48 *----------------------------------------------------------------------
49 *
50 * <a href="/cvs/aolserver/aolserver/nsd/tclstore.c#A_NsTclTlsObjCmd">NsTclTlsObjCmd</a>, <a href="/cvs/aolserver/aolserver/nsd/tclstore.c#A_NsTclClsObjCmd">NsTclClsObjCmd</a> --
51 *
52 * Implements ns_tls and ns_cls as obj commands.
53 *
54 * Results:
55 * Tcl result.
56 *
57 * Side effects:
58 * See docs.
59 *
60 *----------------------------------------------------------------------
61 */
62
63 int
64 <a href="/cvs/aolserver/aolserver/nsd/tclstore.c#A_NsTclTlsObjCmd">NsTclTlsObjCmd</a>(ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj **objv, Ns_Conn *conn)
65 {
66 return <a href="/cvs/aolserver/aolserver/nsd/tclstore.c#A_StoreObjCmd">StoreObjCmd</a>(data, interp, objc, objv, 1);
67 }
68
69 int
70 <a href="/cvs/aolserver/aolserver/nsd/tclstore.c#A_NsTclClsObjCmd">NsTclClsObjCmd</a>(ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj **objv, Ns_Conn *conn)
71 {
72 return <a href="/cvs/aolserver/aolserver/nsd/tclstore.c#A_StoreObjCmd">StoreObjCmd</a>(data, interp, objc, objv, 0);
73 }
74
75 static int
76 <a href="/cvs/aolserver/aolserver/nsd/tclstore.c#A_StoreObjCmd">StoreObjCmd</a>(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv, int tls)
77 {
78 static CONST char *opts[] = {
79 "alloc", "get", "set", NULL
80 };
81 enum {
82 AllocIdx, GetIdx, SetIdx
83 } _nsmayalias opt;
84 Ns_Conn *conn;
85 char *val;
86 int id;
87
88 if (objc < 2) {
89 Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
90 return TCL_ERROR;
91 }
92 if (Tcl_GetIndexFromObj(interp, objv[1], opts, "option", 0,
93 (int *) &opt) != TCL_OK) {
94 return TCL_ERROR;
95 }
96 if (opt == AllocIdx) {
97 if (objc != 2) {
98 Tcl_WrongNumArgs(interp, 2, objv, NULL);
99 return TCL_ERROR;
100 }
101 if (tls) {
102 Ns_TlsAlloc((Ns_Tls *) &id, ns_free);
103 } else {
104 <a href="/cvs/aolserver/aolserver/nsd/cls.c#A_Ns_ClsAlloc">Ns_ClsAlloc</a>((Ns_Cls *) &id, ns_free);
105 }
106 Tcl_SetObjResult(interp, Tcl_NewIntObj(id));
107 } else {
108 if (!tls && <a href="/cvs/aolserver/aolserver/nsd/tclresp.c#A_NsTclGetConn">NsTclGetConn</a>((NsInterp *) arg, &conn) != TCL_OK) {
109 return TCL_ERROR;
110 }
111 if (objc < 3) {
112 Tcl_WrongNumArgs(interp, 2, objv, "index");
113 return TCL_ERROR;
114 }
115 if (Tcl_GetIntFromObj(interp, objv[2], &id) != TCL_OK) {
116 return TCL_ERROR;
117 }
118 if (id < 1 || id >= (tls ? NS_THREAD_MAXTLS : NS_CONN_MAXCLS)) {
119 Tcl_AppendResult(interp, "invalid id: ", Tcl_GetString(objv[2]), NULL);
120 return TCL_ERROR;
121 }
122 if (tls) {
123 val = Ns_TlsGet((Ns_Tls *) &id);
124 } else {
125 val = <a href="/cvs/aolserver/aolserver/nsd/cls.c#A_Ns_ClsGet">Ns_ClsGet</a>((Ns_Cls *) &id, conn);
126 }
127 if (opt == GetIdx) {
128 Tcl_SetResult(interp, val, TCL_VOLATILE);
129 } else {
130 if (objc != 4) {
131 Tcl_WrongNumArgs(interp, 2, objv, "index value");
132 return TCL_ERROR;
133 }
134 if (val) {
135 ns_free(val);
136 }
137 val = ns_strdup(Tcl_GetString(objv[3]));
138 if (tls) {
139 Ns_TlsSet((Ns_Tls *) &id, (void **) val);
140 } else {
141 <a href="/cvs/aolserver/aolserver/nsd/cls.c#A_Ns_ClsSet">Ns_ClsSet</a>((Ns_Cls *) &id, conn, (void **) val);
142 }
143 }
144 }
145 return TCL_OK;
146 }