Skip to content

npp_add_host

Jurek Muszyński edited this page Mar 31, 2022 · 4 revisions

bool npp_add_host(const char *host, const char *res, const char *resmin, const char *snippets, char required_auth_level)

Description

Assigns res, resmin and snippets directories to a host. If requested host matches one of those set with npp_add_host, the engine will use these alternative resources instead of those from main res, resmin or snippets.

required_auth_level will be the default required authorization level for the host (overwrittable by npp_require_auth).

Host comparison is case-insensitive and port number is cuf off if present in request.

Directories specified in res, resmin and snippets need to be under NPP_DIR. For the security reasons it's not possible to set absolute path here. For example, setting res for example1.com to example1/res will cause engine to read static resources for that domain from $NPP_DIR/example1/res.

Returns

true if OK, false if NPP_MAX_HOSTS has been reached.

Example

// in npp_app_init()
// Host additional domains on example.com's server:
npp_add_host("foo.com", "foo/res", "foo/resmin", "foo/snippets", AUTH_LEVEL_NONE);
npp_add_host("bar.com", "bar/res", "bar/resmin", "bar/snippets", AUTH_LEVEL_ANONYMOUS);

Notes

Requires NPP_MULTI_HOST compilation switch.

Clone this wiki locally