File: tapi-104.htm

package info (click to toggle)
aolserver 3.4.2-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 22,692 kB
  • ctags: 33,612
  • sloc: ansic: 171,340; tcl: 10,218; sh: 3,821; cpp: 2,779; makefile: 2,041; yacc: 1,648; perl: 456; php: 13
file content (114 lines) | stat: -rw-r--r-- 6,755 bytes parent folder | download | duplicates (2)
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
<HTML><HEAD>
<TITLE>Tcl API Reference -- ns_register_proc</TITLE>
<LINK rel=Previous href="tapi-103.htm">
<LINK rel=ToC href="toc.htm">
<LINK rel=Index href="master.htm">
<LINK rel=Next href="tapi-105.htm">
</HEAD><BODY BGCOLOR="#ffffff"><A NAME="topofpage"></A>
<TABLE WIDTH=100%>
  <TR>
    <TD ALIGN=LEFT>
      <A NAME="topofpage"></A> <IMG  SRC="as-c-sm.gif">
    </TD>
    <TD ALIGN=RIGHT>
      <A href="tapi-103.htm"><IMG  BORDER="0" src=navbprev.gif alt="[ Previous ]"></A>
      <A href=toc.htm> <IMG  BORDER="0" src=navbhome.gif alt="[ Contents ]"></A>
      <A href=master.htm> <IMG  BORDER="0" src=navbhelp.gif alt="[ Index ]"></A>
      <A href="tapi-105.htm"> <IMG  BORDER="0" src=navbnext.gif alt="[ Next ]"></A>
      <A name="7983"> </A>
    </TD>
  </TR>
</TABLE>

<a name="3937">
</a><h3>ns_register_proc</h3>
<a name="54390">
</a><h4>Overview</h4>
<p><a name="3943">
</a>Register one or two procedures for a method/URL combination</p>
<a name="3945">
</a><h4>Syntax</h4>
<p><a name="3949">
</a><b>ns_register_proc</b> ?-noinherit? <i>method URL procname </i>?args?</p>
<p><a name="174460">
</a>proc <i>procname</i> {?<i>conn</i>? <i>args</i>} { </p>
<p><a name="174461">
</a>...  </p>
<p><a name="174462">
</a>}</p>
<a name="3953">
</a><h4>Description</h4>
<p><a name="149014">
</a><b>ns_register_proc</b> registers the procname to handle the specified method/URL combination. When the server gets a matching request, it calls <i>procname</i> with the connection id and any arguments specified here.</p>
<p><a name="149015">
</a>If -noinherit is specified, the requested URL must match the specified URL exactly. For example, if the URL specified with <b>ns_register_proc</b> is /foo/bar, <i>procname</i> will not be called unless the requested URL is exactly /foo/bar.</p>
<p><a name="149016">
</a>If -noinherit is not specified, the requested URL can match the specified URL or any URL below it. For example, if the URL specified with <b>ns_register_proc</b> is /foo/bar, <i>procname</i> will be called for /foo/bar, /foo/bar/hmm, and any other URL below /foo/bar, provided there is not already another procedure registered for that exact URL or for an URL with a closer match.</p>
<p><a name="165538">
</a>Note that you must use a glob-style matching character if you want inheritance for file names. For example, if you want /foo/bar to match /foo/bar.html, you must use:</p>
<pre>    <a name="165536"></a>ns_register_proc /foo/bar*
</pre><p><p><a name="149017">
</a>You can register two procedures for any given method/URL combination by calling <b>ns_register_proc</b> once with the -noinherit flag set and once without it. Only one of the procedures will be called for any given request, depending on whether the URL was an exact match or not. For example:</p>
<pre>    <a name="149018"></a>  ns_register_proc -noinherit GET /foo/bar Aproc
    <a name="149019"></a>  ns_register_proc GET /foo/bar Bproc
    <a name="149020"></a>  ns_register_proc GET /foo/bar/hmm Cproc
