Merge pull request #2317 from jwillemsen/jwi-deleteop
[ACE_TAO.git] / ACE / apps / JAWS / clients / WebSTONE / src / nsapi-includes / frame / func.h
bloba24df4ea4d05b3c623d578913cca9ae2bf759747
1 /*
2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
3 * rights reserved.
5 * Use of this software is governed by the terms of the license agreement for
6 * the Netscape Communications or Netscape Comemrce Server between the
7 * parties.
8 */
11 /* ------------------------------------------------------------------------ */
15 * func.h: Handles the function hash table
17 * httpd uses a table of internal functions hashed by a name string such that
18 * users can reference specific functions from the configuration files.
20 * Any function referenced by configuration files will be passed a
21 * parameter, a Request structure. The functions do not return anything.
23 * Rob McCool
26 #ifndef FUNC_H
27 #define FUNC_H
30 #include "netsite.h"
31 #include "base/pblock.h"
32 #include "base/session.h" /* Session structure */
33 #include "frame/req.h" /* Request structure */
36 /* -------------------------- Structure and Type -------------------------- */
40 * FuncPtr is a pointer to our kind of functions
43 typedef int Func(pblock *, Session *, Request *);
44 typedef Func *FuncPtr;
47 * FuncStruct is a structure used in the static declaration of the
48 * functions. This static declaration is parsed into a hash table at
49 * startup. You should initialize the next entry to NULL.
52 struct FuncStruct {
53 char *name;
54 FuncPtr func;
55 struct FuncStruct *next;
59 /* --------------------------- Hash definitions --------------------------- */
63 * This is a primitive hash function. Once more is known about the names of
64 * the functions, this will be optimized.
67 #define NUM_HASH 20
68 #define FUNC_HASH(s) (s[0] % NUM_HASH)
71 /* ------------------------------ Prototypes ------------------------------ */
75 * func_init reads the static FuncStruct arrays and creates the global
76 * function table from them.
78 * func_init will only read from the static arrays defined in func.c.
81 void func_init();
84 * func_find returns a pointer to the function named name, or NULL if none
85 * exists.
88 FuncPtr func_find(char *name);
91 * func_exec will try to execute the function whose name is the "fn" entry
92 * in the given pblock. If name is not found, it will log a misconfig of
93 * missing fn parameter. If it can't find it, it will log that. In these
94 * cases it will return REQ_ABORTED. Otherwise, it will return what the
95 * function being executed returns.
98 int func_exec(pblock *pb, Session *sn, Request *rq);
101 * func_insert dynamically inserts a named function into the server's
102 * table of functions. Returns the FuncStruct it keeps in internal
103 * databases, because on server restart you are responsible for freeing
104 * (or not) its contents.
107 struct FuncStruct *func_insert(char *name, FuncPtr fn);
109 #endif