</pre><p><p><a name="3961">
</a>Aproc will be called when the requested URL is exactly /foo/bar.  &nbsp;Bproc will be called when the requested URL is below /foo/bar, provided there is not already another procedure registered to be called for that exact URL or for an URL with a closer match. Cproc (not Bproc) will be called when the requested URL is equal to or below /foo/bar/hmm.</p>
<a name="49608">
</a><h4>Syntax for the registered procedure:</h4>
<p><a name="174613">
</a>The <i>conn</i> (connection) argument is optional for procedures registered by <b>ns_register_proc</b> if the procedure has 0 or 1 arguments (not including <i>conn</i>). The following examples show the variations that can be used in this case:</p>
<pre>    <a name="174614"></a>ns_register_proc GET /noargs noargs
    <a name="174615"></a>ns_register_proc GET /context context fnord
    <a name="174616"></a>ns_register_proc GET /conncontext conncontext greeble
    <a name="174617"></a>proc noargs { } {
    <a name="174618"></a>    ns_returnnotice 200 "noargs"
    <a name="174619"></a>} ;# noargs
    <a name="174620"></a>proc context { context } {
    <a name="174621"></a>    ns_returnnotice 200 "context is $context"
    <a name="174622"></a>} ;# context
    <a name="174623"></a>proc conncontext { conn context } {
    <a name="174624"></a>    ns_returnnotice 200 "conncontext is $context"
    <a name="174625"></a>} ;# conncontext
</pre><p><p><a name="174601">
</a></p>
<p><a name="198881">
</a>The <i>conn</i> (connection) argument is required for procedures registered by <b>ns_register_proc</b> if the procedure has 2 or more arguments (not including <i>conn</i>). The <i>conn</i> argument will be filled automatically with the connection information. The first argument following <i>conn</i> will always take the value supplied by <b>ns_register_proc</b>, if there is one, or an empty value. All other arguments must supply a default value. The following examples show the variations that can be used in this case:</p>
<pre>    <a name="198895"></a>ns_register_proc GET /twoargs twoargs fnord
    <a name="198907"></a>ns_register_proc GET /threeargs threeargs fnord fjord
    <a name="198896"></a>proc twoargs { conn context { greeble bork } } {
    <a name="198897"></a>   ...
    <a name="198898"></a>} ;
    <a name="198893"></a>proc threeargs { conn context {greeble bork } { hoover quark } {
    <a name="198913"></a>...
    <a name="198914"></a>} ;
</pre><p><p><a name="198920">
</a>When a GET of /twoargs is requested, the conn argument will be filled automatically, the context argument will be assigned "fnord" and the greeble argument will be assigned the default value "bork".</p>
<p><a name="198923">
</a>When a GET of /threeargs is requested, the conn argument will be filled automatically, the context argument will be assigned "fnord" and the greeble argument will be assigned "fjord", and the hoover argument will be assigned the default value "quark".</p>
<a name="198921">
</a><h4>See Also</h4>
<p><a name="49609">
</a>Ns_RegisterRequest (C API), Ns_UnRegisterRequest (C API)</p>


<TABLE BORDER="2" CELLPADDING="1" width="100%">
<TR><TD COLSPAN=3><P ALIGN=Center>
<IMG SRC="bluebult.gif">
<A HREF="#topofpage">
<FONT SIZE=-1>Top of Page</FONT></A>
<IMG SRC="bluebult.gif">
</TD></TR>
<TR><TD COLSPAN=3><P ALIGN=Center>
<A href="tapi-103.htm">
<IMG  BORDER="0" src=navbprev.gif alt="[ Previous ]"></A>
<A href=toc.htm>
<IMG  BORDER="0" src=navbhome.gif alt="[ Contents ]"></A>
<A href=master.htm>
<IMG  BORDER="0" src=navbhelp.gif alt="[ Index ]"></A>
<A href="tapi-105.htm">
<IMG  BORDER="0" src=navbnext.gif alt="[ Next ]"></A>
<BR align=center>
<FONT size=-1>Copyright &copy; 1998-99 America Online,
Inc.</FONT>
</TD></TR></TABLE></BODY></HTML>